yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1// func-cbuffer-param.slang 2 3// Test that passing a `ConstantBuffer<X>` parameter 4// into a function works across all target. 5 6// This has a compatibility issue on Windows 10.0.10586 on Dx12 - dxcompiler will crash (can remove form tests with -exclude compatibility-issue) 7 8//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 9//TEST(compute, vulkan, compatibility-issue):COMPARE_COMPUTE_EX:-dx12 -compute -shaderobj 10//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 11//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 12 13 14struct Data 15{ 16 int4 val[4]; 17} 18 19//TEST_INPUT:cbuffer(data=[0 1 2 3 16 17 18 19 32 33 34 35 48 49 50 51]):name=a 20ConstantBuffer<Data> a; 21 22//TEST_INPUT:cbuffer(data=[16 17 18 19 32 33 34 35 48 49 50 51 64 65 66 67]):name=b 23ConstantBuffer<Data> b; 24 25//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 26RWStructuredBuffer<int> outputBuffer; 27 28int helper(ConstantBuffer<Data> buffer, int index) 29{ 30 return buffer.val[index].x; 31} 32 33int test(int val) 34{ 35 return val + helper(a, val) + helper(b, val); 36} 37 38[numthreads(4, 1, 1)] 39void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 40{ 41 int inVal = (int) dispatchThreadID.x; 42 int outVal = test(inVal); 43 outputBuffer[dispatchThreadID.x] = outVal; 44}