[Piglit] [PATCH 2/3] GL 3.2: Test that Clear() clears no buffers when passed a value of 0

Nicholas Mack nichmack at gmail.com
Tue Aug 6 10:29:35 PDT 2013


---
 tests/spec/gl-3.2/CMakeLists.gl.txt  |  2 +-
 tests/spec/gl-3.2/clear-no-buffers.c | 90 ++++++++++++++++++++++++++++++++++++
 2 files changed, 91 insertions(+), 1 deletion(-)
 create mode 100644 tests/spec/gl-3.2/clear-no-buffers.c

diff --git a/tests/spec/gl-3.2/CMakeLists.gl.txt b/tests/spec/gl-3.2/CMakeLists.gl.txt
index 49e9279..1e2225a 100644
--- a/tests/spec/gl-3.2/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.2/CMakeLists.gl.txt
@@ -10,6 +10,6 @@ link_libraries (
 )
 
 piglit_add_executable (gl-3.2-minmax minmax.c)
-piglit_add_executable (gl-3.2-draw-buffers-errors draw-buffers-errors.c)
+piglit_add_executable (gl-3.2-clear-none clear-no-buffers.c)
 
 # vim: ft=cmake:
diff --git a/tests/spec/gl-3.2/clear-no-buffers.c b/tests/spec/gl-3.2/clear-no-buffers.c
new file mode 100644
index 0000000..52566fc
--- /dev/null
+++ b/tests/spec/gl-3.2/clear-no-buffers.c
@@ -0,0 +1,90 @@
+/**
+ * Copyright © 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.
+ */
+
+/**
+ * Test that Clear() clears no buffers when passed 0
+ *
+ * Section 4.2.3(Clearing the Buffers) of OpenGL 3.2 Core says:
+ * "The value to which each buffer is cleared depends on the setting of the
+ *  clear value for that buffer. If buf is zero, no buffers are cleared."
+ *
+ */
+
+#include "piglit-util-gl-common.h"
+
+PIGLIT_GL_TEST_CONFIG_BEGIN
+
+	config.supports_gl_compat_version = 10;
+        //config.supports_gl_core_version = 32;
+
+        config.window_width = 64;
+        config.window_height = 64;
+        config.window_visual = PIGLIT_GL_VISUAL_RGB |
+				PIGLIT_GL_VISUAL_DOUBLE |
+				PIGLIT_GL_VISUAL_DEPTH |
+				PIGLIT_GL_VISUAL_STENCIL;
+
+PIGLIT_GL_TEST_CONFIG_END
+
+//static GLuint fbo;
+
+void
+piglit_init(int argc, char **argv)
+{
+	//glGenFramebuffers(1, &fbo);
+}
+
+enum piglit_result
+piglit_display(void)
+{
+	bool pass = true;
+	float green[] = {0, 1, 0};
+
+	glEnable(GL_DEPTH_TEST);
+	//glDepthFunc(GL_LEQUAL);
+
+	/* Set first base values to the buffers */
+	glClearColor(0.0, 1.0, 0.0, 1.0);
+	glClearDepth(.8);
+	glClearStencil(1);
+	//glClearBufferfi(GL_DEPTH_STENCIL, 0, .8, 1);
+	glClear(GL_COLOR_BUFFER_BIT |
+		GL_DEPTH_BUFFER_BIT |
+		GL_STENCIL_BUFFER_BIT);
+
+	/* Set a second value to the buffers */
+	glClearColor(1.0, 0.0, 0.0, 1.0);
+	glClearDepth(.2);
+	glClearStencil(2);
+
+	glClear(0);
+
+	/* if probe returns the first value, glClear(0) didn't clear values */
+	pass = piglit_probe_pixel_rgb(32, 32, green) && pass;
+	pass = piglit_probe_pixel_depth(32, 32, .8) && pass;
+	pass = piglit_probe_pixel_stencil(32, 32, 1) && pass;
+
+	piglit_present_results();
+
+	return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
-- 
1.8.3.1



More information about the Piglit mailing list