---
tests/fbo/CMakeLists.gl.txt | 1 +
tests/fbo/fbo-5-varyings.c | 347 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 348 insertions(+)
create mode 100644 tests/fbo/fbo-5-varyings.c
diff --git a/tests/fbo/CMakeLists.gl.txt b/tests/fbo/CMakeLists.gl.txt
index cf2a268..935b165 100644
--- a/tests/fbo/CMakeLists.gl.txt
+++ b/tests/fbo/CMakeLists.gl.txt
@@ -93,5 +93,6 @@ piglit_add_executable (fbo-copyteximage-simple
fbo-copyteximage-simple.c)
piglit_add_executable (fbo-cubemap fbo-cubemap.c)
piglit_add_executable (fbo-scissor-bitmap fbo-scissor-bitmap.c)
piglit_add_executable (fbo-viewport fbo-viewport.c)
+piglit_add_executable (fbo-5-varyings fbo-5-varyings.c)
# vim: ft=cmake:
diff --git a/tests/fbo/fbo-5-varyings.c b/tests/fbo/fbo-5-varyings.c
new file mode 100644
index 0000000..d9dbed0
--- /dev/null
+++ b/tests/fbo/fbo-5-varyings.c
@@ -0,0 +1,347 @@
+/*
+ * Copyright (c) 2013 Intel Corporation
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the next
+ * paragraph) shall be included in all copies or substantial portions of the
+ * Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
+ * IN THE SOFTWARE.
+ *
+ */
+
+/** @file fbo-5-varyings.c
+ *
+ * This test reproduces issue that causes the Steam Big Picture
+ * portion of Mesa bugzilla #56920.
+ */
+
+#include "piglit-util-gl-common.h"
+
+#define SIZE 128
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+ config.supports_gl_compat_version = 10;
+ config.window_width = SIZE;
+ config.window_height = SIZE;
+ config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_ALPHA |
PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+static GLuint prog0, prog1;
+static GLuint tex0, tex1;
+static GLuint fb0, fb1;
+
+static GLfloat red[4] = { 1.0f, 0.0f, 0.0f, 1.0f };
+static GLfloat green[4] = { 0.0f, 1.0f, 0.0f, 1.0f };
+static GLfloat blue[4] = { 0.0f, 0.0f, 1.0f, 1.0f };
+static GLfloat white[4] = { 1.0f, 1.0f, 1.0f, 1.0f };
+
+static GLuint make_prog0();
+static GLuint make_prog1();
+
+static GLboolean
+run_programs(GLenum mode0, GLenum mode1)
+{
+ GLboolean pass = GL_TRUE;
+
+ /* tex0/fb0 drawing
+ *
+ * We draw 2 small squares inside the red/green quadrants
+ *
+ * The fragment shader colors the small boxes red and green,
+ * so they are not a different color. This makes using
+ * piglit_probe_rect_rgba easier.
+ *
+ * Thus drawing step ought to be a no-op, but it is important
+ * so that corruption happens when prog1 is used.
+ */
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb0);
+ glBindTexture(GL_TEXTURE_2D, tex0);
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER, fb0);
+ glViewport(0, 0, SIZE, SIZE);
+ glUseProgram(prog0);
+
+ switch (mode0) {
+ case GL_TRIANGLE_STRIP:
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex4f(-0.9, -0.8, 0, 1);
+ glVertex4f(-0.9, -0.9, 0, 1);
+ glVertex4f(-0.8, -0.8, 0, 1);
+ glVertex4f(-0.8, -0.9, 0, 1);
+ glEnd();
+
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex4f( 0.8, -0.8, 0, 1);
+ glVertex4f( 0.8, -0.9, 0, 1);
+ glVertex4f( 0.9, -0.8, 0, 1);
+ glVertex4f( 0.9, -0.9, 0, 1);
+ glEnd();
+ break;
+ case GL_QUADS:
+ glBegin(GL_QUADS);
+ glVertex4f(-0.9, -0.8, 0, 1);
+ glVertex4f(-0.9, -0.9, 0, 1);
+ glVertex4f(-0.8, -0.9, 0, 1);
+ glVertex4f(-0.8, -0.8, 0, 1);
+ glVertex4f( 0.8, -0.8, 0, 1);
+ glVertex4f( 0.8, -0.9, 0, 1);
+ glVertex4f( 0.9, -0.9, 0, 1);
+ glVertex4f( 0.9, -0.8, 0, 1);
+ glEnd();
+ break;
+ }
+
+ glBindTexture(GL_TEXTURE_2D, 0);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);
+
+ glViewport(0, 0, SIZE, SIZE);
+
+ assert(glGetError() == 0);
+
+ /* tex1/fb1 drawing
+ *
+ * We now use tex0 to draw onto fb1. The drawing may now be corrupted
+ * if the behavior causing bug #56920 is reproduced.
+ */
+
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb1);
+
+ glEnable(GL_TEXTURE_2D);
+ glBindTexture(GL_TEXTURE_2D, tex0);
+
+ glViewport(0, 0, piglit_width, piglit_height);
+ glUseProgram(prog1);
+ glUniform1i(glGetUniformLocation(prog1, "Texture0"), 0);
+ glBindTexture(GL_TEXTURE_2D, tex0);
+
+ switch (mode1) {
+ case GL_TRIANGLE_STRIP:
+ glBegin(GL_TRIANGLE_STRIP);
+ glVertex4f(-1.0, 1.0, 0, 1);
+ glVertex4f( 1.0, 1.0, 0, 1);
+ glVertex4f(-1.0, -1.0, 0, 1);
+ glVertex4f( 1.0, -1.0, 0, 1);
+ glEnd();
+ break;
+ case GL_TRIANGLE_FAN:
+ glBegin(GL_TRIANGLE_FAN);
+ glVertex4f(-1.0, 1.0, 0, 1);
+ glVertex4f( 1.0, 1.0, 0, 1);
+ glVertex4f( 1.0, -1.0, 0, 1);
+ glVertex4f(-1.0, -1.0, 0, 1);
+ glEnd();
+ break;
+ case GL_QUADS:
+ glBegin(GL_QUADS);
+ glVertex4f(-1.0, 1.0, 0, 1);
+ glVertex4f( 1.0, 1.0, 0, 1);
+ glVertex4f( 1.0, -1.0, 0, 1);
+ glVertex4f(-1.0, -1.0, 0, 1);
+ glEnd();
+ break;
+ }
+
+ glBindFramebufferEXT(GL_READ_FRAMEBUFFER, fb1);
+ glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER, 0);
+ glBlitFramebuffer(0, 0, piglit_width, piglit_height,
+ 0, 0, piglit_width, piglit_height,
+ GL_COLOR_BUFFER_BIT, GL_NEAREST);
+
+ /* Check that RGBW texture appeared correctly */
+
+ pass = pass && piglit_probe_rect_rgba(0, 0,
+ SIZE / 2, SIZE / 2,
+ red);
+ pass = pass && piglit_probe_rect_rgba(SIZE / 2, 0,
+ SIZE / 2, SIZE / 2,
+ green);
+ pass = pass && piglit_probe_rect_rgba(0, SIZE / 2,
+ SIZE / 2, SIZE / 2,
+ blue);
+ pass = pass && piglit_probe_rect_rgba(SIZE / 2, SIZE / 2,
+ SIZE / 2, SIZE / 2,
+ white);
+
+ return pass;
+}
+
+enum piglit_result
+piglit_display(void)
+{
+ GLboolean pass = GL_TRUE;
+ GLenum status;
+
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+
+ /* tex0/fb0 init */
+
+ glGenFramebuffersEXT(1, &fb0);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb0);
+
+ tex0 = piglit_rgbw_texture(
+ GL_RGBA8,
+ SIZE, SIZE,
+ GL_FALSE,
+ GL_FALSE,
+ GL_UNSIGNED_NORMALIZED);
+
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT + 0,
+ GL_TEXTURE_2D,
+ tex0,
+ 0);
+ assert(glGetError() == 0);
+
+ /* tex1/fb1 init */
+
+ tex1 = piglit_rgbw_texture(
+ GL_RGBA8,
+ SIZE, SIZE,
+ GL_FALSE,
+ GL_FALSE,
+ GL_UNSIGNED_NORMALIZED);
+
+ glGenFramebuffersEXT(1, &fb1);
+ glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb1);
+
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT,
+ GL_COLOR_ATTACHMENT0_EXT + 0,
+ GL_TEXTURE_2D,
+ tex1,
+ 0);
+ assert(glGetError() == 0);
+
+ status = glCheckFramebufferStatusEXT (GL_FRAMEBUFFER_EXT);
+ if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+ fprintf(stderr, "fbo incomplete (status = 0x%04x)\n", status);
+ piglit_report_result(PIGLIT_SKIP);
+ }
+
+ pass = pass && run_programs(GL_TRIANGLE_STRIP, GL_TRIANGLE_STRIP);
+ pass = pass && run_programs(GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN);
+ pass = pass && run_programs(GL_TRIANGLE_STRIP, GL_QUADS);
+ pass = pass && run_programs(GL_QUADS, GL_TRIANGLE_STRIP);
+ pass = pass && run_programs(GL_QUADS, GL_TRIANGLE_FAN);
+ pass = pass && run_programs(GL_QUADS, GL_QUADS);
+
+ piglit_present_results();
+
+ return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+ piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+ piglit_require_extension("GL_EXT_framebuffer_object");
+ piglit_require_extension("GL_ARB_draw_buffers");
+ piglit_require_extension("GL_ARB_fragment_program");
+ piglit_require_extension("GL_ARB_vertex_program");