yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f02b08490
master
1// interface-shader-param-ordinary.slang 2 3// This test is for interface-type shader parameters that 4// get specialized to types that include "ordinary" data 5// but also don't fit into the allocation provided for 6// them in the existential-type field itself. 7 8//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute 9//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -profile sm_6_0 10//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute 11//DISABLE_TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl 12// Slang-RHI/WGPU: Too small buffer is bound #5604 13//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-wgpu 14 15interface IModifier 16{ 17 int modify(int value); 18} 19 20//TEST_INPUT:set gOutputBuffer = out ubuffer(data=[0 0 0 0], stride=4) 21RWStructuredBuffer<int> gOutputBuffer; 22 23//TEST_INPUT:set delta = 65536 24uniform int delta; 25 26//TEST_INPUT: globalSpecializationArg MyModifier 27//TEST_INPUT:set gModifier = new MyModifier{ ubuffer(data=[4 3 2 1], stride=4), 3 } } 28uniform IModifier gModifier; 29 30int test(int val) 31{ 32 return gModifier.modify(val) + delta; 33} 34 35 36[numthreads(4, 1, 1)] 37void computeMain( 38 int3 dispatchThreadID : SV_DispatchThreadID) 39{ 40 let tid = dispatchThreadID.x; 41 42 let inputVal : int = tid; 43 let outputVal = test(inputVal); 44 45 gOutputBuffer[tid] = outputVal; 46} 47 48struct MyModifier : IModifier 49{ 50 RWStructuredBuffer<int> data; 51 int extra; 52 53 int modify(int val) 54 { 55 return val*65536 + data[val]*256 + val*extra; 56 } 57}