Skip to content

Commit

Permalink
Ensure buffer is allocated (if necesary) before setting the buffer va…
Browse files Browse the repository at this point in the history
…lues
  • Loading branch information
MarianoGnu authored and brunosxs committed May 13, 2024
1 parent fedf315 commit 0e606cc
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion servers/rendering/renderer_rd/storage_rd/mesh_storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1930,11 +1930,22 @@ void MeshStorage::multimesh_set_buffer(RID p_multimesh, const Vector<float> &p_b
ERR_FAIL_NULL(multimesh);
ERR_FAIL_COND(p_buffer.size() != (multimesh->instances * (int)multimesh->stride_cache));

if (!multimesh->buffer.is_valid()) {
uint32_t buffer_size = multimesh->instances * multimesh->stride_cache * sizeof(float);
if (multimesh->motion_vectors_enabled) {
buffer_size *= 2;
}
if (buffer_size == 0) {
return;
}
multimesh->buffer = RD::get_singleton()->storage_buffer_create(buffer_size);
}

bool uses_motion_vectors = (RSG::viewport->get_num_viewports_with_motion_vectors() > 0);
if (uses_motion_vectors) {
_multimesh_enable_motion_vectors(multimesh);
}

if (multimesh->motion_vectors_enabled) {
uint32_t frame = RSG::rasterizer->get_frame_number();

Expand Down

0 comments on commit 0e606cc

Please sign in to comment.