You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
o3de/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthT...

61 lines
2.3 KiB
C++

/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#pragma once
#include <Atom/RHI/CopyItem.h>
#include <Atom/RHI/ScopeProducer.h>
#include <Atom/RPI.Public/Pass/Pass.h>
#include <Atom/RPI.Public/Buffer/Buffer.h>
namespace AZ
{
namespace Render
{
//! This pass is used to read back the depth value written to the buffer.
class DepthOfFieldCopyFocusDepthToCpuPass final
: public RPI::Pass
, public RHI::ScopeProducer
{
AZ_RPI_PASS(DepthOfFieldCopyFocusDepthToCpuPass);
public:
AZ_RTTI(DepthOfFieldCopyFocusDepthToCpuPass, "{EA00AD76-92FC-4223-AB7D-87F588AB5394}", Pass);
AZ_CLASS_ALLOCATOR(DepthOfFieldCopyFocusDepthToCpuPass, SystemAllocator, 0);
//! Creates an DepthOfFieldCopyFocusDepthToCpuPass
static RPI::Ptr<DepthOfFieldCopyFocusDepthToCpuPass> Create(const RPI::PassDescriptor& descriptor);
~DepthOfFieldCopyFocusDepthToCpuPass() = default;
void SetBufferRef(RPI::Ptr<RPI::Buffer> bufferRef);
float GetFocusDepth();
private:
explicit DepthOfFieldCopyFocusDepthToCpuPass(const RPI::PassDescriptor& descriptor);
// Scope producer functions
void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override;
void CompileResources(const RHI::FrameGraphCompileContext& context) override;
void BuildCommandList(const RHI::FrameGraphExecuteContext& context) override;
// Pass overrides
void BuildInternal() override;
void FrameBeginInternal(FramePrepareParams params) override;
RPI::Ptr<RPI::Buffer> m_bufferRef;
Data::Instance<RPI::Buffer> m_readbackBuffer;
RHI::CopyBufferDescriptor m_copyDescriptor;
bool m_needsInitialize = true;
};
} // namespace RPI
} // namespace AZ