[Piglit] [PATCH] arb_clear_texture: add a trivial test
Eric Anholt
eric at anholt.net
Fri Mar 7 11:38:45 PST 2014
Ilia Mirkin <imirkin at alum.mit.edu> writes:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
>
> This is my first foray into piglit test-writing. Let me know if I missed
> anything (except for better tests -- I know that this is very limited).
>
> This mechanism of transferring the texture to the screen is pretty poor -- it
> entirely defeats the point of ARB_clear_texture, which is to allow one to
> clear even non-renderable-to textures. I guess I need to create a shader that
> uses the texture? Is there an example of a test that does this?
>
> For all its simplicity, this allowed me to debug my impl of this extension on
> nv50, which is now no longer completely broken.
> +enum piglit_result
> +piglit_display(void)
> +{
> + const float clearColor[3] = { 0.0, 1.0, 0.0 };
> + GLuint fbo;
> + GLenum status;
> + bool pass = true;
> +
> + /* Clear texture with glClearTexImage() */
> + glClearTexImage(texture, 0, GL_RGB, GL_FLOAT, clearColor);
> +
> + glGenFramebuffers(1, &fbo);
> + glBindFramebuffer(GL_FRAMEBUFFER, fbo);
> + glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture, 0);
> + status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
> + if (status != GL_FRAMEBUFFER_COMPLETE) {
> + printf("Framebuffer Status: %s\n",
> + piglit_get_gl_enum_name(status));
> + return PIGLIT_FAIL;
> + }
> +
> + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, piglit_winsys_fbo);
> + glBindFramebuffer(GL_READ_FRAMEBUFFER, fbo);
> + glBlitFramebuffer(0, 0, piglit_width, piglit_height,
> + 0, 0, piglit_width, piglit_height,
> + GL_COLOR_BUFFER_BIT, GL_NEAREST);
> +
> + if (!piglit_check_gl_error(GL_NO_ERROR))
> + pass = false;
Instead of making an FBO and using BlitFramebuffer, I'd just draw the
texture to the screen using texture sampling.
tests/spec/ext_unpack_subimage/ext_unpack_subimage.c has some very easy
code to copy from for the shader and the draw call.
I do really like that you're drawing to the screen. It's important for
people debugging drivers, and I wouldn't want to see it go away.
Other than that, this is a nice simple test. We're going to want an
all-the-formats testcase before we land clear_texture in Mesa, but this
is a good start.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <http://lists.freedesktop.org/archives/piglit/attachments/20140307/fbdefe90/attachment.pgp>
More information about the Piglit
mailing list