MCPcopy Create free account
hub / github.com/TheRealMJP/DeferredTexturing / UpdateProfile

Function UpdateProfile

SampleFramework12/v1.00/Graphics/Profiler.cpp:186–230  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

184}
185
186static void UpdateProfile(ProfileData& profile, uint64 profileIdx, bool drawText, uint64 gpuFrequency, const uint64* frameQueryData)
187{
188 profile.QueryFinished = false;
189
190 double time = 0.0f;
191 if(profile.CPUProfile)
192 {
193 time = double(profile.EndTime - profile.StartTime) / 1000.0;
194 }
195 else
196 {
197 Assert_(frameQueryData != nullptr);
198
199 // Get the query data
200 uint64 startTime = frameQueryData[profileIdx * 2 + 0];
201 uint64 endTime = frameQueryData[profileIdx * 2 + 1];
202
203 uint64 delta = endTime - startTime;
204 double frequency = double(gpuFrequency);
205 time = (delta / frequency) * 1000.0;
206 }
207
208 profile.TimeSamples[profile.CurrSample] = time;
209 profile.CurrSample = (profile.CurrSample + 1) % ProfileData::FilterSize;
210
211 double maxTime = 0.0;
212 double avgTime = 0.0;
213 uint64 avgTimeSamples = 0;
214 for(UINT i = 0; i < ProfileData::FilterSize; ++i)
215 {
216 if(profile.TimeSamples[i] <= 0.0)
217 continue;
218 maxTime = Max(profile.TimeSamples[i], maxTime);
219 avgTime += profile.TimeSamples[i];
220 ++avgTimeSamples;
221 }
222
223 if(avgTimeSamples > 0)
224 avgTime /= double(avgTimeSamples);
225
226 if(profile.Active && drawText)
227 ImGui::Text("%s: %.2fms (%.2fms max)", profile.Name, avgTime, maxTime);
228
229 profile.Active = false;
230}
231
232void Profiler::EndFrame(uint32 displayWidth, uint32 displayHeight)
233{

Callers 1

EndFrameMethod · 0.85

Calls 1

MaxFunction · 0.85

Tested by

no test coverage detected