blob: 3bf8119459b76ae66884f6dc82d8c3ded8727f62 (
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
41
42
43
44
45
46
47
48
|
// 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
//TEST:SIMPLE(filecheck=SPV):-target spirv -entry computeMain -stage compute -emit-spirv-directly
// 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;
// Make sure arithmetic ops are properly performed on unsigned types.
// SPV-NOT: OpSDiv
// SPV: OpUDiv
void test(uint val)
{
uint tmp = val;
tmp = inputBuffer.Load(uint(tmp * 4));
uint2 pair = inputBuffer.Load2(uint(tmp * 4));
tmp = (pair.x + pair.y) & 0xF;
uint4 quad = inputBuffer.Load4(uint(tmp * 4));
tmp = (quad.x + quad.y + quad.z + quad.w) & 0xF;
outputBuffer.Store(val*4, tmp);
}
[numthreads(4, 1, 1)]
[shader("compute")]
void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
{
uint tid = dispatchThreadID.x;
uint val = uint(tid);
test(val);
}
|