[Piglit] [PATCH 20/23] tex-miplevel-selection: fix cubemap targets for texture() and texture(bias)

Marek Olšák maraeo at gmail.com
Fri Jul 4 07:10:07 PDT 2014


From: Marek Olšák <marek.olsak at amd.com>

---
 tests/all.py                             | 14 +++++-----
 tests/texturing/tex-miplevel-selection.c | 46 +++++++++++++++++++++-----------
 2 files changed, 37 insertions(+), 23 deletions(-)

diff --git a/tests/all.py b/tests/all.py
index ffa35cd..c818437 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1193,30 +1193,30 @@ add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection text
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) 1D')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) 2D')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) 3D')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) Cube')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) Cube')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) 1DShadow')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) 2DShadow')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) CubeShadow')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) CubeShadow')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) 1DArray')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) 2DArray')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) CubeArray')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) CubeArray')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture(bias) 1DArrayShadow')
 
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 1D')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 2D')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 3D')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() Cube')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() Cube')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 1DShadow')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 2DShadow')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() CubeShadow')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() CubeShadow')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 1DArray')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 2DArray')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() CubeArray')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() CubeArray')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 1DArrayShadow')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 2DArrayShadow')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 2DRect')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() 2DRectShadow')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() CubeArrayShadow')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection texture() CubeArrayShadow')
 
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureOffset 1D')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureOffset 2D')
diff --git a/tests/texturing/tex-miplevel-selection.c b/tests/texturing/tex-miplevel-selection.c
index e62471e..ea3c762 100644
--- a/tests/texturing/tex-miplevel-selection.c
+++ b/tests/texturing/tex-miplevel-selection.c
@@ -818,11 +818,7 @@ draw_quad(int x, int y, int w, int h, int expected_level, int fetch_level,
 	float t0 = 0;
 	float s1 = (float)w / TEX_SIZE;
 	float t1 = (float)h / TEX_SIZE;
-	/* Cube coordinates */
-	float x0 = 2*s0 - 1;
-	float z0 = 2*t0 - 1;
-	float x1 = 2*s1 - 1;
-	float z1 = 2*t1 - 1;
+	float x0, z0, x1, z1;
 	/* Final coordinates */
 	float c0[4], c1[4], c2[4], c3[4];
 	/* shadow compare value */
@@ -937,6 +933,12 @@ draw_quad(int x, int y, int w, int h, int expected_level, int fetch_level,
 	    test == GL3_TEXTURE_PROJ_GRAD_OFFSET)
 		p = 7;
 
+	/* Cube coordinates */
+	x0 = 2*s0 - 1;
+	z0 = 2*t0 - 1;
+	x1 = 2*s1 - 1;
+	z1 = 2*t1 - 1;
+
 	switch (target) {
 	case TEX_1D:
 		SET_VEC(c0, s0*p, p, 0, 1);
@@ -1020,17 +1022,17 @@ draw_quad(int x, int y, int w, int h, int expected_level, int fetch_level,
 	case TEX_CUBE:
 	case TEX_CUBE_ARRAY:
 		assert(TEST_LAYER % 6 == 3); /* negative Y */
-		SET_VEC(c0, x0, -1,  z0, TEST_LAYER / 6);
-		SET_VEC(c1, x1, -1,  z0, TEST_LAYER / 6);
-		SET_VEC(c2, x1, -1, -z1, TEST_LAYER / 6);
-		SET_VEC(c3, x0, -1, -z1, TEST_LAYER / 6);
+		SET_VEC(c0, x0, -1, z0, TEST_LAYER / 6);
+		SET_VEC(c1, x1, -1, z0, TEST_LAYER / 6);
+		SET_VEC(c2, x1, -1, z1, TEST_LAYER / 6);
+		SET_VEC(c3, x0, -1, z1, TEST_LAYER / 6);
 		break;
 	case TEX_CUBE_SHADOW:
 		assert(TEST_LAYER % 6 == 3); /* negative Y */
-		SET_VEC(c0, x0, -1,  z0, z);
-		SET_VEC(c1, x1, -1,  z0, z);
-		SET_VEC(c2, x1, -1, -z1, z);
-		SET_VEC(c3, x0, -1, -z1, z);
+		SET_VEC(c0, x0, -1, z0, z);
+		SET_VEC(c1, x1, -1, z0, z);
+		SET_VEC(c2, x1, -1, z1, z);
+		SET_VEC(c3, x0, -1, z1, z);
 		break;
 	default:
 		assert(0);
@@ -1140,7 +1142,7 @@ piglit_display(void)
 	int fetch_level, baselevel, maxlevel, minlod, maxlod, bias, mipfilter;
 	int expected_level, x, y, total, failed;
 	int start_bias, end_bias;
-	int end_min_lod, end_max_lod, end_mipfilter;
+	int end_min_lod, end_max_lod, end_mipfilter, end_fetch_level;
 
 	if (no_bias) {
 		start_bias = 0;
@@ -1160,12 +1162,24 @@ piglit_display(void)
 
 	end_mipfilter = gltarget == GL_TEXTURE_RECTANGLE ? 0 : 1;
 
+	/* It's impossible to scale texture coordinates to fetch the last
+	 * level of a cubemap on a 3x3 quad. */
+	if ((gltarget == GL_TEXTURE_CUBE_MAP ||
+	     gltarget == GL_TEXTURE_CUBE_MAP_ARRAY) &&
+	    (test == GL3_TEXTURE ||
+	     test == GL3_TEXTURE_BIAS)) {
+		end_fetch_level = last_level - 1;
+	}
+	else {
+		end_fetch_level = last_level;
+	}
+
 	glClearColor(0.5, 0.5, 0.5, 0.5);
 	glClear(GL_COLOR_BUFFER_BIT);
 
 	total = 0;
 	failed = 0;
-	for (fetch_level = 0; fetch_level <= last_level; fetch_level++)
+	for (fetch_level = 0; fetch_level <= end_fetch_level; fetch_level++)
 		for (baselevel = 0; baselevel <= last_level; baselevel++)
 			for (maxlevel = baselevel; maxlevel <= last_level; maxlevel++)
 				for (minlod = 0; minlod <= end_min_lod; minlod++)
@@ -1228,7 +1242,7 @@ piglit_display(void)
 		glReadPixels(0, 0, piglit_width, piglit_height, GL_RGBA, GL_UNSIGNED_BYTE, pix);
 
 		total = 0;
-		for (fetch_level = 0; fetch_level <= last_level; fetch_level++)
+		for (fetch_level = 0; fetch_level <= end_fetch_level; fetch_level++)
 			for (baselevel = 0; baselevel <= last_level; baselevel++)
 				for (maxlevel = baselevel; maxlevel <= last_level; maxlevel++)
 					for (minlod = 0; minlod <= end_min_lod; minlod++)
-- 
1.9.1



More information about the Piglit mailing list