FXAAResolveWorkQueueCS.hlsl 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // RUN: %dxc -E main -T cs_6_0 %s | FileCheck %s
  2. // CHECK: flattenedThreadIdInGroup
  3. // CHECK: bufferLoad
  4. // CHECK: br i1
  5. // CHECK: bufferStore
  6. // CHECK: br label
  7. //
  8. // Copyright (c) Microsoft. All rights reserved.
  9. // This code is licensed under the MIT License (MIT).
  10. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  11. // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  12. // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
  13. // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
  14. //
  15. // Developed by Minigraph
  16. //
  17. // Author: James Stanard
  18. //
  19. // Used with FXAA to resolve the lengths of the two work queues and to generate DispatchIndirect parameters.
  20. // The work queues are also padded out to a multiple of 64 with dummy work items.
  21. //
  22. #include "FXAARootSignature.hlsli"
  23. ByteAddressBuffer WorkCounterH : register(t0);
  24. ByteAddressBuffer WorkCounterV : register(t1);
  25. RWByteAddressBuffer IndirectParams : register(u0);
  26. RWStructuredBuffer<uint> WorkQueueH : register(u1);
  27. RWStructuredBuffer<uint> WorkQueueV : register(u2);
  28. [RootSignature(FXAA_RootSig)]
  29. [numthreads( 64, 1, 1 )]
  30. void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID )
  31. {
  32. uint PixelCountH = WorkCounterH.Load(0);
  33. uint PixelCountV = WorkCounterV.Load(0);
  34. uint PaddedCountH = (PixelCountH + 63) & ~63;
  35. uint PaddedCountV = (PixelCountV + 63) & ~63;
  36. // Write out padding to the buffer
  37. if (GI + PixelCountH < PaddedCountH)
  38. WorkQueueH[PixelCountH + GI] = 0xffffffff;
  39. // Write out padding to the buffer
  40. if (GI + PixelCountV < PaddedCountV)
  41. WorkQueueV[PixelCountV + GI] = 0xffffffff;
  42. if (GI == 0)
  43. {
  44. IndirectParams.Store(0 , PaddedCountH >> 6);
  45. IndirectParams.Store(12, PaddedCountV >> 6);
  46. }
  47. }