diff options
author | Chris Forbes <chrisf@ijw.co.nz> | 2015-01-25 10:38:52 +1300 |
---|---|---|
committer | Marek Olšák <marek.olsak@amd.com> | 2015-07-29 21:43:48 +0200 |
commit | fe4b48ad484eae779e313bc0a05cf85c6c96a9cf (patch) | |
tree | c1ff1c50a26adb98c1bd8e81a0b8caf829f3936d | |
parent | 9027ebb139bdc2b8a86bbf4cbdaccf5a73900c64 (diff) |
arb_tessellation_shader: add tests to exercise gl_PrimitiveID
v2: fixed by Marek
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Ilia Mirkin <imirkin@alum.mit.edu>
-rw-r--r-- | tests/spec/arb_tessellation_shader/execution/tcs-primitiveid.shader_test | 72 | ||||
-rw-r--r-- | tests/spec/arb_tessellation_shader/execution/tes-primitiveid.shader_test | 68 |
2 files changed, 140 insertions, 0 deletions
diff --git a/tests/spec/arb_tessellation_shader/execution/tcs-primitiveid.shader_test b/tests/spec/arb_tessellation_shader/execution/tcs-primitiveid.shader_test new file mode 100644 index 000000000..0aea046b6 --- /dev/null +++ b/tests/spec/arb_tessellation_shader/execution/tcs-primitiveid.shader_test @@ -0,0 +1,72 @@ +# Test the gl_PrimitiveID input in the TCS. + +[require] +GLSL >= 1.50 +GL_ARB_tessellation_shader +GL_ARB_shader_atomic_counters + +[vertex shader] +#version 150 + +out int id; + +void main() +{ + id = gl_VertexID; +} + +[tessellation control shader] +#version 150 +#extension GL_ARB_tessellation_shader : require +#extension GL_ARB_shader_atomic_counters: require + +layout(vertices = 4) out; +in int id[]; + +layout(binding=0) uniform atomic_uint matches; +layout(binding=0, offset=4) uniform atomic_uint mismatches; + +void main() +{ + /* we have single-vertex patches. primitive id == vertex id */ + if (id[0] == gl_PrimitiveID) + atomicCounterIncrement(matches); + else + atomicCounterIncrement(mismatches); + + /* cull the patch */ + gl_TessLevelInner[0] = 0.0; + gl_TessLevelInner[1] = 0.0; + + gl_TessLevelOuter[0] = 0.0; + gl_TessLevelOuter[1] = 0.0; + gl_TessLevelOuter[2] = 0.0; + gl_TessLevelOuter[3] = 0.0; +} + +[tessellation evaluation shader] +#version 150 +#extension GL_ARB_tessellation_shader : require + +layout(quads, equal_spacing) in; + +void main() +{ + gl_Position = vec4(0); +} + +[fragment shader] +#version 150 + +void main() +{ + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); +} + +[test] +atomic counters 2 +patch parameter vertices 1 +draw arrays GL_PATCHES 0 4 + +probe atomic counter 0 == 16 +probe atomic counter 1 == 0 diff --git a/tests/spec/arb_tessellation_shader/execution/tes-primitiveid.shader_test b/tests/spec/arb_tessellation_shader/execution/tes-primitiveid.shader_test new file mode 100644 index 000000000..2ff96d34b --- /dev/null +++ b/tests/spec/arb_tessellation_shader/execution/tes-primitiveid.shader_test @@ -0,0 +1,68 @@ +# Test the gl_PrimitiveID input in the TES. + +[require] +GLSL >= 1.50 +GL_ARB_tessellation_shader +GL_ARB_shader_atomic_counters + +[vertex shader passthrough] + +[tessellation control shader] +#version 150 +#extension GL_ARB_tessellation_shader : require + +layout(vertices = 1) out; +patch out int id; + +void main() +{ + id = gl_PrimitiveID; + + gl_TessLevelInner[0] = 1.0; + gl_TessLevelInner[1] = 1.0; + + gl_TessLevelOuter[0] = 1.0; + gl_TessLevelOuter[1] = 1.0; + gl_TessLevelOuter[2] = 1.0; + gl_TessLevelOuter[3] = 1.0; +} + +[tessellation evaluation shader] +#version 150 +#extension GL_ARB_tessellation_shader : require +#extension GL_ARB_shader_atomic_counters: require + +layout(quads, equal_spacing) in; +patch in int id; + +layout(binding=0) uniform atomic_uint matches; +layout(binding=0, offset=4) uniform atomic_uint mismatches; + +void main() +{ + gl_Position = vec4(0); + + /* primitive ID observed in TES should be the same as in TCS */ + if (id == gl_PrimitiveID) + atomicCounterIncrement(matches); + else + atomicCounterIncrement(mismatches); + +} + +[fragment shader] +#version 150 + +void main() +{ + gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0); +} + +[test] +atomic counters 2 +patch parameter vertices 1 +draw arrays GL_PATCHES 0 4 + +probe atomic counter 0 == 16 +probe atomic counter 1 == 0 + |