From da529edfb571d0f394874b76e94f5149d4aae5d0 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 21 Jun 2021 20:54:57 -0700 Subject: [PATCH 01/13] Fix ImGui not rendering correctly at resolutions greater than 1080p Signed-off-by: nvsickle --- Gems/ImGui/Code/Source/ImGuiManager.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/ImGui/Code/Source/ImGuiManager.h b/Gems/ImGui/Code/Source/ImGuiManager.h index acd8d7cea4..0df1b25b40 100644 --- a/Gems/ImGui/Code/Source/ImGuiManager.h +++ b/Gems/ImGui/Code/Source/ImGuiManager.h @@ -82,7 +82,7 @@ namespace ImGui DisplayState m_editorWindowState = DisplayState::Hidden; // ImGui Resolution Settings - ImGuiResolutionMode m_resolutionMode = ImGuiResolutionMode::MatchToMaxRenderResolution; + ImGuiResolutionMode m_resolutionMode = ImGuiResolutionMode::MatchRenderResolution; ImVec2 m_renderResolution = ImVec2(1920.0f, 1080.0f); ImVec2 m_lastRenderResolution; AzFramework::WindowSize m_windowSize = AzFramework::WindowSize(1920, 1080); From 6b76eceb1f665aee7a7649369229b8f7a80ff6b8 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 21 Jun 2021 20:56:40 -0700 Subject: [PATCH 02/13] Add GetDpiScaleFactor to native window API -This includes implementations of the API for the Editor and Windows, all other platforms will have a 1.0 scale for now Signed-off-by: nvsickle --- Code/Editor/RenderViewport.h | 1 + .../AzFramework/Application/Application.cpp | 2 ++ .../AzFramework/Windowing/NativeWindow.cpp | 11 +++++++ .../AzFramework/Windowing/NativeWindow.h | 2 ++ .../AzFramework/Windowing/WindowBus.h | 8 +++++ .../Windowing/NativeWindow_Windows.cpp | 32 ++++++++++++++++++- .../Include/Atom/RPI.Public/ViewportContext.h | 11 ++++++- .../Source/RPI.Public/ViewportContext.cpp | 15 +++++++++ .../Viewport/RenderViewportWidget.h | 1 + .../Source/Viewport/RenderViewportWidget.cpp | 5 +++ 10 files changed, 86 insertions(+), 2 deletions(-) diff --git a/Code/Editor/RenderViewport.h b/Code/Editor/RenderViewport.h index 1764028dd6..2a67e1bbc6 100644 --- a/Code/Editor/RenderViewport.h +++ b/Code/Editor/RenderViewport.h @@ -219,6 +219,7 @@ public: void SetFullScreenState(bool fullScreenState) override; bool CanToggleFullScreenState() const override; void ToggleFullScreenState() override; + float GetDpiScaleFactor() const override { return 1.0f; }; void ConnectViewportInteractionRequestBus(); void DisconnectViewportInteractionRequestBus(); diff --git a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp index 07f4865863..81c5a86cda 100644 --- a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp +++ b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp @@ -731,10 +731,12 @@ namespace AzFramework bool Application::IsPrefabSystemEnabled() const { bool value = true; + /* if (auto* registry = AZ::SettingsRegistry::Get()) { registry->Get(value, ApplicationInternal::s_prefabSystemKey); } + */ return value; } diff --git a/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.cpp b/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.cpp index b92d8dc3bc..3e7d67888f 100644 --- a/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.cpp +++ b/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.cpp @@ -116,6 +116,11 @@ namespace AzFramework SetFullScreenState(!GetFullScreenState()); } + float NativeWindow::GetDpiScaleFactor() const + { + return m_pimpl->GetDpiScaleFactor(); + } + /*static*/ bool NativeWindow::GetFullScreenStateOfDefaultWindow() { NativeWindowHandle defaultWindowHandle = nullptr; @@ -228,4 +233,10 @@ namespace AzFramework return false; } + float NativeWindow::Implementation::GetDpiScaleFactor() const + { + // For platforms that aren't DPI-aware, we simply return a 1.0 ratio for no scaling + return 1.0f; + } + } // namespace AzFramework diff --git a/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.h b/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.h index 0b53b5b31c..2d5a897146 100644 --- a/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.h +++ b/Code/Framework/AzFramework/AzFramework/Windowing/NativeWindow.h @@ -128,6 +128,7 @@ namespace AzFramework void SetFullScreenState(bool fullScreenState) override; bool CanToggleFullScreenState() const override; void ToggleFullScreenState() override; + float GetDpiScaleFactor() const override; //! Get the full screen state of the default window. //! \return True if the default window is currently in full screen, false otherwise. @@ -169,6 +170,7 @@ namespace AzFramework virtual bool GetFullScreenState() const; virtual void SetFullScreenState(bool fullScreenState); virtual bool CanToggleFullScreenState() const; + virtual float GetDpiScaleFactor() const; protected: uint32_t m_width = 0; diff --git a/Code/Framework/AzFramework/AzFramework/Windowing/WindowBus.h b/Code/Framework/AzFramework/AzFramework/Windowing/WindowBus.h index 959d7cc07b..8627e06ec8 100644 --- a/Code/Framework/AzFramework/AzFramework/Windowing/WindowBus.h +++ b/Code/Framework/AzFramework/AzFramework/Windowing/WindowBus.h @@ -68,6 +68,11 @@ namespace AzFramework //! Toggle the full screen state of the window. virtual void ToggleFullScreenState() = 0; + + //! Returns a scalar multiplier representing how dots-per-inch this window has, compared + //! to a "standard" value of 96, the default for Windows in a DPI unaware setting. This can + //! be used to scale user interface elements to ensure legibility on high density displays. + virtual float GetDpiScaleFactor() const = 0; }; using WindowRequestBus = AZ::EBus; @@ -87,6 +92,9 @@ namespace AzFramework //! This is called once when the window is Activated and also called if the user resizes the window. virtual void OnWindowResized(uint32_t width, uint32_t height) { AZ_UNUSED(width); AZ_UNUSED(height); }; + //! This is called if the window's underyling DPI scaling factor changes. + virtual void OnDpiScaleFactorChanged(float dpiScaleFactor) { AZ_UNUSED(dpiScaleFactor); } + //! This is called when the window is deactivated from code or if the user closes the window. virtual void OnWindowClosed() {}; }; diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp index 44a3757aea..6f9bf2cf1e 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp @@ -17,7 +17,7 @@ namespace AzFramework { public: AZ_CLASS_ALLOCATOR(NativeWindowImpl_Win32, AZ::SystemAllocator, 0); - NativeWindowImpl_Win32() = default; + NativeWindowImpl_Win32(); ~NativeWindowImpl_Win32() override; // NativeWindow::Implementation overrides... @@ -33,6 +33,7 @@ namespace AzFramework bool GetFullScreenState() const override; void SetFullScreenState(bool fullScreenState) override; bool CanToggleFullScreenState() const override { return true; } + float GetDpiScaleFactor() const override; private: static DWORD ConvertToWin32WindowStyleMask(const WindowStyleMasks& styleMasks); @@ -49,6 +50,9 @@ namespace AzFramework RECT m_windowRectToRestoreOnFullScreenExit; //!< The position and size of the window to restore when exiting full screen. UINT m_windowStyleToRestoreOnFullScreenExit; //!< The style(s) of the window to restore when exiting full screen. bool m_isInBorderlessWindowFullScreenState = false; //!< Was a borderless window used to enter full screen state? + + using GetDpiForWindowType = UINT(HWND hwnd); + GetDpiForWindowType* m_getDpiFunction = nullptr; }; const char* NativeWindowImpl_Win32::s_defaultClassName = "O3DEWin32Class"; @@ -58,6 +62,16 @@ namespace AzFramework return aznew NativeWindowImpl_Win32(); } + NativeWindowImpl_Win32::NativeWindowImpl_Win32() + { + // Attempt to load GetDpiForWindow from user32 at runtime, available on Windows 10+ versions >= 1607 + auto user32module = LoadLibraryA("user32.dll"); + if (user32module) + { + m_getDpiFunction = reinterpret_cast(GetProcAddress(user32module, "GetDpiForWindow")); + } + } + NativeWindowImpl_Win32::~NativeWindowImpl_Win32() { DestroyWindow(m_win32Handle); @@ -237,6 +251,11 @@ namespace AzFramework // Send all other WM_SYSKEYDOWN messages to the default WndProc. break; } + case WM_DPICHANGED: + { + const float newScaleFactor = nativeWindowImpl->GetDpiScaleFactor(); + WindowNotificationBus::Event(nativeWindowImpl->GetWindowHandle(), &WindowNotificationBus::Events::OnDpiScaleFactorChanged, newScaleFactor); + } default: return DefWindowProc(hWnd, message, wParam, lParam); break; @@ -330,6 +349,17 @@ namespace AzFramework } } + float NativeWindowImpl_Win32::GetDpiScaleFactor() const + { + constexpr UINT defaultDotsPerInch = 96; + UINT dotsPerInch = defaultDotsPerInch; + if (m_getDpiFunction) + { + dotsPerInch = m_getDpiFunction(m_win32Handle); + } + return aznumeric_cast(dotsPerInch) / aznumeric_cast(defaultDotsPerInch); + } + void NativeWindowImpl_Win32::EnterBorderlessWindowFullScreen() { if (m_isInBorderlessWindowFullScreenState) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h index 982ef498a0..17e6714132 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h @@ -65,8 +65,14 @@ namespace AZ ConstViewPtr GetDefaultView() const; //! Gets the current size of the viewport. + //! This value is cached and updated on-demand, so may be performantly queried. AzFramework::WindowSize GetViewportSize() const; + //! Gets the screen DPI scaling factor. + //! This value is cached and updated on-demand, so may be performantly queried. + //! \see AzFramework::WindowRequests::GetDpiScaleFactor + float GetDpiScalingFactor() const; + // SceneNotificationBus interface //! Ensures our default view remains set when our scene's render pipelines are modified. void OnRenderPipelineAdded(RenderPipelinePtr pipeline) override; @@ -76,8 +82,10 @@ namespace AZ void OnBeginPrepareRender() override; //WindowNotificationBus interface - //! Used to fire a notification when our window resizes + //! Used to fire a notification when our window resizes. void OnWindowResized(uint32_t width, uint32_t height) override; + //! Used to fire a notification when our window DPI changes. + void OnDpiScaleFactorChanged(float dpiScaleFactor) override; using SizeChangedEvent = AZ::Event; //! Notifies consumers when the viewport size has changed. @@ -130,6 +138,7 @@ namespace AZ WindowContextSharedPtr m_windowContext; ViewPtr m_defaultView; AzFramework::WindowSize m_viewportSize; + float m_viewportDpiScaleFactor = 1.0f; SizeChangedEvent m_sizeChangedEvent; MatrixChangedEvent m_viewMatrixChangedEvent; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp index 23d5805c12..ae2a72ae89 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp @@ -10,6 +10,7 @@ #include #include #include +#include "..\..\Include\Atom\RPI.Public\ViewportContext.h" namespace AZ { @@ -28,6 +29,10 @@ namespace AZ m_viewportSize, nativeWindow, &AzFramework::WindowRequestBus::Events::GetClientAreaSize); + AzFramework::WindowRequestBus::EventResult( + m_viewportDpiScaleFactor, + nativeWindow, + &AzFramework::WindowRequestBus::Events::GetDpiScaleFactor); AzFramework::WindowNotificationBus::Handler::BusConnect(nativeWindow); AzFramework::ViewportRequestBus::Handler::BusConnect(id); @@ -148,6 +153,11 @@ namespace AZ return m_viewportSize; } + float ViewportContext::GetDpiScalingFactor() const + { + return m_viewportDpiScaleFactor; + } + void ViewportContext::ConnectSizeChangedHandler(SizeChangedEvent::Handler& handler) { handler.Connect(m_sizeChangedEvent); @@ -289,5 +299,10 @@ namespace AZ m_sizeChangedEvent.Signal(m_viewportSize); } } + + void ViewportContext::OnDpiScaleFactorChanged(float dpiScaleFactor) + { + m_viewportDpiScaleFactor = dpiScaleFactor; + } } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h index c649031280..10dcc6c5c9 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Include/AtomToolsFramework/Viewport/RenderViewportWidget.h @@ -113,6 +113,7 @@ namespace AtomToolsFramework void SetFullScreenState(bool fullScreenState) override; bool CanToggleFullScreenState() const override; void ToggleFullScreenState() override; + float GetDpiScaleFactor() const override; protected: // AzFramework::InputChannelEventListener ... diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp index 529652e1a9..b12996442a 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp @@ -540,4 +540,9 @@ namespace AtomToolsFramework { // The RenderViewportWidget does not currently support full screen. } + + float RenderViewportWidget::GetDpiScaleFactor() const + { + return aznumeric_cast(devicePixelRatioF()); + } } //namespace AtomToolsFramework From b328cdf11d5f4a705edafea88b10ecddc66f26ab Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 21 Jun 2021 20:57:23 -0700 Subject: [PATCH 03/13] Make the launcher's lack of DPI awareness on Windows explicit This will enable per-screen DPI awareness to be turned on later Signed-off-by: nvsickle --- Code/LauncherUnified/launcher_generator.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Code/LauncherUnified/launcher_generator.cmake b/Code/LauncherUnified/launcher_generator.cmake index 85976e1cb9..628b5fffac 100644 --- a/Code/LauncherUnified/launcher_generator.cmake +++ b/Code/LauncherUnified/launcher_generator.cmake @@ -122,6 +122,8 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC FOLDER ${project_name} ) + # After ensuring that we correctly support DPI scaling, this should be switched to "PerMonitor" + set_property(TARGET ${project_name}.GameLauncher APPEND PROPERTY VS_DPI_AWARE "OFF") if(LY_DEFAULT_PROJECT_PATH) set_property(TARGET ${project_name}.GameLauncher APPEND PROPERTY VS_DEBUGGER_COMMAND_ARGUMENTS "--project-path=\"${LY_DEFAULT_PROJECT_PATH}\"") endif() From 9e4d6a1d85ae86cd7b11831ae83db5f209080c9c Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 21 Jun 2021 20:58:00 -0700 Subject: [PATCH 04/13] Scale the viewport debug info overlay by the DPI scale factor Signed-off-by: nvsickle --- .../Code/Source/AtomViewportDisplayInfoSystemComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp index 5b14fbebb9..2a618518f0 100644 --- a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp +++ b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp @@ -157,7 +157,7 @@ namespace AZ::Render auto viewportSize = viewportContext->GetViewportSize(); m_drawParams.m_position = AZ::Vector3(viewportSize.m_width, 0.0f, 1.0f) + AZ::Vector3(r_topRightBorderPadding); m_drawParams.m_color = AZ::Colors::White; - m_drawParams.m_scale = AZ::Vector2(0.7f); + m_drawParams.m_scale = AZ::Vector2(0.7f * viewportContext->GetDpiScalingFactor()); m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right; m_drawParams.m_monospace = false; m_drawParams.m_depthTest = false; From 0c97888d0f54d142eb7c49134b703029f6ff37bf Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 21 Jun 2021 21:00:42 -0700 Subject: [PATCH 05/13] Revert accidental change Signed-off-by: nvsickle --- .../AzFramework/AzFramework/Application/Application.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp index 81c5a86cda..07f4865863 100644 --- a/Code/Framework/AzFramework/AzFramework/Application/Application.cpp +++ b/Code/Framework/AzFramework/AzFramework/Application/Application.cpp @@ -731,12 +731,10 @@ namespace AzFramework bool Application::IsPrefabSystemEnabled() const { bool value = true; - /* if (auto* registry = AZ::SettingsRegistry::Get()) { registry->Get(value, ApplicationInternal::s_prefabSystemKey); } - */ return value; } From dd20a598b25bb62132c126dabe9a14a056f8b685 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 21 Jun 2021 22:15:39 -0700 Subject: [PATCH 06/13] Add DPI scaling to IMGUI Signed-off-by: nvsickle --- .../Code/Include/Atom/RPI.Public/ViewportContext.h | 6 ++++++ .../Include/Atom/RPI.Public/ViewportContextBus.h | 4 +++- .../Atom/RPI.Public/ViewportContextManager.h | 1 + .../RPI/Code/Source/RPI.Public/ViewportContext.cpp | 6 ++++++ .../Source/RPI.Public/ViewportContextManager.cpp | 12 ++++++++++++ .../Code/Source/ImguiAtomSystemComponent.cpp | 12 +++++++++++- .../Code/Source/ImguiAtomSystemComponent.h | 1 + Gems/ImGui/Code/Include/ImGuiBus.h | 2 ++ Gems/ImGui/Code/Source/ImGuiManager.cpp | 14 ++++++++++++++ Gems/ImGui/Code/Source/ImGuiManager.h | 2 ++ 10 files changed, 58 insertions(+), 2 deletions(-) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h index 17e6714132..3840b2b75c 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h @@ -92,6 +92,11 @@ namespace AZ //! Alternatively, connect to ViewportContextNotificationsBus and listen to ViewportContextNotifications::OnViewportSizeChanged. void ConnectSizeChangedHandler(SizeChangedEvent::Handler& handler); + using ScalarChangedEvent = AZ::Event; + //! Notifies consumers when the viewport DPI scaling ratio has changed. + //! Alternatively, connect to ViewportContextNotificationsBus and listen to ViewportContextNotifications::OnViewportDpiScalingChanged. + void ConnectDpiScalingFactorChangedHandler(ScalarChangedEvent::Handler& handler); + using MatrixChangedEvent = AZ::Event; //! Notifies consumers when the view matrix has changed. void ConnectViewMatrixChangedHandler(MatrixChangedEvent::Handler& handler); @@ -141,6 +146,7 @@ namespace AZ float m_viewportDpiScaleFactor = 1.0f; SizeChangedEvent m_sizeChangedEvent; + ScalarChangedEvent m_dpiScalingFactorChangedEvent; MatrixChangedEvent m_viewMatrixChangedEvent; MatrixChangedEvent::Handler m_onViewMatrixChangedHandler; MatrixChangedEvent m_projectionMatrixChangedEvent; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContextBus.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContextBus.h index da0c850f3d..152c8cf2c1 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContextBus.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContextBus.h @@ -105,8 +105,10 @@ namespace AZ class ViewportContextNotifications { public: - //! Called when the underlying native window size changes for a given viewport context name. + //! Called when the underlying native window size changes for a given viewport context. virtual void OnViewportSizeChanged(AzFramework::WindowSize size){AZ_UNUSED(size);} + //! Called when the window DPI scaling changes for a given viewport context. + virtual void OnViewportDpiScalingChanged(float dpiScale){AZ_UNUSED(dpiScale);} //! Called when the active view for a given viewport context name changes. virtual void OnViewportDefaultViewChanged(AZ::RPI::ViewPtr view){AZ_UNUSED(view);} //! Called when the viewport is to be rendered. diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContextManager.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContextManager.h index 008565d178..e50525cff0 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContextManager.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContextManager.h @@ -51,6 +51,7 @@ namespace AZ { AZStd::weak_ptr context; ViewportContext::SizeChangedEvent::Handler sizeChangedHandler; + ViewportContext::ScalarChangedEvent::Handler dpiScalingChangedHandler; }; // ViewportContextManager is a singleton owned solely by RPISystem, which is tagged as a friend diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp index ae2a72ae89..a37d9f3c00 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp @@ -163,6 +163,11 @@ namespace AZ handler.Connect(m_sizeChangedEvent); } + void ViewportContext::ConnectDpiScalingFactorChangedHandler(ScalarChangedEvent::Handler& handler) + { + handler.Connect(m_dpiScalingFactorChangedEvent); + } + void ViewportContext::ConnectViewMatrixChangedHandler(MatrixChangedEvent::Handler& handler) { handler.Connect(m_viewMatrixChangedEvent); @@ -303,6 +308,7 @@ namespace AZ void ViewportContext::OnDpiScaleFactorChanged(float dpiScaleFactor) { m_viewportDpiScaleFactor = dpiScaleFactor; + m_dpiScalingFactorChangedEvent.Signal(dpiScaleFactor); } } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp index 552304557f..ebf45f36f7 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp @@ -62,9 +62,20 @@ namespace AZ } ViewportContextIdNotificationBus::Event(viewportId, &ViewportContextIdNotificationBus::Events::OnViewportSizeChanged, size); }; + auto onDpiScalingChanged = [this, viewportId](float dpiScalingFactor) + { + // Ensure we emit OnViewportDpiScalingChanged with the correct name. + auto viewportContext = this->GetViewportContextById(viewportId); + if (viewportContext) + { + ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportDpiScalingChanged, dpiScalingFactor); + } + ViewportContextIdNotificationBus::Event(viewportId, &ViewportContextIdNotificationBus::Events::OnViewportDpiScalingChanged, dpiScalingFactor); + }; viewportContext->m_name = contextName; viewportData.sizeChangedHandler = ViewportContext::SizeChangedEvent::Handler(onSizeChanged); viewportContext->ConnectSizeChangedHandler(viewportData.sizeChangedHandler); + viewportContext->ConnectDpiScalingFactorChangedHandler(viewportData.dpiScalingChangedHandler); ViewPtrStack& associatedViews = GetOrCreateViewStackForContext(contextName); viewportContext->SetDefaultView(associatedViews.back()); onSizeChanged(viewportContext->GetViewportSize()); @@ -176,6 +187,7 @@ namespace AZ UpdateViewForContext(newContextName); // Ensure anyone listening on per-name viewport size updates gets notified. ViewportContextNotificationBus::Event(newContextName, &ViewportContextNotificationBus::Events::OnViewportSizeChanged, viewportContext->GetViewportSize()); + ViewportContextNotificationBus::Event(newContextName, &ViewportContextNotificationBus::Events::OnViewportDpiScalingChanged, viewportContext->GetDpiScalingFactor()); } void ViewportContextManager::EnumerateViewportContexts(AZStd::function visitorFunction) diff --git a/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp b/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp index fd41ff45a5..d2c4748670 100644 --- a/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp +++ b/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp @@ -105,10 +105,20 @@ namespace AZ // Let our ImguiAtomSystemComponent know once we successfully connect and update the viewport size. if (!m_initialized) { + auto atomViewportRequests = AZ::Interface::Get(); + auto defaultViewportContext = atomViewportRequests->GetDefaultViewportContext(); + OnViewportDpiScalingChanged(defaultViewportContext->GetDpiScalingFactor()); m_initialized = true; } }); -#endif +#endif //define(IMGUI_ENABLED) + } + + void ImguiAtomSystemComponent::OnViewportDpiScalingChanged(float dpiScale) + { +#if defined(IMGUI_ENABLED) + ImGui::ImGuiManagerBus::Broadcast(&ImGui::ImGuiManagerBus::Events::SetDpiScalingFactor, dpiScale); +#endif //define(IMGUI_ENABLED) } } } diff --git a/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.h b/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.h index e487c9a39a..a0ff1a5dd9 100644 --- a/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.h +++ b/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.h @@ -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; diff --git a/Gems/ImGui/Code/Include/ImGuiBus.h b/Gems/ImGui/Code/Include/ImGuiBus.h index cee9f3882d..ea7fe1631e 100644 --- a/Gems/ImGui/Code/Include/ImGuiBus.h +++ b/Gems/ImGui/Code/Include/ImGuiBus.h @@ -86,6 +86,8 @@ namespace ImGui virtual void SetImGuiRenderResolution(const ImVec2& res) = 0; virtual void OverrideRenderWindowSize(uint32_t width, uint32_t height) = 0; virtual void RestoreRenderWindowSizeToDefault() = 0; + virtual void SetDpiScalingFactor(float dpiScalingFactor) = 0; + virtual float GetDpiScalingFactor() const = 0; virtual void Render() = 0; }; diff --git a/Gems/ImGui/Code/Source/ImGuiManager.cpp b/Gems/ImGui/Code/Source/ImGuiManager.cpp index 7e936bb1f9..42c8d3929c 100644 --- a/Gems/ImGui/Code/Source/ImGuiManager.cpp +++ b/Gems/ImGui/Code/Source/ImGuiManager.cpp @@ -277,6 +277,20 @@ void ImGui::ImGuiManager::RestoreRenderWindowSizeToDefault() InitWindowSize(); } +void ImGui::ImGuiManager::SetDpiScalingFactor(float dpiScalingFactor) +{ + ImGuiIO& io = ImGui::GetIO(); + // Set the global font scale to size our UI to the scaling factor + // Note: Currently we use the default, 13px fixed-size IMGUI font, so this can get somewhat blurry + io.FontGlobalScale = dpiScalingFactor; +} + +float ImGui::ImGuiManager::GetDpiScalingFactor() const +{ + ImGuiIO& io = ImGui::GetIO(); + return io.FontGlobalScale; +} + void ImGuiManager::Render() { if (m_clientMenuBarState == DisplayState::Hidden && m_editorWindowState == DisplayState::Hidden) diff --git a/Gems/ImGui/Code/Source/ImGuiManager.h b/Gems/ImGui/Code/Source/ImGuiManager.h index 0df1b25b40..1509f27c57 100644 --- a/Gems/ImGui/Code/Source/ImGuiManager.h +++ b/Gems/ImGui/Code/Source/ImGuiManager.h @@ -57,6 +57,8 @@ namespace ImGui void SetImGuiRenderResolution(const ImVec2& res) override { m_renderResolution = res; } void OverrideRenderWindowSize(uint32_t width, uint32_t height) override; void RestoreRenderWindowSizeToDefault() override; + void SetDpiScalingFactor(float dpiScalingFactor) override; + float GetDpiScalingFactor() const override; void Render() override; // -- ImGuiManagerBus Interface ------------------------------------------------------------------- From 21dbe8b48fab1bc212363adff4edcd8c0668818c Mon Sep 17 00:00:00 2001 From: nvsickle Date: Tue, 22 Jun 2021 10:35:47 -0700 Subject: [PATCH 07/13] Address review feedback Signed-off-by: nvsickle --- .../AzFramework/AzFramework/Windowing/WindowBus.h | 2 +- .../AzFramework/Windowing/NativeWindow_Windows.cpp | 4 ++-- .../RPI/Code/Include/Atom/RPI.Public/ViewportContext.h | 10 +++++----- .../RPI/Code/Source/RPI.Public/ViewportContext.cpp | 1 - .../Code/Source/RPI.Public/ViewportContextManager.cpp | 4 ++-- .../Source/AtomViewportDisplayInfoSystemComponent.cpp | 2 +- .../Source/AtomViewportDisplayInfoSystemComponent.h | 2 ++ .../ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp | 5 +++-- 8 files changed, 16 insertions(+), 14 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Windowing/WindowBus.h b/Code/Framework/AzFramework/AzFramework/Windowing/WindowBus.h index 8627e06ec8..f21993b80a 100644 --- a/Code/Framework/AzFramework/AzFramework/Windowing/WindowBus.h +++ b/Code/Framework/AzFramework/AzFramework/Windowing/WindowBus.h @@ -69,7 +69,7 @@ namespace AzFramework //! Toggle the full screen state of the window. virtual void ToggleFullScreenState() = 0; - //! Returns a scalar multiplier representing how dots-per-inch this window has, compared + //! Returns a scalar multiplier representing how many dots-per-inch this window has, compared //! to a "standard" value of 96, the default for Windows in a DPI unaware setting. This can //! be used to scale user interface elements to ensure legibility on high density displays. virtual float GetDpiScaleFactor() const = 0; diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp index 6f9bf2cf1e..8d3a3e53f0 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp @@ -65,8 +65,7 @@ namespace AzFramework NativeWindowImpl_Win32::NativeWindowImpl_Win32() { // Attempt to load GetDpiForWindow from user32 at runtime, available on Windows 10+ versions >= 1607 - auto user32module = LoadLibraryA("user32.dll"); - if (user32module) + if (auto user32module = LoadLibraryA("user32.dll")) { m_getDpiFunction = reinterpret_cast(GetProcAddress(user32module, "GetDpiForWindow")); } @@ -255,6 +254,7 @@ namespace AzFramework { const float newScaleFactor = nativeWindowImpl->GetDpiScaleFactor(); WindowNotificationBus::Event(nativeWindowImpl->GetWindowHandle(), &WindowNotificationBus::Events::OnDpiScaleFactorChanged, newScaleFactor); + break; } default: return DefWindowProc(hWnd, message, wParam, lParam); diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h index 3840b2b75c..92e50be75e 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/ViewportContext.h @@ -65,15 +65,15 @@ namespace AZ ConstViewPtr GetDefaultView() const; //! Gets the current size of the viewport. - //! This value is cached and updated on-demand, so may be performantly queried. + //! This value is cached and updated on-demand, so may be efficiently queried. AzFramework::WindowSize GetViewportSize() const; //! Gets the screen DPI scaling factor. - //! This value is cached and updated on-demand, so may be performantly queried. + //! This value is cached and updated on-demand, so may be efficiently queried. //! \see AzFramework::WindowRequests::GetDpiScaleFactor float GetDpiScalingFactor() const; - // SceneNotificationBus interface + // SceneNotificationBus interface overrides... //! Ensures our default view remains set when our scene's render pipelines are modified. void OnRenderPipelineAdded(RenderPipelinePtr pipeline) override; //! Ensures our default view remains set when our scene's render pipelines are modified. @@ -81,7 +81,7 @@ namespace AZ //! OnBeginPrepareRender is forwarded to our RenderTick notification to allow subscribers to do rendering. void OnBeginPrepareRender() override; - //WindowNotificationBus interface + // WindowNotificationBus interface overrides... //! Used to fire a notification when our window resizes. void OnWindowResized(uint32_t width, uint32_t height) override; //! Used to fire a notification when our window DPI changes. @@ -119,7 +119,7 @@ namespace AZ //! Notifies consumers when this ViewportContext is about to be destroyed. void ConnectAboutToBeDestroyedHandler(ViewportIdEvent::Handler& handler); - // ViewportRequestBus interface + // ViewportRequestBus interface overrides... //! Gets the current camera's view matrix. const AZ::Matrix4x4& GetCameraViewMatrix() const override; //! Sets the current camera's view matrix. diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp index a37d9f3c00..eacdbe0293 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp @@ -10,7 +10,6 @@ #include #include #include -#include "..\..\Include\Atom\RPI.Public\ViewportContext.h" namespace AZ { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp index ebf45f36f7..2d9e1c586a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp @@ -55,7 +55,7 @@ namespace AZ auto onSizeChanged = [this, viewportId](AzFramework::WindowSize size) { // Ensure we emit OnViewportSizeChanged with the correct name. - auto viewportContext = this->GetViewportContextById(viewportId); + auto viewportContext = GetViewportContextById(viewportId); if (viewportContext) { ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportSizeChanged, size); @@ -65,7 +65,7 @@ namespace AZ auto onDpiScalingChanged = [this, viewportId](float dpiScalingFactor) { // Ensure we emit OnViewportDpiScalingChanged with the correct name. - auto viewportContext = this->GetViewportContextById(viewportId); + auto viewportContext = GetViewportContextById(viewportId); if (viewportContext) { ViewportContextNotificationBus::Event(viewportContext->GetName(), &ViewportContextNotificationBus::Events::OnViewportDpiScalingChanged, dpiScalingFactor); diff --git a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp index 2a618518f0..9fba4b9c09 100644 --- a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp +++ b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp @@ -157,7 +157,7 @@ namespace AZ::Render auto viewportSize = viewportContext->GetViewportSize(); m_drawParams.m_position = AZ::Vector3(viewportSize.m_width, 0.0f, 1.0f) + AZ::Vector3(r_topRightBorderPadding); m_drawParams.m_color = AZ::Colors::White; - m_drawParams.m_scale = AZ::Vector2(0.7f * viewportContext->GetDpiScalingFactor()); + 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; diff --git a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.h b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.h index 13f42dd638..cec6cd958c 100644 --- a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.h +++ b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.h @@ -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; diff --git a/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp b/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp index d2c4748670..843f30fced 100644 --- a/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp +++ b/Gems/AtomLyIntegration/ImguiAtom/Code/Source/ImguiAtomSystemComponent.cpp @@ -50,7 +50,8 @@ namespace AZ { ImGui::OtherActiveImGuiRequestBus::Handler::BusConnect(); - auto atomViewportRequests = AZ::Interface::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,7 +106,7 @@ namespace AZ // Let our ImguiAtomSystemComponent know once we successfully connect and update the viewport size. if (!m_initialized) { - auto atomViewportRequests = AZ::Interface::Get(); + auto atomViewportRequests = AZ::RPI::ViewportContextRequests::Get(); auto defaultViewportContext = atomViewportRequests->GetDefaultViewportContext(); OnViewportDpiScalingChanged(defaultViewportContext->GetDpiScalingFactor()); m_initialized = true; From 2fefa809376d57539c511761707cff41f8d2a570 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Tue, 22 Jun 2021 11:41:25 -0700 Subject: [PATCH 08/13] Use AZ::DynamicModuleHandle Signed-off-by: nvsickle --- .../Windows/AzFramework/Windowing/NativeWindow_Windows.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp index 8d3a3e53f0..470594853c 100644 --- a/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp +++ b/Code/Framework/AzFramework/Platform/Windows/AzFramework/Windowing/NativeWindow_Windows.cpp @@ -8,6 +8,7 @@ #include #include +#include #include namespace AzFramework @@ -65,9 +66,9 @@ namespace AzFramework NativeWindowImpl_Win32::NativeWindowImpl_Win32() { // Attempt to load GetDpiForWindow from user32 at runtime, available on Windows 10+ versions >= 1607 - if (auto user32module = LoadLibraryA("user32.dll")) + if (auto user32module = AZ::DynamicModuleHandle::Create("user32"); user32module->Load(false)) { - m_getDpiFunction = reinterpret_cast(GetProcAddress(user32module, "GetDpiForWindow")); + m_getDpiFunction = user32module->GetFunction("GetDpiForWindow"); } } From 0b3dab1cf845c6f1ffb2a0f93650d4f072a145ea Mon Sep 17 00:00:00 2001 From: nvsickle Date: Mon, 28 Jun 2021 10:56:14 -0700 Subject: [PATCH 09/13] Use DPI scaling for viewport info padding Signed-off-by: nvsickle --- .../Code/Source/AtomViewportDisplayInfoSystemComponent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp index 9fba4b9c09..af9fd7fdd8 100644 --- a/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp +++ b/Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp @@ -155,7 +155,7 @@ 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(BaseFontSize * viewportContext->GetDpiScalingFactor()); m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right; From 3ee15f1912f02e04205b6fd19c7f2b5b020a781d Mon Sep 17 00:00:00 2001 From: nvsickle Date: Wed, 7 Jul 2021 10:21:21 -0700 Subject: [PATCH 10/13] Try to get some actual log output out of this Signed-off-by: nvsickle --- Tools/LyTestTools/ly_test_tools/log/log_monitor.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Tools/LyTestTools/ly_test_tools/log/log_monitor.py b/Tools/LyTestTools/ly_test_tools/log/log_monitor.py index a2556fa41d..90e0a2280c 100755 --- a/Tools/LyTestTools/ly_test_tools/log/log_monitor.py +++ b/Tools/LyTestTools/ly_test_tools/log/log_monitor.py @@ -133,12 +133,12 @@ class LogMonitor(object): except AssertionError: # Raised by waiter when timeout is reached. logger.warning(f"Timeout of '{timeout}' seconds was reached, log lines may not have been found") # exception will be raised below by _validate_results with failure analysis - - logger.info("Python log output:\n" + self.py_log) - logger.info( - "Finished log monitoring for '{}' seconds, validating results.\n" - "expected_lines_not_found: {}\n unexpected_lines_found: {}".format( - timeout, self.expected_lines_not_found, self.unexpected_lines_found)) + finally: + logger.info("Python log output:\n" + self.py_log) + logger.info( + "Finished log monitoring for '{}' seconds, validating results.\n" + "expected_lines_not_found: {}\n unexpected_lines_found: {}".format( + timeout, self.expected_lines_not_found, self.unexpected_lines_found)) return self._validate_results(self.expected_lines_not_found, self.unexpected_lines_found, expected_lines, unexpected_lines) From 3549e5b946035aac91df705150191a28954af44a Mon Sep 17 00:00:00 2001 From: nvsickle Date: Wed, 7 Jul 2021 10:47:44 -0700 Subject: [PATCH 11/13] More fussing with logs Signed-off-by: nvsickle --- Tools/LyTestTools/ly_test_tools/log/log_monitor.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Tools/LyTestTools/ly_test_tools/log/log_monitor.py b/Tools/LyTestTools/ly_test_tools/log/log_monitor.py index 90e0a2280c..f4266aaace 100755 --- a/Tools/LyTestTools/ly_test_tools/log/log_monitor.py +++ b/Tools/LyTestTools/ly_test_tools/log/log_monitor.py @@ -265,12 +265,21 @@ class LogMonitor(object): self.unexpected_lines_found = unexpected_lines_found self.expected_lines_not_found = expected_lines_not_found + exception_info = None + # To avoid race conditions, we will check *before reading* # If in the mean time the file is closed, we will make sure we read everything by issuing an extra call # by returning the previous alive state process_runing = self.launcher.is_alive() for line in log: line = line[:-1] # remove /n - process_line(line) + try: + process_line(line) + except LogMonitorException as e: + if exception_info is not None: + exception_info = e.args + + if exception_info is not None: + raise LogMonitorException(*exception_info) return not process_runing # Will loop until the process ends From dee591921efd5eb424a116d2cbad7f4b2676d2fa Mon Sep 17 00:00:00 2001 From: nvsickle Date: Wed, 7 Jul 2021 11:47:37 -0700 Subject: [PATCH 12/13] Fix exception bubble-up Signed-off-by: nvsickle --- Tools/LyTestTools/ly_test_tools/log/log_monitor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tools/LyTestTools/ly_test_tools/log/log_monitor.py b/Tools/LyTestTools/ly_test_tools/log/log_monitor.py index f4266aaace..54d71b62c0 100755 --- a/Tools/LyTestTools/ly_test_tools/log/log_monitor.py +++ b/Tools/LyTestTools/ly_test_tools/log/log_monitor.py @@ -276,7 +276,7 @@ class LogMonitor(object): try: process_line(line) except LogMonitorException as e: - if exception_info is not None: + if exception_info is None: exception_info = e.args if exception_info is not None: From 14cab097c772cfd6008386ef4b08074a6f632c56 Mon Sep 17 00:00:00 2001 From: nvsickle Date: Wed, 7 Jul 2021 13:19:51 -0700 Subject: [PATCH 13/13] Fix DPI change callback not being wired up correctly. Signed-off-by: nvsickle --- Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp index 2d9e1c586a..606b5e5b8c 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp @@ -74,6 +74,7 @@ namespace AZ }; viewportContext->m_name = contextName; viewportData.sizeChangedHandler = ViewportContext::SizeChangedEvent::Handler(onSizeChanged); + viewportData.dpiScalingChangedHandler = ViewportContext::ScalarChangedEvent::Handler(onDpiScalingChanged); viewportContext->ConnectSizeChangedHandler(viewportData.sizeChangedHandler); viewportContext->ConnectDpiScalingFactorChangedHandler(viewportData.dpiScalingChangedHandler); ViewPtrStack& associatedViews = GetOrCreateViewStackForContext(contextName);