Quellcode durchsuchen

prevent overactive texture reload

David Rose vor 17 Jahren
Ursprung
Commit
ec408822c5
2 geänderte Dateien mit 14 neuen und 3 gelöschten Zeilen
  1. 8 2
      panda/src/display/graphicsEngine.cxx
  2. 6 1
      panda/src/display/graphicsEngine.h

+ 8 - 2
panda/src/display/graphicsEngine.cxx

@@ -700,7 +700,10 @@ render_frame() {
     // were drawn in the previous frame.
     LoadedTextures::iterator lti;
     for (lti = _loaded_textures.begin(); lti != _loaded_textures.end(); ++lti) {
-      (*lti)->texture_uploaded();
+      LoadedTexture &lt = (*lti);
+      if (lt._tex->get_image_modified() == lt._image_modified) {
+        lt._tex->texture_uploaded();
+      }
     }
     _loaded_textures.clear();
     
@@ -1081,7 +1084,10 @@ texture_uploaded(Texture *tex) {
   // We defer this until the end of the frame; multiple GSG's might be
   // rendering the texture within the same frame, and we don't want to
   // dump the texture image until they've all had a chance at it.
-  _loaded_textures.push_back(tex);
+  _loaded_textures.push_back(LoadedTexture());
+  LoadedTexture &lt = _loaded_textures.back();
+  lt._tex = tex;
+  lt._image_modified = tex->get_image_modified();
 }
 
 

+ 6 - 1
panda/src/display/graphicsEngine.h

@@ -346,7 +346,12 @@ private:
   bool _singular_warning_last_frame;
   bool _singular_warning_this_frame;
 
-  typedef pvector< PT(Texture) > LoadedTextures;
+  class LoadedTexture {
+  public:
+    PT(Texture) _tex;
+    UpdateSeq _image_modified;
+  };
+  typedef pvector<LoadedTexture> LoadedTextures;
   LoadedTextures _loaded_textures;
 
   LightReMutex _lock;