[Piglit] [PATCH 02/25] arb_direct_state_access: Use stdbool.h

Ian Romanick idr at freedesktop.org
Mon May 18 13:49:55 PDT 2015


From: Ian Romanick <ian.d.romanick at intel.com>

Generated by:

    sed --in-place -e 's/GLboolean/bool/g' \
        -e 's/GL_TRUE/true/g' \
        -e 's/GL_FALSE/false/g' \
        tests/spec/arb_direct_state_access/compressedtextureimage.c \
        tests/spec/arb_direct_state_access/copytexturesubimage.c \
        tests/spec/arb_direct_state_access/dsa-textures.c \
        tests/spec/arb_direct_state_access/gettextureimage-formats.c \
        tests/spec/arb_direct_state_access/texunits.c

Two places in gettextureimage-formats.c were hand-edited back to GL_TRUE
and GL_FALSE because the underlying type was actually GLint.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 .../compressedtextureimage.c                       |  8 ++--
 .../arb_direct_state_access/copytexturesubimage.c  | 18 +++----
 tests/spec/arb_direct_state_access/dsa-textures.c  |  2 +-
 .../gettextureimage-formats.c                      | 46 +++++++++---------
 tests/spec/arb_direct_state_access/texunits.c      | 56 +++++++++++-----------
 5 files changed, 65 insertions(+), 65 deletions(-)

diff --git a/tests/spec/arb_direct_state_access/compressedtextureimage.c b/tests/spec/arb_direct_state_access/compressedtextureimage.c
index d8875b6..22a6a8f 100644
--- a/tests/spec/arb_direct_state_access/compressedtextureimage.c
+++ b/tests/spec/arb_direct_state_access/compressedtextureimage.c
@@ -131,10 +131,10 @@ display_mipmaps(int x, int y)
 	}
 }
 
-static GLboolean
+static bool
 check_resulting_mipmaps(int x, int y)
 {
-	GLboolean pass = GL_TRUE;
+	bool pass = true;
 	int size;
 	float red[4] =   {1.0, 0.0, 0.0, 1.0};
 	float green[4] = {0.0, 1.0, 0.0, 1.0};
@@ -198,7 +198,7 @@ piglit_display(void)
 	glClear(GL_COLOR_BUFFER_BIT);
 
 	tex_src = piglit_rgbw_texture(format->token, SIZE, SIZE,
-				      GL_TRUE, GL_FALSE,
+				      true, false,
 				      GL_UNSIGNED_NORMALIZED);
 	glCreateTextures(GL_TEXTURE_2D, 1, &tex);
 
@@ -266,7 +266,7 @@ piglit_init(int argc, char **argv)
 	int i;
 	piglit_require_extension("GL_ARB_direct_state_access");
 
-	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+	piglit_ortho_projection(piglit_width, piglit_height, false);
 
 	if (argc != 2)
 		usage(argc, argv);
diff --git a/tests/spec/arb_direct_state_access/copytexturesubimage.c b/tests/spec/arb_direct_state_access/copytexturesubimage.c
index fb1a5ff..3c83245 100644
--- a/tests/spec/arb_direct_state_access/copytexturesubimage.c
+++ b/tests/spec/arb_direct_state_access/copytexturesubimage.c
@@ -48,19 +48,19 @@ static void rect(int x1, int y1, int x2, int y2)
 	glVertex2f(x2, y1);
 	glEnd();
 }
-static GLboolean inrect(int x, int y, int x1, int y1, int x2, int y2)
+static bool inrect(int x, int y, int x1, int y1, int x2, int y2)
 {
 	if (x >= x1 && x < x2 && y >= y1 && y < y2)
-		return GL_TRUE;
+		return true;
 	else
-		return GL_FALSE;
+		return false;
 }
 
-static GLboolean
+static bool
 check_results(int dstx, int dsty, int w, int h)
 {
 	GLfloat *results;
-	GLboolean pass = GL_TRUE;
+	bool pass = true;
 	int x, y;
 
 	results = malloc(w * h * 4 * sizeof(GLfloat));
@@ -96,7 +96,7 @@ check_results(int dstx, int dsty, int w, int h)
 				       results[(y * w + x) * 4 + 0],
 				       results[(y * w + x) * 4 + 1],
 				       results[(y * w + x) * 4 + 2]);
-				pass = GL_FALSE;
+				pass = false;
 			}
 		}
 	}
@@ -105,7 +105,7 @@ check_results(int dstx, int dsty, int w, int h)
 	return pass;
 }
 
-static GLboolean
+static bool
 do_row(int srcy, int srcw, int srch, GLenum target)
 {
 	int srcx = 20;
@@ -114,7 +114,7 @@ do_row(int srcy, int srcw, int srch, GLenum target)
 	int remain_width;
 	int remain_height;
 	GLuint texname;
-	GLboolean pass = GL_TRUE;
+	bool pass = true;
 
 	/* Rectangle textures use coordinates on the range [0..w]x[0..h],
 	 * where as all other textures use coordinates on the range
@@ -223,7 +223,7 @@ do_row(int srcy, int srcw, int srch, GLenum target)
 enum piglit_result
 piglit_display(void)
 {
-	GLboolean pass;
+	bool pass;
 	int srcy = 5;
 
 
diff --git a/tests/spec/arb_direct_state_access/dsa-textures.c b/tests/spec/arb_direct_state_access/dsa-textures.c
index 5e8b3a1..cc519e4 100644
--- a/tests/spec/arb_direct_state_access/dsa-textures.c
+++ b/tests/spec/arb_direct_state_access/dsa-textures.c
@@ -80,7 +80,7 @@ piglit_display(void)
 	glTextureParameteri(name, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
 
 	/* Draw the image */
-	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+	piglit_ortho_projection(piglit_width, piglit_height, false);
 	dsa_texture_with_unit(texunit);
 	glEnable(GL_TEXTURE_2D);
 	glBindTextureUnit(texunit, name);
diff --git a/tests/spec/arb_direct_state_access/gettextureimage-formats.c b/tests/spec/arb_direct_state_access/gettextureimage-formats.c
index 49f6e54..f6dbb45 100644
--- a/tests/spec/arb_direct_state_access/gettextureimage-formats.c
+++ b/tests/spec/arb_direct_state_access/gettextureimage-formats.c
@@ -46,7 +46,7 @@ static const char *TestName = "gettextureimage-formats";
 
 static const GLfloat clearColor[4] = { 0.4, 0.4, 0.4, 0.0 };
 static GLuint texture_id;
-static GLboolean init_by_rendering;
+static bool init_by_rendering;
 
 #define TEX_SIZE 128
 
@@ -57,9 +57,9 @@ static GLboolean init_by_rendering;
  * Make a simple texture image where red increases from left to right,
  * green increases from bottom to top, blue stays constant (50%) and
  * the alpha channel is a checkerboard pattern.
- * \return GL_TRUE for success, GL_FALSE if unsupported format
+ * \return true for success, false if unsupported format
  */
-static GLboolean
+static bool
 make_texture_image(GLenum intFormat, GLubyte upperRightTexel[4])
 {
 	GLubyte tex[TEX_SIZE][TEX_SIZE][4];
@@ -96,7 +96,7 @@ make_texture_image(GLenum intFormat, GLubyte upperRightTexel[4])
 		if (status != GL_FRAMEBUFFER_COMPLETE) {
 			glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, piglit_winsys_fbo);
 			glDeleteFramebuffers(1, &fb);
-			return GL_FALSE;
+			return false;
 		}
 
 		glViewport(0, 0, TEX_SIZE, TEX_SIZE);
@@ -131,7 +131,7 @@ ubyte_to_float(GLubyte b, GLint bits)
 
 
 static GLfloat
-bits_to_tolerance(GLint bits, GLboolean compressed)
+bits_to_tolerance(GLint bits, bool compressed)
 {
 	GLfloat t;
 
@@ -321,7 +321,7 @@ compute_expected_color(const struct format_desc *fmt,
 }
 
 
-static GLboolean
+static bool
 colors_equal(const GLfloat expected[4], const GLfloat pix[4],
 	     GLfloat tolerance[4])
 {
@@ -329,13 +329,13 @@ colors_equal(const GLfloat expected[4], const GLfloat pix[4],
 		 fabsf(expected[1] - pix[1]) > tolerance[1] ||
 		 fabsf(expected[2] - pix[2]) > tolerance[2] ||
 		 fabsf(expected[3] - pix[3]) > tolerance[3]) {
-		return GL_FALSE;
+		return false;
 	}
-	return GL_TRUE;
+	return true;
 }
 
 
-static GLboolean
+static bool
 test_format(const struct test_desc *test,
 	    const struct format_desc *fmt)
 {
@@ -345,7 +345,7 @@ test_format(const struct test_desc *test,
 	GLubyte upperRightTexel[4];
 	int level;
 	GLfloat expected[4], pix[4], tolerance[4];
-	GLboolean pass = GL_TRUE;
+	bool pass = true;
 
 	glClear(GL_COLOR_BUFFER_BIT);
 
@@ -357,7 +357,7 @@ test_format(const struct test_desc *test,
 	    fmt->internalformat != GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT) {
 		/* init texture image */
 		if (!make_texture_image(fmt->internalformat, upperRightTexel))
-			return GL_TRUE; /* unsupported = OK */
+			return true; /* unsupported = OK */
 
 		x = 10;
 		y = 40;
@@ -408,7 +408,7 @@ test_format(const struct test_desc *test,
 							 pix[0], pix[1], pix[2], pix[3]);
 					printf("Tolerance (%f, %f, %f, %f)\n",
 							 tolerance[0], tolerance[1], tolerance[2], tolerance[3]);
-					pass = GL_FALSE;
+					pass = false;
 				}
 			}
 
@@ -431,11 +431,11 @@ test_format(const struct test_desc *test,
  * This checks if required extensions are present and if this piglit test
  * can actually grok the formats.
  */
-static GLboolean
+static bool
 supported_format_set(const struct test_desc *set)
 {
 	if (!supported(set))
-		return GL_FALSE;
+		return false;
 
 	if (set->format == ext_texture_integer ||
 	    set->format == ext_packed_depth_stencil ||
@@ -445,17 +445,17 @@ supported_format_set(const struct test_desc *set)
 		/* texture_integer requires a fragment shader, different
 		 * glTexImage calls.  Depth/stencil formats not implemented.
 		 */
-		return GL_FALSE;
+		return false;
 	}
 
-	return GL_TRUE;
+	return true;
 }
 
 
-static GLboolean
+static bool
 test_all_formats(void)
 {
-	GLboolean pass = GL_TRUE;
+	bool pass = true;
 	int i, j;
 
 	for (i = 0; i < ARRAY_SIZE(test_sets); i++) {
@@ -463,7 +463,7 @@ test_all_formats(void)
 		if (supported_format_set(set)) {
 			for (j = 0; j < set->num_formats; j++) {
 				if (!test_format(set, &set->format[j])) {
-					pass = GL_FALSE;
+					pass = false;
 				}
 			}
 		}
@@ -476,9 +476,9 @@ test_all_formats(void)
 enum piglit_result
 piglit_display(void)
 {
-	GLboolean pass;
+	bool pass;
 
-	piglit_ortho_projection(piglit_width, piglit_height, GL_FALSE);
+	piglit_ortho_projection(piglit_width, piglit_height, false);
 
 	if (piglit_automatic) {
 		pass = test_all_formats();
@@ -488,7 +488,7 @@ piglit_display(void)
 			pass = test_format(set, &set->format[format_index]);
 		} else {
 			/* unsupported format - not a failure */
-			pass = GL_TRUE;
+			pass = true;
 			glClear(GL_COLOR_BUFFER_BIT);
 			piglit_present_results();
 		}
@@ -514,7 +514,7 @@ piglit_init(int argc, char **argv)
 
 	for (i = 1; i < argc; i++) {
 		if (strcmp(argv[i], "init-by-rendering") == 0) {
-			init_by_rendering = GL_TRUE;
+			init_by_rendering = true;
 			puts("The textures will be initialized by rendering "
 			     "to them using glDrawPixels.");
 			break;
diff --git a/tests/spec/arb_direct_state_access/texunits.c b/tests/spec/arb_direct_state_access/texunits.c
index 43a702d..54bd886 100644
--- a/tests/spec/arb_direct_state_access/texunits.c
+++ b/tests/spec/arb_direct_state_access/texunits.c
@@ -60,7 +60,7 @@ generate_random_numbers(void)
 }
 
 
-static GLboolean
+static bool
 equal4v(const GLfloat v1[4], const GLfloat v2[4])
 {
    return (v1[0] == v2[0] &&
@@ -70,15 +70,15 @@ equal4v(const GLfloat v1[4], const GLfloat v2[4])
 }
 
 
-static GLboolean
+static bool
 equal16v(const GLfloat v1[16], const GLfloat v2[16])
 {
    int i;
    for (i = 0; i < 16; i++) {
       if (v1[i] != v2[i])
-         return GL_FALSE;
+         return false;
    }
-   return GL_TRUE;
+   return true;
 }
 
 
@@ -99,7 +99,7 @@ clear_errors()
 }
 
 
-static GLboolean
+static bool
 test_rasterpos(void)
 {
    int i;
@@ -119,7 +119,7 @@ test_rasterpos(void)
       if (!equal4v(Random[i], v)) {
          printf("Get GL_CURRENT_TEXTURE_COORDS, unit %d failed\n", i);
          report4v(Random[i], v);
-         return GL_FALSE;
+         return false;
       }
    }
 
@@ -133,13 +133,13 @@ test_rasterpos(void)
       if (!equal4v(Random[i], v)) {
          printf("Get GL_CURRENT_RASTER_TEXTURE_COORDS, unit %d failed\n", i);
          report4v(Random[i], v);
-         return GL_FALSE;
+         return false;
       }
    }
 
    /* there should be no errors at this point */
    if (!piglit_check_gl_error(GL_NO_ERROR)) {
-      return GL_FALSE;
+      return false;
    }
 
    /* this should generate an error */
@@ -149,22 +149,22 @@ test_rasterpos(void)
       if (MaxTextureCoordUnits == MaxTextureCombinedUnits) {
          /* INVALID_ENUM is expected */
          if (!piglit_check_gl_error(GL_INVALID_ENUM)) {
-            return GL_FALSE;
+            return false;
          }
       } else {
          /* INVALID_OPERATION is expected */
          glGetFloatv(GL_CURRENT_RASTER_TEXTURE_COORDS, v);
          if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
-            return GL_FALSE;
+            return false;
          }
       }
    }
 
-   return GL_TRUE;
+   return true;
 }
 
 
-static GLboolean
+static bool
 test_texture_matrix(void)
 {
    int i;
@@ -185,13 +185,13 @@ test_texture_matrix(void)
       glGetFloatv(GL_TEXTURE_MATRIX, m);
       if (!equal16v((GLfloat *) Random + (i * 4) % 124, m)) {
          printf("Get texture matrix unit %d failed\n", i);
-         return GL_FALSE;
+         return false;
       }
    }
 
    /* there should be no errors at this point */
    if (!piglit_check_gl_error(GL_NO_ERROR))
-      return GL_FALSE;
+      return false;
 
    /* this should generate an error */
    {
@@ -200,21 +200,21 @@ test_texture_matrix(void)
       if (MaxTextureCoordUnits == MaxTextureCombinedUnits) {
          /* INVALID_ENUM is expected */
          if (!piglit_check_gl_error(GL_INVALID_ENUM))
-            return GL_FALSE;
+            return false;
 
       } else {
          /* INVALID_OPERATION is expected */
          glGetFloatv(GL_TEXTURE_MATRIX, m);
          if (!piglit_check_gl_error(GL_INVALID_OPERATION))
-            return GL_FALSE;
+            return false;
       }
    }
 
-   return GL_TRUE;
+   return true;
 }
 
 
-static GLboolean
+static bool
 test_texture_params(void)
 {
    GLuint tex[MAX_UNITS];
@@ -240,13 +240,13 @@ test_texture_params(void)
       if (!equal4v(v, Random[i])) {
          printf("Setting per-unit param state failed for unit %d\n", i);
          report4v(Random[i], v);
-         return GL_FALSE;
+         return false;
       }
    }
 
    /* there should be no errors at this point */
    if (!piglit_check_gl_error(GL_NO_ERROR)) {
-      return GL_FALSE;
+      return false;
    }
 
    maxUnit = MAX2(MaxTextureCombinedUnits, MaxTextureCoordUnits);
@@ -256,14 +256,14 @@ test_texture_params(void)
    /* INVALID_OPERATION is expected */
    /* (see the GL 4.4 spec for glBindTextures) */
    if (!piglit_check_gl_error(GL_INVALID_OPERATION)) {
-      return GL_FALSE;
+      return false;
    }
 
-   return GL_TRUE;
+   return true;
 }
 
 
-static GLboolean
+static bool
 test_texture_env(void)
 {
    /* Texture Environment state is fixed-function; not used by shaders */
@@ -276,7 +276,7 @@ test_texture_env(void)
       glActiveTexture(GL_TEXTURE0 + i);
       glTexEnvfv(GL_TEXTURE_ENV, GL_TEXTURE_ENV_COLOR, Random[i]);
       if (!piglit_check_gl_error(GL_NO_ERROR))
-         return GL_FALSE;
+         return false;
    }
 
    /* check per-unit state */
@@ -287,15 +287,15 @@ test_texture_env(void)
       if (!equal4v(v, Random[i])) {
          printf("Setting per-unit env state failed for unit %d\n", i);
          report4v(Random[i], v);
-         return GL_FALSE;
+         return false;
       }
    }
 
    /* there should be no errors at this point */
    if (!piglit_check_gl_error(GL_NO_ERROR))
-      return GL_FALSE;
+      return false;
 
-   return GL_TRUE;
+   return true;
 }
 
 
@@ -313,7 +313,7 @@ report_info(void)
 enum piglit_result
 piglit_display(void)
 {
-	GLboolean pass = GL_TRUE;
+	bool pass = true;
 
 	pass = test_rasterpos() && pass;
 	pass = test_texture_matrix() && pass;
-- 
2.1.0



More information about the Piglit mailing list