yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
fef0a87dd
master
1//TEST:SIMPLE(filecheck=CHECK_DXIL): -target dxil -profile sm_6_0 -entry computeMain -stage compute -DMEMBER_FUNCTION_CALL 2//TEST:SIMPLE(filecheck=CHECK_DXIL): -target dxil -profile sm_6_0 -entry computeMain -stage compute 3 4//CHECK_DXIL: computeMain 5 6struct Grid 7{ 8 uint bufSize; 9 StructuredBuffer<uint> buf; 10}; 11 12struct GridGeo 13{ 14 Grid grids[2]; 15 16 void getGrid(uint index, out Grid grid) 17 { 18 grid = grids[index]; 19 } 20}; 21 22struct Scene 23{ 24 GridGeo gridGeo; 25 26 void getGrid_BAD(uint index, out Grid grid) 27 { 28 gridGeo.getGrid(index, grid); 29 } 30 31 void getGrid_GOOD(uint index, out Grid grid) 32 { 33 grid = gridGeo.grids[index]; 34 } 35}; 36 37ParameterBlock<Scene> gScene; 38RWStructuredBuffer<uint> gridBuffers[2]; 39RWStructuredBuffer<uint> outputBuffer; 40 41void direct_getGrid_BAD(uint index, out Grid grid) 42{ 43 gScene.gridGeo.getGrid(index, grid); 44} 45 46[numthreads(1, 1, 1)] 47void computeMain(uint3 threadId: SV_DispatchThreadID) 48{ 49 50 Grid grid; 51 52#ifdef MEMBER_FUNCTION_CALL 53 direct_getGrid_BAD(1, grid); 54#else 55 gScene.getGrid_BAD(1, grid); 56#endif 57 gridBuffers[0][1] = grid.buf[1]; 58}