Merge pull request #7541 from aws-lumberyard-dev/Atom/dmcdiar/ATOM-17288
Application MSAA state
This commit is contained in:
@@ -318,10 +318,8 @@ namespace AZ
|
||||
RPI::RenderPipelineDescriptor renderPipelineDescriptor = *RPI::GetDataFromAnyAsset<RPI::RenderPipelineDescriptor>(pipelineAsset);
|
||||
renderPipelineDescriptor.m_name = AZStd::string::format("%s_%i", renderPipelineDescriptor.m_name.c_str(), viewportContext->GetId());
|
||||
|
||||
// Make sure non-msaa super variant is used for non-msaa pipeline
|
||||
bool isNonMsaaPipeline = (renderPipelineDescriptor.m_renderSettings.m_multisampleState.m_samples == 1);
|
||||
const char* supervariantName = isNonMsaaPipeline ? AZ::RPI::NoMsaaSupervariantName : "";
|
||||
AZ::RPI::ShaderSystemInterface::Get()->SetSupervariantName(AZ::Name(supervariantName));
|
||||
// The default pipeline determines the initial MSAA state for the application
|
||||
AZ::RPI::RPISystemInterface::Get()->SetApplicationMultisampleState(renderPipelineDescriptor.m_renderSettings.m_multisampleState);
|
||||
|
||||
if (!scene->GetRenderPipeline(AZ::Name(renderPipelineDescriptor.m_name)))
|
||||
{
|
||||
|
||||
@@ -34,11 +34,11 @@
|
||||
"Attachment": "Output"
|
||||
}
|
||||
},
|
||||
"MultisampleSource": {
|
||||
"Pass": "Pipeline"
|
||||
},
|
||||
"ImageDescriptor": {
|
||||
"Format": "D32_FLOAT_S8X24_UINT",
|
||||
"MultisampleState": {
|
||||
"samples": 4
|
||||
},
|
||||
"SharedQueueMask": "Graphics"
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -29,6 +29,24 @@
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"Name": "NoMSAA",
|
||||
"RootShaderVariantAssets":
|
||||
[
|
||||
{
|
||||
"APIName": "dx12",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender-nomsaa_dx12_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "vulkan",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender-nomsaa_vulkan_0.azshadervariant"
|
||||
},
|
||||
{
|
||||
"APIName": "null",
|
||||
"RootShaderVariantAssetFileName": "diffuseprobegridrender-nomsaa_null_0.azshadervariant"
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -115,10 +115,6 @@ namespace AZ
|
||||
// all faces of the cubemap have been rendered, invoke the callback
|
||||
m_callback(m_environmentCubeMapPass->GetTextureData(), m_environmentCubeMapPass->GetTextureFormat());
|
||||
|
||||
// remove the pipeline
|
||||
m_scene->RemoveRenderPipeline(m_environmentCubeMapPipelineId);
|
||||
m_environmentCubeMapPass = nullptr;
|
||||
|
||||
// restore exposures
|
||||
sceneSrg->SetConstant(m_globalIblExposureConstantIndex, m_previousGlobalIblExposure);
|
||||
sceneSrg->SetConstant(m_skyBoxExposureConstantIndex, m_previousSkyBoxExposure);
|
||||
@@ -223,6 +219,16 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void ReflectionProbe::OnRenderEnd()
|
||||
{
|
||||
if (m_environmentCubeMapPass && m_environmentCubeMapPass->IsFinished())
|
||||
{
|
||||
// remove the cubemap pipeline
|
||||
// Note: this must be done here (not in Simulate) to avoid a race condition with other feature processors
|
||||
m_scene->RemoveRenderPipeline(m_environmentCubeMapPipelineId);
|
||||
m_environmentCubeMapPass = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
void ReflectionProbe::SetTransform(const AZ::Transform& transform)
|
||||
{
|
||||
@@ -282,7 +288,7 @@ namespace AZ
|
||||
|
||||
AZ::RPI::RenderPipelineDescriptor environmentCubeMapPipelineDesc;
|
||||
environmentCubeMapPipelineDesc.m_mainViewTagName = "MainCamera";
|
||||
environmentCubeMapPipelineDesc.m_renderSettings.m_multisampleState.m_samples = 4;
|
||||
environmentCubeMapPipelineDesc.m_renderSettings.m_multisampleState = RPI::RPISystemInterface::Get()->GetApplicationMultisampleState();
|
||||
environmentCubeMapPipelineDesc.m_renderSettings.m_size.m_width = RPI::EnvironmentCubeMapPass::CubeMapFaceSize;
|
||||
environmentCubeMapPipelineDesc.m_renderSettings.m_size.m_height = RPI::EnvironmentCubeMapPass::CubeMapFaceSize;
|
||||
|
||||
|
||||
@@ -75,6 +75,7 @@ namespace AZ
|
||||
|
||||
void Init(RPI::Scene* scene, ReflectionRenderData* reflectionRenderData);
|
||||
void Simulate(uint32_t probeIndex);
|
||||
void OnRenderEnd();
|
||||
|
||||
const Vector3& GetPosition() const { return m_transform.GetTranslation(); }
|
||||
const AZ::Transform& GetTransform() const { return m_transform; }
|
||||
|
||||
+12
@@ -166,6 +166,18 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
void ReflectionProbeFeatureProcessor::OnRenderEnd()
|
||||
{
|
||||
// call OnRenderEnd on all reflection probes
|
||||
for (uint32_t probeIndex = 0; probeIndex < m_reflectionProbes.size(); ++probeIndex)
|
||||
{
|
||||
AZStd::shared_ptr<ReflectionProbe>& reflectionProbe = m_reflectionProbes[probeIndex];
|
||||
AZ_Assert(reflectionProbe.use_count() > 1, "ReflectionProbe found with no corresponding owner, ensure that RemoveProbe() is called before releasing probe handles");
|
||||
|
||||
reflectionProbe->OnRenderEnd();
|
||||
}
|
||||
}
|
||||
|
||||
ReflectionProbeHandle ReflectionProbeFeatureProcessor::AddProbe(const AZ::Transform& transform, bool useParallaxCorrection)
|
||||
{
|
||||
AZStd::shared_ptr<ReflectionProbe> reflectionProbe = AZStd::make_shared<ReflectionProbe>();
|
||||
|
||||
@@ -46,6 +46,7 @@ namespace AZ
|
||||
void Activate() override;
|
||||
void Deactivate() override;
|
||||
void Simulate(const FeatureProcessor::SimulatePacket& packet) override;
|
||||
void OnRenderEnd() override;
|
||||
|
||||
// find the reflection probe volumes that contain the position
|
||||
using ReflectionProbeVector = AZStd::vector<AZStd::shared_ptr<ReflectionProbe>>;
|
||||
|
||||
@@ -86,6 +86,8 @@ namespace AZ
|
||||
const RPISystemDescriptor& GetDescriptor() const override;
|
||||
Name GetRenderApiName() const override;
|
||||
uint64_t GetCurrentTick() const override;
|
||||
void SetApplicationMultisampleState(const RHI::MultisampleState& multisampleState) override;
|
||||
const RHI::MultisampleState& GetApplicationMultisampleState() const override;
|
||||
|
||||
// AZ::Debug::TraceMessageBus::Handler overrides...
|
||||
bool OnPreAssert(const char* fileName, int line, const char* func, const char* message) override;
|
||||
@@ -136,6 +138,9 @@ namespace AZ
|
||||
bool m_systemAssetsInitialized = false;
|
||||
|
||||
uint64_t m_renderTick = 0;
|
||||
|
||||
// Application multisample state
|
||||
RHI::MultisampleState m_multisampleState;
|
||||
};
|
||||
|
||||
} // namespace RPI
|
||||
|
||||
@@ -90,6 +90,10 @@ namespace AZ
|
||||
|
||||
//! Get the index of current render tick
|
||||
virtual uint64_t GetCurrentTick() const = 0;
|
||||
|
||||
//! Application multisample state
|
||||
virtual void SetApplicationMultisampleState(const RHI::MultisampleState& multisampleState) = 0;
|
||||
virtual const RHI::MultisampleState& GetApplicationMultisampleState() const = 0;
|
||||
};
|
||||
|
||||
} // namespace RPI
|
||||
|
||||
@@ -434,5 +434,29 @@ namespace AZ
|
||||
return m_renderTick;
|
||||
}
|
||||
|
||||
void RPISystem::SetApplicationMultisampleState(const RHI::MultisampleState& multisampleState)
|
||||
{
|
||||
m_multisampleState = multisampleState;
|
||||
|
||||
bool isNonMsaaPipeline = (m_multisampleState.m_samples == 1);
|
||||
const char* supervariantName = isNonMsaaPipeline ? AZ::RPI::NoMsaaSupervariantName : "";
|
||||
AZ::RPI::ShaderSystemInterface::Get()->SetSupervariantName(AZ::Name(supervariantName));
|
||||
|
||||
// reinitialize pipelines for all scenes
|
||||
for (auto& scene : m_scenes)
|
||||
{
|
||||
for (auto& renderPipeline : scene->GetRenderPipelines())
|
||||
{
|
||||
renderPipeline->GetRenderSettings().m_multisampleState = multisampleState;
|
||||
renderPipeline->SetPassNeedsRecreate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const RHI::MultisampleState& RPISystem::GetApplicationMultisampleState() const
|
||||
{
|
||||
return m_multisampleState;
|
||||
}
|
||||
|
||||
} //namespace RPI
|
||||
} //namespace AZ
|
||||
|
||||
@@ -63,10 +63,8 @@ namespace AtomToolsFramework
|
||||
pipelineDesc.m_mainViewTagName = "MainCamera";
|
||||
pipelineDesc.m_name = pipelineName;
|
||||
pipelineDesc.m_rootPassTemplate = "ToolsPipelineRenderToTexture";
|
||||
pipelineDesc.m_renderSettings.m_multisampleState = AZ::RPI::RPISystemInterface::Get()->GetApplicationMultisampleState();
|
||||
|
||||
// We have to set the samples to 4 to match the pipeline passes' setting, otherwise it may lead to device lost issue
|
||||
// [GFX TODO] [ATOM-13551] Default value sand validation required to prevent pipeline crash and device lost
|
||||
pipelineDesc.m_renderSettings.m_multisampleState.m_samples = 4;
|
||||
m_renderPipeline = AZ::RPI::RenderPipeline::CreateRenderPipeline(pipelineDesc);
|
||||
m_scene->AddRenderPipeline(m_renderPipeline);
|
||||
m_scene->Activate();
|
||||
|
||||
Reference in New Issue
Block a user