From 2864f3ad3f864077f8855c08833d1377a7b7a6ea Mon Sep 17 00:00:00 2001 From: Hans Goudey Date: Thu, 30 Nov 2023 20:02:12 -0500 Subject: [PATCH] Cleanup: Remove unused argument to PBVH draw functions The attributes weren't used by BKE_pbvh_draw_cb. --- source/blender/blenkernel/BKE_pbvh_api.hh | 5 +---- source/blender/blenkernel/intern/pbvh.cc | 9 +------- source/blender/draw/DRW_pbvh.hh | 4 ++-- .../engines/workbench/workbench_engine.cc | 4 ++-- .../blender/draw/intern/draw_manager_data.cc | 5 +---- source/blender/draw/intern/draw_pbvh.cc | 16 +++++++------- source/blender/draw/intern/draw_sculpt.cc | 22 ++++++++----------- source/blender/draw/intern/draw_sculpt.hh | 4 +--- 8 files changed, 25 insertions(+), 44 deletions(-) diff --git a/source/blender/blenkernel/BKE_pbvh_api.hh b/source/blender/blenkernel/BKE_pbvh_api.hh index 52a30f1ec73..e6e9289e0c3 100644 --- a/source/blender/blenkernel/BKE_pbvh_api.hh +++ b/source/blender/blenkernel/BKE_pbvh_api.hh @@ -314,10 +314,7 @@ void BKE_pbvh_draw_cb(const Mesh &mesh, void (*draw_fn)(void *user_data, blender::draw::pbvh::PBVHBatches *batches, const blender::draw::pbvh::PBVH_GPU_Args &args), - void *user_data, - bool full_render, - PBVHAttrReq *attrs, - int attrs_num); + void *user_data); /* PBVH Access */ diff --git a/source/blender/blenkernel/intern/pbvh.cc b/source/blender/blenkernel/intern/pbvh.cc index 5de24893185..d1df59958bf 100644 --- a/source/blender/blenkernel/intern/pbvh.cc +++ b/source/blender/blenkernel/intern/pbvh.cc @@ -2876,8 +2876,6 @@ void BKE_pbvh_update_normals(PBVH *pbvh, SubdivCCG *subdiv_ccg) struct PBVHDrawSearchData { PBVHFrustumPlanes *frustum; int accum_update_flag; - PBVHAttrReq *attrs; - int attrs_num; }; static bool pbvh_draw_search(PBVHNode *node, PBVHDrawSearchData *data) @@ -2898,10 +2896,7 @@ void BKE_pbvh_draw_cb(const Mesh &mesh, void (*draw_fn)(void *user_data, blender::draw::pbvh::PBVHBatches *batches, const blender::draw::pbvh::PBVH_GPU_Args &args), - void *user_data, - bool /*full_render*/, - PBVHAttrReq *attrs, - int attrs_num) + void *user_data) { using namespace blender; using namespace blender::bke::pbvh; @@ -2916,8 +2911,6 @@ void BKE_pbvh_draw_cb(const Mesh &mesh, PBVHDrawSearchData data{}; data.frustum = update_frustum; data.accum_update_flag = 0; - data.attrs = attrs; - data.attrs_num = attrs_num; nodes = search_gather(pbvh, [&](PBVHNode &node) { return pbvh_draw_search(&node, &data); }); update_flag = data.accum_update_flag; } diff --git a/source/blender/draw/DRW_pbvh.hh b/source/blender/draw/DRW_pbvh.hh index becf494e26a..8c28add7836 100644 --- a/source/blender/draw/DRW_pbvh.hh +++ b/source/blender/draw/DRW_pbvh.hh @@ -79,13 +79,13 @@ void node_gpu_flush(PBVHBatches *batches); PBVHBatches *node_create(const PBVH_GPU_Args &args); void node_free(PBVHBatches *batches); GPUBatch *tris_get(PBVHBatches *batches, - PBVHAttrReq *attrs, + const PBVHAttrReq *attrs, int attrs_num, const PBVH_GPU_Args &args, int *r_prim_count, bool do_coarse_grids); GPUBatch *lines_get(PBVHBatches *batches, - PBVHAttrReq *attrs, + const PBVHAttrReq *attrs, int attrs_num, const PBVH_GPU_Args &args, int *r_prim_count, diff --git a/source/blender/draw/engines/workbench/workbench_engine.cc b/source/blender/draw/engines/workbench/workbench_engine.cc index 84ed38afdc2..a2f8556e62e 100644 --- a/source/blender/draw/engines/workbench/workbench_engine.cc +++ b/source/blender/draw/engines/workbench/workbench_engine.cc @@ -328,7 +328,7 @@ class Instance { } if (object_state.use_per_material_batches) { - for (SculptBatch &batch : sculpt_batches_get(ob_ref.object, true, features)) { + for (SculptBatch &batch : sculpt_batches_get(ob_ref.object, features)) { Material mat = get_material(ob_ref, object_state.color_type, batch.material_slot); if (SCULPT_DEBUG_DRAW) { mat.base_color = batch.debug_color(); @@ -346,7 +346,7 @@ class Instance { } else { Material mat = get_material(ob_ref, object_state.color_type); - for (SculptBatch &batch : sculpt_batches_get(ob_ref.object, false, features)) { + for (SculptBatch &batch : sculpt_batches_get(ob_ref.object, features)) { if (SCULPT_DEBUG_DRAW) { mat.base_color = batch.debug_color(); } diff --git a/source/blender/draw/intern/draw_manager_data.cc b/source/blender/draw/intern/draw_manager_data.cc index 55ba8b0dfe0..7447d035c79 100644 --- a/source/blender/draw/intern/draw_manager_data.cc +++ b/source/blender/draw/intern/draw_manager_data.cc @@ -1381,10 +1381,7 @@ static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd) (void (*)(void *, blender::draw::pbvh::PBVHBatches *, const blender::draw::pbvh::PBVH_GPU_Args &))sculpt_draw_cb, - scd, - scd->use_mats, - scd->attrs, - scd->attrs_num); + scd); if (SCULPT_DEBUG_BUFFERS) { int debug_node_nr = 0; diff --git a/source/blender/draw/intern/draw_pbvh.cc b/source/blender/draw/intern/draw_pbvh.cc index b51208045b8..03376ccb7d8 100644 --- a/source/blender/draw/intern/draw_pbvh.cc +++ b/source/blender/draw/intern/draw_pbvh.cc @@ -391,13 +391,13 @@ struct PBVHBatches { GPU_INDEXBUF_DISCARD_SAFE(lines_index_coarse); } - std::string build_key(PBVHAttrReq *attrs, int attrs_num, bool do_coarse_grids) + std::string build_key(const PBVHAttrReq *attrs, int attrs_num, bool do_coarse_grids) { PBVHBatch batch; Vector vbos; for (int i : IndexRange(attrs_num)) { - PBVHAttrReq *attr = attrs + i; + const PBVHAttrReq *attr = attrs + i; if (!pbvh_attr_supported(attr->type, attr->domain)) { continue; @@ -447,12 +447,12 @@ struct PBVHBatches { return nullptr; } - bool has_batch(PBVHAttrReq *attrs, int attrs_num, bool do_coarse_grids) + bool has_batch(const PBVHAttrReq *attrs, int attrs_num, bool do_coarse_grids) { return batches.contains(build_key(attrs, attrs_num, do_coarse_grids)); } - PBVHBatch &ensure_batch(PBVHAttrReq *attrs, + PBVHBatch &ensure_batch(const PBVHAttrReq *attrs, int attrs_num, const PBVH_GPU_Args &args, bool do_coarse_grids) @@ -1332,7 +1332,7 @@ struct PBVHBatches { } } - void create_batch(PBVHAttrReq *attrs, + void create_batch(const PBVHAttrReq *attrs, int attrs_num, const PBVH_GPU_Args &args, bool do_coarse_grids) @@ -1355,7 +1355,7 @@ struct PBVHBatches { } for (int i : IndexRange(attrs_num)) { - PBVHAttrReq *attr = attrs + i; + const PBVHAttrReq *attr = attrs + i; if (!pbvh_attr_supported(attr->type, attr->domain)) { continue; @@ -1402,7 +1402,7 @@ void node_free(PBVHBatches *batches) } GPUBatch *tris_get(PBVHBatches *batches, - PBVHAttrReq *attrs, + const PBVHAttrReq *attrs, int attrs_num, const PBVH_GPU_Args &args, int *r_prim_count, @@ -1418,7 +1418,7 @@ GPUBatch *tris_get(PBVHBatches *batches, } GPUBatch *lines_get(PBVHBatches *batches, - PBVHAttrReq *attrs, + const PBVHAttrReq *attrs, int attrs_num, const PBVH_GPU_Args &args, int *r_prim_count, diff --git a/source/blender/draw/intern/draw_sculpt.cc b/source/blender/draw/intern/draw_sculpt.cc index 83d71bb381f..820a14bf55a 100644 --- a/source/blender/draw/intern/draw_sculpt.cc +++ b/source/blender/draw/intern/draw_sculpt.cc @@ -40,7 +40,7 @@ struct SculptCallbackData { bool use_wire; bool fast_mode; - PBVHAttrReq *attrs; + const PBVHAttrReq *attrs; int attrs_len; Vector batches; @@ -72,8 +72,10 @@ static void sculpt_draw_cb(SculptCallbackData *data, data->batches.append(batch); } -static Vector sculpt_batches_get_ex( - const Object *ob, bool use_wire, bool use_materials, PBVHAttrReq *attrs, int attrs_len) +static Vector sculpt_batches_get_ex(const Object *ob, + bool use_wire, + const PBVHAttrReq *attrs, + int attrs_len) { /* PBVH should always exist for non-empty meshes, created by depsgraph eval. */ PBVH *pbvh = ob->sculpt ? ob->sculpt->pbvh : nullptr; @@ -146,17 +148,12 @@ static Vector sculpt_batches_get_ex( &update_frustum, &draw_frustum, (void (*)(void *, pbvh::PBVHBatches *, const pbvh::PBVH_GPU_Args &))sculpt_draw_cb, - &data, - use_materials, - attrs, - attrs_len); + &data); return data.batches; } -Vector sculpt_batches_get(const Object *ob, - bool per_material, - SculptBatchFeature features) +Vector sculpt_batches_get(const Object *ob, SculptBatchFeature features) { PBVHAttrReq attrs[16] = {}; int attrs_len = 0; @@ -197,8 +194,7 @@ Vector sculpt_batches_get(const Object *ob, } } - return sculpt_batches_get_ex( - ob, features & SCULPT_BATCH_WIREFRAME, per_material, attrs, attrs_len); + return sculpt_batches_get_ex(ob, features & SCULPT_BATCH_WIREFRAME, attrs, attrs_len); } Vector sculpt_batches_per_material_get(const Object *ob, @@ -241,7 +237,7 @@ Vector sculpt_batches_per_material_get(const Object *ob, } } - return sculpt_batches_get_ex(ob, false, true, attrs, attrs_len); + return sculpt_batches_get_ex(ob, false, attrs, attrs_len); } } // namespace blender::draw diff --git a/source/blender/draw/intern/draw_sculpt.hh b/source/blender/draw/intern/draw_sculpt.hh index 3ae346d41ce..4d412e00ea3 100644 --- a/source/blender/draw/intern/draw_sculpt.hh +++ b/source/blender/draw/intern/draw_sculpt.hh @@ -32,9 +32,7 @@ enum SculptBatchFeature { ENUM_OPERATORS(SculptBatchFeature, SCULPT_BATCH_UV); /** Used by engines that don't use GPUMaterials, like the Workbench and Overlay engines. */ -Vector sculpt_batches_get(const Object *ob, - bool per_material, - SculptBatchFeature features); +Vector sculpt_batches_get(const Object *ob, SculptBatchFeature features); /** Used by EEVEE. */ Vector sculpt_batches_per_material_get(const Object *ob,