nv_compute_shader_derivatives: Test use of derivatives

v2: Add proper fine derivative tests. (Ian)
    Test all derivative functions when derivative group is set to
    None. (Caio)
Reviewed-by: 's avatarIan Romanick <ian.d.romanick@intel.com>
parent 886f8274
# Use dFdxCoarse and dFdxCoarse in linearNV. The local size is 4x2,
# which contains two sequences of four values (the two rows). The
# derivatives_y will verify the linearNV is working.
[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 = 4, local_size_y = 2) in;
layout(derivative_group_linearNV) in;
layout(binding = 0) buffer SSBO {
uint value[8];
uint derivatives_x[8];
uint derivatives_y[8];
};
void main() {
uint index = gl_LocalInvocationIndex;
derivatives_x[index] = uint(dFdxCoarse(value[index]));
derivatives_y[index] = uint(dFdyCoarse(value[index]));
// Check mapping between gl_LocalInvocationIndex and
// gl_LocalInvocationID is preserved.
uvec3 size = gl_WorkGroupSize;
uvec3 id = gl_LocalInvocationID;
if (id.x != (index % size.x) ||
id.y != ((index / size.x) % size.y) ||
id.z != ((index / (size.x * size.y)) % size.z)) {
// Force failure since no derivative will be that large.
derivatives_x[index] = (size.x * size.y * size.z) + 1;
derivatives_y[index] = (size.x * size.y * size.z) + 1;
}
}
[test]
ssbo 0 96
# value[8]
ssbo 0 subdata int 0 10
ssbo 0 subdata int 4 20
ssbo 0 subdata int 8 30
ssbo 0 subdata int 12 40
ssbo 0 subdata int 16 50
ssbo 0 subdata int 20 60
ssbo 0 subdata int 24 70
ssbo 0 subdata int 28 80
compute 1 1 1
# derivatives_x[8]
probe ssbo uint 0 32 == 10
probe ssbo uint 0 36 == 10
probe ssbo uint 0 40 == 10
probe ssbo uint 0 44 == 10
probe ssbo uint 0 48 == 10
probe ssbo uint 0 52 == 10
probe ssbo uint 0 56 == 10
probe ssbo uint 0 60 == 10
# derivatives_y[8]
probe ssbo uint 0 64 == 20
probe ssbo uint 0 68 == 20
probe ssbo uint 0 72 == 20
probe ssbo uint 0 76 == 20
probe ssbo uint 0 80 == 20
probe ssbo uint 0 84 == 20
probe ssbo uint 0 88 == 20
probe ssbo uint 0 92 == 20
# Use dFdxCoarse and dFdyCoarse in quadsNV. The local size is 4x2, which
# contains two quads side by side. The derivatives_y will verify
# quadsNV are working.
[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 = 4, local_size_y = 2) in;
layout(derivative_group_quadsNV) in;
layout(binding = 0) buffer SSBO {
uint value[8];
uint derivatives_x[8];
uint derivatives_y[8];
};
void main() {
uint index = gl_LocalInvocationIndex;
derivatives_x[index] = uint(dFdxCoarse(value[index]));
derivatives_y[index] = uint(dFdyCoarse(value[index]));
// Check mapping between gl_LocalInvocationIndex and
// gl_LocalInvocationID is preserved.
uvec3 size = gl_WorkGroupSize;
uvec3 id = gl_LocalInvocationID;
if (id.x != (index % size.x) ||
id.y != ((index / size.x) % size.y) ||
id.z != ((index / (size.x * size.y)) % size.z)) {
// Force failure since no derivative will be that large.
derivatives_x[index] = (size.x * size.y * size.z) + 1;
derivatives_y[index] = (size.x * size.y * size.z) + 1;
}
}
[test]
ssbo 0 96
# value[8]
ssbo 0 subdata int 0 10
ssbo 0 subdata int 4 20
ssbo 0 subdata int 8 30
ssbo 0 subdata int 12 40
ssbo 0 subdata int 16 50
ssbo 0 subdata int 20 60
ssbo 0 subdata int 24 70
ssbo 0 subdata int 28 80
compute 1 1 1
# derivatives_x[8]
probe ssbo uint 0 32 == 10
probe ssbo uint 0 36 == 10
probe ssbo uint 0 40 == 10
probe ssbo uint 0 44 == 10
probe ssbo uint 0 48 == 10
probe ssbo uint 0 52 == 10
probe ssbo uint 0 56 == 10
probe ssbo uint 0 60 == 10
# derivatives_y[8]
probe ssbo uint 0 64 == 40
probe ssbo uint 0 68 == 40
probe ssbo uint 0 72 == 40
probe ssbo uint 0 76 == 40
probe ssbo uint 0 80 == 40
probe ssbo uint 0 84 == 40
probe ssbo uint 0 88 == 40
probe ssbo uint 0 92 == 40
# Use dFdxFine and dFdyFine in linearNV. The local size is 4x2, which
# contains two quads side by side. The derivatives_y will verify
# quadsNV are working.
[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 = 4, local_size_y = 2) in;
layout(derivative_group_linearNV) in;
layout(binding = 0) uniform atomic_uint fail;
layout(binding = 0) buffer SSBO {
uint value[8];
uint derivatives_x[8];
uint derivatives_y[8];
};
void main() {
uint index = gl_LocalInvocationIndex;
derivatives_x[index] = uint(dFdxFine(value[index]));
derivatives_y[index] = uint(dFdyFine(value[index]));
// Check mapping between gl_LocalInvocationIndex and
// gl_LocalInvocationID is preserved.
uvec3 size = gl_WorkGroupSize;
uvec3 id = gl_LocalInvocationID;
if (id.x != (index % size.x) ||
id.y != ((index / size.x) % size.y) ||
id.z != ((index / (size.x * size.y)) % size.z)) {
atomicCounterIncrement(fail);
}
}
[test]
atomic counters 1
ssbo 0 96
# value[8]
ssbo 0 subdata int 0 2
ssbo 0 subdata int 4 3
ssbo 0 subdata int 8 5
ssbo 0 subdata int 12 8
ssbo 0 subdata int 16 13
ssbo 0 subdata int 20 21
ssbo 0 subdata int 24 34
ssbo 0 subdata int 28 55
compute 1 1 1
probe atomic counter 0 == 0
# derivatives_x[8]
probe ssbo uint 0 32 == 1
probe ssbo uint 0 36 == 1
probe ssbo uint 0 40 == 3
probe ssbo uint 0 44 == 3
probe ssbo uint 0 48 == 8
probe ssbo uint 0 52 == 8
probe ssbo uint 0 56 == 21
probe ssbo uint 0 60 == 21
# derivatives_y[8]
probe ssbo uint 0 64 == 3
probe ssbo uint 0 68 == 5
probe ssbo uint 0 72 == 3
probe ssbo uint 0 76 == 5
probe ssbo uint 0 80 == 21
probe ssbo uint 0 84 == 34
probe ssbo uint 0 88 == 21
probe ssbo uint 0 92 == 34
# Use dFdxFine and dFdyFine in quadsNV. The local size is 4x2, which
# contains two quads side by side. The derivatives_y will verify
# quadsNV are working. Also ensure that inside a quad all the derivatives
# are different.
[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 = 4, local_size_y = 2) in;
layout(derivative_group_quadsNV) in;
layout(binding = 0) uniform atomic_uint fail;
layout(binding = 0) buffer SSBO {
uint value[8];
uint derivatives_x[8];
uint derivatives_y[8];
};
void main() {
uint index = gl_LocalInvocationIndex;
derivatives_x[index] = uint(dFdxFine(value[index]));
derivatives_y[index] = uint(dFdyFine(value[index]));
// Check mapping between gl_LocalInvocationIndex and
// gl_LocalInvocationID is preserved.
uvec3 size = gl_WorkGroupSize;
uvec3 id = gl_LocalInvocationID;
if (id.x != (index % size.x) ||
id.y != ((index / size.x) % size.y) ||
id.z != ((index / (size.x * size.y)) % size.z)) {
atomicCounterIncrement(fail);
}
}
[test]
atomic counters 1
ssbo 0 96
# value[8]
ssbo 0 subdata int 0 2
ssbo 0 subdata int 4 3
ssbo 0 subdata int 8 5
ssbo 0 subdata int 12 8
ssbo 0 subdata int 16 13
ssbo 0 subdata int 20 21
ssbo 0 subdata int 24 34
ssbo 0 subdata int 28 55
compute 1 1 1
probe atomic counter 0 == 0
# derivatives_x[8]
probe ssbo uint 0 32 == 1
probe ssbo uint 0 36 == 1
probe ssbo uint 0 40 == 3
probe ssbo uint 0 44 == 3
probe ssbo uint 0 48 == 8
probe ssbo uint 0 52 == 8
probe ssbo uint 0 56 == 21
probe ssbo uint 0 60 == 21
# derivatives_y[8]
probe ssbo uint 0 64 == 11
probe ssbo uint 0 68 == 18
probe ssbo uint 0 72 == 29
probe ssbo uint 0 76 == 47
probe ssbo uint 0 80 == 11
probe ssbo uint 0 84 == 18
probe ssbo uint 0 88 == 29
probe ssbo uint 0 92 == 47
# When the extension is used but no arrangement is declared, all the
# derivatives will return 0.
[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 = 6, local_size_y = 4) in;
layout(binding = 0) uniform atomic_uint fail;
layout(binding = 0) buffer SSBO {
uint value[24];
};
void main() {
uint index = gl_LocalInvocationIndex;
if (dFdxFine(value[index]) != 0.0)
atomicCounterIncrement(fail);
if (dFdxCoarse(value[index]) != 0.0)
atomicCounterIncrement(fail);
if (dFdx(value[index]) != 0.0)
atomicCounterIncrement(fail);
if (dFdyFine(value[index]) != 0.0)
atomicCounterIncrement(fail);
if (dFdyCoarse(value[index]) != 0.0)
atomicCounterIncrement(fail);
if (dFdy(value[index]) != 0.0)
atomicCounterIncrement(fail);
// Check mapping between gl_LocalInvocationIndex and
// gl_LocalInvocationID is preserved.
uvec3 size = gl_WorkGroupSize;
uvec3 id = gl_LocalInvocationID;
if (id.x != (index % size.x) ||
id.y != ((index / size.x) % size.y) ||
id.z != ((index / (size.x * size.y)) % size.z)) {
atomicCounterIncrement(fail);
}
}
[test]
atomic counters 1
ssbo 0 96
# value[8]
ssbo 0 subdata int 0 110
ssbo 0 subdata int 4 120
ssbo 0 subdata int 8 130
ssbo 0 subdata int 12 140
ssbo 0 subdata int 16 150
ssbo 0 subdata int 20 160
ssbo 0 subdata int 24 170
ssbo 0 subdata int 28 180
ssbo 0 subdata int 32 210
ssbo 0 subdata int 36 220
ssbo 0 subdata int 40 230
ssbo 0 subdata int 44 240
ssbo 0 subdata int 48 250
ssbo 0 subdata int 52 260
ssbo 0 subdata int 56 270
ssbo 0 subdata int 60 280
ssbo 0 subdata int 64 310
ssbo 0 subdata int 68 320
ssbo 0 subdata int 72 330
ssbo 0 subdata int 76 340
ssbo 0 subdata int 80 350
ssbo 0 subdata int 84 360
ssbo 0 subdata int 88 370
ssbo 0 subdata int 92 380
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