diff options
| -rw-r--r-- | source/slang/core.meta.slang | 12 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/fragment-shader-interlock.slang | 20 | ||||
| -rw-r--r-- | tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl | 31 |
3 files changed, 63 insertions, 0 deletions
diff --git a/source/slang/core.meta.slang b/source/slang/core.meta.slang index d63311985..de78229a9 100644 --- a/source/slang/core.meta.slang +++ b/source/slang/core.meta.slang @@ -1943,6 +1943,18 @@ __target_intrinsic(cuda, " @ ") __target_intrinsic(cpp, " @ ") int __SyntaxError(); +/// Mark beginning of "interlocked" operations in a fragment shader. +__target_intrinsic(glsl, "beginInvocationInterlockARB") +__glsl_extension(GL_ARB_fragment_shader_interlock) +__glsl_version(420) +void beginInvocationInterlock() {} + +/// Mark end of "interlocked" operations in a fragment shader. +__target_intrinsic(glsl, "endInvocationInterlockARB") +__glsl_extension(GL_ARB_fragment_shader_interlock) +__glsl_version(420) +void endInvocationInterlock() {} + // Operators to apply to `enum` types __generic<E : __EnumType> diff --git a/tests/pipeline/rasterization/fragment-shader-interlock.slang b/tests/pipeline/rasterization/fragment-shader-interlock.slang new file mode 100644 index 000000000..66597a9a8 --- /dev/null +++ b/tests/pipeline/rasterization/fragment-shader-interlock.slang @@ -0,0 +1,20 @@ +// fragment-shader-interlock.slang + +// Test that explicit use of fragment-shader interlock (FSI) +// operations is supported by Slang + +//TEST:CROSS_COMPILE:-target spirv -entry main -stage fragment + +[shader("fragment")] +void main( + float4 coords : COORDS, + uniform RasterizerOrderedTexture2D<float4> texture, + out float4 result : SV_Target) +{ + beginInvocationInterlock(); + + result = texture[coords.xy]; + texture[coords.xy] = result + coords; + + endInvocationInterlock(); +} diff --git a/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl b/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl new file mode 100644 index 000000000..a12b9827b --- /dev/null +++ b/tests/pipeline/rasterization/fragment-shader-interlock.slang.glsl @@ -0,0 +1,31 @@ +//TEST_IGNORE_FILE: + +#version 450 +#extension GL_ARB_fragment_shader_interlock : require + +layout(rgba32f) +layout(binding = 0) +uniform image2D entryPointParams_texture_0; + +layout(location = 0) +in vec4 _S1; + +layout(location = 0) +out vec4 _S2; + +void main() +{ + vec4 _S3; + + beginInvocationInterlockARB(); + + vec4 _S4 = (imageLoad((entryPointParams_texture_0), ivec2((uvec2(_S1.xy))))); + + _S3 = _S4; + imageStore((entryPointParams_texture_0), ivec2((uvec2(_S1.xy))), _S3 + _S1); + + endInvocationInterlockARB(); + + _S2 = _S3; + return; +} |
