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 GLES3 multimesh rendering when using colors or custom data #79660

Merged
merged 1 commit into from
Jul 24, 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
8 changes: 6 additions & 2 deletions drivers/gles3/storage/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,13 +1284,17 @@ void MeshStorage::multimesh_allocate_data(RID p_multimesh, int p_instances, RS::
multimesh->data_cache_used_dirty_regions = 0;
}

// If we have either color or custom data, reserve space for both to make data handling logic simpler.
// This way we can always treat them both as a single, compressed uvec4.
int color_and_custom_strides = (p_use_colors || p_use_custom_data) ? 2 : 0;

multimesh->instances = p_instances;
multimesh->xform_format = p_transform_format;
multimesh->uses_colors = p_use_colors;
multimesh->color_offset_cache = p_transform_format == RS::MULTIMESH_TRANSFORM_2D ? 8 : 12;
multimesh->uses_custom_data = p_use_custom_data;
multimesh->custom_data_offset_cache = multimesh->color_offset_cache + (p_use_colors ? 2 : 0);
multimesh->stride_cache = multimesh->custom_data_offset_cache + (p_use_custom_data ? 2 : 0);
multimesh->custom_data_offset_cache = multimesh->color_offset_cache + color_and_custom_strides;
multimesh->stride_cache = multimesh->custom_data_offset_cache + color_and_custom_strides;
multimesh->buffer_set = false;

multimesh->data_cache = Vector<float>();
Expand Down