diff options
author | Paul Lemire <paul.lemire@kdab.com> | 2020-02-14 10:20:38 +0100 |
---|---|---|
committer | Paul Lemire <paul.lemire@kdab.com> | 2020-02-17 07:03:58 +0100 |
commit | e52382023b85c435e9c1e3a37eeac65178ee54e0 (patch) | |
tree | 82624e1155601df7d21e05c6152431f1082b5937 /src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h | |
parent | 42c0dbc377af4d307747a32ca1c1fd267ce4337f (diff) |
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 <mike.krus@kdab.com>
Diffstat (limited to 'src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h')
-rw-r--r-- | src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h | 20 |
1 files changed, 17 insertions, 3 deletions
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 <Qt3DRender/private/handle_types_p.h> #include <Qt3DRender/private/shadercache_p.h> #include <Qt3DRender/private/glfence_p.h> +#include <Qt3DRender/private/attachmentpack_p.h> 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<Qt3DCore::QNodeId, HGLBuffer> m_renderBufferHash; - QHash<Qt3DCore::QNodeId, GLuint> m_renderTargets; - QHash<GLuint, QSize> m_renderTargetsSize; + + + QHash<Qt3DCore::QNodeId, RenderTargetInfo> 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 |