BakeAcesOutputTransformLutPass.h 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #pragma once
  9. #include <AzCore/Memory/SystemAllocator.h>
  10. #include <Atom/RHI/CommandList.h>
  11. #include <Atom/RHI/DeviceDrawItem.h>
  12. #include <Atom/RHI/ScopeProducer.h>
  13. #include <Atom/RHI/ImagePool.h>
  14. #include <Atom/RPI.Public/Pass/ComputePass.h>
  15. #include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
  16. #include <Atom/RPI.Public/Shader/Shader.h>
  17. #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
  18. #include <Atom/Feature/ACES/AcesDisplayMapperFeatureProcessor.h>
  19. #include <AzFramework/Windowing/WindowBus.h>
  20. namespace AZ
  21. {
  22. namespace Render
  23. {
  24. /**
  25. * The bake ACES output transofrm LUT pass.
  26. * This pass the RRT and ODT components of the ACES pipeline into a LUT.
  27. */
  28. class BakeAcesOutputTransformLutPass final
  29. : public RPI::ComputePass
  30. {
  31. AZ_RPI_PASS(BakeAcesOutputTransformLutPass);
  32. public:
  33. AZ_RTTI(BakeAcesOutputTransformLutPass, "{383C28CD-D744-4B48-A30D-086EF66E7BFB}", RPI::ComputePass);
  34. AZ_CLASS_ALLOCATOR(BakeAcesOutputTransformLutPass, SystemAllocator);
  35. virtual ~BakeAcesOutputTransformLutPass();
  36. /// Creates a DisplayMapperPass
  37. static RPI::Ptr<BakeAcesOutputTransformLutPass> Create(const RPI::PassDescriptor& descriptor);
  38. void SetDisplayBufferFormat(RHI::Format format);
  39. const ShaperParams& GetShaperParams() const;
  40. private:
  41. explicit BakeAcesOutputTransformLutPass(const RPI::PassDescriptor& descriptor);
  42. // Pass behavior overrides...
  43. void InitializeInternal() override;
  44. // RHI::ScopeProducer overrides...
  45. void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
  46. void CompileResources(const RHI::FrameGraphCompileContext& context) override;
  47. void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override;
  48. void AcquireLutImage();
  49. void ReleaseLutImage();
  50. bool m_resourcesInitialized = false;
  51. RHI::ShaderInputConstantIndex m_shaderInputColorMatIndex;
  52. RHI::ShaderInputConstantIndex m_shaderInputCinemaLimitsIndex;
  53. RHI::ShaderInputConstantIndex m_shaderInputAcesSplineParamsIndex;
  54. RHI::ShaderInputConstantIndex m_shaderInputFlagsIndex;
  55. RHI::ShaderInputConstantIndex m_shaderInputOutputModeIndex;
  56. RHI::ShaderInputConstantIndex m_shaderInputSurroundGammaIndex;
  57. RHI::ShaderInputConstantIndex m_shaderInputGammaIndex;
  58. RHI::ShaderInputConstantIndex m_shaderInputShaperBiasIndex;
  59. RHI::ShaderInputConstantIndex m_shaderInputShaperScaleIndex;
  60. RHI::ShaderInputImageIndex m_shaderInputLutImageIndex;
  61. AZ::Render::DisplayMapperParameters m_displayMapperParameters = {};
  62. DisplayMapperLut m_displayMapperLut = {};
  63. bool m_needToUpdateLut = false;
  64. RHI::Format m_displayBufferFormat = RHI::Format::Unknown;
  65. OutputDeviceTransformType m_outputDeviceTransformType = OutputDeviceTransformType_48Nits;
  66. ShaperParams m_shaperParams;
  67. };
  68. } // namespace Render
  69. } // namespace AZ