DebugLuminanceLdrCS.hlsl 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. // RUN: %dxc -E main -T cs_6_0 %s | FileCheck %s
  2. // CHECK: threadId
  3. // CHECK: textureLoad
  4. // CHECK: sampleLevel
  5. // CHECK: dot3
  6. // CHECK: Exp
  7. // CHECK: Log
  8. // CHECK: textureStore
  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 "ShaderUtility.hlsli"
  22. #include "PostEffectsRS.hlsli"
  23. Texture2D<float3> SrcColor : register( t0 );
  24. Texture2D<float3> Bloom : register( t1 );
  25. RWTexture2D<float3> DstColor : register( u0 );
  26. RWTexture2D<float> OutLuma : register( u1 );
  27. SamplerState LinearSampler : register( s0 );
  28. cbuffer ConstantBuffer_x : register( b0 )
  29. {
  30. float2 g_RcpBufferDim;
  31. float g_BloomStrength;
  32. float g_LumaGamma;
  33. };
  34. [RootSignature(PostEffects_RootSig)]
  35. [numthreads( 8, 8, 1 )]
  36. void main( uint3 DTid : SV_DispatchThreadID )
  37. {
  38. float2 TexCoord = (DTid.xy + 0.5) * g_RcpBufferDim;
  39. // Load LDR and bloom
  40. float3 ldrColor = SrcColor[DTid.xy] + g_BloomStrength * Bloom.SampleLevel( LinearSampler, TexCoord, 0 );
  41. // Load LDR value from HDR buffer
  42. float luma = RGBToLuminance( ldrColor );
  43. float logLuma = LinearToLogLuminance(luma, g_LumaGamma);
  44. DstColor[DTid.xy] = luma.xxx;
  45. OutLuma[DTid.xy] = logLuma;
  46. }