Browse Source

Backport various bugfixes from master, among which:
- Fix Windows pbuffer crash on Intel cards
- Fix crash when using pnmimage.write with unsupported format
- Fix GLSL diagnostics on Mesa GLES2 compiler
- Reduce warning severity when resizing immutable storage texture
- Print more debug info when FrameBufferProperties are insufficient
- Fix "Bam file contains objects of unknown type: MovingPart<LMatrix4f>"
- Fix memory leak in BulletTriangleMesh
- Fix pmerge in Python 3

rdb 9 years ago
parent
commit
d53b2ca80e

+ 7 - 2
direct/src/p3d/SeqValue.py

@@ -35,7 +35,7 @@ class SeqValue:
         """ Sets the seq from the indicated string of dot-separated
         """ Sets the seq from the indicated string of dot-separated
         integers.  Raises ValueError on error. """
         integers.  Raises ValueError on error. """
         assert isinstance(value, types.StringTypes)
         assert isinstance(value, types.StringTypes)
-        
+
         self.value = ()
         self.value = ()
         if value:
         if value:
             value = value.split('.')
             value = value.split('.')
@@ -77,9 +77,14 @@ class SeqValue:
         """ Compares to another seq value. """
         """ Compares to another seq value. """
         return cmp(self.value, other.value)
         return cmp(self.value, other.value)
 
 
+    def __lt__(self, other):
+        return self.value < other.value
+
+    def __gt__(self, other):
+        return self.value > other.value
+
     def __bool__(self):
     def __bool__(self):
         return bool(self.value)
         return bool(self.value)
 
 
     def __str__(self):
     def __str__(self):
         return 'SeqValue%s' % (repr(self.value))
         return 'SeqValue%s' % (repr(self.value))
-    

+ 1 - 1
dtool/src/dtoolbase/pdtoa.cxx

@@ -250,7 +250,7 @@ inline static unsigned CountDecimalDigit32(uint32_t n) {
 }
 }
 
 
 inline static void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) {
 inline static void DigitGen(const DiyFp& W, const DiyFp& Mp, uint64_t delta, char* buffer, int* len, int* K) {
-  static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000 };
+  static const uint32_t kPow10[] = { 1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000, 0, 0, 0, 0, 0 };
   const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);
   const DiyFp one(uint64_t(1) << -Mp.e, Mp.e);
   const DiyFp wp_w = Mp - W;
   const DiyFp wp_w = Mp - W;
   uint32_t p1 = static_cast<uint32_t>(Mp.f >> -one.e);
   uint32_t p1 = static_cast<uint32_t>(Mp.f >> -one.e);

+ 2 - 2
makepanda/makepandacore.py

@@ -20,10 +20,10 @@ else:
     import cPickle as pickle
     import cPickle as pickle
     import thread
     import thread
 
 
-SUFFIX_INC = [".cxx",".c",".h",".I",".yxx",".lxx",".mm",".rc",".r"]
+SUFFIX_INC = [".cxx",".cpp",".c",".h",".I",".yxx",".lxx",".mm",".rc",".r"]
 SUFFIX_DLL = [".dll",".dlo",".dle",".dli",".dlm",".mll",".exe",".pyd",".ocx"]
 SUFFIX_DLL = [".dll",".dlo",".dle",".dli",".dlm",".mll",".exe",".pyd",".ocx"]
 SUFFIX_LIB = [".lib",".ilb"]
 SUFFIX_LIB = [".lib",".ilb"]
-VCS_DIRS = set(["CVS", "CVSROOT", ".git", ".hg"])
+VCS_DIRS = set(["CVS", "CVSROOT", ".git", ".hg", "__pycache__"])
 VCS_FILES = set([".cvsignore", ".gitignore", ".gitmodules", ".hgignore"])
 VCS_FILES = set([".cvsignore", ".gitignore", ".gitmodules", ".hgignore"])
 STARTTIME = time.time()
 STARTTIME = time.time()
 MAINTHREAD = threading.currentThread()
 MAINTHREAD = threading.currentThread()

+ 1 - 1
panda/src/bullet/bulletHeightfieldShape.I

@@ -21,7 +21,7 @@ INLINE BulletHeightfieldShape::
 ~BulletHeightfieldShape() {
 ~BulletHeightfieldShape() {
 
 
   delete _shape;
   delete _shape;
-  delete _data;
+  delete [] _data;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 4 - 0
panda/src/bullet/bulletTriangleMesh.cxx

@@ -149,6 +149,8 @@ add_geom(const Geom *geom, bool remove_duplicate_vertices, const TransformState
       _mesh->addTriangle(v0, v1, v2, remove_duplicate_vertices);
       _mesh->addTriangle(v0, v1, v2, remove_duplicate_vertices);
     }
     }
   }
   }
+
+  delete [] vertices;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////
@@ -180,6 +182,8 @@ add_array(const PTA_LVecBase3 &points, const PTA_int &indices, bool remove_dupli
 
 
     _mesh->addTriangle(v0, v1, v2, remove_duplicate_vertices);
     _mesh->addTriangle(v0, v1, v2, remove_duplicate_vertices);
   }
   }
+
+  delete [] vertices;
 }
 }
 
 
 ////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////

+ 11 - 0
panda/src/chan/config_chan.cxx

@@ -146,6 +146,17 @@ ConfigureFn(config_chan) {
   AnimChannelScalarTable::register_with_read_factory();
   AnimChannelScalarTable::register_with_read_factory();
   AnimChannelScalarDynamic::register_with_read_factory();
   AnimChannelScalarDynamic::register_with_read_factory();
   AnimPreloadTable::register_with_read_factory();
   AnimPreloadTable::register_with_read_factory();
+
+  // For compatibility with old .bam files.
+#ifndef STDFLOAT_DOUBLE
+  TypeRegistry *reg = TypeRegistry::ptr();
+  reg->record_alternate_name(AnimChannelFixed<ACMatrixSwitchType>::get_class_type(),
+                             "AnimChannelFixed<LMatrix4f>");
+  reg->record_alternate_name(MovingPart<ACMatrixSwitchType>::get_class_type(),
+                             "MovingPart<LMatrix4f>");
+  reg->record_alternate_name(MovingPart<ACScalarSwitchType>::get_class_type(),
+                             "MovingPart<float>");
+#endif
 }
 }
 
 
 
 

+ 3 - 0
panda/src/display/graphicsEngine.cxx

@@ -437,6 +437,9 @@ make_output(GraphicsPipe *pipe,
           if (flags & GraphicsPipe::BF_fb_props_optional) {
           if (flags & GraphicsPipe::BF_fb_props_optional) {
             display_cat.warning()
             display_cat.warning()
               << "FrameBufferProperties available less than requested.\n";
               << "FrameBufferProperties available less than requested.\n";
+            display_cat.warning(false)
+              << "  requested: " << fb_prop << "\n"
+              << "  got: " << window->get_fb_properties() << "\n";
             return window;
             return window;
           }
           }
           display_cat.error()
           display_cat.error()

+ 1 - 1
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -10745,7 +10745,7 @@ upload_texture(CLP(TextureContext) *gtc, bool force, bool uses_mipmaps) {
   }
   }
 
 
   if (needs_reload && gtc->_immutable) {
   if (needs_reload && gtc->_immutable) {
-    GLCAT.warning() << "Attempt to modify texture with immutable storage, recreating texture.\n";
+    GLCAT.info() << "Attempt to modify texture with immutable storage, recreating texture.\n";
     gtc->reset_data();
     gtc->reset_data();
     glBindTexture(target, gtc->_index);
     glBindTexture(target, gtc->_index);
   }
   }

+ 11 - 3
panda/src/glstuff/glShaderContext_src.cxx

@@ -1861,10 +1861,10 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) {
   istringstream log(info_log);
   istringstream log(info_log);
   string line;
   string line;
   while (getline(log, line)) {
   while (getline(log, line)) {
-    int fileno, lineno;
+    int fileno, lineno, colno;
     int prefixlen = 0;
     int prefixlen = 0;
 
 
-    // First is AMD/Intel driver syntax, second is NVIDIA syntax.
+    // This first format is used by the majority of compilers.
     if (sscanf(line.c_str(), "ERROR: %d:%d: %n", &fileno, &lineno, &prefixlen) == 2
     if (sscanf(line.c_str(), "ERROR: %d:%d: %n", &fileno, &lineno, &prefixlen) == 2
         && prefixlen > 0) {
         && prefixlen > 0) {
 
 
@@ -1879,14 +1879,22 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) {
       GLCAT.warning(false)
       GLCAT.warning(false)
         << "WARNING: " << fn << ":" << lineno << ": " << (line.c_str() + prefixlen) << "\n";
         << "WARNING: " << fn << ":" << lineno << ": " << (line.c_str() + prefixlen) << "\n";
 
 
-
     } else if (sscanf(line.c_str(), "%d(%d) : %n", &fileno, &lineno, &prefixlen) == 2
     } else if (sscanf(line.c_str(), "%d(%d) : %n", &fileno, &lineno, &prefixlen) == 2
                && prefixlen > 0) {
                && prefixlen > 0) {
 
 
+      // This is the format NVIDIA uses.
       Filename fn = _shader->get_filename_from_index(fileno, type);
       Filename fn = _shader->get_filename_from_index(fileno, type);
       GLCAT.error(false)
       GLCAT.error(false)
         << fn << "(" << lineno << ") : " << (line.c_str() + prefixlen) << "\n";
         << fn << "(" << lineno << ") : " << (line.c_str() + prefixlen) << "\n";
 
 
+    } else if (sscanf(line.c_str(), "%d:%d(%d): %n", &fileno, &lineno, &colno, &prefixlen) == 3
+               && prefixlen > 0) {
+
+      // This is the format for Mesa's OpenGL ES 2 implementation.
+      Filename fn = _shader->get_filename_from_index(fileno, type);
+      GLCAT.error(false)
+        << fn << ":" << lineno << "(" << colno << "): " << (line.c_str() + prefixlen) << "\n";
+
     } else if (!fatal) {
     } else if (!fatal) {
       GLCAT.warning(false) << line << "\n";
       GLCAT.warning(false) << line << "\n";
 
 

+ 1 - 1
panda/src/pnmimage/pnmImageHeader.cxx

@@ -375,7 +375,7 @@ make_writer(ostream *file, bool owns_file, const Filename &filename,
     delete file;
     delete file;
   }
   }
 
 
-  if (!writer->is_valid()) {
+  if (writer != NULL && !writer->is_valid()) {
     delete writer;
     delete writer;
     writer = NULL;
     writer = NULL;
   }
   }

+ 7 - 5
panda/src/wgldisplay/wglGraphicsBuffer.cxx

@@ -81,10 +81,12 @@ begin_frame(FrameMode mode, Thread *current_thread) {
     return false;
     return false;
   }
   }
 
 
-  if (_fb_properties.is_single_buffered()) {
-    wglgsg->_wglReleaseTexImageARB(_pbuffer, WGL_FRONT_LEFT_ARB);
-  } else {
-    wglgsg->_wglReleaseTexImageARB(_pbuffer, WGL_BACK_LEFT_ARB);
+  if (_pbuffer_bound) {
+    if (_fb_properties.is_single_buffered()) {
+      wglgsg->_wglReleaseTexImageARB(_pbuffer, WGL_FRONT_LEFT_ARB);
+    } else {
+      wglgsg->_wglReleaseTexImageARB(_pbuffer, WGL_BACK_LEFT_ARB);
+    }
   }
   }
 
 
   if (!rebuild_bitplanes()) {
   if (!rebuild_bitplanes()) {
@@ -158,7 +160,7 @@ bind_texture_to_pbuffer() {
   for (size_t i = 0; i != cdata->_textures.size(); ++i) {
   for (size_t i = 0; i != cdata->_textures.size(); ++i) {
     const RenderTexture &rt = cdata->_textures[i];
     const RenderTexture &rt = cdata->_textures[i];
     RenderTexturePlane plane = rt._plane;
     RenderTexturePlane plane = rt._plane;
-    if (plane == RTP_color) {
+    if (plane == RTP_color && rt._rtm_mode == RTM_bind_or_copy) {
       tex_index = i;
       tex_index = i;
       break;
       break;
     }
     }