[1/1] Add a test for rendering with the first draw buffer binding set to GL_NONE.

Submitted by Henri Verbeet on Dec. 25, 2013, 11:40 a.m.

Details

Message ID 1387971650-4760-1-git-send-email-hverbeet@gmail.com
State New
Headers show

Not browsing as part of any series.

Commit Message

Henri Verbeet Dec. 25, 2013, 11:40 a.m.
This currently segfaults on at least the Gallium based drivers.

Signed-off-by: Henri Verbeet <hverbeet@gmail.com>
---
 tests/all.tests                               |    1 +
 tests/spec/arb_draw_buffers/CMakeLists.gl.txt |    1 +
 tests/spec/arb_draw_buffers/rt0_none.c        |   96 +++++++++++++++++++++++++
 3 files changed, 98 insertions(+)
 create mode 100644 tests/spec/arb_draw_buffers/rt0_none.c

Patch hide | download patch | download mbox

diff --git a/tests/all.tests b/tests/all.tests
index edf066b..e495f31 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -2693,6 +2693,7 @@  arb_vertex_type_2_10_10_10_rev['attribs'] = concurrent_test('attribs GL_ARB_vert
 
 arb_draw_buffers = Group()
 spec['ARB_draw_buffers'] = arb_draw_buffers
+add_concurrent_test(arb_draw_buffers, 'arb_draw_buffers-rt0_none')
 add_plain_test(arb_draw_buffers, 'arb_draw_buffers-state_change')
 add_plain_test(arb_draw_buffers, 'fbo-mrt-alphatest')
 
diff --git a/tests/spec/arb_draw_buffers/CMakeLists.gl.txt b/tests/spec/arb_draw_buffers/CMakeLists.gl.txt
index 88af1f3..c94a01e 100644
--- a/tests/spec/arb_draw_buffers/CMakeLists.gl.txt
+++ b/tests/spec/arb_draw_buffers/CMakeLists.gl.txt
@@ -9,6 +9,7 @@  link_libraries (
 	${OPENGL_glu_LIBRARY}
 )
 
+piglit_add_executable (arb_draw_buffers-rt0_none rt0_none.c)
 piglit_add_executable (arb_draw_buffers-state_change state_change.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/arb_draw_buffers/rt0_none.c b/tests/spec/arb_draw_buffers/rt0_none.c
new file mode 100644
index 0000000..df8407a
--- /dev/null
+++ b/tests/spec/arb_draw_buffers/rt0_none.c
@@ -0,0 +1,96 @@ 
+/*
+ * Copyright © 2013 Henri Verbeet <hverbeet@gmail.com>
+ *
+ * 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 rt0_none.c
+ *
+ * Test rendering with the first draw buffer binding set to GL_NONE, and the
+ * second to GL_COLOR_ATTACHMENT0_EXT.
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+enum piglit_result
+piglit_display(void)
+{
+	static const float green[] = {0.0f, 1.0f, 0.0f, 1.0f};
+	static const float blue[] = {0.0f, 0.0f, 1.0f, 1.0f};
+	bool pass = true;
+
+	glClearColor(0.0, 0.0, 1.0, 1.0);
+	glClear(GL_COLOR_BUFFER_BIT);
+	pass = piglit_probe_rect_rgba(0, 0,
+				      piglit_width, piglit_height,
+				      blue) && pass;
+
+	glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
+	piglit_ortho_projection(piglit_width, piglit_height, false);
+	piglit_draw_rect(0, 0, piglit_width, piglit_height);
+	pass = piglit_probe_rect_rgba(0, 0,
+				      piglit_width, piglit_height,
+				      green) && pass;
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	static const GLenum buffers[] = {GL_NONE, GL_COLOR_ATTACHMENT0_EXT};
+	GLuint fbo, tex;
+	GLenum status;
+	GLint i;
+
+	piglit_require_extension("GL_EXT_framebuffer_object");
+	piglit_require_extension("GL_ARB_draw_buffers");
+	glGetIntegerv(GL_MAX_DRAW_BUFFERS_ARB, &i);
+	if (i < 2) {
+		printf("2 draw buffers required, %d reported.\n", i);
+		piglit_report_result(PIGLIT_SKIP);
+	}
+
+	glGenTextures(1, &tex);
+	glBindTexture(GL_TEXTURE_2D, tex);
+	glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, piglit_width, piglit_height,
+		     0, GL_RGBA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
+
+	glGenFramebuffersEXT(1, &fbo);
+	glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo);
+	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT,
+				  GL_TEXTURE_2D, tex, 0);
+	glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);
+	glDrawBuffersARB(2, buffers);
+
+	status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
+	if (status != GL_FRAMEBUFFER_COMPLETE_EXT) {
+		printf("FBO incomplete, status %#x.\n", status);
+		piglit_report_result(PIGLIT_FAIL);
+	}
+}