From f158ff300b72cff5ca1e2e62bc239111987188af Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sat, 28 Jan 2023 16:23:30 +1300 Subject: [PATCH] Handle VideoSoftware's present fallback better Not a good idea to abuse bSupportsPostProcessing --- Source/Core/VideoBackends/Null/NullGfx.cpp | 5 +++++ Source/Core/VideoBackends/Null/NullGfx.h | 1 + Source/Core/VideoBackends/Software/SWGfx.cpp | 5 +++++ Source/Core/VideoBackends/Software/SWGfx.h | 1 + Source/Core/VideoCommon/AbstractGfx.h | 3 +++ Source/Core/VideoCommon/Present.cpp | 14 ++++++++------ 6 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Source/Core/VideoBackends/Null/NullGfx.cpp b/Source/Core/VideoBackends/Null/NullGfx.cpp index ce8da5ff06..7449aae09c 100644 --- a/Source/Core/VideoBackends/Null/NullGfx.cpp +++ b/Source/Core/VideoBackends/Null/NullGfx.cpp @@ -29,6 +29,11 @@ bool NullGfx::IsHeadless() const return true; } +bool NullGfx::SupportsUtilityDrawing() const +{ + return false; +} + std::unique_ptr NullGfx::CreateTexture(const TextureConfig& config, [[maybe_unused]] std::string_view name) { diff --git a/Source/Core/VideoBackends/Null/NullGfx.h b/Source/Core/VideoBackends/Null/NullGfx.h index 5afb3995b8..b1dff2bc2f 100644 --- a/Source/Core/VideoBackends/Null/NullGfx.h +++ b/Source/Core/VideoBackends/Null/NullGfx.h @@ -15,6 +15,7 @@ public: ~NullGfx() override; bool IsHeadless() const override; + virtual bool SupportsUtilityDrawing() const override; std::unique_ptr CreateTexture(const TextureConfig& config, std::string_view name) override; diff --git a/Source/Core/VideoBackends/Software/SWGfx.cpp b/Source/Core/VideoBackends/Software/SWGfx.cpp index b53b7ae89a..7e8c234540 100644 --- a/Source/Core/VideoBackends/Software/SWGfx.cpp +++ b/Source/Core/VideoBackends/Software/SWGfx.cpp @@ -27,6 +27,11 @@ bool SWGfx::IsHeadless() const return m_window->IsHeadless(); } +bool SWGfx::SupportsUtilityDrawing() const +{ + return false; +} + std::unique_ptr SWGfx::CreateTexture(const TextureConfig& config, [[maybe_unused]] std::string_view name) { diff --git a/Source/Core/VideoBackends/Software/SWGfx.h b/Source/Core/VideoBackends/Software/SWGfx.h index 48015fda25..1337d89525 100644 --- a/Source/Core/VideoBackends/Software/SWGfx.h +++ b/Source/Core/VideoBackends/Software/SWGfx.h @@ -15,6 +15,7 @@ public: SWGfx(std::unique_ptr window); bool IsHeadless() const override; + virtual bool SupportsUtilityDrawing() const override; std::unique_ptr CreateTexture(const TextureConfig& config, std::string_view name) override; diff --git a/Source/Core/VideoCommon/AbstractGfx.h b/Source/Core/VideoCommon/AbstractGfx.h index eb5944fc84..d34690ec01 100644 --- a/Source/Core/VideoCommon/AbstractGfx.h +++ b/Source/Core/VideoCommon/AbstractGfx.h @@ -59,6 +59,9 @@ public: virtual bool IsHeadless() const = 0; + // Does the backend support drawing a UI or doing post-processing + virtual bool SupportsUtilityDrawing() const { return true; } + virtual void SetPipeline(const AbstractPipeline* pipeline) {} virtual void SetScissorRect(const MathUtil::Rectangle& rc) {} virtual void SetTexture(u32 index, const AbstractTexture* texture) {} diff --git a/Source/Core/VideoCommon/Present.cpp b/Source/Core/VideoCommon/Present.cpp index 8f10707d0d..a89b41b1dd 100644 --- a/Source/Core/VideoCommon/Present.cpp +++ b/Source/Core/VideoCommon/Present.cpp @@ -393,12 +393,6 @@ void Presenter::RenderXFBToScreen(const MathUtil::Rectangle& target_rc, const AbstractTexture* source_texture, const MathUtil::Rectangle& source_rc) { - if (!g_ActiveConfig.backend_info.bSupportsPostProcessing) - { - g_gfx->ShowImage(source_texture, source_rc); - return; - } - if (g_ActiveConfig.stereo_mode == StereoMode::QuadBuffer && g_ActiveConfig.backend_info.bUsesExplictQuadBuffering) { @@ -463,6 +457,14 @@ void Presenter::Present() { m_last_xfb_id = m_xfb_entry->id; + if (!g_gfx->SupportsUtilityDrawing()) + { + // Video Software doesn't support Drawing a UI or doing post-processing + // So just Show the XFB + g_gfx->ShowImage(m_xfb_entry->texture.get(), m_xfb_rect); + return; + } + // Since we use the common pipelines here and draw vertices if a batch is currently being // built by the vertex loader, we end up trampling over its pointer, as we share the buffer // with the loader, and it has not been unmapped yet. Force a pipeline flush to avoid this.