From 3db8ce2562a92b755e0df193d5484a30d004520c Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 8 Mar 2017 12:28:06 +0100 Subject: [PATCH 1/8] Fixes for ARM build --- panda/src/display/displayInformation.cxx | 6 ++++++ panda/src/display/graphicsPipe.cxx | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/panda/src/display/displayInformation.cxx b/panda/src/display/displayInformation.cxx index 9bda75e0de..d690544889 100644 --- a/panda/src/display/displayInformation.cxx +++ b/panda/src/display/displayInformation.cxx @@ -15,11 +15,13 @@ #include "displayInformation.h" // For __rdtsc +#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) #ifdef _MSC_VER #include #elif defined(__GNUC__) && !defined(__clang__) #include #endif +#endif /** * Returns true if these two DisplayModes are identical. @@ -529,6 +531,7 @@ get_cpu_frequency() { */ uint64_t DisplayInformation:: get_cpu_time() { +#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) #if defined(_MSC_VER) || (defined(__GNUC__) && !defined(__clang__)) return __rdtsc(); #else @@ -536,6 +539,9 @@ get_cpu_time() { __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); return ((uint64_t)hi << 32) | lo; #endif +#else + return 0; +#endif } /** diff --git a/panda/src/display/graphicsPipe.cxx b/panda/src/display/graphicsPipe.cxx index bb6fdae3a4..ad5d1aea62 100644 --- a/panda/src/display/graphicsPipe.cxx +++ b/panda/src/display/graphicsPipe.cxx @@ -28,6 +28,16 @@ #include #endif +#ifdef _WIN32 +#ifndef WIN32_LEAN_AND_MEAN +#define WIN32_LEAN_AND_MEAN 1 +#endif +#include +#endif + +// CPUID is only available on i386 and x86-64 architectures. +#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) + #if defined(__GNUC__) && !defined(__APPLE__) // GCC and Clang offer a useful cpuid.h header. #include @@ -38,13 +48,6 @@ #include #endif -#ifdef _WIN32 -#ifndef WIN32_LEAN_AND_MEAN -#define WIN32_LEAN_AND_MEAN 1 -#endif -#include -#endif - union cpuid_info { char str[16]; struct { @@ -85,6 +88,7 @@ static inline void get_cpuid(uint32_t leaf, cpuid_info &info) { : "0" (leaf)); #endif } +#endif #ifdef IS_LINUX /** @@ -123,6 +127,7 @@ GraphicsPipe() : _display_information = new DisplayInformation(); +#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64) cpuid_info info; const uint32_t max_cpuid = get_cpuid_max(0); const uint32_t max_extended = get_cpuid_max(0x80000000); @@ -148,6 +153,7 @@ GraphicsPipe() : brand[48] = 0; _display_information->_cpu_brand_string = brand; } +#endif #if defined(IS_OSX) // macOS exposes a lot of useful information through sysctl. From 4f299fa71fa96e25a8f0d7dee9bfb2a2de7b2b24 Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 9 Mar 2017 14:31:07 +0100 Subject: [PATCH 2/8] Fix compilation when building without threads enabled --- panda/src/gobj/geomVertexArrayData.I | 50 ++++++++++++++++++++++++++++ panda/src/gobj/geomVertexArrayData.h | 4 +++ 2 files changed, 54 insertions(+) diff --git a/panda/src/gobj/geomVertexArrayData.I b/panda/src/gobj/geomVertexArrayData.I index 6b29288f3b..351f56cd53 100644 --- a/panda/src/gobj/geomVertexArrayData.I +++ b/panda/src/gobj/geomVertexArrayData.I @@ -283,6 +283,31 @@ GeomVertexArrayDataHandle(CPT(GeomVertexArrayData) object, #endif } +/** + * + */ +INLINE GeomVertexArrayDataHandle:: +GeomVertexArrayDataHandle(const GeomVertexArrayData *object, + Thread *current_thread) : + _object((GeomVertexArrayData *)object), + _current_thread(current_thread), + _cdata((GeomVertexArrayData::CData *)object->_cycler.read_unlocked(current_thread)), + _writable(false) +{ +#ifdef _DEBUG + nassertv(_object->test_ref_count_nonzero()); +#endif // _DEBUG +#ifdef DO_PIPELINING + _cdata->ref(); +#endif // DO_PIPELINING + // We must grab the lock *after* we have incremented the reference count, + // above. + _cdata->_rw_lock.acquire(); +#ifdef DO_MEMORY_USAGE + MemoryUsage::update_type(this, get_class_type()); +#endif +} + /** * */ @@ -309,6 +334,31 @@ GeomVertexArrayDataHandle(PT(GeomVertexArrayData) object, #endif } +/** + * + */ +INLINE GeomVertexArrayDataHandle:: +GeomVertexArrayDataHandle(GeomVertexArrayData *object, + Thread *current_thread) : + _object(object), + _current_thread(current_thread), + _cdata(object->_cycler.write_upstream(true, current_thread)), + _writable(true) +{ +#ifdef _DEBUG + nassertv(_object->test_ref_count_nonzero()); +#endif // _DEBUG +#ifdef DO_PIPELINING + _cdata->ref(); +#endif // DO_PIPELINING + // We must grab the lock *after* we have incremented the reference count, + // above. + _cdata->_rw_lock.acquire(); +#ifdef DO_MEMORY_USAGE + MemoryUsage::update_type(this, get_class_type()); +#endif +} + /** * Don't attempt to copy these objects. */ diff --git a/panda/src/gobj/geomVertexArrayData.h b/panda/src/gobj/geomVertexArrayData.h index 2104e74b52..c16c5831d9 100644 --- a/panda/src/gobj/geomVertexArrayData.h +++ b/panda/src/gobj/geomVertexArrayData.h @@ -250,8 +250,12 @@ class EXPCL_PANDA_GOBJ GeomVertexArrayDataHandle : public ReferenceCount, public private: INLINE GeomVertexArrayDataHandle(CPT(GeomVertexArrayData) object, Thread *current_thread); + INLINE GeomVertexArrayDataHandle(const GeomVertexArrayData *object, + Thread *current_thread); INLINE GeomVertexArrayDataHandle(PT(GeomVertexArrayData) object, Thread *current_thread); + INLINE GeomVertexArrayDataHandle(GeomVertexArrayData *object, + Thread *current_thread); INLINE GeomVertexArrayDataHandle(const GeomVertexArrayDataHandle &); INLINE void operator = (const GeomVertexArrayDataHandle &); From ce736ad0936fa64e5ede54eec336903fbf789e42 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 10 Mar 2017 12:25:21 +0100 Subject: [PATCH 3/8] glsl: fix issue with vertex colors not showing up --- panda/src/glstuff/glShaderContext_src.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index 6947a39235..41b004775f 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -2194,7 +2194,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Figure out which attributes to enable or disable. BitMask32 enabled_attribs = _enabled_attribs; if (_color_attrib_index != -1 && - color_attrib->get_type() != ColorAttrib::T_vertex) { + color_attrib->get_color_type() != ColorAttrib::T_vertex) { // Vertex colours are disabled. enabled_attribs.clear_bit(_color_attrib_index); @@ -2247,7 +2247,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) { // Don't apply vertex colors if they are disabled with a ColorAttrib. int num_elements, element_stride, divisor; bool normalized; - if ((p != _color_attrib_index || color_attrib->get_type() == ColorAttrib::T_vertex) && + if ((p != _color_attrib_index || color_attrib->get_color_type() == ColorAttrib::T_vertex) && _glgsg->_data_reader->get_array_info(name, array_reader, num_values, numeric_type, normalized, start, stride, divisor, From 64a7fbab873dedf8aaa6fb1993bc16ed12f0f0bd Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 10 Mar 2017 23:00:00 +0100 Subject: [PATCH 4/8] glgsg: fix assertion encountered when trying to use pointer textures Fixes LP 990089 --- panda/src/gobj/texture.I | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index 47ce9e233f..29b1702280 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -1544,7 +1544,14 @@ INLINE size_t Texture:: get_ram_mipmap_image_size(int n) const { CDReader cdata(_cycler); if (n >= 0 && n < (int)cdata->_ram_images.size()) { - return cdata->_ram_images[n]._image.size(); + if (cdata->_ram_images[n]._pointer_image == nullptr) { + return cdata->_ram_images[n]._image.size(); + } else { + // Calculate it based on the given page size. + return do_get_ram_mipmap_page_size(cdata, n) * + do_get_expected_mipmap_z_size(cdata, n) * + cdata->_num_views; + } } return 0; } From d8066e19b1844786b2369638516813fef29a7026 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 22 Mar 2017 22:42:21 +0100 Subject: [PATCH 5/8] Fix assertion when using Texture.load_sub_image to load entire image --- panda/src/gobj/texture.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 115d9529bf..d3dd47dbb9 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -3441,8 +3441,8 @@ do_load_sub_image(CData *cdata, const PNMImage &image, int x, int y, int z, int nassertr(y >= 0 && y < tex_y_size, false); nassertr(z >= 0 && z < tex_z_size, false); - nassertr(image.get_x_size() + x < tex_x_size, false); - nassertr(image.get_y_size() + y < tex_y_size, false); + nassertr(image.get_x_size() + x <= tex_x_size, false); + nassertr(image.get_y_size() + y <= tex_y_size, false); // Flip y y = cdata->_y_size - (image.get_y_size() + y); From 9d05044a9f925ac8e4440023acd8bd34af75d96e Mon Sep 17 00:00:00 2001 From: rdb Date: Thu, 23 Mar 2017 12:22:34 +0100 Subject: [PATCH 6/8] shadows: force interocular distance to 0 for shadow cameras --- panda/src/pgraphnodes/directionalLight.cxx | 1 + panda/src/pgraphnodes/pointLight.cxx | 6 ++++++ panda/src/pgraphnodes/spotlight.cxx | 1 + 3 files changed, 8 insertions(+) diff --git a/panda/src/pgraphnodes/directionalLight.cxx b/panda/src/pgraphnodes/directionalLight.cxx index 127f994fbb..f0d84ffb9a 100644 --- a/panda/src/pgraphnodes/directionalLight.cxx +++ b/panda/src/pgraphnodes/directionalLight.cxx @@ -59,6 +59,7 @@ DirectionalLight(const string &name) : LightLensNode(name, new OrthographicLens()), _has_specular_color(false) { + _lenses[0]._lens->set_interocular_distance(0); } /** diff --git a/panda/src/pgraphnodes/pointLight.cxx b/panda/src/pgraphnodes/pointLight.cxx index 564116ecac..d3f7192248 100644 --- a/panda/src/pgraphnodes/pointLight.cxx +++ b/panda/src/pgraphnodes/pointLight.cxx @@ -66,21 +66,27 @@ PointLight(const string &name) : { PT(Lens) lens; lens = new PerspectiveLens(90, 90); + lens->set_interocular_distance(0); lens->set_view_vector(1, 0, 0, 0, -1, 0); set_lens(0, lens); lens = new PerspectiveLens(90, 90); + lens->set_interocular_distance(0); lens->set_view_vector(-1, 0, 0, 0, -1, 0); set_lens(1, lens); lens = new PerspectiveLens(90, 90); + lens->set_interocular_distance(0); lens->set_view_vector(0, 1, 0, 0, 0, 1); set_lens(2, lens); lens = new PerspectiveLens(90, 90); + lens->set_interocular_distance(0); lens->set_view_vector(0, -1, 0, 0, 0, -1); set_lens(3, lens); lens = new PerspectiveLens(90, 90); + lens->set_interocular_distance(0); lens->set_view_vector(0, 0, 1, 0, -1, 0); set_lens(4, lens); lens = new PerspectiveLens(90, 90); + lens->set_interocular_distance(0); lens->set_view_vector(0, 0, -1, 0, -1, 0); set_lens(5, lens); } diff --git a/panda/src/pgraphnodes/spotlight.cxx b/panda/src/pgraphnodes/spotlight.cxx index 638f89f93c..badf4544d9 100644 --- a/panda/src/pgraphnodes/spotlight.cxx +++ b/panda/src/pgraphnodes/spotlight.cxx @@ -68,6 +68,7 @@ Spotlight(const string &name) : LightLensNode(name), _has_specular_color(false) { + _lenses[0]._lens->set_interocular_distance(0); } /** From f062c64e9a827e8486776e76eb77febb2935c906 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 27 Mar 2017 00:56:05 -0600 Subject: [PATCH 7/8] distributed: Fix broken reference to StackTrace when __debug__==False --- direct/src/distributed/DistributedObject.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/direct/src/distributed/DistributedObject.py b/direct/src/distributed/DistributedObject.py index 0ed3e90a54..64fd3ecc20 100644 --- a/direct/src/distributed/DistributedObject.py +++ b/direct/src/distributed/DistributedObject.py @@ -4,7 +4,6 @@ from panda3d.core import * from panda3d.direct import * from direct.directnotify.DirectNotifyGlobal import directNotify from direct.distributed.DistributedObjectBase import DistributedObjectBase -from direct.showbase.PythonUtil import StackTrace #from PyDatagram import PyDatagram #from PyDatagramIterator import PyDatagramIterator @@ -259,7 +258,10 @@ class DistributedObject(DistributedObjectBase): def _destroyDO(self): # after this is called, the object is no longer a DistributedObject # but may still be used as a DelayDeleted object - self.destroyDoStackTrace = StackTrace() + if __debug__: + # StackTrace is omitted in packed versions + from direct.showbase.PythonUtil import StackTrace + self.destroyDoStackTrace = StackTrace() # check for leftover cached data that was not retrieved or flushed by this object # this will catch typos in the data name in calls to get/setCachedData if hasattr(self, '_cachedData'): From 4080e03d05c8b33b4ac1d343126a279d28122036 Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Mon, 27 Mar 2017 01:00:00 -0600 Subject: [PATCH 8/8] distributed: Remove use of exceptionLogged() decorator This isn't available when __debug__==False either. --- direct/src/distributed/DoCollectionManager.py | 1 - 1 file changed, 1 deletion(-) diff --git a/direct/src/distributed/DoCollectionManager.py b/direct/src/distributed/DoCollectionManager.py index 16bf345f4e..fcff96e218 100755 --- a/direct/src/distributed/DoCollectionManager.py +++ b/direct/src/distributed/DoCollectionManager.py @@ -312,7 +312,6 @@ class DoCollectionManager: else: self.notify.warning('handleSetLocation: object %s not present' % self.getMsgChannel()) - @exceptionLogged() def storeObjectLocation(self, object, parentId, zoneId): oldParentId = object.parentId oldZoneId = object.zoneId