summaryrefslogtreecommitdiffstats
path: root/docs/language-reference/08-attributes.md
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2022-05-18 10:09:28 -0400
committerGitHub <noreply@github.com>2022-05-18 10:09:28 -0400
commit1148564b9cdbbc8fec4fbecf65b0af60aa6af344 (patch)
treefc5ca7629aed7e60797163c33deb56a4137249b4 /docs/language-reference/08-attributes.md
parentd9fd0ff3f0fc7b775de1e05570f01798fbc8baa3 (diff)
Support for `[[vk::spirv_instruction(op)]]` (#2242)
* #include an absolute path didn't work - because paths were taken to always be relative. * Add extension required by SPIRVOpDecoration into part of emit (could be a prior pass). * Add [[vk::spirv_instruction]] attribute * Add documentation for [[vk::spirv_instruction]. * Update 08-attributes.md * Update 08-attributes.md
Diffstat (limited to 'docs/language-reference/08-attributes.md')
-rw-r--r--docs/language-reference/08-attributes.md26
1 files changed, 26 insertions, 0 deletions
diff --git a/docs/language-reference/08-attributes.md b/docs/language-reference/08-attributes.md
index 4098303cf..76a739315 100644
--- a/docs/language-reference/08-attributes.md
+++ b/docs/language-reference/08-attributes.md
@@ -2,3 +2,29 @@ Attributes
==========
> Note: This section is not yet complete.
+
+## [[vk::spirv_instruction]]
+
+** SPIR-V only **
+
+This attribute is only available for Vulkan SPIR-V output via GLSLANG. In the future it could be supported via the `direct-spirv` option. The attribute will be ignored for any other target. This attribute requires the `GL_EXT_spirv_intrinsics` GLSL extension.
+
+The attibute allows access to SPIR-V intrinsics, by supplying a function declaration with the appropriate signature for the SPIR-V op and no body. The intrinsic takes a single parameter which is the integer value for the SPIR-V op.
+
+In the example below the add function, uses the mechanism to directly use the SPIR-V integer add 'op' which is 128 in this case.
+
+```HLSL
+// 128 is OpIAdd in SPIR-V
+[[vk::spirv_instruction(128)]]
+uint add(uint a, uint b);
+
+RWStructuredBuffer<uint> resultBuffer;
+
+[numthreads(4,1,1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint threadId = dispatchThreadID.x;
+ resultBuffer[threadId] = add(threadId, threadId);
+}
+```
+