summaryrefslogtreecommitdiffstats
path: root/ComputeShaders/zeroMemory.hlsl
blob: c486636b3ffe08d1675f86157e2ac663ce6f393d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
RWBuffer<float> result: register( u0 );

cbuffer Constants: register( b0 )
{
	uint elements: packoffset( c0.x );
}

// Thread group index is 16 bits per coordinate:
// https://learn.microsoft.com/en-us/windows/win32/api/d3d11/nf-d3d11-id3d11devicecontext-dispatch
// We want this shader to support buffers up to 2 GB.
#ifndef THREADS
static const uint THREADS = 512;
#endif
#ifndef ITERATIONS
static const uint ITERATIONS = 128;
#endif

static const uint itemsPerGroup = THREADS * ITERATIONS;

[numthreads( THREADS, 1, 1 )]
void main( uint3 group: SV_GroupID, uint thread : SV_GroupIndex )
{
	uint rdi = group.x * itemsPerGroup;
	const uint rdiEnd = min( rdi + itemsPerGroup, elements );
	for( rdi += thread; rdi < rdiEnd; rdi += THREADS )
		result[ rdi ] = 0.0;
}