LyShine cleanup of TODOs (#6138)

* LyShine cleanup pass for Atom conversion

Signed-off-by: abrmich <abrmich@amazon.com>

* Add GHI numbers to comments

Signed-off-by: abrmich <abrmich@amazon.com>
This commit is contained in:
michabr
2021-12-13 15:00:26 -08:00
committed by GitHub
parent 04669544cc
commit d951e1f652
21 changed files with 105 additions and 133 deletions
-6
View File
@@ -665,13 +665,7 @@ void EditorViewportWidget::OnBeginPrepareRender()
RenderAll();
// Draw 2D helpers.
#ifdef LYSHINE_ATOM_TODO
TransformationMatrices backupSceneMatrices;
#endif
m_debugDisplay->DepthTestOff();
#ifdef LYSHINE_ATOM_TODO
m_renderer->Set2DMode(m_rcClient.right(), m_rcClient.bottom(), backupSceneMatrices);
#endif
auto prevState = m_debugDisplay->GetState();
m_debugDisplay->SetState(e_Mode3D | e_AlphaBlended | e_FillModeSolid | e_CullModeBack | e_DepthWriteOn | e_DepthTestOn);
@@ -341,11 +341,6 @@ void ViewportWidget::ClearUntilSafeToRedraw()
// set flag so that Update will just clear the screen rather than rendering canvas
m_canvasRenderIsEnabled = false;
#ifdef LYSHINE_ATOM_TODO // check if still needed
// Force an update
Update();
#endif
// Schedule a timer to set the m_canvasRenderIsEnabled flag
// using a time of zero just waits until there is nothing on the event queue
QTimer::singleShot(0, this, SLOT(EnableCanvasRender()));
+2 -2
View File
@@ -23,7 +23,7 @@
//! The CDraw2d class implements the IDraw2d interface for drawing 2D images, shapes and text.
//! Positions and sizes are specified in pixels in the associated 2D viewport.
class CDraw2d
: public IDraw2d // LYSHINE_ATOM_TODO - keep around until gEnv->pLyShine is replaced by bus interface
: public IDraw2d // [LYSHINE_ATOM_TODO][GHI #3573] Make Draw2d work better as an API
, public AZ::Render::Bootstrap::NotificationBus::Handler
{
public: // types
@@ -582,7 +582,7 @@ public: // static member functions
//! Helper to get the default IDraw2d interface
static CDraw2d* GetDefaultDraw2d()
{
if (gEnv && gEnv->pLyShine) // LYSHINE_ATOM_TODO - remove pLyShine and use bus interface
if (gEnv && gEnv->pLyShine) // [LYSHINE_ATOM_TODO][GHI #3569] Remove LyShine global interface pointer from legacy global environment
{
IDraw2d* draw2d = gEnv->pLyShine->GetDraw2d();
return reinterpret_cast<CDraw2d*>(draw2d);
@@ -10,6 +10,8 @@
#include <LyShine/UiBase.h>
#include <LyShine/UiRenderFormats.h>
#include <Atom/RPI.Public/Image/AttachmentImage.h>
namespace AZ
{
class Color;
@@ -41,9 +43,28 @@ namespace LyShine
//! End the setup of a mask render node, this marks the end of adding child primitives
virtual void EndMask() = 0;
//! Begin rendering to a texture
virtual void BeginRenderToTexture(AZ::Data::Instance<AZ::RPI::AttachmentImage> attachmentImage,
const AZ::Vector2& viewportTopLeft,
const AZ::Vector2& viewportSize,
const AZ::Color& clearColor) = 0;
//! End rendering to a texture
virtual void EndRenderToTexture() = 0;
//! Add an indexed triangle list primitive to the render graph with given render state
virtual void AddPrimitive(LyShine::UiPrimitive* primitive, const AZ::Data::Instance<AZ::RPI::Image>& texture,
bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) = 0;
//! Add an indexed triangle list primitive to the render graph which will use maskTexture as an alpha (gradient) mask
virtual void AddAlphaMaskPrimitive(LyShine::UiPrimitive* primitive,
AZ::Data::Instance<AZ::RPI::AttachmentImage> contentAttachmentImage,
AZ::Data::Instance<AZ::RPI::AttachmentImage> maskAttachmentImage,
bool isClampTextureMode,
bool isTextureSRGB,
bool isTexturePremultipliedAlpha,
BlendMode blendMode) = 0;
//! Get a dynamic quad primitive that can be added as an image primitive to the render graph
//! The graph handles the allocation of this DynUiPrimitive and deletes it when the graph is reset
//! This can be used if the UI component doesn't want to own the storage of the primitive. Used infrequently,
@@ -11,6 +11,15 @@
#include <smartptr.h>
#include <LyShine/Bus/UiTransformBus.h>
#include <AzCore/Math/Vector2.h>
#include <AtomCore/Instance/Instance.h>
namespace AZ
{
namespace RPI
{
class Image;
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
//! A sprite is a texture with extra information about how it behaves for 2D drawing
@@ -135,4 +144,6 @@ public: // member functions
//! Returns true if this sprite is configured as a sprite-sheet, false otherwise
virtual bool IsSpriteSheet() const = 0;
virtual AZ::Data::Instance<AZ::RPI::Image> GetImage() = 0;
};
+6 -6
View File
@@ -101,7 +101,7 @@ static const int g_numDstBlendModes = 10;
////////////////////////////////////////////////////////////////////////////////////////////////////
#if !defined(_RELEASE)
#ifdef LYSHINE_ATOM_TODO
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
static int Create2DTexture(int width, int height, byte* data, ETEX_Format format)
{
IRenderer* renderer = gEnv->pRenderer;
@@ -120,7 +120,7 @@ static AZ::Vector2 GetTextureSize(AZ::Data::Instance<AZ::RPI::Image> image)
////////////////////////////////////////////////////////////////////////////////////////////////////
#if !defined(_RELEASE)
#ifdef LYSHINE_ATOM_TODO
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
static void FillTextureRectWithCheckerboard(uint32* data, int textureWidth, int textureHeight,
int minX, int minY, [[maybe_unused]] int rectWidth, int rectHeight,
int tileWidth, int tileHeight, uint32* colors, bool varyAlpha)
@@ -152,7 +152,7 @@ static void FillTextureRectWithCheckerboard(uint32* data, int textureWidth, int
#if !defined(_RELEASE)
static AZ::Data::Instance<AZ::RPI::Image> CreateMonoTestTexture()
{
#ifdef LYSHINE_ATOM_TODO
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
const int width = 32;
const int height = 32;
uint32 data[width * height];
@@ -192,7 +192,7 @@ static AZ::Data::Instance<AZ::RPI::Image> CreateMonoTestTexture()
#if !defined(_RELEASE)
static AZ::Data::Instance<AZ::RPI::Image> CreateColorTestTexture()
{
#ifdef LYSHINE_ATOM_TODO
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
const int width = 32;
const int height = 32;
uint32 data[width * height];
@@ -232,7 +232,7 @@ static AZ::Data::Instance<AZ::RPI::Image> CreateColorTestTexture()
#if !defined(_RELEASE)
static AZ::Data::Instance<AZ::RPI::Image> CreateMonoAlphaTestTexture()
{
#ifdef LYSHINE_ATOM_TODO
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
const int width = 32;
const int height = 32;
uint32 data[width * height];
@@ -272,7 +272,7 @@ static AZ::Data::Instance<AZ::RPI::Image> CreateMonoAlphaTestTexture()
#if !defined(_RELEASE)
static AZ::Data::Instance<AZ::RPI::Image> CreateColorAlphaTestTexture()
{
#ifdef LYSHINE_ATOM_TODO
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
const int width = 32;
const int height = 32;
uint32 data[width * height];
+3 -3
View File
@@ -151,7 +151,7 @@ namespace LyShine
// Add the indexed primitives to the dynamic draw context for drawing
//
// [LYSHINE_ATOM_TODO][ATOM-15073] - need to combine into a single DrawIndexed call to take advantage of the draw call
// [LYSHINE_ATOM_TODO][ATOM-15073] Combine into a single DrawIndexed call to take advantage of the draw call
// optimization done by this RenderGraph. This option will be added to DynamicDrawContext. For
// now we could combine the vertices ourselves
for (const LyShine::UiPrimitive& primitive : m_primitives)
@@ -698,7 +698,7 @@ namespace LyShine
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void RenderGraph::AddPrimitiveAtom(LyShine::UiPrimitive* primitive, const AZ::Data::Instance<AZ::RPI::Image>& texture,
void RenderGraph::AddPrimitive(LyShine::UiPrimitive* primitive, const AZ::Data::Instance<AZ::RPI::Image>& texture,
bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode)
{
AZStd::vector<RenderNode*>* renderNodeList = m_renderNodeListStack.top();
@@ -771,7 +771,7 @@ namespace LyShine
}
////////////////////////////////////////////////////////////////////////////////////////////////////
void RenderGraph::AddAlphaMaskPrimitiveAtom(LyShine::UiPrimitive* primitive,
void RenderGraph::AddAlphaMaskPrimitive(LyShine::UiPrimitive* primitive,
AZ::Data::Instance<AZ::RPI::AttachmentImage> contentAttachmentImage,
AZ::Data::Instance<AZ::RPI::AttachmentImage> maskAttachmentImage,
bool isClampTextureMode,
+9 -11
View File
@@ -262,6 +262,10 @@ namespace LyShine
void StartChildrenForMask() override;
void EndMask() override;
void BeginRenderToTexture(AZ::Data::Instance<AZ::RPI::AttachmentImage> attachmentImage,
const AZ::Vector2& viewportTopLeft,
const AZ::Vector2& viewportSize,
const AZ::Color& clearColor) override;
void EndRenderToTexture() override;
LyShine::UiPrimitive* GetDynamicQuadPrimitive(const AZ::Vector2* positions, uint32 packedColor) override;
@@ -273,25 +277,19 @@ namespace LyShine
void PushOverrideAlphaFade(float alphaFadeValue) override;
void PopAlphaFade() override;
float GetAlphaFade() const override;
void AddPrimitive(LyShine::UiPrimitive* primitive, const AZ::Data::Instance<AZ::RPI::Image>& texture,
bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode) override;
// ~IRenderGraph
// LYSHINE_ATOM_TODO - this can be renamed back to AddPrimitive after removal of IRenderer from all UI components
void AddPrimitiveAtom(LyShine::UiPrimitive* primitive, const AZ::Data::Instance<AZ::RPI::Image>& texture,
bool isClampTextureMode, bool isTextureSRGB, bool isTexturePremultipliedAlpha, BlendMode blendMode);
//! Add an indexed triangle list primitive to the render graph which will use maskTexture as an alpha (gradient) mask
void AddAlphaMaskPrimitiveAtom(LyShine::UiPrimitive* primitive,
void AddAlphaMaskPrimitive(LyShine::UiPrimitive* primitive,
AZ::Data::Instance<AZ::RPI::AttachmentImage> contentAttachmentImage,
AZ::Data::Instance<AZ::RPI::AttachmentImage> maskAttachmentImage,
bool isClampTextureMode,
bool isTextureSRGB,
bool isTexturePremultipliedAlpha,
BlendMode blendMode);
void BeginRenderToTexture(AZ::Data::Instance<AZ::RPI::AttachmentImage> attachmentImage,
const AZ::Vector2& viewportTopLeft,
const AZ::Vector2& viewportSize,
const AZ::Color& clearColor);
BlendMode blendMode) override;
//! Render the display graph
void Render(UiRenderer* uiRenderer, const AZ::Vector2& viewportSize);
+1 -3
View File
@@ -243,12 +243,10 @@ void CSprite::SetCellBorders(int cellIndex, Borders borders)
AZ::Data::Instance<AZ::RPI::Image> CSprite::GetImage()
{
// Prioritize usage of an atlas
#ifdef LYSHINE_ATOM_TODO // texture atlas conversion to use Atom
if (m_atlas)
{
return m_atlas->GetTexture();
}
#endif
return m_image;
}
@@ -701,7 +699,7 @@ CSprite* CSprite::CreateSprite(const AZStd::string& renderTargetName)
// create Sprite object
CSprite* sprite = new CSprite;
#ifdef LYSHINE_ATOM_TODO // render target converstion to use ATom
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
// the render target texture may not exist yet in which case we will need to load it later
sprite->m_texture = gEnv->pRenderer->EF_GetTextureByName(renderTargetName.c_str());
if (sprite->m_texture)
+1 -3
View File
@@ -56,7 +56,7 @@ public: // member functions
void SetCellAlias(int cellIndex, const AZStd::string& cellAlias) override;
int GetCellIndexFromAlias(const AZStd::string& cellAlias) const override;
bool IsSpriteSheet() const override;
AZ::Data::Instance<AZ::RPI::Image> GetImage() override;
// ~ISprite
// TextureAtlasNotifications
@@ -66,8 +66,6 @@ public: // member functions
// ~TextureAtlasNotifications
AZ::Data::Instance<AZ::RPI::Image> GetImage();
public: // static member functions
static void Initialize();
@@ -3605,7 +3605,7 @@ void UiCanvasComponent::CreateRenderTarget()
return;
}
#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom
#ifdef LYSHINE_ATOM_TODO // [GHI #6269] Support RTT using Atom
// Create a render target that this canvas will be rendered to.
// The render target size is the canvas size.
m_renderTargetHandle = gEnv->pRenderer->CreateRenderTarget(m_renderTargetName.c_str(),
@@ -3636,11 +3636,11 @@ void UiCanvasComponent::DestroyRenderTarget()
if (m_renderTargetHandle > 0)
{
ISystem::CrySystemNotificationBus::Handler::BusDisconnect();
#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom
#ifdef LYSHINE_ATOM_TODO // [GHI #6269] Support RTT using Atom
gEnv->pRenderer->DestroyDepthSurface(m_renderTargetDepthSurface);
#endif
m_renderTargetDepthSurface = nullptr;
#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom
#ifdef LYSHINE_ATOM_TODO // [GHI #6269] Support RTT using Atom
gEnv->pRenderer->DestroyRenderTarget(m_renderTargetHandle);
#endif
m_renderTargetHandle = -1;
@@ -3650,7 +3650,7 @@ void UiCanvasComponent::DestroyRenderTarget()
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiCanvasComponent::RenderCanvasToTexture()
{
#ifdef LYSHINE_ATOM_TODO // [LYN-3359] Support RTT using Atom
#ifdef LYSHINE_ATOM_TODO // [GHI #6269] Support RTT using Atom
if (m_renderTargetHandle <= 0)
{
return;
+9 -14
View File
@@ -455,7 +455,7 @@ void UiFaderComponent::CreateOrResizeRenderTarget(const AZ::Vector2& pixelAligne
m_viewportTopLeft = pixelAlignedTopLeft;
m_viewportSize = renderTargetSize;
// LYSHINE_ATOM_TODO: optimize by reusing/resizing targets
// [LYSHINE_ATOM_TODO][GHI #6271] Optimize by reusing existing render targets
DestroyRenderTarget();
// Create a render target that this element and its children will be rendered to
@@ -573,8 +573,7 @@ void UiFaderComponent::RenderRttFader(LyShine::IRenderGraph* renderGraph, UiElem
AZ::Color clearColor(0.0f, 0.0f, 0.0f, 0.0f);
// Start building the render to texture node in the render graph
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
lyRenderGraph->BeginRenderToTexture(attachmentImage, m_viewportTopLeft, m_viewportSize, clearColor);
renderGraph->BeginRenderToTexture(attachmentImage, m_viewportTopLeft, m_viewportSize, clearColor);
// We don't want this fader or parent faders to affect what is rendered to the render target since we will
// apply those fades when we render from the render target.
@@ -613,17 +612,13 @@ void UiFaderComponent::RenderRttFader(LyShine::IRenderGraph* renderGraph, UiElem
// Add a primitive to render a quad using the render target we have created
{
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (lyRenderGraph)
{
// Set the texture and other render state required
AZ::Data::Instance<AZ::RPI::Image> image = attachmentImage;
bool isClampTextureMode = true;
bool isTextureSRGB = true;
bool isTexturePremultipliedAlpha = true;
LyShine::BlendMode blendMode = LyShine::BlendMode::Normal;
lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
// Set the texture and other render state required
AZ::Data::Instance<AZ::RPI::Image> image = attachmentImage;
bool isClampTextureMode = true;
bool isTextureSRGB = true;
bool isTexturePremultipliedAlpha = true;
LyShine::BlendMode blendMode = LyShine::BlendMode::Normal;
renderGraph->AddPrimitive(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
}
}
+3 -11
View File
@@ -278,11 +278,7 @@ namespace
AZ::Data::Instance<AZ::RPI::Image> image;
if (sprite)
{
CSprite* cSprite = static_cast<CSprite*>(sprite); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (cSprite)
{
image = cSprite->GetImage();
}
image = sprite->GetImage();
}
return image;
@@ -469,7 +465,7 @@ void UiImageComponent::Render(LyShine::IRenderGraph* renderGraph)
}
}
#ifdef LYSHINE_ATOM_TODO // keeping this code for future phase (masks and render targets)
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
ITexture* texture = (sprite) ? sprite->GetTexture() : nullptr;
bool isClampTextureMode = m_imageType == ImageType::Tiled ? false : true;
bool isTextureSRGB = IsSpriteTypeRenderTarget() && m_isRenderTargetSRGB;
@@ -482,11 +478,7 @@ void UiImageComponent::Render(LyShine::IRenderGraph* renderGraph)
bool isTextureSRGB = IsSpriteTypeRenderTarget() && m_isRenderTargetSRGB;
bool isTexturePremultipliedAlpha = false; // we are not rendering from a render target with alpha in it
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (lyRenderGraph)
{
lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode);
}
renderGraph->AddPrimitive(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode);
#endif
}
}
@@ -97,7 +97,7 @@ void UiImageSequenceComponent::Render(LyShine::IRenderGraph* renderGraph)
return;
}
CSprite* sprite = static_cast<CSprite*>(m_spriteList[m_sequenceIndex]); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
ISprite* sprite = m_spriteList[m_sequenceIndex];
// get fade value (tracked by UiRenderer) and compute the desired alpha for the image
float fade = renderGraph->GetAlphaFade();
@@ -165,12 +165,8 @@ void UiImageSequenceComponent::Render(LyShine::IRenderGraph* renderGraph)
LyShine::BlendMode blendMode = LyShine::BlendMode::Normal;
// Add the quad to the render graph
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (lyRenderGraph)
{
lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image,
isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
renderGraph->AddPrimitive(&m_cachedPrimitive, image,
isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
}
+18 -24
View File
@@ -557,7 +557,7 @@ void UiMaskComponent::CreateOrResizeRenderTarget(const AZ::Vector2& pixelAligned
m_viewportTopLeft = pixelAlignedTopLeft;
m_viewportSize = renderTargetSize;
// LYSHINE_ATOM_TODO: optimize by reusing/resizing targets
// [LYSHINE_ATOM_TODO][GHI #6271] Optimize by reusing existing render targets
DestroyRenderTarget();
// Create a render target that this element and its children will be rendered to
@@ -721,8 +721,7 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph
// mask render target
{
// Start building the render to texture node in the render graph
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
lyRenderGraph->BeginRenderToTexture(maskAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor);
renderGraph->BeginRenderToTexture(maskAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor);
// Render the visual component for this element (if there is one) plus the child mask element (if there is one)
RenderMaskPrimitives(renderGraph, renderInterface, childMaskElementInterface, isInGame);
@@ -734,8 +733,7 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph
// content render target
{
// Start building the render to texture node for the content render target in the render graph
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
lyRenderGraph->BeginRenderToTexture(contentAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor);
renderGraph->BeginRenderToTexture(contentAttachmentImage, m_viewportTopLeft, m_viewportSize, clearColor);
// Render the "content" - the child elements excluding the child mask element (if any)
RenderContentPrimitives(renderGraph, elementInterface, childMaskElementInterface, numChildren, isInGame);
@@ -771,26 +769,22 @@ void UiMaskComponent::RenderUsingGradientMask(LyShine::IRenderGraph* renderGraph
// Add a primitive to do the alpha mask
{
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (lyRenderGraph)
{
// Set the texture and other render state required
AZ::Data::Instance<AZ::RPI::Image> contentImage = contentAttachmentImage;
AZ::Data::Instance<AZ::RPI::Image> maskImage = maskAttachmentImage;
bool isClampTextureMode = true;
bool isTextureSRGB = true;
bool isTexturePremultipliedAlpha = false;
LyShine::BlendMode blendMode = LyShine::BlendMode::Normal;
// Set the texture and other render state required
AZ::Data::Instance<AZ::RPI::Image> contentImage = contentAttachmentImage;
AZ::Data::Instance<AZ::RPI::Image> maskImage = maskAttachmentImage;
bool isClampTextureMode = true;
bool isTextureSRGB = true;
bool isTexturePremultipliedAlpha = false;
LyShine::BlendMode blendMode = LyShine::BlendMode::Normal;
// add a render node to render using the two render targets, one as an alpha mask of the other
lyRenderGraph->AddAlphaMaskPrimitiveAtom(&m_cachedPrimitive,
contentAttachmentImage,
maskAttachmentImage,
isClampTextureMode,
isTextureSRGB,
isTexturePremultipliedAlpha,
blendMode);
}
// add a render node to render using the two render targets, one as an alpha mask of the other
renderGraph->AddAlphaMaskPrimitive(&m_cachedPrimitive,
contentAttachmentImage,
maskAttachmentImage,
isClampTextureMode,
isTextureSRGB,
isTexturePremultipliedAlpha,
blendMode);
}
}
}
@@ -786,11 +786,7 @@ void UiParticleEmitterComponent::Render(LyShine::IRenderGraph* renderGraph)
AZ::Data::Instance<AZ::RPI::Image> image;
if (m_sprite)
{
CSprite* sprite = static_cast<CSprite*>(m_sprite); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (sprite)
{
image = sprite->GetImage();
}
image = m_sprite->GetImage();
}
bool isClampTextureMode = true;
@@ -844,11 +840,7 @@ void UiParticleEmitterComponent::Render(LyShine::IRenderGraph* renderGraph)
m_cachedPrimitive.m_numVertices = totalVerticesInserted;
m_cachedPrimitive.m_numIndices = totalParticlesInserted * indicesPerParticle;
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (lyRenderGraph)
{
lyRenderGraph->AddPrimitiveAtom(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode);
}
renderGraph->AddPrimitive(&m_cachedPrimitive, image, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, m_blendMode);
}
////////////////////////////////////////////////////////////////////////////////////////////////////
+3 -3
View File
@@ -96,13 +96,13 @@ AZ::RPI::ScenePtr UiRenderer::CreateScene(AZStd::shared_ptr<AZ::RPI::ViewportCon
AZ::RPI::SceneDescriptor sceneDesc;
sceneDesc.m_nameId = AZ::Name("UiRenderer");
AZ::RPI::ScenePtr atomScene = AZ::RPI::Scene::CreateScene(sceneDesc);
atomScene->EnableAllFeatureProcessors(); // LYSHINE_ATOM_TODO - have a UI pipeline and enable only needed fps
atomScene->EnableAllFeatureProcessors(); // [LYSHINE_ATOM_TODO][GHI #6272] Enable minimal feature processors
// Assign the new scene to the specified viewport context
viewportContext->SetRenderScene(atomScene);
// Create a render pipeline and add it to the scene
AZStd::string pipelineAssetPath = "passes/MainRenderPipeline.azasset"; // LYSHINE_ATOM_TODO - make and use a UI pipeline
AZStd::string pipelineAssetPath = "passes/MainRenderPipeline.azasset"; // [LYSHINE_ATOM_TODO][GHI #6272] Use a custom UI pipeline
AZ::Data::Asset<AZ::RPI::AnyAsset> pipelineAsset = AZ::RPI::AssetUtils::LoadAssetByProductPath<AZ::RPI::AnyAsset>(pipelineAssetPath.c_str(), AZ::RPI::AssetUtils::TraceLevel::Error);
AZStd::shared_ptr<AZ::RPI::WindowContext> windowContext = viewportContext->GetWindowContext();
auto renderPipeline = AZ::RPI::RenderPipeline::CreateRenderPipelineForWindow(pipelineAsset, *windowContext.get());
@@ -436,7 +436,7 @@ void UiRenderer::DebugDisplayTextureData(int recordingOption)
{
if (recordingOption > 0)
{
#ifdef LYSHINE_ATOM_TODO // Convert debug to use Atom images
#ifdef LYSHINE_ATOM_TODO // [GHI #3568] Support canvas debug display with Atom
// compute the total area of all the textures, also create a vector that we can sort by area
AZStd::vector<ITexture*> textures;
int totalArea = 0;
+1 -1
View File
@@ -179,6 +179,6 @@ protected: // attributes
#ifndef _RELEASE
int m_debugTextureDataRecordLevel = 0;
AZStd::unordered_set<ITexture*> m_texturesUsedInFrame; // LYSHINE_ATOM_TODO - convert to RPI::Image
AZStd::unordered_set<ITexture*> m_texturesUsedInFrame; // [LYN-7857] - Support debug display with Atom
#endif
};
+6 -18
View File
@@ -1843,11 +1843,7 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph)
LyShine::UiPrimitive* primitive = renderGraph->GetDynamicQuadPrimitive(rect.pt, packedColor);
primitive->m_next = nullptr;
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (lyRenderGraph)
{
lyRenderGraph->AddPrimitiveAtom(primitive, systemImage, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
renderGraph->AddPrimitive(primitive, systemImage, isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
}
@@ -1869,12 +1865,8 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph)
}
bool isClampTextureMode = true;
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (lyRenderGraph)
{
lyRenderGraph->AddPrimitiveAtom(&batch->m_cachedPrimitive, texture,
isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
renderGraph->AddPrimitive(&batch->m_cachedPrimitive, texture,
isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
}
@@ -1884,7 +1876,7 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph)
for (RenderCacheBatch* batch : m_renderCache.m_batches)
{
AZ::FFont* font = static_cast<AZ::FFont*>(batch->m_font); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
AZ::FFont* font = static_cast<AZ::FFont*>(batch->m_font); // LYSHINE_ATOM_TODO - move IFont.h out of CryCommon/engine code
AZ::Data::Instance<AZ::RPI::Image> fontImage = font->GetFontImage();
if (fontImage)
{
@@ -1907,12 +1899,8 @@ void UiTextComponent::Render(LyShine::IRenderGraph* renderGraph)
// because there is no padding on the left of the glyphs.
bool isClampTextureMode = false;
LyShine::RenderGraph* lyRenderGraph = static_cast<LyShine::RenderGraph*>(renderGraph); // LYSHINE_ATOM_TODO - find a different solution from downcasting - GHI #3570
if (lyRenderGraph)
{
lyRenderGraph->AddPrimitiveAtom(&batch->m_cachedPrimitive, fontImage,
isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
renderGraph->AddPrimitive(&batch->m_cachedPrimitive, fontImage,
isClampTextureMode, isTextureSRGB, isTexturePremultipliedAlpha, blendMode);
}
}
}
+1 -1
View File
@@ -50,7 +50,7 @@ namespace UnitTest
};
#ifdef LYSHINE_ATOM_TODO // [LYN-3359] - render target support using Atom
#ifdef LYSHINE_ATOM_TODO // [GHI #6270] Support RTT using Atom
TEST_F(LyShineSpriteTest, Sprite_CanAcquireRenderTarget)
{
// initialize to create the static sprite cache
@@ -74,7 +74,7 @@ namespace LyShineExamples
////////////////////////////////////////////////////////////////////////////////////////////////////
void UiCustomImageComponent::Render([[maybe_unused]] LyShine::IRenderGraph* renderGraph)
{
#ifdef LYSHINE_ATOM_TODO // [LYN-3635] convert to use Atom
#ifdef LYSHINE_ATOM_TODO // [GHI #3568] Convert draws to use Atom
// get fade value (tracked by UiRenderer) and compute the desired alpha for the image
float fade = renderGraph->GetAlphaFade();
float desiredAlpha = m_overrideAlpha * fade;