From 5a5b2ef858e1f685ff1cf475e0cc97aa1d927a29 Mon Sep 17 00:00:00 2001 From: KojoZero Date: Mon, 1 Jun 2026 03:22:54 -0700 Subject: [PATCH] vulkan reduced secondary window (or android) drawing --- .../renderer_opengl/renderer_opengl.cpp | 3 +- .../renderer_vulkan/renderer_vulkan.cpp | 109 +++++++++++++++--- .../renderer_vulkan/renderer_vulkan.h | 2 + 3 files changed, 96 insertions(+), 18 deletions(-) diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index ef32b0de8..dfd4c8fe5 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -425,7 +425,7 @@ void RendererOpenGL::AllocateOutputSizeTextures(){ } } - LOG_INFO(Render_OpenGL, "Reallocated OutputSize Textures. PrevRects:\n{}x{}\n{}x{}\n{}x{}\nCurrRects:\n{}x{}\n{}x{}\n{}x{}", + LOG_INFO(Render_OpenGL, "Reallocated OutputSize Textures.\nPrevRects:\n{}x{}\n{}x{}\n{}x{}\nCurrRects:\n{}x{}\n{}x{}\n{}x{}", prevOutputScreenRects[isSecondaryWindow][0].GetWidth(), prevOutputScreenRects[isSecondaryWindow][0].GetHeight(), prevOutputScreenRects[isSecondaryWindow][1].GetWidth(), prevOutputScreenRects[isSecondaryWindow][1].GetHeight(), prevOutputScreenRects[isSecondaryWindow][2].GetWidth(), prevOutputScreenRects[isSecondaryWindow][2].GetHeight(), @@ -433,7 +433,6 @@ void RendererOpenGL::AllocateOutputSizeTextures(){ currOutputScreenRects[isSecondaryWindow][1].GetWidth(), currOutputScreenRects[isSecondaryWindow][1].GetHeight(), currOutputScreenRects[isSecondaryWindow][2].GetWidth(), currOutputScreenRects[isSecondaryWindow][2].GetHeight() ); - // } /** diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.cpp b/src/video_core/renderer_vulkan/renderer_vulkan.cpp index 7f2683e3a..99962ecf5 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.cpp +++ b/src/video_core/renderer_vulkan/renderer_vulkan.cpp @@ -586,7 +586,15 @@ void RendererVulkan::AllocateOutputSizeTextures(){ AllocateTexture(intermediateOutputSizeTextures[isSecondaryWindow][i][j], currOutputScreenRects[isSecondaryWindow][i].GetWidth(), currOutputScreenRects[isSecondaryWindow][i].GetHeight(), vk::Format::eR16G16B16A16Sfloat); } } - LOG_INFO(Render_Vulkan, "Reallocated Output Size Textures"); + // LOG_INFO(Render_Vulkan, "Reallocated Output Size Textures"); + LOG_INFO(Render_OpenGL, "Reallocated OutputSize Textures.\nPrevRects:\n{}x{}\n{}x{}\n{}x{}\nCurrRects:\n{}x{}\n{}x{}\n{}x{}", + prevOutputScreenRects[isSecondaryWindow][0].GetWidth(), prevOutputScreenRects[isSecondaryWindow][0].GetHeight(), + prevOutputScreenRects[isSecondaryWindow][1].GetWidth(), prevOutputScreenRects[isSecondaryWindow][1].GetHeight(), + prevOutputScreenRects[isSecondaryWindow][2].GetWidth(), prevOutputScreenRects[isSecondaryWindow][2].GetHeight(), + currOutputScreenRects[isSecondaryWindow][0].GetWidth(), currOutputScreenRects[isSecondaryWindow][0].GetHeight(), + currOutputScreenRects[isSecondaryWindow][1].GetWidth(), currOutputScreenRects[isSecondaryWindow][1].GetHeight(), + currOutputScreenRects[isSecondaryWindow][2].GetWidth(), currOutputScreenRects[isSecondaryWindow][2].GetHeight() + ); }; void RendererVulkan::CreateOutputSizeTextureFramebuffers(){ @@ -2082,24 +2090,76 @@ void RendererVulkan::DrawScreens(Frame* frame, const Layout::FramebufferLayout& clearingColorAttachment = true; applyingOpacity = true; - if (!Settings::values.swap_screen.GetValue()) { - drawingPrimaryScreen = true; - DrawTopScreen(layout, top_screen); - draw_info.layer = 0; - drawingPrimaryScreen = false; - usingTopOpacity = false; - clearingColorAttachment = false; - DrawBottomScreen(layout, bottom_screen); + if (!secondaryWindowEnabled){ + if (!Settings::values.swap_screen.GetValue()) { + drawingPrimaryScreen = true; + DrawTopScreen(layout, top_screen); + draw_info.layer = 0; + drawingPrimaryScreen = false; + usingTopOpacity = false; + clearingColorAttachment = false; + DrawBottomScreen(layout, bottom_screen); + } else { + drawingPrimaryScreen = true; + DrawBottomScreen(layout, bottom_screen); + draw_info.layer = 0; + drawingPrimaryScreen = false; + usingTopOpacity = true; + clearingColorAttachment = false; + DrawTopScreen(layout, top_screen); + } } else { - drawingPrimaryScreen = true; - DrawBottomScreen(layout, bottom_screen); - draw_info.layer = 0; - drawingPrimaryScreen = false; - usingTopOpacity = true; - clearingColorAttachment = false; - DrawTopScreen(layout, top_screen); + if (!Settings::values.swap_screen.GetValue()) { + if (usingAndroid){ + // Change this block to conditionally display based on layout of primary and secondary screen + if (isSecondaryWindow){ + return; + } else { + drawingPrimaryScreen = true; + DrawTopScreen(layout, top_screen); + draw_info.layer = 0; + drawingPrimaryScreen = false; + usingTopOpacity = false; + clearingColorAttachment = false; + DrawBottomScreen(layout, bottom_screen); + } + } else { + if (isSecondaryWindow) { + drawingPrimaryScreen = true; + DrawBottomScreen(layout, bottom_screen); + } else { + drawingPrimaryScreen = true; + DrawTopScreen(layout, top_screen); + } + } + } else { + if (usingAndroid){ + // Change this block to conditionally display based on layout of primary and secondary screen + if (isSecondaryWindow){ + return; + } else { + drawingPrimaryScreen = true; + DrawBottomScreen(layout, bottom_screen); + draw_info.layer = 0; + drawingPrimaryScreen = false; + usingTopOpacity = true; + clearingColorAttachment = false; + DrawTopScreen(layout, top_screen); + } + } else { + if (isSecondaryWindow) { + drawingPrimaryScreen = true; + DrawTopScreen(layout, top_screen); + } else { + drawingPrimaryScreen = true; + DrawBottomScreen(layout, bottom_screen); + } + } + + } } + applyingOpacity = false; if (layout.additional_screen_enabled) { const auto& additional_screen = layout.additional_screen; @@ -2176,6 +2236,23 @@ void RendererVulkan::DrawCursor(const Layout::FramebufferLayout& layout) { void RendererVulkan::SwapBuffers() { system.perf_stats->StartSwap(); +#ifndef ANDROID + if (Settings::values.layout_option.GetValue() == Settings::LayoutOption::SeparateWindows) { + ASSERT(secondary_window); + secondaryWindowEnabled = true; + } else { + secondaryWindowEnabled = false; + } +#endif + +#ifdef ANDROID + usingAndroid = true; + if (secondary_window) { + secondaryWindowEnabled = true; + } else { + secondaryWindowEnabled = false; + } +#endif const Layout::FramebufferLayout& layout = render_window.GetFramebufferLayout(); PrepareRendertarget(); RenderScreenshot(); diff --git a/src/video_core/renderer_vulkan/renderer_vulkan.h b/src/video_core/renderer_vulkan/renderer_vulkan.h index c06fc9090..285509bd2 100644 --- a/src/video_core/renderer_vulkan/renderer_vulkan.h +++ b/src/video_core/renderer_vulkan/renderer_vulkan.h @@ -269,6 +269,8 @@ private: // Secondary Layout Fix bool isSecondaryWindow; + bool secondaryWindowEnabled; + bool usingAndroid; }; } // namespace Vulkan