[Piglit] [PATCH] tex-miplevel-selection: test textureGrad with cubemaps
Marek Olšák
maraeo at gmail.com
Thu Aug 14 16:24:33 PDT 2014
From: Marek Olšák <marek.olsak at amd.com>
llvmpipe passes, which is probably the only driver which implements it
correctly.
---
tests/all.py | 8 ++++----
tests/texturing/tex-miplevel-selection.c | 20 +++++++++++++++++++-
2 files changed, 23 insertions(+), 5 deletions(-)
diff --git a/tests/all.py b/tests/all.py
index 0f69a66..10e24d9 100644
--- a/tests/all.py
+++ b/tests/all.py
@@ -1294,17 +1294,17 @@ add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection text
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 1D')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 2D')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 3D')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad Cube')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad Cube')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 2DRect')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 2DRectShadow')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 1DShadow')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 2DShadow')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad CubeShadow')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad CubeShadow')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 1DArray')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 2DArray')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 1DArrayShadow')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad 2DArrayShadow')
-#add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad CubeArray')
+add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGrad CubeArray')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGradOffset 1D')
add_concurrent_test(spec['glsl-1.30']['execution'], 'tex-miplevel-selection textureGradOffset 2D')
@@ -2056,7 +2056,7 @@ add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection
add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection *GradARB 1D')
add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection *GradARB 2D')
add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection *GradARB 3D')
-#add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection *GradARB Cube')
+add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection *GradARB Cube')
add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection *GradARB 1DShadow')
add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection *GradARB 2DShadow')
add_concurrent_test(arb_shader_texture_lod['execution'], 'tex-miplevel-selection *GradARB 2DRect')
diff --git a/tests/texturing/tex-miplevel-selection.c b/tests/texturing/tex-miplevel-selection.c
index ef9a066..761f9ae 100644
--- a/tests/texturing/tex-miplevel-selection.c
+++ b/tests/texturing/tex-miplevel-selection.c
@@ -1043,6 +1043,19 @@ draw_quad(int x, int y, int w, int h, int expected_level, int fetch_level,
/* explicit derivative */
float deriv = 1.0 / (TEX_SIZE >> fetch_level);
+ /* Explicit derivatives for cubemaps.
+ *
+ * Each of these vectors should be a difference between (x,y,z)
+ * coordinates from one pixel and its neighbor. The Y coordinate is
+ * always -1 (negative Y face).
+ *
+ * The range for X and Z is [-1,1] for cubemaps as opposed
+ * to [0,1] for 2D textures, therefore multiply the 2D derivative
+ * by 2. The result is 2 vectors on the -Y surface of the cube.
+ */
+ float cube_deriv_x[3] = {deriv*2, 0, 0};
+ float cube_deriv_y[3] = { 0, 0, deriv*2};
+
switch (test) {
case ARB_TEXTURE_LOD:
case ARB_TEXTURE_PROJ_LOD:
@@ -1079,7 +1092,12 @@ draw_quad(int x, int y, int w, int h, int expected_level, int fetch_level,
case ARB_TEXTURE_PROJ_GRAD:
case GL3_TEXTURE_GRAD:
case GL3_TEXTURE_PROJ_GRAD:
- if (gltarget == GL_TEXTURE_3D) {
+ if (gltarget == GL_TEXTURE_CUBE_MAP ||
+ gltarget == GL_TEXTURE_CUBE_MAP_ARRAY) {
+ glUniform3fv(loc_dx, 1, cube_deriv_x);
+ glUniform3fv(loc_dy, 1, cube_deriv_y);
+ }
+ else if (gltarget == GL_TEXTURE_3D) {
glUniform3f(loc_dx, 0, 0, deriv);
glUniform3f(loc_dy, 0, 0, deriv);
}
--
1.9.1
More information about the Piglit
mailing list