From 02e18b55faff56c037a76645c793b24b712fa375 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Tue, 6 Nov 2018 16:16:52 -0800 Subject: Translate NonUniformResourceIndex() calls to Vulkan GLSL (#713) These calls translate to uses of the `nonuniformEXT` qualifier introduced by the `GL_EXT_nonuniform_qualifier` extension. The standard library changes in this case are straightforward uses of existing compiler mechanisms. The test case is one of the less pleasant ones where we compare SPIR-V output against SPIR-V generated from a hand-coded GLSL baseline. This is a case where a simpler test type that just checks for specific textual matches in the output (and not whole files) would be better, but that is out of scope for this change. --- tests/cross-compile/non-uniform-indexing.slang | 13 ++++++++++ .../cross-compile/non-uniform-indexing.slang.glsl | 28 ++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 tests/cross-compile/non-uniform-indexing.slang create mode 100644 tests/cross-compile/non-uniform-indexing.slang.glsl (limited to 'tests') diff --git a/tests/cross-compile/non-uniform-indexing.slang b/tests/cross-compile/non-uniform-indexing.slang new file mode 100644 index 000000000..647742df8 --- /dev/null +++ b/tests/cross-compile/non-uniform-indexing.slang @@ -0,0 +1,13 @@ +//TEST:CROSS_COMPILE:-target spirv-assembly -entry main -stage fragment + +// Confirm that `NonUniformResourceIndex` translates to SPIR-V as expeted + +Texture2D t[10]; +SamplerState s; + +float4 main( + float3 uv : UV) + : SV_Target +{ + return t[NonUniformResourceIndex(int(uv.z))].Sample(s, uv.xy); +} diff --git a/tests/cross-compile/non-uniform-indexing.slang.glsl b/tests/cross-compile/non-uniform-indexing.slang.glsl new file mode 100644 index 000000000..83f63c70d --- /dev/null +++ b/tests/cross-compile/non-uniform-indexing.slang.glsl @@ -0,0 +1,28 @@ +//TEST_IGNORE_FILE +#version 450 + +#extension GL_EXT_nonuniform_qualifier : require + +layout(binding = 0) +uniform texture2D t_0[10]; + +layout(binding = 1) +uniform sampler s_0; + +layout(location = 0) +out vec4 _S1; + +layout(location = 0) +in vec3 _S2; + +void main() +{ + vec3 _S3 = _S2; + + int _S4 = nonuniformEXT(int(_S3.z)); + + vec4 _S5 = texture(sampler2D(t_0[_S4],s_0), _S3.xy); + + _S1 = _S5; + return; +} -- cgit v1.2.3