[Piglit] [PATCH] Add test case to verify Cube Shadow support in fixed function pipeline

Eric Anholt eric at anholt.net
Tue Dec 13 11:23:07 PST 2011


On Tue,  6 Dec 2011 16:54:25 -0800, Anuj Phogat <anuj.phogat at gmail.com> wrote:
> Adding a test case to verify Cube Shadow support in fixed function pipeline.

> diff --git a/tests/all.tests b/tests/all.tests
> index 68a379c..13e97a7 100644
> --- a/tests/all.tests
> +++ b/tests/all.tests
> @@ -654,6 +654,7 @@ add_plain_test(texturing, 'rgtc-teximage-01')
>  add_plain_test(texturing, 'rgtc-teximage-02')
>  add_plain_test(texturing, 's3tc-teximage')
>  add_plain_test(texturing, 's3tc-texsubimage')
> +add_plain_test(texturing, 'sampler-cube-shadow-ff')

It looks like this could be a concurrent test.

> +/* These texture coordinates should have 1 or -1 in the major axis ('r' coordinate) selecting
> + * the face, a nearly-1-or-negative-1 value in the other two coordinates (s,t) and a reference
> + * value ('q' coordinate) used for shadow comparisons.
> + */
> +static GLfloat cube_shadow_texcoords[6][4][4] = {
> +  {  /* GL_TEXTURE_CUBE_MAP_POSITIVE_X */
> +     {1.0,  0.99,  0.99,  0.00},
> +     {1.0,  0.99, -0.99, -0.50},
> +     {1.0, -0.99, -0.99,  0.00},
> +     {1.0, -0.99,  0.99,  0.50},
> +  },

Please use tabs to indent, instead of 3 spaces.  (3 spaces is just Mesa)

> +static void
> +loadTex(void)
> +{

> +   /*Set the cubemap depth values for each face*/

/* Spaces between comment markers and comment text */

> +   /*Set a different depth value to each face of cubemap*/
> +   glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, texDepthDataPosX);
> +   glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, texDepthDataNegX);
> +   glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, texDepthDataPosY);
> +   glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, texDepthDataNegY);
> +   glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, texDepthDataPosZ);
> +   glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_DEPTH_COMPONENT, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, texDepthDataNegZ);

Wrap at 80 columns.

> +piglit_init(int argc, char **argv)
> +{
> +   /*GL version must be 3.0*/
> +   piglit_require_gl_version(30);
> +   glEnable(GL_TEXTURE_CUBE_MAP);
> +   loadTex();
> +   glMatrixMode(GL_PROJECTION);
> +   glPushMatrix();
> +   glLoadIdentity();
> +   glOrtho(0, piglit_width, 0, piglit_height, -1, 1);
> +   glMatrixMode(GL_MODELVIEW);
> +   glPushMatrix();
> +   glLoadIdentity();
> +   glClearColor(0.1, 0.1, 0.1, 1.0);
> +   glVertexPointer(3, GL_FLOAT, 0, vertices);
> +   glEnableClientState(GL_VERTEX_ARRAY);
> +   glEnableClientState(GL_TEXTURE_COORD_ARRAY);
> +}
> +
> +enum piglit_result
> +piglit_display(void)
> +{
> +   GLboolean pass = GL_TRUE;
> +   GLfloat white[3] = {1.0, 0.0, 0.0};
> +   GLfloat black[3] = {0.0, 0.0, 0.0};
> +   
> +   glClear(GL_COLOR_BUFFER_BIT);
> +   glMatrixMode(GL_MODELVIEW);
> +   
> +   /*Apply each face of cubemap as texture to a polygon*/
> +   glTexCoordPointer(4, GL_FLOAT, 0, cube_shadow_texcoords[0]);
> +   glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices);
> +   
> +   glPushMatrix();
> +   glTranslatef(75.0, 0.0, 0.0);
> +   glTexCoordPointer(4, GL_FLOAT, 0, cube_shadow_texcoords[1]);
> +   glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices);
> +   
> +   glTranslatef(75.0, 0.0, 0.0);
> +   glTexCoordPointer(4, GL_FLOAT, 0, cube_shadow_texcoords[2]);
> +   glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices);
> +   glPopMatrix();
> +   
> +   glPushMatrix();
> +   glTranslatef(0.0, 75.0, 0.0);
> +   glTexCoordPointer(4, GL_FLOAT, 0, cube_shadow_texcoords[3]);
> +   glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices);
> +
> +   glTranslatef(75.0, 0.0, 0.0);
> +   glTexCoordPointer(4, GL_FLOAT, 0, cube_shadow_texcoords[4]);
> +   glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices);
> +
> +   glTranslatef(75.0, 0.0, 0.0);
> +   glTexCoordPointer(4, GL_FLOAT, 0, cube_shadow_texcoords[5]);
> +   glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_INT, indices);
> +   glPopMatrix();

I'd prefer to replace the matrix manipulations with explicit coordinates
and piglit_draw_rect() (since piglit_draw_rect() doesn't tweak the
texture coordinate pointer, I think that would work).

> +   /*Test the pixel color of polygons against the expected output*/
> +   pass = piglit_probe_pixel_rgb(110, 135, white);
> +   pass = pass && piglit_probe_pixel_rgb(140, 165, black)
> +   ;
> +   pass = pass && piglit_probe_pixel_rgb(185, 135, black);
> +   pass = pass && piglit_probe_pixel_rgb(215, 165, white);
> +
> +   pass = pass && piglit_probe_pixel_rgb(260, 165, white);
> +   pass = pass && piglit_probe_pixel_rgb(290, 135, black);
> +
> +   pass = pass && piglit_probe_pixel_rgb(110, 240, black);
> +   pass = pass && piglit_probe_pixel_rgb(140, 210, white);
> +
> +   pass = pass && piglit_probe_pixel_rgb(185, 210, black);
> +   pass = pass && piglit_probe_pixel_rgb(215, 240, black);
> +
> +   pass = pass && piglit_probe_pixel_rgb(260, 210, white);
> +   pass = pass && piglit_probe_pixel_rgb(290, 240, white);

I think some of these are solid colors -- could they be converted to
piglit_probe_rect_rgb()?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20111213/afa2d2e2/attachment-0001.pgp>


More information about the Piglit mailing list