[Piglit] [PATCH] texture_rgb10_a2ui: testing drawing with an rgb10_a2ui texture

Jordan Justen jordan.l.justen at intel.com
Thu Jun 7 15:34:03 PDT 2012


Signed-off-by: Jordan Justen <jordan.l.justen at intel.com>
---
 tests/all.tests                                    |    7 +-
 tests/spec/CMakeLists.txt                          |    1 +
 .../spec/arb_texture_rgb10_a2ui/CMakeLists.gl.txt  |   13 ++
 tests/spec/arb_texture_rgb10_a2ui/CMakeLists.txt   |    1 +
 tests/spec/arb_texture_rgb10_a2ui/rgb10_a2ui.c     |  191 ++++++++++++++++++++
 5 files changed, 210 insertions(+), 3 deletions(-)
 create mode 100644 tests/spec/arb_texture_rgb10_a2ui/CMakeLists.gl.txt
 create mode 100644 tests/spec/arb_texture_rgb10_a2ui/CMakeLists.txt
 create mode 100644 tests/spec/arb_texture_rgb10_a2ui/rgb10_a2ui.c

diff --git a/tests/all.tests b/tests/all.tests
index 129a923..703bf5d 100644
--- a/tests/all.tests
+++ b/tests/all.tests
@@ -1512,9 +1512,10 @@ add_texwrap_test2(arb_texture_rg, '2D', 'GL_RG16F')
 add_texwrap_test2(arb_texture_rg, '2D', 'GL_R32F')
 add_texwrap_test2(arb_texture_rg, '2D', 'GL_RG32F')
 
-ext_texture_rgb10_a2ui = Group()
-spec['EXT_texture_rgb10_a2ui'] = ext_texture_rgb10_a2ui
-ext_texture_rgb10_a2ui['fbo-blending'] = concurrent_test('ext_texture_integer-fbo-blending GL_ARB_texture_rgb10_a2ui')
+arb_texture_rgb10_a2ui = Group()
+spec['ARB_texture_rgb10_a2ui'] = arb_texture_rgb10_a2ui
+arb_texture_rgb10_a2ui['fbo-blending'] = concurrent_test('ext_texture_integer-fbo-blending GL_ARB_texture_rgb10_a2ui')
+add_plain_test(arb_texture_rgb10_a2ui, 'arb_texture_rgb10_a2ui')
 
 ext_texture_shared_exponent = Group()
 spec['EXT_texture_shared_exponent'] = ext_texture_shared_exponent
diff --git a/tests/spec/CMakeLists.txt b/tests/spec/CMakeLists.txt
index a0186d3..3dea9a0 100644
--- a/tests/spec/CMakeLists.txt
+++ b/tests/spec/CMakeLists.txt
@@ -17,6 +17,7 @@ add_subdirectory (ati_draw_buffers)
 add_subdirectory (arb_texture_buffer_object)
 add_subdirectory (arb_texture_compression)
 add_subdirectory (arb_texture_float)
+add_subdirectory (arb_texture_rgb10_a2ui)
 add_subdirectory (arb_texture_storage)
 add_subdirectory (arb_transform_feedback2)
 add_subdirectory (ati_envmap_bumpmap)
diff --git a/tests/spec/arb_texture_rgb10_a2ui/CMakeLists.gl.txt b/tests/spec/arb_texture_rgb10_a2ui/CMakeLists.gl.txt
new file mode 100644
index 0000000..0093bff
--- /dev/null
+++ b/tests/spec/arb_texture_rgb10_a2ui/CMakeLists.gl.txt
@@ -0,0 +1,13 @@
+include_directories(
+	${GLEXT_INCLUDE_DIR}
+	${OPENGL_INCLUDE_PATH}
+)
+
+link_libraries (
+	piglitutil
+	${OPENGL_gl_LIBRARY}
+	${OPENGL_glu_LIBRARY}
+)
+
+piglit_add_executable (arb_texture_rgb10_a2ui rgb10_a2ui.c)
+
diff --git a/tests/spec/arb_texture_rgb10_a2ui/CMakeLists.txt b/tests/spec/arb_texture_rgb10_a2ui/CMakeLists.txt
new file mode 100644
index 0000000..144a306
--- /dev/null
+++ b/tests/spec/arb_texture_rgb10_a2ui/CMakeLists.txt
@@ -0,0 +1 @@
+piglit_include_target_api()
diff --git a/tests/spec/arb_texture_rgb10_a2ui/rgb10_a2ui.c b/tests/spec/arb_texture_rgb10_a2ui/rgb10_a2ui.c
new file mode 100644
index 0000000..4d789d0
--- /dev/null
+++ b/tests/spec/arb_texture_rgb10_a2ui/rgb10_a2ui.c
@@ -0,0 +1,191 @@
+/*
+ * Copyright 2010 VMware, Inc.
+ * Copyright (c) 2012 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 GL_ARB_texture_rgb10_a2ui and/or GL 3.1 texture_rgb10_a2ui.
+ */
+
+#include "piglit-util.h"
+
+#define GRID_SIZE 50
+#define WIN_WIDTH  (GRID_SIZE)
+#define WIN_HEIGHT (GRID_SIZE)
+
+int piglit_width = WIN_WIDTH, piglit_height = WIN_HEIGHT;
+int piglit_window_mode = GLUT_RGB | GLUT_DOUBLE;
+
+static int tex_loc;
+
+static const GLfloat white[4]  = {1.0, 1.0, 1.0, 1.0};
+static const GLfloat red[4]    = {1.0, 0.0, 0.0, 1.0};
+static const GLfloat green[4]  = {0.0, 1.0, 0.0, 1.0};
+static const GLfloat blue[4]   = {0.0, 0.0, 1.0, 1.0};
+static const GLfloat yellow[4] = {1.0, 1.0, 0.0, 1.0};
+static const GLfloat black[4]  = {0.0, 0.0, 0.0, 0.0};
+
+#define PRIMS 4
+
+#define POINT(x, y) { ((((GLfloat)(x)) * 2.0) - 1.0), \
+                      ((((GLfloat)(y)) * 2.0) - 1.0) }
+
+static const GLfloat verts[PRIMS][2] = {
+   POINT(0, 0),
+   POINT(0, 1),
+   POINT(1, 0),
+   POINT(1, 1),
+};
+
+#define RGB10_A2UI_COLOR(r, g, b, a) (((GLuint)(r) << 22) | ((GLuint)(g) << 12) | ((GLuint)(b) << 2) | (GLuint)(a))
+
+static const GLuint texdata[4] = {
+   RGB10_A2UI_COLOR(1023,    0,    0, 3), // Red
+   RGB10_A2UI_COLOR(0,    1023,    0, 3), // Green
+   RGB10_A2UI_COLOR(0,       0, 1023, 3), // Blue
+   RGB10_A2UI_COLOR(1023, 1023,    0, 3), // Yellow
+};
+
+
+static GLboolean
+check_rendering(void)
+{
+   int upper = piglit_height - 1;
+   int right = piglit_width - 1;
+
+   if (!piglit_probe_pixel_rgb(0, 0, red)) {
+      return GL_FALSE;
+   }
+
+   if (!piglit_probe_pixel_rgb(0, upper, blue)) {
+      return GL_FALSE;
+   }
+
+   if (!piglit_probe_pixel_rgb(right, 0, green)) {
+      return GL_FALSE;
+   }
+
+   if (!piglit_probe_pixel_rgb(right, upper, yellow)) {
+      return GL_FALSE;
+   }
+
+
+   return GL_TRUE;
+}
+
+
+enum piglit_result
+piglit_display(void)
+{
+   GLboolean pass;
+   GLuint vbo;
+   GLuint tex;
+
+   glActiveTexture(GL_TEXTURE1);
+   glGenTextures(1, &tex);
+   glBindTexture(GL_TEXTURE_2D, tex);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB10_A2UI, 2, 2, 0,
+                GL_RGBA_INTEGER, GL_UNSIGNED_INT_10_10_10_2, texdata);
+   glEnable(GL_TEXTURE_2D);
+
+   glClear(GL_COLOR_BUFFER_BIT);
+   glColor4fv(green);
+
+   glGenBuffers(1, &vbo);
+
+   glBindBuffer(GL_ARRAY_BUFFER, vbo);
+   glBufferData(GL_ARRAY_BUFFER, sizeof(verts), verts, GL_STATIC_DRAW);
+   glVertexPointer(2, GL_FLOAT, 0, (void *)0);
+
+   glEnableClientState(GL_VERTEX_ARRAY);
+
+   assert(glGetError()==0);
+
+   glDrawArrays(GL_TRIANGLE_STRIP, 0, ARRAY_SIZE(verts));
+
+   glDisableClientState(GL_VERTEX_ARRAY);
+
+   glBindBuffer(GL_ARRAY_BUFFER, 0);
+   glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
+
+   glDeleteBuffers(1, &vbo);
+   glDeleteTextures(1, &tex);
+
+   pass = check_rendering();
+
+   piglit_present_results();
+
+   return pass ? PIGLIT_PASS : PIGLIT_FAIL;
+}
+
+
+void
+piglit_init(int argc, char **argv)
+{
+   GLboolean have_ext;
+   GLboolean have_33;
+   static const char *vs_source =
+          "#version 130\n"
+          "in vec4 vertex;\n"
+          "out vec4 texCoord;\n"
+          "void main()\n"
+          "{\n"
+          "   gl_Position = vertex;\n"
+          "   texCoord = (vertex / 2.0) + 0.5;\n"
+          "}\n";
+   static const char *fs_source =
+          "#version 130\n"
+          "in vec4 texCoord;\n"
+          "uniform usampler2D tex;\n"
+          "out vec4 result;\n"
+          "void main()\n"
+          "{\n"
+          "   uvec4 sample = texture(tex, texCoord.xy);\n"
+          "   result = vec4(sample) / 1023.0;\n"
+          "}\n";
+   GLuint fs, vs, prog;
+
+   fs = piglit_compile_shader_text(GL_FRAGMENT_SHADER, fs_source);
+   vs = piglit_compile_shader_text(GL_VERTEX_SHADER, vs_source);
+   prog = piglit_link_simple_program(vs, fs);
+   if (!prog || !fs || !vs)
+          piglit_report_result(PIGLIT_FAIL);
+   glUseProgram(prog);
+
+   tex_loc = glGetUniformLocation(prog, "tex");
+   glUniform1i(tex_loc, 1);
+
+   have_ext = piglit_is_extension_supported("GL_ARB_texture_rgb10_a2ui");
+   have_33 = piglit_get_gl_version() >= 33;
+
+   if (!have_ext && !have_33) {
+      piglit_report_result(PIGLIT_SKIP);
+      exit(1);
+   }
+
+   glClearColor(0, 0, 0, 0);
+}
+
-- 
1.7.10



More information about the Piglit mailing list