diff --git a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc index c10af79eb4f..ad37535a64f 100644 --- a/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc +++ b/source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc @@ -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 data = GPU_indexbuf_get_data(&builder).cast(); 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)