MCPcopy Create free account
hub / github.com/beefytech/Beef / Process

Method Process

BeefySysLib/BFApp.cpp:115–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

113//#define PERIODIC_PERF_TIMING
114
115void BFApp::Process()
116{
117 //Beefy::DebugTimeGuard suspendTimeGuard(30, "BFApp::Process");
118
119 RenderWindow* headRenderWindow = NULL;
120
121 float physRefreshRate = 0;
122 if ((mRenderDevice != NULL) && (!mRenderDevice->mRenderWindowList.IsEmpty()))
123 {
124 headRenderWindow = mRenderDevice->mRenderWindowList[0];
125 physRefreshRate = headRenderWindow->GetRefreshRate();
126 }
127
128 if (physRefreshRate <= 0)
129 physRefreshRate = 60.0f;
130
131 float ticksPerFrame = 1;
132 float physTicksPerFrame = 1000.0f / physRefreshRate;
133
134 if (mInProcess)
135 return; // No reentry
136 mInProcess = true;
137
138 uint32 tickNow = BFTickCount();
139 const int vSyncTestingPeriod = 250;
140
141 bool didVBlankWait = false;
142
143 if (mVSyncActive)
144 {
145 // Have a time limit in the cases we miss the vblank
146 if (mVSyncEvent.WaitFor((int)(physTicksPerFrame + 1)))
147 didVBlankWait = true;
148 }
149
150 if (mRefreshRate > 0)
151 ticksPerFrame = 1000.0f / mRefreshRate;
152 int ticksSinceLastProcess = tickNow - mLastProcessTick;
153
154 mUpdateSampleCount++;
155 mUpdateSampleTimes += ticksSinceLastProcess;
156 //TODO: Turn off mVSynched based on error calculations - (?)
157
158 // Two VSync failures in a row means we set mVSyncFailed and permanently disable it
159 if (mUpdateSampleTimes >= vSyncTestingPeriod)
160 {
161 int expectedFrames = (int)(mUpdateSampleTimes / ticksPerFrame);
162 if (mUpdateSampleCount > expectedFrames * 1.5)
163 {
164 if (!mVSynched)
165 mVSyncFailed = true;
166 mVSynched = false;
167 }
168 else
169 {
170 if (!mVSyncFailed)
171 mVSynched = true;
172 }

Callers

nothing calls this directly

Calls 7

WaitForMethod · 0.80
StartRecordingMethod · 0.80
StopRecordingMethod · 0.80
DbgPrintMethod · 0.80
BfpThread_SleepFunction · 0.50
IsEmptyMethod · 0.45
GetRefreshRateMethod · 0.45

Tested by

no test coverage detected