MultiScaleVODownsample2.compute 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. //
  2. // This is a modified version of the SSAO renderer from Microsoft's MiniEngine
  3. // library. The copyright notice from the original version is included below.
  4. //
  5. // The original source code of MiniEngine is available on GitHub.
  6. // https://github.com/Microsoft/DirectX-Graphics-Samples
  7. //
  8. //
  9. // Copyright (c) Microsoft. All rights reserved.
  10. // This code is licensed under the MIT License (MIT).
  11. // THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF
  12. // ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY
  13. // IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR
  14. // PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.
  15. //
  16. // Developed by Minigraph
  17. //
  18. // Author: James Stanard
  19. //
  20. #pragma warning(disable : 3568)
  21. #pragma exclude_renderers gles gles3 d3d11_9x
  22. #pragma kernel MultiScaleVODownsample2 main=MultiScaleVODownsample2
  23. #pragma kernel MultiScaleVODownsample2_MSAA main=MultiScaleVODownsample2_MSAA MSAA
  24. #include "../StdLib.hlsl"
  25. #ifdef MSAA
  26. Texture2D<float2> DS4x;
  27. RWTexture2D<float2> DS8x;
  28. RWTexture2DArray<float2> DS8xAtlas;
  29. RWTexture2D<float2> DS16x;
  30. RWTexture2DArray<float2> DS16xAtlas;
  31. #else
  32. Texture2D<float> DS4x;
  33. RWTexture2D<float> DS8x;
  34. RWTexture2DArray<float> DS8xAtlas;
  35. RWTexture2D<float> DS16x;
  36. RWTexture2DArray<float> DS16xAtlas;
  37. #endif
  38. #ifdef DISABLE_COMPUTE_SHADERS
  39. TRIVIAL_COMPUTE_KERNEL(main)
  40. #else
  41. [numthreads(8, 8, 1)]
  42. void main(uint3 Gid : SV_GroupID, uint GI : SV_GroupIndex, uint3 GTid : SV_GroupThreadID, uint3 DTid : SV_DispatchThreadID)
  43. {
  44. #ifdef MSAA
  45. float2 m1 = DS4x[DTid.xy << 1];
  46. #else
  47. float m1 = DS4x[DTid.xy << 1];
  48. #endif
  49. uint2 st = DTid.xy;
  50. uint2 stAtlas = st >> 2;
  51. uint stSlice = ((st.x & 3) | (st.y << 2)) & 15;
  52. DS8x[st] = m1;
  53. DS8xAtlas[uint3(stAtlas, stSlice)] = m1;
  54. if ((GI & 011) == 0)
  55. {
  56. uint2 st = DTid.xy >> 1;
  57. uint2 stAtlas = st >> 2;
  58. uint stSlice = ((st.x & 3) | (st.y << 2)) & 15;
  59. DS16x[st] = m1;
  60. DS16xAtlas[uint3(stAtlas, stSlice)] = m1;
  61. }
  62. }
  63. #endif // DISABLE_COMPUTE_SHADERS