Commit b13bf4f8 authored by Andy Nichols's avatar Andy Nichols Committed by Qt Cherry-pick Bot
Browse files

Don't try and execute a draw call with an instance count of 0



It is invalid to call a draw call with an instance count of 0 with metal
and this can lead to a validation error. Better to bail out as soon as
we know the instance count will be 0.

Change-Id: I16fdc17ebb1d75624f04cd680bf9e4df9e27729d
Reviewed-by: default avatarLaszlo Agocs <laszlo.agocs@qt.io>
(cherry picked from commit 64d135bc

)
Reviewed-by: default avatarQt Cherry-pick Bot <cherrypick_bot@qt-project.org>
parent 5affbc13
......@@ -4096,6 +4096,12 @@ static void rhiRenderRenderable(QSSGRhiContext *rhiCtx,
quint32 instances = 1;
if ( subsetRenderable.modelContext.model.instancing()) {
instances = subsetRenderable.modelContext.model.instanceCount();
// If the instance count is 0, the bail out before trying to do any
// draw calls. Making an instanced draw call with a count of 0 is invalid
// for Metal and likely other API's as well.
// It is possible that the particale system may produce 0 instances here
if (instances == 0)
return;
vertexBuffers[1] = QRhiCommandBuffer::VertexInput(subsetRenderable.instanceBuffer, 0);
vertexBufferCount = 2;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment