From e52382023b85c435e9c1e3a37eeac65178ee54e0 Mon Sep 17 00:00:00 2001 From: Paul Lemire Date: Fri, 14 Feb 2020 10:20:38 +0100 Subject: Fix and improve FBO handling FBO need to be rebuild when one of the attachments directly or indirectly changes. By direct change we mean one of the FBO attachment texture being resized or the list of attachments changing. By indirect we mean when texture resource is recreated internally by the engine. Failure to handle this cases resulted in FBO referencing invalid attachments. Change-Id: I8dd4c08e464eed7fb0eeefd61a4158304ab4245f Task-number: QTBUG-64757 Reviewed-by: Mike Krus --- .../opengl/graphicshelpers/submissioncontext_p.h | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h') diff --git a/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h b/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h index 0f769fa1c..fd42090dd 100644 --- a/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h +++ b/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h @@ -62,6 +62,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -158,7 +159,16 @@ public: bool wasSyncSignaled(GLFence sync); void deleteSync(GLFence sync); + // Textures + void setUpdatedTexture(const Qt3DCore::QNodeIdVector &updatedTextureIds); + private: + struct RenderTargetInfo { + GLuint fboId; + QSize size; + AttachmentPack attachments; + }; + void initialize(); // Material @@ -166,7 +176,7 @@ private: void setActiveMaterial(Material* rmat); // FBO - void bindFrameBufferAttachmentHelper(GLuint fboId, const AttachmentPack &attachments); + RenderTargetInfo bindFrameBufferAttachmentHelper(GLuint fboId, const AttachmentPack &attachments); void activateDrawBuffers(const AttachmentPack &attachments); void resolveRenderTargetFormat(); GLuint createRenderTarget(Qt3DCore::QNodeId renderTargetNodeId, const AttachmentPack &attachments); @@ -187,8 +197,9 @@ private: ProgramDNA m_activeShaderDNA; QHash m_renderBufferHash; - QHash m_renderTargets; - QHash m_renderTargetsSize; + + + QHash m_renderTargets; QAbstractTexture::TextureFormat m_renderTargetFormat; // cache some current state, to make sure we don't issue unnecessary GL calls @@ -199,6 +210,7 @@ private: Material* m_material; QRectF m_viewport; GLuint m_activeFBO; + Qt3DCore::QNodeId m_activeFBONodeId; GLBuffer *m_boundArrayBuffer; RenderStateSet* m_stateSet; @@ -227,6 +239,8 @@ private: using VAOIndexAttribute = HGLBuffer; void enableAttribute(const VAOVertexAttribute &attr); void disableAttribute(const VAOVertexAttribute &attr); + + Qt3DCore::QNodeIdVector m_updateTextureIds; }; } // namespace Render -- cgit v1.2.3