[Piglit] [PATCH] copyteximage: Fix the z coordinate used for rendering 3D textures

Neil Roberts neil at linux.intel.com
Thu Feb 19 05:53:14 PST 2015


The copyteximage test tries to render each layer of a 3D texture by
rendering a quad with the same z value in the texture coordinates for
each vertex. It was picking this value by just dividing the layer
number by the depth of the texture. I think this is wrong because it
will effectively point to the nearest face of the cube represented by
the 3D texel that we want. This point is equidistant between two
texels so it might be valid for an implementation to pick the other
texel. What we actually want is to set the texture coordinate to the
center of the texel. This patch makes it do that by just adding 0.5
before doing the division.

This doesn't seem to make any practical difference on Intel hardware
or with the software renderer in Mesa but at least in theory I think
it is more correct.
---
 tests/texturing/copyteximage.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/texturing/copyteximage.c b/tests/texturing/copyteximage.c
index a0f0fa3..af65d5f 100644
--- a/tests/texturing/copyteximage.c
+++ b/tests/texturing/copyteximage.c
@@ -468,7 +468,7 @@ test_target_and_format(GLint x, GLint y, GLenum target, GLenum format,
 		glEnable(target);
 
 		for (k = 0; k < 4; k++) {
-			const float tz = k * 0.25;
+			const float tz = (k + 0.5) * 0.25;
 			draw_rect_tex_3d(x, y, IMAGE_SIZE, IMAGE_SIZE,
 					 0, 0, tz, 1, 1);
 			pass = probe_rect(x, y, IMAGE_SIZE, IMAGE_SIZE,
-- 
1.9.3



More information about the Piglit mailing list