Cache the current QOpenGLFramebufferObject
This doesn't cover FBOs bound directly with glBindFramebuffer(), but it's perfect to create a fast path for code we know uses QOGLFBO, thus avoiding expensive glGetIntegerv() driver calls. The use case is to use this in QSG24BitTextMaskShader::activate(), where we need to check if the current FBO is sRGB capable. Change-Id: I434eeeb7e6a3d16be9327315536ad7280245085d Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io> Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
parent
fbc9edb5e7
commit
0681e60380
@ -61,6 +61,7 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
class QOpenGLFunctions;
|
class QOpenGLFunctions;
|
||||||
class QOpenGLContext;
|
class QOpenGLContext;
|
||||||
|
class QOpenGLFramebufferObject;
|
||||||
class QOpenGLMultiGroupSharedResource;
|
class QOpenGLMultiGroupSharedResource;
|
||||||
|
|
||||||
class Q_GUI_EXPORT QOpenGLSharedResource
|
class Q_GUI_EXPORT QOpenGLSharedResource
|
||||||
@ -204,6 +205,7 @@ public:
|
|||||||
, workaround_missingPrecisionQualifiers(false)
|
, workaround_missingPrecisionQualifiers(false)
|
||||||
, active_engine(0)
|
, active_engine(0)
|
||||||
, qgl_current_fbo_invalid(false)
|
, qgl_current_fbo_invalid(false)
|
||||||
|
, qgl_current_fbo(Q_NULLPTR)
|
||||||
, defaultFboRedirect(0)
|
, defaultFboRedirect(0)
|
||||||
{
|
{
|
||||||
requestedFormat = QSurfaceFormat::defaultFormat();
|
requestedFormat = QSurfaceFormat::defaultFormat();
|
||||||
@ -242,6 +244,11 @@ public:
|
|||||||
|
|
||||||
bool qgl_current_fbo_invalid;
|
bool qgl_current_fbo_invalid;
|
||||||
|
|
||||||
|
// Set and unset in QOpenGLFramebufferObject::bind()/unbind().
|
||||||
|
// (Only meaningful for QOGLFBO since an FBO might be bound by other means)
|
||||||
|
// Saves us from querying the driver for the current FBO in most paths.
|
||||||
|
QOpenGLFramebufferObject *qgl_current_fbo;
|
||||||
|
|
||||||
QVariant nativeHandle;
|
QVariant nativeHandle;
|
||||||
GLuint defaultFboRedirect;
|
GLuint defaultFboRedirect;
|
||||||
|
|
||||||
|
@ -1068,6 +1068,7 @@ bool QOpenGLFramebufferObject::bind()
|
|||||||
d->funcs.glBindFramebuffer(GL_FRAMEBUFFER, d->fbo());
|
d->funcs.glBindFramebuffer(GL_FRAMEBUFFER, d->fbo());
|
||||||
|
|
||||||
QOpenGLContextPrivate::get(current)->qgl_current_fbo_invalid = true;
|
QOpenGLContextPrivate::get(current)->qgl_current_fbo_invalid = true;
|
||||||
|
QOpenGLContextPrivate::get(current)->qgl_current_fbo = this;
|
||||||
|
|
||||||
if (d->format.samples() == 0) {
|
if (d->format.samples() == 0) {
|
||||||
// Create new textures to replace the ones stolen via takeTexture().
|
// Create new textures to replace the ones stolen via takeTexture().
|
||||||
@ -1107,7 +1108,9 @@ bool QOpenGLFramebufferObject::release()
|
|||||||
if (current) {
|
if (current) {
|
||||||
d->funcs.glBindFramebuffer(GL_FRAMEBUFFER, current->defaultFramebufferObject());
|
d->funcs.glBindFramebuffer(GL_FRAMEBUFFER, current->defaultFramebufferObject());
|
||||||
|
|
||||||
QOpenGLContextPrivate::get(current)->qgl_current_fbo_invalid = true;
|
QOpenGLContextPrivate *contextPrv = QOpenGLContextPrivate::get(current);
|
||||||
|
contextPrv->qgl_current_fbo_invalid = true;
|
||||||
|
contextPrv->qgl_current_fbo = Q_NULLPTR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user