yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
117f5e554
master
1// rate-param.slang 2//DISABLE_TEST:SIMPLE: -target hlsl -entry computeMain -stage compute 3 4//TEST_INPUT:ubuffer(data=[0 0 0 0 ], stride=4):out,name outputBuffer 5RWStructuredBuffer < int > outputBuffer ; 6 7groupshareduint gs_values [ 4 ]; 8 9void someFunction ( inout groupshareduint a [ 4 ], int index , int value ) 10{ 11a [ index ] += value ; 12} 13 14[ shader ( "compute" )] 15[ numthreads ( 4 , 1 , 1 )] 16void computeMain ( uint3 dispatchThreadID : SV_DispatchThreadID ) 17{ 18int index = ( int ) dispatchThreadID . x ; 19 20// Initialize 21gs_values [ 3 - index ] = index ; 22 23GroupMemoryBarrierWithGroupSync (); 24 25someFunction ( gs_values , index , index * 2 + 1 ); 26 27GroupMemoryBarrierWithGroupSync (); 28 29outputBuffer [ index ] = gs_values [ index ]; 30}