diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-01-24 20:42:37 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-01-24 20:42:37 +0300 |
commit | e2337b53424f7d89ee4fe1ff90b4ab71b6a0a9d7 (patch) | |
tree | b7477163abc2e72a53eadad61df5cbde9ece75d5 /source/blender/draw/intern/draw_cache_impl_subdivision.cc | |
parent | 90d61600fca97910aafabac4b7f638d2f64dd3ff (diff) |
GPU subdiv: reduce memory usage for point IBO
The point IBO should only have data for coarse vertices (or in general,
the vertices in the original mesh). As it used for displaying the
vertices for selection in edit mode, and as it indexes into the VBOs for
the positions and edit data, it is itself only indexed by coarse/
original vertex index.
For the subdivision case, this would allocate space for the final
subdivision vertex and reallocate to make room for loose geometry,
although only the first coarse vertex count amount of data would be.
Now just allocate for the required memory. Also reuse index buffer APIs
instead of doing manual work.
Diffstat (limited to 'source/blender/draw/intern/draw_cache_impl_subdivision.cc')
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_subdivision.cc | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 60ab2ef8062..2f0c5cca3d6 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -752,9 +752,10 @@ static bool draw_subdiv_topology_info_cb(const SubdivForeachContext *foreach_con cache->subdiv_loop_poly_index = static_cast<int *>( MEM_mallocN(cache->num_subdiv_loops * sizeof(int), "subdiv_loop_poly_index")); + const int num_coarse_vertices = ctx->coarse_mesh->totvert; cache->point_indices = static_cast<int *>( - MEM_mallocN(cache->num_subdiv_verts * sizeof(int), "point_indices")); - for (int i = 0; i < num_vertices; i++) { + MEM_mallocN(num_coarse_vertices * sizeof(int), "point_indices")); + for (int i = 0; i < num_coarse_vertices; i++) { cache->point_indices[i] = -1; } |