mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-01-24 15:01:16 +01:00
Implement AbstractGfx for Software & Null
This commit is contained in:
parent
f0336a3129
commit
d37f83ffeb
@ -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" />
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
90
Source/Core/VideoBackends/Null/NullGfx.cpp
Normal file
90
Source/Core/VideoBackends/Null/NullGfx.cpp
Normal file
@ -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
|
@ -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
|
@ -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
|
@ -14,6 +14,8 @@ add_library(videosoftware
|
||||
SWmain.cpp
|
||||
SWBoundingBox.cpp
|
||||
SWBoundingBox.h
|
||||
SWGfx.cpp
|
||||
SWGfx.h
|
||||
SWOGLWindow.cpp
|
||||
SWOGLWindow.h
|
||||
SWRenderer.cpp
|
||||
|
127
Source/Core/VideoBackends/Software/SWGfx.cpp
Normal file
127
Source/Core/VideoBackends/Software/SWGfx.cpp
Normal file
@ -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
|
55
Source/Core/VideoBackends/Software/SWGfx.h
Normal file
55
Source/Core/VideoBackends/Software/SWGfx.h
Normal file
@ -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
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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());
|
||||
|
@ -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;
|
||||
}
|
||||
InitializeShared();
|
||||
|
||||
g_shader_cache->InitializeShaderCache();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -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) {}
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user