Merge branch 'master' into cmake

This commit is contained in:
Sam Edwards 2017-03-27 01:00:18 -06:00
commit 79f9ac402f
12 changed files with 97 additions and 15 deletions

View File

@ -4,7 +4,6 @@ from panda3d.core import *
from panda3d.direct import * from panda3d.direct import *
from direct.directnotify.DirectNotifyGlobal import directNotify from direct.directnotify.DirectNotifyGlobal import directNotify
from direct.distributed.DistributedObjectBase import DistributedObjectBase from direct.distributed.DistributedObjectBase import DistributedObjectBase
from direct.showbase.PythonUtil import StackTrace
#from PyDatagram import PyDatagram #from PyDatagram import PyDatagram
#from PyDatagramIterator import PyDatagramIterator #from PyDatagramIterator import PyDatagramIterator
@ -259,7 +258,10 @@ class DistributedObject(DistributedObjectBase):
def _destroyDO(self): def _destroyDO(self):
# after this is called, the object is no longer a DistributedObject # after this is called, the object is no longer a DistributedObject
# but may still be used as a DelayDeleted object # 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 # 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 # this will catch typos in the data name in calls to get/setCachedData
if hasattr(self, '_cachedData'): if hasattr(self, '_cachedData'):

View File

@ -312,7 +312,6 @@ class DoCollectionManager:
else: else:
self.notify.warning('handleSetLocation: object %s not present' % self.getMsgChannel()) self.notify.warning('handleSetLocation: object %s not present' % self.getMsgChannel())
@exceptionLogged()
def storeObjectLocation(self, object, parentId, zoneId): def storeObjectLocation(self, object, parentId, zoneId):
oldParentId = object.parentId oldParentId = object.parentId
oldZoneId = object.zoneId oldZoneId = object.zoneId

View File

@ -15,11 +15,13 @@
#include "displayInformation.h" #include "displayInformation.h"
// For __rdtsc // For __rdtsc
#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
#ifdef _MSC_VER #ifdef _MSC_VER
#include <intrin.h> #include <intrin.h>
#elif defined(__GNUC__) && !defined(__clang__) #elif defined(__GNUC__) && !defined(__clang__)
#include <x86intrin.h> #include <x86intrin.h>
#endif #endif
#endif
/** /**
* Returns true if these two DisplayModes are identical. * Returns true if these two DisplayModes are identical.
@ -529,6 +531,7 @@ get_cpu_frequency() {
*/ */
uint64_t DisplayInformation:: uint64_t DisplayInformation::
get_cpu_time() { get_cpu_time() {
#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
#if defined(_MSC_VER) || (defined(__GNUC__) && !defined(__clang__)) #if defined(_MSC_VER) || (defined(__GNUC__) && !defined(__clang__))
return __rdtsc(); return __rdtsc();
#else #else
@ -536,6 +539,9 @@ get_cpu_time() {
__asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi));
return ((uint64_t)hi << 32) | lo; return ((uint64_t)hi << 32) | lo;
#endif #endif
#else
return 0;
#endif
} }
/** /**

View File

@ -28,6 +28,16 @@
#include <unistd.h> #include <unistd.h>
#endif #endif
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#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__) #if defined(__GNUC__) && !defined(__APPLE__)
// GCC and Clang offer a useful cpuid.h header. // GCC and Clang offer a useful cpuid.h header.
#include <cpuid.h> #include <cpuid.h>
@ -38,13 +48,6 @@
#include <intrin.h> #include <intrin.h>
#endif #endif
#ifdef _WIN32
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif
#include <windows.h>
#endif
union cpuid_info { union cpuid_info {
char str[16]; char str[16];
struct { struct {
@ -85,6 +88,7 @@ static inline void get_cpuid(uint32_t leaf, cpuid_info &info) {
: "0" (leaf)); : "0" (leaf));
#endif #endif
} }
#endif
#ifdef IS_LINUX #ifdef IS_LINUX
/** /**
@ -123,6 +127,7 @@ GraphicsPipe() :
_display_information = new DisplayInformation(); _display_information = new DisplayInformation();
#if defined(__i386) || defined(__x86_64__) || defined(_M_IX86) || defined(_M_X64)
cpuid_info info; cpuid_info info;
const uint32_t max_cpuid = get_cpuid_max(0); const uint32_t max_cpuid = get_cpuid_max(0);
const uint32_t max_extended = get_cpuid_max(0x80000000); const uint32_t max_extended = get_cpuid_max(0x80000000);
@ -148,6 +153,7 @@ GraphicsPipe() :
brand[48] = 0; brand[48] = 0;
_display_information->_cpu_brand_string = brand; _display_information->_cpu_brand_string = brand;
} }
#endif
#if defined(IS_OSX) #if defined(IS_OSX)
// macOS exposes a lot of useful information through sysctl. // macOS exposes a lot of useful information through sysctl.

View File

@ -2194,7 +2194,7 @@ update_shader_vertex_arrays(ShaderContext *prev, bool force) {
// Figure out which attributes to enable or disable. // Figure out which attributes to enable or disable.
BitMask32 enabled_attribs = _enabled_attribs; BitMask32 enabled_attribs = _enabled_attribs;
if (_color_attrib_index != -1 && if (_color_attrib_index != -1 &&
color_attrib->get_type() != ColorAttrib::T_vertex) { color_attrib->get_color_type() != ColorAttrib::T_vertex) {
// Vertex colours are disabled. // Vertex colours are disabled.
enabled_attribs.clear_bit(_color_attrib_index); 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. // Don't apply vertex colors if they are disabled with a ColorAttrib.
int num_elements, element_stride, divisor; int num_elements, element_stride, divisor;
bool normalized; 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, _glgsg->_data_reader->get_array_info(name, array_reader,
num_values, numeric_type, num_values, numeric_type,
normalized, start, stride, divisor, normalized, start, stride, divisor,

View File

@ -283,6 +283,31 @@ GeomVertexArrayDataHandle(CPT(GeomVertexArrayData) object,
#endif #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 #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. * Don't attempt to copy these objects.
*/ */

View File

@ -250,8 +250,12 @@ class EXPCL_PANDA_GOBJ GeomVertexArrayDataHandle : public ReferenceCount, public
private: private:
INLINE GeomVertexArrayDataHandle(CPT(GeomVertexArrayData) object, INLINE GeomVertexArrayDataHandle(CPT(GeomVertexArrayData) object,
Thread *current_thread); Thread *current_thread);
INLINE GeomVertexArrayDataHandle(const GeomVertexArrayData *object,
Thread *current_thread);
INLINE GeomVertexArrayDataHandle(PT(GeomVertexArrayData) object, INLINE GeomVertexArrayDataHandle(PT(GeomVertexArrayData) object,
Thread *current_thread); Thread *current_thread);
INLINE GeomVertexArrayDataHandle(GeomVertexArrayData *object,
Thread *current_thread);
INLINE GeomVertexArrayDataHandle(const GeomVertexArrayDataHandle &); INLINE GeomVertexArrayDataHandle(const GeomVertexArrayDataHandle &);
INLINE void operator = (const GeomVertexArrayDataHandle &); INLINE void operator = (const GeomVertexArrayDataHandle &);

View File

@ -1544,7 +1544,14 @@ INLINE size_t Texture::
get_ram_mipmap_image_size(int n) const { get_ram_mipmap_image_size(int n) const {
CDReader cdata(_cycler); CDReader cdata(_cycler);
if (n >= 0 && n < (int)cdata->_ram_images.size()) { 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; return 0;
} }

View File

@ -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(y >= 0 && y < tex_y_size, false);
nassertr(z >= 0 && z < tex_z_size, false); nassertr(z >= 0 && z < tex_z_size, false);
nassertr(image.get_x_size() + x < tex_x_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_y_size() + y <= tex_y_size, false);
// Flip y // Flip y
y = cdata->_y_size - (image.get_y_size() + y); y = cdata->_y_size - (image.get_y_size() + y);

View File

@ -59,6 +59,7 @@ DirectionalLight(const string &name) :
LightLensNode(name, new OrthographicLens()), LightLensNode(name, new OrthographicLens()),
_has_specular_color(false) _has_specular_color(false)
{ {
_lenses[0]._lens->set_interocular_distance(0);
} }
/** /**

View File

@ -66,21 +66,27 @@ PointLight(const string &name) :
{ {
PT(Lens) lens; PT(Lens) lens;
lens = new PerspectiveLens(90, 90); lens = new PerspectiveLens(90, 90);
lens->set_interocular_distance(0);
lens->set_view_vector(1, 0, 0, 0, -1, 0); lens->set_view_vector(1, 0, 0, 0, -1, 0);
set_lens(0, lens); set_lens(0, lens);
lens = new PerspectiveLens(90, 90); lens = new PerspectiveLens(90, 90);
lens->set_interocular_distance(0);
lens->set_view_vector(-1, 0, 0, 0, -1, 0); lens->set_view_vector(-1, 0, 0, 0, -1, 0);
set_lens(1, lens); set_lens(1, lens);
lens = new PerspectiveLens(90, 90); lens = new PerspectiveLens(90, 90);
lens->set_interocular_distance(0);
lens->set_view_vector(0, 1, 0, 0, 0, 1); lens->set_view_vector(0, 1, 0, 0, 0, 1);
set_lens(2, lens); set_lens(2, lens);
lens = new PerspectiveLens(90, 90); lens = new PerspectiveLens(90, 90);
lens->set_interocular_distance(0);
lens->set_view_vector(0, -1, 0, 0, 0, -1); lens->set_view_vector(0, -1, 0, 0, 0, -1);
set_lens(3, lens); set_lens(3, lens);
lens = new PerspectiveLens(90, 90); lens = new PerspectiveLens(90, 90);
lens->set_interocular_distance(0);
lens->set_view_vector(0, 0, 1, 0, -1, 0); lens->set_view_vector(0, 0, 1, 0, -1, 0);
set_lens(4, lens); set_lens(4, lens);
lens = new PerspectiveLens(90, 90); lens = new PerspectiveLens(90, 90);
lens->set_interocular_distance(0);
lens->set_view_vector(0, 0, -1, 0, -1, 0); lens->set_view_vector(0, 0, -1, 0, -1, 0);
set_lens(5, lens); set_lens(5, lens);
} }

View File

@ -68,6 +68,7 @@ Spotlight(const string &name) :
LightLensNode(name), LightLensNode(name),
_has_specular_color(false) _has_specular_color(false)
{ {
_lenses[0]._lens->set_interocular_distance(0);
} }
/** /**