yum-mirror/slang

Making it easier to work with shaders

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

Jay KwakUse and() and or() functions for logical-AND and OR (#6310)57b09a898

master
1.1 KiB33 linesraw
1//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK):-dx12 -compute -shaderobj
2//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK):-vk -compute  -shaderobj
3//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHK):-mtl -compute  -shaderobj
4//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-cuda -compute -shaderobj
5//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-cpu -compute -compile-arg -O3 -shaderobj
6//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHK):-slang -compute -shaderobj
7
8// Test doing vector comparisons 
9
10//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
11RWStructuredBuffer<int> outputBuffer;
12
13bool assignFunc(int index)
14{
15    outputBuffer[index] = 1;
16    return true;
17}
18
19[numthreads(16, 1, 1)]
20void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
21{
22    int index = dispatchThreadID.x;
23
24    // Only the first 4 elements will be 1
25    (index < 4) && assignFunc(index);
26
27    // Only the last 4 elements will be 1.
28    (index < 12) || assignFunc(index);
29
30    //CHK-COUNT-4: 1
31    //CHK-COUNT-8: 0
32    //CHK-COUNT-4: 1
33}