summaryrefslogtreecommitdiffstats
path: root/tests/compute/byte-address-buffer.slang
blob: 2efbeb63038297d791469b8f92529b9cf574569d (plain)
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
// byte-address-buffer.slang

//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-d3d12 -compute

// 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]):dxbinding(0),glbinding(0)
RWByteAddressBuffer inputBuffer;

//TEST_INPUT:ubuffer(data=[0 0 0 0]):dxbinding(1),glbinding(1),out
RWByteAddressBuffer outputBuffer;

void test(int val)
{
	uint tmp = val;

	tmp = inputBuffer.Load(tmp * 4);

	uint2 pair = inputBuffer.Load2(tmp * 4);
	tmp = (pair.x + pair.y) & 0xF;

	uint4 quad = inputBuffer.Load4(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);
}