7#include <QtCore/private/qobject_p.h>
8#include <QtGui/QOpenGLContext>
9#include <QtGui/QOpenGLFunctions>
96 qWarning(
"A current OpenGL context is required to create timer query objects");
101 qWarning(
"QOpenGLTimerQuery: Not supported on OpenGL ES");
117 qWarning(
"QOpenGLTimerQuery requires one of:\n"
118 " OpenGL 3.3 or newer,\n"
119 " OpenGL 3.2 and the ARB_timer_query extension\n"
120 " or the EXT_timer query extension");
139#if !defined(GL_TIME_ELAPSED_EXT)
140#define GL_TIME_ELAPSED_EXT 0x88BF
144#if !defined(GL_TIME_ELAPSED)
145#define GL_TIME_ELAPSED GL_TIME_ELAPSED_EXT
161#if defined(GL_TIMESTAMP)
165 qWarning(
"QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query");
167 qWarning(
"QOpenGLTimerQuery::recordTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query");
174#if defined(GL_TIMESTAMP)
178 qWarning(
"QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query");
180 qWarning(
"QOpenGLTimerQuery::waitForTimestamp() requires OpenGL 3.3 or GL_ARB_timer_query");
188 GLuint available = GL_FALSE;
278 if (
d->context !=
ctx) {
280 if (
d->context->makeCurrent(oldContext->
surface())) {
283 qWarning(
"QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to make query objects's context current");
293 qWarning(
"QOpenGLTimerQuery::~QOpenGLTimerQuery() failed to restore current context");
327 return (
d->timer != 0);
381 return d->recordTimestamp();
395 return d->waitForTimeStamp();
409 return d->isResultAvailable();
477 qWarning(
"QTimeMonitor: Attempting to use different OpenGL context to recreate timers.\n"
478 "Please call destroy() first or use the same context to previously create");
484 qWarning(
"A current OpenGL context is required to create timer query objects");
504 qWarning(
"QOpenGLTimeMonitor requires one of:\n"
505 " OpenGL 3.3 or newer,\n"
506 " OpenGL 3.2 and the ARB_timer_query extension\n"
507 " or the EXT_timer query extension");
534#if defined(GL_TIMESTAMP)
558 GLuint available = GL_FALSE;
572 qWarning(
"QOpenGLTimeMonitor::samples() requires OpenGL >=3.3\n"
573 "or OpenGL 3.2 and GL_ARB_timer_query");
669 if (
d->context !=
ctx) {
671 if (
d->context->makeCurrent(oldContext->
surface())) {
674 qWarning(
"QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to make time monitor's context current");
684 qWarning(
"QOpenGLTimeMonitor::~QOpenGLTimeMonitor() failed to restore current context");
720 return d->requestedSampleCount;
757 return (!
d->timers.isEmpty() &&
d->timers.at(0) != 0);
781 return d->currentSample;
792 return d->isResultAvailable();
828 return d->intervals();
846#include "moc_qopengltimerquery.cpp"
QExtTimerQueryHelper(QOpenGLContext *context)
void glGetQueryObjecti64vEXT(GLuint id, GLenum pname, GLint64EXT *params)
void glGetQueryObjectui64vEXT(GLuint id, GLenum pname, GLuint64EXT *params)
qsizetype size() const noexcept
QList< T > & fill(parameter_type t, qsizetype size=-1)
bool isEmpty() const noexcept
const_reference at(qsizetype i) const noexcept
void resize(qsizetype size)
bool makeCurrent(QSurface *surface)
Makes the context current in the current thread, against the given surface.
QSurfaceFormat format() const
Returns the format of the underlying platform context, if create() has been called.
bool hasExtension(const QByteArray &extension) const
Returns true if this OpenGL context supports the specified OpenGL extension, false otherwise.
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
QSurface * surface() const
Returns the surface the context has been made current with.
bool isOpenGLES() const
Returns true if the context is an OpenGL ES context.
void glEndQuery(GLenum target)
void glGetQueryObjectuiv(GLuint id, GLenum pname, GLuint *params)
void glGetQueryObjectui64v(GLuint id, GLenum pname, GLuint64 *params)
void glGetInteger64v(GLenum pname, GLint64 *params)
void glGenQueries(GLsizei n, GLuint *ids)
void glQueryCounter(GLuint id, GLenum target)
void glBeginQuery(GLenum target, GLuint id)
void glDeleteQueries(GLsizei n, const GLuint *ids)
QOpenGLTimeMonitorPrivate()
QList< GLuint64 > intervals() const
bool isResultAvailable() const
QList< GLuint64 > timeSamples
~QOpenGLTimeMonitorPrivate()
QExtTimerQueryHelper * ext
QOpenGLQueryHelper * core
QList< GLuint64 > samples() const
The QOpenGLTimeMonitor class wraps a sequence of OpenGL timer query objects.
QList< GLuint > objectIds() const
Returns a QList containing the object Ids of the OpenGL timer query objects.
int sampleCount() const
Returns the number of sample points that have been requested with setSampleCount().
bool create()
Instantiate sampleCount() OpenGL timer query objects that will be used to track the amount of time ta...
void destroy()
Destroys any OpenGL timer query objects used within this instance.
int recordSample()
Issues an OpenGL timer query at this point in the OpenGL command queue.
QList< GLuint64 > waitForSamples() const
Returns a QList containing the GPU timestamps taken with recordSample().
QList< GLuint64 > waitForIntervals() const
Returns a QList containing the time intervals delimited by the calls to recordSample().
bool isResultAvailable() const
Returns true if the OpenGL timer query results are available.
bool isCreated() const
Returns true if the underlying OpenGL query objects have been created.
void reset()
Resets the time monitor ready for use in another frame of rendering.
void setSampleCount(int sampleCount)
Sets the number of sample points to sampleCount.
~QOpenGLTimeMonitor()
Destroys the QOpenGLTimeMonitor and any underlying OpenGL resources.
QOpenGLTimeMonitor(QObject *parent=nullptr)
Creates a QOpenGLTimeMonitor instance with the given parent.
QExtTimerQueryHelper * ext
QOpenGLTimerQueryPrivate()
bool isResultAvailable() const
~QOpenGLTimerQueryPrivate()
QOpenGLQueryHelper * core
GLuint64 waitForTimeStamp() const
The QOpenGLTimerQuery class wraps an OpenGL timer query object.
~QOpenGLTimerQuery()
Destroys the QOpenGLTimerQuery and the underlying OpenGL resource.
bool isResultAvailable() const
Returns true if the OpenGL timer query result is available.
void destroy()
Destroys the underlying OpenGL timer query object.
void end()
Marks the end point in the OpenGL command queue for a sequence of commands to be timed by this query ...
bool isCreated() const
Returns true if the underlying OpenGL query object has been created.
GLuint objectId() const
Returns the id of the underlying OpenGL query object.
void recordTimestamp()
Places a marker in the OpenGL command queue for the GPU to record the timestamp when this marker is r...
GLuint64 waitForTimestamp() const
Returns the current timestamp of the GPU when all previously issued OpenGL commands have been receive...
bool create()
Creates the underlying OpenGL timer query object.
void begin()
Marks the start point in the OpenGL command queue for a sequence of commands to be timed by this quer...
GLuint64 waitForResult() const
Returns the result of the OpenGL timer query.
QOpenGLTimerQuery(QObject *parent=nullptr)
Creates a QOpenGLTimerQuery instance with the given parent.
Combined button and popup list for selecting options.
#define QByteArrayLiteral(str)
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char return DBusMessage return DBusMessage const char return DBusMessage dbus_bool_t return DBusMessage dbus_uint32_t return DBusMessage void
#define QOPENGLF_APIENTRYP
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
#define GL_QUERY_RESULT_AVAILABLE
#define GL_TIME_ELAPSED_EXT
constexpr decltype(auto) qMakePair(T1 &&value1, T2 &&value2) noexcept(noexcept(std::make_pair(std::forward< T1 >(value1), std::forward< T2 >(value2))))
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent