diff options
author | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-01-16 09:31:12 +0300 |
---|---|---|
committer | Kévin Dietrich <kevin.dietrich@mailoo.org> | 2022-01-16 09:31:26 +0300 |
commit | 3574f2730d2a42cda2881d26209b8dc53b1d2047 (patch) | |
tree | dfd1aa439249d44ce10de737aea5259db70781c8 /source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc | |
parent | b87d87b1d3c8400e4ee4ea3f0763df64c8ca7fc0 (diff) |
Cleanup: deduplicate GPU subdiv data extraction loops
This puts the loop over the final subdivision quads outside of the mesh
iteration callback. This can also allow for easier parallel execution in
the future if need be.
Diffstat (limited to 'source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc')
-rw-r--r-- | source/blender/draw/intern/mesh_extractors/extract_mesh_ibo_edituv.cc | 76 |
1 files changed, 38 insertions, 38 deletions
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 5cb77426438..3a2b6d468d8 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 @@ -112,30 +112,29 @@ static void extract_edituv_tris_init_subdiv(const DRWSubdivCache *subdiv_cache, static void extract_edituv_tris_iter_subdiv(const DRWSubdivCache *subdiv_cache, const MeshRenderData *mr, - void *_data) + void *_data, + uint subdiv_quad_index) { MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); int *subdiv_loop_poly_index = subdiv_cache->subdiv_loop_poly_index; - for (uint i = 0; i < subdiv_cache->num_subdiv_quads; i++) { - const uint loop_idx = i * 4; - const int poly_origindex = subdiv_loop_poly_index[loop_idx]; - BMFace *efa = bm_original_face_get(mr, poly_origindex); + const uint loop_idx = subdiv_quad_index * 4; + const int poly_origindex = subdiv_loop_poly_index[loop_idx]; + BMFace *efa = bm_original_face_get(mr, poly_origindex); - edituv_tri_add(data, - BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0, - BM_elem_flag_test(efa, BM_ELEM_SELECT) != 0, - loop_idx, - loop_idx + 1, - loop_idx + 2); - - edituv_tri_add(data, - BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0, - BM_elem_flag_test(efa, BM_ELEM_SELECT) != 0, - loop_idx, - loop_idx + 2, - loop_idx + 3); - } + edituv_tri_add(data, + BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0, + BM_elem_flag_test(efa, BM_ELEM_SELECT) != 0, + loop_idx, + loop_idx + 1, + loop_idx + 2); + + edituv_tri_add(data, + BM_elem_flag_test(efa, BM_ELEM_HIDDEN) != 0, + BM_elem_flag_test(efa, BM_ELEM_SELECT) != 0, + loop_idx, + loop_idx + 2, + loop_idx + 3); } static void extract_edituv_tris_finish_subdiv(const struct DRWSubdivCache *UNUSED(subdiv_cache), @@ -256,30 +255,28 @@ static void extract_edituv_lines_init_subdiv(const DRWSubdivCache *subdiv_cache, static void extract_edituv_lines_iter_subdiv(const DRWSubdivCache *subdiv_cache, const MeshRenderData *mr, - void *_data) + void *_data, + uint subdiv_quad_index) { MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); int *subdiv_loop_poly_index = subdiv_cache->subdiv_loop_poly_index; int *subdiv_loop_edge_index = (int *)GPU_vertbuf_get_data(subdiv_cache->edges_orig_index); - for (uint i = 0; i < subdiv_cache->num_subdiv_quads; i++) { + uint start_loop_idx = subdiv_quad_index * 4; + uint end_loop_idx = (subdiv_quad_index + 1) * 4; - uint start_loop_idx = i * 4; - uint end_loop_idx = (i + 1) * 4; + const int poly_origindex = subdiv_loop_poly_index[start_loop_idx]; + BMFace *efa = bm_original_face_get(mr, poly_origindex); - const int poly_origindex = subdiv_loop_poly_index[start_loop_idx]; - BMFace *efa = bm_original_face_get(mr, poly_origindex); - - for (uint loop_idx = start_loop_idx; loop_idx < end_loop_idx; loop_idx++) { - const int edge_origindex = subdiv_loop_edge_index[loop_idx]; - const bool real_edge = (edge_origindex != -1 && - mr->e_origindex[edge_origindex] != ORIGINDEX_NONE); - edituv_edge_add(data, - BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) != 0 || !real_edge, - BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) != 0, - loop_idx, - (loop_idx + 1 == end_loop_idx) ? start_loop_idx : (loop_idx + 1)); - } + for (uint loop_idx = start_loop_idx; loop_idx < end_loop_idx; loop_idx++) { + const int edge_origindex = subdiv_loop_edge_index[loop_idx]; + const bool real_edge = (edge_origindex != -1 && + mr->e_origindex[edge_origindex] != ORIGINDEX_NONE); + edituv_edge_add(data, + BM_elem_flag_test_bool(efa, BM_ELEM_HIDDEN) != 0 || !real_edge, + BM_elem_flag_test_bool(efa, BM_ELEM_SELECT) != 0, + loop_idx, + (loop_idx + 1 == end_loop_idx) ? start_loop_idx : (loop_idx + 1)); } } @@ -395,13 +392,16 @@ static void extract_edituv_points_init_subdiv(const DRWSubdivCache *subdiv_cache static void extract_edituv_points_iter_subdiv(const DRWSubdivCache *subdiv_cache, const MeshRenderData *mr, - void *_data) + void *_data, + uint subdiv_quad_index) { MeshExtract_EditUvElem_Data *data = static_cast<MeshExtract_EditUvElem_Data *>(_data); int *subdiv_loop_vert_index = (int *)GPU_vertbuf_get_data(subdiv_cache->verts_orig_index); int *subdiv_loop_poly_index = subdiv_cache->subdiv_loop_poly_index; - for (uint i = 0; i < subdiv_cache->num_subdiv_loops; i++) { + uint start_loop_idx = subdiv_quad_index * 4; + uint end_loop_idx = (subdiv_quad_index + 1) * 4; + for (uint i = start_loop_idx; i < end_loop_idx; i++) { const int vert_origindex = subdiv_loop_vert_index[i]; const int poly_origindex = subdiv_loop_poly_index[i]; BMFace *efa = bm_original_face_get(mr, poly_origindex); |