From d37f83ffeba218c6ef94b78532aed50b1ebbc4a4 Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Fri, 27 Jan 2023 15:07:05 +1300 Subject: [PATCH] Implement AbstractGfx for Software & Null --- Source/Core/DolphinLib.props | 6 +- Source/Core/VideoBackends/Null/CMakeLists.txt | 4 +- .../Core/VideoBackends/Null/NullBackend.cpp | 24 +--- Source/Core/VideoBackends/Null/NullGfx.cpp | 90 +++++++++++++ .../Null/{NullRender.h => NullGfx.h} | 25 ++-- Source/Core/VideoBackends/Null/NullRender.cpp | 92 ------------- .../VideoBackends/Software/CMakeLists.txt | 2 + Source/Core/VideoBackends/Software/SWGfx.cpp | 127 ++++++++++++++++++ Source/Core/VideoBackends/Software/SWGfx.h | 55 ++++++++ .../VideoBackends/Software/SWRenderer.cpp | 125 ----------------- .../Core/VideoBackends/Software/SWRenderer.h | 45 ------- .../Core/VideoBackends/Software/SWTexture.cpp | 10 +- Source/Core/VideoBackends/Software/SWmain.cpp | 21 +-- Source/Core/VideoCommon/AbstractGfx.h | 2 + Source/Core/VideoCommon/RenderBase.h | 4 +- 15 files changed, 314 insertions(+), 318 deletions(-) create mode 100644 Source/Core/VideoBackends/Null/NullGfx.cpp rename Source/Core/VideoBackends/Null/{NullRender.h => NullGfx.h} (83%) delete mode 100644 Source/Core/VideoBackends/Null/NullRender.cpp create mode 100644 Source/Core/VideoBackends/Software/SWGfx.cpp create mode 100644 Source/Core/VideoBackends/Software/SWGfx.h diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props index a3d1bbacb7..b491f2f880 100644 --- a/Source/Core/DolphinLib.props +++ b/Source/Core/DolphinLib.props @@ -561,7 +561,7 @@ - + @@ -588,6 +588,7 @@ + @@ -1172,7 +1173,7 @@ - + @@ -1195,6 +1196,7 @@ + diff --git a/Source/Core/VideoBackends/Null/CMakeLists.txt b/Source/Core/VideoBackends/Null/CMakeLists.txt index e95877323f..e8ad21bbe8 100644 --- a/Source/Core/VideoBackends/Null/CMakeLists.txt +++ b/Source/Core/VideoBackends/Null/CMakeLists.txt @@ -1,8 +1,8 @@ add_library(videonull NullBackend.cpp NullBoundingBox.h - NullRender.cpp - NullRender.h + NullGfx.cpp + NullGfx.h NullTexture.cpp NullTexture.h NullVertexManager.cpp diff --git a/Source/Core/VideoBackends/Null/NullBackend.cpp b/Source/Core/VideoBackends/Null/NullBackend.cpp index 80f8431ee7..b90363818e 100644 --- a/Source/Core/VideoBackends/Null/NullBackend.cpp +++ b/Source/Core/VideoBackends/Null/NullBackend.cpp @@ -11,12 +11,14 @@ #include "Common/Common.h" #include "Common/MsgHandler.h" -#include "VideoBackends/Null/NullRender.h" +#include "VideoBackends/Null/NullBoundingBox.h" +#include "VideoBackends/Null/NullGfx.h" #include "VideoBackends/Null/NullVertexManager.h" #include "VideoBackends/Null/PerfQuery.h" #include "VideoBackends/Null/TextureCache.h" #include "VideoCommon/FramebufferManager.h" +#include "VideoCommon/Present.h" #include "VideoCommon/VideoBackendBase.h" #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" @@ -69,25 +71,13 @@ void VideoBackend::InitBackendInfo() bool VideoBackend::Initialize(const WindowSystemInfo& wsi) { - InitializeShared(); - - g_renderer = std::make_unique(); + g_gfx = std::make_unique(); + g_renderer = std::make_unique(); + g_bounding_box = std::make_unique(); g_vertex_manager = std::make_unique(); g_perf_query = std::make_unique(); - g_framebuffer_manager = std::make_unique(); - g_texture_cache = std::make_unique(); - g_shader_cache = std::make_unique(); - if (!g_vertex_manager->Initialize() || !g_shader_cache->Initialize() || - !g_renderer->Initialize() || !g_framebuffer_manager->Initialize() || - !g_texture_cache->Initialize()) - { - PanicAlertFmt("Failed to initialize renderer classes"); - Shutdown(); - return false; - } - - g_shader_cache->InitializeShaderCache(); + InitializeShared(); return true; } diff --git a/Source/Core/VideoBackends/Null/NullGfx.cpp b/Source/Core/VideoBackends/Null/NullGfx.cpp new file mode 100644 index 0000000000..ce8da5ff06 --- /dev/null +++ b/Source/Core/VideoBackends/Null/NullGfx.cpp @@ -0,0 +1,90 @@ +// Copyright 2015 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "VideoBackends/Null/NullGfx.h" + +#include "VideoBackends/Null/NullBoundingBox.h" +#include "VideoBackends/Null/NullTexture.h" + +#include "VideoCommon/AbstractPipeline.h" +#include "VideoCommon/AbstractShader.h" +#include "VideoCommon/NativeVertexFormat.h" +#include "VideoCommon/VideoConfig.h" + +namespace Null +{ +// Init functions +NullGfx::NullGfx() +{ + UpdateActiveConfig(); +} + +NullGfx::~NullGfx() +{ + UpdateActiveConfig(); +} + +bool NullGfx::IsHeadless() const +{ + return true; +} + +std::unique_ptr NullGfx::CreateTexture(const TextureConfig& config, + [[maybe_unused]] std::string_view name) +{ + return std::make_unique(config); +} + +std::unique_ptr NullGfx::CreateStagingTexture(StagingTextureType type, + const TextureConfig& config) +{ + return std::make_unique(type, config); +} + +class NullShader final : public AbstractShader +{ +public: + explicit NullShader(ShaderStage stage) : AbstractShader(stage) {} +}; + +std::unique_ptr +NullGfx::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source, + [[maybe_unused]] std::string_view name) +{ + return std::make_unique(stage); +} + +std::unique_ptr +NullGfx::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length, + [[maybe_unused]] std::string_view name) +{ + return std::make_unique(stage); +} + +class NullPipeline final : public AbstractPipeline +{ +}; + +std::unique_ptr NullGfx::CreatePipeline(const AbstractPipelineConfig& config, + const void* cache_data, + size_t cache_data_length) +{ + return std::make_unique(); +} + +std::unique_ptr NullGfx::CreateFramebuffer(AbstractTexture* color_attachment, + AbstractTexture* depth_attachment) +{ + return NullFramebuffer::Create(static_cast(color_attachment), + static_cast(depth_attachment)); +} + +std::unique_ptr +NullGfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) +{ + return std::make_unique(vtx_decl); +} + +NullRenderer::~NullRenderer() = default; + +} // namespace Null diff --git a/Source/Core/VideoBackends/Null/NullRender.h b/Source/Core/VideoBackends/Null/NullGfx.h similarity index 83% rename from Source/Core/VideoBackends/Null/NullRender.h rename to Source/Core/VideoBackends/Null/NullGfx.h index 061e78c61a..5afb3995b8 100644 --- a/Source/Core/VideoBackends/Null/NullRender.h +++ b/Source/Core/VideoBackends/Null/NullGfx.h @@ -3,17 +3,16 @@ #pragma once +#include "VideoCommon/AbstractGfx.h" #include "VideoCommon/RenderBase.h" -class BoundingBox; - namespace Null { -class Renderer final : public ::Renderer +class NullGfx final : public AbstractGfx { public: - Renderer(); - ~Renderer() override; + NullGfx(); + ~NullGfx() override; bool IsHeadless() const override; @@ -34,18 +33,18 @@ public: std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, const void* cache_data = nullptr, size_t cache_data_length = 0) override; +}; + +class NullRenderer final : public Renderer +{ +public: + NullRenderer() {} + ~NullRenderer() override; u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override { return 0; } void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points) override {} - void ClearScreen(const MathUtil::Rectangle& rc, bool colorEnable, bool alphaEnable, - bool zEnable, u32 color, u32 z) override - { - } - void ReinterpretPixelData(EFBReinterpretType convtype) override {} - -protected: - std::unique_ptr CreateBoundingBox() const override; }; + } // namespace Null diff --git a/Source/Core/VideoBackends/Null/NullRender.cpp b/Source/Core/VideoBackends/Null/NullRender.cpp deleted file mode 100644 index e7b7a7907c..0000000000 --- a/Source/Core/VideoBackends/Null/NullRender.cpp +++ /dev/null @@ -1,92 +0,0 @@ -// Copyright 2015 Dolphin Emulator Project -// SPDX-License-Identifier: GPL-2.0-or-later - -#include "VideoBackends/Null/NullRender.h" - -#include "VideoBackends/Null/NullBoundingBox.h" -#include "VideoBackends/Null/NullTexture.h" - -#include "VideoCommon/AbstractPipeline.h" -#include "VideoCommon/AbstractShader.h" -#include "VideoCommon/NativeVertexFormat.h" -#include "VideoCommon/VideoConfig.h" - -namespace Null -{ -// Init functions -Renderer::Renderer() : ::Renderer(1, 1, 1.0f, AbstractTextureFormat::RGBA8) -{ - UpdateActiveConfig(); -} - -Renderer::~Renderer() -{ - UpdateActiveConfig(); -} - -bool Renderer::IsHeadless() const -{ - return true; -} - -std::unique_ptr Renderer::CreateTexture(const TextureConfig& config, - [[maybe_unused]] std::string_view name) -{ - return std::make_unique(config); -} - -std::unique_ptr Renderer::CreateStagingTexture(StagingTextureType type, - const TextureConfig& config) -{ - return std::make_unique(type, config); -} - -class NullShader final : public AbstractShader -{ -public: - explicit NullShader(ShaderStage stage) : AbstractShader(stage) {} -}; - -std::unique_ptr -Renderer::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source, - [[maybe_unused]] std::string_view name) -{ - return std::make_unique(stage); -} - -std::unique_ptr -Renderer::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length, - [[maybe_unused]] std::string_view name) -{ - return std::make_unique(stage); -} - -class NullPipeline final : public AbstractPipeline -{ -}; - -std::unique_ptr Renderer::CreatePipeline(const AbstractPipelineConfig& config, - const void* cache_data, - size_t cache_data_length) -{ - return std::make_unique(); -} - -std::unique_ptr Renderer::CreateFramebuffer(AbstractTexture* color_attachment, - AbstractTexture* depth_attachment) -{ - return NullFramebuffer::Create(static_cast(color_attachment), - static_cast(depth_attachment)); -} - -std::unique_ptr -Renderer::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) -{ - return std::make_unique(vtx_decl); -} - -std::unique_ptr Renderer::CreateBoundingBox() const -{ - return std::make_unique(); -} -} // namespace Null diff --git a/Source/Core/VideoBackends/Software/CMakeLists.txt b/Source/Core/VideoBackends/Software/CMakeLists.txt index f71421cb57..7fc904bbf2 100644 --- a/Source/Core/VideoBackends/Software/CMakeLists.txt +++ b/Source/Core/VideoBackends/Software/CMakeLists.txt @@ -14,6 +14,8 @@ add_library(videosoftware SWmain.cpp SWBoundingBox.cpp SWBoundingBox.h + SWGfx.cpp + SWGfx.h SWOGLWindow.cpp SWOGLWindow.h SWRenderer.cpp diff --git a/Source/Core/VideoBackends/Software/SWGfx.cpp b/Source/Core/VideoBackends/Software/SWGfx.cpp new file mode 100644 index 0000000000..b53b7ae89a --- /dev/null +++ b/Source/Core/VideoBackends/Software/SWGfx.cpp @@ -0,0 +1,127 @@ +// Copyright 2023 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#include "VideoBackends/Software/SWGfx.h" + +#include "Common/GL/GLContext.h" + +#include "VideoBackends/Software/EfbCopy.h" +#include "VideoBackends/Software/Rasterizer.h" +#include "VideoBackends/Software/SWOGLWindow.h" +#include "VideoBackends/Software/SWTexture.h" + +#include "VideoCommon/AbstractPipeline.h" +#include "VideoCommon/AbstractShader.h" +#include "VideoCommon/AbstractTexture.h" +#include "VideoCommon/NativeVertexFormat.h" +#include "VideoCommon/Present.h" + +namespace SW +{ +SWGfx::SWGfx(std::unique_ptr window) : m_window(std::move(window)) +{ +} + +bool SWGfx::IsHeadless() const +{ + return m_window->IsHeadless(); +} + +std::unique_ptr SWGfx::CreateTexture(const TextureConfig& config, + [[maybe_unused]] std::string_view name) +{ + return std::make_unique(config); +} + +std::unique_ptr SWGfx::CreateStagingTexture(StagingTextureType type, + const TextureConfig& config) +{ + return std::make_unique(type, config); +} + +std::unique_ptr SWGfx::CreateFramebuffer(AbstractTexture* color_attachment, + AbstractTexture* depth_attachment) +{ + return SWFramebuffer::Create(static_cast(color_attachment), + static_cast(depth_attachment)); +} + +void SWGfx::BindBackbuffer(const ClearColor& clear_color) +{ + // Look for framebuffer resizes + if (!g_presenter->SurfaceResizedTestAndClear()) + return; + + GLContext* context = m_window->GetContext(); + context->Update(); + g_presenter->SetBackbuffer(context->GetBackBufferWidth(), context->GetBackBufferHeight()); +} + +class SWShader final : public AbstractShader +{ +public: + explicit SWShader(ShaderStage stage) : AbstractShader(stage) {} + ~SWShader() = default; + + BinaryData GetBinary() const override { return {}; } +}; + +std::unique_ptr +SWGfx::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source, + [[maybe_unused]] std::string_view name) +{ + return std::make_unique(stage); +} + +std::unique_ptr +SWGfx::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length, + [[maybe_unused]] std::string_view name) +{ + return std::make_unique(stage); +} + +class SWPipeline final : public AbstractPipeline +{ +public: + SWPipeline() = default; + ~SWPipeline() override = default; +}; + +std::unique_ptr SWGfx::CreatePipeline(const AbstractPipelineConfig& config, + const void* cache_data, + size_t cache_data_length) +{ + return std::make_unique(); +} + +// Called on the GPU thread +void SWGfx::ShowImage(const AbstractTexture* source_texture, + const MathUtil::Rectangle& source_rc) +{ + if (!IsHeadless()) + m_window->ShowImage(source_texture, source_rc); +} + +void SWGfx::ClearRegion(const MathUtil::Rectangle& rc, + const MathUtil::Rectangle& target_rc, bool colorEnable, + bool alphaEnable, bool zEnable, u32 color, u32 z) +{ + EfbCopy::ClearEfb(); +} + +std::unique_ptr +SWGfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) +{ + return std::make_unique(vtx_decl); +} + +void SWGfx::SetScissorRect(const MathUtil::Rectangle& rc) +{ + // BPFunctions calls SetScissorRect with the "best" scissor rect whenever the viewport or scissor + // changes. However, the software renderer is actually able to use multiple scissor rects (which + // is necessary in a few renderering edge cases, such as with Major Minor's Majestic March). + // Thus, we use this as a signal to update the list of scissor rects, but ignore the parameter. + Rasterizer::ScissorChanged(); +} + +} // namespace SW \ No newline at end of file diff --git a/Source/Core/VideoBackends/Software/SWGfx.h b/Source/Core/VideoBackends/Software/SWGfx.h new file mode 100644 index 0000000000..48015fda25 --- /dev/null +++ b/Source/Core/VideoBackends/Software/SWGfx.h @@ -0,0 +1,55 @@ +// Copyright 2023 Dolphin Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include "VideoCommon/AbstractGfx.h" + +class SWOGLWindow; + +namespace SW +{ +class SWGfx final : public AbstractGfx +{ +public: + SWGfx(std::unique_ptr window); + + bool IsHeadless() const override; + + std::unique_ptr CreateTexture(const TextureConfig& config, + std::string_view name) override; + std::unique_ptr + CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; + std::unique_ptr + CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override; + + void BindBackbuffer(const ClearColor& clear_color = {}) override; + + std::unique_ptr CreateShaderFromSource(ShaderStage stage, std::string_view source, + std::string_view name) override; + std::unique_ptr CreateShaderFromBinary(ShaderStage stage, const void* data, + size_t length, + std::string_view name) override; + std::unique_ptr + CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; + std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, + const void* cache_data = nullptr, + size_t cache_data_length = 0) override; + + void ShowImage(const AbstractTexture* source_texture, + const MathUtil::Rectangle& source_rc) override; + + void ScaleTexture(AbstractFramebuffer* dst_framebuffer, const MathUtil::Rectangle& dst_rect, + const AbstractTexture* src_texture, + const MathUtil::Rectangle& src_rect) override; + + void SetScissorRect(const MathUtil::Rectangle& rc) override; + + void ClearRegion(const MathUtil::Rectangle& rc, const MathUtil::Rectangle& target_rc, + bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override; + +private: + std::unique_ptr m_window; +}; + +} // namespace SW diff --git a/Source/Core/VideoBackends/Software/SWRenderer.cpp b/Source/Core/VideoBackends/Software/SWRenderer.cpp index 887bce177f..7440fba1b3 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.cpp +++ b/Source/Core/VideoBackends/Software/SWRenderer.cpp @@ -6,117 +6,17 @@ #include #include "Common/CommonTypes.h" -#include "Common/GL/GLContext.h" #include "Core/HW/Memmap.h" #include "Core/System.h" -#include "VideoBackends/Software/EfbCopy.h" #include "VideoBackends/Software/EfbInterface.h" -#include "VideoBackends/Software/Rasterizer.h" -#include "VideoBackends/Software/SWBoundingBox.h" -#include "VideoBackends/Software/SWOGLWindow.h" -#include "VideoBackends/Software/SWTexture.h" -#include "VideoCommon/AbstractPipeline.h" -#include "VideoCommon/AbstractShader.h" -#include "VideoCommon/AbstractTexture.h" -#include "VideoCommon/NativeVertexFormat.h" #include "VideoCommon/PixelEngine.h" -#include "VideoCommon/Present.h" #include "VideoCommon/VideoBackendBase.h" -#include "VideoCommon/VideoCommon.h" namespace SW { -SWRenderer::SWRenderer(std::unique_ptr window) - : ::Renderer(static_cast(std::max(window->GetContext()->GetBackBufferWidth(), 1u)), - static_cast(std::max(window->GetContext()->GetBackBufferHeight(), 1u)), 1.0f, - AbstractTextureFormat::RGBA8), - m_window(std::move(window)) -{ -} - -bool SWRenderer::IsHeadless() const -{ - return m_window->IsHeadless(); -} - -std::unique_ptr SWRenderer::CreateTexture(const TextureConfig& config, - [[maybe_unused]] std::string_view name) -{ - return std::make_unique(config); -} - -std::unique_ptr -SWRenderer::CreateStagingTexture(StagingTextureType type, const TextureConfig& config) -{ - return std::make_unique(type, config); -} - -std::unique_ptr -SWRenderer::CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) -{ - return SWFramebuffer::Create(static_cast(color_attachment), - static_cast(depth_attachment)); -} - -void SWRenderer::BindBackbuffer(const ClearColor& clear_color) -{ - // Look for framebuffer resizes - if (!g_presenter->SurfaceResizedTestAndClear()) - return; - - GLContext* context = m_window->GetContext(); - context->Update(); - g_presenter->SetBackbuffer(context->GetBackBufferWidth(), context->GetBackBufferHeight()); -} - -class SWShader final : public AbstractShader -{ -public: - explicit SWShader(ShaderStage stage) : AbstractShader(stage) {} - ~SWShader() = default; - - BinaryData GetBinary() const override { return {}; } -}; - -std::unique_ptr -SWRenderer::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source, - [[maybe_unused]] std::string_view name) -{ - return std::make_unique(stage); -} - -std::unique_ptr -SWRenderer::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length, - [[maybe_unused]] std::string_view name) -{ - return std::make_unique(stage); -} - -class SWPipeline final : public AbstractPipeline -{ -public: - SWPipeline() = default; - ~SWPipeline() override = default; -}; - -std::unique_ptr SWRenderer::CreatePipeline(const AbstractPipelineConfig& config, - const void* cache_data, - size_t cache_data_length) -{ - return std::make_unique(); -} - -// Called on the GPU thread -void SWRenderer::ShowImage(const AbstractTexture* source_texture, - const MathUtil::Rectangle& source_rc) -{ - if (!IsHeadless()) - m_window->ShowImage(source_texture, source_rc); -} - u32 SWRenderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) { u32 value = 0; @@ -165,29 +65,4 @@ u32 SWRenderer::AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData) return value; } -std::unique_ptr SWRenderer::CreateBoundingBox() const -{ - return std::make_unique(); -} - -void SWRenderer::ClearScreen(const MathUtil::Rectangle& rc, bool colorEnable, bool alphaEnable, - bool zEnable, u32 color, u32 z) -{ - EfbCopy::ClearEfb(); -} - -std::unique_ptr -SWRenderer::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) -{ - return std::make_unique(vtx_decl); -} - -void SWRenderer::SetScissorRect(const MathUtil::Rectangle& rc) -{ - // BPFunctions calls SetScissorRect with the "best" scissor rect whenever the viewport or scissor - // changes. However, the software renderer is actually able to use multiple scissor rects (which - // is necessary in a few renderering edge cases, such as with Major Minor's Majestic March). - // Thus, we use this as a signal to update the list of scissor rects, but ignore the parameter. - Rasterizer::ScissorChanged(); -} } // namespace SW diff --git a/Source/Core/VideoBackends/Software/SWRenderer.h b/Source/Core/VideoBackends/Software/SWRenderer.h index 7444834a18..e34a016e15 100644 --- a/Source/Core/VideoBackends/Software/SWRenderer.h +++ b/Source/Core/VideoBackends/Software/SWRenderer.h @@ -10,59 +10,14 @@ #include "VideoCommon/RenderBase.h" -class BoundingBox; -class SWOGLWindow; - namespace SW { class SWRenderer final : public Renderer { public: - SWRenderer(std::unique_ptr window); - - bool IsHeadless() const override; - - std::unique_ptr CreateTexture(const TextureConfig& config, - std::string_view name) override; - std::unique_ptr - CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override; - std::unique_ptr - CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override; - - void BindBackbuffer(const ClearColor& clear_color = {}) override; - - std::unique_ptr CreateShaderFromSource(ShaderStage stage, std::string_view source, - std::string_view name) override; - std::unique_ptr CreateShaderFromBinary(ShaderStage stage, const void* data, - size_t length, - std::string_view name) override; - std::unique_ptr - CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override; - std::unique_ptr CreatePipeline(const AbstractPipelineConfig& config, - const void* cache_data = nullptr, - size_t cache_data_length = 0) override; - u32 AccessEFB(EFBAccessType type, u32 x, u32 y, u32 poke_data) override; void PokeEFB(EFBAccessType type, const EfbPokeData* points, size_t num_points) override {} - void ShowImage(const AbstractTexture* source_texture, - const MathUtil::Rectangle& source_rc) override; - - void ClearScreen(const MathUtil::Rectangle& rc, bool colorEnable, bool alphaEnable, - bool zEnable, u32 color, u32 z) override; - void ReinterpretPixelData(EFBReinterpretType convtype) override {} - - void ScaleTexture(AbstractFramebuffer* dst_framebuffer, const MathUtil::Rectangle& dst_rect, - const AbstractTexture* src_texture, - const MathUtil::Rectangle& src_rect) override; - - void SetScissorRect(const MathUtil::Rectangle& rc) override; - -protected: - std::unique_ptr CreateBoundingBox() const override; - -private: - std::unique_ptr m_window; }; } // namespace SW diff --git a/Source/Core/VideoBackends/Software/SWTexture.cpp b/Source/Core/VideoBackends/Software/SWTexture.cpp index 6805ff0eb8..2e925c4686 100644 --- a/Source/Core/VideoBackends/Software/SWTexture.cpp +++ b/Source/Core/VideoBackends/Software/SWTexture.cpp @@ -8,7 +8,7 @@ #include "Common/Assert.h" #include "VideoBackends/Software/CopyRegion.h" -#include "VideoBackends/Software/SWRenderer.h" +#include "VideoBackends/Software/SWGfx.h" namespace SW { @@ -48,10 +48,10 @@ void CopyTextureData(const TextureConfig& src_config, const u8* src_ptr, u32 src } } // namespace -void SWRenderer::ScaleTexture(AbstractFramebuffer* dst_framebuffer, - const MathUtil::Rectangle& dst_rect, - const AbstractTexture* src_texture, - const MathUtil::Rectangle& src_rect) +void SWGfx::ScaleTexture(AbstractFramebuffer* dst_framebuffer, + const MathUtil::Rectangle& dst_rect, + const AbstractTexture* src_texture, + const MathUtil::Rectangle& src_rect) { const SWTexture* software_source_texture = static_cast(src_texture); SWTexture* software_dest_texture = static_cast(dst_framebuffer->GetColorAttachment()); diff --git a/Source/Core/VideoBackends/Software/SWmain.cpp b/Source/Core/VideoBackends/Software/SWmain.cpp index b749f447bb..46101afe77 100644 --- a/Source/Core/VideoBackends/Software/SWmain.cpp +++ b/Source/Core/VideoBackends/Software/SWmain.cpp @@ -16,6 +16,8 @@ #include "VideoBackends/Software/Clipper.h" #include "VideoBackends/Software/EfbInterface.h" #include "VideoBackends/Software/Rasterizer.h" +#include "VideoBackends/Software/SWBoundingBox.h" +#include "VideoBackends/Software/SWGfx.h" #include "VideoBackends/Software/SWOGLWindow.h" #include "VideoBackends/Software/SWRenderer.h" #include "VideoBackends/Software/SWTexture.h" @@ -23,6 +25,7 @@ #include "VideoBackends/Software/TextureCache.h" #include "VideoCommon/FramebufferManager.h" +#include "VideoCommon/Present.h" #include "VideoCommon/TextureCacheBase.h" #include "VideoCommon/VideoCommon.h" #include "VideoCommon/VideoConfig.h" @@ -96,8 +99,6 @@ void VideoSoftware::InitBackendInfo() bool VideoSoftware::Initialize(const WindowSystemInfo& wsi) { - InitializeShared(); - std::unique_ptr window = SWOGLWindow::Create(wsi); if (!window) return false; @@ -105,23 +106,13 @@ bool VideoSoftware::Initialize(const WindowSystemInfo& wsi) Clipper::Init(); Rasterizer::Init(); - g_renderer = std::make_unique(std::move(window)); + g_gfx = std::make_unique(std::move(window)); + g_bounding_box = std::make_unique(); g_vertex_manager = std::make_unique(); - g_shader_cache = std::make_unique(); - g_framebuffer_manager = std::make_unique(); g_perf_query = std::make_unique(); - g_texture_cache = std::make_unique(); - if (!g_vertex_manager->Initialize() || !g_shader_cache->Initialize() || - !g_renderer->Initialize() || !g_framebuffer_manager->Initialize() || - !g_texture_cache->Initialize()) - { - PanicAlertFmt("Failed to initialize renderer classes"); - Shutdown(); - return false; - } + InitializeShared(); - g_shader_cache->InitializeShaderCache(); return true; } diff --git a/Source/Core/VideoCommon/AbstractGfx.h b/Source/Core/VideoCommon/AbstractGfx.h index 2db077c98c..eb5944fc84 100644 --- a/Source/Core/VideoCommon/AbstractGfx.h +++ b/Source/Core/VideoCommon/AbstractGfx.h @@ -55,6 +55,8 @@ using ClearColor = std::array; class AbstractGfx { public: + virtual ~AbstractGfx() = default; + virtual bool IsHeadless() const = 0; virtual void SetPipeline(const AbstractPipeline* pipeline) {} diff --git a/Source/Core/VideoCommon/RenderBase.h b/Source/Core/VideoCommon/RenderBase.h index fb88dfd1eb..7bd18e16e7 100644 --- a/Source/Core/VideoCommon/RenderBase.h +++ b/Source/Core/VideoCommon/RenderBase.h @@ -90,8 +90,8 @@ public: float EFBToScaledXf(float x) const; float EFBToScaledYf(float y) const; - virtual void ClearScreen(const MathUtil::Rectangle& rc, bool colorEnable, bool alphaEnable, - bool zEnable, u32 color, u32 z); + void ClearScreen(const MathUtil::Rectangle& rc, bool colorEnable, bool alphaEnable, + bool zEnable, u32 color, u32 z); virtual void ReinterpretPixelData(EFBReinterpretType convtype); void RenderToXFB(u32 xfbAddr, const MathUtil::Rectangle& sourceRc, u32 fbStride, u32 fbHeight, float Gamma = 1.0f);