From 05f0f5603561daed2c134e13bc64649362759968 Mon Sep 17 00:00:00 2001 From: davli-nv Date: Wed, 20 Aug 2025 17:30:44 -0700 Subject: Implement SV_VulkanSamplePosition (#8236) -Adds semantic SV_VulkanSamplePosition that emits corresponding gl_SamplePosition and SpvBuiltinSamplePosition -Adds gl_SamplePosition property to glsl.meta.slang -Adds SPIRV and GLSL tests for the semantic and property -Plan is to later implement SV_SamplePosition that follows HLSL range of -0.5 to +0.5, and emits GetRenderTargetSamplePosition(SV_SampleIndex) which needs more complicated IR manipulation for HLSL and Metal Fixes #7906 --------- Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> --- tests/spirv/sv-vulkan-sample-position.slang | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/spirv/sv-vulkan-sample-position.slang (limited to 'tests/spirv') diff --git a/tests/spirv/sv-vulkan-sample-position.slang b/tests/spirv/sv-vulkan-sample-position.slang new file mode 100644 index 000000000..853ae03ac --- /dev/null +++ b/tests/spirv/sv-vulkan-sample-position.slang @@ -0,0 +1,21 @@ +//TEST:SIMPLE(filecheck=CHECK-SPIRV): -target spirv -stage fragment -entry main +//TEST:SIMPLE(filecheck=CHECK-GLSL): -target glsl -stage fragment -entry main + +// Test for SV_VulkanSamplePosition support + +// CHECK-SPIRV: OpCapability SampleRateShading +// CHECK-SPIRV-DAG: OpDecorate {{.*}} BuiltIn SamplePosition +// CHECK-GLSL-DAG: gl_SamplePosition + +import glsl; + +struct FragmentInput +{ + float2 samplePosition : SV_VulkanSamplePosition; +} + +[shader("fragment")] +float4 main(FragmentInput input) : SV_Target +{ + return float4(input.samplePosition.x, gl_SamplePosition.y, 0.0, 1.0); +} \ No newline at end of file -- cgit v1.2.3