VideoCommon: perf querys by async events

This commit is contained in:
degasus 2015-01-31 13:09:25 +01:00
parent edbd402101
commit b35fa222f5
5 changed files with 17 additions and 42 deletions

View File

@ -97,6 +97,11 @@ void AsyncRequests::HandleEvent(const AsyncRequests::Event& e)
case Event::BBOX_READ: case Event::BBOX_READ:
*e.bbox.data = g_renderer->BBoxRead(e.bbox.index); *e.bbox.data = g_renderer->BBoxRead(e.bbox.index);
break;
case Event::PERF_QUERY:
g_perf_query->FlushResults();
break;
} }
} }

View File

@ -24,6 +24,7 @@ public:
EFB_PEEK_Z, EFB_PEEK_Z,
SWAP_EVENT, SWAP_EVENT,
BBOX_READ, BBOX_READ,
PERF_QUERY,
} type; } type;
u64 time; u64 time;
@ -56,6 +57,10 @@ public:
int index; int index;
u16* data; u16* data;
} bbox; } bbox;
struct
{
} perf_query;
}; };
}; };

View File

@ -290,7 +290,6 @@ void RunGpuLoop()
{ {
g_video_backend->PeekMessages(); g_video_backend->PeekMessages();
VideoFifo_CheckAsyncRequest();
AsyncRequests::GetInstance()->PullEvents(); AsyncRequests::GetInstance()->PullEvents();
if (g_use_deterministic_gpu_thread) 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. // 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 // 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. // leading the CPU thread to wait in Video_BeginField or Video_AccessEFB thus slowing things down.
VideoFifo_CheckAsyncRequest();
AsyncRequests::GetInstance()->PullEvents(); AsyncRequests::GetInstance()->PullEvents();
CommandProcessor::isPossibleWaitingSetDrawDone = false; CommandProcessor::isPossibleWaitingSetDrawDone = false;
} }

View File

@ -53,7 +53,3 @@ void EmulatorState(bool running);
bool AtBreakpoint(); bool AtBreakpoint();
void ResetVideoBuffer(); void ResetVideoBuffer();
void Fifo_SetRendering(bool bEnabled); void Fifo_SetRendering(bool bEnabled);
// Implemented by the Video Backend
void VideoFifo_CheckAsyncRequest();

View File

@ -21,9 +21,6 @@ bool s_BackendInitialized = false;
static Common::Flag s_FifoShuttingDown; static Common::Flag s_FifoShuttingDown;
static Common::Flag s_perfQueryRequested;
static Common::Event s_perfQueryReadyEvent;
static volatile struct static volatile struct
{ {
u32 xfbAddr; u32 xfbAddr;
@ -47,7 +44,6 @@ void VideoBackendHardware::Video_ExitLoop()
{ {
ExitGpuLoop(); ExitGpuLoop();
s_FifoShuttingDown.Set(); s_FifoShuttingDown.Set();
s_perfQueryReadyEvent.Set();
} }
void VideoBackendHardware::Video_SetRendering(bool bEnabled) 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.data = InputData;
e.efb_poke.x = x; e.efb_poke.x = x;
e.efb_poke.y = y; e.efb_poke.y = y;
AsyncRequests::GetInstance()->PushEvent(e, 0); AsyncRequests::GetInstance()->PushEvent(e, false);
return 0; return 0;
} }
else else
@ -130,21 +126,11 @@ u32 VideoBackendHardware::Video_AccessEFB(EFBAccessType type, u32 x, u32 y, u32
e.efb_peek.x = x; e.efb_peek.x = x;
e.efb_peek.y = y; e.efb_peek.y = y;
e.efb_peek.data = &result; e.efb_peek.data = &result;
AsyncRequests::GetInstance()->PushEvent(e, 1); AsyncRequests::GetInstance()->PushEvent(e, true);
return result; 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) u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type)
{ {
if (!g_perf_query->ShouldEmulate()) if (!g_perf_query->ShouldEmulate())
@ -154,20 +140,12 @@ u32 VideoBackendHardware::Video_GetQueryResult(PerfQueryType type)
SyncGPU(SYNC_GPU_PERFQUERY); 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 (!g_perf_query->IsFlushed())
{ AsyncRequests::GetInstance()->PushEvent(e, true);
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();
}
return g_perf_query->GetQueryResult(type); return g_perf_query->GetQueryResult(type);
} }
@ -194,7 +172,6 @@ void VideoBackendHardware::InitializeShared()
{ {
VideoCommon_Init(); VideoCommon_Init();
s_perfQueryRequested.Clear();
s_FifoShuttingDown.Clear(); s_FifoShuttingDown.Clear();
memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs)); memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs));
m_invalid = false; m_invalid = false;
@ -246,17 +223,11 @@ void VideoBackendHardware::PauseAndLock(bool doLock, bool unpauseOnUnlock)
Fifo_PauseAndLock(doLock, unpauseOnUnlock); Fifo_PauseAndLock(doLock, unpauseOnUnlock);
} }
void VideoBackendHardware::RunLoop(bool enable) void VideoBackendHardware::RunLoop(bool enable)
{ {
VideoCommon_RunLoop(enable); VideoCommon_RunLoop(enable);
} }
void VideoFifo_CheckAsyncRequest()
{
VideoFifo_CheckPerfQueryRequest();
}
void VideoBackendHardware::Video_GatherPipeBursted() void VideoBackendHardware::Video_GatherPipeBursted()
{ {
CommandProcessor::GatherPipeBursted(); CommandProcessor::GatherPipeBursted();