From fc8c07a949270381d6b089527b0b28c72c868142 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 25 Oct 2022 13:19:53 +0200 Subject: [PATCH] pgraph: Remove unused vertices during premunge phase Disable with premunge-remove-unused-vertices config var - let me know if causes issues for you, performance or otherwise, though! --- panda/src/pgraph/config_pgraph.cxx | 5 +++++ panda/src/pgraph/config_pgraph.h | 1 + panda/src/pgraph/geomNode.cxx | 3 +++ panda/src/pgraph/sceneGraphReducer.I | 1 + 4 files changed, 10 insertions(+) diff --git a/panda/src/pgraph/config_pgraph.cxx b/panda/src/pgraph/config_pgraph.cxx index 406f8fa41a..7b175f15d0 100644 --- a/panda/src/pgraph/config_pgraph.cxx +++ b/panda/src/pgraph/config_pgraph.cxx @@ -290,6 +290,11 @@ ConfigVariableBool premunge_data "encoding requirements, as appropriate. When this is false, the " "data will be munged at render time instead.")); +ConfigVariableBool premunge_remove_unused_vertices +("premunge-remove-unused-vertices", true, + PRC_DESC("Set this true to remove unused vertices as part of the premunge " + "which occurs when models are loaded from disk.")); + ConfigVariableBool preserve_geom_nodes ("preserve-geom-nodes", false, PRC_DESC("This specifies the default value for the \"preserved\" flag on " diff --git a/panda/src/pgraph/config_pgraph.h b/panda/src/pgraph/config_pgraph.h index 59551133aa..0cba3cf971 100644 --- a/panda/src/pgraph/config_pgraph.h +++ b/panda/src/pgraph/config_pgraph.h @@ -55,6 +55,7 @@ extern ConfigVariableBool depth_offset_decals; extern ConfigVariableInt max_collect_vertices; extern ConfigVariableInt max_collect_indices; extern EXPCL_PANDA_PGRAPH ConfigVariableBool premunge_data; +extern ConfigVariableBool premunge_remove_unused_vertices; extern ConfigVariableBool preserve_geom_nodes; extern ConfigVariableBool flatten_geoms; extern EXPCL_PANDA_PGRAPH ConfigVariableInt max_lenses; diff --git a/panda/src/pgraph/geomNode.cxx b/panda/src/pgraph/geomNode.cxx index c92d27d5f0..bd10178594 100644 --- a/panda/src/pgraph/geomNode.cxx +++ b/panda/src/pgraph/geomNode.cxx @@ -892,6 +892,9 @@ do_premunge(GraphicsStateGuardianBase *gsg, CPT(Geom) geom = entry._geom.get_read_pointer(); PT(GeomMunger) munger = gsg->get_geom_munger(geom_state, current_thread); entry._geom = transformer.premunge_geom(geom, munger); + if (premunge_remove_unused_vertices) { + transformer.register_vertices(entry._geom.get_write_pointer(), true); + } } } CLOSE_ITERATE_CURRENT_AND_UPSTREAM(_cycler); diff --git a/panda/src/pgraph/sceneGraphReducer.I b/panda/src/pgraph/sceneGraphReducer.I index 2db336c546..4e0f6e6585 100644 --- a/panda/src/pgraph/sceneGraphReducer.I +++ b/panda/src/pgraph/sceneGraphReducer.I @@ -176,5 +176,6 @@ premunge(PandaNode *root, const RenderState *initial_state) { if (_gsg != nullptr) { PStatTimer timer(_premunge_collector); r_premunge(root, initial_state); + _transformer.finish_apply(); } }