[Piglit] [PATCH 1/2] arb_blend_func_extended: require GL 3.0

2014-07-03 Thread Brian Paul
Since the test shaders require GLSL 1.30
---
 .../arb_blend_func_extended/execution/fbo-extended-blend-explicit.c  |2 +-
 tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c|2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c 
b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
index 1605961..abc4675 100644
--- a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
+++ b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend-explicit.c
@@ -39,7 +39,7 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
-   config.supports_gl_compat_version = 10;
+   config.supports_gl_compat_version = 30;
config.window_visual = PIGLIT_GL_VISUAL_RGB;
 
 PIGLIT_GL_TEST_CONFIG_END
diff --git a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c 
b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
index 8cf16ed..d4e976a 100644
--- a/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
+++ b/tests/spec/arb_blend_func_extended/execution/fbo-extended-blend.c
@@ -39,7 +39,7 @@
 
 PIGLIT_GL_TEST_CONFIG_BEGIN
 
-   config.supports_gl_compat_version = 10;
+   config.supports_gl_compat_version = 30;
config.window_visual = PIGLIT_GL_VISUAL_RGB;
 
 PIGLIT_GL_TEST_CONFIG_END
-- 
1.7.10.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH] cl-api-get-platform-ids: Initialize variable.

2014-07-03 Thread Tom Stellard
On Tue, Jul 01, 2014 at 10:38:56PM -0700, Vinson Lee wrote:
 Fix clang sometimes-uninitialized warning.
 
 get-platform-ids.c:62:5: warning: variable 'platforms' is used uninitialized 
 whenever 'if' condition is true [-Wsometimes-uninitialized]
 if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
^
 get-platform-ids.c:93:30: note: uninitialized use occurs here
 errNo = clGetPlatformIDs(0, platforms, NULL);
 ^
 get-platform-ids.c:62:2: note: remove the 'if' if its condition is always 
 false
 if(!piglit_cl_check_error(errNo, CL_SUCCESS)) {
 ^~~
 get-platform-ids.c:56:27: note: initialize the variable 'platforms' to 
 silence this warning
 cl_platform_id* platforms;
  ^
   = NULL
 
Reviewed-by: Tom Stellard thomas.stell...@amd.com
 Signed-off-by: Vinson Lee v...@freedesktop.org
 ---
  tests/cl/api/get-platform-ids.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 diff --git a/tests/cl/api/get-platform-ids.c b/tests/cl/api/get-platform-ids.c
 index 6cc734a..f94ab0c 100644
 --- a/tests/cl/api/get-platform-ids.c
 +++ b/tests/cl/api/get-platform-ids.c
 @@ -53,7 +53,7 @@ piglit_cl_test(const int argc,
   int i;
   cl_int errNo;
   cl_uint num_platforms;
 - cl_platform_id* platforms;
 + cl_platform_id* platforms = NULL;
  
   /*** Normal usage ***/
  
 -- 
 1.9.2
 
 ___
 Piglit mailing list
 Piglit@lists.freedesktop.org
 http://lists.freedesktop.org/mailman/listinfo/piglit
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 2/2] arb_provoking_vertex/xfb-before-flatshading: use default window size

2014-07-03 Thread Brian Paul
---
 tests/spec/arb_provoking_vertex/xfb-before-flatshading.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c 
b/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
index 67cc581..6d168ea 100644
--- a/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
+++ b/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
@@ -40,8 +40,6 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 32;
 config.supports_gl_core_version = 32;
 
-   config.window_width = 100;
-   config.window_height = 100;
config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;
 
 PIGLIT_GL_TEST_CONFIG_END
-- 
1.7.10.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


Re: [Piglit] [PATCH 2/2] arb_provoking_vertex/xfb-before-flatshading: use default window size

2014-07-03 Thread Charmaine Lee
Reviewed-by: Charmaine Lee charmai...@vmware.com

From: Piglit piglit-boun...@lists.freedesktop.org on behalf of Brian Paul 
bri...@vmware.com
Sent: Thursday, July 3, 2014 10:41 AM
To: piglit@lists.freedesktop.org
Subject: [Piglit] [PATCH 2/2] arb_provoking_vertex/xfb-before-flatshading:  
use default window size

---
 tests/spec/arb_provoking_vertex/xfb-before-flatshading.c |2 --
 1 file changed, 2 deletions(-)

diff --git a/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c 
b/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
index 67cc581..6d168ea 100644
--- a/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
+++ b/tests/spec/arb_provoking_vertex/xfb-before-flatshading.c
@@ -40,8 +40,6 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
config.supports_gl_compat_version = 32;
 config.supports_gl_core_version = 32;

-   config.window_width = 100;
-   config.window_height = 100;
config.window_visual = PIGLIT_GL_VISUAL_RGB | PIGLIT_GL_VISUAL_DOUBLE;

 PIGLIT_GL_TEST_CONFIG_END
--
1.7.10.4

___
Piglit mailing list
Piglit@lists.freedesktop.org
https://urldefense.proofpoint.com/v1/url?u=http://lists.freedesktop.org/mailman/listinfo/piglitk=oIvRg1%2BdGAgOoM1BIlLLqw%3D%3D%0Ar=iVNYIcCaC9TDvyNBQU%2F5q5NVsC01tSgJb3oX27T14ck%3D%0Am=AOPJ5rlYmUW3z%2BoPP6k1Iavi6h20Rh4GM%2BXEnugnnhU%3D%0As=24aeec83ec2e4a9e812d6aede16bb71cfc071c27f120756154752a8cee7d3c63
___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 12/16] Unify piglit_checkerboard_texture between GL and GLES

2014-07-03 Thread Josh Triplett
In the GLES implementation, factor out the conversion of the white and
black pixel values from float to ubyte outside the loop.  That then
unifies the loop between the two implementations.

Update the documentation to note that piglit_checkerboard_texture sets
GL_CLAMP_TO_EDGE on GLES, not GL_CLAMP_TO_BORDER as it does on GL.

Signed-off-by: Josh Triplett j...@joshtriplett.org
---
 tests/util/piglit-util-gl-common.c | 110 +
 tests/util/piglit-util-gl.c|  83 
 tests/util/piglit-util-gles.c  |  87 -
 3 files changed, 110 insertions(+), 170 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index f84fd2c..bd61e35 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1917,3 +1917,113 @@ piglit_draw_triangle_z(float z, float x1, float y1, 
float x2, float y2,
 
glDisableClientState(GL_VERTEX_ARRAY);
 }
+
+/**
+ * Generate a checkerboard texture
+ *
+ * \param texName of the texture to be used.  If \c tex is
+ *   zero, a new texture name will be generated.
+ * \param level  Mipmap level the checkerboard should be written to
+ * \param width  Width of the texture image
+ * \param height Height of the texture image
+ * \param horiz_square_size  Size of each checkerboard tile along the X axis
+ * \param vert_square_size   Size of each checkerboard tile along the Y axis
+ * \param black  RGBA color to be used for black tiles
+ * \param white  RGBA color to be used for white tiles
+ *
+ * A texture with alternating black and white squares in a checkerboard
+ * pattern is generated.  The texture data is written to LOD \c level of
+ * the texture \c tex.
+ *
+ * If \c tex is zero, a new texture created.  This texture will have several
+ * texture parameters set to non-default values:
+ *
+ *  - Min and mag filter will be set to \c GL_NEAREST.
+ *  - For GL:
+ *- S and T wrap modes will be set to \c GL_CLAMP_TO_BORDER.
+ *- Border color will be set to { 1.0, 0.0, 0.0, 1.0 }.
+ *  - For GLES:
+ *- S and T wrap modes will be set to \c GL_CLAMP_TO_EDGE.
+ *
+ * \return
+ * Name of the texture.  In addition, this texture will be bound to the
+ * \c GL_TEXTURE_2D target of the currently active texture unit.
+ */
+GLuint
+piglit_checkerboard_texture(GLuint tex, unsigned level,
+   unsigned width, unsigned height,
+   unsigned horiz_square_size,
+   unsigned vert_square_size,
+   const float *black, const float *white)
+{
+   static const GLfloat border_color[4] = { 1.0, 0.0, 0.0, 1.0 };
+   unsigned i;
+   unsigned j;
+   void *tex_data;
+   char *texel;
+   unsigned pixel_size;
+   GLubyte black_b[4], white_b[4];
+   const void *black_data, *white_data;
+
+   if (piglit_is_gles()) {
+   pixel_size = 4 * sizeof(GLubyte);
+   for (i = 0; i  4; i++) {
+   black_b[i] = black[i] * 255;
+   white_b[i] = white[i] * 255;
+   }
+   black_data = black_b;
+   white_data = white_b;
+   } else {
+   pixel_size = 4 * sizeof(float);
+   black_data = black;
+   white_data = white;
+   }
+   texel = tex_data = malloc(width * height * pixel_size);
+
+   for (i = 0; i  height; i++) {
+   const unsigned row = i / vert_square_size;
+
+   for (j = 0; j  width; j++) {
+   const unsigned col = j / horiz_square_size;
+
+   if ((row ^ col)  1) {
+   memcpy(texel, white_data, pixel_size);
+   } else {
+   memcpy(texel, black_data, pixel_size);
+   }
+
+   texel += pixel_size;
+   }
+   }
+
+   if (tex == 0) {
+   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);
+   if (piglit_is_gles()) {
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+   GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+   GL_CLAMP_TO_EDGE);
+   } else {
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
+   GL_CLAMP_TO_BORDER);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
+  

[Piglit] [PATCH 07/16] Unify piglit_escape_exit_key between GL and GLES

2014-07-03 Thread Josh Triplett
Signed-off-by: Josh Triplett j...@joshtriplett.org
---
 tests/util/piglit-util-gl-common.c | 14 ++
 tests/util/piglit-util-gl.c| 13 -
 tests/util/piglit-util-gles.c  | 12 
 3 files changed, 14 insertions(+), 25 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 9f778c5..3a31e42 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -520,6 +520,20 @@ piglit_compressed_pixel_offset(GLenum format, unsigned 
width,
return offset;
 }
 
+void
+piglit_escape_exit_key(unsigned char key, int x, int y)
+{
+   (void) x;
+   (void) y;
+   switch (key) {
+   case 27:
+   exit(0);
+   break;
+   }
+   if (!piglit_is_gles())
+   piglit_post_redisplay();
+}
+
 /**
  * Convenience function to configure an abitrary orthogonal projection matrix
  */
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 7c3414c..df81a63 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -416,19 +416,6 @@ GLuint piglit_compile_program(GLenum target, const char* 
text)
return program;
 }
 
-void
-piglit_escape_exit_key(unsigned char key, int x, int y)
-{
-   (void) x;
-   (void) y;
-   switch (key) {
-   case 27:
-   exit(0);
-   break;
-   }
-   piglit_post_redisplay();
-}
-
 /**
  * Convenience function to draw a triangle.
  */
diff --git a/tests/util/piglit-util-gles.c b/tests/util/piglit-util-gles.c
index 7eef8e2..f6d6555 100644
--- a/tests/util/piglit-util-gles.c
+++ b/tests/util/piglit-util-gles.c
@@ -35,18 +35,6 @@
 
 #include piglit-util-gl-common.h
 
-void
-piglit_escape_exit_key(unsigned char key, int x, int y)
-{
-   (void) x;
-   (void) y;
-   switch (key) {
-   case 27:
-   exit(0);
-   break;
-   }
-}
-
 /**
  * Generates a texture with the given internalFormat, w, h with a
  * teximage of r, g, b w quadrants.
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 14/16] Factor out image generation from GLES piglit_rgbw_texture into a helper

2014-07-03 Thread Josh Triplett
This moves the GLES implementation of piglit_rgbw_texture much closer to
the GL version.

Signed-off-by: Josh Triplett j...@joshtriplett.org
---
 tests/util/piglit-util-gles.c | 82 ---
 1 file changed, 45 insertions(+), 37 deletions(-)

diff --git a/tests/util/piglit-util-gles.c b/tests/util/piglit-util-gles.c
index 29e8c4d..e4b3ec4 100644
--- a/tests/util/piglit-util-gles.c
+++ b/tests/util/piglit-util-gles.c
@@ -35,6 +35,46 @@
 
 #include piglit-util-gl-common.h
 
+static GLubyte *
+piglit_rgbw_image_ubyte(int w, int h, GLboolean alpha)
+{
+   GLubyte red[4]   = {255, 0, 0, 0};
+   GLubyte green[4] = {0, 255, 0, 64};
+   GLubyte blue[4]  = {0, 0, 255, 128};
+   GLubyte white[4] = {255, 255, 255, 255};
+   GLubyte *data;
+   int x, y;
+
+   if (!alpha) {
+   red[3] = 255;
+   green[3] = 255;
+   blue[3] = 255;
+   white[3] = 255;
+   }
+
+   data = malloc(w * h * 4 * sizeof(GLubyte));
+
+   for (y = 0; y  h; y++) {
+   for (x = 0; x  w; x++) {
+   const GLubyte *color;
+
+   if (x  w / 2  y  h / 2)
+   color = red;
+   else if (y  h / 2)
+   color = green;
+   else if (x  w / 2)
+   color = blue;
+   else
+   color = white;
+
+   memcpy(data + (y * w + x) * 4, color,
+  4 * sizeof(GLubyte));
+   }
+   }
+
+   return data;
+}
+
 /**
  * Generates a texture with the given internalFormat, w, h with a
  * teximage of r, g, b w quadrants.
@@ -47,20 +87,8 @@ GLuint
 piglit_rgbw_texture(GLenum format, int w, int h, GLboolean mip,
GLboolean alpha, GLenum basetype)
 {
-   GLubyte *data;
-   int size, x, y, level;
+   int size, level;
GLuint tex;
-   GLubyte red[4]   = {255, 0, 0, 0};
-   GLubyte green[4] = {0, 255, 0, 64};
-   GLubyte blue[4]  = {0, 0, 255, 128};
-   GLubyte white[4] = {255, 255, 255, 255};
-
-   if (!alpha) {
-   red[3] = 255;
-   green[3] = 255;
-   blue[3] = 255;
-   white[3] = 255;
-   }
 
glGenTextures(1, tex);
glBindTexture(GL_TEXTURE_2D, tex);
@@ -77,33 +105,14 @@ piglit_rgbw_texture(GLenum format, int w, int h, GLboolean 
mip,
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
GL_NEAREST);
}
-   data = malloc(w * h * 4 * sizeof(GLubyte));
-
-   /* XXX: Do we want non-square textures?  Surely some day. */
-   assert(w == h);
-
-   for (level = 0, size = w; size  0; level++, size = 1) {
-   for (y = 0; y  size; y++) {
-   for (x = 0; x  size; x++) {
-   const GLubyte *color;
 
-   if (x  size / 2  y  size / 2)
-   color = red;
-   else if (y  size / 2)
-   color = green;
-   else if (x  size / 2)
-   color = blue;
-   else
-   color = white;
-
-   memcpy(data + (y * size + x) * 4, color,
-  4 * sizeof(GLubyte));
-   }
-   }
+   for (level = 0, size = w  h ? w : h; size  0; level++, size = 1) {
+   GLubyte *data = piglit_rgbw_image_ubyte(w, h, alpha);
glTexImage2D(GL_TEXTURE_2D, level,
 format,
-size, size, 0,
+w, h, 0,
 GL_RGBA, GL_UNSIGNED_BYTE, data);
+   free(data);
 
if (!mip)
break;
@@ -113,6 +122,5 @@ piglit_rgbw_texture(GLenum format, int w, int h, GLboolean 
mip,
if (h  1)
h = 1;
}
-   free(data);
return tex;
 }
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 00/16] Unify piglit-util-{gl, gles}.c into piglit-util-gl-common.c

2014-07-03 Thread Josh Triplett
This patch series unifies both the GL and GLES utility functions into a single
set of functions in piglit-util-gl-common.c, in preparation for unifying the
libraries themselves.

I've confirmed (on an IVB test system) that this causes zero piglit
regressions.

This supersedes the 4-patch series I sent yesterday.

Josh Triplett (16):
  Fix piglit_is_gles to return true for OpenGL ES-CM 1.1 ...
  Unify piglit_num_components between GL and GLES
  Move piglit_get_luminance_intensity_bits to GL common code
  Unify projection utility functions across GL and GLES
  Unify piglit_probe_pixel_* and piglit_probe_rect_* between GL and GLES
  Unify piglit_probe_image_* functions between GL and GLES
  Unify piglit_escape_exit_key between GL and GLES
  Move piglit_probe_texel_* functions to GL common code
  Move remaining piglit_probe_* functions to GL common code
  Move piglit program helper functions to GL common code
  Move piglit_draw_triangle* helper functions to GL common code
  Unify piglit_checkerboard_texture between GL and GLES
  Move piglit_miptree_texture to GL common code
  Factor out image generation from GLES piglit_rgbw_texture into a
helper
  Unify piglit_rgbw_texture between GL and GLES; drop piglit-util-gles.c
  Move the remaining piglit-util-gl functions into piglit-util-gl-common

 tests/util/CMakeLists.gl.txt   |2 -
 tests/util/CMakeLists.gles1.txt|5 -
 tests/util/CMakeLists.gles2.txt|1 -
 tests/util/CMakeLists.gles3.txt|1 -
 tests/util/piglit-util-gl-common.c | 1711 +++-
 tests/util/piglit-util-gl.c| 1605 -
 tests/util/piglit-util-gles.c  |  446 --
 7 files changed, 1710 insertions(+), 2061 deletions(-)
 delete mode 100644 tests/util/piglit-util-gl.c
 delete mode 100644 tests/util/piglit-util-gles.c

-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 13/16] Move piglit_miptree_texture to GL common code

2014-07-03 Thread Josh Triplett
This doesn't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett j...@joshtriplett.org
---
 tests/util/piglit-util-gl-common.c | 39 +
 tests/util/piglit-util-gl.c| 40 --
 2 files changed, 39 insertions(+), 40 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index bd61e35..537e19c 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -2027,3 +2027,42 @@ piglit_checkerboard_texture(GLuint tex, unsigned level,
 
return tex;
 }
+
+/**
+ * Generates a 8x8 mipmapped texture whose layers contain solid r, g, b, and w.
+ */
+GLuint
+piglit_miptree_texture()
+{
+   GLfloat *data;
+   int size, i, level;
+   GLuint tex;
+   const float color_wheel[4][4] = {
+   {1, 0, 0, 1}, /* red */
+   {0, 1, 0, 1}, /* green */
+   {0, 0, 1, 1}, /* blue */
+   {1, 1, 1, 1}, /* white */
+   };
+
+   glGenTextures(1, tex);
+   glBindTexture(GL_TEXTURE_2D, tex);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
+   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
+   GL_NEAREST_MIPMAP_NEAREST);
+
+   for (level = 0; level  4; ++level) {
+   size = 8  level;
+
+   data = malloc(size*size*4*sizeof(GLfloat));
+   for (i = 0; i  size * size; ++i) {
+   memcpy(data + 4 * i, color_wheel[level],
+  4 * sizeof(GLfloat));
+   }
+   glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA,
+size, size, 0, GL_RGBA, GL_FLOAT, data);
+   free(data);
+   }
+   return tex;
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index cbaf167..5e20b01 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -37,46 +37,6 @@
 
 
 /**
- * Generates a 8x8 mipmapped texture whose layers contain solid r, g, b, and w.
- */
-GLuint
-piglit_miptree_texture()
-{
-   GLfloat *data;
-   int size, i, level;
-   GLuint tex;
-   const float color_wheel[4][4] = {
-   {1, 0, 0, 1}, /* red */
-   {0, 1, 0, 1}, /* green */
-   {0, 0, 1, 1}, /* blue */
-   {1, 1, 1, 1}, /* white */
-   };
-
-   glGenTextures(1, tex);
-   glBindTexture(GL_TEXTURE_2D, tex);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
-   glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
-   GL_NEAREST_MIPMAP_NEAREST);
-
-   for (level = 0; level  4; ++level) {
-   size = 8  level;
-
-   data = malloc(size*size*4*sizeof(GLfloat));
-   for (i = 0; i  size * size; ++i) {
-   memcpy(data + 4 * i, color_wheel[level],
-  4 * sizeof(GLfloat));
-   }
-   glTexImage2D(GL_TEXTURE_2D, level, GL_RGBA,
-size, size, 0, GL_RGBA, GL_FLOAT, data);
-   free(data);
-   }
-   return tex;
-}
-
-
-/**
  * Generates an image of the given size with quadrants of red, green,
  * blue and white.
  * Note that for compressed teximages, where the blocking would be
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 11/16] Move piglit_draw_triangle* helper functions to GL common code

2014-07-03 Thread Josh Triplett
These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett j...@joshtriplett.org
---
 tests/util/piglit-util-gl-common.c | 40 ++
 tests/util/piglit-util-gl.c| 40 --
 2 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index c00c9c7..f84fd2c 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1877,3 +1877,43 @@ GLuint piglit_compile_program(GLenum target, const char* 
text)
 
return program;
 }
+
+/**
+ * Convenience function to draw a triangle.
+ */
+GLvoid
+piglit_draw_triangle(float x1, float y1, float x2, float y2,
+float x3, float y3)
+{
+   piglit_draw_triangle_z(0.0, x1, y1, x2, y2, x3, y3);
+}
+
+/**
+ * Convenience function to draw a triangle at a given depth.
+ */
+GLvoid
+piglit_draw_triangle_z(float z, float x1, float y1, float x2, float y2,
+float x3, float y3)
+{
+   float verts[3][4];
+
+   verts[0][0] = x1;
+   verts[0][1] = y1;
+   verts[0][2] = z;
+   verts[0][3] = 1.0;
+   verts[1][0] = x2;
+   verts[1][1] = y2;
+   verts[1][2] = z;
+   verts[1][3] = 1.0;
+   verts[2][0] = x3;
+   verts[2][1] = y3;
+   verts[2][2] = z;
+   verts[2][3] = 1.0;
+
+   glVertexPointer(4, GL_FLOAT, 0, verts);
+   glEnableClientState(GL_VERTEX_ARRAY);
+
+   glDrawArrays(GL_TRIANGLES, 0, 3);
+
+   glDisableClientState(GL_VERTEX_ARRAY);
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index bec2940..346a985 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -37,46 +37,6 @@
 
 
 /**
- * Convenience function to draw a triangle.
- */
-GLvoid
-piglit_draw_triangle(float x1, float y1, float x2, float y2,
-float x3, float y3)
-{
-   piglit_draw_triangle_z(0.0, x1, y1, x2, y2, x3, y3);
-}
-
-/**
- * Convenience function to draw a triangle at a given depth.
- */
-GLvoid
-piglit_draw_triangle_z(float z, float x1, float y1, float x2, float y2,
-float x3, float y3)
-{
-   float verts[3][4];
-
-   verts[0][0] = x1;
-   verts[0][1] = y1;
-   verts[0][2] = z;
-   verts[0][3] = 1.0;
-   verts[1][0] = x2;
-   verts[1][1] = y2;
-   verts[1][2] = z;
-   verts[1][3] = 1.0;
-   verts[2][0] = x3;
-   verts[2][1] = y3;
-   verts[2][2] = z;
-   verts[2][3] = 1.0;
-
-   glVertexPointer(4, GL_FLOAT, 0, verts);
-   glEnableClientState(GL_VERTEX_ARRAY);
-
-   glDrawArrays(GL_TRIANGLES, 0, 3);
-
-   glDisableClientState(GL_VERTEX_ARRAY);
-}
-
-/**
  * Generate a checkerboard texture
  *
  * \param texName of the texture to be used.  If \c tex is
-- 
2.0.1

___
Piglit mailing list
Piglit@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/piglit


[Piglit] [PATCH 10/16] Move piglit program helper functions to GL common code

2014-07-03 Thread Josh Triplett
These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett j...@joshtriplett.org
---
 tests/util/piglit-util-gl-common.c | 81 +
 tests/util/piglit-util-gl.c| 82 --
 2 files changed, 81 insertions(+), 82 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index a4c283d..c00c9c7 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1796,3 +1796,84 @@ bool piglit_probe_buffer(GLuint buf, GLenum target, 
const char *label,
return status;
 }
 
+GLint piglit_ARBfp_pass_through = 0;
+
+int piglit_use_fragment_program(void)
+{
+   static const char source[] =
+   !!ARBfp1.0\n
+   MOVresult.color, fragment.color;\n
+   END\n
+   ;
+
+   piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
+   if (!piglit_is_extension_supported(GL_ARB_fragment_program))
+   return 0;
+
+   piglit_ARBfp_pass_through =
+   piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, source);
+
+   return (piglit_ARBfp_pass_through != 0);
+}
+
+void piglit_require_fragment_program(void)
+{
+   if (!piglit_use_fragment_program()) {
+   printf(GL_ARB_fragment_program not supported.\n);
+   piglit_report_result(PIGLIT_SKIP);
+   }
+}
+
+int piglit_use_vertex_program(void)
+{
+   piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
+   return piglit_is_extension_supported(GL_ARB_vertex_program);
+}
+
+void piglit_require_vertex_program(void)
+{
+   if (!piglit_use_vertex_program()) {
+   printf(GL_ARB_vertex_program not supported.\n);
+   piglit_report_result(PIGLIT_SKIP);
+   }
+}
+
+GLuint piglit_compile_program(GLenum target, const char* text)
+{
+   GLuint program;
+   GLint errorPos;
+
+   glGenProgramsARB(1, program);
+   glBindProgramARB(target, program);
+   glProgramStringARB(
+   target,
+   GL_PROGRAM_FORMAT_ASCII_ARB,
+   strlen(text),
+   (const GLubyte *)text);
+   glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, errorPos);
+   if (glGetError() != GL_NO_ERROR || errorPos != -1) {
+   int l = piglit_find_line(text, errorPos);
+   int a;
+
+   fprintf(stderr, Compiler Error (pos=%d line=%d): %s\n,
+   errorPos, l,
+   (char *) glGetString(GL_PROGRAM_ERROR_STRING_ARB));
+
+   for (a=-10; a10; a++)
+   {
+   if (errorPos+a  0)
+   continue;
+   if (errorPos+a = strlen(text))
+   break;
+   fprintf(stderr, %c, text[errorPos+a]);
+   }
+   fprintf(stderr, \nin program:\n%s, text);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+   if (!glIsProgramARB(program)) {
+   fprintf(stderr, glIsProgramARB failed\n);
+   piglit_report_result(PIGLIT_FAIL);
+   }
+
+   return program;
+}
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 611b59a..bec2940 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -36,88 +36,6 @@
 #include piglit-util-gl-common.h
 
 
-GLint piglit_ARBfp_pass_through = 0;
-
-int piglit_use_fragment_program(void)
-{
-   static const char source[] =
-   !!ARBfp1.0\n
-   MOVresult.color, fragment.color;\n
-   END\n
-   ;
-
-   piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
-   if (!piglit_is_extension_supported(GL_ARB_fragment_program))
-   return 0;
-
-   piglit_ARBfp_pass_through =
-   piglit_compile_program(GL_FRAGMENT_PROGRAM_ARB, source);
-
-   return (piglit_ARBfp_pass_through != 0);
-}
-
-void piglit_require_fragment_program(void)
-{
-   if (!piglit_use_fragment_program()) {
-   printf(GL_ARB_fragment_program not supported.\n);
-   piglit_report_result(PIGLIT_SKIP);
-   }
-}
-
-int piglit_use_vertex_program(void)
-{
-   piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);
-   return piglit_is_extension_supported(GL_ARB_vertex_program);
-}
-
-void piglit_require_vertex_program(void)
-{
-   if (!piglit_use_vertex_program()) {
-   printf(GL_ARB_vertex_program not supported.\n);
-   piglit_report_result(PIGLIT_SKIP);
-   }
-}
-
-GLuint piglit_compile_program(GLenum target, const char* text)
-{
-   GLuint program;
-   GLint errorPos;
-
-   glGenProgramsARB(1, program);
-   glBindProgramARB(target, program);
-   glProgramStringARB(
-   target,
-   GL_PROGRAM_FORMAT_ASCII_ARB,
-   

[Piglit] [PATCH 09/16] Move remaining piglit_probe_* functions to GL common code

2014-07-03 Thread Josh Triplett
These don't need to remain in the GL-specific utility library.

Signed-off-by: Josh Triplett j...@joshtriplett.org
---
 tests/util/piglit-util-gl-common.c | 116 +
 tests/util/piglit-util-gl.c| 115 
 2 files changed, 116 insertions(+), 115 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index e05ae43..a4c283d 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1680,3 +1680,119 @@ int piglit_probe_texel_volume_rgba(int target, int 
level, int x, int y, int z,
free(buffer);
return 1;
 }
+
+/**
+ * Read a pixel from the given location and compare its depth value to the
+ * given expected value.
+ *
+ * Print a log message if the depth value deviates from the expected value.
+ * \return true if the depth value matches, false otherwise
+ */
+int piglit_probe_pixel_depth(int x, int y, float expected)
+{
+   GLfloat probe;
+   GLfloat delta;
+
+   glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, probe);
+
+   delta = probe - expected;
+   if (fabs(delta)  0.01)
+   return 1;
+
+   printf(Probe depth at (%i,%i)\n, x, y);
+   printf(  Expected: %f\n, expected);
+   printf(  Observed: %f\n, probe);
+
+   return 0;
+}
+
+int piglit_probe_rect_depth(int x, int y, int w, int h, float expected)
+{
+   int i, j;
+   GLfloat *probe;
+   GLfloat *pixels = malloc(w*h*sizeof(float));
+
+   glReadPixels(x, y, w, h, GL_DEPTH_COMPONENT, GL_FLOAT, pixels);
+
+   for (j = 0; j  h; j++) {
+   for (i = 0; i  w; i++) {
+   probe = pixels[j*w+i];
+
+   if (fabs(*probe - expected) = 0.01) {
+   printf(Probe depth at (%i,%i)\n, x+i, y+j);
+   printf(  Expected: %f\n, expected);
+   printf(  Observed: %f\n, *probe);
+
+   free(pixels);
+   return 0;
+   }
+   }
+   }
+
+   free(pixels);
+   return 1;
+}
+
+int piglit_probe_pixel_stencil(int x, int y, unsigned expected)
+{
+   GLuint probe;
+   glReadPixels(x, y, 1, 1, GL_STENCIL_INDEX, GL_UNSIGNED_INT, probe);
+
+   if (probe == expected)
+   return 1;
+
+   printf(Probe stencil at (%i, %i)\n, x, y);
+   printf(  Expected: %u\n, expected);
+   printf(  Observed: %u\n, probe);
+
+   return 0;
+}
+
+int piglit_probe_rect_stencil(int x, int y, int w, int h, unsigned expected)
+{
+   int i, j;
+   GLuint *pixels = malloc(w*h*sizeof(GLuint));
+
+   glReadPixels(x, y, w, h, GL_STENCIL_INDEX, GL_UNSIGNED_INT, pixels);
+
+   for (j = 0; j  h; j++) {
+   for (i = 0; i  w; i++) {
+   GLuint probe = pixels[j * w + i];
+   if (probe != expected) {
+   printf(Probe stencil at (%i, %i)\n, x + i, y 
+ j);
+   printf(  Expected: %u\n, expected);
+   printf(  Observed: %u\n, probe);
+   free(pixels);
+   return 0;
+   }
+   }
+   }
+
+   free(pixels);
+   return 1;
+}
+
+bool piglit_probe_buffer(GLuint buf, GLenum target, const char *label,
+unsigned n, unsigned num_components,
+const float *expected)
+{
+   float *ptr;
+   unsigned i;
+   bool status = true;
+
+   glBindBuffer(target, buf);
+   ptr = glMapBuffer(target, GL_READ_ONLY);
+
+   for (i = 0; i  n * num_components; i++) {
+   if (fabs(ptr[i] - expected[i % num_components])  0.01) {
+   printf(%s[%i]: %f, Expected: %f\n, label, i, ptr[i],
+   expected[i % num_components]);
+   status = false;
+   }
+   }
+
+   glUnmapBuffer(target);
+
+   return status;
+}
+
diff --git a/tests/util/piglit-util-gl.c b/tests/util/piglit-util-gl.c
index 8e4fc52..611b59a 100644
--- a/tests/util/piglit-util-gl.c
+++ b/tests/util/piglit-util-gl.c
@@ -38,121 +38,6 @@
 
 GLint piglit_ARBfp_pass_through = 0;
 
-/**
- * Read a pixel from the given location and compare its depth value to the
- * given expected value.
- *
- * Print a log message if the depth value deviates from the expected value.
- * \return true if the depth value matches, false otherwise
- */
-int piglit_probe_pixel_depth(int x, int y, float expected)
-{
-   GLfloat probe;
-   GLfloat delta;
-
-   glReadPixels(x, y, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, probe);
-
-   delta = probe - expected;
-   if (fabs(delta)  0.01)
-   return 1;
-
-   printf(Probe depth at (%i,%i)\n, x, y);
-   printf(  Expected: %f\n, expected);

[Piglit] [PATCH 06/16] Unify piglit_probe_image_* functions between GL and GLES

2014-07-03 Thread Josh Triplett
Signed-off-by: Josh Triplett j...@joshtriplett.org
---
 tests/util/piglit-util-gl-common.c | 210 +
 tests/util/piglit-util-gl.c| 166 -
 tests/util/piglit-util-gles.c  |  44 
 3 files changed, 210 insertions(+), 210 deletions(-)

diff --git a/tests/util/piglit-util-gl-common.c 
b/tests/util/piglit-util-gl-common.c
index 6764d96..9f778c5 100644
--- a/tests/util/piglit-util-gl-common.c
+++ b/tests/util/piglit-util-gl-common.c
@@ -1273,3 +1273,213 @@ piglit_probe_rect_rgba_uint(int x, int y, int w, int h,
free(pixels);
return 1;
 }
+
+static void
+print_pixel_ubyte(const GLubyte *pixel, unsigned components)
+{
+   int p;
+   for (p = 0; p  components; ++p)
+   printf( %u, pixel[p]);
+}
+
+static void
+print_pixel_float(const float *pixel, unsigned components)
+{
+   int p;
+   for (p = 0; p  components; ++p)
+   printf( %f, pixel[p]);
+}
+
+/**
+ * Compute the appropriate tolerance for comparing images of the given
+ * base format.
+ */
+void
+piglit_compute_probe_tolerance(GLenum format, float *tolerance)
+{
+   int num_components, component;
+   switch (format) {
+   case GL_LUMINANCE_ALPHA:
+   tolerance[0] = piglit_tolerance[0];
+   tolerance[1] = piglit_tolerance[3];
+   break;
+   case GL_ALPHA:
+   tolerance[0] = piglit_tolerance[3];
+   break;
+   default:
+   num_components = piglit_num_components(format);
+   for (component = 0; component  num_components; ++component)
+   tolerance[component] = piglit_tolerance[component];
+   break;
+   }
+}
+
+/**
+ * Compare two in-memory floating-point images.
+ */
+int
+piglit_compare_images_color(int x, int y, int w, int h, int num_components,
+   const float *tolerance,
+   const float *expected_image,
+   const float *observed_image)
+{
+   int i, j, p;
+   for (j = 0; j  h; j++) {
+   for (i = 0; i  w; i++) {
+   const float *expected =
+   expected_image[(j*w+i)*num_components];
+   const float *probe =
+   observed_image[(j*w+i)*num_components];
+
+   for (p = 0; p  num_components; ++p) {
+   if (fabs(probe[p] - expected[p])
+   = tolerance[p]) {
+   printf(Probe at (%i,%i)\n, x+i, y+j);
+   printf(  Expected:);
+   print_pixel_float(expected, 
num_components);
+   printf(\n  Observed:);
+   print_pixel_float(probe, 
num_components);
+   printf(\n);
+
+   return 0;
+   }
+   }
+   }
+   }
+
+   return 1;
+}
+
+/**
+ * Compare the contents of the current read framebuffer with the given
+ * in-memory floating-point image.
+ */
+int
+piglit_probe_image_color(int x, int y, int w, int h, GLenum format,
+const float *image)
+{
+   int c = piglit_num_components(format);
+   GLfloat *pixels;
+   float tolerance[4];
+   int result;
+
+   piglit_compute_probe_tolerance(format, tolerance);
+
+   if (format == GL_INTENSITY) {
+   /* GL_INTENSITY is not allowed for ReadPixels so
+* substitute GL_LUMINANCE.
+*/
+   format = GL_LUMINANCE;
+   }
+
+   pixels = piglit_read_pixels_float(x, y, w, h, format, NULL);
+
+   result = piglit_compare_images_color(x, y, w, h, c, tolerance, image,
+pixels);
+
+   free(pixels);
+   return result;
+}
+
+int
+piglit_probe_image_rgb(int x, int y, int w, int h, const float *image)
+{
+   return piglit_probe_image_color(x, y, w, h, GL_RGB, image);
+}
+
+int
+piglit_probe_image_rgba(int x, int y, int w, int h, const float *image)
+{
+   return piglit_probe_image_color(x, y, w, h, GL_RGBA, image);
+}
+
+/**
+ * Compare two in-memory unsigned-byte images.
+ */
+int
+piglit_compare_images_ubyte(int x, int y, int w, int h,
+   const GLubyte *expected_image,
+   const GLubyte *observed_image)
+{
+   int i, j;
+   for (j = 0; j  h; j++) {
+   for (i = 0; i  w; i++) {
+   const GLubyte expected = expected_image[j*w+i];
+   const GLubyte probe = observed_image[j*w+i];
+
+   if (probe != expected) {
+   printf(Probe at (%i,%i)\n, x+i, y+j);
+