diff options
author | Mike Krus <mike.krus@kdab.com> | 2019-03-14 11:19:45 +0000 |
---|---|---|
committer | Mike Krus <mike.krus@kdab.com> | 2019-03-18 13:53:37 +0000 |
commit | e9868e157b56eea991e34712eace5962d14543e6 (patch) | |
tree | e4dfe9476a88bce3fcbfad314d0e04efb45ddca5 /src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h | |
parent | 0cbc08e2a7bf5195af8d0134e190d49d24ecabc9 (diff) |
Don't reset texture units at every frame
Resetting texture to unit assignment at every frame seems to trigger
constant shader recompilation on macOS. Maybe GL driver is implemented
on top of Metal which has more restrictions.
Not resetting the assignment means the same texture units are used
for consecutive frames and fixes excessive recompilation.
Refactored the code to move the texture handling to separate class.
Change-Id: I480f76e7e7b0ea669c6acb039cc3d079937ff97f
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h')
-rw-r--r-- | src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h b/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h index 52c6034d7..9b9bd7fa8 100644 --- a/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h +++ b/src/render/renderers/opengl/graphicshelpers/submissioncontext_p.h @@ -54,6 +54,7 @@ #include <Qt3DRender/private/graphicscontext_p.h> +#include <Qt3DRender/private/texturesubmissioncontext_p.h> #include <Qt3DRender/qclearbuffers.h> #include <Qt3DRender/private/glbuffer_p.h> #include <Qt3DRender/qattribute.h> @@ -81,13 +82,6 @@ class Buffer; class ShaderManager; struct StateVariant; -enum TextureScope -{ - TextureScopeMaterial = 0, - TextureScopeTechnique - // per-pass for deferred rendering? -}; - typedef QPair<QString, int> NamedUniformLocation; class Q_AUTOTEST_EXPORT SubmissionContext : public GraphicsContext @@ -124,11 +118,6 @@ public: QRenderTargetOutput::AttachmentPoint outputAttachmentPoint, QBlitFramebuffer::InterpolationMethod interpolationMethod); - - // Material - Material* activeMaterial() const { return m_material; } - void setActiveMaterial(Material* rmat); - // Attributes void specifyAttribute(const Attribute *attribute, Buffer *buffer, @@ -145,10 +134,6 @@ public: // Parameters bool setParameters(ShaderParameterPack ¶meterPack); - // Textures - int activateTexture(TextureScope scope, GLTexture* tex, int onUnit = -1); - void deactivateTexture(GLTexture *tex); - // RenderState void setCurrentStateSet(RenderStateSet* ss); RenderStateSet *currentStateSet() const; @@ -165,10 +150,9 @@ public: private: void initialize(); - // Textures - void decayTextureScores(); - GLint assignUnitForTexture(GLTexture* tex); - void deactivateTexturesWithScope(TextureScope ts); + // Material + Material* activeMaterial() const { return m_material; } + void setActiveMaterial(Material* rmat); // FBO void bindFrameBufferAttachmentHelper(GLuint fboId, const AttachmentPack &attachments); @@ -177,7 +161,6 @@ private: GLuint createRenderTarget(Qt3DCore::QNodeId renderTargetNodeId, const AttachmentPack &attachments); GLuint updateRenderTarget(Qt3DCore::QNodeId renderTargetNodeId, const AttachmentPack &attachments, bool isActiveRenderTarget); - // Buffers HGLBuffer createGLBufferFor(Buffer *buffer, GLBuffer::Type type); void uploadDataToGLBuffer(Buffer *buffer, GLBuffer *b, bool releaseBuffer = false); @@ -197,15 +180,6 @@ private: QHash<GLuint, QSize> m_renderTargetsSize; QAbstractTexture::TextureFormat m_renderTargetFormat; - // active textures, indexed by texture unit - struct ActiveTexture { - GLTexture *texture = nullptr; - int score = 0; - TextureScope scope = TextureScopeMaterial; - bool pinned = false; - }; - QVector<ActiveTexture> m_activeTextures; - // cache some current state, to make sure we don't issue unnecessary GL calls int m_currClearStencilValue; float m_currClearDepthValue; @@ -220,6 +194,7 @@ private: Renderer *m_renderer; QByteArray m_uboTempArray; + TextureSubmissionContext m_textureContext; // Attributes friend class OpenGLVertexArrayObject; |