Merge branch 'release/1.10.x'

This commit is contained in:
rdb 2022-06-29 19:09:59 +02:00
commit 20334cce05
11 changed files with 176 additions and 48 deletions

View File

@ -1187,6 +1187,18 @@ class Freezer:
else: else:
self.__loadModule(self.ModuleDef(modname, implicit = True)) self.__loadModule(self.ModuleDef(modname, implicit = True))
# Special case for sysconfig, which depends on a platform-specific
# sysconfigdata module on POSIX systems.
if 'sysconfig' in self.mf.modules:
if sys.version_info >= (3, 6):
if 'linux' in self.platform:
arch = self.platform.split('_', 1)[1]
self.__loadModule(self.ModuleDef('_sysconfigdata__linux_' + arch + '-linux-gnu', implicit=True))
elif 'mac' in self.platform:
self.__loadModule(self.ModuleDef('_sysconfigdata__darwin_darwin', implicit=True))
elif 'linux' in self.platform or 'mac' in self.platform:
self.__loadModule(self.ModuleDef('_sysconfigdata', implicit=True))
# Now, any new modules we found get added to the export list. # Now, any new modules we found get added to the export list.
for origName in list(self.mf.modules.keys()): for origName in list(self.mf.modules.keys()):
if origName not in origToNewName: if origName not in origToNewName:

View File

@ -44,14 +44,14 @@ class DirectObject:
def addTask(self, *args, **kwargs): def addTask(self, *args, **kwargs):
if not hasattr(self, "_taskList"): if not hasattr(self, "_taskList"):
self._taskList = {} self._taskList = {}
kwargs['owner']=self kwargs['owner'] = self
task = taskMgr.add(*args, **kwargs) task = taskMgr.add(*args, **kwargs)
return task return task
def doMethodLater(self, *args, **kwargs): def doMethodLater(self, *args, **kwargs):
if not hasattr(self, "_taskList"): if not hasattr(self, "_taskList"):
self._taskList = {} self._taskList = {}
kwargs['owner']=self kwargs['owner'] = self
task = taskMgr.doMethodLater(*args, **kwargs) task = taskMgr.doMethodLater(*args, **kwargs)
return task return task

View File

@ -800,6 +800,21 @@ if __debug__:
whl.write_file(target_path, source_path) whl.write_file(target_path, source_path)
# Include the special sysconfigdata module.
if os.name == 'posix':
import sysconfig
if hasattr(sysconfig, '_get_sysconfigdata_name'):
modname = sysconfig._get_sysconfigdata_name() + '.py'
else:
modname = '_sysconfigdata.py'
for entry in sys.path:
source_path = os.path.join(entry, modname)
if os.path.isfile(source_path):
whl.write_file('deploy_libs/' + modname, source_path)
break
# Add plug-ins. # Add plug-ins.
for lib in PLUGIN_LIBS: for lib in PLUGIN_LIBS:
plugin_name = 'lib' + lib plugin_name = 'lib' + lib

View File

@ -194,7 +194,7 @@ make_from_bam(const FactoryParams &params) {
void BulletConvexHullShape:: void BulletConvexHullShape::
fillin(DatagramIterator &scan, BamReader *manager) { fillin(DatagramIterator &scan, BamReader *manager) {
BulletShape::fillin(scan, manager); BulletShape::fillin(scan, manager);
nassertv(_shape == nullptr); nassertv(_shape);
_shape->setMargin(scan.get_stdfloat()); _shape->setMargin(scan.get_stdfloat());
unsigned int num_points = scan.get_uint32(); unsigned int num_points = scan.get_uint32();

View File

@ -21,6 +21,12 @@
#include <EGL/eglext.h> #include <EGL/eglext.h>
static ConfigVariableInt egl_device_index
("egl-device-index", -1,
PRC_DESC("Selects which EGL device index is used to create the EGL display in "
"a headless configuration. The special value -1 selects the default "
"device."));
TypeHandle eglGraphicsPipe::_type_handle; TypeHandle eglGraphicsPipe::_type_handle;
/** /**
@ -30,6 +36,8 @@ eglGraphicsPipe::
eglGraphicsPipe() { eglGraphicsPipe() {
// Check for client extensions. // Check for client extensions.
vector_string extensions; vector_string extensions;
bool supports_platform_device = false;
bool supports_device_enumeration = false;
const char *ext_ptr = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS); const char *ext_ptr = eglQueryString(EGL_NO_DISPLAY, EGL_EXTENSIONS);
if (ext_ptr != nullptr) { if (ext_ptr != nullptr) {
extract_words(ext_ptr, extensions); extract_words(ext_ptr, extensions);
@ -42,6 +50,13 @@ eglGraphicsPipe() {
out << " " << extension << "\n"; out << " " << extension << "\n";
} }
} }
if (std::find(extensions.begin(), extensions.end(), "EGL_EXT_platform_device") != extensions.end()) {
supports_platform_device = true;
}
if (std::find(extensions.begin(), extensions.end(), "EGL_EXT_device_enumeration") != extensions.end()) {
supports_device_enumeration = true;
}
} }
else if (egldisplay_cat.is_debug()) { else if (egldisplay_cat.is_debug()) {
eglGetError(); eglGetError();
@ -51,23 +66,10 @@ eglGraphicsPipe() {
EGLint major, minor; EGLint major, minor;
//NB. if the X11 display failed to open, _display will be 0, which is a valid int index = egl_device_index.get_value();
// input to eglGetDisplay - it means to open the default display. if (index >= 0 && supports_platform_device && supports_device_enumeration) {
#ifdef USE_X11 PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
_egl_display = eglGetDisplay((NativeDisplayType) _display); (PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
#else
_egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
#endif
if (_egl_display && !eglInitialize(_egl_display, &major, &minor)) {
egldisplay_cat.warning()
<< "Couldn't initialize the default EGL display: "
<< get_egl_error_string(eglGetError()) << "\n";
_egl_display = EGL_NO_DISPLAY;
}
if (!_egl_display &&
std::find(extensions.begin(), extensions.end(), "EGL_EXT_platform_device") != extensions.end() &&
std::find(extensions.begin(), extensions.end(), "EGL_EXT_device_enumeration") != extensions.end()) {
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT = PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress("eglQueryDevicesEXT"); (PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress("eglQueryDevicesEXT");
@ -79,23 +81,74 @@ eglGraphicsPipe() {
EGLDeviceEXT *devices = (EGLDeviceEXT *)alloca(sizeof(EGLDeviceEXT) * num_devices); EGLDeviceEXT *devices = (EGLDeviceEXT *)alloca(sizeof(EGLDeviceEXT) * num_devices);
eglQueryDevicesEXT(num_devices, devices, &num_devices); eglQueryDevicesEXT(num_devices, devices, &num_devices);
if (egldisplay_cat.is_debug()) { if (index >= num_devices) {
egldisplay_cat.debug() egldisplay_cat.error()
<< "Found " << num_devices << " EGL devices.\n"; << "Requested EGL device index " << index << " does not exist ("
<< "there are only " << num_devices << " devices)\n";
_is_valid = false;
return;
} }
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT = if (egldisplay_cat.is_debug()) {
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT"); egldisplay_cat.debug()
<< "Found " << num_devices << " EGL devices, using device index "
<< index << ".\n";
}
if (eglGetPlatformDisplayEXT != nullptr) { _egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, devices[index], nullptr);
for (EGLint i = 0; i < num_devices && !_egl_display; ++i) {
_egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, devices[i], nullptr);
if (_egl_display && !eglInitialize(_egl_display, &major, &minor)) { if (_egl_display && !eglInitialize(_egl_display, &major, &minor)) {
egldisplay_cat.warning() egldisplay_cat.error()
<< "Couldn't initialize EGL platform display " << i << ": " << "Couldn't initialize EGL platform display " << index << ": "
<< get_egl_error_string(eglGetError()) << "\n"; << get_egl_error_string(eglGetError()) << "\n";
_egl_display = EGL_NO_DISPLAY; _egl_display = EGL_NO_DISPLAY;
}
}
}
else {
//NB. if the X11 display failed to open, _display will be 0, which is a valid
// input to eglGetDisplay - it means to open the default display.
#ifdef USE_X11
_egl_display = eglGetDisplay((NativeDisplayType) _display);
#else
_egl_display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
#endif
if (_egl_display && !eglInitialize(_egl_display, &major, &minor)) {
egldisplay_cat.warning()
<< "Couldn't initialize the default EGL display: "
<< get_egl_error_string(eglGetError()) << "\n";
_egl_display = EGL_NO_DISPLAY;
}
if (!_egl_display && supports_platform_device && supports_device_enumeration) {
PFNEGLQUERYDEVICESEXTPROC eglQueryDevicesEXT =
(PFNEGLQUERYDEVICESEXTPROC)eglGetProcAddress("eglQueryDevicesEXT");
EGLint num_devices = 0;
if (eglQueryDevicesEXT != nullptr &&
eglQueryDevicesEXT(0, nullptr, &num_devices) &&
num_devices > 0) {
EGLDeviceEXT *devices = (EGLDeviceEXT *)alloca(sizeof(EGLDeviceEXT) * num_devices);
eglQueryDevicesEXT(num_devices, devices, &num_devices);
if (egldisplay_cat.is_debug()) {
egldisplay_cat.debug()
<< "Found " << num_devices << " EGL devices.\n";
}
PFNEGLGETPLATFORMDISPLAYEXTPROC eglGetPlatformDisplayEXT =
(PFNEGLGETPLATFORMDISPLAYEXTPROC)eglGetProcAddress("eglGetPlatformDisplayEXT");
if (eglGetPlatformDisplayEXT != nullptr) {
for (EGLint i = 0; i < num_devices && !_egl_display; ++i) {
_egl_display = eglGetPlatformDisplayEXT(EGL_PLATFORM_DEVICE_EXT, devices[i], nullptr);
if (_egl_display && !eglInitialize(_egl_display, &major, &minor)) {
egldisplay_cat.warning()
<< "Couldn't initialize EGL platform display " << i << ": "
<< get_egl_error_string(eglGetError()) << "\n";
_egl_display = EGL_NO_DISPLAY;
}
} }
} }
} }

View File

@ -208,10 +208,22 @@ set_owner(PyObject *owner) {
#ifndef NDEBUG #ifndef NDEBUG
if (owner != Py_None) { if (owner != Py_None) {
PyObject *add = PyObject_GetAttrString(owner, "_addTask"); PyObject *add = PyObject_GetAttrString(owner, "_addTask");
PyErr_Clear();
PyObject *clear = PyObject_GetAttrString(owner, "_clearTask"); PyObject *clear = PyObject_GetAttrString(owner, "_clearTask");
PyErr_Clear();
if (add == nullptr || !PyCallable_Check(add) || bool valid_add = false;
clear == nullptr || !PyCallable_Check(clear)) { if (add != nullptr) {
valid_add = PyCallable_Check(add);
Py_DECREF(add);
}
bool valid_clear = false;
if (clear != nullptr) {
valid_clear = PyCallable_Check(clear);
Py_DECREF(clear);
}
if (!valid_add || !valid_clear) {
Dtool_Raise_TypeError("owner object should have _addTask and _clearTask methods"); Dtool_Raise_TypeError("owner object should have _addTask and _clearTask methods");
return; return;
} }

View File

@ -10691,7 +10691,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
case Texture::F_rgba: case Texture::F_rgba:
case Texture::F_rgbm: case Texture::F_rgbm:
#ifndef OPENGLES_1 #ifndef OPENGLES_1
if (component_type == Texture::T_float) { if (component_type == Texture::T_float ||
component_type == Texture::T_half_float) {
return GL_RGBA16F; return GL_RGBA16F;
} else } else
#endif #endif
@ -10757,7 +10758,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
#endif // OPENGLES #endif // OPENGLES
#ifndef OPENGLES #ifndef OPENGLES
case Texture::F_rgba16: case Texture::F_rgba16:
if (component_type == Texture::T_float) { if (component_type == Texture::T_float ||
component_type == Texture::T_half_float) {
return GL_RGBA16F; return GL_RGBA16F;
} else if (Texture::is_unsigned(component_type)) { } else if (Texture::is_unsigned(component_type)) {
return GL_RGBA16; return GL_RGBA16;
@ -10777,6 +10779,7 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
case Texture::F_rgb: case Texture::F_rgb:
switch (component_type) { switch (component_type) {
case Texture::T_float: return GL_RGB16F; case Texture::T_float: return GL_RGB16F;
case Texture::T_half_float: return GL_RGB16F;
#ifndef OPENGLES #ifndef OPENGLES
case Texture::T_unsigned_short: return GL_RGB16; case Texture::T_unsigned_short: return GL_RGB16;
case Texture::T_short: return GL_RGB16_SNORM; case Texture::T_short: return GL_RGB16_SNORM;
@ -10813,7 +10816,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
case Texture::F_rgb12: case Texture::F_rgb12:
return GL_RGB12; return GL_RGB12;
case Texture::F_rgb16: case Texture::F_rgb16:
if (component_type == Texture::T_float) { if (component_type == Texture::T_float ||
component_type == Texture::T_half_float) {
return GL_RGB16F; return GL_RGB16F;
} else if (Texture::is_unsigned(component_type)) { } else if (Texture::is_unsigned(component_type)) {
return GL_RGB16; return GL_RGB16;
@ -10836,7 +10840,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
return GL_RG16F_EXT; return GL_RG16F_EXT;
#elif !defined(OPENGLES_1) #elif !defined(OPENGLES_1)
case Texture::F_r16: case Texture::F_r16:
if (component_type == Texture::T_float) { if (component_type == Texture::T_float ||
component_type == Texture::T_half_float) {
return GL_R16F; return GL_R16F;
} else if (Texture::is_unsigned(component_type)) { } else if (Texture::is_unsigned(component_type)) {
return GL_R16; return GL_R16;
@ -10844,7 +10849,8 @@ get_internal_image_format(Texture *tex, bool force_sized) const {
return GL_R16_SNORM; return GL_R16_SNORM;
} }
case Texture::F_rg16: case Texture::F_rg16:
if (component_type == Texture::T_float) { if (component_type == Texture::T_float ||
component_type == Texture::T_half_float) {
return GL_RG16F; return GL_RG16F;
} else if (Texture::is_unsigned(component_type)) { } else if (Texture::is_unsigned(component_type)) {
return GL_RG16; return GL_RG16;

View File

@ -66,12 +66,7 @@ make_ortho(FLOATTYPE fnear, FLOATTYPE ffar, FLOATTYPE l, FLOATTYPE r,
} }
/** /**
* Behaves like gluPerspective (Aspect = width/height, Yfov in degrees) aspect * Behaves like gluPerspective (Aspect = width/height, Yfov in degrees)
* +------------+ | | 1 | | yfov | |
* +------------+
*
* -------+------ \ | \ | \ | \ | \ | \| W yfov
*
*/ */
INLINE_MATHUTIL void FLOATNAME(LFrustum):: INLINE_MATHUTIL void FLOATNAME(LFrustum)::
make_perspective_hfov(FLOATTYPE hfov, FLOATTYPE aspect, FLOATTYPE fnear, make_perspective_hfov(FLOATTYPE hfov, FLOATTYPE aspect, FLOATTYPE fnear,
@ -84,7 +79,9 @@ make_perspective_hfov(FLOATTYPE hfov, FLOATTYPE aspect, FLOATTYPE fnear,
_b = -_t; _b = -_t;
} }
/**
*
*/
INLINE_MATHUTIL void FLOATNAME(LFrustum):: INLINE_MATHUTIL void FLOATNAME(LFrustum)::
make_perspective_vfov(FLOATTYPE yfov, FLOATTYPE aspect, FLOATTYPE fnear, make_perspective_vfov(FLOATTYPE yfov, FLOATTYPE aspect, FLOATTYPE fnear,
FLOATTYPE ffar) { FLOATTYPE ffar) {
@ -96,7 +93,9 @@ make_perspective_vfov(FLOATTYPE yfov, FLOATTYPE aspect, FLOATTYPE fnear,
_l = -_r; _l = -_r;
} }
/**
*
*/
INLINE_MATHUTIL void FLOATNAME(LFrustum):: INLINE_MATHUTIL void FLOATNAME(LFrustum)::
make_perspective(FLOATTYPE xfov, FLOATTYPE yfov, FLOATTYPE fnear, make_perspective(FLOATTYPE xfov, FLOATTYPE yfov, FLOATTYPE fnear,
FLOATTYPE ffar) { FLOATTYPE ffar) {

View File

@ -89,6 +89,15 @@ end_frame(FrameMode mode, Thread *current_thread) {
} }
} }
/**
*
*/
void TinyGraphicsBuffer::
set_size(int x, int y) {
GraphicsBuffer::set_size(x, y);
create_frame_buffer();
}
/** /**
* Closes the buffer right now. Called from the buffer thread. * Closes the buffer right now. Called from the buffer thread.
*/ */

View File

@ -35,6 +35,8 @@ public:
virtual bool begin_frame(FrameMode mode, Thread *current_thread); virtual bool begin_frame(FrameMode mode, Thread *current_thread);
virtual void end_frame(FrameMode mode, Thread *current_thread); virtual void end_frame(FrameMode mode, Thread *current_thread);
virtual void set_size(int x, int y);
INLINE ZBuffer *get_frame_buffer(); INLINE ZBuffer *get_frame_buffer();
protected: protected:

View File

@ -133,6 +133,26 @@ def test_sphere_shape():
assert shape.radius == shape2.radius assert shape.radius == shape2.radius
def test_convex_shape():
shape = bullet.BulletConvexHullShape()
shape.add_array([
(-1.0, -1.0, -1.0),
(1.0, -1.0, -1.0),
(-1.0, 1.0, -1.0),
(-1.0, -1.0, 1.0),
(1.0, 1.0, -1.0),
(1.0, -1.0, 1.0),
(-1.0, 1.0, 1.0),
(1.0, 1.0, 1.0),
])
shape.margin = 0.5
shape2 = reconstruct(shape)
assert type(shape) is type(shape2)
assert shape.margin == shape2.margin
def test_ghost(): def test_ghost():
node = bullet.BulletGhostNode("some ghost node") node = bullet.BulletGhostNode("some ghost node")