Merged stabilization/2106 -> development (resolved merge conflicts).
Signed-off-by: Chris Galvan <chgalvan@amazon.com>
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include <AzCore/std/containers/map.h>
|
||||
#include <AzCore/std/smart_ptr/weak_ptr.h>
|
||||
#include <AzCore/std/parallel/shared_mutex.h>
|
||||
#include <AzCore/Asset/AssetCommon.h>
|
||||
#include <map>
|
||||
|
||||
#include <AzFramework/Font/FontInterface.h>
|
||||
@@ -38,6 +39,7 @@ namespace AZ
|
||||
class AtomFont
|
||||
: public ICryFont
|
||||
, public AzFramework::FontQueryInterface
|
||||
, private Data::AssetBus::Handler
|
||||
{
|
||||
friend class FFont;
|
||||
|
||||
@@ -122,6 +124,9 @@ namespace AZ
|
||||
//! \param outputFullPath Full path to loaded font family, may need resolving with PathUtil::MakeGamePath.
|
||||
XmlNodeRef LoadFontFamilyXml(const char* fontFamilyName, string& outputDirectory, string& outputFullPath);
|
||||
|
||||
// Data::AssetBus::Handler overrides...
|
||||
void OnAssetReady(Data::Asset<Data::AssetData> asset) override;
|
||||
|
||||
private:
|
||||
AzFramework::ISceneSystem::SceneEvent::Handler m_sceneEventHandler;
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
#include <Atom/RPI.Public/RPIUtils.h>
|
||||
#include <Atom/RPI.Public/DynamicDraw/DynamicDrawInterface.h>
|
||||
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
|
||||
|
||||
// Static member definitions
|
||||
const AZ::AtomFont::GlyphSize AZ::AtomFont::defaultGlyphSize = AZ::AtomFont::GlyphSize(ICryFont::defaultGlyphSizeX, ICryFont::defaultGlyphSizeY);
|
||||
@@ -349,30 +350,18 @@ AZ::AtomFont::AtomFont(ISystem* system)
|
||||
#endif
|
||||
AZ::Interface<AzFramework::FontQueryInterface>::Register(this);
|
||||
|
||||
// register font per viewport dynamic draw context.
|
||||
// Queue a load for the font per viewport dynamic draw context shader, and wait for it to load
|
||||
static const char* shaderFilepath = "Shaders/SimpleTextured.azshader";
|
||||
AZ::AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(
|
||||
AZ::Name(AZ::AtomFontDynamicDrawContextName),
|
||||
[](RPI::Ptr<RPI::DynamicDrawContext> drawContext)
|
||||
{
|
||||
Data::Instance<RPI::Shader> shader = AZ::RPI::LoadShader(shaderFilepath);
|
||||
AZ::RPI::ShaderOptionList shaderOptions;
|
||||
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("false")));
|
||||
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("true")));
|
||||
drawContext->InitShaderWithVariant(shader, &shaderOptions);
|
||||
drawContext->InitVertexFormat(
|
||||
{
|
||||
{"POSITION", RHI::Format::R32G32B32_FLOAT},
|
||||
{"COLOR", RHI::Format::B8G8R8A8_UNORM},
|
||||
{"TEXCOORD0", RHI::Format::R32G32_FLOAT}
|
||||
});
|
||||
drawContext->EndInit();
|
||||
});
|
||||
Data::Asset<RPI::ShaderAsset> shaderAsset = RPI::AssetUtils::GetAssetByProductPath<RPI::ShaderAsset>(shaderFilepath, RPI::AssetUtils::TraceLevel::Assert);
|
||||
shaderAsset.QueueLoad();
|
||||
Data::AssetBus::Handler::BusConnect(shaderAsset.GetId());
|
||||
|
||||
}
|
||||
|
||||
AZ::AtomFont::~AtomFont()
|
||||
{
|
||||
Data::AssetBus::Handler::BusDisconnect();
|
||||
|
||||
AZ::Interface<AzFramework::FontQueryInterface>::Unregister(this);
|
||||
m_defaultFontDrawInterface = nullptr;
|
||||
|
||||
@@ -864,5 +853,36 @@ XmlNodeRef AZ::AtomFont::LoadFontFamilyXml(const char* fontFamilyName, string& o
|
||||
|
||||
return root;
|
||||
}
|
||||
|
||||
void AZ::AtomFont::OnAssetReady(Data::Asset<Data::AssetData> asset)
|
||||
{
|
||||
Data::Asset<RPI::ShaderAsset> shaderAsset = asset;
|
||||
|
||||
AZ::AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(
|
||||
AZ::Name(AZ::AtomFontDynamicDrawContextName),
|
||||
[shaderAsset](RPI::Ptr<RPI::DynamicDrawContext> drawContext)
|
||||
{
|
||||
AZ_Assert(shaderAsset->IsReady(), "Attempting to register the AtomFont"
|
||||
" dynamic draw context before the shader asset is loaded. The shader should be loaded first"
|
||||
" to avoid a blocking asset load and potential deadlock, since the DynamicDrawContext lambda"
|
||||
" will be executed during scene processing and there may be multiple scenes executing in parallel.");
|
||||
|
||||
Data::Instance<RPI::Shader> shader = RPI::Shader::FindOrCreate(shaderAsset);
|
||||
AZ::RPI::ShaderOptionList shaderOptions;
|
||||
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_useColorChannels"), AZ::Name("false")));
|
||||
shaderOptions.push_back(AZ::RPI::ShaderOption(AZ::Name("o_clamp"), AZ::Name("true")));
|
||||
drawContext->InitShaderWithVariant(shader, &shaderOptions);
|
||||
drawContext->InitVertexFormat(
|
||||
{
|
||||
{"POSITION", RHI::Format::R32G32B32_FLOAT},
|
||||
{"COLOR", RHI::Format::B8G8R8A8_UNORM},
|
||||
{"TEXCOORD0", RHI::Format::R32G32_FLOAT}
|
||||
});
|
||||
drawContext->EndInit();
|
||||
});
|
||||
|
||||
Data::AssetBus::Handler::BusDisconnect();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+29
-10
@@ -27,6 +27,7 @@
|
||||
#include <Atom/RPI.Public/Image/ImageSystemInterface.h>
|
||||
#include <Atom/RPI.Reflect/Image/StreamingImageAssetCreator.h>
|
||||
#include <Atom/RPI.Reflect/Image/ImageMipChainAssetCreator.h>
|
||||
#include <Atom/RPI.Reflect/Asset/AssetUtils.h>
|
||||
#include <Atom/RPI.Public/Image/StreamingImagePool.h>
|
||||
|
||||
#include <AtomBridge/PerViewportDynamicDrawInterface.h>
|
||||
@@ -87,6 +88,7 @@ namespace AZ::Render
|
||||
|
||||
void AtomViewportDisplayIconsSystemComponent::Deactivate()
|
||||
{
|
||||
Data::AssetBus::Handler::BusDisconnect();
|
||||
Bootstrap::NotificationBus::Handler::BusDisconnect();
|
||||
|
||||
auto perViewportDynamicDrawInterface = AtomBridge::PerViewportDynamicDraw::Get();
|
||||
@@ -338,15 +340,32 @@ namespace AZ::Render
|
||||
|
||||
void AtomViewportDisplayIconsSystemComponent::OnBootstrapSceneReady([[maybe_unused]]AZ::RPI::Scene* bootstrapScene)
|
||||
{
|
||||
AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(m_drawContextName, [](RPI::Ptr<RPI::DynamicDrawContext> drawContext)
|
||||
{
|
||||
auto shader = RPI::LoadShader(DrawContextShaderPath);
|
||||
drawContext->InitShader(shader);
|
||||
drawContext->InitVertexFormat(
|
||||
{{"POSITION", RHI::Format::R32G32B32_FLOAT},
|
||||
{"COLOR", RHI::Format::R8G8B8A8_UNORM},
|
||||
{"TEXCOORD", RHI::Format::R32G32_FLOAT}});
|
||||
drawContext->EndInit();
|
||||
});
|
||||
// Queue a load for the draw context shader, and wait for it to load
|
||||
Data::Asset<RPI::ShaderAsset> shaderAsset = RPI::AssetUtils::GetAssetByProductPath<RPI::ShaderAsset>(DrawContextShaderPath, RPI::AssetUtils::TraceLevel::Assert);
|
||||
shaderAsset.QueueLoad();
|
||||
Data::AssetBus::Handler::BusConnect(shaderAsset.GetId());
|
||||
}
|
||||
|
||||
void AtomViewportDisplayIconsSystemComponent::OnAssetReady(Data::Asset<Data::AssetData> asset)
|
||||
{
|
||||
// Once the shader is loaded, register it with the dynamic draw context
|
||||
Data::Asset<RPI::ShaderAsset> shaderAsset = asset;
|
||||
AtomBridge::PerViewportDynamicDraw::Get()->RegisterDynamicDrawContext(m_drawContextName, [shaderAsset](RPI::Ptr<RPI::DynamicDrawContext> drawContext)
|
||||
{
|
||||
AZ_Assert(shaderAsset->IsReady(), "Attempting to register the AtomViewportDisplayIconsSystemComponent"
|
||||
" dynamic draw context before the shader asset is loaded. The shader should be loaded first"
|
||||
" to avoid a blocking asset load and potential deadlock, since the DynamicDrawContext lambda"
|
||||
" will be executed during scene processing and there may be multiple scenes executing in parallel.");
|
||||
|
||||
Data::Instance<RPI::Shader> shader = RPI::Shader::FindOrCreate(shaderAsset);
|
||||
drawContext->InitShader(shader);
|
||||
drawContext->InitVertexFormat(
|
||||
{ {"POSITION", RHI::Format::R32G32B32_FLOAT},
|
||||
{"COLOR", RHI::Format::R8G8B8A8_UNORM},
|
||||
{"TEXCOORD", RHI::Format::R32G32_FLOAT} });
|
||||
drawContext->EndInit();
|
||||
});
|
||||
|
||||
Data::AssetBus::Handler::BusDisconnect();
|
||||
}
|
||||
} // namespace AZ::Render
|
||||
|
||||
+4
@@ -27,6 +27,7 @@ namespace AZ
|
||||
: public AZ::Component
|
||||
, public AzToolsFramework::EditorViewportIconDisplayInterface
|
||||
, public AZ::Render::Bootstrap::NotificationBus::Handler
|
||||
, private Data::AssetBus::Handler
|
||||
{
|
||||
public:
|
||||
AZ_COMPONENT(AtomViewportDisplayIconsSystemComponent, "{AEC1D3E1-1D9A-437A-B4C6-CFAEE620C160}");
|
||||
@@ -51,6 +52,9 @@ namespace AZ
|
||||
// AZ::Render::Bootstrap::NotificationBus::Handler overrides...
|
||||
void OnBootstrapSceneReady(AZ::RPI::Scene* bootstrapScene) override;
|
||||
|
||||
// Data::AssetBus::Handler overrides...
|
||||
void OnAssetReady(Data::Asset<Data::AssetData> asset) override;
|
||||
|
||||
private:
|
||||
static constexpr const char* DrawContextShaderPath = "Shaders/TexturedIcon.azshader";
|
||||
static constexpr QSize MinimumRenderedSvgSize = QSize(128, 128);
|
||||
|
||||
+2
-2
@@ -155,9 +155,9 @@ namespace AZ::Render
|
||||
|
||||
m_drawParams.m_drawViewportId = viewportContext->GetId();
|
||||
auto viewportSize = viewportContext->GetViewportSize();
|
||||
m_drawParams.m_position = AZ::Vector3(viewportSize.m_width, 0.0f, 1.0f) + AZ::Vector3(r_topRightBorderPadding);
|
||||
m_drawParams.m_position = AZ::Vector3(viewportSize.m_width, 0.0f, 1.0f) + AZ::Vector3(r_topRightBorderPadding) * viewportContext->GetDpiScalingFactor();
|
||||
m_drawParams.m_color = AZ::Colors::White;
|
||||
m_drawParams.m_scale = AZ::Vector2(0.7f);
|
||||
m_drawParams.m_scale = AZ::Vector2(BaseFontSize * viewportContext->GetDpiScalingFactor());
|
||||
m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right;
|
||||
m_drawParams.m_monospace = false;
|
||||
m_drawParams.m_depthTest = false;
|
||||
|
||||
+2
@@ -60,6 +60,8 @@ namespace AZ
|
||||
void DrawPassInfo();
|
||||
void DrawFramerate();
|
||||
|
||||
static constexpr float BaseFontSize = 0.7f;
|
||||
|
||||
AZStd::string m_rendererDescription;
|
||||
AzFramework::TextDrawParameters m_drawParams;
|
||||
AzFramework::FontDrawInterface* m_fontDrawInterface = nullptr;
|
||||
|
||||
+18
-2
@@ -263,7 +263,23 @@ namespace AZ
|
||||
|
||||
// Update the cached light type.
|
||||
m_lightType = m_controller.m_configuration.m_lightType;
|
||||
|
||||
// Check to see if the current photometric type is supported by the light type. If not, convert to lumens before deactivating.
|
||||
auto supportedPhotometricUnits = m_controller.m_configuration.GetValidPhotometricUnits();
|
||||
auto foundIt = AZStd::find_if(
|
||||
supportedPhotometricUnits.begin(),
|
||||
supportedPhotometricUnits.end(),
|
||||
[&](const Edit::EnumConstant<PhotometricUnit>& entry) -> bool
|
||||
{
|
||||
return AZStd::RemoveEnum<PhotometricUnit>::type(m_controller.m_configuration.m_intensityMode) == entry.m_value;
|
||||
}
|
||||
);
|
||||
|
||||
if (foundIt == supportedPhotometricUnits.end())
|
||||
{
|
||||
m_controller.ConvertToIntensityMode(PhotometricUnit::Lumen);
|
||||
}
|
||||
|
||||
// componets may be removed or added here, so deactivate now and reactivate the entity when everything is done shifting around.
|
||||
GetEntity()->Deactivate();
|
||||
|
||||
@@ -320,7 +336,7 @@ namespace AZ
|
||||
// Some light types don't require a shape, this is ok.
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
GetEntity()->Activate();
|
||||
|
||||
// Set more reasonable default values for certain shapes.
|
||||
@@ -333,7 +349,7 @@ namespace AZ
|
||||
LmbrCentral::DiskShapeComponentRequestBus::Event(GetEntityId(), &LmbrCentral::DiskShapeComponentRequests::SetRadius, 0.05f);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -134,6 +134,11 @@ namespace AZ
|
||||
// For lights that get their transform from the shape bus, force an OnShapeChanged to update the transform.
|
||||
OnShapeChanged(ShapeChangeReasons::TransformChanged);
|
||||
}
|
||||
else
|
||||
{
|
||||
// OnShapeChanged() already calls this for delegates with a shape bus
|
||||
HandleShapeChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -130,6 +130,12 @@ namespace AZ
|
||||
arguments.append(QString("--rhi=%1").arg(apiName.GetCStr()));
|
||||
}
|
||||
|
||||
AZ::IO::FixedMaxPathString projectPath(AZ::Utils::GetProjectPath());
|
||||
if (!projectPath.empty())
|
||||
{
|
||||
arguments.append(QString("--project-path=%1").arg(projectPath.c_str()));
|
||||
}
|
||||
|
||||
AtomToolsFramework::LaunchTool("MaterialEditor", ".exe", arguments);
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ namespace AZ
|
||||
Render::FrameCaptureRequestBus::BroadcastResult(
|
||||
startedCapture,
|
||||
&Render::FrameCaptureRequestBus::Events::CapturePassAttachmentWithCallback,
|
||||
m_context->GetData()->m_passHierarchy, AZStd::string("Output"), readbackCallback);
|
||||
m_context->GetData()->m_passHierarchy, AZStd::string("Output"), readbackCallback, RPI::PassAttachmentReadbackOption::Output);
|
||||
// Reset the capture flag if the capture request was successful. Otherwise try capture it again next tick.
|
||||
if (startedCapture)
|
||||
{
|
||||
|
||||
@@ -50,7 +50,8 @@ namespace AZ
|
||||
{
|
||||
ImGui::OtherActiveImGuiRequestBus::Handler::BusConnect();
|
||||
|
||||
auto atomViewportRequests = AZ::Interface<AZ::RPI::ViewportContextRequestsInterface>::Get();
|
||||
auto atomViewportRequests = AZ::RPI::ViewportContextRequests::Get();
|
||||
AZ_Assert(atomViewportRequests, "AtomViewportContextRequests interface not found!");
|
||||
const AZ::Name contextName = atomViewportRequests->GetDefaultViewportContextName();
|
||||
AZ::RPI::ViewportContextNotificationBus::Handler::BusConnect(contextName);
|
||||
|
||||
@@ -105,10 +106,20 @@ namespace AZ
|
||||
// Let our ImguiAtomSystemComponent know once we successfully connect and update the viewport size.
|
||||
if (!m_initialized)
|
||||
{
|
||||
auto atomViewportRequests = AZ::RPI::ViewportContextRequests::Get();
|
||||
auto defaultViewportContext = atomViewportRequests->GetDefaultViewportContext();
|
||||
OnViewportDpiScalingChanged(defaultViewportContext->GetDpiScalingFactor());
|
||||
m_initialized = true;
|
||||
}
|
||||
});
|
||||
#endif
|
||||
#endif //define(IMGUI_ENABLED)
|
||||
}
|
||||
|
||||
void ImguiAtomSystemComponent::OnViewportDpiScalingChanged([[maybe_unused]] float dpiScale)
|
||||
{
|
||||
#if defined(IMGUI_ENABLED)
|
||||
ImGui::ImGuiManagerBus::Broadcast(&ImGui::ImGuiManagerBus::Events::SetDpiScalingFactor, dpiScale);
|
||||
#endif //define(IMGUI_ENABLED)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ namespace AZ
|
||||
// ViewportContextNotificationBus overrides...
|
||||
void OnRenderTick() override;
|
||||
void OnViewportSizeChanged(AzFramework::WindowSize size) override;
|
||||
void OnViewportDpiScalingChanged(float dpiScale) override;
|
||||
|
||||
DebugConsole m_debugConsole;
|
||||
bool m_initialized = false;
|
||||
|
||||
Reference in New Issue
Block a user