| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
- // All rights reserved.
- // Code licensed under the BSD License.
- // http://www.anki3d.org/LICENSE
- // A slow compute program to clear an image with a contant color
- #pragma anki mutator TEXTURE_DIMENSIONS 2 3
- #pragma anki mutator COMPONENT_TYPE 0 1 // 0 is float, 1 is uint
- #pragma anki technique comp
- #include <AnKi/Shaders/Common.hlsl>
- struct Consts
- {
- #if COMPONENT_TYPE == 0
- Vec4 m_clearColor;
- #else
- UVec4 m_clearColor;
- #endif
- };
- ANKI_FAST_CONSTANTS(Consts, g_consts)
- #if TEXTURE_DIMENSIONS == 2
- # if COMPONENT_TYPE == 0
- RWTexture2D<Vec4> g_storageTex : register(u0);
- # else
- RWTexture2D<UVec4> g_storageTex : register(u0);
- # endif
- #else
- # if COMPONENT_TYPE == 0
- RWTexture3D<Vec4> g_storageTex : register(u0);
- # else
- RWTexture3D<UVec4> g_storageTex : register(u0);
- # endif
- #endif
- [numthreads(8, 8, (TEXTURE_DIMENSIONS == 2) ? 1 : 8)] void main(UVec3 svDispatchThreadId : SV_DISPATCHTHREADID)
- {
- #if TEXTURE_DIMENSIONS == 2
- UVec2 texSize;
- g_storageTex.GetDimensions(texSize.x, texSize.y);
- if(svDispatchThreadId.x >= texSize.x || svDispatchThreadId.y >= texSize.y)
- {
- return;
- }
- g_storageTex[svDispatchThreadId.xy] = g_consts.m_clearColor;
- #else
- UVec3 texSize;
- g_storageTex.GetDimensions(texSize.x, texSize.y, texSize.z);
- if(svDispatchThreadId.x >= texSize.x || svDispatchThreadId.y >= texSize.y || svDispatchThreadId.z >= texSize.z)
- {
- return;
- }
- g_storageTex[svDispatchThreadId] = g_consts.m_clearColor;
- #endif
- }
|