yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1// byte-address-16bit-load.slang 2 3// Test that loading values using 16-bit 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 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 int16_t a; 36 int16_t b; 37} 38 39int test(int val) 40{ 41 int offsetX = val*4; 42 int offsetY = offsetX & 0xFF; 43 44 Data x = inputBuffer.Load<Data>(offsetX); 45 tmpBuffer.Store<Data>(offsetY, x); 46 47 Data y = tmpBuffer.Load<Data>(offsetX); 48 return int(y.a)*256*16 + int(y.b); 49} 50 51[numthreads(4, 1, 1)] 52void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 53{ 54 int tid = dispatchThreadID.x; 55 outputBuffer[tid] = test(tid); 56}