On Fri,  8 Jun 2012 14:31:16 -0600, Brian Paul <[email protected]> wrote:
> diff --git a/tests/general/drawpix-z.c b/tests/general/drawpix-z.c
> new file mode 100644
> index 0000000..cdd6ac9
> --- /dev/null
> +++ b/tests/general/drawpix-z.c

The code would have made more sense to me if you had:

float ndc(float z)
{
        return -1.0 + 2.0 * z;
}

> +static void
> +draw_z_gradient(GLfloat zLeft, GLfloat zRight)
> +{
> +     GLfloat verts[4][3];
> +
> +     verts[0][0] = -1.0;  verts[0][1] = -1.0;  verts[0][2] = zLeft;
> +     verts[1][0] =  1.0;  verts[1][1] = -1.0;  verts[1][2] = zRight;
> +     verts[2][0] =  1.0;  verts[2][1] =  1.0;  verts[2][2] = zRight;
> +     verts[3][0] = -1.0;  verts[3][1] =  1.0;  verts[3][2] = zLeft;

        verts[0][0] = -1.0;  verts[0][1] = -1.0;  verts[0][2] = ndc(zLeft);
        verts[1][0] =  1.0;  verts[1][1] = -1.0;  verts[1][2] = ndc(zRight);
        verts[2][0] =  1.0;  verts[2][1] =  1.0;  verts[2][2] = ndc(zRight);
        verts[3][0] = -1.0;  verts[3][1] =  1.0;  verts[3][2] = ndc(zLeft);

> +enum piglit_result
> +piglit_display(void)
> +{

         float left = epsilon;
         float right = 1.0 - epsilon;

> +
> +     /* create image of Z values increasing from left to right */
> +     buf = (GLfloat *)
> +             malloc(piglit_width * piglit_height * sizeof(GLfloat));
> +     for (j = 0; j < piglit_height; j++) {
> +             for (i = 0; i < piglit_width; i++) {
> +                     float z = i / (float) (piglit_width - 1);
> +                     z = epsilon + (z * (1.0 - 2.0 * epsilon));

                        z = left + i * (right - left);

> +                     buf[j * piglit_width + i] = z;
> +             }
> +     }
> +
> +     /* draw a red quad behind the Z gradient - it should not be visible */
> +     glColor4fv(red);
> +     draw_z_gradient(-1.0 + 2.0 * epsilon, 1.0);

        draw_z_gradient(left + epsilon, right + epsilon);

> +     draw_z_gradient(-1.0, 1.0 - 2.0 * epsilon);

        draw_z_gradient(left - epsilon, right - epsilon);

With the code you had, if I'm reading this right, the epsilon in
drawpixels is on a different scale from the epsilon in draw_z_gradient,
so on the +/- (1.0 - 2.0 * epsilon) side, the zs are equal to the
z that was DrawPixels()ed, and basically you're getting lucky.

I think it's an interesting test to have because of not exercising
readpixels, though.

Attachment: pgplnPoUohMMY.pgp
Description: PGP signature

_______________________________________________
Piglit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/piglit

Reply via email to