[Piglit] [PATCH] Add test case to verify glClearBuffer support in display list
Anuj Phogat
anuj.phogat at gmail.com
Wed Dec 14 14:06:04 PST 2011
Adding a test case to verify that glClearBuffer[fui]v functions are supported
in display lists
Signed-off-by: Anuj Phogat <anuj.phogat at gmail.com>
---
This test case depends on few functions defined in patch sent for
clearbuffer-mixed-format test case.
tests/all.tests | 1 +
tests/spec/gl-3.0/api/CMakeLists.gl.txt | 1 +
tests/spec/gl-3.0/api/clearbuffer-display-list.c | 212 ++++++++++++++++++++++
3 files changed, 214 insertions(+), 0 deletions(-)
create mode 100644 tests/spec/gl-3.0/api/clearbuffer-display-list.c
diff --git a/tests/all.tests b/tests/all.tests
index 8bfd373..0dd6428 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -810,6 +810,7 @@ add_concurrent_test(gl30, 'clearbuffer-invalid-drawbuffer')
add_concurrent_test(gl30, 'clearbuffer-invalid-buffer')
add_concurrent_test(gl30, 'clearbuffer-stencil')
add_concurrent_test(gl30, 'clearbuffer-mixed-format')
+add_concurrent_test(gl30, 'clearbuffer-display-list')
add_concurrent_test(gl30, 'getfragdatalocation')
gl30['minmax'] = concurrent_test('gl-3.0-minmax')
add_concurrent_test(gl30, 'gl-3.0-required-sized-texture-formats')
diff --git a/tests/spec/gl-3.0/api/CMakeLists.gl.txt b/tests/spec/gl-3.0/api/CMakeLists.gl.txt
index 5a34380..3b54b4a 100644
--- a/tests/spec/gl-3.0/api/CMakeLists.gl.txt
+++ b/tests/spec/gl-3.0/api/CMakeLists.gl.txt
@@ -19,6 +19,7 @@ add_executable (clearbuffer-invalid-drawbuffer clearbuffer-invalid-drawbuffer.c)
add_executable (clearbuffer-invalid-buffer clearbuffer-invalid-buffer.c)
add_executable (clearbuffer-stencil clearbuffer-common.c clearbuffer-stencil.c)
add_executable (clearbuffer-mixed-format clearbuffer-common.c clearbuffer-mixed-format.c)
+add_executable (clearbuffer-display-list clearbuffer-common.c clearbuffer-display-list.c)
add_executable (getfragdatalocation getfragdatalocation.c)
# vim: ft=cmake:
diff --git a/tests/spec/gl-3.0/api/clearbuffer-display-list.c b/tests/spec/gl-3.0/api/clearbuffer-display-list.c
new file mode 100644
index 0000000..f7af75a
--- /dev/null
+++ b/tests/spec/gl-3.0/api/clearbuffer-display-list.c
@@ -0,0 +1,212 @@
+/* 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.
+ */
+
+/**
+ * \file clearbuffer-display-list.c
+ * Verify glClearBufferfv/glClearBufferiv/glClearBufferuiv are supported in
+ * display lists
+ *
+ * This test works by generating several mixed foarmt color framebuffer objects
+ * and attempting to clear the color buffer of those FBOs using display lists.
+ *
+ * \author Anuj Phogat
+ */
+
+#include "piglit-util.h"
+#include "clearbuffer-common.h"
+
+#define COUNT ARRAY_SIZE(test_vectors)
+
+void piglit_init(int argc, char **argv)
+{
+ static const float fcolor[4][4] = {
+ { 0.5, 0.3, 0.7, 0.0 },
+ { 0.8, 0.0, 0.2, 1.0 },
+ { 1.2, -2.9, 0.2, 5.8 },
+ { 0.5, 2.5, -5.2, 1.0 } };
+
+ static const unsigned int uicolor[4][4] = {
+ { 10, 90, 100, 150 },
+ { 100, 190, 200, 15 },
+ { 15, 25, 20, 15 },
+ { 10, 80, 0, 25 }, };
+
+ static const int icolor[4][4] = {
+ { -10, -90, 100, 15 },
+ { 100, 190, 200, -15 },
+ { -50, -50, -50, 50 },
+ { -80, 170, 0, 0 } };
+
+ static const struct {
+ GLenum fb_format;
+ GLenum rp_format;
+ GLenum type;
+ GLvoid *clear_color;
+ } test_vectors[] = {
+ /* GL_RGBA8, GL_RGBA16 clamps the color vaues to [0, 1] */
+ { GL_RGBA8, GL_RGBA,
+ GL_FLOAT, (GLvoid *)fcolor[0] },
+ { GL_RGBA16, GL_RGBA,
+ GL_FLOAT, (GLvoid *)fcolor[1] },
+
+ /* GL_RGBA16F, GL_RGBA32F doesn't clamp color values to [0, 1] */
+ { GL_RGBA16F, GL_RGBA,
+ GL_FLOAT, (GLvoid *)fcolor[2] },
+ { GL_RGBA32F, GL_RGBA,
+ GL_FLOAT, (GLvoid *)fcolor[3] },
+
+ /* Integer formats */
+ { GL_RGBA8UI, GL_RGBA_INTEGER,
+ GL_UNSIGNED_INT, (GLvoid *)uicolor[0] },
+ { GL_RGBA16UI, GL_RGBA_INTEGER,
+ GL_UNSIGNED_INT, (GLvoid *)uicolor[1] },
+ { GL_RGBA32UI, GL_RGBA_INTEGER,
+ GL_UNSIGNED_INT, (GLvoid *)uicolor[2] },
+
+ { GL_RGBA8I, GL_RGBA_INTEGER,
+ GL_INT, (GLvoid *)icolor[0] },
+ { GL_RGBA16I, GL_RGBA_INTEGER,
+ GL_INT, (GLvoid *)icolor[1] },
+ { GL_RGBA32I, GL_RGBA_INTEGER,
+ GL_INT, (GLvoid *)icolor[2] },
+ };
+
+ GLuint fb[COUNT], index;
+ bool pass = true;
+ GLenum err;
+ int i, j;
+
+ piglit_require_gl_version(30);
+ index = glGenLists(COUNT);
+
+
+ for (i = 0; i < COUNT; i++) {
+ fb[i] = generate_color_fbo(test_vectors[i].fb_format);
+
+ if (fb[i] == 0) {
+ if (!piglit_automatic) {
+ printf("Skipping framebuffer %d with color"
+ " renderbuffer attachment\n",
+ i);
+ }
+ }
+ if (!piglit_automatic)
+ printf("Created framebuffer %d with a color"
+ " renderbuffer attachment\n",
+ i);
+
+ /* Make display list to clear color buffer to a unique color */
+ switch (test_vectors[i].type) {
+
+ /*Float buffer types*/
+ case GL_FLOAT:
+ glNewList(index + i, GL_COMPILE);
+ glClearBufferfv(GL_COLOR,
+ 0,
+ (GLfloat *)test_vectors[i].clear_color);
+ glEndList();
+
+ glCallList(index + i);
+ /* Test the pixel values of color buffer against
+ * expected color values
+ */
+ pass = pass && probe_rect_color(0,
+ 0,
+ piglit_width, piglit_height,
+ test_vectors[i].rp_format,
+ test_vectors[i].type,
+ test_vectors[i].clear_color);
+ break;
+
+ /* Signed/unsigned integer buffer types */
+ case GL_INT:
+ glNewList(index + i, GL_COMPILE);
+ glClearBufferiv(GL_COLOR,
+ 0,
+ (GLint *)test_vectors[i].clear_color);
+ glEndList();
+
+ glCallList(index + i);
+ /* Test the pixel values of color buffer against
+ * expected color values
+ */
+ pass = pass && probe_rect_color(0,
+ 0,
+ piglit_width, piglit_height,
+ test_vectors[i].rp_format,
+ test_vectors[i].type,
+ test_vectors[i].clear_color);
+ break;
+
+ case GL_UNSIGNED_INT:
+ glNewList(index + i, GL_COMPILE);
+ glClearBufferuiv(GL_COLOR,
+ 0,
+ (GLuint *)test_vectors[i].clear_color);
+ glEndList();
+
+ glCallList(index + i);
+ /* Test the pixel values of color buffer against
+ * expected color values
+ */
+ pass = pass && probe_rect_color(0,
+ 0,
+ piglit_width, piglit_height,
+ test_vectors[i].rp_format,
+ test_vectors[i].type,
+ test_vectors[i].clear_color);
+ break;
+
+ }
+
+ /* Check GL error */
+ err = glGetError();
+ if (err != GL_NO_ERROR) {
+ piglit_get_gl_error_name(err);
+ pass = false;
+ }
+
+ /* Test the color buffer values of all existing FBOs against
+ * their expected color values. Previously issued glClearBuffer
+ * functions (in display list) should not modify color buffers
+ * of other existing FBOs
+ */
+ for (j = 0; j < i; j++)
+ {
+ /* Bind previously created FBO */
+ glBindFramebuffer(GL_FRAMEBUFFER, fb[j]);
+ pass = pass && probe_rect_color(0,
+ 0,
+ piglit_width, piglit_height,
+ test_vectors[j].rp_format,
+ test_vectors[j].type,
+ test_vectors[j].clear_color);
+ }
+ }
+ /* Delete all generated framebuffer objects */
+ glDeleteFramebuffers(COUNT, fb);
+ /* Delete all display lists */
+ glDeleteLists(index, COUNT);
+ piglit_check_gl_error(GL_NO_ERROR, PIGLIT_FAIL);
+ piglit_present_results();
+ piglit_report_result(pass ? PIGLIT_PASS : PIGLIT_FAIL);
+}
--
1.7.7.4
More information about the Piglit
mailing list