nv_compute_shader_derivatives: Test textures with implicit LOD

When quads or linear derivative groups are used, the texture functions
are able to perform implicit LOD calculation.  When no group is
specified, the LOD is always considered 0.
Reviewed-by: 's avatarIan Romanick <ian.d.romanick@intel.com>
parent 7c9637a1
# Check that sampling with implicit LOD works when using derivative
# group quads.
[require]
GL >= 4.5
GLSL >= 4.50
GL_NV_compute_shader_derivatives
[compute shader]
#version 450
#extension GL_NV_compute_shader_derivatives : require
layout(local_size_x = 2, local_size_y = 2) in;
layout(derivative_group_linearNV) in;
layout(binding = 0) uniform atomic_uint fail;
uniform sampler2D tex;
uniform int lod;
uniform vec4 expected;
// Manually map to a grid, for the sake of texture sampling.
vec2 texcoord[4] = {
vec2(0, 0),
vec2(1, 0),
vec2(0, 1),
vec2(1, 1),
};
void main() {
vec4 result = texture(tex, (texcoord[gl_LocalInvocationIndex] * (1 << lod)) / 8.0);
if (result != expected)
atomicCounterIncrement(fail);
}
[test]
atomic counters 1
# A 8x8 texture with levels in a different colors: R, G, B and White.
uniform int tex 0
texture miptree 0 (8, 8)
uniform int lod 0
uniform vec4 expected 1.0 0.0 0.0 1.0
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 1
uniform vec4 expected 0.0 1.0 0.0 1.0
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 2
uniform vec4 expected 0.0 0.0 1.0 1.0
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 3
uniform vec4 expected 1.0 1.0 1.0 1.0
compute 1 1 1
probe atomic counter 0 == 0
# Check that sampling always default to LOD=0 when the derivative
# group is not specified.
[require]
GL >= 4.5
GLSL >= 4.50
GL_NV_compute_shader_derivatives
[compute shader]
#version 450
#extension GL_NV_compute_shader_derivatives : require
layout(local_size_x = 2, local_size_y = 2) in;
layout(binding = 0) uniform atomic_uint fail;
uniform sampler2D tex;
uniform int lod;
uniform vec4 expected;
// Manually map to a grid, for the sake of texture sampling.
vec2 texcoord[4] = {
vec2(0, 0),
vec2(1, 0),
vec2(0, 1),
vec2(1, 1),
};
void main() {
vec4 result = texture(tex, (texcoord[gl_LocalInvocationIndex] * (1 << lod)) / 8.0);
if (result != expected)
atomicCounterIncrement(fail);
}
[test]
atomic counters 1
# A 8x8 texture with levels in a different colors: R, G, B and White.
uniform int tex 0
texture miptree 0 (8, 8)
# Expected is always RED, as the implicit LOD always defaults to zero
# when no derivative group is specified.
uniform vec4 expected 1.0 0.0 0.0 1.0
uniform int lod 0
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 1
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 2
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 3
compute 1 1 1
probe atomic counter 0 == 0
# Check that sampling with implicit LOD works when using derivative
# group quads.
[require]
GL >= 4.5
GLSL >= 4.50
GL_NV_compute_shader_derivatives
[compute shader]
#version 450
#extension GL_NV_compute_shader_derivatives : require
layout(local_size_x = 2, local_size_y = 2) in;
layout(derivative_group_quadsNV) in;
layout(binding = 0) uniform atomic_uint fail;
uniform sampler2D tex;
uniform int lod;
uniform vec4 expected;
void main() {
vec4 result = texture(tex, (gl_LocalInvocationID.xy * (1 << lod)) / 8.0);
if (result != expected)
atomicCounterIncrement(fail);
}
[test]
atomic counters 1
# A 8x8 texture with levels in a different colors: R, G, B and White.
uniform int tex 0
texture miptree 0 (8, 8)
uniform int lod 0
uniform vec4 expected 1.0 0.0 0.0 1.0
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 1
uniform vec4 expected 0.0 1.0 0.0 1.0
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 2
uniform vec4 expected 0.0 0.0 1.0 1.0
compute 1 1 1
probe atomic counter 0 == 0
uniform int lod 3
uniform vec4 expected 1.0 1.0 1.0 1.0
compute 1 1 1
probe atomic counter 0 == 0
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment