summaryrefslogtreecommitdiffstats
path: root/source
diff options
context:
space:
mode:
authorTim Foley <tfoleyNV@users.noreply.github.com>2021-02-22 15:07:26 -0800
committerGitHub <noreply@github.com>2021-02-22 15:07:26 -0800
commit025c0edc3fd3fb751b36058596a0733ac24b8939 (patch)
tree1529b4c7066044228c3012e5b8c751b05604f7ba /source
parente1e4220621b3bbf01d65b61a6e4f468651205b66 (diff)
Add basic support for fragment shader interlock (FSI) (#1722)
Both D3D "rasterizer ordered views" (ROVs) and GLSL "fragment shader interlock" (FSI) are aimed at the same basic use case: they allow for fragment shaders to contain operations that require mutual exclusion and/or deterinistics ordering between fragment shader invocations that affect the same framebuffer coordinates. The language-level exposure of the features varies greatly between the two API families, though: * ROVs define an implicit ordering and mutual exclusion constraint: certain resoure parameters are marked as `RasterizerOrdered`, and reads/writes to these resources must be sequences *as if* fragment-shader invocations ran in sequential order for each pixel. * FSI defines paired begin/end functions that mark a critical section of code. All memory operations in the critical section must be sequences *as if* fragment-shader invocations ran in sequential order for each pixel. In order to make this model tractable, only a single critical section is allowed per fragment shader, and the begin/end must appear at the top level of the shader entry point function (not under control flow or after a possible conditional `return`. The simplest way for Slang to support portable programs that run across both API families is to insist that code that cares about these ordering guarantees must use *both* mechanisms, and then each of them will only affect the API that cares about it. Slang already supports ROV resource types, and already lowers them to plain textures for GLSL/SPIR-V. This change adds the missing feature of a begin/end function pair for FSI, which will map to empty functions on non-GLSL targets.
Diffstat (limited to 'source')
-rw-r--r--source/slang/core.meta.slang12
1 files changed, 12 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>