summaryrefslogtreecommitdiff
path: root/Source/Core/VideoCommon
diff options
context:
space:
mode:
authorPierre Bourdon <delroth@gmail.com>2016-01-13 01:27:24 +0100
committerPierre Bourdon <delroth@gmail.com>2016-01-13 01:27:24 +0100
commit8f8134f5f4da2ff29f58c8f373ed1f5c64bcdf71 (patch)
tree74f8317e0e5e161a21c636a6388cc3013bfe837c /Source/Core/VideoCommon
parent82f3b94ad7a344972a26cb87d4ab362fd1397738 (diff)
parentaa430c10d573b5e73154b8fbb7d661a58e44df68 (diff)
Merge pull request #3504 from degasus/master
VideoBackend: Cleanup API a bit.
Diffstat (limited to 'Source/Core/VideoCommon')
-rw-r--r--Source/Core/VideoCommon/AsyncRequests.cpp2
-rw-r--r--Source/Core/VideoCommon/BPStructs.cpp8
-rw-r--r--Source/Core/VideoCommon/CommandProcessor.cpp28
-rw-r--r--Source/Core/VideoCommon/Fifo.cpp19
-rw-r--r--Source/Core/VideoCommon/Fifo.h19
-rw-r--r--Source/Core/VideoCommon/MainBase.cpp92
-rw-r--r--Source/Core/VideoCommon/OpcodeDecoding.cpp8
-rw-r--r--Source/Core/VideoCommon/PixelEngine.cpp4
-rw-r--r--Source/Core/VideoCommon/VideoBackendBase.cpp18
-rw-r--r--Source/Core/VideoCommon/VideoBackendBase.h93
-rw-r--r--Source/Core/VideoCommon/VideoState.cpp14
-rw-r--r--Source/Core/VideoCommon/VideoState.h1
-rw-r--r--Source/Core/VideoCommon/XFStructs.cpp6
13 files changed, 92 insertions, 220 deletions
diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp
index 1ce7c8fdb7..bddf8e7445 100644
--- a/Source/Core/VideoCommon/AsyncRequests.cpp
+++ b/Source/Core/VideoCommon/AsyncRequests.cpp
@@ -81,7 +81,7 @@ void AsyncRequests::PushEvent(const AsyncRequests::Event& event, bool blocking)
m_queue.push(event);
- RunGpu();
+ Fifo::RunGpu();
if (blocking)
{
m_cond.wait(lock, [this]{return m_queue.empty();});
diff --git a/Source/Core/VideoCommon/BPStructs.cpp b/Source/Core/VideoCommon/BPStructs.cpp
index 6dc505c28e..35f017f5c5 100644
--- a/Source/Core/VideoCommon/BPStructs.cpp
+++ b/Source/Core/VideoCommon/BPStructs.cpp
@@ -177,7 +177,7 @@ static void BPWritten(const BPCmd& bp)
switch (bp.newvalue & 0xFF)
{
case 0x02:
- if (!g_use_deterministic_gpu_thread)
+ if (!Fifo::g_use_deterministic_gpu_thread)
PixelEngine::SetFinish(); // may generate interrupt
DEBUG_LOG(VIDEO, "GXSetDrawDone SetPEFinish (value: 0x%02X)", (bp.newvalue & 0xFFFF));
return;
@@ -188,12 +188,12 @@ static void BPWritten(const BPCmd& bp)
}
return;
case BPMEM_PE_TOKEN_ID: // Pixel Engine Token ID
- if (!g_use_deterministic_gpu_thread)
+ if (!Fifo::g_use_deterministic_gpu_thread)
PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), false);
DEBUG_LOG(VIDEO, "SetPEToken 0x%04x", (bp.newvalue & 0xFFFF));
return;
case BPMEM_PE_TOKEN_INT_ID: // Pixel Engine Interrupt Token ID
- if (!g_use_deterministic_gpu_thread)
+ if (!Fifo::g_use_deterministic_gpu_thread)
PixelEngine::SetToken(static_cast<u16>(bp.newvalue & 0xFFFF), true);
DEBUG_LOG(VIDEO, "SetPEToken + INT 0x%04x", (bp.newvalue & 0xFFFF));
return;
@@ -378,7 +378,7 @@ static void BPWritten(const BPCmd& bp)
case BPMEM_CLEARBBOX2:
// Don't compute bounding box if this frame is being skipped!
// Wrong but valid values are better than bogus values...
- if (!g_bSkipCurrentFrame)
+ if (!Fifo::g_bSkipCurrentFrame)
{
u8 offset = bp.address & 2;
BoundingBox::active = true;
diff --git a/Source/Core/VideoCommon/CommandProcessor.cpp b/Source/Core/VideoCommon/CommandProcessor.cpp
index 8bca029cae..1d5e1ab172 100644
--- a/Source/Core/VideoCommon/CommandProcessor.cpp
+++ b/Source/Core/VideoCommon/CommandProcessor.cpp
@@ -223,7 +223,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
UCPCtrlReg tmp(val);
m_CPCtrlReg.Hex = tmp.Hex;
SetCpControlRegister();
- RunGpu();
+ Fifo::RunGpu();
})
);
@@ -233,7 +233,7 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
UCPClearReg tmp(val);
m_CPClearReg.Hex = tmp.Hex;
SetCpClearRegister();
- RunGpu();
+ Fifo::RunGpu();
})
);
@@ -265,17 +265,17 @@ void RegisterMMIO(MMIO::Mapping* mmio, u32 base)
: MMIO::DirectRead<u16>(MMIO::Utils::HighPart(&fifo.CPReadWriteDistance)),
MMIO::ComplexWrite<u16>([](u32, u16 val) {
WriteHigh(fifo.CPReadWriteDistance, val);
- SyncGPU(SYNC_GPU_OTHER);
+ Fifo::SyncGPU(Fifo::SYNC_GPU_OTHER);
if (fifo.CPReadWriteDistance == 0)
{
GPFifo::ResetGatherPipe();
- ResetVideoBuffer();
+ Fifo::ResetVideoBuffer();
}
else
{
- ResetVideoBuffer();
+ Fifo::ResetVideoBuffer();
}
- RunGpu();
+ Fifo::RunGpu();
})
);
mmio->Register(base | FIFO_READ_POINTER_LO,
@@ -306,7 +306,7 @@ void GatherPipeBursted()
// if we aren't linked, we don't care about gather pipe data
if (!m_CPCtrlReg.GPLinkEnable)
{
- if (IsOnThread() && !g_use_deterministic_gpu_thread)
+ if (IsOnThread() && !Fifo::g_use_deterministic_gpu_thread)
{
// In multibuffer mode is not allowed write in the same FIFO attached to the GPU.
// Fix Pokemon XD in DC mode.
@@ -314,10 +314,10 @@ void GatherPipeBursted()
(ProcessorInterface::Fifo_CPUBase == fifo.CPBase) &&
fifo.CPReadWriteDistance > 0)
{
- FlushGpu();
+ Fifo::FlushGpu();
}
}
- RunGpu();
+ Fifo::RunGpu();
return;
}
@@ -340,7 +340,7 @@ void GatherPipeBursted()
Common::AtomicAdd(fifo.CPReadWriteDistance, GATHER_PIPE_SIZE);
- RunGpu();
+ Fifo::RunGpu();
_assert_msg_(COMMANDPROCESSOR, fifo.CPReadWriteDistance <= fifo.CPEnd - fifo.CPBase,
"FIFO is overflowed by GatherPipe !\nCPU thread is too fast!");
@@ -367,12 +367,12 @@ void UpdateInterrupts(u64 userdata)
}
CoreTiming::ForceExceptionCheck(0);
s_interrupt_waiting.store(false);
- RunGpu();
+ Fifo::RunGpu();
}
void UpdateInterruptsFromVideoBackend(u64 userdata)
{
- if (!g_use_deterministic_gpu_thread)
+ if (!Fifo::g_use_deterministic_gpu_thread)
CoreTiming::ScheduleEvent_Threadsafe(0, et_UpdateInterrupts, userdata);
}
@@ -494,7 +494,7 @@ void SetCpStatusRegister()
// Here always there is one fifo attached to the GPU
m_CPStatusReg.Breakpoint = fifo.bFF_Breakpoint;
m_CPStatusReg.ReadIdle = !fifo.CPReadWriteDistance || (fifo.CPReadPointer == fifo.CPWritePointer);
- m_CPStatusReg.CommandIdle = !fifo.CPReadWriteDistance || AtBreakpoint() || !fifo.bFF_GPReadEnable;
+ m_CPStatusReg.CommandIdle = !fifo.CPReadWriteDistance || Fifo::AtBreakpoint() || !fifo.bFF_GPReadEnable;
m_CPStatusReg.UnderflowLoWatermark = fifo.bFF_LoWatermark;
m_CPStatusReg.OverflowHiWatermark = fifo.bFF_HiWatermark;
@@ -519,7 +519,7 @@ void SetCpControlRegister()
if (fifo.bFF_GPReadEnable && !m_CPCtrlReg.GPReadEnable)
{
fifo.bFF_GPReadEnable = m_CPCtrlReg.GPReadEnable;
- FlushGpu();
+ Fifo::FlushGpu();
}
else
{
diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp
index 6ad184cc3e..97c8902bd8 100644
--- a/Source/Core/VideoCommon/Fifo.cpp
+++ b/Source/Core/VideoCommon/Fifo.cpp
@@ -30,6 +30,9 @@
#include "VideoCommon/VertexManagerBase.h"
#include "VideoCommon/VideoConfig.h"
+namespace Fifo
+{
+
static constexpr u32 FIFO_SIZE = 2 * 1024 * 1024;
bool g_bSkipCurrentFrame = false;
@@ -66,7 +69,7 @@ static u8* s_video_buffer_pp_read_ptr;
static std::atomic<int> s_sync_ticks;
static Common::Event s_sync_wakeup_event;
-void Fifo_DoState(PointerWrap &p)
+void DoState(PointerWrap &p)
{
p.DoArray(s_video_buffer, FIFO_SIZE);
u8* write_ptr = s_video_buffer_write_ptr;
@@ -81,7 +84,7 @@ void Fifo_DoState(PointerWrap &p)
p.Do(g_bSkipCurrentFrame);
}
-void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock)
+void PauseAndLock(bool doLock, bool unpauseOnUnlock)
{
if (doLock)
{
@@ -97,7 +100,7 @@ void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock)
}
-void Fifo_Init()
+void Init()
{
// Padded so that SIMD overreads in the vertex loader are safe
s_video_buffer = (u8*)AllocateMemoryPages(FIFO_SIZE + 4);
@@ -107,7 +110,7 @@ void Fifo_Init()
s_sync_ticks.store(0);
}
-void Fifo_Shutdown()
+void Shutdown()
{
if (s_gpu_mainloop.IsRunning())
PanicAlert("Fifo shutting down while active");
@@ -122,7 +125,7 @@ void Fifo_Shutdown()
s_fifo_aux_read_ptr = nullptr;
}
-void Fifo_SetRendering(bool enabled)
+void SetRendering(bool enabled)
{
g_bSkipCurrentFrame = !enabled;
}
@@ -450,7 +453,7 @@ void RunGpu()
}
}
-void Fifo_UpdateWantDeterminism(bool want)
+void UpdateWantDeterminism(bool want)
{
// We are paused (or not running at all yet), so
// it should be safe to change this.
@@ -492,7 +495,7 @@ void Fifo_UpdateWantDeterminism(bool want)
}
}
-int Fifo_Update(int ticks)
+int Update(int ticks)
{
const SConfig& param = SConfig::GetInstance();
@@ -528,3 +531,5 @@ int Fifo_Update(int ticks)
return param.iSyncGpuMaxDistance - s_sync_ticks.load();
}
+
+}
diff --git a/Source/Core/VideoCommon/Fifo.h b/Source/Core/VideoCommon/Fifo.h
index a66cec7fc2..c137869414 100644
--- a/Source/Core/VideoCommon/Fifo.h
+++ b/Source/Core/VideoCommon/Fifo.h
@@ -9,6 +9,9 @@
class PointerWrap;
+namespace Fifo
+{
+
extern bool g_bSkipCurrentFrame;
// This could be in SConfig, but it depends on multiple settings
@@ -16,11 +19,11 @@ extern bool g_bSkipCurrentFrame;
extern bool g_use_deterministic_gpu_thread;
extern std::atomic<u8*> g_video_buffer_write_ptr_xthread;
-void Fifo_Init();
-void Fifo_Shutdown();
-void Fifo_DoState(PointerWrap &f);
-void Fifo_PauseAndLock(bool doLock, bool unpauseOnUnlock);
-void Fifo_UpdateWantDeterminism(bool want);
+void Init();
+void Shutdown();
+void DoState(PointerWrap &f);
+void PauseAndLock(bool doLock, bool unpauseOnUnlock);
+void UpdateWantDeterminism(bool want);
// Used for diagnostics.
enum SyncGPUReason
@@ -47,5 +50,7 @@ void ExitGpuLoop();
void EmulatorState(bool running);
bool AtBreakpoint();
void ResetVideoBuffer();
-void Fifo_SetRendering(bool bEnabled);
-int Fifo_Update(int ticks);
+void SetRendering(bool bEnabled);
+int Update(int ticks);
+
+};
diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp
index 067f506bde..173c8f7077 100644
--- a/Source/Core/VideoCommon/MainBase.cpp
+++ b/Source/Core/VideoCommon/MainBase.cpp
@@ -29,30 +29,14 @@ static volatile struct
u32 fbHeight;
} s_beginFieldArgs;
-void VideoBackendHardware::EmuStateChange(EMUSTATE_CHANGE newState)
+void VideoBackendBase::Video_ExitLoop()
{
- EmulatorState(newState == EMUSTATE_CHANGE_PLAY);
-}
-
-// Enter and exit the video loop
-void VideoBackendHardware::Video_EnterLoop()
-{
- RunGpuLoop();
-}
-
-void VideoBackendHardware::Video_ExitLoop()
-{
- ExitGpuLoop();
+ Fifo::ExitGpuLoop();
s_FifoShuttingDown.Set();
}
-void VideoBackendHardware::Video_SetRendering(bool bEnabled)
-{
- Fifo_SetRendering(bEnabled);
-}
-
// Run from the CPU thread (from VideoInterface.cpp)
-void VideoBackendHardware::Video_BeginField(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight)
+void VideoBackendBase::Video_BeginField(u32 xfbAddr, u32 fbWidth, u32 fbStride, u32 fbHeight)
{
if (m_initialized && g_ActiveConfig.bUseXFB)
{
@@ -64,11 +48,11 @@ void VideoBackendHardware::Video_BeginField(u32 xfbAddr, u32 fbWidth, u32 fbStri
}
// Run from the CPU thread (from VideoInterface.cpp)
-void VideoBackendHardware::Video_EndField()
+void VideoBackendBase::Video_EndField()
{
if (m_initialized && g_ActiveConfig.bUseXFB && g_renderer)
{
- SyncGPU(SYNC_GPU_SWAP);
+ Fifo::SyncGPU(Fifo::SYNC_GPU_SWAP);
AsyncRequests::Event e;
e.time = 0;
@@ -82,24 +66,7 @@ void VideoBackendHardware::Video_EndField()
}
}
-void VideoBackendHardware::Video_AddMessage(const std::string& msg, u32 milliseconds)
-{
- OSD::AddMessage(msg, milliseconds);
-}
-
-void VideoBackendHardware::Video_ClearMessages()
-{
- OSD::ClearMessages();
-}
-
-// Screenshot
-bool VideoBackendHardware::Video_Screenshot(const std::string& filename)
-{
- Renderer::SetScreenshot(filename.c_str());
- return true;
-}
-
-u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
+u32 VideoBackendBase::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 InputData)
{
if (!g_ActiveConfig.bEFBAccessEnable)
{
@@ -131,14 +98,14 @@ u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32
}
}
-u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type)
+u32 VideoBackendBase::Video_GetQueryResult(PerfQueryType type)
{
if (!g_perf_query->ShouldEmulate())
{
return 0;
}
- SyncGPU(SYNC_GPU_PERFQUERY);
+ Fifo::SyncGPU(Fifo::SYNC_GPU_PERFQUERY);
AsyncRequests::Event e;
e.time = 0;
@@ -150,7 +117,7 @@ u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type)
return g_perf_query->GetQueryResult(type);
}
-u16 VideoBackendHardware::Video_GetBoundingBox(int index)
+u16 VideoBackendBase::Video_GetBoundingBox(int index)
{
if (!g_ActiveConfig.backend_info.bSupportsBBox)
return 0;
@@ -164,7 +131,7 @@ u16 VideoBackendHardware::Video_GetBoundingBox(int index)
return 0;
}
- SyncGPU(SYNC_GPU_BBOX);
+ Fifo::SyncGPU(Fifo::SYNC_GPU_BBOX);
AsyncRequests::Event e;
u16 result;
@@ -177,7 +144,7 @@ u16 VideoBackendHardware::Video_GetBoundingBox(int index)
return result;
}
-void VideoBackendHardware::InitializeShared()
+void VideoBackendBase::InitializeShared()
{
VideoCommon_Init();
@@ -187,7 +154,7 @@ void VideoBackendHardware::InitializeShared()
}
// Run from the CPU thread
-void VideoBackendHardware::DoState(PointerWrap& p)
+void VideoBackendBase::DoState(PointerWrap& p)
{
bool software = false;
p.Do(software);
@@ -202,7 +169,7 @@ void VideoBackendHardware::DoState(PointerWrap& p)
p.DoMarker("VideoCommon");
p.Do(s_beginFieldArgs);
- p.DoMarker("VideoBackendHardware");
+ p.DoMarker("VideoBackendBase");
// Refresh state.
if (p.GetMode() == PointerWrap::MODE_READ)
@@ -215,7 +182,7 @@ void VideoBackendHardware::DoState(PointerWrap& p)
}
}
-void VideoBackendHardware::CheckInvalidState()
+void VideoBackendBase::CheckInvalidState()
{
if (m_invalid)
{
@@ -225,34 +192,3 @@ void VideoBackendHardware::CheckInvalidState()
TextureCacheBase::Invalidate();
}
}
-
-void VideoBackendHardware::PauseAndLock(bool doLock, bool unpauseOnUnlock)
-{
- Fifo_PauseAndLock(doLock, unpauseOnUnlock);
-}
-
-void VideoBackendHardware::RunLoop(bool enable)
-{
- VideoCommon_RunLoop(enable);
-}
-
-void VideoBackendHardware::Video_GatherPipeBursted()
-{
- CommandProcessor::GatherPipeBursted();
-}
-
-int VideoBackendHardware::Video_Sync(int ticks)
-{
- return Fifo_Update(ticks);
-}
-
-void VideoBackendHardware::RegisterCPMMIO(MMIO::Mapping* mmio, u32 base)
-{
- CommandProcessor::RegisterMMIO(mmio, base);
-}
-
-void VideoBackendHardware::UpdateWantDeterminism(bool want)
-{
- Fifo_UpdateWantDeterminism(want);
-}
-
diff --git a/Source/Core/VideoCommon/OpcodeDecoding.cpp b/Source/Core/VideoCommon/OpcodeDecoding.cpp
index 000711b19e..5e7b57a54a 100644
--- a/Source/Core/VideoCommon/OpcodeDecoding.cpp
+++ b/Source/Core/VideoCommon/OpcodeDecoding.cpp
@@ -39,8 +39,8 @@ static u32 InterpretDisplayList(u32 address, u32 size)
{
u8* startAddress;
- if (g_use_deterministic_gpu_thread)
- startAddress = (u8*)PopFifoAuxBuffer(size);
+ if (Fifo::g_use_deterministic_gpu_thread)
+ startAddress = (u8*)Fifo::PopFifoAuxBuffer(size);
else
startAddress = Memory::GetPointer(address);
@@ -66,7 +66,7 @@ static void InterpretDisplayListPreprocess(u32 address, u32 size)
{
u8* startAddress = Memory::GetPointer(address);
- PushFifoAuxBuffer(startAddress, size);
+ Fifo::PushFifoAuxBuffer(startAddress, size);
if (startAddress != nullptr)
{
@@ -278,7 +278,7 @@ u8* OpcodeDecoder_Run(DataReader src, u32* cycles, bool in_display_list)
(cmd_byte & GX_PRIMITIVE_MASK) >> GX_PRIMITIVE_SHIFT,
num_vertices,
src,
- g_bSkipCurrentFrame,
+ Fifo::g_bSkipCurrentFrame,
is_preprocess);
if (bytes < 0)
diff --git a/Source/Core/VideoCommon/PixelEngine.cpp b/Source/Core/VideoCommon/PixelEngine.cpp
index 162815ac40..af261eb90f 100644
--- a/Source/Core/VideoCommon/PixelEngine.cpp
+++ b/Source/Core/VideoCommon/PixelEngine.cpp
@@ -298,7 +298,7 @@ void SetToken(const u16 _token, const int _bSetTokenAcknowledge)
CommandProcessor::SetInterruptTokenWaiting(true);
- if (!SConfig::GetInstance().bCPUThread || g_use_deterministic_gpu_thread)
+ if (!SConfig::GetInstance().bCPUThread || Fifo::g_use_deterministic_gpu_thread)
CoreTiming::ScheduleEvent(0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16));
else
CoreTiming::ScheduleEvent_Threadsafe(0, et_SetTokenOnMainThread, _token | (_bSetTokenAcknowledge << 16));
@@ -310,7 +310,7 @@ void SetFinish()
{
CommandProcessor::SetInterruptFinishWaiting(true);
- if (!SConfig::GetInstance().bCPUThread || g_use_deterministic_gpu_thread)
+ if (!SConfig::GetInstance().bCPUThread || Fifo::g_use_deterministic_gpu_thread)
CoreTiming::ScheduleEvent(0, et_SetFinishOnMainThread, 0);
else
CoreTiming::ScheduleEvent_Threadsafe(0, et_SetFinishOnMainThread, 0);
diff --git a/Source/Core/VideoCommon/VideoBackendBase.cpp b/Source/Core/VideoCommon/VideoBackendBase.cpp
index 69beee3f1d..aeca4e2827 100644
--- a/Source/Core/VideoCommon/VideoBackendBase.cpp
+++ b/Source/Core/VideoCommon/VideoBackendBase.cpp
@@ -11,9 +11,9 @@
#include "VideoCommon/VideoBackendBase.h"
-std::vector<VideoBackend*> g_available_video_backends;
-VideoBackend* g_video_backend = nullptr;
-static VideoBackend* s_default_backend = nullptr;
+std::vector<VideoBackendBase*> g_available_video_backends;
+VideoBackendBase* g_video_backend = nullptr;
+static VideoBackendBase* s_default_backend = nullptr;
#ifdef _WIN32
#include <windows.h>
@@ -26,9 +26,9 @@ __declspec(dllexport) DWORD NvOptimusEnablement = 1;
}
#endif
-void VideoBackend::PopulateList()
+void VideoBackendBase::PopulateList()
{
- VideoBackend* backends[4] = { nullptr };
+ VideoBackendBase* backends[4] = { nullptr };
// OGL > D3D11 > SW
g_available_video_backends.push_back(backends[0] = new OGL::VideoBackend);
@@ -37,7 +37,7 @@ void VideoBackend::PopulateList()
#endif
g_available_video_backends.push_back(backends[3] = new SW::VideoSoftware);
- for (VideoBackend* backend : backends)
+ for (VideoBackendBase* backend : backends)
{
if (backend)
{
@@ -47,7 +47,7 @@ void VideoBackend::PopulateList()
}
}
-void VideoBackend::ClearList()
+void VideoBackendBase::ClearList()
{
while (!g_available_video_backends.empty())
{
@@ -56,12 +56,12 @@ void VideoBackend::ClearList()
}
}
-void VideoBackend::ActivateBackend(const std::string& name)
+void VideoBackendBase::ActivateBackend(const std::string& name)
{
if (name.length() == 0) // If nullptr, set it to the default backend (expected behavior)
g_video_backend = s_default_backend;
- for (VideoBackend* backend : g_available_video_backends)
+ for (VideoBackendBase* backend : g_available_video_backends)
if (name == backend->GetName())
g_video_backend = backend;
}
diff --git a/Source/Core/VideoCommon/VideoBackendBase.h b/Source/Core/VideoCommon/VideoBackendBase.h
index 75b4674454..75c26be296 100644
--- a/Source/Core/VideoCommon/VideoBackendBase.h
+++ b/Source/Core/VideoCommon/VideoBackendBase.h
@@ -57,18 +57,15 @@ struct SCPFifoStruct
volatile u32 bFF_HiWatermark;
};
-class VideoBackend
+class VideoBackendBase
{
public:
- virtual ~VideoBackend() {}
-
- virtual void EmuStateChange(EMUSTATE_CHANGE) = 0;
+ virtual ~VideoBackendBase() {}
virtual unsigned int PeekMessages() = 0;
virtual bool Initialize(void* window_handle) = 0;
virtual void Shutdown() = 0;
- virtual void RunLoop(bool enable) = 0;
virtual std::string GetName() const = 0;
virtual std::string GetDisplayName() const { return GetName(); }
@@ -76,91 +73,31 @@ public:
virtual void ShowConfig(void*) = 0;
virtual void Video_Prepare() = 0;
- virtual void Video_EnterLoop() = 0;
- virtual void Video_ExitLoop() = 0;
+ void Video_ExitLoop();
virtual void Video_Cleanup() = 0; // called from gl/d3d thread
- virtual void Video_BeginField(u32, u32, u32, u32) = 0;
- virtual void Video_EndField() = 0;
-
- virtual u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) = 0;
- virtual u32 Video_GetQueryResult(PerfQueryType type) = 0;
- virtual u16 Video_GetBoundingBox(int index) = 0;
-
- virtual void Video_AddMessage(const std::string& msg, unsigned int milliseconds) = 0;
- virtual void Video_ClearMessages() = 0;
- virtual bool Video_Screenshot(const std::string& filename) = 0;
-
- virtual void Video_SetRendering(bool bEnabled) = 0;
+ void Video_BeginField(u32, u32, u32, u32);
+ void Video_EndField();
- virtual void Video_GatherPipeBursted() = 0;
-
- virtual int Video_Sync(int ticks) = 0;
-
- // Registers MMIO handlers for the CommandProcessor registers.
- virtual void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) = 0;
+ u32 Video_AccessEFB(EFBAccessType, u32, u32, u32);
+ u32 Video_GetQueryResult(PerfQueryType type);
+ u16 Video_GetBoundingBox(int index);
static void PopulateList();
static void ClearList();
static void ActivateBackend(const std::string& name);
- // waits until is paused and fully idle, and acquires a lock on that state.
- // or, if doLock is false, releases a lock on that state and optionally unpauses.
- // calls must be balanced and non-recursive (once with doLock true, then once with doLock false).
- virtual void PauseAndLock(bool doLock, bool unpauseOnUnlock = true) = 0;
-
// the implementation needs not do synchronization logic, because calls to it are surrounded by PauseAndLock now
- virtual void DoState(PointerWrap &p) = 0;
-
- virtual void CheckInvalidState() = 0;
+ void DoState(PointerWrap &p);
- virtual void UpdateWantDeterminism(bool want) {}
+ void CheckInvalidState();
protected:
+ void InitializeShared();
+
bool m_initialized = false;
+ bool m_invalid = false;
};
-extern std::vector<VideoBackend*> g_available_video_backends;
-extern VideoBackend* g_video_backend;
-
-// inherited by D3D/OGL backends
-class VideoBackendHardware : public VideoBackend
-{
- void RunLoop(bool enable) override;
-
- void EmuStateChange(EMUSTATE_CHANGE) override;
-
- void Video_EnterLoop() override;
- void Video_ExitLoop() override;
- void Video_BeginField(u32, u32, u32, u32) override;
- void Video_EndField() override;
-
- u32 Video_AccessEFB(EFBAccessType, u32, u32, u32) override;
- u32 Video_GetQueryResult(PerfQueryType type) override;
- u16 Video_GetBoundingBox(int index) override;
-
- void Video_AddMessage(const std::string& pstr, unsigned int milliseconds) override;
- void Video_ClearMessages() override;
- bool Video_Screenshot(const std::string& filename) override;
-
- void Video_SetRendering(bool bEnabled) override;
-
- void Video_GatherPipeBursted() override;
-
- int Video_Sync(int ticks) override;
-
- void RegisterCPMMIO(MMIO::Mapping* mmio, u32 base) override;
-
- void PauseAndLock(bool doLock, bool unpauseOnUnlock = true) override;
- void DoState(PointerWrap &p) override;
-
- void UpdateWantDeterminism(bool want) override;
-
- bool m_invalid;
-
-public:
- void CheckInvalidState() override;
-
-protected:
- void InitializeShared();
-};
+extern std::vector<VideoBackendBase*> g_available_video_backends;
+extern VideoBackendBase* g_video_backend;
diff --git a/Source/Core/VideoCommon/VideoState.cpp b/Source/Core/VideoCommon/VideoState.cpp
index 9f2b11f31c..355742367e 100644
--- a/Source/Core/VideoCommon/VideoState.cpp
+++ b/Source/Core/VideoCommon/VideoState.cpp
@@ -17,7 +17,7 @@
#include "VideoCommon/VideoState.h"
#include "VideoCommon/XFMemory.h"
-static void DoState(PointerWrap &p)
+void VideoCommon_DoState(PointerWrap &p)
{
// BP Memory
p.Do(bpmem);
@@ -35,7 +35,7 @@ static void DoState(PointerWrap &p)
p.DoMarker("texMem");
// FIFO
- Fifo_DoState(p);
+ Fifo::DoState(p);
p.DoMarker("Fifo");
CommandProcessor::DoState(p);
@@ -64,16 +64,6 @@ static void DoState(PointerWrap &p)
// TODO: search for more data that should be saved and add it here
}
-void VideoCommon_DoState(PointerWrap &p)
-{
- DoState(p);
-}
-
-void VideoCommon_RunLoop(bool enable)
-{
- EmulatorState(enable);
-}
-
void VideoCommon_Init()
{
memset(&g_main_cp_state, 0, sizeof(g_main_cp_state));
diff --git a/Source/Core/VideoCommon/VideoState.h b/Source/Core/VideoCommon/VideoState.h
index b77b3e529d..ec25cdca5d 100644
--- a/Source/Core/VideoCommon/VideoState.h
+++ b/Source/Core/VideoCommon/VideoState.h
@@ -7,5 +7,4 @@
class PointerWrap;
void VideoCommon_DoState(PointerWrap &p);
-void VideoCommon_RunLoop(bool enable);
void VideoCommon_Init();
diff --git a/Source/Core/VideoCommon/XFStructs.cpp b/Source/Core/VideoCommon/XFStructs.cpp
index ecf1eda08e..4fb7333964 100644
--- a/Source/Core/VideoCommon/XFStructs.cpp
+++ b/Source/Core/VideoCommon/XFStructs.cpp
@@ -258,9 +258,9 @@ void LoadIndexedXF(u32 val, int refarray)
u32* currData = (u32*)(&xfmem) + address;
u32* newData;
- if (g_use_deterministic_gpu_thread)
+ if (Fifo::g_use_deterministic_gpu_thread)
{
- newData = (u32*)PopFifoAuxBuffer(size * sizeof(u32));
+ newData = (u32*)Fifo::PopFifoAuxBuffer(size * sizeof(u32));
}
else
{
@@ -291,5 +291,5 @@ void PreprocessIndexedXF(u32 val, int refarray)
u32* new_data = (u32*)Memory::GetPointer(g_preprocess_cp_state.array_bases[refarray] + g_preprocess_cp_state.array_strides[refarray] * index);
size_t buf_size = size * sizeof(u32);
- PushFifoAuxBuffer(new_data, buf_size);
+ Fifo::PushFifoAuxBuffer(new_data, buf_size);
}