Reenable support for UI Elements that use Render Targets (#2352)
* Re-add support for UI Elements that use Render Targets * Move LyShine pass request from Atom's MainPipeline.pass to project's * Make all dynamic draw contexts in LyShine draw to pass directly without the need of draw list tags * Remove local RPI changes that are no longer needed * Prevent crash if LyShine gem is enabled but its custom pass hasn't been added to the main render pipeline * Revert to default UI pass if the LyShine pass has not been added to project's main render pipeline Signed-off-by: abrmich <abrmich@amazon.com>
This commit is contained in:
@@ -9,6 +9,7 @@
|
||||
#include <IRenderer.h> // for SVF_P3F_C4B_T2F which will be removed in a coming PR
|
||||
|
||||
#include <LyShine/Draw2d.h>
|
||||
#include "LyShinePassDataBus.h"
|
||||
|
||||
#include <AzCore/Math/Matrix3x3.h>
|
||||
#include <AzCore/Math/MatrixUtils.h>
|
||||
@@ -95,6 +96,12 @@ void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapSc
|
||||
AZ_Assert(scene != nullptr, "Attempting to create a DynamicDrawContext for a viewport context that has not been associated with a scene yet.");
|
||||
|
||||
// Create and initialize a DynamicDrawContext for 2d drawing
|
||||
|
||||
// Get the pass for the dynamic draw context to render to
|
||||
AZ::RPI::RasterPass* uiCanvasPass = nullptr;
|
||||
AZ::RPI::SceneId sceneId = scene->GetId();
|
||||
LyShinePassRequestBus::EventResult(uiCanvasPass, sceneId, &LyShinePassRequestBus::Events::GetUiCanvasPass);
|
||||
|
||||
m_dynamicDraw = AZ::RPI::DynamicDrawInterface::Get()->CreateDynamicDrawContext();
|
||||
AZ::RPI::ShaderOptionList shaderOptions;
|
||||
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("true")));
|
||||
@@ -106,7 +113,15 @@ void CDraw2d::OnBootstrapSceneReady([[maybe_unused]] AZ::RPI::Scene* bootstrapSc
|
||||
{"TEXCOORD0", AZ::RHI::Format::R32G32_FLOAT} });
|
||||
m_dynamicDraw->AddDrawStateOptions(AZ::RPI::DynamicDrawContext::DrawStateOptions::PrimitiveType
|
||||
| AZ::RPI::DynamicDrawContext::DrawStateOptions::BlendMode);
|
||||
m_dynamicDraw->SetOutputScope(scene.get());
|
||||
if (uiCanvasPass)
|
||||
{
|
||||
m_dynamicDraw->SetOutputScope(uiCanvasPass);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Render target support is disabled
|
||||
m_dynamicDraw->SetOutputScope(scene.get());
|
||||
}
|
||||
m_dynamicDraw->EndInit();
|
||||
|
||||
AZ::RHI::TargetBlendState targetBlendState;
|
||||
@@ -491,6 +506,7 @@ bool CDraw2d::GetDeferPrimitives()
|
||||
return m_deferCalls;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
void CDraw2d::SetSortKey(int64_t key)
|
||||
{
|
||||
m_dynamicDraw->SetSortKey(key);
|
||||
|
||||
Reference in New Issue
Block a user