blob: eb323ace082f2f0b92142c1df98b5efee8ae91b5 (
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
49
50
51
|
// byte-address-struct-load.slang
// Test that load of a `struct` type from a byte-address
// buffer can be translated into per-field loads on
// all targets that support loads of the field types.
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -shaderobj
//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-slang -vk -compute -shaderobj
//TEST(compute):COMPARE_COMPUTE_EX:-slang -cuda -compute -shaderobj
// Note: This input should really be just a `ByteAddressBuffer`,
// so that we can confirm that the functionality works in the
// read-only case as well. The reason we are using a `RWByteAddressBuffer`
// is because of limitations in the `render-test` app, and if
// those limitations get fixed, we should switch this code.
//
//TEST_INPUT:ubuffer(data=[0x5 0x3f800000 0x6 0x40000000 0x7 0x40400000 0x8 0x40800000]):name=inputBuffer
RWByteAddressBuffer inputBuffer;
//TEST_INPUT:ubuffer(data=[0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef]):name=tmpBuffer
RWByteAddressBuffer tmpBuffer;
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<int> outputBuffer;
struct Data
{
int a;
float b;
}
int test(int val)
{
int offsetX = val*8;
int offsetY = offsetX & 0xFF;
Data x = inputBuffer.Load<Data>(offsetX);
tmpBuffer.Store<Data>(offsetY, x);
Data y = tmpBuffer.Load<Data>(offsetX);
return y.a*256*16 + int(y.b);
}
[numthreads(4, 1, 1)]
void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
{
int tid = dispatchThreadID.x;
outputBuffer[tid] = test(tid);
}
|