[Piglit] [PATCH] add new test for stencil ref clamping

Eric Anholt eric at anholt.net
Wed May 15 09:36:51 PDT 2013


Chris Forbes <chrisf at ijw.co.nz> writes:
> +void
> +piglit_init(int argc, char **argv)
> +{
> +    GLuint fbo;
> +    GLuint rb;
> +    GLint stencil_bits = 1;
> +    GLint stencil_ref;

Piglit is 8-space tab indentation.

> +    glGenFramebuffers(1, &fbo);
> +    glBindFramebuffer(GL_FRAMEBUFFER, fbo);
> +
> +    /* ensure we have no stencil bits */
> +    glGetIntegerv(GL_STENCIL_BITS, &stencil_bits);
> +    if (stencil_bits != 0) {
> +        printf("initial stencil bits: expected 0, got %d\n", stencil_bits);
> +        piglit_report_result(PIGLIT_FAIL);
> +    }

This should be a SKIP.  If the implementation only gives you visuals
with stencil, that's not a bug in the implementation.

> +    /* read back the stencil ref; ensure it is clamped */
> +    glGetIntegerv(GL_STENCIL_REF, &stencil_ref);
> +    if (stencil_ref != 0) {
> +        printf("stencil ref with no stencil attachment: expected 0, got 0x%x\n", stencil_ref);

wrap at 80 columns

> +        piglit_report_result(PIGLIT_FAIL);
> +    }

> +    /* now add a stencil attachment */
> +    glGenRenderbuffers(1, &rb);
> +    glBindRenderbuffer(GL_RENDERBUFFER, rb);
> +    glRenderbufferStorage(GL_RENDERBUFFER, GL_STENCIL_INDEX8, 64, 64);
> +    glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rb);
> +
> +    if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
> +        printf("framebuffer incomplete, not going to work.\n");
> +        piglit_report_result(PIGLIT_FAIL);
> +    }

Implementations may legitimately report incomplete here, and that's a
SKIP case, not a test FAIL.

> +    /* now read back the stencil depth, should be 8. */
> +    glGetIntegerv(GL_STENCIL_BITS, &stencil_bits);
> +    if (stencil_bits != 8) {
> +        printf("stencil depth with S8 renderbuffer bound: expected 8, got %d\n", stencil_bits);
> +        piglit_report_result(PIGLIT_FAIL);
> +    }

Again, implementations could choose something other than 8, and that's
a bug in your testcase, not a bug in the implementation.
-------------- 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/20130515/b8bcf474/attachment.pgp>


More information about the Piglit mailing list