Переглянути джерело

Render scale update related support and fixes (#136)

* Render scale update related support and fixes

Signed-off-by: moudgils <[email protected]>
moudgils 1 рік тому
батько
коміт
64edaebaf2

+ 13 - 1
Gems/Atom/Bootstrap/Code/Source/BootstrapSystemComponent.cpp

@@ -121,7 +121,19 @@ AZ_CVAR(uint32_t, r_width, 1920, nullptr, AZ::ConsoleFunctorFlags::DontReplicate
 AZ_CVAR(uint32_t, r_height, 1080, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Starting window height in pixels.");
 AZ_CVAR(uint32_t, r_fullscreen, false, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Starting fullscreen state.");
 AZ_CVAR(uint32_t, r_resolutionMode, 0, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "0: render resolution same as window client area size, 1: render resolution use the values specified by r_width and r_height");
-AZ_CVAR(float, r_renderScale, 1.0f, nullptr, AZ::ConsoleFunctorFlags::DontReplicate, "Scale to apply to the window resolution.");
+
+void cvar_r_renderScale_Changed(const float& newRenderScale)
+{
+    AZ_Error("AtomBootstrap", newRenderScale > 0, "RenderScale should be greater than 0");
+    if (newRenderScale > 0)
+    {
+        AzFramework::WindowSize newSize =
+            AzFramework::WindowSize(static_cast<uint32_t>(r_width * newRenderScale), static_cast<uint32_t>(r_height * newRenderScale));
+        AzFramework::WindowRequestBus::Broadcast(&AzFramework::WindowRequestBus::Events::SetEnableCustomizedResolution, true);
+        AzFramework::WindowRequestBus::Broadcast(&AzFramework::WindowRequestBus::Events::SetRenderResolution, newSize);
+    }
+}
+AZ_CVAR(float, r_renderScale, 1.0f, cvar_r_renderScale_Changed, AZ::ConsoleFunctorFlags::DontReplicate, "Scale to apply to the window resolution.");
 AZ_CVAR(AZ::CVarFixedString, r_antiAliasing, "", cvar_r_antiAliasing_Changed, AZ::ConsoleFunctorFlags::DontReplicate, "The anti-aliasing to be used for the current render pipeline. Available options: MSAA, TAA, SMAA");
 AZ_CVAR(uint16_t, r_multiSampleCount, 0, cvar_r_multiSample_Changed, AZ::ConsoleFunctorFlags::DontReplicate, "The multi-sample count to be used for the current render pipeline."); // 0 stands for unchanged, load the default setting from the pipeline itself
 

+ 19 - 2
Gems/AtomLyIntegration/AtomViewportDisplayInfo/Code/Source/AtomViewportDisplayInfoSystemComponent.cpp

@@ -163,8 +163,25 @@ namespace AZ::Render
         }
 
         m_drawParams.m_drawViewportId = viewportContext->GetId();
-        auto viewportSize = viewportContext->GetViewportSize();
-        m_drawParams.m_position = AZ::Vector3(static_cast<float>(viewportSize.m_width), 0.0f, 1.0f) + AZ::Vector3(r_topRightBorderPadding) * viewportContext->GetDpiScalingFactor();
+        
+        AZ::IConsole* console = AZ::Interface<AZ::IConsole>::Get();
+        uint32_t r_width, r_resolutionMode  = 0;
+        console->GetCvarValue("r_resolutionMode", r_resolutionMode);
+        
+        if (r_resolutionMode > 0u)
+        {
+            //This ensures the debug text is always attached to the top right when r_resolutionMode is enabled
+            console->GetCvarValue("r_width", r_width);
+            m_drawParams.m_position = AZ::Vector3(static_cast<float>(r_width), 0.0f, 1.0f) +
+                AZ::Vector3(r_topRightBorderPadding) * viewportContext->GetDpiScalingFactor();
+        }
+        else
+        {
+            auto viewportSize = viewportContext->GetViewportSize();
+            m_drawParams.m_position = AZ::Vector3(static_cast<float>(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);
         m_drawParams.m_hAlign = AzFramework::TextHorizontalAlignment::Right;

+ 2 - 1
Registry/Platform/iOS/window.setreg

@@ -3,7 +3,8 @@
         "Autoexec": {
             "ConsoleCommands": {
                 "r_fullscreen": 1,
-                "sys_PakLogInvalidFileAccess" : 1
+                "sys_PakLogInvalidFileAccess" : 1,
+                "r_resolutionMode" : 1
             }
         }
     }