From 7b0bb21bbe58a2a235a97f55ca3332b91d4ed2e4 Mon Sep 17 00:00:00 2001 From: David Rose Date: Mon, 16 Jul 2007 18:02:28 +0000 Subject: [PATCH] fix RenderEffects cache problem --- panda/src/pgraph/renderEffects.cxx | 38 ++++++++++++++++++++++++- panda/src/pgraph/renderState.cxx | 11 +++++++ panda/src/pgraph/texProjectorEffect.cxx | 2 +- panda/src/pgraph/transformState.cxx | 11 +++++++ 4 files changed, 60 insertions(+), 2 deletions(-) diff --git a/panda/src/pgraph/renderEffects.cxx b/panda/src/pgraph/renderEffects.cxx index 42b83ca4db..edb33512fb 100644 --- a/panda/src/pgraph/renderEffects.cxx +++ b/panda/src/pgraph/renderEffects.cxx @@ -510,7 +510,18 @@ validate_states() { while (snext != _states->end()) { if (!(*(*si) < *(*snext))) { pgraph_cat.error() - << "RenderEffectss out of order!\n"; + << "RenderEffects out of order!\n"; + (*si)->write(pgraph_cat.error(false), 2); + (*snext)->write(pgraph_cat.error(false), 2); + return false; + } + if ((*(*snext) < *(*si))) { + pgraph_cat.error() + << "RenderEffects::operator < not defined properly!\n"; + pgraph_cat.error(false) + << "a < b: " << (*(*si) < *(*snext)) << "\n"; + pgraph_cat.error(false) + << "b < a: " << (*(*snext) < *(*si)) << "\n"; (*si)->write(pgraph_cat.error(false), 2); (*snext)->write(pgraph_cat.error(false), 2); return false; @@ -650,6 +661,31 @@ release_new() { nassertv(_states_lock->debug_is_locked()); if (_saved_entry != _states->end()) { + /* + if (_states->find(this) != _saved_entry) { + nassertv(*_saved_entry == this); + cerr << "States wrong!\n"; + cerr << "validate = " << validate_states() << "\n"; + + if (!_states->empty()) { + States::iterator si; + si = _states->begin(); + cerr << (*si) << ": " << *(*si) << "\n"; + States::iterator ni = si; + ++ni; + while (ni != _states->end()) { + if (*(*si) < *(*ni)) { + cerr << " ok, " << (*(*ni) < *(*si)) << "\n"; + } else { + cerr << " **wrong! " << (*(*ni) < *(*si)) << "\n"; + } + si = ni; + cerr << (*si) << ": " << *(*si) << "\n"; + ++ni; + } + } + } + */ nassertv(_states->find(this) == _saved_entry); _states->erase(_saved_entry); _saved_entry = _states->end(); diff --git a/panda/src/pgraph/renderState.cxx b/panda/src/pgraph/renderState.cxx index 47a2436c7a..47a740d563 100644 --- a/panda/src/pgraph/renderState.cxx +++ b/panda/src/pgraph/renderState.cxx @@ -1052,6 +1052,17 @@ validate_states() { (*snext)->write(pgraph_cat.error(false), 2); return false; } + if ((*(*snext) < *(*si))) { + pgraph_cat.error() + << "RenderStates::operator < not defined properly!\n"; + pgraph_cat.error(false) + << "a < b: " << (*(*si) < *(*snext)) << "\n"; + pgraph_cat.error(false) + << "b < a: " << (*(*snext) < *(*si)) << "\n"; + (*si)->write(pgraph_cat.error(false), 2); + (*snext)->write(pgraph_cat.error(false), 2); + return false; + } si = snext; ++snext; nassertr((*si)->get_ref_count() > 0, false); diff --git a/panda/src/pgraph/texProjectorEffect.cxx b/panda/src/pgraph/texProjectorEffect.cxx index d6143cdbeb..407663e681 100644 --- a/panda/src/pgraph/texProjectorEffect.cxx +++ b/panda/src/pgraph/texProjectorEffect.cxx @@ -292,7 +292,7 @@ compare_to_impl(const RenderEffect *other) const { } } - if (bi != _stages.end()) { + if (bi != ta->_stages.end()) { // a ran out first; b was longer. return -1; } diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index db70f68b0f..cef57b9965 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -1221,6 +1221,17 @@ validate_states() { (*snext)->write(pgraph_cat.error(false), 2); return false; } + if ((*(*snext) < *(*si))) { + pgraph_cat.error() + << "TransformState::operator < not defined properly!\n"; + pgraph_cat.error(false) + << "a < b: " << (*(*si) < *(*snext)) << "\n"; + pgraph_cat.error(false) + << "b < a: " << (*(*snext) < *(*si)) << "\n"; + (*si)->write(pgraph_cat.error(false), 2); + (*snext)->write(pgraph_cat.error(false), 2); + return false; + } si = snext; ++snext; nassertr((*si)->get_ref_count() > 0, false);