Harbor

branch main
showing the latest snapshot on main
compute_basic.hlsl 608 B · Plain text
gpu/shader/tests/golden/compute_basic.hlsl 0644 Raw
groupshared float scratch[64];

struct Params {
	uint count;
	float scale;
};
RWStructuredBuffer<Params> params : register(u0, space0);
struct DataBuffer {
	float values[64];
};
RWStructuredBuffer<DataBuffer> 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];
}