AverageLumaCS.hlsl 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // RUN: %dxc -E main -T cs_6_0 -O0 %s | FileCheck %s
  2. // CHECK: groupId
  3. // CHECK: flattenedThreadIdInGroup
  4. // CHECK: threadId
  5. // CHECK: barrier
  6. // CHECK: addrspace(3)
  7. // CHECK: barrier
  8. // CHECK: addrspace(3)
  9. //
  10. // Copyright (c) Microsoft. All rights reserved.
  11. // This code is licensed under the MIT License (MIT).
  12. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  13. // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  14. // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
  15. // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
  16. //
  17. // Developed by Minigraph
  18. //
  19. // Author: James Stanard
  20. //
  21. #include "PostEffectsRS.hlsli"
  22. Texture2D<float> InputBuf : register( t0 );
  23. RWStructuredBuffer<float> Result : register( u0 );
  24. groupshared float buffer[64];
  25. [RootSignature(PostEffects_RootSig)]
  26. [numthreads( 8, 8, 1 )]
  27. void main( uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID )
  28. {
  29. float sumThisThread = InputBuf[DTid.xy];
  30. buffer[GI] = sumThisThread;
  31. GroupMemoryBarrierWithGroupSync();
  32. sumThisThread += buffer[GI + 32];
  33. buffer[GI] = sumThisThread;
  34. GroupMemoryBarrierWithGroupSync();
  35. sumThisThread += buffer[GI + 16];
  36. buffer[GI] = sumThisThread;
  37. GroupMemoryBarrierWithGroupSync();
  38. sumThisThread += buffer[GI + 8];
  39. buffer[GI] = sumThisThread;
  40. GroupMemoryBarrierWithGroupSync();
  41. sumThisThread += buffer[GI + 4];
  42. buffer[GI] = sumThisThread;
  43. GroupMemoryBarrierWithGroupSync();
  44. sumThisThread += buffer[GI + 2];
  45. buffer[GI] = sumThisThread;
  46. GroupMemoryBarrierWithGroupSync();
  47. sumThisThread += buffer[GI + 1];
  48. if (GI == 0)
  49. Result[Gid.x + Gid.y * 5] = sumThisThread / 64.0f;
  50. }