Skip to content

Commit

Permalink
VideoCommon: perf querys by async events
Browse files Browse the repository at this point in the history
  • Loading branch information
degasus committed Jan 31, 2015
1 parent fed4efe commit 302705f
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 42 deletions.
5 changes: 5 additions & 0 deletions Source/Core/VideoCommon/AsyncRequests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

}
}
Expand Down
5 changes: 5 additions & 0 deletions Source/Core/VideoCommon/AsyncRequests.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AsyncRequests
EFB_PEEK_Z,
SWAP_EVENT,
BBOX_READ,
PERF_QUERY,
} type;
u64 time;

Expand Down Expand Up @@ -56,6 +57,10 @@ class AsyncRequests
int index;
u16* data;
} bbox;

struct
{
} perf_query;
};
};

Expand Down
2 changes: 0 additions & 2 deletions Source/Core/VideoCommon/Fifo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,6 @@ void RunGpuLoop()
{
g_video_backend->PeekMessages();

VideoFifo_CheckAsyncRequest();
AsyncRequests::GetInstance()->PullEvents();
if (g_use_deterministic_gpu_thread)
{
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 0 additions & 4 deletions Source/Core/VideoCommon/Fifo.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
43 changes: 7 additions & 36 deletions Source/Core/VideoCommon/MainBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -47,7 +44,6 @@ void VideoBackendHardware::Video_ExitLoop()
{
ExitGpuLoop();
s_FifoShuttingDown.Set();
s_perfQueryReadyEvent.Set();
}

void VideoBackendHardware::Video_SetRendering(bool bEnabled)
Expand Down Expand Up @@ -113,7 +109,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
Expand All @@ -125,21 +121,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())
Expand All @@ -149,20 +135,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);
}
Expand All @@ -189,7 +167,6 @@ void VideoBackendHardware::InitializeShared()
{
VideoCommon_Init();

s_perfQueryRequested.Clear();
s_FifoShuttingDown.Clear();
memset((void*)&s_beginFieldArgs, 0, sizeof(s_beginFieldArgs));
m_invalid = false;
Expand Down Expand Up @@ -241,17 +218,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();
Expand Down

0 comments on commit 302705f

Please sign in to comment.