ConvertLDRToDisplayAltPS.hlsl 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // RUN: %dxc -E main -T ps_6_0 %s | FileCheck %s
  2. // CHECK: textureLoad
  3. // CHECK: Log
  4. // CHECK: Exp
  5. // CHECK: Saturate
  6. //
  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. #include "ShaderUtility.hlsli"
  20. #include "PresentRS.hlsli"
  21. Texture2D<float3> ColorTex : register(t0);
  22. cbuffer CB : register(b0)
  23. {
  24. uint DisplayColorSpace;
  25. float Gamma;
  26. float LimitedScale;
  27. float LimitedBias;
  28. };
  29. [RootSignature(Present_RootSig)]
  30. float3 main( float4 position : SV_Position ) : SV_Target0
  31. {
  32. float3 LinearRGB = LinearizeColor(ColorTex[(int2)position.xy], LDR_COLOR_FORMAT);
  33. if (DisplayColorSpace == 10)
  34. {
  35. //return pow(saturate(LinearRGB), Gamma) * LimitedScale + LimitedBias;
  36. return saturate(LinearToREC709(LinearRGB)) * LimitedScale + LimitedBias;
  37. }
  38. #if 1
  39. return ApplyColorProfile(LinearRGB, DisplayColorSpace);
  40. #else
  41. return ApplyColorProfile(LinearRGB, COLOR_FORMAT_sRGB_FULL);
  42. #endif
  43. }