diff options
| author | davli-nv <davli@nvidia.com> | 2025-08-05 10:55:52 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-08-05 17:55:52 +0000 |
| commit | 83675103a1a4fefde11b314aed26f4d37860efe7 (patch) | |
| tree | 136f597da62532f4b9361ff0d9e785d413fef2f1 /tests | |
| parent | 2d775b54d2ab7772785c2196075d4c7c174407ab (diff) | |
Implement SPV_EXT_fragment_invocation_density (SPV_NV_shading_rate) (#8037)
* Implement SPV_EXT_fragment_invocation_density
-Adds semantics SV_FragSize and SV_FragInvocationCount and implements them for SPIRV and GLSL using the appropriate target builtins from extensions.
-Adds test case checking for expected target builtins from these semantics.
-For future work, could implement SV_FragSize using pixel shader input SV_ShadingRate for HLSL, and SV_FragInvocationCount needs research.
Fixes #7974
Generated with Claude Code
* address review feedback
https://github.com/shader-slang/slang/pull/8037#pullrequestreview-3084645845
* fixup format
* review feedback
https://github.com/shader-slang/slang/pull/8037#pullrequestreview-3086442819
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/glsl/fragment-invocation-density-glsl.slang | 15 | ||||
| -rw-r--r-- | tests/spirv/fragment-invocation-density.slang | 25 |
2 files changed, 40 insertions, 0 deletions
diff --git a/tests/glsl/fragment-invocation-density-glsl.slang b/tests/glsl/fragment-invocation-density-glsl.slang new file mode 100644 index 000000000..7cee4620b --- /dev/null +++ b/tests/glsl/fragment-invocation-density-glsl.slang @@ -0,0 +1,15 @@ +//TEST:SIMPLE(filecheck=CHECK-GLSL): -target glsl -stage fragment -entry main + +// Test for EXT_fragment_invocation_density support (gl_FragSizeEXT and gl_FragInvocationCountEXT ) +import glsl; + +layout(location = 0) out highp vec4 FragColor; + +void main() +{ + // CHECK-GLSL: #extension GL_EXT_fragment_invocation_density : require + // CHECK-GLSL-DAG: gl_FragSizeEXT + // CHECK-GLSL-DAG: gl_FragInvocationCountEXT + + FragColor = vec4(gl_FragSizeEXT.x, gl_FragSizeEXT.y, gl_FragInvocationCountEXT, 1.0); +}
\ No newline at end of file diff --git a/tests/spirv/fragment-invocation-density.slang b/tests/spirv/fragment-invocation-density.slang new file mode 100644 index 000000000..f26b403ec --- /dev/null +++ b/tests/spirv/fragment-invocation-density.slang @@ -0,0 +1,25 @@ +//TEST:SIMPLE(filecheck=CHECK-SPIRV): -target spirv -stage fragment -entry main +//TEST:SIMPLE(filecheck=CHECK-GLSL): -target glsl -stage fragment -entry main + +// Test for SPV_EXT_fragment_invocation_density support (SV_FragSize and SV_FragInvocationCount) + +struct FragmentInput +{ + int2 fragmentSize : SV_FragSize; + int invocationsPerPixel : SV_FragInvocationCount; +} + +[shader("fragment")] +float4 main(FragmentInput input) : SV_Target +{ + // CHECK-SPIRV: OpCapability FragmentDensityEXT + // CHECK-SPIRV: OpExtension "SPV_EXT_fragment_invocation_density" + // CHECK-SPIRV-DAG: OpDecorate {{.*}} BuiltIn FragSizeEXT + // CHECK-SPIRV-DAG: OpDecorate {{.*}} BuiltIn FragInvocationCountEXT + + // CHECK-GLSL: #extension GL_EXT_fragment_invocation_density : require + // CHECK-GLSL-DAG: gl_FragSizeEXT + // CHECK-GLSL-DAG: gl_FragInvocationCountEXT + + return float4(input.fragmentSize.x, input.fragmentSize.y, input.invocationsPerPixel, 1.0); +}
\ No newline at end of file |
