From 1808ad217cea81b5232cf7be977ee4f375416b6a Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 20 Dec 2016 23:14:58 +0100 Subject: [PATCH 01/12] Fix Python 3 error in particle sample in 1.9 --- direct/src/particles/ParticleEffect.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/direct/src/particles/ParticleEffect.py b/direct/src/particles/ParticleEffect.py index 914630f19c..3ccec4b589 100644 --- a/direct/src/particles/ParticleEffect.py +++ b/direct/src/particles/ParticleEffect.py @@ -200,7 +200,7 @@ class ParticleEffect(NodePath): def loadConfig(self, filename): data = vfs.readFile(filename, 1) - data = data.replace('\r', '') + data = data.replace(b'\r', b'') try: exec(data) except: From 637767fec893b43c4e6201a434fa435991ffe543 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 20 Dec 2016 23:15:21 +0100 Subject: [PATCH 02/12] Flush nout before inducing crash in assert-abort --- dtool/src/prc/notify.cxx | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dtool/src/prc/notify.cxx b/dtool/src/prc/notify.cxx index ebfd19ac42..9a34869923 100644 --- a/dtool/src/prc/notify.cxx +++ b/dtool/src/prc/notify.cxx @@ -405,6 +405,9 @@ assert_failure(const char *expression, int line, // so we can guarantee it has already been constructed. ALIGN_16BYTE ConfigVariableBool assert_abort("assert-abort", false); if (assert_abort) { + // Make sure the error message has been flushed to the output. + nout.flush(); + #ifdef WIN32 // How to trigger an exception in VC++ that offers to take us into // the debugger? abort() doesn't do it. We used to be able to From 5aa86185723f4858827e62703082c3ece672a303 Mon Sep 17 00:00:00 2001 From: rdb Date: Tue, 20 Dec 2016 23:18:05 +0100 Subject: [PATCH 03/12] Don't error if passing an oversized matrix array to a mat4[1] shader parameter --- panda/src/pgraph/shaderAttrib.cxx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/panda/src/pgraph/shaderAttrib.cxx b/panda/src/pgraph/shaderAttrib.cxx index ad9b1a6eef..350c97ac84 100644 --- a/panda/src/pgraph/shaderAttrib.cxx +++ b/panda/src/pgraph/shaderAttrib.cxx @@ -501,7 +501,8 @@ get_shader_input_matrix(const InternalName *id, LMatrix4 &matrix) const { nassertr(!np.is_empty(), LMatrix4::ident_mat()); return np.get_transform()->get_mat(); - } else if (p->get_value_type() == ShaderInput::M_numeric && p->get_ptr()._size == 16) { + } else if (p->get_value_type() == ShaderInput::M_numeric && + p->get_ptr()._size >= 16 && (p->get_ptr()._size & 15) == 0) { const Shader::ShaderPtrData &ptr = p->get_ptr(); switch (ptr._type) { @@ -527,7 +528,7 @@ get_shader_input_matrix(const InternalName *id, LMatrix4 &matrix) const { } ostringstream strm; - strm << "Shader input " << id->get_name() << " is not a NodePath or LMatrix4.\n"; + strm << "Shader input " << id->get_name() << " is not a NodePath, LMatrix4 or PTA_LMatrix4.\n"; nassert_raise(strm.str()); return LMatrix4::ident_mat(); } From 92302942feb5d2eacf4dd8bc9caa7fe4cb4aaf3c Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 21 Dec 2016 17:14:10 +0100 Subject: [PATCH 04/12] Changes to build on ancient Linux distributions (CentOS 5 / manylinux) --- doc/ReleaseNotes | 1 + panda/src/glxdisplay/panda_glxext.h | 1 + panda/src/vision/webcamVideoV4L.cxx | 66 +++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 03d2dcf92a..92a31b7d52 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -50,6 +50,7 @@ This issue fixes several bugs that were still found in 1.9.2. * GLSL: fix error when legacy matrix generator inputs are mat3 * Now tries to preserve refresh rate when switching fullscreen on Windows * Fix back-to-front sorting when gl-coordinate-system is changed +* Now also compiles on older Linux distros (eg. CentOS 5 / manylinux1) ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/glxdisplay/panda_glxext.h b/panda/src/glxdisplay/panda_glxext.h index 308e166224..5208302929 100644 --- a/panda/src/glxdisplay/panda_glxext.h +++ b/panda/src/glxdisplay/panda_glxext.h @@ -199,6 +199,7 @@ GLXContext glXCreateContextAttribsARB (X11_Display *dpy, GLXFBConfig config, GLX #ifndef GLX_ARB_get_proc_address #define GLX_ARB_get_proc_address 1 +typedef void (*__GLXextFuncPtr)(void); typedef __GLXextFuncPtr ( *PFNGLXGETPROCADDRESSARBPROC) (const GLubyte *procName); #ifdef GLX_GLXEXT_PROTOTYPES __GLXextFuncPtr glXGetProcAddressARB (const GLubyte *procName); diff --git a/panda/src/vision/webcamVideoV4L.cxx b/panda/src/vision/webcamVideoV4L.cxx index 71cee3d312..dd77c6813e 100644 --- a/panda/src/vision/webcamVideoV4L.cxx +++ b/panda/src/vision/webcamVideoV4L.cxx @@ -23,6 +23,72 @@ #include #include +#ifndef CPPPARSER +#ifndef VIDIOC_ENUM_FRAMESIZES +enum v4l2_frmsizetypes { + V4L2_FRMSIZE_TYPE_DISCRETE = 1, + V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, + V4L2_FRMSIZE_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmsize_discrete { + __u32 width; + __u32 height; +}; + +struct v4l2_frmsize_stepwise { + __u32 min_width; + __u32 max_width; + __u32 step_width; + __u32 min_height; + __u32 max_height; + __u32 step_height; +}; + +struct v4l2_frmsizeenum { + __u32 index; + __u32 pixel_format; + __u32 type; + union { + struct v4l2_frmsize_discrete discrete; + struct v4l2_frmsize_stepwise stepwise; + }; + __u32 reserved[2]; +}; + +#define VIDIOC_ENUM_FRAMESIZES _IOWR('V', 74, struct v4l2_frmsizeenum) +#endif + +#ifndef VIDIOC_ENUM_FRAMEINTERVALS +enum v4l2_frmivaltypes { + V4L2_FRMIVAL_TYPE_DISCRETE = 1, + V4L2_FRMIVAL_TYPE_CONTINUOUS = 2, + V4L2_FRMIVAL_TYPE_STEPWISE = 3, +}; + +struct v4l2_frmival_stepwise { + struct v4l2_fract min; + struct v4l2_fract max; + struct v4l2_fract step; +}; + +struct v4l2_frmivalenum { + __u32 index; + __u32 pixel_format; + __u32 width; + __u32 height; + __u32 type; + union { + struct v4l2_fract discrete; + struct v4l2_frmival_stepwise stepwise; + }; + __u32 reserved[2]; +}; + +#define VIDIOC_ENUM_FRAMEINTERVALS _IOWR('V', 75, struct v4l2_frmivalenum) +#endif +#endif + TypeHandle WebcamVideoV4L::_type_handle; //////////////////////////////////////////////////////////////////// From c1d6e9316631e33b49e10f29de0089a700c49b43 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 21 Dec 2016 17:41:15 +0100 Subject: [PATCH 05/12] Don't link extension modules with libpython; changes to help w/ building whls This fixes compatibility issues with homebrew Python on Mac OS X. This introduces a --no-directscripts flag to disable building packpanda and eggcacher, which require linking with libpython (which is not available on manylinux). When building a wheel, the packpanda and eggcacher modules can instead be added to console_scripts in the entry_points definition. --- direct/src/directscripts/eggcacher.py | 4 ++++ direct/src/directscripts/packpanda.py | 3 +++ doc/ReleaseNotes | 1 + makepanda/makepanda.py | 15 +++++++++++---- 4 files changed, 19 insertions(+), 4 deletions(-) diff --git a/direct/src/directscripts/eggcacher.py b/direct/src/directscripts/eggcacher.py index ea2f653876..3d53e4e122 100644 --- a/direct/src/directscripts/eggcacher.py +++ b/direct/src/directscripts/eggcacher.py @@ -88,3 +88,7 @@ class EggCacher: progress += size cacher = EggCacher(sys.argv[1:]) + +# Dummy main function so this can be added to console_scripts. +def main(): + return 0 diff --git a/direct/src/directscripts/packpanda.py b/direct/src/directscripts/packpanda.py index 72e33c3e9b..c27c8c678d 100755 --- a/direct/src/directscripts/packpanda.py +++ b/direct/src/directscripts/packpanda.py @@ -419,3 +419,6 @@ else: if not(os.path.exists("/usr/bin/rpmbuild") or os.path.exists("/usr/bin/dpkg-deb")): exit("To build an installer, either rpmbuild or dpkg-deb must be present on your system!") +# Dummy main function so this can be added to console_scripts. +def main(): + return 0 diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 92a31b7d52..4ba7c0930f 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -2,6 +2,7 @@ This issue fixes several bugs that were still found in 1.9.2. +* Fix crash when using homebrew Python on Mac OS X * Fix crash when running in Steam on Linux when using OpenAL * Fix crash using wx/tkinter on Mac as long as want-wx/tk is set * Fix loading models from 'models' package with models/ prefix diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 4adcb96d5e..040fb03e2b 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -74,6 +74,7 @@ STRDXSDKVERSION = 'default' STRMSPLATFORMVERSION = 'default' BOOUSEINTELCOMPILER = False OPENCV_VER_23 = False +DIRECTSCRIPTS = True if "MACOSX_DEPLOYMENT_TARGET" in os.environ: OSXTARGET=os.environ["MACOSX_DEPLOYMENT_TARGET"] @@ -169,7 +170,7 @@ def usage(problem): def parseopts(args): global INSTALLER,RTDIST,RUNTIME,GENMAN,DISTRIBUTOR,VERSION global COMPRESSOR,THREADCOUNT,OSXTARGET,OSX_ARCHS,HOST_URL - global DEBVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX + global DEBVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX,DIRECTSCRIPTS global STRDXSDKVERSION, STRMSPLATFORMVERSION, BOOUSEINTELCOMPILER longopts = [ "help","distributor=","verbose","runtime","osxtarget=", @@ -177,7 +178,7 @@ def parseopts(args): "version=","lzma","no-python","threads=","outputdir=","override=", "static","host=","debversion=","rpmrelease=","p3dsuffix=", "directx-sdk=", "platform-sdk=", "use-icl", "clean", - "universal", "target=", "arch=", "git-commit="] + "universal", "target=", "arch=", "git-commit=", "no-directscripts"] anything = 0 optimize = "" target = None @@ -223,6 +224,7 @@ def parseopts(args): # Backward compatibility, OPENGL was renamed to GL elif (option=="--use-opengl"): PkgEnable("GL") elif (option=="--no-opengl"): PkgDisable("GL") + elif (option=="--no-directscripts"): DIRECTSCRIPTS=False elif (option=="--directx-sdk"): STRDXSDKVERSION = value.strip().lower() if STRDXSDKVERSION == '': @@ -799,7 +801,7 @@ if (COMPILER=="GCC"): if GetTarget() != 'darwin': # CgGL is covered by the Cg framework, and we don't need X11 components on OSX if not PkgSkip("NVIDIACG") and not RUNTIME: - SmartPkgEnable("CGGL", "", ("CgGL"), "Cg/cgGL.h") + SmartPkgEnable("CGGL", "", ("CgGL"), "Cg/cgGL.h", thirdparty_dir = "nvidiacg") if not RUNTIME: SmartPkgEnable("X11", "x11", "X11", ("X11", "X11/Xlib.h")) SmartPkgEnable("XRANDR", "xrandr", "Xrandr", "X11/extensions/Xrandr.h") @@ -1646,6 +1648,11 @@ def CompileLink(dll, obj, opts): if LDFLAGS != "": cmd += " " + LDFLAGS + # Don't link libraries with Python. + if "PYTHON" in opts and GetOrigExt(dll) != ".exe" and not RTDIST: + opts = opts[:] + opts.remove("PYTHON") + for (opt, dir) in LIBDIRECTORIES: if (opt=="ALWAYS") or (opt in opts): cmd += ' -L' + BracketNameWithQuotes(dir) @@ -4822,7 +4829,7 @@ if (PkgSkip("DIRECT")==0): OPTS=['DIR:direct/src/directbase', 'PYTHON'] TargetAdd('p3directbase_directbase.obj', opts=OPTS+['BUILDING:DIRECT'], input='directbase.cxx') - if (PkgSkip("PYTHON")==0 and not RTDIST and not RUNTIME): + if (PkgSkip("PYTHON")==0 and not RTDIST and not RUNTIME and DIRECTSCRIPTS): DefSymbol("BUILDING:PACKPANDA", "IMPORT_MODULE", "direct.directscripts.packpanda") TargetAdd('packpanda.obj', opts=OPTS+['BUILDING:PACKPANDA'], input='ppython.cxx') TargetAdd('packpanda.exe', input='packpanda.obj') From 62d0d8292e21561caf6486dfdc3ec87204443f14 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 9 Dec 2016 01:41:32 +0100 Subject: [PATCH 06/12] More texture load/store performance optimisations --- panda/src/gobj/texture.cxx | 53 ++++++++++++++++++++++++-------------- 1 file changed, 33 insertions(+), 20 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index bcabaa7a8c..cd5cd54e73 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -6005,10 +6005,11 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, // Most common case: one byte per pixel, and the source image // maxval of 255. No scaling is necessary. Because this is such a common // case, we break it out per component for best performance. + const xel *array = pnmimage.get_array(); switch (num_components) { case 1: for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); + const xel *row = array + j * x_size; for (int i = 0; i < x_size; i++) { *p++ = (uchar)PPM_GETB(row[i]); } @@ -6018,9 +6019,10 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, case 2: if (img_has_alpha) { + const xelval *alpha = pnmimage.get_alpha_array(); for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); - xelval *alpha_row = pnmimage.alpha_row(j); + const xel *row = array + j * x_size; + const xelval *alpha_row = alpha + j * x_size; for (int i = 0; i < x_size; i++) { *p++ = (uchar)PPM_GETB(row[i]); *p++ = (uchar)alpha_row[i]; @@ -6029,7 +6031,7 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, } } else { for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); + const xel *row = array + j * x_size; for (int i = 0; i < x_size; i++) { *p++ = (uchar)PPM_GETB(row[i]); *p++ = (uchar)255; @@ -6041,7 +6043,7 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, case 3: for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); + const xel *row = array + j * x_size; for (int i = 0; i < x_size; i++) { *p++ = (uchar)PPM_GETB(row[i]); *p++ = (uchar)PPM_GETG(row[i]); @@ -6053,9 +6055,10 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, case 4: if (img_has_alpha) { + const xelval *alpha = pnmimage.get_alpha_array(); for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); - xelval *alpha_row = pnmimage.alpha_row(j); + const xel *row = array + j * x_size; + const xelval *alpha_row = alpha + j * x_size; for (int i = 0; i < x_size; i++) { *p++ = (uchar)PPM_GETB(row[i]); *p++ = (uchar)PPM_GETG(row[i]); @@ -6066,7 +6069,7 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, } } else { for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); + const xel *row = array + j * x_size; for (int i = 0; i < x_size; i++) { *p++ = (uchar)PPM_GETB(row[i]); *p++ = (uchar)PPM_GETG(row[i]); @@ -6089,7 +6092,7 @@ convert_from_pnmimage(PTA_uchar &image, size_t page_size, for (int j = y_size-1; j >= 0; j--) { for (int i = 0; i < x_size; i++) { if (is_grayscale) { - store_unscaled_short(p, pnmimage.get_gray_val(i, j)); + store_unscaled_short(p, pnmimage.get_gray_val(i, j)); } else { store_unscaled_short(p, pnmimage.get_blue_val(i, j)); store_unscaled_short(p, pnmimage.get_green_val(i, j)); @@ -6260,11 +6263,13 @@ convert_to_pnmimage(PNMImage &pnmimage, int x_size, int y_size, const unsigned char *p = &image[idx]; if (component_width == 1) { + xel *array = pnmimage.get_array(); if (is_grayscale) { if (has_alpha) { + xelval *alpha = pnmimage.get_alpha_array(); for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); - xelval *alpha_row = pnmimage.alpha_row(j); + xel *row = array + j * x_size; + xelval *alpha_row = alpha + j * x_size; for (int i = 0; i < x_size; i++) { PPM_PUTB(row[i], *p++); alpha_row[i] = *p++; @@ -6272,7 +6277,7 @@ convert_to_pnmimage(PNMImage &pnmimage, int x_size, int y_size, } } else { for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); + xel *row = array + j * x_size; for (int i = 0; i < x_size; i++) { PPM_PUTB(row[i], *p++); } @@ -6280,9 +6285,10 @@ convert_to_pnmimage(PNMImage &pnmimage, int x_size, int y_size, } } else { if (has_alpha) { + xelval *alpha = pnmimage.get_alpha_array(); for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); - xelval *alpha_row = pnmimage.alpha_row(j); + xel *row = array + j * x_size; + xelval *alpha_row = alpha + j * x_size; for (int i = 0; i < x_size; i++) { PPM_PUTB(row[i], *p++); PPM_PUTG(row[i], *p++); @@ -6292,7 +6298,7 @@ convert_to_pnmimage(PNMImage &pnmimage, int x_size, int y_size, } } else { for (int j = y_size-1; j >= 0; j--) { - xel *row = pnmimage.row(j); + xel *row = array + j * x_size; for (int i = 0; i < x_size; i++) { PPM_PUTB(row[i], *p++); PPM_PUTG(row[i], *p++); @@ -7028,13 +7034,20 @@ compare_images(const PNMImage &a, const PNMImage &b) { nassertr(a.get_x_size() == b.get_x_size() && a.get_y_size() == b.get_y_size(), false); + const xel *a_array = a.get_array(); + const xel *b_array = b.get_array(); + const xelval *a_alpha = a.get_alpha_array(); + const xelval *b_alpha = b.get_alpha_array(); + + int x_size = a.get_x_size(); + int delta = 0; for (int yi = 0; yi < a.get_y_size(); ++yi) { - xel *a_row = a.row(yi); - xel *b_row = b.row(yi); - xelval *a_alpha_row = a.alpha_row(yi); - xelval *b_alpha_row = b.alpha_row(yi); - for (int xi = 0; xi < a.get_x_size(); ++xi) { + const xel *a_row = a_array + yi * x_size; + const xel *b_row = b_array + yi * x_size; + const xelval *a_alpha_row = a_alpha + yi * x_size; + const xelval *b_alpha_row = b_alpha + yi * x_size; + for (int xi = 0; xi < x_size; ++xi) { delta += abs(PPM_GETR(a_row[xi]) - PPM_GETR(b_row[xi])); delta += abs(PPM_GETG(a_row[xi]) - PPM_GETG(b_row[xi])); delta += abs(PPM_GETB(a_row[xi]) - PPM_GETB(b_row[xi])); From 056ea94765aeccd659e3905fa46ccc4556eaa9e8 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 22 Dec 2016 21:28:19 +0100 Subject: [PATCH 07/12] Fix PythonThread crash (LP bug 1245818) --- panda/src/pipeline/pythonThread.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/panda/src/pipeline/pythonThread.cxx b/panda/src/pipeline/pythonThread.cxx index c1ef41e344..493b576229 100644 --- a/panda/src/pipeline/pythonThread.cxx +++ b/panda/src/pipeline/pythonThread.cxx @@ -50,6 +50,13 @@ PythonThread(PyObject *function, PyObject *args, nassert_raise("Invalid args passed to PythonThread constructor"); } } + +#ifndef SIMPLE_THREADS + // Ensure that the Python threading system is initialized and ready to go. +#ifdef WITH_THREAD // This symbol defined within Python.h + PyEval_InitThreads(); +#endif +#endif } //////////////////////////////////////////////////////////////////// @@ -59,9 +66,20 @@ PythonThread(PyObject *function, PyObject *args, //////////////////////////////////////////////////////////////////// PythonThread:: ~PythonThread() { + // Unfortunately, we need to grab the GIL to release these things, + // since the destructor could be called from any thread. +#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) + PyGILState_STATE gstate; + gstate = PyGILState_Ensure(); +#endif + Py_DECREF(_function); Py_XDECREF(_args); Py_XDECREF(_result); + +#if defined(HAVE_THREADS) && !defined(SIMPLE_THREADS) + PyGILState_Release(gstate); +#endif } //////////////////////////////////////////////////////////////////// From 601b6b86781912ac761d4d25d1a3499b93b7e690 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 22 Dec 2016 21:29:11 +0100 Subject: [PATCH 08/12] Tweaks for building with static thirdparty libs on Linux Sneak in a function used by makewheel --- makepanda/makepanda.py | 14 +++++++++++--- makepanda/makepandacore.py | 12 ++++++++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 040fb03e2b..cb175542f2 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -561,6 +561,10 @@ if (COMPILER == "MSVC"): LibName(pkg, 'dxerrVNUM.lib'.replace("VNUM", vnum)) #LibName(pkg, 'ddraw.lib') LibName(pkg, 'dxguid.lib') + + if not PkgSkip("FREETYPE") and os.path.isdir(GetThirdpartyDir() + "freetype/include/freetype2"): + IncDirectory("FREETYPE", GetThirdpartyDir() + "freetype/include/freetype2") + IncDirectory("ALWAYS", GetThirdpartyDir() + "extras/include") LibName("WINSOCK", "wsock32.lib") LibName("WINSOCK2", "wsock32.lib") @@ -766,9 +770,13 @@ if (COMPILER=="GCC"): SmartPkgEnable("JPEG", "", ("jpeg"), "jpeglib.h") SmartPkgEnable("PNG", "libpng", ("png"), "png.h", tool = "libpng-config") - if GetTarget() == "darwin" and not PkgSkip("FFMPEG"): - LibName("FFMPEG", "-Wl,-read_only_relocs,suppress") - LibName("FFMPEG", "-framework VideoDecodeAcceleration") + if not PkgSkip("FFMPEG"): + if GetTarget() == "darwin": + LibName("FFMPEG", "-Wl,-read_only_relocs,suppress") + LibName("FFMPEG", "-framework VideoDecodeAcceleration") + elif os.path.isfile(GetThirdpartyDir() + "ffmpeg/lib/libavcodec.a"): + # Needed when linking ffmpeg statically on Linux. + LibName("FFMPEG", "-Wl,-Bsymbolic") cv_lib = ChooseLib(("opencv_core", "cv"), "OPENCV") if cv_lib == "opencv_core": diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 1b011188ff..fea93fd434 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -1491,6 +1491,11 @@ def SmartPkgEnable(pkg, pkgconfig = None, libs = None, incs = None, defs = None, if os.path.isdir(os.path.join(pkg_dir, "include")): IncDirectory(target_pkg, os.path.join(pkg_dir, "include")) + # Handle cases like freetype2 where the include dir is a subdir under "include" + for i in incs: + if os.path.isdir(os.path.join(pkg_dir, "include", i)): + IncDirectory(target_pkg, os.path.join(pkg_dir, "include", i)) + if os.path.isdir(os.path.join(pkg_dir, "lib")): LibDirectory(target_pkg, os.path.join(pkg_dir, "lib")) @@ -2749,6 +2754,13 @@ def GetOrigExt(x): def SetOrigExt(x, v): ORIG_EXT[x] = v +def GetExtensionSuffix(): + target = GetTarget() + if target == 'windows': + return '.pyd' + else: + return '.so' + def CalcLocation(fn, ipath): if (fn.count("/")): return fn dllext = "" From 2ac1734566dbe5174a72b878a429b581421461ad Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 23 Dec 2016 00:36:59 +0100 Subject: [PATCH 09/12] Fix crash when trying to write 16-bit TIFF file (LP bug 1222922) Note: does not actually add support for writing 16-bit tifs; Panda just doesn't crash but automatically downsamples to 8-bit. --- doc/ReleaseNotes | 1 + panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 4ba7c0930f..3ad0ecd49b 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -76,6 +76,7 @@ remained in the 1.9.1 release, including: * Fix constant reloading of texture when gl-ignore-mipmaps is set * BamReader now releases the GIL (so it can be used threaded) * Fix AttributeError in direct.stdpy.threading module +* Fix crash when writing 16-bit .tif file (now silently downsamples) ------------------------ RELEASE 1.9.1 ------------------------ diff --git a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx index ab09b1f034..5bfb87e5c3 100644 --- a/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx +++ b/panda/src/pnmimagetypes/pnmFileTypeTIFF.cxx @@ -1114,13 +1114,13 @@ write_data(xel *array, xelval *alpha) { bytesperrow = _x_size * samplesperpixel; } else if ( grayscale ) { samplesperpixel = 1; - bitspersample = pm_maxvaltobits( _maxval ); + bitspersample = min(8, pm_maxvaltobits(_maxval)); photometric = PHOTOMETRIC_MINISBLACK; i = 8 / bitspersample; bytesperrow = ( _x_size + i - 1 ) / i; } else { samplesperpixel = 1; - bitspersample = 8; + bitspersample = min(8, pm_maxvaltobits(_maxval)); photometric = PHOTOMETRIC_PALETTE; bytesperrow = _x_size; } From 59c3aa3ef6a090592b7ee32e7b4ca229c6ffe649 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 25 Dec 2016 09:59:29 -0500 Subject: [PATCH 10/12] cocoa: don't crash if display server doesn't give us display modes --- panda/src/cocoadisplay/cocoaGraphicsPipe.mm | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm index 1969ac4116..367b00c520 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsPipe.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsPipe.mm @@ -148,11 +148,14 @@ load_display_information() { //_display_information->_device_id = CGDisplaySerialNumber(_display); // Display modes + size_t num_modes = 0; #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 CFArrayRef modes = CGDisplayCopyAllDisplayModes(_display, NULL); - size_t num_modes = CFArrayGetCount(modes); - _display_information->_total_display_modes = num_modes; - _display_information->_display_mode_array = new DisplayMode[num_modes]; + if (modes != NULL) { + num_modes = CFArrayGetCount(modes); + _display_information->_total_display_modes = num_modes; + _display_information->_display_mode_array = new DisplayMode[num_modes]; + } for (size_t i = 0; i < num_modes; ++i) { CGDisplayModeRef mode = (CGDisplayModeRef) CFArrayGetValueAtIndex(modes, i); @@ -189,13 +192,17 @@ load_display_information() { } CFRelease(encoding); } - CFRelease(modes); + if (modes != NULL) { + CFRelease(modes); + } #else CFArrayRef modes = CGDisplayAvailableModes(_display); - size_t num_modes = CFArrayGetCount(modes); - _display_information->_total_display_modes = num_modes; - _display_information->_display_mode_array = new DisplayMode[num_modes]; + if (modes != NULL) { + num_modes = CFArrayGetCount(modes); + _display_information->_total_display_modes = num_modes; + _display_information->_display_mode_array = new DisplayMode[num_modes]; + } for (size_t i = 0; i < num_modes; ++i) { CFDictionaryRef mode = (CFDictionaryRef) CFArrayGetValueAtIndex(modes, i); From 4393455ebac4fd4c65febc5d5bf7dde862117978 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 25 Dec 2016 16:12:54 +0100 Subject: [PATCH 11/12] Fix get_keyboard_map on Czech (and other) layouts Now reports proper Unicode name, and doesn't omit keys that don't have a recognised mapping by Panda https://bugs.launchpad.net/panda3d/+bug/1652145 --- doc/ReleaseNotes | 1 + panda/src/windisplay/winGraphicsWindow.cxx | 15 ++++++++------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 3ad0ecd49b..cd6bdf2f4c 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -52,6 +52,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Now tries to preserve refresh rate when switching fullscreen on Windows * Fix back-to-front sorting when gl-coordinate-system is changed * Now also compiles on older Linux distros (eg. CentOS 5 / manylinux1) +* get_keyboard_map now includes keys on layouts with special characters ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/panda/src/windisplay/winGraphicsWindow.cxx b/panda/src/windisplay/winGraphicsWindow.cxx index 0f7e33dc75..7f949415fe 100644 --- a/panda/src/windisplay/winGraphicsWindow.cxx +++ b/panda/src/windisplay/winGraphicsWindow.cxx @@ -2721,7 +2721,7 @@ ButtonMap *WinGraphicsWindow:: get_keyboard_map() const { ButtonMap *map = new ButtonMap; - char text[256]; + wchar_t text[256]; UINT vsc = 0; unsigned short ex_vsc[] = {0x57, 0x58, 0x011c, 0x011d, 0x0135, 0x0137, 0x0138, 0x0145, 0x0147, 0x0148, 0x0149, 0x014b, 0x014d, 0x014f, 0x0150, 0x0151, 0x0152, 0x0153, 0x015b, 0x015c, 0x015d}; @@ -2759,14 +2759,15 @@ get_keyboard_map() const { UINT vk = MapVirtualKeyA(vsc, MAPVK_VSC_TO_VK_EX); button = lookup_key(vk); - if (button == ButtonHandle::none()) { - continue; - } + //if (button == ButtonHandle::none()) { + // continue; + //} } - int len = GetKeyNameTextA(lparam, text, 256); - string label (text, len); - map->map_button(raw_button, button, label); + int len = GetKeyNameTextW(lparam, text, 256); + TextEncoder enc; + enc.set_wtext(wstring(text, len)); + map->map_button(raw_button, button, enc.get_text()); } return map; From 0c742d59e58dd4c7a5a608e5d243d42319a7357a Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 25 Dec 2016 22:03:05 +0100 Subject: [PATCH 12/12] Fix crash due to incorrect alignment when building Eigen with AVX extensions Consequentially, we now use 32-byte alignment when building with eigen if __AVX__ is set. --- doc/ReleaseNotes | 1 + dtool/src/dtoolbase/deletedBufferChain.h | 4 ++++ dtool/src/dtoolbase/dlmalloc_src.cxx | 5 +++++ dtool/src/dtoolbase/dtoolbase.h | 2 +- dtool/src/dtoolbase/memoryHook.I | 12 +++++++++++- 5 files changed, 22 insertions(+), 2 deletions(-) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index cd6bdf2f4c..74a0a9ea05 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -53,6 +53,7 @@ This issue fixes several bugs that were still found in 1.9.2. * Fix back-to-front sorting when gl-coordinate-system is changed * Now also compiles on older Linux distros (eg. CentOS 5 / manylinux1) * get_keyboard_map now includes keys on layouts with special characters +* Fix crash due to incorrect alignment when compiling Eigen with AVX ------------------------ RELEASE 1.9.2 ------------------------ diff --git a/dtool/src/dtoolbase/deletedBufferChain.h b/dtool/src/dtoolbase/deletedBufferChain.h index 301ee5d297..a71bc90b45 100644 --- a/dtool/src/dtoolbase/deletedBufferChain.h +++ b/dtool/src/dtoolbase/deletedBufferChain.h @@ -105,7 +105,11 @@ private: #elif defined(LINMATH_ALIGN) // With SSE2 alignment, we need all 16 bytes to preserve alignment. +#ifdef __AVX__ + static const size_t flag_reserved_bytes = 32; +#else static const size_t flag_reserved_bytes = 16; +#endif #else // Otherwise, we only need enough space for the Integer itself. diff --git a/dtool/src/dtoolbase/dlmalloc_src.cxx b/dtool/src/dtoolbase/dlmalloc_src.cxx index 4e21f4c914..dcbb0daa25 100644 --- a/dtool/src/dtoolbase/dlmalloc_src.cxx +++ b/dtool/src/dtoolbase/dlmalloc_src.cxx @@ -453,8 +453,13 @@ DEFAULT_MMAP_THRESHOLD default: 256K // drose: We require 16-byte alignment of certain structures, to // support SSE2. We don't strictly have to align *everything*, but // it's just easier to do so. +#ifdef __AVX__ +// Eigen requires 32-byte alignment when using AVX instructions. +#define MALLOC_ALIGNMENT ((size_t)32U) +#else #define MALLOC_ALIGNMENT ((size_t)16U) #endif +#endif #ifndef WIN32 #ifdef _WIN32 diff --git a/dtool/src/dtoolbase/dtoolbase.h b/dtool/src/dtoolbase/dtoolbase.h index 2c883f8220..27add7c84d 100644 --- a/dtool/src/dtoolbase/dtoolbase.h +++ b/dtool/src/dtoolbase/dtoolbase.h @@ -372,7 +372,7 @@ // enforce alignment externally. #define MEMORY_HOOK_DO_ALIGN 1 -#elif defined(IS_OSX) || defined(_WIN64) +#elif (defined(IS_OSX) || defined(_WIN64)) && !defined(__AVX__) // The OS-provided malloc implementation will do the required // alignment. #undef MEMORY_HOOK_DO_ALIGN diff --git a/dtool/src/dtoolbase/memoryHook.I b/dtool/src/dtoolbase/memoryHook.I index 9286a18d7a..ecccf07d65 100644 --- a/dtool/src/dtoolbase/memoryHook.I +++ b/dtool/src/dtoolbase/memoryHook.I @@ -55,7 +55,12 @@ get_memory_alignment() { // We require 16-byte alignment of certain structures, to support // SSE2. We don't strictly have to align *everything*, but it's just // easier to do so. +#ifdef __AVX__ + // Eigen requires 32-byte alignment when using AVX instructions. + const size_t alignment_size = 32; +#else const size_t alignment_size = 16; +#endif #else // Otherwise, use word alignment. const size_t alignment_size = sizeof(void *); @@ -79,7 +84,12 @@ get_header_reserved_bytes() { #ifdef LINMATH_ALIGN // If we're doing SSE2 alignment, we must reserve a full 16-byte // block, since anything less than that will spoil the alignment. - static const size_t header_reserved_bytes = 16; +#ifdef __AVX__ + // Eigen requires 32-byte alignment when using AVX instructions. + const size_t header_reserved_bytes = 32; +#else + const size_t header_reserved_bytes = 16; +#endif #elif defined(MEMORY_HOOK_DO_ALIGN) // If we're just aligning to words, we reserve a block as big as two