yum-mirror/slang

Making it easier to work with shaders

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

James Helferty (NVIDIA)render-test: Change D3D12 default to sm_6_5 (#8320)f02b08490

master
1.6 KiB55 linesraw
1// byte-address-16bit-vector.slang
2
3// Test that loading values using 16-bit vector types from
4// byte-address buffers works as expected, on targets
5// that support it.
6
7//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -cpu -shaderobj
8
9// Note: disabled on D3D12 because some of the CI services don't have
10// a recent enough build of dxc to support generic load/store.
11//
12//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile cs_6_2 -render-features half -shaderobj
13
14//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-slang -vk -compute -profile cs_6_2 -render-features half -shaderobj
15//TEST(compute):COMPARE_COMPUTE_EX:-slang -cuda -compute -shaderobj
16
17// Unavailable on D3D and fxc-based targets, because fxc doesn't
18// support loading anything besides `uint` from a byte-address
19// buffer.
20//
21//TEST_DISABLED(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
22
23
24//TEST_INPUT:ubuffer(data=[0x00010002 0x00030004 0x00050006 0x00070008]):name=inputBuffer
25RWByteAddressBuffer inputBuffer;
26
27//TEST_INPUT:ubuffer(data=[0xdeadbeef 0xdeadbeef 0xdeadbeef 0xdeadbeef]):name=tmpBuffer
28RWByteAddressBuffer tmpBuffer;
29
30//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
31RWStructuredBuffer<int> outputBuffer;
32
33struct Data
34{
35    uint16_t2 v;
36}
37
38int test(int val)
39{
40    int offsetX = val*4;
41    int offsetY = offsetX & 0xFF;
42
43    Data x = inputBuffer.Load<Data>(offsetX);
44    tmpBuffer.Store<Data>(offsetY, x);
45
46    uint16_t2 y = tmpBuffer.Load<uint16_t2>(offsetX);
47    return int(y.x)*256*16 + int(y.y);
48}
49
50[numthreads(4, 1, 1)]
51void computeMain(int3 dispatchThreadID : SV_DispatchThreadID)
52{
53    int tid = dispatchThreadID.x;
54    outputBuffer[tid] = test(tid);
55}