yum-mirror/slang

Making it easier to work with shaders

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

Ellie HermaszewskaAllow bitwise or expressions and numeric literals in spirv_asm blocks (#3157)508dc3a95

master
719 B26 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -shaderobj -emit-spirv-directly
2
3//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):out,name=outputBuffer
4RWStructuredBuffer<int> outputBuffer;
5
6// CHECK:      2
7// CHECK-NEXT: 4
8// CHECK-NEXT: 6
9// CHECK-NEXT: 8
10
11//
12// This tests that we can look up a type qualified enum in a spirv block
13//
14[numthreads(4, 1, 1)]
15void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
16{
17    int i = dispatchThreadID.x;
18    int n = outputBuffer[i];
19    int r = spirv_asm
20    {
21        // MemorySemanticsAcquire happens to have value 0x2
22        %two   : $$int = OpConstant MemorySemanticsAcquire;
23        result : $$int = OpIMul $n %two
24    };
25    outputBuffer[i] = r;
26}