Prevent drawing MultiMesh with zero instance count

Issuing a driver drawcall for MultiMesh with zero instances crashes some drivers.
This commit is contained in:
lawnjelly 2022-09-15 13:20:12 +01:00 committed by Relintai
parent 0859d5b60f
commit 19dc79114d
2 changed files with 13 additions and 7 deletions

View File

@ -935,7 +935,15 @@ void RasterizerCanvasGLES2::render_batches(Item *p_current_clip, bool &r_reclip,
break;
}
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != RS::MULTIMESH_CUSTOM_DATA_NONE);
int amount = MIN(multi_mesh->size, multi_mesh->visible_instances);
if (amount == -1) {
amount = multi_mesh->size;
}
if (!amount) {
break;
}
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCING, true);
_set_texture_rect_mode(false);
@ -953,12 +961,6 @@ void RasterizerCanvasGLES2::render_batches(Item *p_current_clip, bool &r_reclip,
//reset shader and force rebind
int amount = MIN(multi_mesh->size, multi_mesh->visible_instances);
if (amount == -1) {
amount = multi_mesh->size;
}
int stride = multi_mesh->color_floats + multi_mesh->custom_data_floats + multi_mesh->xform_floats;
int color_ofs = multi_mesh->xform_floats;

View File

@ -1710,6 +1710,10 @@ void RasterizerSceneGLES2::_render_geometry(RenderList::Element *p_element) {
amount = multi_mesh->size;
}
if (!amount) {
return;
}
int stride = multi_mesh->color_floats + multi_mesh->custom_data_floats + multi_mesh->xform_floats;
int color_ofs = multi_mesh->xform_floats;