summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorScott Mansell <phiren@gmail.com>2023-01-27 15:07:05 +1300
committerScott Mansell <phiren@gmail.com>2023-01-31 19:41:23 +1300
commitd37f83ffeba218c6ef94b78532aed50b1ebbc4a4 (patch)
tree0958778e5ee1693c70a9d66d02f6674e91202fb8 /Source/Core
parentf0336a3129ea431862e6e3bf1ccf51a384cf3f57 (diff)
Implement AbstractGfx for Software & Null
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinLib.props6
-rw-r--r--Source/Core/VideoBackends/Null/CMakeLists.txt4
-rw-r--r--Source/Core/VideoBackends/Null/NullBackend.cpp24
-rw-r--r--Source/Core/VideoBackends/Null/NullGfx.cpp90
-rw-r--r--Source/Core/VideoBackends/Null/NullGfx.h (renamed from Source/Core/VideoBackends/Null/NullRender.h)25
-rw-r--r--Source/Core/VideoBackends/Null/NullRender.cpp92
-rw-r--r--Source/Core/VideoBackends/Software/CMakeLists.txt2
-rw-r--r--Source/Core/VideoBackends/Software/SWGfx.cpp127
-rw-r--r--Source/Core/VideoBackends/Software/SWGfx.h55
-rw-r--r--Source/Core/VideoBackends/Software/SWRenderer.cpp125
-rw-r--r--Source/Core/VideoBackends/Software/SWRenderer.h45
-rw-r--r--Source/Core/VideoBackends/Software/SWTexture.cpp10
-rw-r--r--Source/Core/VideoBackends/Software/SWmain.cpp23
-rw-r--r--Source/Core/VideoCommon/AbstractGfx.h2
-rw-r--r--Source/Core/VideoCommon/RenderBase.h4
15 files changed, 315 insertions, 319 deletions
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 @@
<ClInclude Include="VideoBackends\D3DCommon\Shader.h" />
<ClInclude Include="VideoBackends\D3DCommon\SwapChain.h" />
<ClInclude Include="VideoBackends\Null\NullBoundingBox.h" />
- <ClInclude Include="VideoBackends\Null\NullRender.h" />
+ <ClInclude Include="VideoBackends\Null\NullGfx.h" />
<ClInclude Include="VideoBackends\Null\NullTexture.h" />
<ClInclude Include="VideoBackends\Null\NullVertexManager.h" />
<ClInclude Include="VideoBackends\Null\PerfQuery.h" />
@@ -588,6 +588,7 @@
<ClInclude Include="VideoBackends\Software\Rasterizer.h" />
<ClInclude Include="VideoBackends\Software\SetupUnit.h" />
<ClInclude Include="VideoBackends\Software\SWBoundingBox.h" />
+ <ClInclude Include="VideoBackends\Software\SWGfx.h" />
<ClInclude Include="VideoBackends\Software\SWOGLWindow.h" />
<ClInclude Include="VideoBackends\Software\SWRenderer.h" />
<ClInclude Include="VideoBackends\Software\SWTexture.h" />
@@ -1172,7 +1173,7 @@
<ClCompile Include="VideoBackends\D3DCommon\Shader.cpp" />
<ClCompile Include="VideoBackends\D3DCommon\SwapChain.cpp" />
<ClCompile Include="VideoBackends\Null\NullBackend.cpp" />
- <ClCompile Include="VideoBackends\Null\NullRender.cpp" />
+ <ClCompile Include="VideoBackends\Null\NullGfx.cpp" />
<ClCompile Include="VideoBackends\Null\NullTexture.cpp" />
<ClCompile Include="VideoBackends\Null\NullVertexManager.cpp" />
<ClCompile Include="VideoBackends\OGL\OGLBoundingBox.cpp" />
@@ -1195,6 +1196,7 @@
<ClCompile Include="VideoBackends\Software\SetupUnit.cpp" />
<ClCompile Include="VideoBackends\Software\SWmain.cpp" />
<ClCompile Include="VideoBackends\Software\SWBoundingBox.cpp" />
+ <ClCompile Include="VideoBackends\Software\SWGfx.cpp" />
<ClCompile Include="VideoBackends\Software\SWOGLWindow.cpp" />
<ClCompile Include="VideoBackends\Software\SWRenderer.cpp" />
<ClCompile Include="VideoBackends\Software\SWTexture.cpp" />
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<Renderer>();
+ g_gfx = std::make_unique<NullGfx>();
+ g_renderer = std::make_unique<NullRenderer>();
+ g_bounding_box = std::make_unique<NullBoundingBox>();
g_vertex_manager = std::make_unique<VertexManager>();
g_perf_query = std::make_unique<PerfQuery>();
- g_framebuffer_manager = std::make_unique<FramebufferManager>();
- g_texture_cache = std::make_unique<TextureCache>();
- g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
- 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<AbstractTexture> NullGfx::CreateTexture(const TextureConfig& config,
+ [[maybe_unused]] std::string_view name)
+{
+ return std::make_unique<NullTexture>(config);
+}
+
+std::unique_ptr<AbstractStagingTexture> NullGfx::CreateStagingTexture(StagingTextureType type,
+ const TextureConfig& config)
+{
+ return std::make_unique<NullStagingTexture>(type, config);
+}
+
+class NullShader final : public AbstractShader
+{
+public:
+ explicit NullShader(ShaderStage stage) : AbstractShader(stage) {}
+};
+
+std::unique_ptr<AbstractShader>
+NullGfx::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source,
+ [[maybe_unused]] std::string_view name)
+{
+ return std::make_unique<NullShader>(stage);
+}
+
+std::unique_ptr<AbstractShader>
+NullGfx::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length,
+ [[maybe_unused]] std::string_view name)
+{
+ return std::make_unique<NullShader>(stage);
+}
+
+class NullPipeline final : public AbstractPipeline
+{
+};
+
+std::unique_ptr<AbstractPipeline> NullGfx::CreatePipeline(const AbstractPipelineConfig& config,
+ const void* cache_data,
+ size_t cache_data_length)
+{
+ return std::make_unique<NullPipeline>();
+}
+
+std::unique_ptr<AbstractFramebuffer> NullGfx::CreateFramebuffer(AbstractTexture* color_attachment,
+ AbstractTexture* depth_attachment)
+{
+ return NullFramebuffer::Create(static_cast<NullTexture*>(color_attachment),
+ static_cast<NullTexture*>(depth_attachment));
+}
+
+std::unique_ptr<NativeVertexFormat>
+NullGfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
+{
+ return std::make_unique<NativeVertexFormat>(vtx_decl);
+}
+
+NullRenderer::~NullRenderer() = default;
+
+} // namespace Null
diff --git a/Source/Core/VideoBackends/Null/NullRender.h b/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<AbstractPipeline> 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<int>& rc, bool colorEnable, bool alphaEnable,
- bool zEnable, u32 color, u32 z) override
- {
- }
-
void ReinterpretPixelData(EFBReinterpretType convtype) override {}
-
-protected:
- std::unique_ptr<BoundingBox> 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<AbstractTexture> Renderer::CreateTexture(const TextureConfig& config,
- [[maybe_unused]] std::string_view name)
-{
- return std::make_unique<NullTexture>(config);
-}
-
-std::unique_ptr<AbstractStagingTexture> Renderer::CreateStagingTexture(StagingTextureType type,
- const TextureConfig& config)
-{
- return std::make_unique<NullStagingTexture>(type, config);
-}
-
-class NullShader final : public AbstractShader
-{
-public:
- explicit NullShader(ShaderStage stage) : AbstractShader(stage) {}
-};
-
-std::unique_ptr<AbstractShader>
-Renderer::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source,
- [[maybe_unused]] std::string_view name)
-{
- return std::make_unique<NullShader>(stage);
-}
-
-std::unique_ptr<AbstractShader>
-Renderer::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length,
- [[maybe_unused]] std::string_view name)
-{
- return std::make_unique<NullShader>(stage);
-}
-
-class NullPipeline final : public AbstractPipeline
-{
-};
-
-std::unique_ptr<AbstractPipeline> Renderer::CreatePipeline(const AbstractPipelineConfig& config,
- const void* cache_data,
- size_t cache_data_length)
-{
- return std::make_unique<NullPipeline>();
-}
-
-std::unique_ptr<AbstractFramebuffer> Renderer::CreateFramebuffer(AbstractTexture* color_attachment,
- AbstractTexture* depth_attachment)
-{
- return NullFramebuffer::Create(static_cast<NullTexture*>(color_attachment),
- static_cast<NullTexture*>(depth_attachment));
-}
-
-std::unique_ptr<NativeVertexFormat>
-Renderer::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
-{
- return std::make_unique<NativeVertexFormat>(vtx_decl);
-}
-
-std::unique_ptr<BoundingBox> Renderer::CreateBoundingBox() const
-{
- return std::make_unique<NullBoundingBox>();
-}
-} // 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<SWOGLWindow> window) : m_window(std::move(window))
+{
+}
+
+bool SWGfx::IsHeadless() const
+{
+ return m_window->IsHeadless();
+}
+
+std::unique_ptr<AbstractTexture> SWGfx::CreateTexture(const TextureConfig& config,
+ [[maybe_unused]] std::string_view name)
+{
+ return std::make_unique<SWTexture>(config);
+}
+
+std::unique_ptr<AbstractStagingTexture> SWGfx::CreateStagingTexture(StagingTextureType type,
+ const TextureConfig& config)
+{
+ return std::make_unique<SWStagingTexture>(type, config);
+}
+
+std::unique_ptr<AbstractFramebuffer> SWGfx::CreateFramebuffer(AbstractTexture* color_attachment,
+ AbstractTexture* depth_attachment)
+{
+ return SWFramebuffer::Create(static_cast<SWTexture*>(color_attachment),
+ static_cast<SWTexture*>(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<AbstractShader>
+SWGfx::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source,
+ [[maybe_unused]] std::string_view name)
+{
+ return std::make_unique<SWShader>(stage);
+}
+
+std::unique_ptr<AbstractShader>
+SWGfx::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length,
+ [[maybe_unused]] std::string_view name)
+{
+ return std::make_unique<SWShader>(stage);
+}
+
+class SWPipeline final : public AbstractPipeline
+{
+public:
+ SWPipeline() = default;
+ ~SWPipeline() override = default;
+};
+
+std::unique_ptr<AbstractPipeline> SWGfx::CreatePipeline(const AbstractPipelineConfig& config,
+ const void* cache_data,
+ size_t cache_data_length)
+{
+ return std::make_unique<SWPipeline>();
+}
+
+// Called on the GPU thread
+void SWGfx::ShowImage(const AbstractTexture* source_texture,
+ const MathUtil::Rectangle<int>& source_rc)
+{
+ if (!IsHeadless())
+ m_window->ShowImage(source_texture, source_rc);
+}
+
+void SWGfx::ClearRegion(const MathUtil::Rectangle<int>& rc,
+ const MathUtil::Rectangle<int>& target_rc, bool colorEnable,
+ bool alphaEnable, bool zEnable, u32 color, u32 z)
+{
+ EfbCopy::ClearEfb();
+}
+
+std::unique_ptr<NativeVertexFormat>
+SWGfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
+{
+ return std::make_unique<NativeVertexFormat>(vtx_decl);
+}
+
+void SWGfx::SetScissorRect(const MathUtil::Rectangle<int>& 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<SWOGLWindow> window);
+
+ bool IsHeadless() const override;
+
+ std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config,
+ std::string_view name) override;
+ std::unique_ptr<AbstractStagingTexture>
+ CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
+ std::unique_ptr<AbstractFramebuffer>
+ CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override;
+
+ void BindBackbuffer(const ClearColor& clear_color = {}) override;
+
+ std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage, std::string_view source,
+ std::string_view name) override;
+ std::unique_ptr<AbstractShader> CreateShaderFromBinary(ShaderStage stage, const void* data,
+ size_t length,
+ std::string_view name) override;
+ std::unique_ptr<NativeVertexFormat>
+ CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override;
+ std::unique_ptr<AbstractPipeline> 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<int>& source_rc) override;
+
+ void ScaleTexture(AbstractFramebuffer* dst_framebuffer, const MathUtil::Rectangle<int>& dst_rect,
+ const AbstractTexture* src_texture,
+ const MathUtil::Rectangle<int>& src_rect) override;
+
+ void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
+
+ void ClearRegion(const MathUtil::Rectangle<int>& rc, const MathUtil::Rectangle<int>& target_rc,
+ bool colorEnable, bool alphaEnable, bool zEnable, u32 color, u32 z) override;
+
+private:
+ std::unique_ptr<SWOGLWindow> 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 <string>
#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<SWOGLWindow> window)
- : ::Renderer(static_cast<int>(std::max(window->GetContext()->GetBackBufferWidth(), 1u)),
- static_cast<int>(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<AbstractTexture> SWRenderer::CreateTexture(const TextureConfig& config,
- [[maybe_unused]] std::string_view name)
-{
- return std::make_unique<SWTexture>(config);
-}
-
-std::unique_ptr<AbstractStagingTexture>
-SWRenderer::CreateStagingTexture(StagingTextureType type, const TextureConfig& config)
-{
- return std::make_unique<SWStagingTexture>(type, config);
-}
-
-std::unique_ptr<AbstractFramebuffer>
-SWRenderer::CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment)
-{
- return SWFramebuffer::Create(static_cast<SWTexture*>(color_attachment),
- static_cast<SWTexture*>(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<AbstractShader>
-SWRenderer::CreateShaderFromSource(ShaderStage stage, [[maybe_unused]] std::string_view source,
- [[maybe_unused]] std::string_view name)
-{
- return std::make_unique<SWShader>(stage);
-}
-
-std::unique_ptr<AbstractShader>
-SWRenderer::CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length,
- [[maybe_unused]] std::string_view name)
-{
- return std::make_unique<SWShader>(stage);
-}
-
-class SWPipeline final : public AbstractPipeline
-{
-public:
- SWPipeline() = default;
- ~SWPipeline() override = default;
-};
-
-std::unique_ptr<AbstractPipeline> SWRenderer::CreatePipeline(const AbstractPipelineConfig& config,
- const void* cache_data,
- size_t cache_data_length)
-{
- return std::make_unique<SWPipeline>();
-}
-
-// Called on the GPU thread
-void SWRenderer::ShowImage(const AbstractTexture* source_texture,
- const MathUtil::Rectangle<int>& 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<BoundingBox> SWRenderer::CreateBoundingBox() const
-{
- return std::make_unique<SWBoundingBox>();
-}
-
-void SWRenderer::ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
- bool zEnable, u32 color, u32 z)
-{
- EfbCopy::ClearEfb();
-}
-
-std::unique_ptr<NativeVertexFormat>
-SWRenderer::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
-{
- return std::make_unique<NativeVertexFormat>(vtx_decl);
-}
-
-void SWRenderer::SetScissorRect(const MathUtil::Rectangle<int>& 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<SWOGLWindow> window);
-
- bool IsHeadless() const override;
-
- std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config,
- std::string_view name) override;
- std::unique_ptr<AbstractStagingTexture>
- CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
- std::unique_ptr<AbstractFramebuffer>
- CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override;
-
- void BindBackbuffer(const ClearColor& clear_color = {}) override;
-
- std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage, std::string_view source,
- std::string_view name) override;
- std::unique_ptr<AbstractShader> CreateShaderFromBinary(ShaderStage stage, const void* data,
- size_t length,
- std::string_view name) override;
- std::unique_ptr<NativeVertexFormat>
- CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override;
- std::unique_ptr<AbstractPipeline> 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<int>& source_rc) override;
-
- void ClearScreen(const MathUtil::Rectangle<int>& 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<int>& dst_rect,
- const AbstractTexture* src_texture,
- const MathUtil::Rectangle<int>& src_rect) override;
-
- void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
-
-protected:
- std::unique_ptr<BoundingBox> CreateBoundingBox() const override;
-
-private:
- std::unique_ptr<SWOGLWindow> 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<int>& dst_rect,
- const AbstractTexture* src_texture,
- const MathUtil::Rectangle<int>& src_rect)
+void SWGfx::ScaleTexture(AbstractFramebuffer* dst_framebuffer,
+ const MathUtil::Rectangle<int>& dst_rect,
+ const AbstractTexture* src_texture,
+ const MathUtil::Rectangle<int>& src_rect)
{
const SWTexture* software_source_texture = static_cast<const SWTexture*>(src_texture);
SWTexture* software_dest_texture = static_cast<SWTexture*>(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<SWOGLWindow> 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<SWRenderer>(std::move(window));
+ g_gfx = std::make_unique<SWGfx>(std::move(window));
+ g_bounding_box = std::make_unique<SWBoundingBox>();
g_vertex_manager = std::make_unique<SWVertexLoader>();
- g_shader_cache = std::make_unique<VideoCommon::ShaderCache>();
- g_framebuffer_manager = std::make_unique<FramebufferManager>();
g_perf_query = std::make_unique<PerfQuery>();
- g_texture_cache = std::make_unique<TextureCache>();
-
- 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/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<float, 4>;
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<int>& rc, bool colorEnable, bool alphaEnable,
- bool zEnable, u32 color, u32 z);
+ void ClearScreen(const MathUtil::Rectangle<int>& rc, bool colorEnable, bool alphaEnable,
+ bool zEnable, u32 color, u32 z);
virtual void ReinterpretPixelData(EFBReinterpretType convtype);
void RenderToXFB(u32 xfbAddr, const MathUtil::Rectangle<int>& sourceRc, u32 fbStride,
u32 fbHeight, float Gamma = 1.0f);