summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Vistnes <harald.vistnes@gmail.com>2017-10-08 11:09:34 +0200
committerHarald Vistnes <harald.vistnes@gmail.com>2017-10-09 05:35:39 +0000
commit3532ac70ce69de608d14c24d18b42a6781edf4be (patch)
tree4df43e6e02e2e38c0d996719acc0f6e8c7186a41
parent6ae3debbc983927fc74c8ee29cfccfc8bf02c646 (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>
-rw-r--r--src/render/backend/renderer.cpp3
-rw-r--r--src/render/graphicshelpers/graphicscontext.cpp9
-rw-r--r--src/render/graphicshelpers/graphicscontext_p.h2
3 files changed, 11 insertions, 3 deletions
diff --git a/src/render/backend/renderer.cpp b/src/render/backend/renderer.cpp
index 889888945..19cc97dc5 100644
--- a/src/render/backend/renderer.cpp
+++ b/src/render/backend/renderer.cpp
@@ -1650,7 +1650,8 @@ bool Renderer::executeCommandsSubmission(const RenderView *rv)
{
Profiling::GLTimeRecorder recorder(Profiling::UniformUpdate);
//// Update program uniforms
- m_graphicsContext->setParameters(command->m_parameterPack);
+ if (!m_graphicsContext->setParameters(command->m_parameterPack))
+ allCommandsIssued = false;
}
//// OpenGL State
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 &parameterPack)
+bool GraphicsContext::setParameters(ShaderParameterPack &parameterPack)
{
// 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 &parameterPack)
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 &parameterPack)
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 &parameterPack);
+ bool setParameters(ShaderParameterPack &parameterPack);
/**
* @brief glBufferFor - given a client-side (CPU) buffer, provide the