[Piglit] [PATCH 02/24] tex3d-npot: assorted clean-ups

Brian Paul brianp at vmware.com
Tue Apr 29 08:05:36 PDT 2014


As with the previous patch for the tex3d test.
---
 tests/texturing/tex3d-npot.c |   51 ++++++++++++++++++++----------------------
 1 file changed, 24 insertions(+), 27 deletions(-)

diff --git a/tests/texturing/tex3d-npot.c b/tests/texturing/tex3d-npot.c
index e9e4604..6911521 100644
--- a/tests/texturing/tex3d-npot.c
+++ b/tests/texturing/tex3d-npot.c
@@ -32,9 +32,7 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
 
 	config.supports_gl_compat_version = 10;
 
-	config.window_width = 128;
-	config.window_height = 128;
-	config.window_visual = PIGLIT_GL_VISUAL_RGBA;
+	config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
 
@@ -50,17 +48,8 @@ static int nrcomponents(GLenum format)
     }
 }
 
-static const char* formatname(GLenum format)
-{
-    switch(format) {
-    case GL_RGBA: return "GL_RGBA";
-    case GL_RGB: return "GL_RGB";
-    case GL_ALPHA: return "GL_ALPHA";
-    default: abort();
-    }
-}
-
-static void expected_rgba(GLenum format, const unsigned char* texdata, unsigned char* expected)
+static void
+expected_rgba(GLenum format, const GLubyte *texdata, GLubyte *expected)
 {
     switch(format) {
     case GL_RGBA:
@@ -84,13 +73,15 @@ static void expected_rgba(GLenum format, const unsigned char* texdata, unsigned
     }
 }
 
-static int render_and_check(int w, int h, int d, GLenum format, float q, unsigned char* data, const char* test)
+static bool
+render_and_check(int w, int h, int d, GLenum format, float q,
+                 const GLubyte *data, const char* test)
 {
     int x, y, z;
     int layer;
-    unsigned char* readback;
-    unsigned char* texp;
-    unsigned char* readp;
+    GLubyte *readback;
+    const GLubyte *texp;
+    GLubyte *readp;
     int ncomp = 0;
 
     glClearColor(0.0, 0.0, 0.0, 0.0);
@@ -145,7 +136,7 @@ static int render_and_check(int w, int h, int d, GLenum format, float q, unsigne
                         fprintf(stderr, " Readback: %i,%i,%i,%i\n",
                             readp[0], readp[1], readp[2], readp[3]);
                         free(readback);
-                        return 0;
+                        return false;
                     }
                 }
             }
@@ -154,7 +145,7 @@ static int render_and_check(int w, int h, int d, GLenum format, float q, unsigne
     free(readback);
 
     piglit_present_results();
-    return 1;
+    return true;
 }
 
 
@@ -162,12 +153,13 @@ static int render_and_check(int w, int h, int d, GLenum format, float q, unsigne
  * Load non-mipmapped 3D texture of the given size
  * and check whether it is rendered correctly.
  */
-static void test_simple(int w, int h, int d, GLenum format)
+static bool
+test_simple(int w, int h, int d, GLenum format)
 {
     int size;
     unsigned char *data;
     int i;
-    int success = 1;
+    bool success = true;
 
     assert(1 <= w && w <= 16);
     assert(1 <= h && h <= 16);
@@ -194,9 +186,10 @@ static void test_simple(int w, int h, int d, GLenum format)
 
     if (!success) {
         fprintf(stderr, "Failure with texture size %ix%ix%i, format = %s\n",
-            w, h, d, formatname(format));
-        piglit_report_result(PIGLIT_FAIL);
+            w, h, d, piglit_get_gl_enum_name(format));
     }
+
+    return success;
 }
 
 enum piglit_result
@@ -204,6 +197,7 @@ piglit_display(void)
 {
     GLenum formats[] = { GL_RGBA, GL_RGB, GL_ALPHA };
     int w, h, d, fmt;
+    bool pass = true;
 
     piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
 
@@ -214,7 +208,9 @@ piglit_display(void)
                     if (h != 4 && h != 8) {
                         for(d = 3; d <= 15; d++) {
                             if (d != 4 && d != 8) {
-                                test_simple(w, h, d, formats[fmt]);
+                               pass = test_simple(w, h, d, formats[fmt]);
+                               if (!pass)
+                                  goto end;
                             }
                         }
                     }
@@ -223,17 +219,18 @@ piglit_display(void)
         }
     }
 
-    return PIGLIT_PASS;
+end:
+    return pass ? PIGLIT_PASS : PIGLIT_FAIL;
 }
 
 void
 piglit_init(int argc, char **argv)
 {
-    piglit_automatic = GL_TRUE;
     piglit_require_extension("GL_ARB_texture_non_power_of_two");
 
     glDisable(GL_DITHER);
 
     glGenTextures(1, &Texture);
     glBindTexture(GL_TEXTURE_3D, Texture);
+    glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
 }
-- 
1.7.10.4



More information about the Piglit mailing list