yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Bruce Mitchenerdocs: Reduce typo count (#5671)c3557978c

master
958 B32 linesraw

Note: This document is a work in progress. It is both incomplete and, in many cases, inaccurate.

Attributes

Note: This section is not yet complete.

[[vk::spirv_instruction]]

** SPIR-V only **

This attribute is only available for Vulkan SPIR-V output.

The attribute 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.

// 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);
}
1> Note: This document is a work in progress. It is both incomplete and, in many cases, inaccurate.
2
3Attributes
4==========
5
6> Note: This section is not yet complete.
7
8## [[vk::spirv_instruction]]
9
10** SPIR-V only **
11
12This attribute is only available for Vulkan SPIR-V output.
13
14The attribute 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.
15
16In the example below the add function, uses the mechanism to directly use the SPIR-V integer add 'op' which is 128 in this case.
17
18```HLSL
19// 128 is OpIAdd in SPIR-V
20[[vk::spirv_instruction(128)]]
21uint add(uint a, uint b);
22
23RWStructuredBuffer<uint> resultBuffer;
24
25[numthreads(4,1,1)]
26void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
27{
28    uint threadId = dispatchThreadID.x;
29    resultBuffer[threadId] = add(threadId, threadId);
30}
31```
32