yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
43df1da01
master
1//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj 2//TEST(compute,vulkan):COMPARE_COMPUTE_EX:-vk -slang -compute -shaderobj 3 4// When a function is passed a parameter that contains an array, it specialized it as a performance 5// improvement for VK. If the struct contained a structured buffer, though it meant that the 6// function was specialized to have the structured buffer passed as a parameter. For GLSL/VK based 7// targets Slang cannot pass StructuredBuffer types and so would subsequently fail in 8// GLSLSourceEmitter::emitSimpleTypeImpl when trying to output the StructuredBuffer type as a parameter 9// 10// This test, checks that when passing a struct with an array and structured buffer 11// code functions as expected. 12 13struct Params 14{ 15 RWStructuredBuffer<int> buffer; 16 int a[2]; 17}; 18 19//TEST_INPUT:ubuffer(data=[9 9 9 9], stride=4):out,name=outputBuffer 20RWStructuredBuffer<int> outputBuffer; 21 22//TEST_INPUT:ubuffer(data=[1 2 3 4], stride=4):name=anotherBuffer 23RWStructuredBuffer<int> anotherBuffer; 24// 25int doSomething(Params params, int v) 26{ 27 return params.a[v & 1] - v; 28} 29 30[numthreads(4, 1, 1)] 31void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) 32{ 33 Params params; 34 params.buffer = anotherBuffer; 35 params.a[0] = 1; 36 params.a[1] = 2; 37 38 int tid = int(dispatchThreadID.x); 39 40 outputBuffer[tid] = doSomething(params, tid); 41}