Browse Source

Merge branch 'release/1.10.x'

rdb 1 year ago
parent
commit
9145b6c729

+ 4 - 2
direct/src/dist/commands.py

@@ -471,8 +471,10 @@ class build_apps(setuptools.Command):
         if self.bam_model_extensions:
             for ext in self.bam_model_extensions:
                 ext = '.' + ext.lstrip('.')
-                assert ext not in self.file_handlers, \
-                    'Extension {} occurs in both file_handlers and bam_model_extensions!'.format(ext)
+                handler = self.file_handlers.get(ext)
+                if handler != _model_to_bam:
+                    assert handler is None, \
+                        'Extension {} occurs in both file_handlers and bam_model_extensions!'.format(ext)
                 self.file_handlers[ext] = _model_to_bam
 
         tmp = self.default_file_handlers.copy()

+ 5 - 0
panda/src/bullet/bulletContactCallbacks.h

@@ -88,7 +88,12 @@ contact_added_callback(btManifoldPoint &cp,
       BulletManifoldPoint mp(cp);
       BulletContactCallbackData cbdata(mp, node0, node1, id0, id1, index0, index1);
 
+      // Release the world mutex object so that bullet methods can be called from the callback.
+      LightMutex &mutex = BulletWorld::get_global_lock();
+
+      mutex.release();
       bullet_contact_added_callback->do_callback(&cbdata);
+      mutex.acquire();
     }
   }
 

+ 1 - 1
panda/src/device/inputDeviceNode.cxx

@@ -69,7 +69,7 @@ do_transmit_data(DataGraphTraverser *, const DataNodeTransmit &,
       const ButtonEvent &event = bel->get_event(i);
       if (event._type == ButtonEvent::T_down) {
         _button_states[event._button] = true;
-      } else if (event._type == ButtonEvent::T_down) {
+      } else if (event._type == ButtonEvent::T_up) {
         _button_states[event._button] = false;
       }
     }

+ 3 - 2
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -3178,7 +3178,7 @@ reset() {
   _max_image_units = 0;
 #ifndef OPENGLES_1
 #ifdef OPENGLES
-  if (is_at_least_gl_version(3, 1)) {
+  if (is_at_least_gles_version(3, 1) && gl_immutable_texture_storage) {
 #else
   if (is_at_least_gl_version(4, 2) || has_extension("GL_ARB_shader_image_load_store")) {
 #endif
@@ -14284,7 +14284,8 @@ upload_texture_image(CLP(TextureContext) *gtc, int view, bool needs_reload,
         GLCAT.debug()
           << "allocating storage for texture " << tex->get_name() << ", "
           << width << " x " << height << " x " << depth << ", mipmaps "
-          << num_levels << "\n";
+          << num_levels << ", internal_format = 0x" << std::hex
+          << internal_format << std::dec << "\n";
       }
 
       switch (texture_type) {

+ 40 - 8
panda/src/glstuff/glShaderContext_src.cxx

@@ -1708,17 +1708,35 @@ reflect_uniform(int i, char *name_buffer, GLsizei name_buflen) {
       case GL_UNSIGNED_INT_IMAGE_BUFFER:
         // This won't really change at runtime, so we might as well bind once
         // and then forget about it.
-        // Note that OpenGL ES doesn't support changing this at runtime, so we
-        // rely on the shader using a layout declaration.
-#ifndef OPENGLES
-        _glgsg->_glUniform1i(p, _glsl_img_inputs.size());
-#endif
         {
+#ifdef OPENGLES
+          // In OpenGL ES, we can't choose our own binding, but we can ask the
+          // driver what it assigned (or what the shader specified).
+          GLint binding = 0;
+          glGetUniformiv(_glsl_program, p, &binding);
+          if (GLCAT.is_debug()) {
+            GLCAT.debug()
+              << "Active uniform " << param_name
+              << " is bound to image unit " << binding << "\n";
+          }
+
+          if (binding >= _glsl_img_inputs.size()) {
+            _glsl_img_inputs.resize(binding + 1);
+          }
+
+          ImageInput &input = _glsl_img_inputs[binding];
+          input._name = InternalName::make(param_name);
+#else
+          if (GLCAT.is_debug()) {
+            GLCAT.debug()
+              << "Binding image uniform " << param_name
+              << " to image unit " << _glsl_img_inputs.size() << "\n";
+          }
+          _glgsg->_glUniform1i(p, _glsl_img_inputs.size());
           ImageInput input;
           input._name = InternalName::make(param_name);
-          input._writable = false;
-          input._gtc = nullptr;
-          _glsl_img_inputs.push_back(input);
+          _glsl_img_inputs.push_back(std::move(input));
+#endif
         }
         return;
       default:
@@ -2676,6 +2694,10 @@ update_shader_texture_bindings(ShaderContext *prev) {
       const ParamTextureImage *param = nullptr;
       Texture *tex;
 
+      if (input._name == nullptr) {
+        continue;
+      }
+
       const ShaderInput &sinp = _glgsg->_target_shader->get_shader_input(input._name);
       switch (sinp.get_value_type()) {
       case ShaderInput::M_texture_image:
@@ -2729,6 +2751,16 @@ update_shader_texture_bindings(ShaderContext *prev) {
         // TODO: automatically convert to sized type instead of plain GL_RGBA
         // If a base type is used, it will crash.
         GLenum internal_format = gtc->_internal_format;
+#ifdef OPENGLES
+        if (!gtc->_immutable) {
+          static bool error_shown = false;
+          if (!error_shown) {
+            error_shown = true;
+            GLCAT.error()
+              << "Enable gl-immutable-texture-storage to use image textures in OpenGL ES.\n";
+          }
+        }
+#endif
         if (internal_format == GL_RGBA || internal_format == GL_RGB) {
           GLCAT.error()
             << "Texture " << tex->get_name() << " has an unsized format.  Textures bound "

+ 2 - 2
panda/src/glstuff/glShaderContext_src.h

@@ -107,8 +107,8 @@ private:
 
   struct ImageInput {
     CPT(InternalName) _name;
-    CLP(TextureContext) *_gtc;
-    bool _writable;
+    CLP(TextureContext) *_gtc = nullptr;
+    bool _writable = false;
   };
   pvector<ImageInput> _glsl_img_inputs;
 

+ 5 - 0
panda/src/grutil/meshDrawer.cxx

@@ -416,6 +416,11 @@ void MeshDrawer::geometry(NodePath draw_node) {
 /**
  * Stars or continues linked segment.  Control position, frame, thickness and
  * color with parameters.  Frame contains u,v,u-size,v-size quadruple.
+ * Note that for the first two calls to this method, the "frame" parameter is
+ * ignored; it first takes effect as of the third call.
+ * Similarly, note that in the second call to this method, the "color" parameter
+ * is ignored; it only has effect in the first call and calls from the third
+ * onwards.
  */
 void MeshDrawer::
 link_segment(const LVector3 &pos, const LVector4 &frame,

+ 2 - 1
panda/src/pgraph/lensNode.cxx

@@ -119,7 +119,8 @@ set_lens_active(int index, bool flag) {
 
 /**
  * Returns true if the given point is within the bounds of the lens of the
- * LensNode (i.e.  if the camera can see the point).
+ * LensNode (i.e.  if the camera can see the point).  The point is assumed to
+ * be relative to the LensNode itself.
  */
 bool LensNode::
 is_in_view(int index, const LPoint3 &pos) {

+ 2 - 4
panda/src/recorder/mouseRecorder.cxx

@@ -228,11 +228,9 @@ make_from_bam(const FactoryParams &params) {
 RecorderBase *MouseRecorder::
 make_recorder(const FactoryParams &params) {
   MouseRecorder *node = new MouseRecorder("");
-  DatagramIterator scan;
-  BamReader *manager;
+  BamReaderParam *param = DCAST(BamReaderParam, params.get_param(0));
 
-  parse_params(params, scan, manager);
-  node->fillin_recorder(scan, manager);
+  node->fillin_recorder((DatagramIterator &)param->get_iterator(), param->get_manager());
 
   return node;
 }

+ 2 - 4
panda/src/recorder/socketStreamRecorder.cxx

@@ -113,11 +113,9 @@ write_recorder(BamWriter *manager, Datagram &dg) {
 RecorderBase *SocketStreamRecorder::
 make_recorder(const FactoryParams &params) {
   SocketStreamRecorder *node = new SocketStreamRecorder;
-  DatagramIterator scan;
-  BamReader *manager;
+  BamReaderParam *param = DCAST(BamReaderParam, params.get_param(0));
 
-  parse_params(params, scan, manager);
-  node->fillin_recorder(scan, manager);
+  node->fillin_recorder((DatagramIterator &)param->get_iterator(), param->get_manager());
 
   return node;
 }

+ 8 - 8
panda/src/windisplay/winGraphicsWindow.cxx

@@ -676,18 +676,18 @@ initialize_input_devices() {
   _input = device;
 
   // Get the number of devices.
-  if (GetRawInputDeviceList(nullptr, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) {
+  if ((int)GetRawInputDeviceList(nullptr, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) != 0) {
     return;
   }
 
   // Allocate the array to hold the DeviceList
   pRawInputDeviceList = (PRAWINPUTDEVICELIST)alloca(sizeof(RAWINPUTDEVICELIST) * nInputDevices);
-  if (pRawInputDeviceList==0) {
+  if (pRawInputDeviceList == nullptr) {
     return;
   }
 
   // Fill the Array
-  if (GetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1) {
+  if ((int)GetRawInputDeviceList(pRawInputDeviceList, &nInputDevices, sizeof(RAWINPUTDEVICELIST)) == -1) {
     return;
   }
 
@@ -696,13 +696,13 @@ initialize_input_devices() {
     if (pRawInputDeviceList[i].dwType == RIM_TYPEMOUSE) {
       // Fetch information about specified mouse device.
       UINT nSize;
-      if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)0, &nSize) != 0) {
-        return;
+      if ((int)GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)nullptr, &nSize) != 0) {
+        continue;
       }
       char *psName = (char*)alloca(sizeof(TCHAR) * nSize);
-      if (psName == 0) return;
-      if (GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0) {
-        return;
+      if (psName == nullptr) continue;
+      if ((int)GetRawInputDeviceInfoA(pRawInputDeviceList[i].hDevice, RIDI_DEVICENAME, (LPVOID)psName, &nSize) < 0) {
+        continue;
       }
 
       // If it's not an RDP mouse, add it to the list of raw mice.

+ 1 - 1
pandatool/src/egg-palettize/txaFileFilter.cxx

@@ -92,7 +92,7 @@ post_load(Texture *tex) {
   egg_tex->set_alpha_mode(tex_image.get_alpha_mode());
   egg_tex->set_format(props._format);
   egg_tex->set_minfilter(props._minfilter);
-  egg_tex->set_minfilter(props._magfilter);
+  egg_tex->set_magfilter(props._magfilter);
   egg_tex->set_anisotropic_degree(props._anisotropic_degree);
 
   tex->set_aux_data("egg", egg_tex);

+ 2 - 2
tests/display/test_cg_shader.py

@@ -18,14 +18,14 @@ def run_cg_compile_check(gsg, shader_path, expect_fail=False):
         assert shader is not None
 
 
[email protected](platform.machine().lower() == 'arm64', reason="Cg not supported on arm64")
[email protected](platform.machine().lower() in ('arm64', 'aarch64'), reason="Cg not supported on arm64")
 def test_cg_compile_error(gsg):
     """Test getting compile errors from bad Cg shaders"""
     shader_path = core.Filename(SHADERS_DIR, 'cg_bad.sha')
     run_cg_compile_check(gsg, shader_path, expect_fail=True)
 
 
[email protected](platform.machine().lower() == 'arm64', reason="Cg not supported on arm64")
[email protected](platform.machine().lower() in ('arm64', 'aarch64'), reason="Cg not supported on arm64")
 def test_cg_from_file(gsg):
     """Test compiling Cg shaders from files"""
     shader_path = core.Filename(SHADERS_DIR, 'cg_simple.sha')