瀏覽代碼

fix RenderEffects cache problem

David Rose 18 年之前
父節點
當前提交
7b0bb21bbe

+ 37 - 1
panda/src/pgraph/renderEffects.cxx

@@ -510,7 +510,18 @@ validate_states() {
   while (snext != _states->end()) {
   while (snext != _states->end()) {
     if (!(*(*si) < *(*snext))) {
     if (!(*(*si) < *(*snext))) {
       pgraph_cat.error()
       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);
       (*si)->write(pgraph_cat.error(false), 2);
       (*snext)->write(pgraph_cat.error(false), 2);
       (*snext)->write(pgraph_cat.error(false), 2);
       return false;
       return false;
@@ -650,6 +661,31 @@ release_new() {
   nassertv(_states_lock->debug_is_locked());
   nassertv(_states_lock->debug_is_locked());
 
 
   if (_saved_entry != _states->end()) {
   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);
     nassertv(_states->find(this) == _saved_entry);
     _states->erase(_saved_entry);
     _states->erase(_saved_entry);
     _saved_entry = _states->end();
     _saved_entry = _states->end();

+ 11 - 0
panda/src/pgraph/renderState.cxx

@@ -1052,6 +1052,17 @@ validate_states() {
       (*snext)->write(pgraph_cat.error(false), 2);
       (*snext)->write(pgraph_cat.error(false), 2);
       return false;
       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;
     si = snext;
     ++snext;
     ++snext;
     nassertr((*si)->get_ref_count() > 0, false);
     nassertr((*si)->get_ref_count() > 0, false);

+ 1 - 1
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.
     // a ran out first; b was longer.
     return -1;
     return -1;
   }
   }

+ 11 - 0
panda/src/pgraph/transformState.cxx

@@ -1221,6 +1221,17 @@ validate_states() {
       (*snext)->write(pgraph_cat.error(false), 2);
       (*snext)->write(pgraph_cat.error(false), 2);
       return false;
       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;
     si = snext;
     ++snext;
     ++snext;
     nassertr((*si)->get_ref_count() > 0, false);
     nassertr((*si)->get_ref_count() > 0, false);