yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
f8294202c
master
1// func-resource-result-simple.slang 2 3//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 4//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj 5//TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -shaderobj 6//TEST(compute):COMPARE_COMPUTE:-slang -shaderobj -mtl 7 8// Test that a function that returns a resource type can be 9// compiled for targets that don't natively support resource 10// return values. 11 12//TEST_INPUT:ubuffer(data=[0x11 0x22 0x33 0x44], stride=4):name=inputBuffer 13RWStructuredBuffer<int> inputBuffer; 14 15RWStructuredBuffer<int> getInputBuffer() { return inputBuffer; } 16 17int test(int val) 18{ 19 return getInputBuffer()[val]; 20} 21 22//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer 23RWStructuredBuffer<int> outputBuffer; 24 25[numthreads(4, 1, 1)] 26void computeMain(int3 dispatchThreadID : SV_DispatchThreadID) 27{ 28 int tid = dispatchThreadID.x; 29 int inVal = tid; 30 int outVal = test(inVal); 31 outputBuffer[tid] = outVal; 32}