From d53b2ca80eeb249f825ebcd4400ee4de8ced49a1 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 7 Jun 2016 14:40:27 +0200 Subject: [PATCH] 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" - Fix memory leak in BulletTriangleMesh - Fix pmerge in Python 3 --- direct/src/p3d/SeqValue.py | 9 +++++++-- dtool/src/dtoolbase/pdtoa.cxx | 2 +- makepanda/makepandacore.py | 4 ++-- panda/src/bullet/bulletHeightfieldShape.I | 2 +- panda/src/bullet/bulletTriangleMesh.cxx | 4 ++++ panda/src/chan/config_chan.cxx | 11 +++++++++++ panda/src/display/graphicsEngine.cxx | 3 +++ panda/src/glstuff/glGraphicsStateGuardian_src.cxx | 2 +- panda/src/glstuff/glShaderContext_src.cxx | 14 +++++++++++--- panda/src/pnmimage/pnmImageHeader.cxx | 2 +- panda/src/wgldisplay/wglGraphicsBuffer.cxx | 12 +++++++----- 11 files changed, 49 insertions(+), 16 deletions(-) diff --git a/direct/src/p3d/SeqValue.py b/direct/src/p3d/SeqValue.py index 493098f4e6..7d097a5e24 100644 --- a/direct/src/p3d/SeqValue.py +++ b/direct/src/p3d/SeqValue.py @@ -35,7 +35,7 @@ class SeqValue: """ Sets the seq from the indicated string of dot-separated integers. Raises ValueError on error. """ assert isinstance(value, types.StringTypes) - + self.value = () if value: value = value.split('.') @@ -77,9 +77,14 @@ class SeqValue: """ Compares to another seq 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): return bool(self.value) def __str__(self): return 'SeqValue%s' % (repr(self.value)) - diff --git a/dtool/src/dtoolbase/pdtoa.cxx b/dtool/src/dtoolbase/pdtoa.cxx index a2778dc962..47aa2db50a 100644 --- a/dtool/src/dtoolbase/pdtoa.cxx +++ b/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) { - 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 wp_w = Mp - W; uint32_t p1 = static_cast(Mp.f >> -one.e); diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 974e59b186..205caa896e 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -20,10 +20,10 @@ else: import cPickle as pickle 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_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"]) STARTTIME = time.time() MAINTHREAD = threading.currentThread() diff --git a/panda/src/bullet/bulletHeightfieldShape.I b/panda/src/bullet/bulletHeightfieldShape.I index 6803855a51..648f238dc1 100644 --- a/panda/src/bullet/bulletHeightfieldShape.I +++ b/panda/src/bullet/bulletHeightfieldShape.I @@ -21,7 +21,7 @@ INLINE BulletHeightfieldShape:: ~BulletHeightfieldShape() { delete _shape; - delete _data; + delete [] _data; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/bullet/bulletTriangleMesh.cxx b/panda/src/bullet/bulletTriangleMesh.cxx index 928c728677..30b0019e8c 100644 --- a/panda/src/bullet/bulletTriangleMesh.cxx +++ b/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); } } + + 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); } + + delete [] vertices; } //////////////////////////////////////////////////////////////////// diff --git a/panda/src/chan/config_chan.cxx b/panda/src/chan/config_chan.cxx index 8d35a75f49..d9246a3de0 100644 --- a/panda/src/chan/config_chan.cxx +++ b/panda/src/chan/config_chan.cxx @@ -146,6 +146,17 @@ ConfigureFn(config_chan) { AnimChannelScalarTable::register_with_read_factory(); AnimChannelScalarDynamic::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::get_class_type(), + "AnimChannelFixed"); + reg->record_alternate_name(MovingPart::get_class_type(), + "MovingPart"); + reg->record_alternate_name(MovingPart::get_class_type(), + "MovingPart"); +#endif } diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index 5d3c109c46..9bd325fc95 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -437,6 +437,9 @@ make_output(GraphicsPipe *pipe, if (flags & GraphicsPipe::BF_fb_props_optional) { display_cat.warning() << "FrameBufferProperties available less than requested.\n"; + display_cat.warning(false) + << " requested: " << fb_prop << "\n" + << " got: " << window->get_fb_properties() << "\n"; return window; } display_cat.error() diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index fd0c60ce40..b70552a032 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/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) { - 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(); glBindTexture(target, gtc->_index); } diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index ed7e6df1bd..df8ea97655 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/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); string line; while (getline(log, line)) { - int fileno, lineno; + int fileno, lineno, colno; 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 && prefixlen > 0) { @@ -1879,14 +1879,22 @@ glsl_report_shader_errors(GLuint shader, Shader::ShaderType type, bool fatal) { GLCAT.warning(false) << "WARNING: " << fn << ":" << lineno << ": " << (line.c_str() + prefixlen) << "\n"; - } else if (sscanf(line.c_str(), "%d(%d) : %n", &fileno, &lineno, &prefixlen) == 2 && prefixlen > 0) { + // This is the format NVIDIA uses. Filename fn = _shader->get_filename_from_index(fileno, type); GLCAT.error(false) << 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) { GLCAT.warning(false) << line << "\n"; diff --git a/panda/src/pnmimage/pnmImageHeader.cxx b/panda/src/pnmimage/pnmImageHeader.cxx index f4f002a87c..83bc0000f1 100644 --- a/panda/src/pnmimage/pnmImageHeader.cxx +++ b/panda/src/pnmimage/pnmImageHeader.cxx @@ -375,7 +375,7 @@ make_writer(ostream *file, bool owns_file, const Filename &filename, delete file; } - if (!writer->is_valid()) { + if (writer != NULL && !writer->is_valid()) { delete writer; writer = NULL; } diff --git a/panda/src/wgldisplay/wglGraphicsBuffer.cxx b/panda/src/wgldisplay/wglGraphicsBuffer.cxx index def16d8b23..1ede991dcb 100644 --- a/panda/src/wgldisplay/wglGraphicsBuffer.cxx +++ b/panda/src/wgldisplay/wglGraphicsBuffer.cxx @@ -81,10 +81,12 @@ begin_frame(FrameMode mode, Thread *current_thread) { 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()) { @@ -158,7 +160,7 @@ bind_texture_to_pbuffer() { for (size_t i = 0; i != cdata->_textures.size(); ++i) { const RenderTexture &rt = cdata->_textures[i]; RenderTexturePlane plane = rt._plane; - if (plane == RTP_color) { + if (plane == RTP_color && rt._rtm_mode == RTM_bind_or_copy) { tex_index = i; break; }