mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-02-18 22:37:42 -07:00
VideoBackends: Use System parameters instead of System::GetInstance
This commit is contained in:
parent
6feb2a0bcd
commit
d8cd227ac2
@ -457,14 +457,14 @@ static void FifoPlayerThread(Core::System& system, const std::optional<std::stri
|
||||
AsyncRequests::GetInstance()->SetPassthrough(!system.IsDualCoreMode());
|
||||
|
||||
// Must happen on the proper thread for some video backends, e.g. OpenGL.
|
||||
return g_video_backend->Initialize(wsi);
|
||||
return g_video_backend->Initialize(system, wsi);
|
||||
};
|
||||
|
||||
const auto deinit_video = [] {
|
||||
auto deinit_video = [&] {
|
||||
// Clear on screen messages that haven't expired
|
||||
OSD::ClearMessages();
|
||||
|
||||
g_video_backend->Shutdown();
|
||||
g_video_backend->Shutdown(system);
|
||||
};
|
||||
|
||||
if (system.IsDualCoreMode())
|
||||
@ -472,7 +472,11 @@ static void FifoPlayerThread(Core::System& system, const std::optional<std::stri
|
||||
std::promise<bool> init_from_thread;
|
||||
|
||||
// Spawn the GPU thread.
|
||||
std::thread gpu_thread{[&] {
|
||||
// Capture deinit_video by value to prevent a reference to it from being used by gpu_thread
|
||||
// after GetInitializedVideoGuard returns. init_video doesn't need to be captured by value
|
||||
// because it's only used before init_from_thread is set, while GetInitializedVideoGuard waits
|
||||
// on init_from_thread below and can only return after that.
|
||||
std::thread gpu_thread{[&, deinit_video] {
|
||||
Common::SetCurrentThreadName("Video thread");
|
||||
|
||||
const bool is_init = init_video();
|
||||
@ -503,7 +507,7 @@ static void FifoPlayerThread(Core::System& system, const std::optional<std::stri
|
||||
else // SingleCore mode
|
||||
{
|
||||
if (init_video())
|
||||
return std::make_unique<GuardType>(deinit_video);
|
||||
return std::make_unique<GuardType>(std::move(deinit_video));
|
||||
}
|
||||
|
||||
return ReturnType{};
|
||||
|
||||
@ -864,7 +864,7 @@ void VideoInterfaceManager::OutputField(FieldType field, u64 ticks)
|
||||
// can change the register values during scanout. To correctly emulate the scanout process, we
|
||||
// would need to collate all changes to the VI registers during scanout.
|
||||
if (xfbAddr)
|
||||
g_video_backend->Video_OutputXFB(xfbAddr, fbWidth, fbStride, fbHeight, ticks);
|
||||
g_video_backend->Video_OutputXFB(m_system, xfbAddr, fbWidth, fbStride, fbHeight, ticks);
|
||||
}
|
||||
|
||||
void VideoInterfaceManager::BeginField(FieldType field, u64 ticks)
|
||||
|
||||
@ -175,7 +175,7 @@ static void DoState(Core::System& system, PointerWrap& p)
|
||||
|
||||
// Begin with video backend, so that it gets a chance to clear its caches and writeback modified
|
||||
// things to RAM
|
||||
g_video_backend->DoState(p);
|
||||
g_video_backend->DoState(system, p);
|
||||
p.DoMarker("video_backend");
|
||||
|
||||
// CoreTiming needs to be restored before restoring Hardware because
|
||||
|
||||
@ -26,6 +26,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
std::string VideoBackend::GetConfigName() const
|
||||
@ -139,7 +144,7 @@ void VideoBackend::FillBackendInfo()
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
if (!D3D::Create(g_Config.iAdapter, g_Config.bEnableValidationLayer))
|
||||
return false;
|
||||
@ -151,7 +156,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
if (wsi.render_surface && !(swap_chain = SwapChain::Create(wsi)))
|
||||
{
|
||||
PanicAlertFmtT("Failed to create D3D swap chain");
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
D3D::Destroy();
|
||||
return false;
|
||||
}
|
||||
@ -161,13 +166,13 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
auto perf_query = std::make_unique<PerfQuery>();
|
||||
auto bounding_box = std::make_unique<D3DBoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
D3D::Destroy();
|
||||
}
|
||||
} // namespace DX11
|
||||
|
||||
@ -4,15 +4,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
class VideoBackend : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -24,6 +24,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX12
|
||||
{
|
||||
std::string VideoBackend::GetConfigName() const
|
||||
@ -104,7 +109,7 @@ void VideoBackend::FillBackendInfo()
|
||||
}
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
if (!DXContext::Create(g_Config.iAdapter, g_Config.bEnableValidationLayer))
|
||||
{
|
||||
@ -119,7 +124,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
{
|
||||
PanicAlertFmtT("Failed to create D3D12 global resources");
|
||||
DXContext::Destroy();
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -128,7 +133,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
{
|
||||
PanicAlertFmtT("Failed to create D3D swap chain");
|
||||
DXContext::Destroy();
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -138,17 +143,17 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
auto perf_query = std::make_unique<DX12::PerfQuery>();
|
||||
auto bounding_box = std::make_unique<DX12::D3D12BoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
// Keep the debug runtime happy...
|
||||
if (g_gfx)
|
||||
Gfx::GetInstance()->ExecuteCommandList(true);
|
||||
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
DXContext::Destroy();
|
||||
}
|
||||
} // namespace DX12
|
||||
|
||||
@ -7,13 +7,18 @@
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace DX12
|
||||
{
|
||||
class VideoBackend final : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -29,6 +29,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
std::string Metal::VideoBackend::GetConfigName() const
|
||||
{
|
||||
return CONFIG_NAME;
|
||||
@ -63,7 +68,7 @@ static bool WindowSystemTypeSupportsMetal(WindowSystemType type)
|
||||
}
|
||||
}
|
||||
|
||||
bool Metal::VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool Metal::VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
@autoreleasepool
|
||||
{
|
||||
@ -125,15 +130,16 @@ bool Metal::VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
ObjectCache::Initialize(std::move(adapter));
|
||||
g_state_tracker = std::make_unique<StateTracker>();
|
||||
|
||||
return InitializeShared(
|
||||
std::make_unique<Metal::Gfx>(std::move(layer)), std::make_unique<Metal::VertexManager>(),
|
||||
std::make_unique<Metal::PerfQuery>(), std::make_unique<Metal::BoundingBox>());
|
||||
return InitializeShared(system, std::make_unique<Metal::Gfx>(std::move(layer)),
|
||||
std::make_unique<Metal::VertexManager>(),
|
||||
std::make_unique<Metal::PerfQuery>(),
|
||||
std::make_unique<Metal::BoundingBox>());
|
||||
}
|
||||
}
|
||||
|
||||
void Metal::VideoBackend::Shutdown()
|
||||
void Metal::VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
|
||||
g_state_tracker.reset();
|
||||
ObjectCache::Shutdown();
|
||||
|
||||
@ -4,15 +4,21 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Metal
|
||||
{
|
||||
class VideoBackend : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -19,6 +19,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Null
|
||||
{
|
||||
void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
|
||||
@ -65,16 +70,16 @@ void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
|
||||
g_backend_info.AAModes = {1};
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
return InitializeShared(std::make_unique<NullGfx>(), std::make_unique<VertexManager>(),
|
||||
return InitializeShared(system, std::make_unique<NullGfx>(), std::make_unique<VertexManager>(),
|
||||
std::make_unique<PerfQuery>(), std::make_unique<NullBoundingBox>(),
|
||||
std::make_unique<NullEFBInterface>(), std::make_unique<TextureCache>());
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
}
|
||||
|
||||
std::string VideoBackend::GetDisplayName() const
|
||||
|
||||
@ -3,15 +3,22 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Null
|
||||
{
|
||||
class VideoBackend final : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override { return CONFIG_NAME; }
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -59,6 +59,11 @@ Make AA apply instantly during gameplay if possible
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace OGL
|
||||
{
|
||||
std::string VideoBackend::GetConfigName() const
|
||||
@ -193,7 +198,7 @@ bool VideoBackend::FillBackendInfo(GLContext* context)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
std::unique_ptr<GLContext> main_gl_context =
|
||||
GLContext::Create(wsi, g_Config.stereo_mode == StereoMode::QuadBuffer, true, false,
|
||||
@ -212,13 +217,13 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
auto perf_query = GetPerfQuery(gfx->IsGLES());
|
||||
auto bounding_box = std::make_unique<OGLBoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
|
||||
ProgramShaderCache::Shutdown();
|
||||
g_sampler_cache.reset();
|
||||
|
||||
@ -4,8 +4,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
class GLContext;
|
||||
|
||||
namespace OGL
|
||||
@ -13,8 +19,8 @@ namespace OGL
|
||||
class VideoBackend : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -23,6 +23,11 @@
|
||||
#include "VideoCommon/VideoCommon.h"
|
||||
#include "VideoCommon/VideoConfig.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace SW
|
||||
{
|
||||
class PerfQuery : public PerfQueryBase
|
||||
@ -90,7 +95,7 @@ void VideoSoftware::InitBackendInfo(const WindowSystemInfo& wsi)
|
||||
g_backend_info.AAModes = {1};
|
||||
}
|
||||
|
||||
bool VideoSoftware::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoSoftware::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
std::unique_ptr<SWOGLWindow> window = SWOGLWindow::Create(wsi);
|
||||
if (!window)
|
||||
@ -99,14 +104,14 @@ bool VideoSoftware::Initialize(const WindowSystemInfo& wsi)
|
||||
Clipper::Init();
|
||||
Rasterizer::Init();
|
||||
|
||||
return InitializeShared(std::make_unique<SWGfx>(std::move(window)),
|
||||
return InitializeShared(system, std::make_unique<SWGfx>(std::move(window)),
|
||||
std::make_unique<SWVertexLoader>(), std::make_unique<PerfQuery>(),
|
||||
std::make_unique<SWBoundingBox>(), std::make_unique<SWEFBInterface>(),
|
||||
std::make_unique<TextureCache>());
|
||||
}
|
||||
|
||||
void VideoSoftware::Shutdown()
|
||||
void VideoSoftware::Shutdown(Core::System& system)
|
||||
{
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
}
|
||||
} // namespace SW
|
||||
|
||||
@ -4,14 +4,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace SW
|
||||
{
|
||||
class VideoSoftware : public VideoBackendBase
|
||||
{
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override;
|
||||
std::string GetDisplayName() const override;
|
||||
|
||||
@ -23,6 +23,11 @@
|
||||
#include <objc/message.h>
|
||||
#endif
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Vulkan
|
||||
{
|
||||
void VideoBackend::InitBackendInfo(const WindowSystemInfo& wsi)
|
||||
@ -88,7 +93,7 @@ static bool ShouldEnableDebugUtils(bool enable_validation_layers)
|
||||
return enable_validation_layers || IsHostGPULoggingEnabled();
|
||||
}
|
||||
|
||||
bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
bool VideoBackend::Initialize(Core::System& system, const WindowSystemInfo& wsi)
|
||||
{
|
||||
if (!LoadVulkanLibrary())
|
||||
{
|
||||
@ -192,7 +197,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
if (!g_object_cache->Initialize())
|
||||
{
|
||||
PanicAlertFmt("Failed to initialize Vulkan object cache.");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -204,7 +209,7 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
if (!swap_chain)
|
||||
{
|
||||
PanicAlertFmt("Failed to create Vulkan swap chain.");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -216,14 +221,14 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
if (!g_command_buffer_mgr->Initialize(swapchain_image_count))
|
||||
{
|
||||
PanicAlertFmt("Failed to create Vulkan command buffers");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!StateTracker::CreateInstance())
|
||||
{
|
||||
PanicAlertFmt("Failed to create state tracker");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -232,11 +237,11 @@ bool VideoBackend::Initialize(const WindowSystemInfo& wsi)
|
||||
auto perf_query = std::make_unique<PerfQuery>();
|
||||
auto bounding_box = std::make_unique<VKBoundingBox>();
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box));
|
||||
}
|
||||
|
||||
void VideoBackend::Shutdown()
|
||||
void VideoBackend::Shutdown(Core::System& system)
|
||||
{
|
||||
if (g_vulkan_context)
|
||||
vkDeviceWaitIdle(g_vulkan_context->GetDevice());
|
||||
@ -244,7 +249,7 @@ void VideoBackend::Shutdown()
|
||||
if (g_object_cache)
|
||||
g_object_cache->Shutdown();
|
||||
|
||||
ShutdownShared();
|
||||
ShutdownShared(system);
|
||||
|
||||
g_object_cache.reset();
|
||||
StateTracker::DestroyInstance();
|
||||
|
||||
@ -3,16 +3,23 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "Common/Common.h"
|
||||
#include "VideoCommon/VideoBackendBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace Vulkan
|
||||
{
|
||||
class VideoBackend : public VideoBackendBase
|
||||
{
|
||||
public:
|
||||
bool Initialize(const WindowSystemInfo& wsi) override;
|
||||
void Shutdown() override;
|
||||
bool Initialize(Core::System& system, const WindowSystemInfo& wsi) override;
|
||||
void Shutdown(Core::System& system) override;
|
||||
|
||||
std::string GetConfigName() const override { return CONFIG_NAME; }
|
||||
std::string GetDisplayName() const override { return _trans("Vulkan"); }
|
||||
|
||||
@ -111,12 +111,13 @@ void PixelEngineManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||
};
|
||||
for (auto& pq_reg : pq_regs)
|
||||
{
|
||||
mmio->Register(base | pq_reg.addr, MMIO::ComplexRead<u16>([pq_reg](Core::System&, u32) {
|
||||
return g_video_backend->Video_GetQueryResult(pq_reg.pqtype) & 0xFFFF;
|
||||
mmio->Register(base | pq_reg.addr, MMIO::ComplexRead<u16>([pq_reg](Core::System& system, u32) {
|
||||
return g_video_backend->Video_GetQueryResult(system, pq_reg.pqtype) & 0xFFFF;
|
||||
}),
|
||||
MMIO::InvalidWrite<u16>());
|
||||
mmio->Register(base | (pq_reg.addr + 2), MMIO::ComplexRead<u16>([pq_reg](Core::System&, u32) {
|
||||
return g_video_backend->Video_GetQueryResult(pq_reg.pqtype) >> 16;
|
||||
mmio->Register(base | (pq_reg.addr + 2),
|
||||
MMIO::ComplexRead<u16>([pq_reg](Core::System& system, u32) {
|
||||
return g_video_backend->Video_GetQueryResult(system, pq_reg.pqtype) >> 16;
|
||||
}),
|
||||
MMIO::InvalidWrite<u16>());
|
||||
}
|
||||
@ -152,7 +153,7 @@ void PixelEngineManager::RegisterMMIO(MMIO::Mapping* mmio, u32 base)
|
||||
mmio->Register(base | (PE_BBOX_LEFT + 2 * i),
|
||||
MMIO::ComplexRead<u16>([i](Core::System& system, u32) {
|
||||
g_bounding_box->Disable(system.GetPixelShaderManager());
|
||||
return g_video_backend->Video_GetBoundingBox(i);
|
||||
return g_video_backend->Video_GetBoundingBox(system, i);
|
||||
}),
|
||||
MMIO::InvalidWrite<u16>());
|
||||
}
|
||||
|
||||
@ -90,12 +90,11 @@ std::string VideoBackendBase::BadShaderFilename(const char* shader_stage, int co
|
||||
}
|
||||
|
||||
// Run from the CPU thread (from VideoInterface.cpp)
|
||||
void VideoBackendBase::Video_OutputXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height,
|
||||
u64 ticks)
|
||||
void VideoBackendBase::Video_OutputXFB(Core::System& system, u32 xfb_addr, u32 fb_width,
|
||||
u32 fb_stride, u32 fb_height, u64 ticks)
|
||||
{
|
||||
if (m_initialized && g_presenter && !g_ActiveConfig.bImmediateXFB)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetFifo().SyncGPU(Fifo::SyncGPUReason::Swap);
|
||||
|
||||
const TimePoint presentation_time = system.GetCoreTiming().GetTargetHostTime(ticks);
|
||||
@ -105,14 +104,13 @@ void VideoBackendBase::Video_OutputXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride
|
||||
}
|
||||
}
|
||||
|
||||
u32 VideoBackendBase::Video_GetQueryResult(PerfQueryType type)
|
||||
u32 VideoBackendBase::Video_GetQueryResult(Core::System& system, PerfQueryType type)
|
||||
{
|
||||
if (!g_perf_query->ShouldEmulate())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetFifo().SyncGPU(Fifo::SyncGPUReason::PerfQuery);
|
||||
|
||||
if (!g_perf_query->IsFlushed())
|
||||
@ -123,7 +121,7 @@ u32 VideoBackendBase::Video_GetQueryResult(PerfQueryType type)
|
||||
return g_perf_query->GetQueryResult(type);
|
||||
}
|
||||
|
||||
u16 VideoBackendBase::Video_GetBoundingBox(int index)
|
||||
u16 VideoBackendBase::Video_GetBoundingBox(Core::System& system, int index)
|
||||
{
|
||||
DolphinAnalytics::Instance().ReportGameQuirk(GameQuirk::ReadsBoundingBox);
|
||||
|
||||
@ -151,7 +149,6 @@ u16 VideoBackendBase::Video_GetBoundingBox(int index)
|
||||
warn_once = false;
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetFifo().SyncGPU(Fifo::SyncGPUReason::BBox);
|
||||
|
||||
return AsyncRequests::GetInstance()->PushBlockingEvent(
|
||||
@ -249,23 +246,22 @@ void VideoBackendBase::PopulateBackendInfo(const WindowSystemInfo& wsi)
|
||||
g_Config.VerifyValidity();
|
||||
}
|
||||
|
||||
void VideoBackendBase::DoState(PointerWrap& p)
|
||||
void VideoBackendBase::DoState(Core::System& system, PointerWrap& p)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
if (!system.IsDualCoreMode())
|
||||
{
|
||||
VideoCommon_DoState(p);
|
||||
VideoCommon_DoState(system, p);
|
||||
return;
|
||||
}
|
||||
|
||||
AsyncRequests::GetInstance()->PushBlockingEvent([&] { VideoCommon_DoState(p); });
|
||||
AsyncRequests::GetInstance()->PushBlockingEvent([&] { VideoCommon_DoState(system, p); });
|
||||
|
||||
// Let the GPU thread sleep after loading the state, so we're not spinning if paused after loading
|
||||
// a state. The next GP burst will wake it up again.
|
||||
system.GetFifo().GpuMaySleep();
|
||||
}
|
||||
|
||||
bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
bool VideoBackendBase::InitializeShared(Core::System& system, std::unique_ptr<AbstractGfx> gfx,
|
||||
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||
std::unique_ptr<PerfQueryBase> perf_query,
|
||||
std::unique_ptr<BoundingBox> bounding_box)
|
||||
@ -273,12 +269,12 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
// All hardware backends use the default EFBInterface and TextureCacheBase.
|
||||
// Only Null and Software backends override them
|
||||
|
||||
return InitializeShared(std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
return InitializeShared(system, std::move(gfx), std::move(vertex_manager), std::move(perf_query),
|
||||
std::move(bounding_box), std::make_unique<HardwareEFBInterface>(),
|
||||
std::make_unique<TextureCacheBase>());
|
||||
}
|
||||
|
||||
bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
bool VideoBackendBase::InitializeShared(Core::System& system, std::unique_ptr<AbstractGfx> gfx,
|
||||
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||
std::unique_ptr<PerfQueryBase> perf_query,
|
||||
std::unique_ptr<BoundingBox> bounding_box,
|
||||
@ -315,11 +311,10 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
!g_graphics_mod_manager->Initialize())
|
||||
{
|
||||
PanicAlertFmtT("Failed to initialize renderer classes");
|
||||
Shutdown();
|
||||
Shutdown(system);
|
||||
return false;
|
||||
}
|
||||
|
||||
auto& system = Core::System::GetInstance();
|
||||
auto& command_processor = system.GetCommandProcessor();
|
||||
command_processor.Init();
|
||||
system.GetFifo().Init();
|
||||
@ -347,9 +342,8 @@ bool VideoBackendBase::InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
return true;
|
||||
}
|
||||
|
||||
void VideoBackendBase::ShutdownShared()
|
||||
void VideoBackendBase::ShutdownShared(Core::System& system)
|
||||
{
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetCustomResourceManager().Shutdown();
|
||||
|
||||
g_frame_dumper.reset();
|
||||
|
||||
@ -12,6 +12,11 @@
|
||||
#include "Common/WindowSystemInfo.h"
|
||||
#include "VideoCommon/PerfQueryBase.h"
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
namespace MMIO
|
||||
{
|
||||
class Mapping;
|
||||
@ -34,8 +39,8 @@ class VideoBackendBase
|
||||
{
|
||||
public:
|
||||
virtual ~VideoBackendBase() {}
|
||||
virtual bool Initialize(const WindowSystemInfo& wsi) = 0;
|
||||
virtual void Shutdown() = 0;
|
||||
virtual bool Initialize(Core::System& system, const WindowSystemInfo& wsi) = 0;
|
||||
virtual void Shutdown(Core::System& system) = 0;
|
||||
|
||||
virtual std::string GetConfigName() const = 0;
|
||||
virtual std::string GetDisplayName() const { return GetConfigName(); }
|
||||
@ -48,10 +53,11 @@ public:
|
||||
|
||||
static std::string BadShaderFilename(const char* shader_stage, int counter);
|
||||
|
||||
void Video_OutputXFB(u32 xfb_addr, u32 fb_width, u32 fb_stride, u32 fb_height, u64 ticks);
|
||||
void Video_OutputXFB(Core::System& system, u32 xfb_addr, u32 fb_width, u32 fb_stride,
|
||||
u32 fb_height, u64 ticks);
|
||||
|
||||
u32 Video_GetQueryResult(PerfQueryType type);
|
||||
u16 Video_GetBoundingBox(int index);
|
||||
u32 Video_GetQueryResult(Core::System& system, PerfQueryType type);
|
||||
u16 Video_GetBoundingBox(Core::System& system, int index);
|
||||
|
||||
static std::string GetDefaultBackendConfigName();
|
||||
static std::string GetDefaultBackendDisplayName();
|
||||
@ -62,23 +68,23 @@ public:
|
||||
static void PopulateBackendInfo(const WindowSystemInfo& wsi);
|
||||
|
||||
// Wrapper function which pushes the event to the GPU thread.
|
||||
void DoState(PointerWrap& p);
|
||||
void DoState(Core::System& system, PointerWrap& p);
|
||||
|
||||
protected:
|
||||
// For hardware backends
|
||||
bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
bool InitializeShared(Core::System& system, std::unique_ptr<AbstractGfx> gfx,
|
||||
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||
std::unique_ptr<PerfQueryBase> perf_query,
|
||||
std::unique_ptr<BoundingBox> bounding_box);
|
||||
|
||||
// For software and null backends. Allows overriding the default EFBInterface and TextureCache
|
||||
bool InitializeShared(std::unique_ptr<AbstractGfx> gfx,
|
||||
bool InitializeShared(Core::System& system, std::unique_ptr<AbstractGfx> gfx,
|
||||
std::unique_ptr<VertexManagerBase> vertex_manager,
|
||||
std::unique_ptr<PerfQueryBase> perf_query,
|
||||
std::unique_ptr<BoundingBox> bounding_box,
|
||||
std::unique_ptr<EFBInterfaceBase> efb_interface,
|
||||
std::unique_ptr<TextureCacheBase> texture_cache);
|
||||
void ShutdownShared();
|
||||
void ShutdownShared(Core::System& system);
|
||||
|
||||
bool m_initialized = false;
|
||||
};
|
||||
|
||||
@ -29,7 +29,7 @@
|
||||
#include "VideoCommon/XFMemory.h"
|
||||
#include "VideoCommon/XFStateManager.h"
|
||||
|
||||
void VideoCommon_DoState(PointerWrap& p)
|
||||
void VideoCommon_DoState(Core::System& system, PointerWrap& p)
|
||||
{
|
||||
bool software = false;
|
||||
p.Do(software);
|
||||
@ -65,7 +65,6 @@ void VideoCommon_DoState(PointerWrap& p)
|
||||
p.DoMarker("TMEM");
|
||||
|
||||
// FIFO
|
||||
auto& system = Core::System::GetInstance();
|
||||
system.GetFifo().DoState(p);
|
||||
p.DoMarker("Fifo");
|
||||
|
||||
|
||||
@ -3,6 +3,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace Core
|
||||
{
|
||||
class System;
|
||||
}
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
void VideoCommon_DoState(PointerWrap& p);
|
||||
void VideoCommon_DoState(Core::System& system, PointerWrap& p);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user