QOpenGLTimeMonitor¶
The
QOpenGLTimeMonitor
class wraps a sequence of OpenGL timer query objects. More…
New in version 5.1.
Synopsis¶
Functions¶
def
create
()def
destroy
()def
isCreated
()def
isResultAvailable
()def
objectIds
()def
recordSample
()def
reset
()def
sampleCount
()def
setSampleCount
(sampleCount)
Detailed Description¶
The
QOpenGLTimeMonitor
class is a convenience wrapper around a collection of OpenGL timer query objects used to measure intervals of time on the GPU to the level of granularity required by your rendering application.The OpenGL timer queries objects are queried in sequence to record the GPU timestamps at positions of interest in your rendering code. Once the results for all issues timer queries become available, the results can be fetched and QOpenGLTimerMonitor will calculate the recorded time intervals for you.
The typical use case of this class is to either profile your application’s rendering algorithms or to adjust those algorithms in real-time for dynamic performance/quality balancing.
Prior to using
QOpenGLTimeMonitor
in your rendering function you should set the required number of sample points that you wish to record by calling setSamples(). Note that measuring N sample points will produce N-1 time intervals. Once you have set the number of sample points, call thecreate()
function with a valid current OpenGL context to create the necessary query timer objects. These steps are usually performed just once in an initialization function.Use the
recordSample()
function to delimit blocks of code containing OpenGL commands that you wish to time. You can check availability of the resulting time samples and time intervals withisResultAvailable()
. The calculated time intervals and the raw timestamp samples can be retrieved with the blockingwaitForIntervals()
andwaitForSamples()
functions respectively.After retrieving the results and before starting a new round of taking samples (for example, in the next frame) be sure to call the
reset()
function which will clear the cached results and reset the timer index back to the first timer object.See also
- class PySide2.QtGui.QOpenGLTimeMonitor([parent=None])¶
- param parent:
Creates a
QOpenGLTimeMonitor
instance with the givenparent
. You must callcreate()
with a valid OpenGL context before using.See also
- PySide2.QtGui.QOpenGLTimeMonitor.create()¶
- Return type:
bool
Instantiate
sampleCount()
OpenGL timer query objects that will be used to track the amount of time taken to execute OpenGL commands between successive calls torecordSample()
.Returns
true
if the OpenGL timer query objects could be created.See also
- PySide2.QtGui.QOpenGLTimeMonitor.destroy()¶
Destroys any OpenGL timer query objects used within this instance.
See also
- PySide2.QtGui.QOpenGLTimeMonitor.isCreated()¶
- Return type:
bool
Returns
true
if the underlying OpenGL query objects have been created. If this returnstrue
and the associated OpenGL context is current, then you are able to record time samples with this object.
- PySide2.QtGui.QOpenGLTimeMonitor.isResultAvailable()¶
- Return type:
bool
Returns
true
if the OpenGL timer query results are available.See also
waitForSamples()
waitForIntervals()
- PySide2.QtGui.QOpenGLTimeMonitor.objectIds()¶
- Return type:
Returns a
QVector
containing the object Ids of the OpenGL timer query objects.
- PySide2.QtGui.QOpenGLTimeMonitor.recordSample()¶
- Return type:
int
Issues an OpenGL timer query at this point in the OpenGL command queue. Calling this function in a sequence in your application’s rendering function, will build up details of the GPU time taken to execute the OpenGL commands between successive calls to this function.
See also
setSampleCount()
isResultAvailable()
waitForSamples()
waitForIntervals()
- PySide2.QtGui.QOpenGLTimeMonitor.reset()¶
Resets the time monitor ready for use in another frame of rendering. Call this once you have obtained the previous results and before calling
recordSample()
for the first time on the next frame.See also
- PySide2.QtGui.QOpenGLTimeMonitor.sampleCount()¶
- Return type:
int
Returns the number of sample points that have been requested with
setSampleCount()
. If create was successfully called followingsetSampleCount()
, then the value returned will be the actual number of sample points that can be used.The default value for sample count is 2, leading to the measurement of a single interval.
See also
- PySide2.QtGui.QOpenGLTimeMonitor.setSampleCount(sampleCount)¶
- Parameters:
sampleCount – int
Sets the number of sample points to
sampleCount
. After setting the number of samples with this function, you must callcreate()
to instantiate the underlying OpenGL timer query objects.The new
sampleCount
must be at least 2.See also
© 2022 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.