Merge pull request #6461 from aws-lumberyard-dev/Atom/dmcdiar/ATOM-16956

Disable DiffuseProbeGridDownsamplePass
This commit is contained in:
dmcdiarmid-ly
2021-12-16 17:39:56 -07:00
committed by GitHub
7 changed files with 163 additions and 51 deletions
@@ -26,6 +26,54 @@
"Name": "DepthStencilInputOutput",
"SlotType": "InputOutput",
"ScopeAttachmentUsage": "DepthStencil"
},
{
"Name": "IrradianceOutput",
"SlotType": "InputOutput",
"ScopeAttachmentUsage": "RenderTarget",
"LoadStoreAction": {
"ClearValue": {
"Value": [
0.0,
0.0,
0.0,
0.0
]
},
"LoadAction": "Clear"
}
}
],
"ImageAttachments": [
{
"Name": "IrradianceImage",
"SizeSource": {
"Source": {
"Pass": "This",
"Attachment": "NormalInput"
},
"Multipliers": {
"WidthMultiplier": 0.25,
"HeightMultiplier": 0.25
}
},
"MultisampleSource": {
"Pass": "This",
"Attachment": "NormalInput"
},
"ImageDescriptor": {
"Format": "R16G16B16A16_FLOAT",
"SharedQueueMask": "Graphics"
}
}
],
"Connections": [
{
"LocalSlot": "IrradianceOutput",
"AttachmentRef": {
"Pass": "This",
"Attachment": "IrradianceImage"
}
}
],
"PassRequests": [
@@ -78,7 +126,7 @@
{
"LocalSlot": "Output",
"AttachmentRef": {
"Pass": "DiffuseProbeGridDownsamplePass",
"Pass": "Parent",
"Attachment": "IrradianceOutput"
}
}
@@ -5,7 +5,7 @@
"ClassData": {
"PassTemplate": {
"Name": "DiffuseProbeGridDownsamplePassTemplate",
"PassClass": "FullScreenTriangle",
"PassClass": "DiffuseProbeGridDownsamplePass",
"Slots": [
{
"Name": "NormalInput",
@@ -38,24 +38,6 @@
"LoadStoreAction": {
"LoadAction": "DontCare"
}
},
{
// Note: this is attached here to ensure that the image is cleared,
// but it is not used as an output from the shader
"Name": "IrradianceOutput",
"SlotType": "Output",
"ScopeAttachmentUsage": "RenderTarget",
"LoadStoreAction": {
"ClearValue": {
"Value": [
0.0,
0.0,
0.0,
0.0
]
},
"LoadAction": "Clear"
}
}
],
"ImageAttachments": [
@@ -103,27 +85,6 @@
"Format": "R16G16B16A16_FLOAT",
"SharedQueueMask": "Graphics"
}
},
{
"Name": "IrradianceImage",
"SizeSource": {
"Source": {
"Pass": "This",
"Attachment": "NormalInput"
},
"Multipliers": {
"WidthMultiplier": 0.25,
"HeightMultiplier": 0.25
}
},
"MultisampleSource": {
"Pass": "This",
"Attachment": "NormalInput"
},
"ImageDescriptor": {
"Format": "R16G16B16A16_FLOAT",
"SharedQueueMask": "Graphics"
}
}
],
"Connections": [
@@ -140,13 +101,6 @@
"Pass": "This",
"Attachment": "DownsampledDepthImage"
}
},
{
"LocalSlot": "IrradianceOutput",
"AttachmentRef": {
"Pass": "This",
"Attachment": "IrradianceImage"
}
}
],
"PassData": {
@@ -97,6 +97,7 @@
#include <DiffuseGlobalIllumination/DiffuseProbeGridBorderUpdatePass.h>
#include <DiffuseGlobalIllumination/DiffuseProbeGridRelocationPass.h>
#include <DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.h>
#include <DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h>
#include <DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h>
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
#include <DiffuseGlobalIllumination/DiffuseGlobalIlluminationFeatureProcessor.h>
@@ -285,6 +286,7 @@ namespace AZ
passSystem->AddPassCreator(Name("DiffuseProbeGridBorderUpdatePass"), &Render::DiffuseProbeGridBorderUpdatePass::Create);
passSystem->AddPassCreator(Name("DiffuseProbeGridRelocationPass"), &Render::DiffuseProbeGridRelocationPass::Create);
passSystem->AddPassCreator(Name("DiffuseProbeGridClassificationPass"), &Render::DiffuseProbeGridClassificationPass::Create);
passSystem->AddPassCreator(Name("DiffuseProbeGridDownsamplePass"), &Render::DiffuseProbeGridDownsamplePass::Create);
passSystem->AddPassCreator(Name("DiffuseProbeGridRenderPass"), &Render::DiffuseProbeGridRenderPass::Create);
passSystem->AddPassCreator(Name("LuminanceHistogramGeneratorPass"), &LuminanceHistogramGeneratorPass::Create);
@@ -9,6 +9,7 @@
#include <AzCore/Serialization/SerializeContext.h>
#include <Atom/RPI.Public/RPIUtils.h>
#include <Atom/RPI.Public/Scene.h>
#include <Atom/RPI.Public/Pass/ParentPass.h>
#include <Atom/RPI.Public/Pass/PassFilter.h>
#include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
#include <DiffuseGlobalIllumination/DiffuseGlobalIlluminationFeatureProcessor.h>
@@ -90,10 +91,11 @@ namespace AZ
downsamplePassFilter,
[sizeMultiplier](RPI::Pass* pass) -> RPI::PassFilterExecutionFlow
{
for (uint32_t outputIndex = 0; outputIndex < pass->GetOutputCount(); ++outputIndex)
// update the downsample pass size multipliers
for (uint32_t attachmentIndex = 0; attachmentIndex < pass->GetOutputCount(); ++attachmentIndex)
{
RPI::Ptr<RPI::PassAttachment> outputAttachment = pass->GetOutputBinding(outputIndex).m_attachment;
RPI::PassAttachmentSizeMultipliers& sizeMultipliers = outputAttachment->m_sizeMultipliers;
RPI::Ptr<RPI::PassAttachment> attachment = pass->GetOutputBinding(attachmentIndex).m_attachment;
RPI::PassAttachmentSizeMultipliers& sizeMultipliers = attachment->m_sizeMultipliers;
sizeMultipliers.m_widthMultiplier = sizeMultiplier;
sizeMultipliers.m_heightMultiplier = sizeMultiplier;
@@ -105,6 +107,25 @@ namespace AZ
downsamplePass->GetShaderResourceGroup()->SetConstant(
outputImageScaleShaderInput, aznumeric_cast<uint32_t>(1.0f / sizeMultiplier));
// update the parent pass IrradianceImage size multiplier
RPI::ParentPass* parentPass = pass->GetParent();
RPI::Ptr<RPI::PassAttachment> irradianceImageAttachment;
for (uint32_t attachmentIndex = 0; attachmentIndex < parentPass->GetInputOutputCount(); ++attachmentIndex)
{
RPI::Ptr<RPI::PassAttachment> attachment = parentPass->GetInputOutputBinding(attachmentIndex).m_attachment;
if (attachment->m_name == Name("IrradianceImage"))
{
irradianceImageAttachment = attachment;
break;
}
}
AZ_Assert(irradianceImageAttachment != nullptr, "Unable to find IrradianceImage attachment");
RPI::PassAttachmentSizeMultipliers& sizeMultipliers = irradianceImageAttachment->m_sizeMultipliers;
sizeMultipliers.m_widthMultiplier = sizeMultiplier;
sizeMultipliers.m_heightMultiplier = sizeMultiplier;
// handle all downsample passes
return RPI::PassFilterExecutionFlow::ContinueVisitingPasses;
});
@@ -0,0 +1,47 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#include "DiffuseProbeGridDownsamplePass.h"
#include <DiffuseGlobalIllumination/DiffuseProbeGridFeatureProcessor.h>
#include <Atom/RPI.Public/RenderPipeline.h>
namespace AZ
{
namespace Render
{
RPI::Ptr<DiffuseProbeGridDownsamplePass> DiffuseProbeGridDownsamplePass::Create(const RPI::PassDescriptor& descriptor)
{
RPI::Ptr<DiffuseProbeGridDownsamplePass> pass = aznew DiffuseProbeGridDownsamplePass(descriptor);
return AZStd::move(pass);
}
DiffuseProbeGridDownsamplePass::DiffuseProbeGridDownsamplePass(const RPI::PassDescriptor& descriptor)
: RPI::FullscreenTrianglePass(descriptor)
{
}
bool DiffuseProbeGridDownsamplePass::IsEnabled() const
{
if (!Base::IsEnabled())
{
return false;
}
RPI::Scene* scene = m_pipeline->GetScene();
if (!scene)
{
return false;
}
// only enabled if there are DiffuseProbeGrids present in the scene
DiffuseProbeGridFeatureProcessor* diffuseProbeGridFeatureProcessor = scene->GetFeatureProcessor<DiffuseProbeGridFeatureProcessor>();
return (diffuseProbeGridFeatureProcessor && !diffuseProbeGridFeatureProcessor->GetProbeGrids().empty());
}
} // namespace RPI
} // namespace AZ
@@ -0,0 +1,38 @@
/*
* Copyright (c) Contributors to the Open 3D Engine Project.
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
*
* SPDX-License-Identifier: Apache-2.0 OR MIT
*
*/
#pragma once
#include <Atom/RPI.Public/Pass/Pass.h>
#include <Atom/RPI.Public/Pass/FullscreenTrianglePass.h>
namespace AZ
{
namespace Render
{
//! This pass downsamples the scene for use by the DiffuseProbeGridRenderPass.
class DiffuseProbeGridDownsamplePass
: public RPI::FullscreenTrianglePass
{
using Base = RPI::FullscreenTrianglePass;
AZ_RPI_PASS(DiffuseProbeGridDownsamplePass);
public:
AZ_RTTI(Render::DiffuseProbeGridDownsamplePass, "{B3331B68-F974-44D6-806B-2CFFB4B6B563}", Base);
AZ_CLASS_ALLOCATOR(Render::DiffuseProbeGridDownsamplePass, SystemAllocator, 0);
//! Creates a new pass without a PassTemplate
static RPI::Ptr<DiffuseProbeGridDownsamplePass> Create(const RPI::PassDescriptor& descriptor);
private:
explicit DiffuseProbeGridDownsamplePass(const RPI::PassDescriptor& descriptor);
// Pass behavior overrides...
bool IsEnabled() const override;
};
} // namespace RPI
} // namespace AZ
@@ -133,6 +133,8 @@ set(FILES
Source/DiffuseGlobalIllumination/DiffuseProbeGridRelocationPass.h
Source/DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.cpp
Source/DiffuseGlobalIllumination/DiffuseProbeGridClassificationPass.h
Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.cpp
Source/DiffuseGlobalIllumination/DiffuseProbeGridDownsamplePass.h
Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.cpp
Source/DiffuseGlobalIllumination/DiffuseProbeGridRenderPass.h
Source/DiffuseGlobalIllumination/DiffuseProbeGrid.cpp