Prevent drawing MultiMesh with zero instance count
Issuing a driver drawcall for MultiMesh with zero instances crashes some drivers.
This commit is contained in:
parent
5600be9571
commit
a300505066
|
@ -935,6 +935,16 @@ void RasterizerCanvasGLES2::render_batches(Item *p_current_clip, bool &r_reclip,
|
|||
break;
|
||||
}
|
||||
|
||||
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_INSTANCE_CUSTOM, multi_mesh->custom_data_format != VS::MULTIMESH_CUSTOM_DATA_NONE);
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_INSTANCING, true);
|
||||
_set_texture_rect_mode(false);
|
||||
|
@ -953,12 +963,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;
|
||||
|
|
|
@ -1738,6 +1738,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;
|
||||
|
|
|
@ -850,6 +850,16 @@ void RasterizerCanvasGLES3::render_batches(Item *p_current_clip, bool &r_reclip,
|
|||
break;
|
||||
}
|
||||
|
||||
int amount = MIN(multi_mesh->size, multi_mesh->visible_instances);
|
||||
|
||||
if (amount == -1) {
|
||||
amount = multi_mesh->size;
|
||||
}
|
||||
|
||||
if (!amount) {
|
||||
break;
|
||||
}
|
||||
|
||||
RasterizerStorageGLES3::Texture *texture = _bind_canvas_texture(mmesh->texture, mmesh->normal_map);
|
||||
|
||||
state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_INSTANCE_CUSTOM, multi_mesh->custom_data_format != VS::MULTIMESH_CUSTOM_DATA_NONE);
|
||||
|
@ -863,12 +873,6 @@ void RasterizerCanvasGLES3::render_batches(Item *p_current_clip, bool &r_reclip,
|
|||
state.canvas_shader.set_uniform(CanvasShaderGLES3::COLOR_TEXPIXEL_SIZE, texpixel_size);
|
||||
}
|
||||
|
||||
int amount = MIN(multi_mesh->size, multi_mesh->visible_instances);
|
||||
|
||||
if (amount == -1) {
|
||||
amount = multi_mesh->size;
|
||||
}
|
||||
|
||||
glVertexAttrib4f(VS::ARRAY_COLOR, 1.0, 1.0, 1.0, 1.0);
|
||||
|
||||
for (int j = 0; j < mesh_data->surfaces.size(); j++) {
|
||||
|
|
|
@ -1526,6 +1526,10 @@ void RasterizerSceneGLES3::_render_geometry(RenderList::Element *e) {
|
|||
if (amount == -1) {
|
||||
amount = multi_mesh->size;
|
||||
}
|
||||
|
||||
if (!amount) {
|
||||
return;
|
||||
}
|
||||
#ifdef DEBUG_ENABLED
|
||||
|
||||
if (state.debug_draw == VS::VIEWPORT_DEBUG_DRAW_WIREFRAME && s->array_wireframe_id) {
|
||||
|
|
Loading…
Reference in New Issue