From 163f6a17e4fe60ce917715afc5bb5eae3d5ff07a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?K=C3=A9vin=20Dietrich?= Date: Wed, 27 Apr 2022 15:30:17 +0200 Subject: Fix T96434: bad performance with viewport statistics and GPU subdivision The subdivision is always recomputed on the CPU when displaying stats if the mesh is animated which leads to bad performance. This caches the subdivision topology counters from the draw code in the mesh runtime and uses them for the viewport statistics. Differential Revision: https://developer.blender.org/D14774 --- source/blender/draw/intern/draw_cache_impl_subdivision.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'source/blender/draw') diff --git a/source/blender/draw/intern/draw_cache_impl_subdivision.cc b/source/blender/draw/intern/draw_cache_impl_subdivision.cc index 8944388a5ac..4a39ca6dacb 100644 --- a/source/blender/draw/intern/draw_cache_impl_subdivision.cc +++ b/source/blender/draw/intern/draw_cache_impl_subdivision.cc @@ -1953,6 +1953,13 @@ static bool draw_subdiv_create_requested_buffers(const Scene *scene, draw_cache->optimal_display = optimal_display; draw_cache->num_subdiv_triangles = tris_count_from_number_of_loops(draw_cache->num_subdiv_loops); + /* Copy topology information for stats display. Use `mesh` directly, as `mesh_eval` could be the + * edit mesh. */ + mesh->runtime.subsurf_totvert = draw_cache->num_subdiv_verts; + mesh->runtime.subsurf_totedge = draw_cache->num_subdiv_edges; + mesh->runtime.subsurf_totpoly = draw_cache->num_subdiv_quads; + mesh->runtime.subsurf_totloop = draw_cache->num_subdiv_loops; + draw_cache->use_custom_loop_normals = (smd->flags & eSubsurfModifierFlag_UseCustomNormals) && (mesh_eval->flag & ME_AUTOSMOOTH) && CustomData_has_layer(&mesh_eval->ldata, -- cgit v1.2.3