forked from shader-slang/slang
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbyte-address-buffer.slang
41 lines (30 loc) · 1.11 KB
/
byte-address-buffer.slang
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// byte-address-buffer.slang
//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-d3d12 -compute -shaderobj
// Confirm cross-compilation of `(RW)ByteAddressBuffer`
//
// TODO: I'm only using `RWByteAddressBuffer` for now because I don't
// know if `render-test` supports the non-UAV case.
//TEST_INPUT:ubuffer(data=[0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15]):name=inputBuffer
RWByteAddressBuffer inputBuffer;
//TEST_INPUT:ubuffer(data=[0 0 0 0]):out,name=outputBuffer
RWByteAddressBuffer outputBuffer;
void test(int val)
{
uint tmp = val;
tmp = inputBuffer.Load(int(tmp * 4));
uint2 pair = inputBuffer.Load2(int(tmp * 4));
tmp = (pair.x + pair.y) & 0xF;
uint4 quad = inputBuffer.Load4(int(tmp * 4));
tmp = (quad.x + quad.y + quad.z + quad.w) & 0xF;
outputBuffer.Store(val*4, tmp);
}
[numthreads(4, 1, 1)]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
uint tid = dispatchThreadID.x;
int val = int(tid);
test(val);
}