Get rid of the sync around curTickEst

This commit is contained in:
Henrik Rydgård 2017-11-05 19:46:42 +01:00
parent 4d9c571bf4
commit 5e63f0700e
2 changed files with 5 additions and 35 deletions

View file

@ -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 file

@ -143,17 +143,7 @@ public:
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 @@ protected:
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_;