diff --git a/Source/Core/DolphinLib.props b/Source/Core/DolphinLib.props
index b244c00e98..4df8e0cd84 100644
--- a/Source/Core/DolphinLib.props
+++ b/Source/Core/DolphinLib.props
@@ -534,7 +534,7 @@
-
+
@@ -1148,7 +1148,7 @@
-
+
diff --git a/Source/Core/VideoBackends/D3D/CMakeLists.txt b/Source/Core/VideoBackends/D3D/CMakeLists.txt
index f296040526..ed75b29b77 100644
--- a/Source/Core/VideoBackends/D3D/CMakeLists.txt
+++ b/Source/Core/VideoBackends/D3D/CMakeLists.txt
@@ -7,8 +7,8 @@ add_library(videod3d
D3DNativeVertexFormat.cpp
D3DPerfQuery.cpp
D3DPerfQuery.h
- D3DRender.cpp
- D3DRender.h
+ D3DGfx.cpp
+ D3DGfx.h
D3DState.cpp
D3DState.h
D3DSwapChain.cpp
diff --git a/Source/Core/VideoBackends/D3D/D3DRender.cpp b/Source/Core/VideoBackends/D3D/D3DGfx.cpp
similarity index 73%
rename from Source/Core/VideoBackends/D3D/D3DRender.cpp
rename to Source/Core/VideoBackends/D3D/D3DGfx.cpp
index 6e045979cb..dc391f08b3 100644
--- a/Source/Core/VideoBackends/D3D/D3DRender.cpp
+++ b/Source/Core/VideoBackends/D3D/D3DGfx.cpp
@@ -1,7 +1,7 @@
// Copyright 2010 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
-#include "VideoBackends/D3D/D3DRender.h"
+#include "VideoBackends/D3D/D3DGfx.h"
#include
#include
@@ -37,34 +37,31 @@
namespace DX11
{
-Renderer::Renderer(std::unique_ptr swap_chain, float backbuffer_scale)
- : ::Renderer(swap_chain ? swap_chain->GetWidth() : 0, swap_chain ? swap_chain->GetHeight() : 0,
- backbuffer_scale,
- swap_chain ? swap_chain->GetFormat() : AbstractTextureFormat::Undefined),
- m_swap_chain(std::move(swap_chain))
+Gfx::Gfx(std::unique_ptr swap_chain, float backbuffer_scale)
+ : m_backbuffer_scale(backbuffer_scale), m_swap_chain(std::move(swap_chain))
{
}
-Renderer::~Renderer() = default;
+Gfx::~Gfx() = default;
-bool Renderer::IsHeadless() const
+bool Gfx::IsHeadless() const
{
return !m_swap_chain;
}
-std::unique_ptr Renderer::CreateTexture(const TextureConfig& config,
+std::unique_ptr Gfx::CreateTexture(const TextureConfig& config,
std::string_view name)
{
return DXTexture::Create(config, name);
}
-std::unique_ptr Renderer::CreateStagingTexture(StagingTextureType type,
+std::unique_ptr Gfx::CreateStagingTexture(StagingTextureType type,
const TextureConfig& config)
{
return DXStagingTexture::Create(type, config);
}
-std::unique_ptr Renderer::CreateFramebuffer(AbstractTexture* color_attachment,
+std::unique_ptr Gfx::CreateFramebuffer(AbstractTexture* color_attachment,
AbstractTexture* depth_attachment)
{
return DXFramebuffer::Create(static_cast(color_attachment),
@@ -72,7 +69,7 @@ std::unique_ptr Renderer::CreateFramebuffer(AbstractTexture
}
std::unique_ptr
-Renderer::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::string_view name)
+Gfx::CreateShaderFromSource(ShaderStage stage, std::string_view source, std::string_view name)
{
auto bytecode = DXShader::CompileShader(D3D::feature_level, stage, source);
if (!bytecode)
@@ -81,21 +78,21 @@ Renderer::CreateShaderFromSource(ShaderStage stage, std::string_view source, std
return DXShader::CreateFromBytecode(stage, std::move(*bytecode), name);
}
-std::unique_ptr Renderer::CreateShaderFromBinary(ShaderStage stage,
+std::unique_ptr Gfx::CreateShaderFromBinary(ShaderStage stage,
const void* data, size_t length,
std::string_view name)
{
return DXShader::CreateFromBytecode(stage, DXShader::CreateByteCode(data, length), name);
}
-std::unique_ptr Renderer::CreatePipeline(const AbstractPipelineConfig& config,
+std::unique_ptr Gfx::CreatePipeline(const AbstractPipelineConfig& config,
const void* cache_data,
size_t cache_data_length)
{
return DXPipeline::Create(config);
}
-void Renderer::SetPipeline(const AbstractPipeline* pipeline)
+void Gfx::SetPipeline(const AbstractPipeline* pipeline)
{
const DXPipeline* dx_pipeline = static_cast(pipeline);
if (m_current_pipeline == dx_pipeline)
@@ -123,7 +120,7 @@ void Renderer::SetPipeline(const AbstractPipeline* pipeline)
}
}
-void Renderer::SetScissorRect(const MathUtil::Rectangle& rc)
+void Gfx::SetScissorRect(const MathUtil::Rectangle& rc)
{
// TODO: Move to stateman
const CD3D11_RECT rect(rc.left, rc.top, std::max(rc.right, rc.left + 1),
@@ -131,7 +128,7 @@ void Renderer::SetScissorRect(const MathUtil::Rectangle& rc)
D3D::context->RSSetScissorRects(1, &rect);
}
-void Renderer::SetViewport(float x, float y, float width, float height, float near_depth,
+void Gfx::SetViewport(float x, float y, float width, float height, float near_depth,
float far_depth)
{
// TODO: Move to stateman
@@ -139,19 +136,19 @@ void Renderer::SetViewport(float x, float y, float width, float height, float ne
D3D::context->RSSetViewports(1, &vp);
}
-void Renderer::Draw(u32 base_vertex, u32 num_vertices)
+void Gfx::Draw(u32 base_vertex, u32 num_vertices)
{
D3D::stateman->Apply();
D3D::context->Draw(num_vertices, base_vertex);
}
-void Renderer::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex)
+void Gfx::DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex)
{
D3D::stateman->Apply();
D3D::context->DrawIndexed(num_indices, base_index, base_vertex);
}
-void Renderer::DispatchComputeShader(const AbstractShader* shader, u32 groupsize_x, u32 groupsize_y,
+void Gfx::DispatchComputeShader(const AbstractShader* shader, u32 groupsize_x, u32 groupsize_y,
u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z)
{
D3D::stateman->SetComputeShader(static_cast(shader)->GetD3DComputeShader());
@@ -159,25 +156,25 @@ void Renderer::DispatchComputeShader(const AbstractShader* shader, u32 groupsize
D3D::context->Dispatch(groups_x, groups_y, groups_z);
}
-void Renderer::BindBackbuffer(const ClearColor& clear_color)
+void Gfx::BindBackbuffer(const ClearColor& clear_color)
{
CheckForSwapChainChanges();
SetAndClearFramebuffer(m_swap_chain->GetFramebuffer(), clear_color);
}
-void Renderer::PresentBackbuffer()
+void Gfx::PresentBackbuffer()
{
m_swap_chain->Present();
}
-void Renderer::OnConfigChanged(u32 bits)
+void Gfx::OnConfigChanged(u32 bits)
{
// Quad-buffer changes require swap chain recreation.
if (bits & CONFIG_CHANGE_BIT_STEREO_MODE && m_swap_chain)
m_swap_chain->SetStereo(SwapChain::WantsStereo());
}
-void Renderer::CheckForSwapChainChanges()
+void Gfx::CheckForSwapChainChanges()
{
const bool surface_changed = g_presenter->SurfaceChangedTestAndClear();
const bool surface_resized =
@@ -194,11 +191,10 @@ void Renderer::CheckForSwapChainChanges()
m_swap_chain->ResizeSwapChain();
}
- m_backbuffer_width = m_swap_chain->GetWidth();
- m_backbuffer_height = m_swap_chain->GetHeight();
+ g_presenter->SetBackbuffer(m_swap_chain->GetWidth(), m_swap_chain->GetHeight());
}
-void Renderer::SetFramebuffer(AbstractFramebuffer* framebuffer)
+void Gfx::SetFramebuffer(AbstractFramebuffer* framebuffer)
{
if (m_current_framebuffer == framebuffer)
return;
@@ -219,12 +215,12 @@ void Renderer::SetFramebuffer(AbstractFramebuffer* framebuffer)
m_current_framebuffer = fb;
}
-void Renderer::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
+void Gfx::SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer)
{
SetFramebuffer(framebuffer);
}
-void Renderer::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
+void Gfx::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
const ClearColor& color_value, float depth_value)
{
SetFramebuffer(framebuffer);
@@ -242,53 +238,58 @@ void Renderer::SetAndClearFramebuffer(AbstractFramebuffer* framebuffer,
}
}
-void Renderer::SetTexture(u32 index, const AbstractTexture* texture)
+void Gfx::SetTexture(u32 index, const AbstractTexture* texture)
{
D3D::stateman->SetTexture(index, texture ? static_cast(texture)->GetD3DSRV() :
nullptr);
}
-void Renderer::SetSamplerState(u32 index, const SamplerState& state)
+void Gfx::SetSamplerState(u32 index, const SamplerState& state)
{
D3D::stateman->SetSampler(index, m_state_cache.Get(state));
}
-void Renderer::SetComputeImageTexture(AbstractTexture* texture, bool read, bool write)
+void Gfx::SetComputeImageTexture(AbstractTexture* texture, bool read, bool write)
{
D3D::stateman->SetComputeUAV(texture ? static_cast(texture)->GetD3DUAV() : nullptr);
}
-void Renderer::UnbindTexture(const AbstractTexture* texture)
+void Gfx::UnbindTexture(const AbstractTexture* texture)
{
if (D3D::stateman->UnsetTexture(static_cast(texture)->GetD3DSRV()) != 0)
D3D::stateman->ApplyTextures();
}
-std::unique_ptr Renderer::CreateBoundingBox() const
-{
- return std::make_unique();
-}
-
-void Renderer::Flush()
+void Gfx::Flush()
{
D3D::context->Flush();
}
-void Renderer::WaitForGPUIdle()
+void Gfx::WaitForGPUIdle()
{
// There is no glFinish() equivalent in D3D.
D3D::context->Flush();
}
-void Renderer::SetFullscreen(bool enable_fullscreen)
+void Gfx::SetFullscreen(bool enable_fullscreen)
{
if (m_swap_chain)
m_swap_chain->SetFullscreen(enable_fullscreen);
}
-bool Renderer::IsFullscreen() const
+bool Gfx::IsFullscreen() const
{
return m_swap_chain && m_swap_chain->GetFullscreen();
}
+SurfaceInfo Gfx::GetSurfaceInfo() const
+{
+ return {
+ m_swap_chain ? static_cast(m_swap_chain->GetWidth()) : 0,
+ m_swap_chain ? static_cast(m_swap_chain->GetHeight()) : 0,
+ m_backbuffer_scale,
+ m_swap_chain ? m_swap_chain->GetFormat() : AbstractTextureFormat::Undefined
+ };
+}
+
} // namespace DX11
diff --git a/Source/Core/VideoBackends/D3D/D3DRender.h b/Source/Core/VideoBackends/D3D/D3DGfx.h
similarity index 92%
rename from Source/Core/VideoBackends/D3D/D3DRender.h
rename to Source/Core/VideoBackends/D3D/D3DGfx.h
index a0d25bc270..8bbf998e36 100644
--- a/Source/Core/VideoBackends/D3D/D3DRender.h
+++ b/Source/Core/VideoBackends/D3D/D3DGfx.h
@@ -6,7 +6,7 @@
#include
#include
#include "VideoBackends/D3D/D3DState.h"
-#include "VideoCommon/RenderBase.h"
+#include "VideoCommon/AbstractGfx.h"
class BoundingBox;
@@ -16,11 +16,11 @@ class SwapChain;
class DXTexture;
class DXFramebuffer;
-class Renderer : public ::Renderer
+class Gfx : public ::AbstractGfx
{
public:
- Renderer(std::unique_ptr swap_chain, float backbuffer_scale);
- ~Renderer() override;
+ Gfx(std::unique_ptr swap_chain, float backbuffer_scale);
+ ~Gfx() override;
StateCache& GetStateCache() { return m_state_cache; }
@@ -69,14 +69,14 @@ public:
void OnConfigChanged(u32 bits) override;
-protected:
- std::unique_ptr CreateBoundingBox() const override;
+ SurfaceInfo GetSurfaceInfo() const override;
private:
void CheckForSwapChainChanges();
StateCache m_state_cache;
+ float m_backbuffer_scale;
std::unique_ptr m_swap_chain;
};
} // namespace DX11
diff --git a/Source/Core/VideoBackends/D3D/D3DMain.cpp b/Source/Core/VideoBackends/D3D/D3DMain.cpp
index 1748a0b3fc..ae2e0cd959 100644
--- a/Source/Core/VideoBackends/D3D/D3DMain.cpp
+++ b/Source/Core/VideoBackends/D3D/D3DMain.cpp
@@ -14,11 +14,12 @@
#include "VideoBackends/D3D/D3DBase.h"
#include "VideoBackends/D3D/D3DBoundingBox.h"
#include "VideoBackends/D3D/D3DPerfQuery.h"
-#include "VideoBackends/D3D/D3DRender.h"
+#include "VideoBackends/D3D/D3DGfx.h"
#include "VideoBackends/D3D/D3DSwapChain.h"
#include "VideoBackends/D3D/D3DVertexManager.h"
#include "VideoBackends/D3DCommon/D3DCommon.h"
+#include "VideoCommon/AbstractGfx.h"
#include "VideoCommon/FramebufferManager.h"
#include "VideoCommon/ShaderCache.h"
#include "VideoCommon/TextureCacheBase.h"
@@ -143,7 +144,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
return false;
FillBackendInfo();
- InitializeShared();
+ UpdateActiveConfig();
std::unique_ptr swap_chain;
if (wsi.render_surface && !(swap_chain = SwapChain::Create(wsi)))
@@ -154,22 +155,13 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
return false;
}
- g_renderer = std::make_unique(std::move(swap_chain), wsi.render_surface_scale);
- g_vertex_manager = std::make_unique();
- g_shader_cache = std::make_unique();
- g_framebuffer_manager = std::make_unique();
- g_texture_cache = std::make_unique();
- g_perf_query = std::make_unique();
- if (!g_vertex_manager->Initialize() || !g_shader_cache->Initialize() ||
- !g_renderer->Initialize() || !g_framebuffer_manager->Initialize() ||
- !g_texture_cache->Initialize())
- {
- Shutdown();
- return false;
- }
+ auto gfx = std::make_unique(std::move(swap_chain), wsi.render_surface_scale);
+ auto vertex_manager = std::make_unique();
+ auto perf_query = std::make_unique();
+ auto bounding_box = std::make_unique();
- g_shader_cache->InitializeShaderCache();
- return true;
+ return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
+ std::move(bounding_box));
}
void VideoBackend::Shutdown()
diff --git a/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp b/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp
index aca5a177fa..54c1ae8220 100644
--- a/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp
+++ b/Source/Core/VideoBackends/D3D/D3DNativeVertexFormat.cpp
@@ -7,7 +7,7 @@
#include "Common/EnumMap.h"
#include "VideoBackends/D3D/D3DBase.h"
-#include "VideoBackends/D3D/D3DRender.h"
+#include "VideoBackends/D3D/D3DGfx.h"
#include "VideoBackends/D3D/D3DState.h"
#include "VideoBackends/D3D/D3DVertexManager.h"
#include "VideoBackends/D3D/DXShader.h"
@@ -18,7 +18,7 @@ namespace DX11
std::mutex s_input_layout_lock;
std::unique_ptr
-Renderer::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
+Gfx::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
{
return std::make_unique(vtx_decl);
}
diff --git a/Source/Core/VideoBackends/D3D/D3DVertexManager.cpp b/Source/Core/VideoBackends/D3D/D3DVertexManager.cpp
index ce41e90e31..4aa1c40266 100644
--- a/Source/Core/VideoBackends/D3D/D3DVertexManager.cpp
+++ b/Source/Core/VideoBackends/D3D/D3DVertexManager.cpp
@@ -13,7 +13,7 @@
#include "VideoBackends/D3D/D3DBase.h"
#include "VideoBackends/D3D/D3DBoundingBox.h"
-#include "VideoBackends/D3D/D3DRender.h"
+#include "VideoBackends/D3D/D3DGfx.h"
#include "VideoBackends/D3D/D3DState.h"
#include "VideoBackends/D3DCommon/D3DCommon.h"
diff --git a/Source/Core/VideoBackends/D3D/DXPipeline.cpp b/Source/Core/VideoBackends/D3D/DXPipeline.cpp
index 0bdfeb0012..3553e8d512 100644
--- a/Source/Core/VideoBackends/D3D/DXPipeline.cpp
+++ b/Source/Core/VideoBackends/D3D/DXPipeline.cpp
@@ -7,7 +7,7 @@
#include "Common/Logging/Log.h"
#include "VideoBackends/D3D/D3DBase.h"
-#include "VideoBackends/D3D/D3DRender.h"
+#include "VideoBackends/D3D/D3DGfx.h"
#include "VideoBackends/D3D/D3DState.h"
#include "VideoBackends/D3D/D3DVertexManager.h"
#include "VideoBackends/D3D/DXShader.h"
@@ -32,7 +32,7 @@ DXPipeline::~DXPipeline() = default;
std::unique_ptr DXPipeline::Create(const AbstractPipelineConfig& config)
{
- StateCache& state_cache = static_cast(g_renderer.get())->GetStateCache();
+ StateCache& state_cache = static_cast(g_gfx.get())->GetStateCache();
ID3D11RasterizerState* rasterizer_state = state_cache.Get(config.rasterization_state);
ID3D11DepthStencilState* depth_state = state_cache.Get(config.depth_state);
ID3D11BlendState* blend_state = state_cache.Get(config.blending_state);