yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
719772c01
master
1//TEST(compute):COMPARE_COMPUTE_EX(filecheck-buffer=CHECK):-cuda -compute -shaderobj 2 3//TEST_INPUT:ubuffer(data=[1 1 1 1], stride=4),name=inputBuffer 4RWStructuredBuffer<int[2]> inputBuffer; 5 6//TEST_INPUT:ubuffer(data=[0 0 0 0 0], stride=4):out,name=outputBuffer 7RWStructuredBuffer<int> outputBuffer; 8 9void math(int data[2]) 10{ 11 // This test is to ensure that we do not break our optimization-pass which optimizes the IR of 12 // `getElement(load(getElementPtr(...)), ...)` into `load(getElementPtr(getElementPtr(...), ...))`. 13 // 14 // This test triggers the bug given the IR: `store(outputBuffer[0], getElement(Array<>, load(getElementPtr(data,0))))`. 15 // `Array<int,2>(5,6)` is not created as a local variable intentionally. We do this because we want to test the case 16 // where `Array<>` must be accessed as a value (`getElement`), not a pointer (`getElementPtr`). 17 // 18 // If this code fails, outputBuffer[0] will contain the value `1`. We expect `6` if the bug is fixed. 19 outputBuffer[0] = Array<int,2>(5,6)[data[0]]; 20} 21 22[shader("compute")] 23[numthreads(1, 1, 1)] 24void computeMain(int3 id: SV_DispatchThreadID) 25{ 26 math(inputBuffer[0]); 27} 28 29//CHECK: 6 30//CHECK-NEXT: 0