groupshared float scratch[64]; struct Params { uint count; float scale; }; RWStructuredBuffer params : register(u0, space0); struct DataBuffer { float values[64]; }; RWStructuredBuffer data : register(u1, space0); [numthreads(64, 1, 1)] void main(uint3 global_id : SV_DispatchThreadID, uint3 local_id : SV_GroupThreadID) { uint idx = local_id.x; scratch[idx] = (data.values[idx] * params.scale); GroupMemoryBarrierWithGroupSync(); if ((idx < 32)) { scratch[idx] = (scratch[idx] + scratch[(idx + 32)]); } GroupMemoryBarrierWithGroupSync(); data.values[idx] = scratch[idx]; }