Skip to content

Commit cc117db

Browse files
authored
The Editor does not crash if UIPass doesn't exist (o3de#17651)
* The Editor does not crash if UIPass doesn't exist 1. Improved DynamicDrawContext.cpp by replacing `AZ_Asserts` with `AZ_WarningOnce`. This allows graphics developers to use render pipelines that do not include the `UIPass`. 2. Replaced several deprecation `AZ_Warning` for `AZ_WarningOnce` in `Application.cpp` because they were overwhelming the console with the message: "'IsPrefabSystemEnabled' is deprecated, the editor only supports prefabs for level editing." 3. Add comment in `Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.h`, on top of the function: `static Descriptor ConvertRenderAttachmentLayout`. This is a breadcrumb for RHI developers on what's the ultimate purpose of this function. --------- Signed-off-by: galibzon <[email protected]>
1 parent f10206a commit cc117db

File tree

3 files changed

+21
-12
lines changed

3 files changed

+21
-12
lines changed

Code/Framework/AzFramework/AzFramework/Application/Application.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,7 @@ namespace AzFramework
770770

771771
bool Application::IsPrefabSystemEnabled() const
772772
{
773-
AZ_Warning("Application", false, "'IsPrefabSystemEnabled' is deprecated, the editor only supports prefabs for level editing.");
773+
AZ_WarningOnce("Application", false, "'IsPrefabSystemEnabled' is deprecated, the editor only supports prefabs for level editing.");
774774
return true;
775775
}
776776

@@ -786,12 +786,12 @@ namespace AzFramework
786786

787787
void Application::SetPrefabSystemEnabled(bool /* enable */)
788788
{
789-
AZ_Warning("Application", false, "'SetPrefabSystemEnabled' is deprecated, the editor only supports prefabs for level editing.");
789+
AZ_WarningOnce("Application", false, "'SetPrefabSystemEnabled' is deprecated, the editor only supports prefabs for level editing.");
790790
}
791791

792792
bool Application::IsPrefabSystemForLevelsEnabled() const
793793
{
794-
AZ_Warning("Application", false, "'IsPrefabSystemForLevelsEnabled' is deprecated, the editor only supports prefabs for level editing.");
794+
AZ_WarningOnce("Application", false, "'IsPrefabSystemForLevelsEnabled' is deprecated, the editor only supports prefabs for level editing.");
795795
return true;
796796
}
797797

Gems/Atom/RHI/Vulkan/Code/Source/RHI/RenderPass.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ namespace AZ
109109
const Descriptor& GetDescriptor() const;
110110
uint32_t GetAttachmentCount() const;
111111

112+
//! Typically the returned descriptor is only used to create a dummy VkRenderPass (cached and reusable)
113+
//! that will be associated with one or more PSOs. The PSO will use such VkRenderPass as a data source
114+
//! to better optimize the layout of the PSO. In the end the real VkRenderPass is built (cached and reusable)
115+
//! at runtime by the FrameGraph and used with VkCmdBeginRenderPass.
116+
//! This is possible because, per the Vulkan spec, it is only required that the PSO VkRenderPass and the VkCmdBeginRenderPass
117+
//! VkRenderPass to be "compatible", but they don't have to be the same object.
112118
static Descriptor ConvertRenderAttachmentLayout(
113119
Device& device,
114120
const RHI::RenderAttachmentLayout& layout,

Gems/Atom/RPI/Code/Source/RPI.Public/DynamicDraw/DynamicDrawContext.cpp

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ namespace AZ
179179
{
180180
AZ_Warning("RPI", m_pipelineState, "Failed to initialize shader for DynamicDrawContext");
181181
AZ_Warning("RPI", m_drawListTag.IsValid(), "DynamicDrawContext doesn't have a valid DrawListTag");
182-
183182
if (!m_drawListTag.IsValid() || m_pipelineState == nullptr)
184183
{
185184
return;
@@ -298,13 +297,12 @@ namespace AZ
298297

299298
ShaderVariantId DynamicDrawContext::UseShaderVariant(const ShaderOptionList& optionAndValues)
300299
{
301-
AZ_Assert(m_initialized && m_supportShaderVariants, "DynamicDrawContext is not initialized or unable to support shader variants. "
302-
"Check if it was initialized with InitShaderWithVariant");
303-
304300
ShaderVariantId variantId;
305301

306-
if (!m_supportShaderVariants)
302+
if (!m_initialized || !m_supportShaderVariants)
307303
{
304+
AZ_WarningOnce("DynamicDrawContext", false, "%s DynamicDrawContext is not initialized or unable to support shader variants. "
305+
"Check if it was initialized with InitShaderWithVariant", __FUNCTION__);
308306
return variantId;
309307
}
310308

@@ -446,16 +444,21 @@ namespace AZ
446444

447445
void DynamicDrawContext::SetShaderVariant(ShaderVariantId shaderVariantId)
448446
{
449-
AZ_Assert( m_initialized && m_supportShaderVariants, "DynamicDrawContext is not initialized or unable to support shader variants. "
450-
"Check if it was initialized with InitShaderWithVariant");
447+
if (!m_initialized || !m_supportShaderVariants)
448+
{
449+
AZ_WarningOnce("DynamicDrawContext", false, "%s DynamicDrawContext is not initialized or unable to support shader variants. "
450+
"Check if it was initialized with InitShaderWithVariant.\n", __FUNCTION__);
451+
return;
452+
}
453+
451454
m_currentShaderVariantId = shaderVariantId;
452455
}
453456

454457
void DynamicDrawContext::DrawIndexed(const void* vertexData, uint32_t vertexCount, const void* indexData, uint32_t indexCount, RHI::IndexFormat indexFormat, Data::Instance < ShaderResourceGroup> drawSrg)
455458
{
456459
if (!m_initialized)
457460
{
458-
AZ_Assert(false, "DynamicDrawContext isn't initialized");
461+
AZ_WarningOnce("DynamicDrawContext", false, "%s This function has been disabled because of failed initialization.\n", __FUNCTION__);
459462
return;
460463
}
461464

@@ -553,7 +556,7 @@ namespace AZ
553556
{
554557
if (!m_initialized)
555558
{
556-
AZ_Assert(false, "DynamicDrawContext isn't initialized");
559+
AZ_WarningOnce("DynamicDrawContext", false, "%s This function has been disabled because of failed initialization.\n", __FUNCTION__);
557560
return;
558561
}
559562

0 commit comments

Comments
 (0)