summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2014-12-17 15:10:00 +0000
committerNeil Roberts <neil@linux.intel.com>2014-12-18 11:55:06 +0000
commit8433c118dfa6f03f615724d9b8a25e9ab3156c93 (patch)
tree330ac48438739dd7848a98d689ddeca2473e20d7
parent5cfdc9d1d46fce9112845762a669dd308e21498c (diff)
texsubimage: Render all of the images of a 3D texture
Previously when testing a 3D texture the test would just draw a single image with the width and height of the texture and the z coordinates set to span across the depth. This wouldn't end up drawing all of the texels in the texture so instead it will now render all of the images in a vertical line. In order to do this the test needs a taller window than the default 160 pixels. Reviewed-by: Brian Paul <brianp@vmware.com>
-rw-r--r--tests/texturing/texsubimage.c35
1 files changed, 28 insertions, 7 deletions
diff --git a/tests/texturing/texsubimage.c b/tests/texturing/texsubimage.c
index 0388da615..e091fd140 100644
--- a/tests/texturing/texsubimage.c
+++ b/tests/texturing/texsubimage.c
@@ -41,6 +41,9 @@ PIGLIT_GL_TEST_CONFIG_BEGIN
config.window_visual = PIGLIT_GL_VISUAL_RGBA | PIGLIT_GL_VISUAL_DOUBLE;
+ config.window_width = 512;
+ config.window_height = 512;
+
PIGLIT_GL_TEST_CONFIG_END
/**
@@ -141,9 +144,9 @@ piglit_draw_rect_tex3d(float x, float y, float w, float h,
static GLboolean
equal_images(const GLubyte *img1, const GLubyte *img2,
- GLuint w, GLuint h)
+ GLuint w, GLuint h, GLuint d)
{
- return memcmp(img1, img2, w*h*4) == 0;
+ return memcmp(img1, img2, w*h*d*4) == 0;
}
@@ -190,6 +193,26 @@ get_format_block_size(GLenum format, GLuint *bw, GLuint *bh)
}
}
+/**
+ * Draw each image of the texture to the framebuffer and then save the
+ * entire thing to a buffer with glReadPixels().
+ */
+static void
+draw_and_read_texture(GLuint w, GLuint h, GLuint d, GLubyte *ref)
+{
+ int i;
+
+ for (i = 0; i < d; i++) {
+ float tz = (i + 0.5f) / d;
+ piglit_draw_rect_tex3d(0, i * h, /* x/y */
+ w, h,
+ 0.0, 0.0, /* tx/ty */
+ 1.0, 1.0, /* tw/th */
+ tz, tz /* tz0/tz1 */);
+ }
+
+ glReadPixels(0, 0, w, h * d, GL_RGBA, GL_UNSIGNED_BYTE, ref);
+}
/**
* Create a texture image with reference values. Draw a textured quad.
@@ -267,8 +290,7 @@ test_format(GLenum target, GLenum intFormat)
/* draw reference image */
glClear(GL_COLOR_BUFFER_BIT);
- piglit_draw_rect_tex3d(0, 0, w, h, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0);
- glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, ref);
+ draw_and_read_texture(w, h, d, ref);
for (t = 0; t < 10; t++) {
/* Choose random region of texture to update.
@@ -305,12 +327,11 @@ test_format(GLenum target, GLenum intFormat)
/* draw test image */
glClear(GL_COLOR_BUFFER_BIT);
- piglit_draw_rect_tex3d(0, 0, w, h, 0.0, 0.0, 1.0, 1.0, 0.0, 1.0);
- glReadPixels(0, 0, w, h, GL_RGBA, GL_UNSIGNED_BYTE, testImg);
+ draw_and_read_texture(w, h, d, testImg);
piglit_present_results();
- if (!equal_images(ref, testImg, w, h)) {
+ if (!equal_images(ref, testImg, w, h, d)) {
printf("texsubimage failed\n");
printf(" target: %s\n", piglit_get_gl_enum_name(target));
printf(" internal format: %s\n", piglit_get_gl_enum_name(intFormat));