diff options
author | Harald Vistnes <harald.vistnes@gmail.com> | 2017-10-08 11:09:34 +0200 |
---|---|---|
committer | Harald Vistnes <harald.vistnes@gmail.com> | 2017-10-09 05:35:39 +0000 |
commit | 3532ac70ce69de608d14c24d18b42a6781edf4be (patch) | |
tree | 4df43e6e02e2e38c0d996719acc0f6e8c7186a41 /src/render/graphicshelpers | |
parent | 6ae3debbc983927fc74c8ee29cfccfc8bf02c646 (diff) |
Render next frame if texture data is not available
Texture data from generators may not be available in the current frame and
the next frame should be rendered immediately, even in OnDemand rendering.
The problem was that this information was not propagated back to the
renderer, it was just silently ignored inside
GraphicsContext::setParameters. Added a bool return type to
GraphicsContext::setParameters so that the renderer could check for
errors.
Task-number: QTBUG-63561
Task-number: QTBUG-59752
Change-Id: I18fb6f8236bf47d3eeab07d879dffaa599665e6b
Reviewed-by: Paul Lemire <paul.lemire@kdab.com>
Diffstat (limited to 'src/render/graphicshelpers')
-rw-r--r-- | src/render/graphicshelpers/graphicscontext.cpp | 9 | ||||
-rw-r--r-- | src/render/graphicshelpers/graphicscontext_p.h | 2 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/render/graphicshelpers/graphicscontext.cpp b/src/render/graphicshelpers/graphicscontext.cpp index 7b09985a7..5ac83cac0 100644 --- a/src/render/graphicshelpers/graphicscontext.cpp +++ b/src/render/graphicshelpers/graphicscontext.cpp @@ -1161,10 +1161,11 @@ void GraphicsContext::setRenderer(Renderer *renderer) // It will be easier if the QGraphicContext applies the QUniformPack // than the other way around -void GraphicsContext::setParameters(ShaderParameterPack ¶meterPack) +bool GraphicsContext::setParameters(ShaderParameterPack ¶meterPack) { // Activate textures and update TextureUniform in the pack // with the correct textureUnit + bool allValid = true; // Set the pinned texture of the previous material texture // to pinable so that we should easily find an available texture unit @@ -1184,6 +1185,10 @@ void GraphicsContext::setParameters(ShaderParameterPack ¶meterPack) Q_ASSERT(texUniform.valueType() == UniformValue::TextureValue); const int texUnit = activateTexture(TextureScopeMaterial, t); texUniform.data<UniformValue::Texture>()->textureId = texUnit; + // if the texture data from generators may not be available yet, + // make sure that the next frame is rendered + if (texUnit == -1) + allValid = false; } } } @@ -1238,6 +1243,8 @@ void GraphicsContext::setParameters(ShaderParameterPack ¶meterPack) applyUniform(uniform, v); } + // if not all data is valid, the next frame will be rendered immediately + return allValid; } void GraphicsContext::enableAttribute(const VAOVertexAttribute &attr) diff --git a/src/render/graphicshelpers/graphicscontext_p.h b/src/render/graphicshelpers/graphicscontext_p.h index 2e2d4584b..79089a31e 100644 --- a/src/render/graphicshelpers/graphicscontext_p.h +++ b/src/render/graphicshelpers/graphicscontext_p.h @@ -166,7 +166,7 @@ public: void memoryBarrier(QMemoryBarrier::Operations barriers); - void setParameters(ShaderParameterPack ¶meterPack); + bool setParameters(ShaderParameterPack ¶meterPack); /** * @brief glBufferFor - given a client-side (CPU) buffer, provide the |