[Piglit] [PATCH 1/4] GL_ARB_framebuffer_sRGB: Add a new test for glPopAttrib() behavior.

Eric Anholt eric at anholt.net
Wed Aug 1 16:04:02 PDT 2012


---
 tests/spec/CMakeLists.txt                         |    1 +
 tests/spec/arb_framebuffer_srgb/CMakeLists.gl.txt |   12 +++
 tests/spec/arb_framebuffer_srgb/CMakeLists.txt    |    1 +
 tests/spec/arb_framebuffer_srgb/pushpop.c         |   97 +++++++++++++++++++++
 4 files changed, 111 insertions(+)
 create mode 100644 tests/spec/arb_framebuffer_srgb/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_framebuffer_srgb/CMakeLists.txt
 create mode 100644 tests/spec/arb_framebuffer_srgb/pushpop.c

diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index 6021492..cd374d1 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -3,6 +3,7 @@ add_subdirectory (arb_debug_output)
 add_subdirectory (arb_draw_instanced)
 add_subdirectory (arb_es2_compatibility)
 add_subdirectory (arb_framebuffer_object)
+add_subdirectory (arb_framebuffer_srgb)
 add_subdirectory (arb_instanced_arrays)
 add_subdirectory (arb_map_buffer_range)
 add_subdirectory (arb_multisample)
diff --git a/tests/spec/arb_framebuffer_srgb/CMakeLists.gl.txt b/tests/spec/arb_framebuffer_srgb/CMakeLists.gl.txt
new file mode 100644
index 0000000..f4ef120
--- /dev/null
+++ b/tests/spec/arb_framebuffer_srgb/CMakeLists.gl.txt
@@ -0,0 +1,12 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+	piglitutil_${piglit_target_api}
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (arb_framebuffer_srgb-pushpop pushpop.c)
diff --git a/tests/spec/arb_framebuffer_srgb/CMakeLists.txt b/tests/spec/arb_framebuffer_srgb/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_framebuffer_srgb/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_framebuffer_srgb/pushpop.c b/tests/spec/arb_framebuffer_srgb/pushpop.c
new file mode 100644
index 0000000..8fb639d
--- /dev/null
+++ b/tests/spec/arb_framebuffer_srgb/pushpop.c
@@ -0,0 +1,97 @@
+/*
+ * Copyright © 2011 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.
+ */
+
+#include "piglit-util-gl-common.h"
+
+/**
+ * @file pushpop.c
+ *
+ * Tests that GL_FRAMEBUFFER_SRGB is under the color-buffer/enable
+ * push/pop bits.
+ */
+
+PIGLIT_GL_TEST_MAIN(
+    32 /*window_width*/,
+    32 /*window_height*/,
+    GLUT_DOUBLE | GLUT_RGB | GLUT_ALPHA)
+
+enum piglit_result
+piglit_display(void)
+{
+	/* UNREACHED */
+	return PIGLIT_FAIL;
+}
+
+static bool
+test_enabled(bool val)
+{
+	GLboolean ret = glIsEnabled(GL_FRAMEBUFFER_SRGB);
+
+	if (ret != val) {
+		fprintf(stderr,
+			"  GL_FRAMEBUFFER_SRGB %d doesn't match expected %d\n",
+			ret, val);
+		return false;
+	} else {
+		return true;
+	}
+}
+
+static bool
+pushpop(GLuint bits, const char *test)
+{
+	bool pushpop_affects = (bits & (GL_ENABLE_BIT |
+					GL_COLOR_BUFFER_BIT)) != 0;
+	printf("%s test:\n", test);
+
+	glEnable(GL_FRAMEBUFFER_SRGB);
+	glPushAttrib(bits);
+	glDisable(GL_FRAMEBUFFER_SRGB);
+	glPopAttrib();
+
+	if (!test_enabled(pushpop_affects))
+		return false;
+
+	/* Now, test the bits the other direction. */
+	glDisable(GL_FRAMEBUFFER_SRGB);
+	glPushAttrib(bits);
+	glEnable(GL_FRAMEBUFFER_SRGB);
+	glPopAttrib();
+
+	return test_enabled(!pushpop_affects);
+}
+
+void
+piglit_init(int argc, char **argv)
+{
+	bool pass = true;
+
+	if (!piglit_is_extension_supported("GL_EXT_framebuffer_sRGB"))
+		piglit_require_extension("GL_ARB_framebuffer_sRGB");
+
+	pass = pushpop(GL_ENABLE_BIT, "GL_ENABLE_BIT") && pass;
+	pass = pushpop(GL_COLOR_BUFFER_BIT, "GL_COLOR_BUFFER_BIT") && pass;
+	pass = pushpop(GL_FOG_BIT, "GL_FOG_BIT") && pass;
+
+	piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
-- 
1.7.10.4



More information about the Piglit mailing list