From dd5b8895fe983b0e577ddd222ecb902c7a9a4af1 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Aug 2019 22:45:25 -0400 Subject: VideoCommon/RenderBase: Make functions const where applicable --- Source/Core/VideoCommon/RenderBase.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'Source/Core/VideoCommon/RenderBase.cpp') diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 48b8e4cfd3..4bd69e186d 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -665,13 +665,13 @@ void Renderer::ScaleTexture(AbstractFramebuffer* dst_framebuffer, MathUtil::Rectangle Renderer::ConvertFramebufferRectangle(const MathUtil::Rectangle& rect, - const AbstractFramebuffer* framebuffer) + const AbstractFramebuffer* framebuffer) const { return ConvertFramebufferRectangle(rect, framebuffer->GetWidth(), framebuffer->GetHeight()); } MathUtil::Rectangle Renderer::ConvertFramebufferRectangle(const MathUtil::Rectangle& rect, - u32 fb_width, u32 fb_height) + u32 fb_width, u32 fb_height) const { MathUtil::Rectangle ret = rect; if (g_ActiveConfig.backend_info.bUsesLowerLeftOrigin) @@ -682,7 +682,7 @@ MathUtil::Rectangle Renderer::ConvertFramebufferRectangle(const MathUtil::R return ret; } -MathUtil::Rectangle Renderer::ConvertEFBRectangle(const MathUtil::Rectangle& rc) +MathUtil::Rectangle Renderer::ConvertEFBRectangle(const MathUtil::Rectangle& rc) const { MathUtil::Rectangle result; result.left = EFBToScaledX(rc.left); @@ -827,7 +827,7 @@ void Renderer::SetWindowSize(int width, int height) } } -std::tuple Renderer::CalculateOutputDimensions(int width, int height) +std::tuple Renderer::CalculateOutputDimensions(int width, int height) const { width = std::max(width, 1); height = std::max(height, 1); @@ -1356,7 +1356,7 @@ void Renderer::RenderXFBToScreen(const MathUtil::Rectangle& target_rc, } } -bool Renderer::IsFrameDumping() +bool Renderer::IsFrameDumping() const { if (m_screenshot_request.IsSet()) return true; -- cgit v1.2.3 From cfdfbbff386711e07204a36e8dcf64f12b01eeb2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Aug 2019 22:57:12 -0400 Subject: VideoCommon/RenderBase: Use structured bindings where applicable Same behavior, but immediately assigns to variables, allowing them to be const. --- Source/Core/VideoCommon/RenderBase.cpp | 30 ++++++++++++------------------ 1 file changed, 12 insertions(+), 18 deletions(-) (limited to 'Source/Core/VideoCommon/RenderBase.cpp') diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 4bd69e186d..67afec8ada 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -315,9 +315,7 @@ bool Renderer::CalculateTargetSize() if (max_size < EFB_WIDTH * m_efb_scale) m_efb_scale = max_size / EFB_WIDTH; - int new_efb_width = 0; - int new_efb_height = 0; - std::tie(new_efb_width, new_efb_height) = CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT); + auto [new_efb_width, new_efb_height] = CalculateTargetScale(EFB_WIDTH, EFB_HEIGHT); new_efb_width = std::max(new_efb_width, 1); new_efb_height = std::max(new_efb_height, 1); @@ -816,15 +814,15 @@ void Renderer::UpdateDrawRectangle() void Renderer::SetWindowSize(int width, int height) { - std::tie(width, height) = CalculateOutputDimensions(width, height); + const auto [out_width, out_height] = CalculateOutputDimensions(width, height); // Track the last values of width/height to avoid sending a window resize event every frame. - if (width != m_last_window_request_width || height != m_last_window_request_height) - { - m_last_window_request_width = width; - m_last_window_request_height = height; - Host_RequestRenderWindowSize(width, height); - } + if (out_width == m_last_window_request_width && out_height == m_last_window_request_height) + return; + + m_last_window_request_width = out_width; + m_last_window_request_height = out_height; + Host_RequestRenderWindowSize(out_width, out_height); } std::tuple Renderer::CalculateOutputDimensions(int width, int height) const @@ -832,8 +830,7 @@ std::tuple Renderer::CalculateOutputDimensions(int width, int height) width = std::max(width, 1); height = std::max(height, 1); - float scaled_width, scaled_height; - std::tie(scaled_width, scaled_height) = ScaleToDisplayAspectRatio(width, height); + auto [scaled_width, scaled_height] = ScaleToDisplayAspectRatio(width, height); if (g_ActiveConfig.bCrop) { @@ -1210,11 +1207,9 @@ void Renderer::Swap(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u6 else { // Heuristic to detect if a GameCube game is in 16:9 anamorphic widescreen mode. - - size_t flush_count_4_3, flush_count_anamorphic; - std::tie(flush_count_4_3, flush_count_anamorphic) = + const auto [flush_count_4_3, flush_count_anamorphic] = g_vertex_manager->ResetFlushAspectRatioCount(); - size_t flush_total = flush_count_4_3 + flush_count_anamorphic; + const size_t flush_total = flush_count_4_3 + flush_count_anamorphic; // Modify the threshold based on which aspect ratio we're already using: if // the game's in 4:3, it probably won't switch to anamorphic, and vice-versa. @@ -1344,8 +1339,7 @@ void Renderer::RenderXFBToScreen(const MathUtil::Rectangle& target_rc, if (g_ActiveConfig.stereo_mode == StereoMode::SBS || g_ActiveConfig.stereo_mode == StereoMode::TAB) { - MathUtil::Rectangle left_rc, right_rc; - std::tie(left_rc, right_rc) = ConvertStereoRectangle(target_rc); + const auto [left_rc, right_rc] = ConvertStereoRectangle(target_rc); m_post_processor->BlitFromTexture(left_rc, source_rc, source_texture, 0); m_post_processor->BlitFromTexture(right_rc, source_rc, source_texture, 1); -- cgit v1.2.3 From 7366b4281fea28f666ac7ed870f731f42f7b4044 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Sun, 4 Aug 2019 23:01:16 -0400 Subject: VideoCommon/RenderBase: Remove dependency on renderer global within renderer There's no need to have a dependency when we can simply call the function itself as part of the instance itself. --- Source/Core/VideoCommon/RenderBase.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoCommon/RenderBase.cpp') diff --git a/Source/Core/VideoCommon/RenderBase.cpp b/Source/Core/VideoCommon/RenderBase.cpp index 67afec8ada..972b0e15fc 100644 --- a/Source/Core/VideoCommon/RenderBase.cpp +++ b/Source/Core/VideoCommon/RenderBase.cpp @@ -629,8 +629,8 @@ void Renderer::ScaleTexture(AbstractFramebuffer* dst_framebuffer, BeginUtilityDrawing(); // The shader needs to know the source rectangle. - const auto converted_src_rect = g_renderer->ConvertFramebufferRectangle( - src_rect, src_texture->GetWidth(), src_texture->GetHeight()); + const auto converted_src_rect = + ConvertFramebufferRectangle(src_rect, src_texture->GetWidth(), src_texture->GetHeight()); const float rcp_src_width = 1.0f / src_texture->GetWidth(); const float rcp_src_height = 1.0f / src_texture->GetHeight(); const std::array uniforms = {{converted_src_rect.left * rcp_src_width, @@ -1036,7 +1036,7 @@ bool Renderer::InitializeImGui() pconfig.framebuffer_state.samples = 1; pconfig.framebuffer_state.per_sample_shading = false; pconfig.usage = AbstractPipelineUsage::Utility; - m_imgui_pipeline = g_renderer->CreatePipeline(pconfig); + m_imgui_pipeline = CreatePipeline(pconfig); if (!m_imgui_pipeline) { PanicAlert("Failed to create imgui pipeline"); -- cgit v1.2.3