yum-mirror/slang

Making it easier to work with shaders

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

Yong HeAdd `target_switch` and `intrinsic_asm` statement. (#3154)c787c4b82

master
939 B25 linesraw
1//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK):-emit-spirv-directly -target spirv-asm -entry computeMain -stage compute
2
3//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):out,name=outputBuffer
4RWStructuredBuffer<int> outputBuffer;
5
6//
7// This test checks that we correctly diagnose using 'result' in an instruction
8// not in the last position.
9//
10[numthreads(4, 1, 1)]
11void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
12{
13    int i = dispatchThreadID.x;
14    int n = outputBuffer[i];
15    int r = spirv_asm
16    {
17        OpConstant $$int %two 2;
18        OpIMul $$int result $n %two;
19        // CHECK: instructions-at-end.slang([[#@LINE-1]]): error {{.*}}: the result-id marker must only be used in the last instruction of a spriv_asm expression
20        // CHECK: note 29102: consider adding an OpCopyObject instruction to the end of the spirv_asm expression
21
22        OpIAdd $$uint %something %two %two;
23    };
24    outputBuffer[i] = r;
25}