GpuSceneMicroPatching.ankiprog 1.0 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright (C) 2009-present, Panagiotis Christopoulos Charitos and contributors.
  2. // All rights reserved.
  3. // Code licensed under the BSD License.
  4. // http://www.anki3d.org/LICENSE
  5. #pragma anki technique comp
  6. #include <AnKi/Shaders/Common.hlsl>
  7. // Needs to match the C++. See C++ for comments
  8. struct PatchHeader
  9. {
  10. U32 m_dwordSizeMinusOne : 6;
  11. U32 m_srcDwordOffset : 26;
  12. U32 m_dstDwordOffset;
  13. };
  14. StructuredBuffer<PatchHeader> g_patchHeaders : register(t0);
  15. StructuredBuffer<U32> g_srcBuffer : register(t1);
  16. RWStructuredBuffer<U32> g_dstBuffer : register(u0);
  17. [numthreads(64, 1, 1)] void main(UVec3 svGroupId : SV_GROUPID, U32 svGroupIndex : SV_GROUPINDEX)
  18. {
  19. const PatchHeader header = SBUFF(g_patchHeaders, svGroupId.x);
  20. const U32 dwordCount = header.m_dwordSizeMinusOne + 1u;
  21. if(svGroupIndex >= dwordCount)
  22. {
  23. return;
  24. }
  25. const U32 srcDwordOffset = header.m_srcDwordOffset;
  26. const U32 dstDwordOffset = header.m_dstDwordOffset;
  27. SBUFF(g_dstBuffer, dstDwordOffset + svGroupIndex) = SBUFF(g_srcBuffer, srcDwordOffset + svGroupIndex);
  28. }