diff --git a/Gem/Code/Source/RHI/SubpassExampleComponent.cpp b/Gem/Code/Source/RHI/SubpassExampleComponent.cpp index acd2b43f..9699dd0e 100644 --- a/Gem/Code/Source/RHI/SubpassExampleComponent.cpp +++ b/Gem/Code/Source/RHI/SubpassExampleComponent.cpp @@ -41,6 +41,8 @@ namespace AtomSampleViewer , m_depthStencilAttachmentId("depthAttachmentId") { m_supportRHISamplePipeline = true; + m_gbufferScopeId = AZ::RHI::ScopeId("GBufferScope"); + m_compositionScopeId = AZ::RHI::ScopeId("CompositionScope"); } void SubpassExampleComponent::Reflect(AZ::ReflectContext* context) @@ -223,14 +225,14 @@ namespace AtomSampleViewer // Build the render attachment layout with the 2 subpasses. RHI::RenderAttachmentLayoutBuilder attachmentsBuilder; // GBuffer Subpass - attachmentsBuilder.AddSubpass() + attachmentsBuilder.AddSubpass(&m_gbufferScopeId) ->RenderTargetAttachment(RHI::Format::R16G16B16A16_FLOAT, m_positionAttachmentId) ->RenderTargetAttachment(RHI::Format::R16G16B16A16_FLOAT, m_normalAttachmentId) ->RenderTargetAttachment(RHI::Format::R8G8B8A8_UNORM, m_albedoAttachmentId) ->RenderTargetAttachment(m_outputFormat, m_outputAttachmentId) ->DepthStencilAttachment(AZ::RHI::Format::D32_FLOAT, m_depthStencilAttachmentId); // Composition Subpass - attachmentsBuilder.AddSubpass() + attachmentsBuilder.AddSubpass(&m_compositionScopeId) ->SubpassInputAttachment(m_positionAttachmentId, RHI::ImageAspectFlags::Color) ->SubpassInputAttachment(m_normalAttachmentId, RHI::ImageAspectFlags::Color) ->SubpassInputAttachment(m_albedoAttachmentId, RHI::ImageAspectFlags::Color) @@ -341,6 +343,7 @@ namespace AtomSampleViewer descriptor.m_attachmentId = m_positionAttachmentId; descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Clear; descriptor.m_loadStoreAction.m_clearValue = RHI::ClearValue::CreateVector4Float(0.f, 0.f, 0.f, 0.f); + descriptor.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Color; frameGraph.UseColorAttachment(descriptor); } @@ -350,6 +353,7 @@ namespace AtomSampleViewer descriptor.m_attachmentId = m_normalAttachmentId; descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Clear; descriptor.m_loadStoreAction.m_clearValue = RHI::ClearValue::CreateVector4Float(0.f, 0.f, 0.f, 0.f); + descriptor.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Color; frameGraph.UseColorAttachment(descriptor); } @@ -359,6 +363,7 @@ namespace AtomSampleViewer descriptor.m_attachmentId = m_albedoAttachmentId; descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Clear; descriptor.m_loadStoreAction.m_clearValue = RHI::ClearValue::CreateVector4Float(0.f, 0.f, 0.f, 0.f); + descriptor.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Color; frameGraph.UseColorAttachment(descriptor); } @@ -367,6 +372,7 @@ namespace AtomSampleViewer RHI::ImageScopeAttachmentDescriptor descriptor; descriptor.m_attachmentId = m_outputAttachmentId; descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Load; + descriptor.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Color; frameGraph.UseColorAttachment(descriptor); } @@ -376,6 +382,7 @@ namespace AtomSampleViewer dsDesc.m_attachmentId = m_depthStencilAttachmentId; dsDesc.m_loadStoreAction.m_clearValue = RHI::ClearValue::CreateDepthStencil(0, 0); dsDesc.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Clear; + dsDesc.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Depth; frameGraph.UseDepthStencilAttachment(dsDesc, RHI::ScopeAttachmentAccess::Write); } @@ -420,14 +427,13 @@ namespace AtomSampleViewer } }; - const RHI::ScopeId forwardScope("GBufferScope"); m_scopeProducers.emplace_back( aznew RHI::ScopeProducerFunction< ScopeData, decltype(prepareFunction), decltype(compileFunction), decltype(executeFunction)>( - forwardScope, + m_gbufferScopeId, ScopeData{}, prepareFunction, compileFunction, @@ -447,6 +453,7 @@ namespace AtomSampleViewer RHI::ImageScopeAttachmentDescriptor descriptor; descriptor.m_attachmentId = m_positionAttachmentId; descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Load; + descriptor.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Color; frameGraph.UseSubpassInputAttachment(descriptor); } @@ -455,6 +462,7 @@ namespace AtomSampleViewer RHI::ImageScopeAttachmentDescriptor descriptor; descriptor.m_attachmentId = m_normalAttachmentId; descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Load; + descriptor.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Color; frameGraph.UseSubpassInputAttachment(descriptor); } @@ -463,6 +471,7 @@ namespace AtomSampleViewer RHI::ImageScopeAttachmentDescriptor descriptor; descriptor.m_attachmentId = m_albedoAttachmentId; descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Load; + descriptor.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Color; frameGraph.UseSubpassInputAttachment(descriptor); } @@ -471,6 +480,7 @@ namespace AtomSampleViewer RHI::ImageScopeAttachmentDescriptor descriptor; descriptor.m_attachmentId = m_outputAttachmentId; descriptor.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Load; + descriptor.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Color; frameGraph.UseColorAttachment(descriptor); } @@ -479,6 +489,7 @@ namespace AtomSampleViewer RHI::ImageScopeAttachmentDescriptor dsDesc; dsDesc.m_attachmentId = m_depthStencilAttachmentId; dsDesc.m_loadStoreAction.m_loadAction = RHI::AttachmentLoadAction::Load; + dsDesc.m_imageViewDescriptor.m_aspectFlags = RHI::ImageAspectFlags::Depth; frameGraph.UseDepthStencilAttachment(dsDesc, RHI::ScopeAttachmentAccess::Read); } @@ -531,14 +542,13 @@ namespace AtomSampleViewer commandList->Submit(drawItem); }; - const RHI::ScopeId forwardScope("CompositionScope"); m_scopeProducers.emplace_back( aznew RHI::ScopeProducerFunction< ScopeData, decltype(prepareFunction), decltype(compileFunction), decltype(executeFunction)>( - forwardScope, + m_compositionScopeId, ScopeData{}, prepareFunction, compileFunction, diff --git a/Gem/Code/Source/RHI/SubpassExampleComponent.h b/Gem/Code/Source/RHI/SubpassExampleComponent.h index 46ae037b..5d9085cf 100644 --- a/Gem/Code/Source/RHI/SubpassExampleComponent.h +++ b/Gem/Code/Source/RHI/SubpassExampleComponent.h @@ -126,5 +126,8 @@ namespace AtomSampleViewer AZ::Data::Instance m_compositionSubpassInputsSRG; AZ::Data::Instance m_viewShaderResourceGroup; AZ::RHI::ConstPtr m_compositionPipeline; + + AZ::RHI::ScopeId m_gbufferScopeId; + AZ::RHI::ScopeId m_compositionScopeId; }; } // namespace AtomSampleViewer