Fix #142583: Uninitialized data in edit UV lines index buffer

Caused by a slightly weird API, that has no good way to recieve
the final size of a partially used index buffer. Until this is refactored
more, just assign this data manually.

Pull Request: https://projects.blender.org/blender/blender/pulls/142748
This commit is contained in:
Hans Goudey
2025-07-21 21:06:49 +02:00
committed by Hans Goudey
parent ce0ae95ed3
commit d84f10f2a0

View File

@@ -155,8 +155,6 @@ static gpu::IndexBufPtr extract_edituv_lines_bm(const MeshRenderData &mr,
const bool sync_selection)
{
GPUIndexBufBuilder builder;
/* The entire data array might not be used. It might be beneficial to count the number of visible
* edges first, especially if that allows parallelizing filling the data array. */
GPU_indexbuf_init(&builder, GPU_PRIM_LINES, mr.corners_num, mr.corners_num);
MutableSpan<uint2> data = GPU_indexbuf_get_data(&builder).cast<uint2>();
int line_index = 0;
@@ -174,7 +172,16 @@ static gpu::IndexBufPtr extract_edituv_lines_bm(const MeshRenderData &mr,
}
}
return gpu::IndexBufPtr(GPU_indexbuf_build_ex(&builder, 0, mr.corners_num, false));
/* Only upload the part of the index buffer that is used. Alternatively it might be beneficial to
* count the number of visible edges first, especially if that allows parallelizing filling the
* data array. */
builder.index_len = line_index * 2;
builder.index_min = 0;
builder.index_max = mr.corners_num;
builder.uses_restart_indices = false;
gpu::IndexBufPtr result = gpu::IndexBufPtr(GPU_indexbuf_calloc());
GPU_indexbuf_build_in_place(&builder, result.get());
return result;
}
static gpu::IndexBufPtr extract_edituv_lines_mesh(const MeshRenderData &mr,
@@ -236,7 +243,16 @@ static gpu::IndexBufPtr extract_edituv_lines_mesh(const MeshRenderData &mr,
});
}
return gpu::IndexBufPtr(GPU_indexbuf_build_ex(&builder, 0, mr.corners_num, false));
/* Only upload the part of the index buffer that is used. Alternatively it might be beneficial to
* count the number of visible edges first, especially if that allows parallelizing filling the
* data array. */
builder.index_len = line_index;
builder.index_min = 0;
builder.index_max = mr.corners_num;
builder.uses_restart_indices = false;
gpu::IndexBufPtr result = gpu::IndexBufPtr(GPU_indexbuf_calloc());
GPU_indexbuf_build_in_place(&builder, result.get());
return result;
}
gpu::IndexBufPtr extract_edituv_lines(const MeshRenderData &mr, bool edit_uvs)