qopengltimerquery.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/gui/opengl/qopengltimerquery.cpp
Switch to Source codePreprocessed file
LineSourceCount
1-
2-
3-
4-
5-
6class QExtTimerQueryHelper-
7{-
8public:-
9 QExtTimerQueryHelper(QOpenGLContext *context)-
10 {-
11 ((!(context)) ? qt_assert("context",__FILE__,55) : qt_noop());-
12 GetQueryObjectui64vEXT = reinterpret_cast<void ( *)(GLuint , GLenum , GLuint64EXT *)>(context->getProcAddress("glGetQueryObjectui64vEXT"));-
13 GetQueryObjecti64vEXT = reinterpret_cast<void ( *)(GLuint , GLenum , GLint64EXT *)>(context->getProcAddress("glGetQueryObjecti64vEXT"));-
14 }
never executed: end of block
0
15-
16 inline void glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params)-
17 {-
18 GetQueryObjectui64vEXT(id, pname, params);-
19 }
never executed: end of block
0
20-
21 inline void glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params)-
22 {-
23 GetQueryObjecti64vEXT(id, pname, params);-
24 }
never executed: end of block
0
25-
26private:-
27 void ( * GetQueryObjectui64vEXT)(GLuint id, GLenum pname, GLuint64EXT *params);-
28 void ( * GetQueryObjecti64vEXT)(GLuint id, GLenum pname, GLint64EXT *params);-
29};-
30-
31class QOpenGLTimerQueryPrivate : public QObjectPrivate-
32{-
33public:-
34 QOpenGLTimerQueryPrivate()-
35 : QObjectPrivate(),-
36 context(0),-
37 ext(0),-
38 timeInterval(0),-
39 timer(0)-
40 {-
41 }
never executed: end of block
0
42-
43 ~QOpenGLTimerQueryPrivate()-
44 {-
45 delete core;-
46 delete ext;-
47 }
never executed: end of block
0
48-
49 bool create();-
50 void destroy();-
51 void begin();-
52 void end();-
53 GLuint64 waitForTimeStamp() const;-
54 void recordTimestamp();-
55 bool isResultAvailable() const;-
56 GLuint64 result() const;-
57 QOpenGLContext *context;-
58 QOpenGLQueryHelper *core;-
59 QExtTimerQueryHelper *ext;-
60 mutable GLuint64 timeInterval;-
61 GLuint timer;-
62};-
63-
64bool QOpenGLTimerQueryPrivate::create()-
65{-
66 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
67-
68 if (timer
timerDescription
TRUEnever evaluated
FALSEnever evaluated
&& context == ctx
context == ctxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
69 return
never executed: return true;
true;
never executed: return true;
0
70-
71 context = ctx;-
72 if (!context
!contextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
73 QMessageLogger(__FILE__, 132, __PRETTY_FUNCTION__).warning("A current OpenGL context is required to create timer query objects");-
74 return
never executed: return false;
false;
never executed: return false;
0
75 }-
76-
77 if (context->isOpenGLES()
context->isOpenGLES()Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
78 QMessageLogger(__FILE__, 137, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery: Not supported on OpenGL ES");-
79 return
never executed: return false;
false;
never executed: return false;
0
80 }-
81-
82-
83 core = new QOpenGLQueryHelper(context);-
84-
85-
86 QSurfaceFormat f = context->format();-
87 if (f.version() <= qMakePair<int, int>(3, 2)
f.version() <=...nt, int>(3, 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
88 && !context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_timer_query") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_timer_query" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
89 && context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_timer_query") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_timer_query" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
context->hasEx...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
90 ext = new QExtTimerQueryHelper(context);-
91 }
never executed: end of block
else if (f.version() <= qMakePair<int, int>(3, 2)
f.version() <=...nt, int>(3, 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
92 && !context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_timer_query") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_timer_query" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
93 && !context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_timer_query") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_timer_query" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
94 QMessageLogger(__FILE__, 153, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery requires one of:\n"-
95 " OpenGL 3.3 or newer,\n"-
96 " OpenGL 3.2 and the ARB_timer_query extension\n"-
97 " or the EXT_timer query extension");-
98 return
never executed: return false;
false;
never executed: return false;
0
99 }-
100-
101 core->glGenQueries(1, &timer);-
102 return
never executed: return (timer != 0);
(timer != 0);
never executed: return (timer != 0);
0
103}-
104-
105void QOpenGLTimerQueryPrivate::destroy()-
106{-
107 if (!timer
!timerDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
108 return;
never executed: return;
0
109-
110 core->glDeleteQueries(1, &timer);-
111 timer = 0;-
112 context = 0;-
113}
never executed: end of block
0
114void QOpenGLTimerQueryPrivate::begin()-
115{-
116 core->glBeginQuery(0x88BF, timer);-
117}
never executed: end of block
0
118-
119void QOpenGLTimerQueryPrivate::end()-
120{-
121 core->glEndQuery(0x88BF);-
122}
never executed: end of block
0
123-
124void QOpenGLTimerQueryPrivate::recordTimestamp()-
125{-
126-
127-
128 if (!ext
!extDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
129 core->glQueryCounter(timer, 0x8E28);
never executed: core->glQueryCounter(timer, 0x8E28);
0
130 else-
131 QMessageLogger(__FILE__, 201, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query");
never executed: QMessageLogger(__FILE__, 201, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query");
0
132-
133-
134-
135}-
136-
137GLuint64 QOpenGLTimerQueryPrivate::waitForTimeStamp() const-
138{-
139 GLint64 tmp = 0;-
140-
141 if (!ext
!extDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
142 core->glGetInteger64v(0x8E28, &tmp);
never executed: core->glGetInteger64v(0x8E28, &tmp);
0
143 else-
144 QMessageLogger(__FILE__, 214, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query");
never executed: QMessageLogger(__FILE__, 214, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query");
0
145-
146-
147-
148 GLuint64 timestamp(tmp);-
149 return
never executed: return timestamp;
timestamp;
never executed: return timestamp;
0
150}-
151-
152bool QOpenGLTimerQueryPrivate::isResultAvailable() const-
153{-
154 GLuint available = 0;-
155 core->glGetQueryObjectuiv(timer, 0x8867, &available);-
156 return
never executed: return available;
available;
never executed: return available;
0
157}-
158-
159GLuint64 QOpenGLTimerQueryPrivate::result() const-
160{-
161 if (!ext
!extDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
162 core->glGetQueryObjectui64v(timer, 0x8866, &timeInterval);
never executed: core->glGetQueryObjectui64v(timer, 0x8866, &timeInterval);
0
163 else-
164 ext->glGetQueryObjectui64vEXT(timer, 0x8866, &timeInterval);
never executed: ext->glGetQueryObjectui64vEXT(timer, 0x8866, &timeInterval);
0
165 return
never executed: return timeInterval;
timeInterval;
never executed: return timeInterval;
0
166}-
167QOpenGLTimerQuery::QOpenGLTimerQuery(QObject *parent)-
168 : QObject(*new QOpenGLTimerQueryPrivate, parent)-
169{-
170}
never executed: end of block
0
171-
172-
173-
174-
175QOpenGLTimerQuery::~QOpenGLTimerQuery()-
176{-
177 QOpenGLContext* ctx = QOpenGLContext::currentContext();-
178-
179 QOpenGLTimerQueryPrivate * const d = d_func();-
180 QOpenGLContext *oldContext = 0;-
181 if (d->context != ctx
d->context != ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
182 oldContext = ctx;-
183 if (d->context->makeCurrent(oldContext->surface())
d->context->ma...xt->surface())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
184 ctx = d->context;-
185 }
never executed: end of block
else {
0
186 QMessageLogger(__FILE__, 319, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to make query objects's context current");-
187 ctx = 0;-
188 }
never executed: end of block
0
189 }-
190-
191 if (ctx
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
192 destroy();
never executed: destroy();
0
193-
194 if (oldContext
oldContextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
195 if (!oldContext->makeCurrent(oldContext->surface())
!oldContext->m...xt->surface())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
196 QMessageLogger(__FILE__, 329, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to restore current context");
never executed: QMessageLogger(__FILE__, 329, __PRETTY_FUNCTION__).warning("QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to restore current context");
0
197 }
never executed: end of block
0
198}
never executed: end of block
0
199-
200-
201-
202-
203-
204-
205-
206bool QOpenGLTimerQuery::create()-
207{-
208 QOpenGLTimerQueryPrivate * const d = d_func();-
209 return
never executed: return d->create();
d->create();
never executed: return d->create();
0
210}-
211-
212-
213-
214-
215-
216void QOpenGLTimerQuery::destroy()-
217{-
218 QOpenGLTimerQueryPrivate * const d = d_func();-
219 d->destroy();-
220}
never executed: end of block
0
221-
222-
223-
224-
225-
226-
227bool QOpenGLTimerQuery::isCreated() const-
228{-
229 const QOpenGLTimerQueryPrivate * const d = d_func();-
230 return
never executed: return (d->timer != 0);
(d->timer != 0);
never executed: return (d->timer != 0);
0
231}-
232-
233-
234-
235-
236GLuint QOpenGLTimerQuery::objectId() const-
237{-
238 const QOpenGLTimerQueryPrivate * const d = d_func();-
239 return
never executed: return d->timer;
d->timer;
never executed: return d->timer;
0
240}-
241void QOpenGLTimerQuery::begin()-
242{-
243 QOpenGLTimerQueryPrivate * const d = d_func();-
244 d->begin();-
245}
never executed: end of block
0
246void QOpenGLTimerQuery::end()-
247{-
248 QOpenGLTimerQueryPrivate * const d = d_func();-
249 d->end();-
250}
never executed: end of block
0
251void QOpenGLTimerQuery::recordTimestamp()-
252{-
253 QOpenGLTimerQueryPrivate * const d = d_func();-
254 return
never executed: return d->recordTimestamp();
d->recordTimestamp();
never executed: return d->recordTimestamp();
0
255}-
256GLuint64 QOpenGLTimerQuery::waitForTimestamp() const-
257{-
258 const QOpenGLTimerQueryPrivate * const d = d_func();-
259 return
never executed: return d->waitForTimeStamp();
d->waitForTimeStamp();
never executed: return d->waitForTimeStamp();
0
260}-
261bool QOpenGLTimerQuery::isResultAvailable() const-
262{-
263 const QOpenGLTimerQueryPrivate * const d = d_func();-
264 return
never executed: return d->isResultAvailable();
d->isResultAvailable();
never executed: return d->isResultAvailable();
0
265}-
266GLuint64 QOpenGLTimerQuery::waitForResult() const-
267{-
268 const QOpenGLTimerQueryPrivate * const d = d_func();-
269 return
never executed: return d->result();
d->result();
never executed: return d->result();
0
270}-
271-
272-
273class QOpenGLTimeMonitorPrivate : public QObjectPrivate-
274{-
275public:-
276 QOpenGLTimeMonitorPrivate()-
277 : QObjectPrivate(),-
278 timers(),-
279 timeSamples(),-
280 context(0),-
281 core(0),-
282 ext(0),-
283 requestedSampleCount(2),-
284 currentSample(-1),-
285 timerQueryActive(false)-
286 {-
287 }
never executed: end of block
0
288-
289 ~QOpenGLTimeMonitorPrivate()-
290 {-
291 delete core;-
292 delete ext;-
293 }
never executed: end of block
0
294-
295 bool create();-
296 void destroy();-
297 void recordSample();-
298 bool isResultAvailable() const;-
299 QVector<GLuint64> samples() const;-
300 QVector<GLuint64> intervals() const;-
301 void reset();-
302-
303 QVector<GLuint> timers;-
304 mutable QVector<GLuint64> timeSamples;-
305-
306 QOpenGLContext *context;-
307 QOpenGLQueryHelper *core;-
308 QExtTimerQueryHelper *ext;-
309-
310 int requestedSampleCount;-
311 int currentSample;-
312 mutable bool timerQueryActive;-
313};-
314-
315bool QOpenGLTimeMonitorPrivate::create()-
316{-
317 if (!timers.isEmpty()
!timers.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
&& timers.at(0) != 0
timers.at(0) != 0Description
TRUEnever evaluated
FALSEnever evaluated
&& timers.size() == requestedSampleCount
timers.size() ...tedSampleCountDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
318 return
never executed: return true;
true;
never executed: return true;
0
319-
320 QOpenGLContext *ctx = QOpenGLContext::currentContext();-
321 if (context
contextDescription
TRUEnever evaluated
FALSEnever evaluated
&& context != ctx
context != ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
322 QMessageLogger(__FILE__, 513, __PRETTY_FUNCTION__).warning("QTimeMonitor: Attempting to use different OpenGL context to recreate timers.\n"-
323 "Please call destroy() first or use the same context to previously create");-
324 return
never executed: return false;
false;
never executed: return false;
0
325 }-
326-
327 context = ctx;-
328 if (!context
!contextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
329 QMessageLogger(__FILE__, 520, __PRETTY_FUNCTION__).warning("A current OpenGL context is required to create timer query objects");-
330 return
never executed: return false;
false;
never executed: return false;
0
331 }-
332-
333-
334 timers.resize(requestedSampleCount);-
335 timeSamples.resize(requestedSampleCount);-
336-
337-
338 core = new QOpenGLQueryHelper(context);-
339-
340-
341 QSurfaceFormat f = context->format();-
342 if (f.version() <= qMakePair<int, int>(3, 2)
f.version() <=...nt, int>(3, 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
343 && !context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_timer_query") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_timer_query" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
344 && context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_timer_query") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_timer_query" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
context->hasEx...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
345 ext = new QExtTimerQueryHelper(context);-
346 }
never executed: end of block
else if (f.version() <= qMakePair<int, int>(3, 2)
f.version() <=...nt, int>(3, 2)Description
TRUEnever evaluated
FALSEnever evaluated
0
347 && !context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_ARB_timer_query") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_ARB_timer_query" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
0
348 && !context->hasExtension(([]() -> QByteArray { enum { Size = sizeof("GL_EXT_timer_query") - 1 }; static const QStaticByteArrayData<Size> qbytearray_literal = { { { { -1 } }, Size, 0, 0, sizeof(QByteArrayData) }, "GL_EXT_timer_query" }; QByteArrayDataPtr holder = { qbytearray_literal.data_ptr() }; const QByteArray ba(holder); return ba; }()))
!context->hasE...turn ba; }()))Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
349 QMessageLogger(__FILE__, 540, __PRETTY_FUNCTION__).warning("QOpenGLTimeMonitor requires one of:\n"-
350 " OpenGL 3.3 or newer,\n"-
351 " OpenGL 3.2 and the ARB_timer_query extension\n"-
352 " or the EXT_timer query extension");-
353 return
never executed: return false;
false;
never executed: return false;
0
354 }-
355-
356 core->glGenQueries(requestedSampleCount, timers.data());-
357 return
never executed: return (timers.at(0) != 0);
(timers.at(0) != 0);
never executed: return (timers.at(0) != 0);
0
358}-
359-
360void QOpenGLTimeMonitorPrivate::destroy()-
361{-
362 if (timers.isEmpty()
timers.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
|| timers.at(0) == 0
timers.at(0) == 0Description
TRUEnever evaluated
FALSEnever evaluated
)
0
363 return;
never executed: return;
0
364-
365 core->glDeleteQueries(timers.size(), timers.data());-
366 timers.clear();-
367 delete core;-
368 core = 0;-
369 delete ext;-
370 ext = 0;-
371 context = 0;-
372}
never executed: end of block
0
373-
374void QOpenGLTimeMonitorPrivate::recordSample()-
375{-
376-
377-
378 if (!ext
!extDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
379-
380 core->glQueryCounter(timers.at(++currentSample), 0x8E28);-
381-
382 }
never executed: end of block
else {
0
383 if (currentSample == -1
currentSample == -1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
384 core->glBeginQuery(0x88BF, timers.at(++currentSample));-
385 timerQueryActive = true;-
386 }
never executed: end of block
else if (currentSample < timers.size() - 1
currentSample ...ers.size() - 1Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
387 core->glEndQuery(0x88BF);-
388 core->glBeginQuery(0x88BF, timers.at(++currentSample));-
389 }
never executed: end of block
else {
0
390 if (timerQueryActive
timerQueryActiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
391 core->glEndQuery(0x88BF);-
392 timerQueryActive = false;-
393 }
never executed: end of block
0
394 }
never executed: end of block
0
395 }-
396}-
397-
398bool QOpenGLTimeMonitorPrivate::isResultAvailable() const-
399{-
400-
401-
402-
403 GLuint available = 0;-
404 core->glGetQueryObjectuiv(timers.at(currentSample), 0x8867, &available);-
405 return
never executed: return available;
available;
never executed: return available;
0
406}-
407-
408QVector<GLuint64> QOpenGLTimeMonitorPrivate::samples() const-
409{-
410-
411-
412-
413 if (!ext
!extDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
414 for (int i = 0; i <= currentSample
i <= currentSampleDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
415 core->glGetQueryObjectui64v(timers.at(i), 0x8866, &timeSamples[i]);
never executed: core->glGetQueryObjectui64v(timers.at(i), 0x8866, &timeSamples[i]);
0
416 }
never executed: end of block
else {
0
417 QMessageLogger(__FILE__, 608, __PRETTY_FUNCTION__).warning("QOpenGLTimeMonitor::samples() requires OpenGL >=3.3\n"-
418 "or OpenGL 3.2 and GL_ARB_timer_query");-
419 }
never executed: end of block
0
420 return
never executed: return timeSamples;
timeSamples;
never executed: return timeSamples;
0
421}-
422-
423QVector<GLuint64> QOpenGLTimeMonitorPrivate::intervals() const-
424{-
425 QVector<GLuint64> intervals(timers.size() - 1);-
426 if (!ext
!extDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
427-
428 const QVector<GLuint64> timeStamps = samples();-
429 for (int i = 0; i < intervals.size()
i < intervals.size()Description
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
430 intervals[i] = timeStamps[i+1] - timeStamps[i];
never executed: intervals[i] = timeStamps[i+1] - timeStamps[i];
0
431 }
never executed: end of block
else {
0
432-
433 if (timerQueryActive
timerQueryActiveDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
434 core->glEndQuery(0x88BF);-
435 timerQueryActive = false;-
436 }
never executed: end of block
0
437-
438-
439-
440 for (int i = 0; i < currentSample
i < currentSampleDescription
TRUEnever evaluated
FALSEnever evaluated
; ++i)
0
441 ext->glGetQueryObjectui64vEXT(timers.at(i), 0x8866, &intervals[i]);
never executed: ext->glGetQueryObjectui64vEXT(timers.at(i), 0x8866, &intervals[i]);
0
442 }
never executed: end of block
0
443-
444 return
never executed: return intervals;
intervals;
never executed: return intervals;
0
445}-
446-
447void QOpenGLTimeMonitorPrivate::reset()-
448{-
449 currentSample = -1;-
450 timeSamples.fill(0);-
451}
never executed: end of block
0
452QOpenGLTimeMonitor::QOpenGLTimeMonitor(QObject *parent)-
453 : QObject(*new QOpenGLTimeMonitorPrivate, parent)-
454{-
455}
never executed: end of block
0
456-
457-
458-
459-
460QOpenGLTimeMonitor::~QOpenGLTimeMonitor()-
461{-
462 QOpenGLContext* ctx = QOpenGLContext::currentContext();-
463-
464 QOpenGLTimeMonitorPrivate * const d = d_func();-
465 QOpenGLContext *oldContext = 0;-
466 if (d->context != ctx
d->context != ctxDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
467 oldContext = ctx;-
468 if (d->context->makeCurrent(oldContext->surface())
d->context->ma...xt->surface())Description
TRUEnever evaluated
FALSEnever evaluated
) {
0
469 ctx = d->context;-
470 }
never executed: end of block
else {
0
471 QMessageLogger(__FILE__, 710, __PRETTY_FUNCTION__).warning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to make time monitor's context current");-
472 ctx = 0;-
473 }
never executed: end of block
0
474 }-
475-
476 if (ctx
ctxDescription
TRUEnever evaluated
FALSEnever evaluated
)
0
477 destroy();
never executed: destroy();
0
478-
479 if (oldContext
oldContextDescription
TRUEnever evaluated
FALSEnever evaluated
) {
0
480 if (!oldContext->makeCurrent(oldContext->surface())
!oldContext->m...xt->surface())Description
TRUEnever evaluated
FALSEnever evaluated
)
0
481 QMessageLogger(__FILE__, 720, __PRETTY_FUNCTION__).warning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to restore current context");
never executed: QMessageLogger(__FILE__, 720, __PRETTY_FUNCTION__).warning("QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to restore current context");
0
482 }
never executed: end of block
0
483}
never executed: end of block
0
484void QOpenGLTimeMonitor::setSampleCount(int sampleCount)-
485{-
486-
487 if (sampleCount < 2
sampleCount < 2Description
TRUEnever evaluated
FALSEnever evaluated
)
0
488 return;
never executed: return;
0
489 QOpenGLTimeMonitorPrivate * const d = d_func();-
490 d->requestedSampleCount = sampleCount;-
491}
never executed: end of block
0
492int QOpenGLTimeMonitor::sampleCount() const-
493{-
494 const QOpenGLTimeMonitorPrivate * const d = d_func();-
495 return
never executed: return d->requestedSampleCount;
d->requestedSampleCount;
never executed: return d->requestedSampleCount;
0
496}-
497bool QOpenGLTimeMonitor::create()-
498{-
499 QOpenGLTimeMonitorPrivate * const d = d_func();-
500 return
never executed: return d->create();
d->create();
never executed: return d->create();
0
501}-
502-
503-
504-
505-
506-
507-
508void QOpenGLTimeMonitor::destroy()-
509{-
510 QOpenGLTimeMonitorPrivate * const d = d_func();-
511 d->destroy();-
512}
never executed: end of block
0
513-
514-
515-
516-
517-
518-
519bool QOpenGLTimeMonitor::isCreated() const-
520{-
521 const QOpenGLTimeMonitorPrivate * const d = d_func();-
522 return
never executed: return (!d->timers.isEmpty() && d->timers.at(0) != 0);
(!d->timers.isEmpty() && d->timers.at(0) != 0);
never executed: return (!d->timers.isEmpty() && d->timers.at(0) != 0);
0
523}-
524-
525-
526-
527-
528QVector<GLuint> QOpenGLTimeMonitor::objectIds() const-
529{-
530 const QOpenGLTimeMonitorPrivate * const d = d_func();-
531 return
never executed: return d->timers;
d->timers;
never executed: return d->timers;
0
532}-
533int QOpenGLTimeMonitor::recordSample()-
534{-
535 QOpenGLTimeMonitorPrivate * const d = d_func();-
536 d->recordSample();-
537 return
never executed: return d->currentSample;
d->currentSample;
never executed: return d->currentSample;
0
538}-
539-
540-
541-
542-
543-
544-
545bool QOpenGLTimeMonitor::isResultAvailable() const-
546{-
547 const QOpenGLTimeMonitorPrivate * const d = d_func();-
548 return
never executed: return d->isResultAvailable();
d->isResultAvailable();
never executed: return d->isResultAvailable();
0
549}-
550QVector<GLuint64> QOpenGLTimeMonitor::waitForSamples() const-
551{-
552 const QOpenGLTimeMonitorPrivate * const d = d_func();-
553 return
never executed: return d->samples();
d->samples();
never executed: return d->samples();
0
554}-
555QVector<GLuint64> QOpenGLTimeMonitor::waitForIntervals() const-
556{-
557 const QOpenGLTimeMonitorPrivate * const d = d_func();-
558 return
never executed: return d->intervals();
d->intervals();
never executed: return d->intervals();
0
559}-
560void QOpenGLTimeMonitor::reset()-
561{-
562 QOpenGLTimeMonitorPrivate * const d = d_func();-
563 d->reset();-
564}
never executed: end of block
0
565-
566-
Switch to Source codePreprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9