From 8f9d0ab6f6710a9e2209fb556184a32901377705 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 13 Aug 2019 18:08:48 +0200 Subject: [PATCH] pgraph: fix some TextureAttrib state cache issues The _render_stages and _render_ff_stages cannot simply be copied, because they contain pointer references to the previous TextureAttrib. Never copy them, and always mark _sort_seq as stale. This fixes a test failure in replace_texture. --- panda/src/pgraph/textureAttrib.I | 6 +++--- panda/src/pgraph/textureAttrib.cxx | 13 ------------- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/panda/src/pgraph/textureAttrib.I b/panda/src/pgraph/textureAttrib.I index 9ee2f69f62..c3d40bafbe 100644 --- a/panda/src/pgraph/textureAttrib.I +++ b/panda/src/pgraph/textureAttrib.I @@ -29,12 +29,12 @@ TextureAttrib() { INLINE TextureAttrib:: TextureAttrib(const TextureAttrib ©) : _on_stages(copy._on_stages), - _render_stages(copy._render_stages), - _render_ff_stages(copy._render_ff_stages), + _render_stages(), + _render_ff_stages(), _next_implicit_sort(copy._next_implicit_sort), _off_stages(copy._off_stages), _off_all_stages(copy._off_all_stages), - _sort_seq(copy._sort_seq), + _sort_seq(UpdateSeq::old()), _filtered_seq(UpdateSeq::old()) { } diff --git a/panda/src/pgraph/textureAttrib.cxx b/panda/src/pgraph/textureAttrib.cxx index 58225185d7..ff78fc2780 100644 --- a/panda/src/pgraph/textureAttrib.cxx +++ b/panda/src/pgraph/textureAttrib.cxx @@ -116,10 +116,6 @@ add_on_stage(TextureStage *stage, Texture *tex, int override) const { (*si)._has_sampler = false; ++(attrib->_next_implicit_sort); - // We now need to re-sort the attrib list. - attrib->_sort_seq = UpdateSeq::old(); - attrib->_filtered_seq = UpdateSeq::old(); - return return_new(attrib); } @@ -140,10 +136,6 @@ add_on_stage(TextureStage *stage, Texture *tex, const SamplerState &sampler, int (*si)._has_sampler = true; ++(attrib->_next_implicit_sort); - // We now need to re-sort the attrib list. - attrib->_sort_seq = UpdateSeq::old(); - attrib->_filtered_seq = UpdateSeq::old(); - return return_new(attrib); } @@ -158,9 +150,6 @@ remove_on_stage(TextureStage *stage) const { Stages::iterator si = attrib->_on_stages.find(StageNode(stage)); if (si != attrib->_on_stages.end()) { attrib->_on_stages.erase(si); - - attrib->_sort_seq = UpdateSeq::old(); - attrib->_filtered_seq = UpdateSeq::old(); } return return_new(attrib); @@ -182,8 +171,6 @@ add_off_stage(TextureStage *stage, int override) const { Stages::iterator si = attrib->_on_stages.find(sn); if (si != attrib->_on_stages.end()) { attrib->_on_stages.erase(si); - attrib->_sort_seq = UpdateSeq::old(); - attrib->_filtered_seq = UpdateSeq::old(); } } return return_new(attrib);