yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
9606401e1
master
1// trivial-copy.slang 2 3// Copy the contents of "tex" into "buffer". These are for textures containing FLOAT data. 4[shader("compute")] 5[numthreads(4,1,1)] 6void copyTexFloat4( 7 uint3 sv_dispatchThreadID : SV_DispatchThreadID, 8 uniform uint width, 9 uniform uint height, 10 uniform RWTexture2D<float4> tex, 11 uniform RWStructuredBuffer<float> buffer) 12{ 13 float4 result = tex[uint2(sv_dispatchThreadID.x % width, sv_dispatchThreadID.x / width)]; 14 buffer[sv_dispatchThreadID.x * 4] = result.r; 15 buffer[sv_dispatchThreadID.x * 4 + 1] = result.g; 16 buffer[sv_dispatchThreadID.x * 4 + 2] = result.b; 17 buffer[sv_dispatchThreadID.x * 4 + 3] = result.a; 18}