diff options
| author | Konstantin <const@const.me> | 2023-01-16 14:52:43 +0100 |
|---|---|---|
| committer | Konstantin <const@const.me> | 2023-01-16 14:52:43 +0100 |
| commit | 8c4603c73675958efc960fbd4bb599a2909d106a (patch) | |
| tree | 714dc6fc9a1672d5fd7f89676b97e10959662abc /ComputeShaders/zeroMemory.hlsl | |
| parent | 990a8d0dbaefc996244097397259e92758b15cce (diff) | |
Source codes
Diffstat (limited to 'ComputeShaders/zeroMemory.hlsl')
| -rw-r--r-- | ComputeShaders/zeroMemory.hlsl | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/ComputeShaders/zeroMemory.hlsl b/ComputeShaders/zeroMemory.hlsl new file mode 100644 index 0000000..c486636 --- /dev/null +++ b/ComputeShaders/zeroMemory.hlsl @@ -0,0 +1,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; +}
\ No newline at end of file |
