diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2020-01-13 09:13:18 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-13 09:13:18 +0100 |
commit | 8130decfe4b4be31d3bf8ca9c519927052a942fc (patch) | |
tree | 69c94d82d808fe8c4d5a8b65effa7acd0c876dec /drivers/gles3 | |
parent | b5cfe9d74521e5595e1afb8cfd6cfe5e2ffda7da (diff) | |
parent | 179193775b83b02f16ae396e2a028266cbf23abe (diff) |
Merge pull request #35064 from clayjohn/rendering_crashes
Fix light and multimesh crashes
Diffstat (limited to 'drivers/gles3')
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.cpp | 4 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_storage_gles3.cpp | 16 |
2 files changed, 12 insertions, 8 deletions
diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 3ee39ede18..1be0c46668 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -1891,13 +1891,13 @@ void RasterizerSceneGLES3::_setup_light(RenderList::Element *e, const Transform if (li->last_pass != render_pass) //not visible continue; - if (li->light_ptr->type == VS::LIGHT_OMNI) { + if (li && li->light_ptr->type == VS::LIGHT_OMNI) { if (omni_count < maxobj && e->instance->layer_mask & li->light_ptr->cull_mask) { omni_indices[omni_count++] = li->light_index; } } - if (li->light_ptr->type == VS::LIGHT_SPOT) { + if (li && li->light_ptr->type == VS::LIGHT_SPOT) { if (spot_count < maxobj && e->instance->layer_mask & li->light_ptr->cull_mask) { spot_indices[spot_count++] = li->light_index; } diff --git a/drivers/gles3/rasterizer_storage_gles3.cpp b/drivers/gles3/rasterizer_storage_gles3.cpp index c02f17ab95..335931efd1 100644 --- a/drivers/gles3/rasterizer_storage_gles3.cpp +++ b/drivers/gles3/rasterizer_storage_gles3.cpp @@ -4470,20 +4470,20 @@ void RasterizerStorageGLES3::multimesh_allocate(RID p_multimesh, int p_instances multimesh->xform_floats = 12; } - if (multimesh->color_format == VS::MULTIMESH_COLOR_NONE) { - multimesh->color_floats = 0; - } else if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) { + if (multimesh->color_format == VS::MULTIMESH_COLOR_8BIT) { multimesh->color_floats = 1; } else if (multimesh->color_format == VS::MULTIMESH_COLOR_FLOAT) { multimesh->color_floats = 4; + } else { + multimesh->color_floats = 0; } - if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE) { - multimesh->custom_data_floats = 0; - } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) { + if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_8BIT) { multimesh->custom_data_floats = 1; } else if (multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_FLOAT) { multimesh->custom_data_floats = 4; + } else { + multimesh->custom_data_floats = 0; } int format_floats = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; @@ -4679,6 +4679,7 @@ void RasterizerStorageGLES3::multimesh_instance_set_color(RID p_multimesh, int p ERR_FAIL_COND(!multimesh); ERR_FAIL_INDEX(p_index, multimesh->size); ERR_FAIL_COND(multimesh->color_format == VS::MULTIMESH_COLOR_NONE); + ERR_FAIL_INDEX(multimesh->color_format, VS::MULTIMESH_COLOR_FLOAT); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats]; @@ -4712,6 +4713,7 @@ void RasterizerStorageGLES3::multimesh_instance_set_custom_data(RID p_multimesh, ERR_FAIL_COND(!multimesh); ERR_FAIL_INDEX(p_index, multimesh->size); ERR_FAIL_COND(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE); + ERR_FAIL_INDEX(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_FLOAT); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats]; @@ -4800,6 +4802,7 @@ Color RasterizerStorageGLES3::multimesh_instance_get_color(RID p_multimesh, int ERR_FAIL_COND_V(!multimesh, Color()); ERR_FAIL_INDEX_V(p_index, multimesh->size, Color()); ERR_FAIL_COND_V(multimesh->color_format == VS::MULTIMESH_COLOR_NONE, Color()); + ERR_FAIL_INDEX_V(multimesh->color_format, VS::MULTIMESH_COLOR_FLOAT, Color()); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats]; @@ -4833,6 +4836,7 @@ Color RasterizerStorageGLES3::multimesh_instance_get_custom_data(RID p_multimesh ERR_FAIL_COND_V(!multimesh, Color()); ERR_FAIL_INDEX_V(p_index, multimesh->size, Color()); ERR_FAIL_COND_V(multimesh->custom_data_format == VS::MULTIMESH_CUSTOM_DATA_NONE, Color()); + ERR_FAIL_INDEX_V(multimesh->custom_data_format, VS::MULTIMESH_CUSTOM_DATA_FLOAT, Color()); int stride = multimesh->color_floats + multimesh->xform_floats + multimesh->custom_data_floats; float *dataptr = &multimesh->data.write[stride * p_index + multimesh->xform_floats + multimesh->color_floats]; |