Permalink
Browse files

Get rid of the sync around curTickEst

  • Loading branch information...
hrydgard committed Nov 5, 2017
1 parent 4d9c571 commit 5e63f0700ec087dab67797cf67298e91bbe3b8c4
Showing with 5 additions and 35 deletions.
  1. +4 −4 GPU/GPUCommon.cpp
  2. +1 −31 GPU/GPUCommon.h
View
@@ -404,7 +404,7 @@ void GPUCommon::Reinitialize() {
busyTicks = 0;
timeSpentStepping_ = 0.0;
interruptsEnabled_ = true;
UpdateTickEstimate(0);
curTickEst_ = 0;
ScheduleEvent(GPU_EVENT_REINITIALIZE);
}
@@ -1107,7 +1107,7 @@ bool GPUCommon::ProcessDLQueue() {
void GPUCommon::ProcessDLQueueInternal() {
startingTicks = CoreTiming::GetTicks();
cyclesExecuted = 0;
UpdateTickEstimate(std::max(busyTicks, startingTicks + cyclesExecuted));
curTickEst_ = std::max(busyTicks, startingTicks + cyclesExecuted);
// Seems to be correct behaviour to process the list anyway?
if (startingTicks < busyTicks) {
@@ -1126,7 +1126,7 @@ void GPUCommon::ProcessDLQueueInternal() {
// At the end, we can remove it from the queue and continue.
dlQueue.erase(std::remove(dlQueue.begin(), dlQueue.end(), listIndex), dlQueue.end());
}
UpdateTickEstimate(std::max(busyTicks, startingTicks + cyclesExecuted));
curTickEst_ = std::max(busyTicks, startingTicks + cyclesExecuted);
}
}
@@ -1136,7 +1136,7 @@ void GPUCommon::ProcessDLQueueInternal() {
busyTicks = std::max(busyTicks, drawCompleteTicks);
__GeTriggerSync(GPU_SYNC_DRAW, 1, drawCompleteTicks);
// Since the event is in CoreTiming, we're in sync. Just set 0 now.
UpdateTickEstimate(0);
curTickEst_ = 0;
}
void GPUCommon::PreExecuteOp(u32 op, u32 diff) {
View
@@ -143,17 +143,7 @@ class GPUCommon : public GPUThreadEventQueue, public GPUDebugInterface {
inline void Flush();
u64 GetTickEstimate() override {
#if defined(_M_X64) || defined(__ANDROID__)
return curTickEst_;
#elif defined(_M_SSE)
__m64 result = *(__m64 *)&curTickEst_;
u64 safeResult = *(u64 *)&result;
_mm_empty();
return safeResult;
#else
std::lock_guard<std::mutex> guard(curTickEstLock_);
return curTickEst_;
#endif
}
#ifdef USE_CRT_DBG
@@ -329,27 +319,7 @@ class GPUCommon : public GPUThreadEventQueue, public GPUDebugInterface {
GEPrimitiveType lastPrim_;
private:
// For CPU/GPU sync.
#ifdef __ANDROID__
alignas(16) std::atomic<u64> curTickEst_;
#else
alignas(16) volatile u64 curTickEst_;
std::mutex curTickEstLock_;
#endif
inline void UpdateTickEstimate(u64 value) {
#if defined(_M_X64) || defined(__ANDROID__)
curTickEst_ = value;
#elif defined(_M_SSE)
__m64 result = *(__m64 *)&value;
*(__m64 *)&curTickEst_ = result;
_mm_empty();
#else
std::lock_guard<std::mutex> guard(curTickEstLock_);
curTickEst_ = value;
#endif
}
u64 curTickEst_;
// Debug stats.
double timeSteppingStarted_;

0 comments on commit 5e63f07

Please sign in to comment.