mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Zero-time check for WaitForVBlank
This commit is contained in:
parent
ae5d8313c4
commit
2aaf5a2db4
1 changed files with 25 additions and 5 deletions
|
@ -1297,6 +1297,10 @@ void BFP_CALLTYPE WinBFApp::VSyncThreadProcThunk(void* ptr)
|
|||
|
||||
void WinBFApp::VSyncThreadProc()
|
||||
{
|
||||
DWORD lastBlankFinish = GetTickCount();
|
||||
|
||||
Array<int> waitTimes;
|
||||
|
||||
while (!mClosing)
|
||||
{
|
||||
bool didWait = false;
|
||||
|
@ -1315,12 +1319,28 @@ void WinBFApp::VSyncThreadProc()
|
|||
|
||||
if (output != NULL)
|
||||
{
|
||||
DWORD start = GetTickCount();
|
||||
DWORD startTick = GetTickCount();
|
||||
bool success = output->WaitForVBlank() == 0;
|
||||
int elapsed = (int)(GetTickCount() - start);
|
||||
if (elapsed >= 20)
|
||||
DWORD endTick = GetTickCount();
|
||||
|
||||
if (success)
|
||||
{
|
||||
NOP;
|
||||
int elapsed = (int)(endTick - startTick);
|
||||
waitTimes.Add(elapsed);
|
||||
if (waitTimes.mSize > 8)
|
||||
waitTimes.RemoveAt(0);
|
||||
|
||||
if (elapsed <= 1)
|
||||
{
|
||||
bool hadNonZero = false;
|
||||
for (auto waitTime : waitTimes)
|
||||
{
|
||||
if (waitTime > 1)
|
||||
hadNonZero = true;
|
||||
}
|
||||
if (!hadNonZero)
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (success)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue