Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory access error for MultiMesh with GLES3 #80788

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix memory access error for MultiMesh with GLES3
Buffer was incorrectly assigned when invalid data was provided
  • Loading branch information
AThousandShips committed Aug 19, 2023
commit 6cb28e481f72d6fa1b2d06ff1e0c8664dcbd22ca
6 changes: 4 additions & 2 deletions drivers/gles3/storage/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,14 +1689,16 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
// Color and custom need to be packed so copy buffer to data_cache and pack.

_multimesh_make_local(multimesh);
multimesh->data_cache = p_buffer;

float *w = multimesh->data_cache.ptrw();
uint32_t old_stride = multimesh->xform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
old_stride += multimesh->uses_colors ? 4 : 0;
old_stride += multimesh->uses_custom_data ? 4 : 0;
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)old_stride));

multimesh->data_cache = p_buffer;

float *w = multimesh->data_cache.ptrw();

for (int i = 0; i < multimesh->instances; i++) {
{
float *dataptr = w + i * old_stride;
Expand Down