yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f8294202c
master
1// func-resource-param.slang 2 3// Test that a function with a resource parameter that 4// requires non-trivial legalization can be compiled 5// to work on GLSL-based targets. 6 7//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 8//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-dx12 -compute -shaderobj 9//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 10//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 11 12//NO_TEST:SIMPLE:-target glsl -entry computeMain -stage compute -validate-ir -dump-ir 13 14//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 15RWStructuredBuffer<int> outputBuffer; 16 17//TEST_INPUT:ubuffer(data=[0 16 32 48], stride=4):name=inputBuffer 18RWStructuredBuffer<int> inputBuffer; 19 20int helper(RWStructuredBuffer<int> buffer, int index) 21{ 22 return buffer[index]; 23} 24 25int test(int val) 26{ 27 return helper(inputBuffer, val) + val; 28} 29 30[numthreads(4, 1, 1)] 31void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 32{ 33 int inVal = (int) dispatchThreadID.x; 34 int outVal = test(inVal); 35 outputBuffer[dispatchThreadID.x] = outVal; 36}