From b35fa222f5db3d7862a8526735d195284b4a1f34 Mon Sep 17 00:00:00 2001 From: degasus Date: Sat, 31 Jan 2015 13:09:25 +0100 Subject: [PATCH] VideoCommon: perf querys by async events --- Source/Core/VideoCommon/AsyncRequests.cpp | 5 +++ Source/Core/VideoCommon/AsyncRequests.h | 5 +++ Source/Core/VideoCommon/Fifo.cpp | 2 -- Source/Core/VideoCommon/Fifo.h | 4 --- Source/Core/VideoCommon/MainBase.cpp | 43 ++++------------------- 5 files changed, 17 insertions(+), 42 deletions(-) diff --git a/Source/Core/VideoCommon/AsyncRequests.cpp b/Source/Core/VideoCommon/AsyncRequests.cpp index e99b1ab255..a6cc5a4b9c 100644 --- a/Source/Core/VideoCommon/AsyncRequests.cpp +++ b/Source/Core/VideoCommon/AsyncRequests.cpp @@ -97,6 +97,11 @@ void AsyncRequests::HandleEvent(const AsyncRequests::Event& e) case Event::BBOX_READ: *e.bbox.data = g_renderer->BBoxRead(e.bbox.index); + break; + + case Event::PERF_QUERY: + g_perf_query->FlushResults(); + break; } } diff --git a/Source/Core/VideoCommon/AsyncRequests.h b/Source/Core/VideoCommon/AsyncRequests.h index 15cc5c72e8..68ef08cf67 100644 --- a/Source/Core/VideoCommon/AsyncRequests.h +++ b/Source/Core/VideoCommon/AsyncRequests.h @@ -24,6 +24,7 @@ public: EFB_PEEK_Z, SWAP_EVENT, BBOX_READ, + PERF_QUERY, } type; u64 time; @@ -56,6 +57,10 @@ public: int index; u16* data; } bbox; + + struct + { + } perf_query; }; }; diff --git a/Source/Core/VideoCommon/Fifo.cpp b/Source/Core/VideoCommon/Fifo.cpp index 74470a9fcd..4a85679210 100644 --- a/Source/Core/VideoCommon/Fifo.cpp +++ b/Source/Core/VideoCommon/Fifo.cpp @@ -290,7 +290,6 @@ void RunGpuLoop() { g_video_backend->PeekMessages(); - VideoFifo_CheckAsyncRequest(); AsyncRequests::GetInstance()->PullEvents(); if (g_use_deterministic_gpu_thread) { @@ -353,7 +352,6 @@ void RunGpuLoop() // This call is pretty important in DualCore mode and must be called in the FIFO Loop. // If we don't, s_swapRequested or s_efbAccessRequested won't be set to false // leading the CPU thread to wait in Video_BeginField or Video_AccessEFB thus slowing things down. - VideoFifo_CheckAsyncRequest(); AsyncRequests::GetInstance()->PullEvents(); CommandProcessor::isPossibleWaitingSetDrawDone = false; } diff --git a/Source/Core/VideoCommon/Fifo.h b/Source/Core/VideoCommon/Fifo.h index d0b3c07015..56212e7d17 100644 --- a/Source/Core/VideoCommon/Fifo.h +++ b/Source/Core/VideoCommon/Fifo.h @@ -53,7 +53,3 @@ void EmulatorState(bool running); bool AtBreakpoint(); void ResetVideoBuffer(); void Fifo_SetRendering(bool bEnabled); - - -// Implemented by the Video Backend -void VideoFifo_CheckAsyncRequest(); diff --git a/Source/Core/VideoCommon/MainBase.cpp b/Source/Core/VideoCommon/MainBase.cpp index 74a2cc5fcf..a8af71b31e 100644 --- a/Source/Core/VideoCommon/MainBase.cpp +++ b/Source/Core/VideoCommon/MainBase.cpp @@ -21,9 +21,6 @@ bool s_BackendInitialized = false; static Common::Flag s_FifoShuttingDown; -static Common::Flag s_perfQueryRequested; -static Common::Event s_perfQueryReadyEvent; - static volatile struct { u32 xfbAddr; @@ -47,7 +44,6 @@ void VideoBackendHardware::Video_ExitLoop() { ExitGpuLoop(); s_FifoShuttingDown.Set(); - s_perfQueryReadyEvent.Set(); } void VideoBackendHardware::Video_SetRendering(bool bEnabled) @@ -118,7 +114,7 @@ u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 e.efb_poke.data = InputData; e.efb_poke.x = x; e.efb_poke.y = y; - AsyncRequests::GetInstance()->PushEvent(e, 0); + AsyncRequests::GetInstance()->PushEvent(e, false); return 0; } else @@ -130,21 +126,11 @@ u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32 e.efb_peek.x = x; e.efb_peek.y = y; e.efb_peek.data = &result; - AsyncRequests::GetInstance()->PushEvent(e, 1); + AsyncRequests::GetInstance()->PushEvent(e, true); return result; } } -static void VideoFifo_CheckPerfQueryRequest() -{ - if (s_perfQueryRequested.IsSet()) - { - g_perf_query->FlushResults(); - s_perfQueryRequested.Clear(); - s_perfQueryReadyEvent.Set(); - } -} - u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type) { if (!g_perf_query->ShouldEmulate()) @@ -154,20 +140,12 @@ u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type) SyncGPU(SYNC_GPU_PERFQUERY); - // TODO: Is this check sane? + AsyncRequests::Event e; + e.time = 0; + e.type = AsyncRequests::Event::PERF_QUERY; + if (!g_perf_query->IsFlushed()) - { - if (SConfig::GetInstance().m_LocalCoreStartupParameter.bCPUThread) - { - s_perfQueryReadyEvent.Reset(); - if (s_FifoShuttingDown.IsSet()) - return 0; - s_perfQueryRequested.Set(); - s_perfQueryReadyEvent.Wait(); - } - else - g_perf_query->FlushResults(); - } + AsyncRequests::GetInstance()->PushEvent(e, true); return g_perf_query->GetQueryResult(type); } @@ -194,7 +172,6 @@ void VideoBackendHardware::InitializeShared() { VideoCommon_Init(); - s_perfQueryRequested.Clear(); s_FifoShuttingDown.Clear(); memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs)); m_invalid = false; @@ -246,17 +223,11 @@ void VideoBackendHardware::PauseAndLock(bool doLock, bool unpauseOnUnlock) Fifo_PauseAndLock(doLock, unpauseOnUnlock); } - void VideoBackendHardware::RunLoop(bool enable) { VideoCommon_RunLoop(enable); } -void VideoFifo_CheckAsyncRequest() -{ - VideoFifo_CheckPerfQueryRequest(); -} - void VideoBackendHardware::Video_GatherPipeBursted() { CommandProcessor::GatherPipeBursted();