[Piglit] [PATCH 14/23] tex-miplevel-selection: test all variants of textureProjLodOffset

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


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

+ Use level 0 texture coordinates to really verify the Lod fetch works.
  It was using scaled coordinates, so textureLodOffset could have been
  replaced by textureOffset and the test would pass. Now the test will
  fail if drivers attempt to fake it that way.
---
 tests/all.py                             |  8 +++++
 tests/texturing/tex-miplevel-selection.c | 57 +++++++++++++++++++++++---------
 2 files changed, 50 insertions(+), 15 deletions(-)

diff --git a/tests/all.py b/tests/all.py
index bc8f31c..791e22f 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1284,6 +1284,14 @@ add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection text
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLod 1DShadow')
 add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLod 2DShadow')
 
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLodOffset 1D')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLodOffset 1D_ProjVec4')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLodOffset 2D')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLodOffset 2D_ProjVec4')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLodOffset 3D')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLodOffset 1DShadow')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureProjLodOffset 2DShadow')
+
 # Group spec/glsl-1.40
 spec['glsl-1.40'] = {}
 import_glsl_parser_tests(spec['glsl-1.40'],
diff --git a/tests/texturing/tex-miplevel-selection.c b/tests/texturing/tex-miplevel-selection.c
index d7468ed..16de9e1 100644
--- a/tests/texturing/tex-miplevel-selection.c
+++ b/tests/texturing/tex-miplevel-selection.c
@@ -128,6 +128,7 @@ enum shader_type {
 	GL3_TEXTURE_PROJ_OFFSET_BIAS,
 	GL3_TEXTURE_LOD_OFFSET,
 	GL3_TEXTURE_PROJ_LOD,
+	GL3_TEXTURE_PROJ_LOD_OFFSET,
 };
 
 #define NEED_ARB_LOD(t) ((t) == ARB_SHADER_TEXTURE_LOD)
@@ -223,6 +224,8 @@ piglit_init(int argc, char **argv)
 			test = GL3_TEXTURE_LOD_OFFSET;
 		else if (strcmp(argv[i], "textureProjLod") == 0)
 			test = GL3_TEXTURE_PROJ_LOD;
+		else if (strcmp(argv[i], "textureProjLodOffset") == 0)
+			test = GL3_TEXTURE_PROJ_LOD_OFFSET;
 		else if (strcmp(argv[i], "1D") == 0)
 			target = TEX_1D;
 		else if (strcmp(argv[i], "1D_ProjVec4") == 0)
@@ -381,7 +384,8 @@ piglit_init(int argc, char **argv)
 	    test == GL3_TEXTURE_PROJ_BIAS ||
 	    test == GL3_TEXTURE_PROJ_OFFSET ||
 	    test == GL3_TEXTURE_PROJ_OFFSET_BIAS ||
-	    test == GL3_TEXTURE_PROJ_LOD) {
+	    test == GL3_TEXTURE_PROJ_LOD ||
+	    test == GL3_TEXTURE_PROJ_LOD_OFFSET) {
 		if (!strcmp(type_str, "float"))
 			type_str = "vec2";
 		else if (!strcmp(type_str, "vec2"))
@@ -443,6 +447,10 @@ piglit_init(int argc, char **argv)
 		instruction = "textureProjLod";
 		other_params = ", lod";
 		break;
+	case GL3_TEXTURE_PROJ_LOD_OFFSET:
+		instruction = "textureProjLodOffset";
+		other_params = ", lod, OFFSET";
+		break;
 	default:
 		assert(0);
 	}
@@ -483,7 +491,8 @@ piglit_init(int argc, char **argv)
 		if (test == ARB_SHADER_TEXTURE_LOD ||
 		    test == GL3_TEXTURE_LOD ||
 		    test == GL3_TEXTURE_LOD_OFFSET ||
-		    test == GL3_TEXTURE_PROJ_LOD)
+		    test == GL3_TEXTURE_PROJ_LOD ||
+		    test == GL3_TEXTURE_PROJ_LOD_OFFSET)
 			loc_lod = glGetUniformLocation(prog, "lod");
 
 		if (test == GL3_TEXTURE_BIAS ||
@@ -496,7 +505,8 @@ piglit_init(int argc, char **argv)
 		    test == GL3_TEXTURE_OFFSET_BIAS ||
 		    test == GL3_TEXTURE_PROJ_OFFSET ||
 		    test == GL3_TEXTURE_PROJ_OFFSET_BIAS ||
-		    test == GL3_TEXTURE_LOD_OFFSET) {
+		    test == GL3_TEXTURE_LOD_OFFSET ||
+		    test == GL3_TEXTURE_PROJ_LOD_OFFSET) {
 			has_offset = GL_TRUE;
 			no_lod_clamp = GL_TRUE; /* not implemented for now */
 		}
@@ -710,21 +720,16 @@ draw_quad(int x, int y, int w, int h, int expected_level, int fetch_level,
 
 	case GL3_TEXTURE_OFFSET_BIAS:
 	case GL3_TEXTURE_PROJ_OFFSET_BIAS:
-	case GL3_TEXTURE_LOD_OFFSET:
-		if (loc_bias != -1)
-			glUniform1f(loc_bias, bias);
-		if (loc_lod != -1)
-			glUniform1f(loc_lod, fetch_level - baselevel);
+		glUniform1f(loc_bias, bias);
 		/* fall through */
 	case GL3_TEXTURE_OFFSET:
 	case GL3_TEXTURE_PROJ_OFFSET:
 	{
-		/* Things get quite complicated with offsets.
-		 *
-		 * The single pixel which is not black has the same integer
-		 * coordinates in every mipmap level, but not the same normalized
-		 * coordinates. Therefore we have to fix the normalized ones, so
-		 * that GLSL always reads from the same integer coordinates.
+		/* When testing the texture offset, there is only one pixel which
+		 * is not black and it has the same integer coordinates in every
+		 * mipmap level, but not the same normalized coordinates. Therefore,
+		 * we have to fix the normalized ones, so that GLSL always reads
+		 * from the same integer coordinates.
 		 */
 		int maxlevel_clamped = mipfilter ? maxlevel : baselevel;
 		int bias_clamped =
@@ -754,6 +759,27 @@ draw_quad(int x, int y, int w, int h, int expected_level, int fetch_level,
 		}
 		break;
 	}
+
+	case GL3_TEXTURE_LOD_OFFSET:
+	case GL3_TEXTURE_PROJ_LOD_OFFSET:
+		glUniform1f(loc_lod, fetch_level - baselevel);
+
+		/* When testing the texture offset, there is only one pixel which
+		 * is not black and it has the same integer coordinates in every
+		 * mipmap level, but not the same normalized coordinates. Therefore,
+		 * we have to fix the normalized ones, so that GLSL always reads
+		 * from the same integer coordinates.
+		 */
+		if (expected_level > 0) {
+			float pixsize_base = 1.0 / TEX_SIZE;
+			float offset = pixsize_base * ((1 << (expected_level-1))*3 - 1.5);
+
+			s0 += offset;
+			t0 += offset;
+			s1 += offset;
+			t1 += offset;
+		}
+		break;
 	default:
 		assert(0);
 	}
@@ -762,7 +788,8 @@ draw_quad(int x, int y, int w, int h, int expected_level, int fetch_level,
 	    test == GL3_TEXTURE_PROJ_BIAS ||
 	    test == GL3_TEXTURE_PROJ_OFFSET ||
 	    test == GL3_TEXTURE_PROJ_OFFSET_BIAS ||
-	    test == GL3_TEXTURE_PROJ_LOD)
+	    test == GL3_TEXTURE_PROJ_LOD ||
+	    test == GL3_TEXTURE_PROJ_LOD_OFFSET)
 		p = 7;
 
 	switch (target) {
-- 
1.9.1



More information about the Piglit mailing list