mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 20:12:21 +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()
|
void WinBFApp::VSyncThreadProc()
|
||||||
{
|
{
|
||||||
|
DWORD lastBlankFinish = GetTickCount();
|
||||||
|
|
||||||
|
Array<int> waitTimes;
|
||||||
|
|
||||||
while (!mClosing)
|
while (!mClosing)
|
||||||
{
|
{
|
||||||
bool didWait = false;
|
bool didWait = false;
|
||||||
|
@ -1315,12 +1319,28 @@ void WinBFApp::VSyncThreadProc()
|
||||||
|
|
||||||
if (output != NULL)
|
if (output != NULL)
|
||||||
{
|
{
|
||||||
DWORD start = GetTickCount();
|
DWORD startTick = GetTickCount();
|
||||||
bool success = output->WaitForVBlank() == 0;
|
bool success = output->WaitForVBlank() == 0;
|
||||||
int elapsed = (int)(GetTickCount() - start);
|
DWORD endTick = GetTickCount();
|
||||||
if (elapsed >= 20)
|
|
||||||
|
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)
|
if (success)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue