Bläddra i källkod

Merge branch 'master' into shaderpipeline

rdb 2 år sedan
förälder
incheckning
b5584b4cf8
100 ändrade filer med 841 tillägg och 626 borttagningar
  1. 1 1
      README.md
  2. 5 1
      direct/src/directnotify/Notifier.py
  3. 8 4
      direct/src/showbase/ShowBase.py
  4. 76 59
      dtool/src/dtoolbase/dtoolbase.h
  5. 3 7
      dtool/src/dtoolbase/typeHandle.h
  6. 5 11
      dtool/src/dtoolutil/filename.h
  7. 19 19
      dtool/src/dtoolutil/textEncoder.h
  8. 1 3
      dtool/src/prc/configVariable.h
  9. 3 3
      dtool/src/prc/pnotify.h
  10. 3 5
      dtool/src/prc/streamReader.h
  11. 1 3
      dtool/src/prc/streamWriter.h
  12. 2 0
      makepanda/makepanda.py
  13. 64 55
      panda/src/cocoadisplay/cocoaGraphicsWindow.mm
  14. 2 2
      panda/src/collide/collisionHandlerEvent.h
  15. 2 2
      panda/src/collide/collisionHandlerPhysical.h
  16. 1 1
      panda/src/collide/collisionHandlerQueue.h
  17. 2 2
      panda/src/collide/collisionPolygon.h
  18. 2 2
      panda/src/collide/collisionTraverser.h
  19. 2 4
      panda/src/display/frameBufferProperties.h
  20. 1 3
      panda/src/display/graphicsPipeSelection.h
  21. 47 0
      panda/src/display/graphicsStateGuardian.cxx
  22. 1 3
      panda/src/display/graphicsStateGuardian.h
  23. 1 3
      panda/src/display/graphicsWindow.h
  24. 3 7
      panda/src/display/windowProperties.h
  25. 10 10
      panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx
  26. 1 1
      panda/src/egg/eggComment.h
  27. 1 1
      panda/src/egg/eggCoordinateSystem.h
  28. 2 2
      panda/src/egg/eggGroupNode.h
  29. 1 1
      panda/src/egg/eggNode.h
  30. 6 14
      panda/src/event/asyncFuture.h
  31. 3 5
      panda/src/express/datagram.h
  32. 3 3
      panda/src/express/memoryUsagePointers.h
  33. 2 4
      panda/src/express/multifile.h
  34. 14 24
      panda/src/express/pointerToArray.h
  35. 6 10
      panda/src/express/ramfile.h
  36. 4 8
      panda/src/express/stringStream.h
  37. 2 6
      panda/src/express/virtualFile.h
  38. 2 6
      panda/src/express/virtualFileSystem.h
  39. 28 14
      panda/src/glstuff/glGraphicsStateGuardian_src.cxx
  40. 9 0
      panda/src/glstuff/glShaderContext_src.cxx
  41. 9 13
      panda/src/gobj/geomVertexArrayData.h
  42. 2 4
      panda/src/gobj/internalName.h
  43. 36 0
      panda/src/gobj/shader.cxx
  44. 8 0
      panda/src/gobj/shader.h
  45. 3 0
      panda/src/gobj/texture.cxx
  46. 5 4
      panda/src/gobj/texture.h
  47. 2 4
      panda/src/gobj/textureCollection.h
  48. 3 5
      panda/src/gobj/texturePool.h
  49. 1 3
      panda/src/linmath/lmatrix3_src.h
  50. 1 3
      panda/src/linmath/lmatrix4_src.h
  51. 2 4
      panda/src/linmath/lpoint2_src.h
  52. 2 4
      panda/src/linmath/lpoint3_src.h
  53. 2 4
      panda/src/linmath/lpoint4_src.h
  54. 12 18
      panda/src/linmath/lvecBase2_src.h
  55. 12 18
      panda/src/linmath/lvecBase3_src.h
  56. 12 18
      panda/src/linmath/lvecBase4_src.h
  57. 2 4
      panda/src/linmath/lvector2_src.h
  58. 2 4
      panda/src/linmath/lvector3_src.h
  59. 2 4
      panda/src/linmath/lvector4_src.h
  60. 5 5
      panda/src/ode/odeBody.h
  61. 3 3
      panda/src/ode/odeGeom.h
  62. 2 2
      panda/src/ode/odeJoint.h
  63. 5 5
      panda/src/ode/odeSpace.h
  64. 3 3
      panda/src/ode/odeUtil.h
  65. 4 8
      panda/src/pgraph/loaderFileTypeRegistry.h
  66. 22 30
      panda/src/pgraph/nodePath.h
  67. 3 7
      panda/src/pgraph/nodePathCollection.h
  68. 10 14
      panda/src/pgraph/pandaNode.h
  69. 5 9
      panda/src/pgraph/renderState.h
  70. 2 4
      panda/src/pgraph/shaderAttrib.h
  71. 1 3
      panda/src/pgraph/shaderInput.h
  72. 4 8
      panda/src/pgraph/transformState.h
  73. 73 14
      panda/src/pgraphnodes/shaderGenerator.cxx
  74. 1 0
      panda/src/pgraphnodes/shaderGenerator.h
  75. 2 4
      panda/src/pipeline/pmutex.h
  76. 2 4
      panda/src/pipeline/reMutex.h
  77. 12 0
      panda/src/pipeline/thread.cxx
  78. 1 0
      panda/src/pipeline/thread.h
  79. 2 4
      panda/src/pnmimage/pfmFile.h
  80. 9 0
      panda/src/pnmimage/pnmImage.cxx
  81. 57 4
      panda/src/pstatclient/pStatClient.cxx
  82. 1 0
      panda/src/pstatclient/pStatClient.h
  83. 25 7
      panda/src/pstatclient/pStatClientImpl.cxx
  84. 2 0
      panda/src/pstatclient/pStatClientImpl.h
  85. 13 7
      panda/src/pstatclient/pStatFrameData.cxx
  86. 1 1
      panda/src/pstatclient/pStatProperties.cxx
  87. 3 9
      panda/src/putil/bamReader.h
  88. 13 6
      panda/src/putil/bitArray.I
  89. 3 3
      panda/src/putil/bitArray.cxx
  90. 5 8
      panda/src/putil/bitArray.h
  91. 2 4
      panda/src/putil/bitMask.h
  92. 1 3
      panda/src/putil/callbackObject.h
  93. 3 7
      panda/src/putil/doubleBitMask.h
  94. 2 4
      panda/src/putil/sparseArray.h
  95. 2 4
      panda/src/putil/typedWritable.h
  96. 9 1
      panda/src/testbed/pview.cxx
  97. 5 6
      panda/src/x11display/x11GraphicsWindow.cxx
  98. 37 2
      pandatool/src/deploy-stub/deploy-stub.c
  99. 2 0
      pandatool/src/gtk-stats/gtkStatsChartMenu.h
  100. 17 0
      pandatool/src/gtk-stats/gtkStatsMonitor.cxx

+ 1 - 1
README.md

@@ -24,7 +24,7 @@ Installing Panda3D
 ==================
 
 The latest Panda3D SDK can be downloaded from
-[this page](https://www.panda3d.org/download/sdk-1-10-12/).
+[this page](https://www.panda3d.org/download/sdk-1-10-13/).
 If you are familiar with installing Python packages, you can use
 the following command:
 

+ 5 - 1
direct/src/directnotify/Notifier.py

@@ -9,6 +9,10 @@ import time
 import sys
 
 
+class NotifierException(Exception):
+    pass
+
+
 class Notifier:
     serverDelta = 0
 
@@ -116,7 +120,7 @@ class Notifier:
             return NSError
 
     # error funcs
-    def error(self, errorString, exception=Exception):
+    def error(self, errorString, exception=NotifierException):
         """
         Raise an exception with given string and optional type:
         Exception: error

+ 8 - 4
direct/src/showbase/ShowBase.py

@@ -487,11 +487,15 @@ class ShowBase(DirectObject.DirectObject):
             DGG.setDefaultClickSound(self.loader.loadSfx("audio/sfx/GUI_click.wav"))
             DGG.setDefaultRolloverSound(self.loader.loadSfx("audio/sfx/GUI_rollover.wav"))
 
+        # Create a private DirectObject - allowing base.accept for window-event
+        # as well as allowing ShowBase's default handling of this.
+        self.__directObject = DirectObject.DirectObject()
+
         # Now hang a hook on the window-event from Panda.  This allows
         # us to detect when the user resizes, minimizes, or closes the
         # main window.
         self.__prevWindowProperties = None
-        self.accept('window-event', self.windowEvent)
+        self.__directObject.accept('window-event', self.windowEvent)
 
         # Transition effects (fade, iris, etc)
         from . import Transitions
@@ -2579,9 +2583,9 @@ class ShowBase(DirectObject.DirectObject):
             self.oobeVis.setLightOff(1)
             self.oobeCullFrustum = None
 
-            self.accept('oobe-down', self.__oobeButton, extraArgs = [''])
-            self.accept('oobe-repeat', self.__oobeButton, extraArgs = ['-repeat'])
-            self.accept('oobe-up', self.__oobeButton, extraArgs = ['-up'])
+            self.__directObject.accept('oobe-down', self.__oobeButton, extraArgs = [''])
+            self.__directObject.accept('oobe-repeat', self.__oobeButton, extraArgs = ['-repeat'])
+            self.__directObject.accept('oobe-up', self.__oobeButton, extraArgs = ['-up'])
 
         if self.oobeMode:
             # Disable OOBE mode.

+ 76 - 59
dtool/src/dtoolbase/dtoolbase.h

@@ -53,16 +53,16 @@
 #ifdef _WIN32
 #ifndef NOMINMAX
 #define NOMINMAX
-#endif
-#endif
+#endif // !NOMINMAX
+#endif // _WIN32
 
 #ifndef __has_builtin
 #define __has_builtin(x) 0
-#endif
+#endif // !__has_builtin
 
 #ifndef __has_attribute
 #define __has_attribute(x) 0
-#endif
+#endif // !__has_attribute
 
 // Use NODEFAULT to optimize a switch() stmt to tell MSVC to automatically go
 // to the final untested case after it has failed all the other cases (i.e.
@@ -73,30 +73,30 @@
 #define NODEFAULT  default: __builtin_unreachable();
 #elif defined(_MSC_VER)
 #define NODEFAULT  default: __assume(0);   // special VC keyword
-#else
+#else // NODEFAULT
 #define NODEFAULT
-#endif
+#endif // NODEFAULT
 
 // Use this to hint the compiler that a memory address is aligned.
 #if __has_builtin(__builtin_assume_aligned) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 7)
 #define ASSUME_ALIGNED(x, y) (__builtin_assume_aligned(x, y))
-#else
+#else // ASSUME_ALIGNED
 #define ASSUME_ALIGNED(x, y) (x)
-#endif
+#endif // ASSUME_ALIGNED
 
 #if __has_attribute(assume_aligned) || __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 9)
 #define RETURNS_ALIGNED(x) __attribute__((assume_aligned(x)))
-#else
+#else // RETURNS_ALIGNED
 #define RETURNS_ALIGNED(x)
-#endif
+#endif // RETURNS_ALIGNED
 
 #ifdef __GNUC__
 #define LIKELY(x) __builtin_expect(!!(x), 1)
 #define UNLIKELY(x) __builtin_expect(!!(x), 0)
-#else
+#else // LIKELY/UNLIKELY
 #define LIKELY(x) (x)
 #define UNLIKELY(x) (x)
-#endif
+#endif // LIKELY/UNLIKELY
 
 /*
   include win32 defns for everything up to WinServer2003, and assume
@@ -105,17 +105,17 @@
 */
 #ifdef _WIN32_WINNT
 #undef _WIN32_WINNT
-#endif
+#endif // _WIN32_WINNT
 #define _WIN32_WINNT 0x0600
 
 #ifdef __cplusplus
 #ifndef __STDC_LIMIT_MACROS
 #define __STDC_LIMIT_MACROS
-#endif
+#endif // !__STDC_LIMIT_MACROS
 #ifndef __STDC_CONSTANT_MACROS
 #define __STDC_CONSTANT_MACROS
-#endif
-#endif
+#endif // !__STDC_CONSTANT_MACROS
+#endif // __cplusplus
 
 // This is a workaround for a glibc bug that is triggered by clang when
 // compiling with -ffast-math.
@@ -123,8 +123,8 @@
 #include <sys/cdefs.h>
 #ifndef __extern_always_inline
 #define __extern_always_inline extern __always_inline
-#endif
-#endif
+#endif // !__extern_always_inline
+#endif // __clang__ && __GLIBC__
 
 // Instead of including the Python headers, which will implicitly add a linker
 // flag to link in Python, we'll just excerpt the forward declaration of
@@ -134,7 +134,7 @@ typedef struct _object PyObject;
 #ifndef HAVE_EIGEN
 // If we don't have the Eigen library, don't define LINMATH_ALIGN.
 #undef LINMATH_ALIGN
-#endif
+#endif // !HAVE_EIGEN
 
 #include "dtoolsymbols.h"
 
@@ -146,73 +146,75 @@ typedef struct _object PyObject;
 // headers
 #define _FILE_OFFSET_BITS 64
 #define _LARGEFILE_SOURCE 1
-#endif
+#endif // __GNUC__
 
 #ifdef PHAVE_TYPES_H
 #include <types.h>
-#endif
+#endif // PHAVE_TYPES_H
 
 #ifdef PHAVE_SYS_TYPES_H
 #include <sys/types.h>
-#endif
+#endif // PHAVE_SYS_TYPES_H
 
 #ifdef PHAVE_MALLOC_H
 #include <malloc.h>
-#endif
+#endif // PHAVE_MALLOC_H
 
 #ifdef PHAVE_SYS_MALLOC_H
 #include <sys/malloc.h>
-#endif
+#endif // PHAVE_SYS_MALLOC_H
 
 #ifdef PHAVE_ALLOCA_H
 #include <alloca.h>
-#endif
+#endif // PHAVE_ALLOCA_H
 
 #ifdef PHAVE_UNISTD_H
 #include <unistd.h>
-#endif
+#endif // PHAVE_UNISTD_H
 
 #ifdef PHAVE_IO_H
 #include <io.h>
-#endif
+#endif // PHAVE_IO_H
 
 #ifdef PHAVE_LOCALE_H
 #include <locale.h>
-#endif
+#endif // PHAVE_LOCALE_H
 
 #ifdef PHAVE_STRING_H
 #include <string.h>
-#endif
+#endif // PHAVE_STRING_H
 
 #ifdef PHAVE_STDLIB_H
 #include <stdlib.h>
-#endif
+#endif // PHAVE_STDLIB_H
 
 #ifdef PHAVE_LIMITS_H
 #include <limits.h>
-#endif
+#endif // PHAVE_LIMITS_H
 
 #ifdef PHAVE_SYS_TIME_H
 #include <sys/time.h>
-#endif
+#endif // PHAVE_SYS_TIME_H
 
 #ifdef PHAVE_STDINT_H
 #include <stdint.h>
-#endif
+#endif // PHAVE_STDINT_H
 
 #ifdef CPPPARSER
 #include <stdtypedefs.h>
 
+#ifdef HAVE_PYTHON
 // Also pick up the forward declaration of PyObject.
 #include <Python.h>
-#endif
+#endif // HAVE_PYTHON
+#endif // CPPPARSER
 
 #ifdef USE_TAU
 /* If we're building with the Tau instrumentor, include the
    appropriate header file to pick up the TAU macros. */
 #include <TAU.h>
 #include <Profile/Profiler.h>
-#else
+#else // USE_TAU
 /* Otherwise, if we're not building with the Tau instrumentor, turn
    off all the TAU macros.  We could include the Tau header file to do
    this, but it's better not to assume that Tau is installed. */
@@ -324,7 +326,7 @@ typedef struct _object PyObject;
 #undef WORDS_BIGENDIAN
 #define WORDS_BIGENDIAN 1
 
-#endif
+#endif // WORDS_BIGENDIAN
 
 /* Try to determine if we're compiling in a 64-bit mode. */
 
@@ -332,9 +334,9 @@ typedef struct _object PyObject;
 #define NATIVE_WORDSIZE __WORDSIZE
 #elif defined(_LP64) || defined(_WIN64)
 #define NATIVE_WORDSIZE 64
-#else
+#else // __WORDSIZE
 #define NATIVE_WORDSIZE 32
-#endif
+#endif // __WORDSIZE
 
 /* Some byte-alignment macros. */
 #ifdef CPPPARSER
@@ -355,13 +357,13 @@ typedef struct _object PyObject;
 #define ALIGN_16BYTE __attribute__ ((aligned (16)))
 #define ALIGN_32BYTE __attribute__ ((aligned (32)))
 #define ALIGN_64BYTE __attribute__ ((aligned (64)))
-#else
+#else // ALIGN_*
 #define ALIGN_4BYTE
 #define ALIGN_8BYTE
 #define ALIGN_16BYTE
 #define ALIGN_32BYTE
 #define ALIGN_64BYTE
-#endif
+#endif // ALIGN_*
 
 // Do we need to implement memory-alignment enforcement within the MemoryHook
 // class, or will the underlying malloc implementation provide it
@@ -398,13 +400,13 @@ typedef struct _object PyObject;
 #elif defined(MEMORY_HOOK_DO_ALIGN)
 // We need memory alignment, and we're willing to provide it ourselves.
 
-#else
+#else // malloc alignment
 // We need memory alignment, and we haven't specified whether it should be
 // provided on top of the existing malloc library, or otherwise.  Let's rely
 // on dlmalloc to provide it, it seems to be the most memory-efficient option.
 #define USE_MEMORY_DLMALLOC 1
 
-#endif
+#endif // malloc alignment
 
 #ifdef LINMATH_ALIGN
 /* We require 16-byte alignment of certain structures, to support SSE2.  We
@@ -413,37 +415,37 @@ typedef struct _object PyObject;
 /* Eigen uses AVX instructions, but let's only enable this when compiling with
    double precision, so that we can keep our ABI a bit more stable. */
 #define MEMORY_HOOK_ALIGNMENT 32
-#else
+#else // HAVE_EIGEN alignment
 #define MEMORY_HOOK_ALIGNMENT 16
-#endif
+#endif // HAVE_EIGEN alignment
 /* Otherwise, align to two words.  This seems to be pretty standard to the
    point where some code may rely on this being the case. */
 #elif defined(IS_OSX) || NATIVE_WORDSIZE >= 64
 #define MEMORY_HOOK_ALIGNMENT 16
-#else
+#else // memory alignment
 #define MEMORY_HOOK_ALIGNMENT 8
-#endif
+#endif // memory alignment
 
 #ifdef HAVE_EIGEN
 /* Make sure that Eigen doesn't assume alignment guarantees we don't offer. */
 #define EIGEN_MAX_ALIGN_BYTES MEMORY_HOOK_ALIGNMENT
 #ifndef EIGEN_MPL2_ONLY
 #define EIGEN_MPL2_ONLY 1
-#endif
+#endif // !EIGEN_MPL2_ONLY
 #if !defined(_DEBUG) && !defined(EIGEN_NO_DEBUG)
 #define EIGEN_NO_DEBUG 1
-#endif
-#endif
+#endif // !_DEBUG && !EIGEN_NO_DEBUG
+#endif // HAVE_EIGEN
 
 /* Determine our memory-allocation requirements. */
 #if defined(USE_MEMORY_MIMALLOC) || defined(USE_MEMORY_PTMALLOC2) || defined(USE_MEMORY_DLMALLOC) || defined(DO_MEMORY_USAGE) || defined(MEMORY_HOOK_DO_ALIGN)
 /* In this case we have some custom memory management requirements. */
-#else
+#else // memory allocation wrappers
 /* Otherwise, if we have no custom memory management needs at all, we
    might as well turn it all off and go straight to the OS-level
    calls. */
 #define USE_MEMORY_NOWRAPPERS 1
-#endif
+#endif // memory allocation wrappers
 
 /* We must always use the STL allocator nowadays, because we have
    redefined the constructors for pvector, pmap, etc. */
@@ -468,7 +470,18 @@ typedef struct _object PyObject;
 #define MAKE_MAP_KEYS_SEQ(property_name, ...) __make_map_keys_seq(property_name, __VA_ARGS__)
 #define EXTENSION(x) __extension x
 #define EXTEND __extension
-#else
+#ifdef HAVE_PYTHON
+#define PY_EXTENSION(x) __extension x
+#define PY_EXTEND(...) __extension __VA_ARGS__
+#define PY_MAKE_PROPERTY(property_name, ...) __make_property(property_name, __VA_ARGS__)
+#define PY_MAKE_SEQ_PROPERTY(property_name, ...) __make_seq_property(property_name, __VA_ARGS__)
+#else // HAVE_PYTHON
+#define PY_EXTENSION(x)
+#define PY_EXTEND(...)
+#define PY_MAKE_PROPERTY(property_name, ...)
+#define PY_MAKE_SEQ_PROPERTY(property_name, ...)
+#endif // HAVE_PYTHON
+#else // CPPPARSER
 #define BEGIN_PUBLISH
 #define END_PUBLISH
 #define BLOCKING
@@ -480,7 +493,11 @@ typedef struct _object PyObject;
 #define MAKE_MAP_KEYS_SEQ(property_name, ...)
 #define EXTENSION(x)
 #define EXTEND
-#endif
+#define PY_EXTENSION(x)
+#define PY_EXTEND(...)
+#define PY_MAKE_PROPERTY(property_name, ...)
+#define PY_MAKE_SEQ_PROPERTY(property_name, ...)
+#endif // CPPPARSER
 
 /* These symbols are used in dtoolsymbols.h and pandasymbols.h. */
 #if defined(_WIN32) && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC)
@@ -489,10 +506,10 @@ typedef struct _object PyObject;
 #elif __GNUC__ >= 4 && !defined(CPPPARSER) && !defined(LINK_ALL_STATIC)
 #define EXPORT_CLASS __attribute__((visibility("default")))
 #define IMPORT_CLASS
-#else
+#else // IMPORT/EXPORT
 #define EXPORT_CLASS
 #define IMPORT_CLASS
-#endif
+#endif // IMPORT/EXPORT
 
 /* "extern template" is now part of the C++11 standard. */
 #if defined(CPPPARSER) || defined(LINK_ALL_STATIC)
@@ -507,13 +524,13 @@ typedef struct _object PyObject;
    duplicate template instantiations that this causes. */
 #define EXPORT_TEMPL
 #define IMPORT_TEMPL extern
-#else
+#else // IMPORT/EXPORT template
 #define EXPORT_TEMPL extern
 #define IMPORT_TEMPL extern
-#endif
+#endif // IMPORT/EXPORT template
 
 #ifdef __cplusplus
 #include "dtoolbase_cc.h"
-#endif
+#endif // __cplusplus
 
-#endif
+#endif // !DTOOLBASE_H

+ 3 - 7
dtool/src/dtoolbase/typeHandle.h

@@ -97,9 +97,7 @@ PUBLISHED:
   // its value, it  might happen after the value had already been set
   // previously by another static initializer!
 
-#ifdef HAVE_PYTHON
-  EXTENSION(static TypeHandle make(PyTypeObject *classobj));
-#endif
+  PY_EXTENSION(static TypeHandle make(PyTypeObject *classobj));
 
   INLINE bool operator == (const TypeHandle &other) const;
   INLINE bool operator != (const TypeHandle &other) const;
@@ -137,10 +135,8 @@ PUBLISHED:
   MAKE_SEQ_PROPERTY(parent_classes, get_num_parent_classes, get_parent_class);
   MAKE_SEQ_PROPERTY(child_classes, get_num_child_classes, get_child_class);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__reduce__() const);
-  EXTENSION(void __setstate__(PyObject *));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__reduce__() const);
+  PY_EXTENSION(void __setstate__(PyObject *));
 
 public:
 #ifdef HAVE_PYTHON

+ 5 - 11
dtool/src/dtoolutil/filename.h

@@ -66,11 +66,9 @@ PUBLISHED:
   INLINE Filename();
   explicit Filename(const Filename &dirname, const Filename &basename);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(Filename(PyObject *path));
+  PY_EXTENSION(Filename(PyObject *path));
 
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
   // Static constructors to explicitly create a filename that refers to a text
   // or binary file.  This is in lieu of calling set_text() or set_binary() or
@@ -114,10 +112,8 @@ PUBLISHED:
   INLINE size_t length() const;
   INLINE char operator [] (size_t n) const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__repr__() const);
-  EXTENSION(PyObject *__fspath__() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__repr__() const);
+  PY_EXTENSION(PyObject *__fspath__() const);
 
   INLINE std::string substr(size_t begin) const;
   INLINE std::string substr(size_t begin, size_t end) const;
@@ -202,9 +198,7 @@ PUBLISHED:
   int find_on_searchpath(const DSearchPath &searchpath);
 
   bool scan_directory(vector_string &contents) const;
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *scan_directory() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *scan_directory() const);
 
   bool open_read(std::ifstream &stream) const;
   bool open_write(std::ofstream &stream, bool truncate = true) const;

+ 19 - 19
dtool/src/dtoolutil/textEncoder.h

@@ -54,28 +54,28 @@ PUBLISHED:
   INLINE static Encoding get_default_encoding();
   MAKE_PROPERTY(default_encoding, get_default_encoding, set_default_encoding);
 
-#if defined(CPPPARSER) && defined(HAVE_PYTHON)
-  EXTEND void set_text(PyObject *text);
-  EXTEND void set_text(PyObject *text, Encoding encoding);
-#else // CPPPARSER && HAVE_PYTHON
+#if defined(CPPPARSER)
+  PY_EXTEND(void set_text(PyObject *text));
+  PY_EXTEND(void set_text(PyObject *text, Encoding encoding));
+#else // CPPPARSER
   INLINE void set_text(const std::string &text);
   INLINE void set_text(const std::string &text, Encoding encoding);
-#endif // CPPPARSER && HAVE_PYTHON
+#endif // CPPPARSER
   INLINE void clear_text();
   INLINE bool has_text() const;
 
   void make_upper();
   void make_lower();
 
-#if defined(CPPPARSER) && defined(HAVE_PYTHON)
-  EXTEND PyObject *get_text() const;
-  EXTEND PyObject *get_text(Encoding encoding) const;
-  EXTEND void append_text(PyObject *text);
-#else // CPPPARSER && HAVE_PYTHON
+#if defined(CPPPARSER)
+  PY_EXTEND(PyObject *get_text() const);
+  PY_EXTEND(PyObject *get_text(Encoding encoding) const);
+  PY_EXTEND(void append_text(PyObject *text));
+#else // CPPPARSER
   INLINE std::string get_text() const;
   INLINE std::string get_text(Encoding encoding) const;
   INLINE void append_text(const std::string &text);
-#endif // CPPPARSER && HAVE_PYTHON
+#endif // CPPPARSER
   INLINE void append_unicode_char(char32_t character);
   INLINE size_t get_num_chars() const;
   INLINE int get_unicode_char(size_t index) const;
@@ -108,19 +108,19 @@ PUBLISHED:
   std::wstring get_wtext_as_ascii() const;
   bool is_wtext() const;
 
-#if defined(CPPPARSER) && defined(HAVE_PYTHON)
-  EXTEND static PyObject *encode_wchar(char32_t ch, Encoding encoding);
-  EXTEND INLINE PyObject *encode_wtext(const std::wstring &wtext) const;
-  EXTEND static PyObject *encode_wtext(const std::wstring &wtext, Encoding encoding);
-  EXTEND INLINE PyObject *decode_text(PyObject *text) const;
-  EXTEND static PyObject *decode_text(PyObject *text, Encoding encoding);
-#else // CPPPARSER && HAVE_PYTHON
+#if defined(CPPPARSER)
+  PY_EXTEND(static PyObject *encode_wchar(char32_t ch, Encoding encoding));
+  PY_EXTEND(INLINE PyObject *encode_wtext(const std::wstring &wtext) const);
+  PY_EXTEND(static PyObject *encode_wtext(const std::wstring &wtext, Encoding encoding));
+  PY_EXTEND(INLINE PyObject *decode_text(PyObject *text) const);
+  PY_EXTEND(static PyObject *decode_text(PyObject *text, Encoding encoding));
+#else // CPPPARSER
   static std::string encode_wchar(char32_t ch, Encoding encoding);
   INLINE std::string encode_wtext(const std::wstring &wtext) const;
   static std::string encode_wtext(const std::wstring &wtext, Encoding encoding);
   INLINE std::wstring decode_text(const std::string &text) const;
   static std::wstring decode_text(const std::string &text, Encoding encoding);
-#endif // CPPPARSER && HAVE_PYTHON
+#endif // CPPPARSER
 
   MAKE_PROPERTY(text, get_text, set_text);
 

+ 1 - 3
dtool/src/prc/configVariable.h

@@ -44,9 +44,7 @@ PUBLISHED:
 
   INLINE size_t get_num_words() const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
 protected:
   INLINE const ConfigDeclaration *get_default_value() const;

+ 3 - 3
dtool/src/prc/pnotify.h

@@ -36,10 +36,10 @@ PUBLISHED:
   ~Notify();
 
 #if defined(CPPPARSER) && defined(HAVE_PYTHON)
-  EXTEND void set_ostream_ptr(PyObject *ostream_ptr, bool delete_later);
-#else
+  PY_EXTEND(void set_ostream_ptr(PyObject *ostream_ptr, bool delete_later));
+#else // CPPPARSER && HAVE_PYTHON
   void set_ostream_ptr(std::ostream *ostream_ptr, bool delete_later);
-#endif
+#endif // CPPPARSER && HAVE_PYTHON
   std::ostream *get_ostream_ptr() const;
 
   typedef bool AssertHandler(const char *expression, int line,

+ 3 - 5
dtool/src/prc/streamReader.h

@@ -68,12 +68,10 @@ PUBLISHED:
 
   BLOCKING void skip_bytes(size_t size);
   BLOCKING size_t extract_bytes(unsigned char *into, size_t size);
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *extract_bytes(size_t size));
+  PY_EXTENSION(PyObject *extract_bytes(size_t size));
 
-  EXTENSION(PyObject *readline());
-  EXTENSION(PyObject *readlines());
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *readline());
+  PY_EXTENSION(PyObject *readlines());
 public:
   BLOCKING vector_uchar extract_bytes(size_t size);
   BLOCKING std::string readline();

+ 1 - 3
dtool/src/prc/streamWriter.h

@@ -70,9 +70,7 @@ PUBLISHED:
   BLOCKING INLINE void add_fixed_string(const std::string &str, size_t size);
 
   BLOCKING void pad_bytes(size_t size);
-#ifdef HAVE_PYTHON
-  EXTENSION(void append_data(PyObject *data));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(void append_data(PyObject *data));
 
   BLOCKING INLINE void flush();
 

+ 2 - 0
makepanda/makepanda.py

@@ -6169,6 +6169,8 @@ if PkgSkip("PYTHON") == 0:
         LibName('DEPLOYSTUB', "-Wl,--disable-new-dtags,-rpath,\\$ORIGIN")
         LibName('DEPLOYSTUB', "-Wl,-z,origin")
         LibName('DEPLOYSTUB', "-rdynamic")
+    elif GetTarget() == 'darwin':
+        LibName('DEPLOYSTUB', "-Wl,-sectcreate,__PANDA,__panda,/dev/null")
 
     PyTargetAdd('deploy-stub.exe', input='deploy-stub.obj')
     if GetTarget() == 'windows':

+ 64 - 55
panda/src/cocoadisplay/cocoaGraphicsWindow.mm

@@ -814,7 +814,12 @@ set_properties_now(WindowProperties &properties) {
           if (switched) {
             if (_window != nil) {
               // For some reason, setting the style mask makes it give up its
-              // first-responder status.
+              // first-responder status.  And for some reason, we need to first
+              // restore the window to normal level before we switch fullscreen,
+              // otherwise we may get a black bar if we're currently on Z_top.
+              if (_properties.get_z_order() != WindowProperties::Z_normal) {
+                [_window setLevel: NSNormalWindowLevel];
+              }
               if ([_window respondsToSelector:@selector(setStyleMask:)]) {
                 [_window setStyleMask:NSBorderlessWindowMask];
               }
@@ -847,8 +852,12 @@ set_properties_now(WindowProperties &properties) {
         _properties.set_fullscreen(false);
 
         // Force properties to be reset to their actual values
-        properties.set_undecorated(_properties.get_undecorated());
-        properties.set_z_order(_properties.get_z_order());
+        if (!properties.has_undecorated()) {
+          properties.set_undecorated(_properties.get_undecorated());
+        }
+        if (!properties.has_z_order()) {
+          properties.set_z_order(_properties.get_z_order());
+        }
         properties.clear_fullscreen();
       }
     }
@@ -865,6 +874,58 @@ set_properties_now(WindowProperties &properties) {
     properties.clear_minimized();
   }
 
+  if (properties.has_title() && _window != nil) {
+    _properties.set_title(properties.get_title());
+    [_window setTitle:[NSString stringWithUTF8String:properties.get_title().c_str()]];
+    properties.clear_title();
+  }
+
+  if (properties.has_fixed_size() && _window != nil) {
+    _properties.set_fixed_size(properties.get_fixed_size());
+    [_window setShowsResizeIndicator:!properties.get_fixed_size()];
+
+    if (!_properties.get_fullscreen()) {
+      // If our window is decorated, change the style mask to show or hide the
+      // resize button appropriately.  However, if we're specifying the
+      // 'undecorated' property also, then we'll be setting the style mask
+      // about 25 LOC further down, so we won't need to bother setting it
+      // here.
+      if (!properties.has_undecorated() && !_properties.get_undecorated() &&
+          [_window respondsToSelector:@selector(setStyleMask:)]) {
+        if (properties.get_fixed_size()) {
+          [_window setStyleMask:NSTitledWindowMask | NSClosableWindowMask |
+                                NSMiniaturizableWindowMask ];
+        } else {
+          [_window setStyleMask:NSTitledWindowMask | NSClosableWindowMask |
+                                NSMiniaturizableWindowMask | NSResizableWindowMask ];
+        }
+        [_window makeFirstResponder:_view];
+      }
+    }
+
+    properties.clear_fixed_size();
+  }
+
+  if (properties.has_undecorated() && _window != nil && [_window respondsToSelector:@selector(setStyleMask:)]) {
+    _properties.set_undecorated(properties.get_undecorated());
+
+    if (!_properties.get_fullscreen()) {
+      if (properties.get_undecorated()) {
+        [_window setStyleMask: NSBorderlessWindowMask];
+      } else if (_properties.get_fixed_size()) {
+        // Fixed size windows should not show the resize button.
+        [_window setStyleMask: NSTitledWindowMask | NSClosableWindowMask |
+                               NSMiniaturizableWindowMask ];
+      } else {
+        [_window setStyleMask: NSTitledWindowMask | NSClosableWindowMask |
+                               NSMiniaturizableWindowMask | NSResizableWindowMask ];
+      }
+      [_window makeFirstResponder:_view];
+    }
+
+    properties.clear_undecorated();
+  }
+
   if (properties.has_size()) {
     int width = properties.get_x_size();
     int height = properties.get_y_size();
@@ -978,58 +1039,6 @@ set_properties_now(WindowProperties &properties) {
     properties.clear_maximized();
   }
 
-  if (properties.has_title() && _window != nil) {
-    _properties.set_title(properties.get_title());
-    [_window setTitle:[NSString stringWithUTF8String:properties.get_title().c_str()]];
-    properties.clear_title();
-  }
-
-  if (properties.has_fixed_size() && _window != nil) {
-    _properties.set_fixed_size(properties.get_fixed_size());
-    [_window setShowsResizeIndicator:!properties.get_fixed_size()];
-
-    if (!_properties.get_fullscreen()) {
-      // If our window is decorated, change the style mask to show or hide the
-      // resize button appropriately.  However, if we're specifying the
-      // 'undecorated' property also, then we'll be setting the style mask
-      // about 25 LOC further down, so we won't need to bother setting it
-      // here.
-      if (!properties.has_undecorated() && !_properties.get_undecorated() &&
-          [_window respondsToSelector:@selector(setStyleMask:)]) {
-        if (properties.get_fixed_size()) {
-          [_window setStyleMask:NSTitledWindowMask | NSClosableWindowMask |
-                                NSMiniaturizableWindowMask ];
-        } else {
-          [_window setStyleMask:NSTitledWindowMask | NSClosableWindowMask |
-                                NSMiniaturizableWindowMask | NSResizableWindowMask ];
-        }
-        [_window makeFirstResponder:_view];
-      }
-    }
-
-    properties.clear_fixed_size();
-  }
-
-  if (properties.has_undecorated() && _window != nil && [_window respondsToSelector:@selector(setStyleMask:)]) {
-    _properties.set_undecorated(properties.get_undecorated());
-
-    if (!_properties.get_fullscreen()) {
-      if (properties.get_undecorated()) {
-        [_window setStyleMask: NSBorderlessWindowMask];
-      } else if (_properties.get_fixed_size()) {
-        // Fixed size windows should not show the resize button.
-        [_window setStyleMask: NSTitledWindowMask | NSClosableWindowMask |
-                               NSMiniaturizableWindowMask ];
-      } else {
-        [_window setStyleMask: NSTitledWindowMask | NSClosableWindowMask |
-                               NSMiniaturizableWindowMask | NSResizableWindowMask ];
-      }
-      [_window makeFirstResponder:_view];
-    }
-
-    properties.clear_undecorated();
-  }
-
   if (properties.has_foreground() && !_properties.get_fullscreen() && _window != nil) {
     _properties.set_foreground(properties.get_foreground());
     if (!_properties.get_minimized()) {

+ 2 - 2
panda/src/collide/collisionHandlerEvent.h

@@ -69,8 +69,8 @@ PUBLISHED:
   void flush();
 
   // These help implement Python pickle support.
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-  EXTENSION(void __setstate__(PyObject *self, vector_uchar data));
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(void __setstate__(PyObject *self, vector_uchar data));
 
   virtual void write_datagram(Datagram &destination) const;
   virtual void read_datagram(DatagramIterator &source);

+ 2 - 2
panda/src/collide/collisionHandlerPhysical.h

@@ -54,8 +54,8 @@ PUBLISHED:
 PUBLISHED:
   MAKE_PROPERTY2(center, has_center, get_center, set_center, clear_center);
 
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-  EXTENSION(void __setstate__(PyObject *self, vector_uchar data, PyObject *nodepaths));
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(void __setstate__(PyObject *self, vector_uchar data, PyObject *nodepaths));
 
 protected:
   bool _has_contact; // Are we in contact with anything?

+ 1 - 1
panda/src/collide/collisionHandlerQueue.h

@@ -46,7 +46,7 @@ PUBLISHED:
   void output(std::ostream &out) const;
   void write(std::ostream &out, int indent_level = 0) const;
 
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
 private:
   typedef pvector< PT(CollisionEntry) > Entries;

+ 2 - 2
panda/src/collide/collisionPolygon.h

@@ -59,8 +59,8 @@ PUBLISHED:
   bool is_valid() const;
   bool is_concave() const;
 
-  EXTENSION(static bool verify_points(PyObject *points));
-  EXTENSION(void setup_points(PyObject *points));
+  PY_EXTENSION(static bool verify_points(PyObject *points));
+  PY_EXTENSION(void setup_points(PyObject *points));
 
 PUBLISHED:
   MAKE_SEQ_PROPERTY(points, get_num_points, get_point);

+ 2 - 2
panda/src/collide/collisionTraverser.h

@@ -80,8 +80,8 @@ PUBLISHED:
   void output(std::ostream &out) const;
   void write(std::ostream &out, int indent_level) const;
 
-  EXTENSION(PyObject *__getstate__() const);
-  EXTENSION(void __setstate__(PyObject *state));
+  PY_EXTENSION(PyObject *__getstate__() const);
+  PY_EXTENSION(void __setstate__(PyObject *state));
 
 private:
   typedef pvector<CollisionLevelStateSingle> LevelStatesSingle;

+ 2 - 4
panda/src/display/frameBufferProperties.h

@@ -144,10 +144,8 @@ PUBLISHED:
   MAKE_PROPERTY(float_color, get_float_color, set_float_color);
   MAKE_PROPERTY(float_depth, get_float_depth, set_float_depth);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__getstate__() const);
-  EXTENSION(void __setstate__(PyObject *self, PyObject *state));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__getstate__() const);
+  PY_EXTENSION(void __setstate__(PyObject *self, PyObject *state));
 
   // Other.
 

+ 1 - 3
panda/src/display/graphicsPipeSelection.h

@@ -52,9 +52,7 @@ PUBLISHED:
 
   INLINE static GraphicsPipeSelection *get_global_ptr();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__reduce__() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__reduce__() const);
 
 public:
   typedef PT(GraphicsPipe) PipeConstructorFunc();

+ 47 - 0
panda/src/display/graphicsStateGuardian.cxx

@@ -57,6 +57,7 @@
 #include "colorScaleAttrib.h"
 #include "clipPlaneAttrib.h"
 #include "fogAttrib.h"
+#include "renderModeAttrib.h"
 #include "config_pstatclient.h"
 
 #include <limits.h>
@@ -1255,6 +1256,25 @@ fetch_specified_part(Shader::ShaderMatInput part, const InternalName *name,
     }
     return;
   }
+  case Shader::SMO_texconst_i: {
+    const TexGenAttrib *tga;
+    const TextureAttrib *ta;
+
+    int num_stages = 0;
+    if (_target_rs->get_attrib(ta) && _target_rs->get_attrib(tga)) {
+      num_stages = std::min(count, (int)ta->get_num_on_stages());
+    }
+
+    int i = 0;
+    for (; i < num_stages; ++i) {
+      LVecBase3 value = tga->get_constant_value(ta->get_on_stage(i));
+      into[i].set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, value[0], value[1], value[2], 1);
+    }
+    for (; i < count; ++i) {
+      into[i] = LMatrix4::ident_mat();
+    }
+    return;
+  }
   case Shader::SMO_tex_is_alpha_i: {
     // This is a hack so we can support both F_alpha and other formats in the
     // default shader, to fix font rendering in GLES2
@@ -1616,6 +1636,33 @@ fetch_specified_part(Shader::ShaderMatInput part, const InternalName *name,
     }
     return;
   }
+  case Shader::SMO_attr_pointparams: {
+    const RenderModeAttrib *target_render_mode;
+    _target_rs->get_attrib_def(target_render_mode);
+
+    PN_stdfloat thickness = target_render_mode->get_thickness();
+    PN_stdfloat catten = thickness;
+    PN_stdfloat patten = 0.0f;
+    if (target_render_mode->get_perspective()) {
+      LVecBase2i pixel_size = _current_display_region->get_pixel_size();
+
+      LVector3 height(0.0f, thickness, 1.0f);
+      height = height * _projection_mat->get_mat();
+      height = height * _internal_transform->get_scale()[1];
+      PN_stdfloat s = height[1] * pixel_size[1];
+
+      if (_current_lens->is_orthographic()) {
+        catten = s;
+        patten = 0.0f;
+      } else {
+        catten = 0.0f;
+        patten = s;
+      }
+    }
+
+    into[0].set(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, thickness, catten, patten, 0.0f);
+    return;
+  }
   default:
     nassertv(false /*should never get here*/);
     return;

+ 1 - 3
panda/src/display/graphicsStateGuardian.h

@@ -256,9 +256,7 @@ PUBLISHED:
   MAKE_PROPERTY(texture_quality_override, get_texture_quality_override,
                                           set_texture_quality_override);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_prepared_textures() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_prepared_textures() const);
   typedef bool TextureCallback(TextureContext *tc, void *callback_arg);
   void traverse_prepared_textures(TextureCallback *func, void *callback_arg);
 

+ 1 - 3
panda/src/display/graphicsWindow.h

@@ -56,9 +56,7 @@ PUBLISHED:
   void clear_rejected_properties();
   WindowProperties get_rejected_properties() const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(void request_properties(PyObject *args, PyObject *kwds));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(void request_properties(PyObject *args, PyObject *kwds));
 
   INLINE bool is_closed() const;
   virtual bool is_active() const;

+ 3 - 7
panda/src/display/windowProperties.h

@@ -44,9 +44,7 @@ PUBLISHED:
     M_confined,
   };
 
-#ifdef HAVE_PYTHON
-  EXTENSION(WindowProperties(PyObject *self, PyObject *args, PyObject *kwds));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(WindowProperties(PyObject *self, PyObject *args, PyObject *kwds));
 
 PUBLISHED:
   void operator = (const WindowProperties &copy);
@@ -207,10 +205,8 @@ PUBLISHED:
   MAKE_PROPERTY2(parent_window, has_parent_window, get_parent_window,
                                 set_parent_window, clear_parent_window);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__getstate__(PyObject *self) const);
-  EXTENSION(void __setstate__(PyObject *self, PyObject *state));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__getstate__(PyObject *self) const);
+  PY_EXTENSION(void __setstate__(PyObject *self, PyObject *state));
 
   void add_properties(const WindowProperties &other);
 

+ 10 - 10
panda/src/dxgsg9/dxGraphicsStateGuardian9.cxx

@@ -3160,6 +3160,7 @@ set_state_and_transform(const RenderState *target,
   }
   _target_rs = target;
 
+  int shader_deps = 0;
   determine_target_shader();
 
   int alpha_test_slot = AlphaTestAttrib::get_class_slot();
@@ -3189,10 +3190,7 @@ set_state_and_transform(const RenderState *target,
     do_issue_color_scale();
     _state_mask.set_bit(color_slot);
     _state_mask.set_bit(color_scale_slot);
-    if (_current_shader_context) {
-      _current_shader_context->issue_parameters(this, Shader::SSD_color);
-      _current_shader_context->issue_parameters(this, Shader::SSD_colorscale);
-    }
+    shader_deps |= Shader::SSD_color | Shader::SSD_colorscale;
   }
 
   int cull_face_slot = CullFaceAttrib::get_class_slot();
@@ -3233,6 +3231,7 @@ set_state_and_transform(const RenderState *target,
     // PStatTimer timer(_draw_set_state_render_mode_pcollector);
     do_issue_render_mode();
     _state_mask.set_bit(render_mode_slot);
+    shader_deps |= Shader::SSD_render_mode;
   }
 
   int rescale_normal_slot = RescaleNormalAttrib::get_class_slot();
@@ -3296,6 +3295,7 @@ set_state_and_transform(const RenderState *target,
     _state_mask.set_bit(texture_slot);
     _state_mask.set_bit(tex_matrix_slot);
     _state_mask.set_bit(tex_gen_slot);
+    shader_deps |= Shader::SSD_tex_matrix | Shader::SSD_tex_gen;
   }
 
   int material_slot = MaterialAttrib::get_class_slot();
@@ -3304,9 +3304,7 @@ set_state_and_transform(const RenderState *target,
     // PStatTimer timer(_draw_set_state_material_pcollector);
     do_issue_material();
     _state_mask.set_bit(material_slot);
-    if (_current_shader_context) {
-      _current_shader_context->issue_parameters(this, Shader::SSD_material);
-    }
+    shader_deps |= Shader::SSD_material;
   }
 
   int light_slot = LightAttrib::get_class_slot();
@@ -3331,9 +3329,7 @@ set_state_and_transform(const RenderState *target,
     // PStatTimer timer(_draw_set_state_fog_pcollector);
     do_issue_fog();
     _state_mask.set_bit(fog_slot);
-    if (_current_shader_context) {
-      _current_shader_context->issue_parameters(this, Shader::SSD_fog);
-    }
+    shader_deps |= Shader::SSD_fog;
   }
 
   int scissor_slot = ScissorAttrib::get_class_slot();
@@ -3344,6 +3340,10 @@ set_state_and_transform(const RenderState *target,
     _state_mask.set_bit(scissor_slot);
   }
 
+  if (_current_shader_context != nullptr && shader_deps != 0) {
+    _current_shader_context->issue_parameters(this, shader_deps);
+  }
+
   _state_rs = _target_rs;
 }
 

+ 1 - 1
panda/src/egg/eggComment.h

@@ -41,7 +41,7 @@ PUBLISHED:
 
   virtual void write(std::ostream &out, int indent_level) const;
 
-  EXTENSION(PyObject *__reduce__() const);
+  PY_EXTENSION(PyObject *__reduce__() const);
 
 private:
   std::string _comment;

+ 1 - 1
panda/src/egg/eggCoordinateSystem.h

@@ -36,7 +36,7 @@ PUBLISHED:
 
   virtual void write(std::ostream &out, int indent_level) const;
 
-  EXTENSION(PyObject *__reduce__() const);
+  PY_EXTENSION(PyObject *__reduce__() const);
 
 private:
   CoordinateSystem _value;

+ 2 - 2
panda/src/egg/eggGroupNode.h

@@ -108,8 +108,8 @@ PUBLISHED:
   EggNode *get_first_child();
   EggNode *get_next_child();
 
-  EXTENSION(PyObject *get_children() const);
-  MAKE_PROPERTY(children, get_children);
+  PY_EXTENSION(PyObject *get_children() const);
+  PY_MAKE_PROPERTY(children, get_children);
 
   EggNode *add_child(EggNode *node);
   PT(EggNode) remove_child(EggNode *node);

+ 1 - 1
panda/src/egg/eggNode.h

@@ -93,7 +93,7 @@ PUBLISHED:
   void test_under_integrity() const { }
 #endif  // _DEBUG
 
-  EXTENSION(PyObject *__reduce__() const);
+  PY_EXTENSION(PyObject *__reduce__() const);
 
 protected:
   enum UnderFlags {

+ 6 - 14
panda/src/event/asyncFuture.h

@@ -62,16 +62,12 @@ PUBLISHED:
   INLINE AsyncFuture();
   virtual ~AsyncFuture();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(static PyObject *__await__(PyObject *self));
-  EXTENSION(static PyObject *__iter__(PyObject *self));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(static PyObject *__await__(PyObject *self));
+  PY_EXTENSION(static PyObject *__iter__(PyObject *self));
 
   INLINE bool done() const;
   INLINE bool cancelled() const;
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *result(PyObject *self, PyObject *timeout = Py_None) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *result(PyObject *self, PyObject *timeout = Py_None) const);
 
   virtual bool cancel();
 
@@ -79,11 +75,9 @@ PUBLISHED:
   INLINE const std::string &get_done_event() const;
   MAKE_PROPERTY(done_event, get_done_event, set_done_event);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *add_done_callback(PyObject *self, PyObject *fn));
+  PY_EXTENSION(PyObject *add_done_callback(PyObject *self, PyObject *fn));
 
-  EXTENSION(static PyObject *gather(PyObject *args));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(static PyObject *gather(PyObject *args));
   INLINE static PT(AsyncFuture) shield(PT(AsyncFuture) future);
 
   virtual void output(std::ostream &out) const;
@@ -91,9 +85,7 @@ PUBLISHED:
   BLOCKING void wait();
   BLOCKING void wait(double timeout);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(void set_result(PyObject *));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(void set_result(PyObject *));
 public:
   INLINE void set_result(std::nullptr_t);
   INLINE void set_result(TypedReferenceCount *result);

+ 3 - 5
panda/src/express/datagram.h

@@ -95,11 +95,9 @@ public:
   INLINE const void *get_data() const;
 
 PUBLISHED:
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE PyObject *get_message() const);
-  EXTENSION(INLINE PyObject *__bytes__() const);
-  EXTENSION(PyObject *__reduce__() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE PyObject *get_message() const);
+  PY_EXTENSION(INLINE PyObject *__bytes__() const);
+  PY_EXTENSION(PyObject *__reduce__() const);
 
   INLINE size_t get_length() const;
 

+ 3 - 3
panda/src/express/memoryUsagePointers.h

@@ -50,9 +50,9 @@ PUBLISHED:
   std::string get_type_name(size_t n) const;
   double get_age(size_t n) const;
 
-#if defined(DO_MEMORY_USAGE) && defined(HAVE_PYTHON)
-  EXTENSION(PyObject *get_python_pointer(size_t n) const);
-#endif // DO_MEMORY_USAGE && HAVE_PYTHON
+#if defined(DO_MEMORY_USAGE)
+  PY_EXTENSION(PyObject *get_python_pointer(size_t n) const);
+#endif // DO_MEMORY_USAGE
 
   void clear();
 

+ 2 - 4
panda/src/express/multifile.h

@@ -84,10 +84,8 @@ PUBLISHED:
   std::string update_subfile(const std::string &subfile_name, const Filename &filename,
                         int compression_level);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE PyObject *set_encryption_password(PyObject *encryption_password) const);
-  EXTENSION(INLINE PyObject *get_encryption_password() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE PyObject *set_encryption_password(PyObject *encryption_password) const);
+  PY_EXTENSION(INLINE PyObject *get_encryption_password() const);
 
 #ifdef HAVE_OPENSSL
   bool add_signature(const Filename &certificate,

+ 14 - 24
panda/src/express/pointerToArray.h

@@ -96,9 +96,7 @@ PUBLISHED:
   INLINE static PointerToArray<Element> empty_array(size_type n, TypeHandle type_handle = get_type_handle(Element));
   INLINE PointerToArray(const PointerToArray<Element> &copy);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PointerToArray(PyObject *self, PyObject *source));
-#endif // HAVE_PYTHON */
+  PY_EXTENSION(PointerToArray(PyObject *self, PyObject *source));
 
   INLINE void clear();
 
@@ -109,25 +107,21 @@ PUBLISHED:
   INLINE void set_element(size_type n, const Element &value);
   EXTENSION(const Element &__getitem__(size_type n) const);
   EXTENSION(void __setitem__(size_type n, const Element &value));
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_data() const);
-  EXTENSION(void set_data(PyObject *data));
-  EXTENSION(PyObject *get_subdata(size_type n, size_type count) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_data() const);
+  PY_EXTENSION(void set_data(PyObject *data));
+  PY_EXTENSION(PyObject *get_subdata(size_type n, size_type count) const);
   INLINE void set_subdata(size_type n, size_type count, const std::string &data);
   INLINE int get_ref_count() const;
   INLINE int get_node_ref_count() const;
 
   INLINE size_t count(const Element &) const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
-  EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags));
-  EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const);
+  PY_EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags));
+  PY_EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const);
 
-  EXTENSION(PointerToArray<Element> __deepcopy__(PyObject *memo) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PointerToArray<Element> __deepcopy__(PyObject *memo) const);
 
 #else  // CPPPARSER
   // This is the actual, complete interface.
@@ -273,23 +267,19 @@ PUBLISHED:
   INLINE size_type size() const;
   INLINE const Element &get_element(size_type n) const;
   EXTENSION(const Element &__getitem__(size_type n) const);
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_data() const);
-  EXTENSION(PyObject *get_subdata(size_type n, size_type count) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_data() const);
+  PY_EXTENSION(PyObject *get_subdata(size_type n, size_type count) const);
   INLINE int get_ref_count() const;
   INLINE int get_node_ref_count() const;
 
   INLINE size_t count(const Element &) const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
-  EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
-  EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const);
+  PY_EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
+  PY_EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const);
 
-  EXTENSION(ConstPointerToArray<Element> __deepcopy__(PyObject *memo) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(ConstPointerToArray<Element> __deepcopy__(PyObject *memo) const);
 
 #else  // CPPPARSER
   // This is the actual, complete interface.

+ 6 - 10
panda/src/express/ramfile.h

@@ -27,20 +27,16 @@ PUBLISHED:
 
   INLINE void seek(size_t pos);
   INLINE size_t tell() const;
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *read(size_t length));
-  EXTENSION(PyObject *readline());
-  EXTENSION(PyObject *readlines());
+  PY_EXTENSION(PyObject *read(size_t length));
+  PY_EXTENSION(PyObject *readline());
+  PY_EXTENSION(PyObject *readlines());
 
-  EXTENSION(PyObject *get_data() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_data() const);
   INLINE size_t get_data_size() const;
   INLINE void clear();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__getstate__() const);
-  EXTENSION(void __setstate__(PyObject *state));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__getstate__() const);
+  PY_EXTENSION(void __setstate__(PyObject *state));
 public:
   std::string read(size_t length);
   std::string readline();

+ 4 - 8
panda/src/express/stringStream.h

@@ -30,9 +30,7 @@ public:
   INLINE StringStream(vector_uchar source);
 
 PUBLISHED:
-#ifdef HAVE_PYTHON
-  EXTENSION(StringStream(PyObject *source));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(StringStream(PyObject *source));
   INLINE StringStream();
 
 #if _MSC_VER >= 1800
@@ -42,12 +40,10 @@ PUBLISHED:
   INLINE void clear_data();
   INLINE size_t get_data_size();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_data());
-  EXTENSION(void set_data(PyObject *data));
+  PY_EXTENSION(PyObject *get_data());
+  PY_EXTENSION(void set_data(PyObject *data));
 
-  MAKE_PROPERTY(data, get_data, set_data);
-#endif // HAVE_PYTHON
+  PY_MAKE_PROPERTY(data, get_data, set_data);
 
 public:
 #ifndef CPPPARSER

+ 2 - 6
panda/src/express/virtualFile.h

@@ -56,16 +56,12 @@ PUBLISHED:
   BLOCKING void ls(std::ostream &out = std::cout) const;
   BLOCKING void ls_all(std::ostream &out = std::cout) const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *read_file(bool auto_unwrap) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *read_file(bool auto_unwrap) const);
   BLOCKING virtual std::istream *open_read_file(bool auto_unwrap) const;
   BLOCKING virtual void close_read_file(std::istream *stream) const;
   virtual bool was_read_successful() const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *write_file(PyObject *data, bool auto_wrap));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *write_file(PyObject *data, bool auto_wrap));
   BLOCKING virtual std::ostream *open_write_file(bool auto_wrap, bool truncate);
   BLOCKING virtual std::ostream *open_append_file();
   BLOCKING virtual void close_write_file(std::ostream *stream);

+ 2 - 6
panda/src/express/virtualFileSystem.h

@@ -98,15 +98,11 @@ PUBLISHED:
 
   static VirtualFileSystem *get_global_ptr();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *read_file(const Filename &filename, bool auto_unwrap) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *read_file(const Filename &filename, bool auto_unwrap) const);
   BLOCKING std::istream *open_read_file(const Filename &filename, bool auto_unwrap) const;
   BLOCKING static void close_read_file(std::istream *stream);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *write_file(const Filename &filename, PyObject *data, bool auto_wrap));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *write_file(const Filename &filename, PyObject *data, bool auto_wrap));
   BLOCKING std::ostream *open_write_file(const Filename &filename, bool auto_wrap, bool truncate);
   BLOCKING std::ostream *open_append_file(const Filename &filename);
   BLOCKING static void close_write_file(std::ostream *stream);

+ 28 - 14
panda/src/glstuff/glGraphicsStateGuardian_src.cxx

@@ -12396,6 +12396,8 @@ set_state_and_transform(const RenderState *target,
   }
 
   int texture_slot = TextureAttrib::get_class_slot();
+  int tex_gen_slot = TexGenAttrib::get_class_slot();
+  int tex_matrix_slot = TexMatrixAttrib::get_class_slot();
   if (_target_rs->get_attrib(texture_slot) != _state_rs->get_attrib(texture_slot) ||
       !_state_mask.get_bit(texture_slot)) {
     //PStatGPUTimer timer(this, _draw_set_state_texture_pcollector);
@@ -12411,7 +12413,7 @@ set_state_and_transform(const RenderState *target,
       _target_texture = (const TextureAttrib *)
         _target_rs->get_attrib_def(TextureAttrib::get_class_slot());
       _target_tex_gen = (const TexGenAttrib *)
-        _target_rs->get_attrib_def(TexGenAttrib::get_class_slot());
+        _target_rs->get_attrib_def(tex_gen_slot);
     }
 #endif
     do_issue_texture();
@@ -12419,28 +12421,36 @@ set_state_and_transform(const RenderState *target,
     // Since the TexGen and TexMatrix states depend partly on the particular
     // set of textures in use, we should force both of those to be reissued
     // every time we change the texture state.
-    _state_mask.clear_bit(TexGenAttrib::get_class_slot());
-    _state_mask.clear_bit(TexMatrixAttrib::get_class_slot());
+    _state_mask.clear_bit(tex_gen_slot);
+    _state_mask.clear_bit(tex_matrix_slot);
 
     _state_texture = _target_texture;
     _state_mask.set_bit(texture_slot);
   }
+  else if (_target_rs->get_attrib(tex_gen_slot) != _state_rs->get_attrib(tex_gen_slot) ||
+           !_state_mask.get_bit(tex_gen_slot)) {
+    _target_tex_gen = (const TexGenAttrib *)_target_rs->get_attrib_def(tex_gen_slot);
+
+#ifdef SUPPORT_FIXED_FUNCTION
+#ifdef OPENGLES_1
+    if (_has_texture_alpha_scale) {
+#else
+    if (_has_texture_alpha_scale && _current_shader == nullptr) {
+#endif
+      PT(TextureStage) stage = get_alpha_scale_texture_stage();
+      _target_tex_gen = DCAST(TexGenAttrib, _target_tex_gen->add_stage
+                              (stage, TexGenAttrib::M_constant, LTexCoord3(_current_color_scale[3], 0.0f, 0.0f)));
+    }
+#endif  // SUPPORT_FIXED_FUNCTION
 
-  // If one of the previously-loaded TexGen modes modified the texture matrix,
-  // then if either state changed, we have to change both of them now.
-  if (_tex_gen_modifies_mat) {
-    int tex_gen_slot = TexGenAttrib::get_class_slot();
-    int tex_matrix_slot = TexMatrixAttrib::get_class_slot();
-    if (_target_rs->get_attrib(tex_gen_slot) != _state_rs->get_attrib(tex_gen_slot) ||
-        _target_rs->get_attrib(tex_matrix_slot) != _state_rs->get_attrib(tex_matrix_slot) ||
-        !_state_mask.get_bit(tex_gen_slot) ||
-        !_state_mask.get_bit(tex_matrix_slot)) {
+    // If one of the previously-loaded TexGen modes modified the texture matrix,
+    // then if either state changed, we have to change both of them now.
+    if (_tex_gen_modifies_mat) {
       _state_mask.clear_bit(tex_gen_slot);
       _state_mask.clear_bit(tex_matrix_slot);
     }
   }
 
-  int tex_matrix_slot = TexMatrixAttrib::get_class_slot();
   if (_target_rs->get_attrib(tex_matrix_slot) != _state_rs->get_attrib(tex_matrix_slot) ||
       !_state_mask.get_bit(tex_matrix_slot)) {
     // PStatGPUTimer timer(this, _draw_set_state_tex_matrix_pcollector);
@@ -12455,11 +12465,15 @@ set_state_and_transform(const RenderState *target,
       _current_shader_context->issue_parameters(Shader::SSD_tex_matrix);
     }
 #endif
+
+    // See previous occurrence of this check.
+    if (_tex_gen_modifies_mat) {
+      _state_mask.clear_bit(tex_gen_slot);
+    }
   }
 
 #ifdef SUPPORT_FIXED_FUNCTION
   if (has_fixed_function_pipeline()) {
-    int tex_gen_slot = TexGenAttrib::get_class_slot();
     if (_target_tex_gen != _state_tex_gen ||
         !_state_mask.get_bit(tex_gen_slot)) {
       // PStatGPUTimer timer(this, _draw_set_state_tex_gen_pcollector);

+ 9 - 0
panda/src/glstuff/glShaderContext_src.cxx

@@ -25,6 +25,7 @@
 #include "fogAttrib.h"
 #include "lightAttrib.h"
 #include "clipPlaneAttrib.h"
+#include "renderModeAttrib.h"
 #include "bamCache.h"
 #include "shaderModuleGlsl.h"
 #include "shaderModuleSpirV.h"
@@ -2184,6 +2185,14 @@ set_state_and_transform(const RenderState *target_rs,
         target_rs->get_attrib(TextureAttrib::get_class_slot())) {
       altered |= Shader::SSD_texture;
     }
+    if (state_rs->get_attrib(TexGenAttrib::get_class_slot()) !=
+        target_rs->get_attrib(TexGenAttrib::get_class_slot())) {
+      altered |= Shader::SSD_tex_gen;
+    }
+    if (state_rs->get_attrib(RenderModeAttrib::get_class_slot()) !=
+        target_rs->get_attrib(RenderModeAttrib::get_class_slot())) {
+      altered |= Shader::SSD_render_mode;
+    }
     _state_rs = target_rs;
   }
 

+ 9 - 13
panda/src/gobj/geomVertexArrayData.h

@@ -114,11 +114,9 @@ PUBLISHED:
   static void lru_epoch();
   INLINE static VertexDataBook &get_book();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags));
-  EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
-  EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags));
+  PY_EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
+  PY_EXTENSION(void __releasebuffer__(PyObject *self, Py_buffer *view) const);
 
 public:
   virtual void evict_lru();
@@ -310,14 +308,12 @@ PUBLISHED:
                          const unsigned char *source,
                          size_t from_start, size_t from_size);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(void copy_data_from(PyObject *buffer));
-  EXTENSION(void copy_subdata_from(size_t to_start, size_t to_size,
-                                   PyObject *buffer));
-  EXTENSION(void copy_subdata_from(size_t to_start, size_t to_size,
-                                   PyObject *buffer,
-                                   size_t from_start, size_t from_size));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(void copy_data_from(PyObject *buffer));
+  PY_EXTENSION(void copy_subdata_from(size_t to_start, size_t to_size,
+                                      PyObject *buffer));
+  PY_EXTENSION(void copy_subdata_from(size_t to_start, size_t to_size,
+                                      PyObject *buffer,
+                                      size_t from_start, size_t from_size));
 
   INLINE vector_uchar get_data() const;
   void set_data(const vector_uchar &data);

+ 2 - 4
panda/src/gobj/internalName.h

@@ -94,13 +94,11 @@ PUBLISHED:
   INLINE static PT(InternalName) get_view();
   INLINE static PT(InternalName) get_instance_matrix();
 
-#ifdef HAVE_PYTHON
   // These versions are exposed to Python, which have additional logic to map
   // from Python interned strings.
-  EXTENSION(static PT(InternalName) make(PyObject *str));
+  PY_EXTENSION(static PT(InternalName) make(PyObject *str));
 
-  EXTENSION(PyObject *__reduce__() const);
-#endif
+  PY_EXTENSION(PyObject *__reduce__() const);
 
 public:
 #ifdef HAVE_PYTHON

+ 36 - 0
panda/src/gobj/shader.cxx

@@ -384,6 +384,12 @@ cp_dependency(ShaderMatInput inp) {
   if (inp == SMO_tex_is_alpha_i || inp == SMO_texcolor_i) {
     dep |= SSD_texture | SSD_frame;
   }
+  if (inp == SMO_texconst_i) {
+    dep |= SSD_tex_gen;
+  }
+  if (inp == SMO_attr_pointparams) {
+    dep |= SSD_render_mode | SSD_transform | SSD_frame;
+  }
 
   return dep;
 }
@@ -2143,6 +2149,17 @@ bind_parameter(const Parameter &param) {
         bind._arg[1] = nullptr;
         bind._index = atoi(pieces[1].c_str() + 5);
       }
+      else if (pieces[1] == "pointparams") {
+        if (!expect_float_vector(name, type, 3, 4)) {
+          return false;
+        }
+        bind._piece = SMP_row3;
+        bind._func = SMF_first;
+        bind._part[0] = SMO_attr_pointparams;
+        bind._arg[0] = nullptr;
+        bind._part[1] = SMO_identity;
+        bind._arg[1] = nullptr;
+      }
       else {
         return report_parameter_error(name, type, "unrecognized parameter name");
       }
@@ -2287,6 +2304,25 @@ bind_parameter(const Parameter &param) {
       return true;
     }
 
+    if (pieces[0] == "texconst") {
+      if (!expect_num_words(name, type, 2) ||
+          !expect_float_vector(name, type, 3, 4)) {
+        return false;
+      }
+      ShaderMatSpec bind;
+      bind._id = param;
+      bind._piece = SMP_row3;
+      bind._func = SMF_first;
+      bind._part[0] = SMO_texconst_i;
+      bind._arg[0] = nullptr;
+      bind._part[1] = SMO_identity;
+      bind._arg[1] = nullptr;
+      bind._index = atoi(pieces[1].c_str());
+
+      cp_add_mat_spec(bind);
+      return true;
+    }
+
     if (pieces[0] == "plane") {
       if (!expect_num_words(name, type, 2) ||
           !expect_float_vector(name, type, 4, 4)) {

+ 8 - 0
panda/src/gobj/shader.h

@@ -231,6 +231,12 @@ public:
     // Color of an M_blend texture stage.
     SMO_texcolor_i,
 
+    // Constant value of the TexGenAttrib of stage i.
+    SMO_texconst_i,
+
+    // Point parameters
+    SMO_attr_pointparams,
+
     SMO_INVALID
   };
 
@@ -294,6 +300,8 @@ public:
     SSD_projection    = 0x800,
     SSD_texture      = 0x1000,
     SSD_view_transform= 0x2000,
+    SSD_tex_gen      = 0x4000,
+    SSD_render_mode  = 0x8000,
   };
 
   enum ShaderBug {

+ 3 - 0
panda/src/gobj/texture.cxx

@@ -70,6 +70,7 @@ ConfigVariableEnum<Texture::QualityLevel> texture_quality_level
           "renderers.  See Texture::set_quality_level()."));
 
 PStatCollector Texture::_texture_read_pcollector("*:Texture:Read");
+PStatCollector Texture::_texture_write_pcollector("*:Texture:Write");
 TypeHandle Texture::_type_handle;
 TypeHandle Texture::CData::_type_handle;
 AutoTextureScale Texture::_textures_power_2 = ATS_unspecified;
@@ -5198,6 +5199,8 @@ do_read_ktx(CData *cdata, istream &in, const string &filename, bool header_only)
 bool Texture::
 do_write(CData *cdata,
          const Filename &fullpath, int z, int n, bool write_pages, bool write_mipmaps) {
+  PStatTimer timer(_texture_write_pcollector);
+
   if (is_txo_filename(fullpath)) {
     if (!do_has_bam_rawdata(cdata)) {
       do_get_bam_rawdata(cdata);

+ 5 - 4
panda/src/gobj/texture.h

@@ -461,9 +461,9 @@ PUBLISHED:
                             size_t page_size = 0);
   void set_ram_image_as(CPTA_uchar image, const std::string &provided_format);
 #else // !CPPPARSER || !HAVE_PYTHON
-  EXTEND void set_ram_image(PyObject *image, CompressionMode compression = CM_off,
-                            size_t page_size = 0);
-  EXTEND void set_ram_image_as(PyObject *image, const std::string &provided_format);
+  PY_EXTEND(void set_ram_image(PyObject *image, CompressionMode compression = CM_off,
+                               size_t page_size = 0));
+  PY_EXTEND(void set_ram_image_as(PyObject *image, const std::string &provided_format));
 #endif // !CPPPARSER || !HAVE_PYTHON
   INLINE void clear_ram_image();
   INLINE void set_keep_ram_image(bool keep_ram_image);
@@ -474,7 +474,7 @@ PUBLISHED:
   MAKE_PROPERTY(keep_ram_image, get_keep_ram_image, set_keep_ram_image);
   MAKE_PROPERTY(cacheable, is_cacheable);
 
-  EXTENSION(PT(Texture) __deepcopy__(PyObject *memo) const);
+  PY_EXTENSION(PT(Texture) __deepcopy__(PyObject *memo) const);
 
   BLOCKING INLINE bool compress_ram_image(CompressionMode compression = CM_on,
                                           QualityLevel quality_level = QL_default,
@@ -1088,6 +1088,7 @@ private:
 
   static AutoTextureScale _textures_power_2;
   static PStatCollector _texture_read_pcollector;
+  static PStatCollector _texture_write_pcollector;
 
   // Datagram stuff
 public:

+ 2 - 4
panda/src/gobj/textureCollection.h

@@ -29,10 +29,8 @@ PUBLISHED:
   void operator = (const TextureCollection &copy);
   INLINE ~TextureCollection();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(TextureCollection(PyObject *self, PyObject *sequence));
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-#endif
+  PY_EXTENSION(TextureCollection(PyObject *self, PyObject *sequence));
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
   void add_texture(Texture *texture);
   bool remove_texture(Texture *texture);

+ 3 - 5
panda/src/gobj/texturePool.h

@@ -98,11 +98,9 @@ PUBLISHED:
   TexturePoolFilter *get_filter(size_t i) const;
   MAKE_SEQ_PROPERTY(filters, get_num_filters, get_filter);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(bool register_filter(PyObject *tex_filter));
-  EXTENSION(bool unregister_filter(PyObject *tex_filter));
-  EXTENSION(bool is_filter_registered(PyObject *tex_filter));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(bool register_filter(PyObject *tex_filter));
+  PY_EXTENSION(bool unregister_filter(PyObject *tex_filter));
+  PY_EXTENSION(bool is_filter_registered(PyObject *tex_filter));
 
   static TexturePool *get_global_ptr();
 

+ 1 - 3
panda/src/linmath/lmatrix3_src.h

@@ -68,9 +68,7 @@ PUBLISHED:
                                      const FLOATNAME(LVecBase3) &);
   ALLOC_DELETED_CHAIN(FLOATNAME(LMatrix3));
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
 
   void fill(FLOATTYPE fill_value);
   INLINE_LINMATH void set(

+ 1 - 3
panda/src/linmath/lmatrix4_src.h

@@ -72,9 +72,7 @@ PUBLISHED:
                                      const FLOATNAME(LVecBase4) &);
   ALLOC_DELETED_CHAIN(FLOATNAME(LMatrix4));
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
 
   // Construct a 4x4 matrix given a 3x3 rotation matrix and an optional
   // translation component.

+ 2 - 4
panda/src/linmath/lpoint2_src.h

@@ -22,10 +22,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE fill_value);
   INLINE_LINMATH FLOATNAME(LPoint2)(FLOATTYPE x, FLOATTYPE y);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LPoint2) &zero();
   INLINE_LINMATH static const FLOATNAME(LPoint2) &unit_x();

+ 2 - 4
panda/src/linmath/lpoint3_src.h

@@ -26,10 +26,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LPoint3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z);
   INLINE_LINMATH FLOATNAME(LPoint3)(const FLOATNAME(LVecBase2) &copy, FLOATTYPE z);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LPoint3) &zero();
   INLINE_LINMATH static const FLOATNAME(LPoint3) &unit_x();

+ 2 - 4
panda/src/linmath/lpoint4_src.h

@@ -22,10 +22,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LPoint4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w);
   INLINE_LINMATH FLOATNAME(LPoint4)(const FLOATNAME(LVecBase3) &copy, FLOATTYPE w);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LPoint4) &zero();
   INLINE_LINMATH static const FLOATNAME(LPoint4) &unit_x();

+ 12 - 18
panda/src/linmath/lvecBase2_src.h

@@ -44,11 +44,9 @@ PUBLISHED:
   INLINE_LINMATH static const FLOATNAME(LVecBase2) &unit_x();
   INLINE_LINMATH static const FLOATNAME(LVecBase2) &unit_y();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH FLOATTYPE operator [](int i) const;
   INLINE_LINMATH FLOATTYPE &operator [](int i);
@@ -135,19 +133,17 @@ PUBLISHED:
 
   INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase2) &other);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__rmul__(PyObject *self, FLOATTYPE scalar) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__rmul__(PyObject *self, FLOATTYPE scalar) const);
 
-  EXTENSION(INLINE_LINMATH PyObject *__floordiv__(PyObject *self, FLOATTYPE scalar) const);
-  EXTENSION(INLINE_LINMATH PyObject *__ifloordiv__(PyObject *self, FLOATTYPE scalar));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__floordiv__(PyObject *self, FLOATTYPE scalar) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ifloordiv__(PyObject *self, FLOATTYPE scalar));
 
-  EXTENSION(INLINE_LINMATH PyObject *__pow__(PyObject *self, FLOATTYPE exponent) const);
-  EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__pow__(PyObject *self, FLOATTYPE exponent) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
 
-  EXTENSION(INLINE_LINMATH PyObject *__round__(PyObject *self));
-  EXTENSION(INLINE_LINMATH PyObject *__floor__(PyObject *self));
-  EXTENSION(INLINE_LINMATH PyObject *__ceil__(PyObject *self));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__round__(PyObject *self));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__floor__(PyObject *self));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ceil__(PyObject *self));
 
   INLINE_LINMATH FLOATNAME(LVecBase2) fmax(const FLOATNAME(LVecBase2) &other) const;
   INLINE_LINMATH FLOATNAME(LVecBase2) fmin(const FLOATNAME(LVecBase2) &other) const;
@@ -164,9 +160,7 @@ PUBLISHED:
   INLINE_LINMATH void write_datagram(Datagram &destination) const;
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
 
 public:
   // The underlying implementation is via the Eigen library, if available.

+ 12 - 18
panda/src/linmath/lvecBase3_src.h

@@ -46,11 +46,9 @@ PUBLISHED:
   INLINE_LINMATH static const FLOATNAME(LVecBase3) &unit_y();
   INLINE_LINMATH static const FLOATNAME(LVecBase3) &unit_z();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH FLOATTYPE operator [](int i) const;
   INLINE_LINMATH FLOATTYPE &operator [](int i);
@@ -154,19 +152,17 @@ PUBLISHED:
 
   INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase3) &other);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__rmul__(PyObject *self, FLOATTYPE scalar) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__rmul__(PyObject *self, FLOATTYPE scalar) const);
 
-  EXTENSION(INLINE_LINMATH PyObject *__floordiv__(PyObject *self, FLOATTYPE scalar) const);
-  EXTENSION(INLINE_LINMATH PyObject *__ifloordiv__(PyObject *self, FLOATTYPE scalar));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__floordiv__(PyObject *self, FLOATTYPE scalar) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ifloordiv__(PyObject *self, FLOATTYPE scalar));
 
-  EXTENSION(INLINE_LINMATH PyObject *__pow__(PyObject *self, FLOATTYPE exponent) const);
-  EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__pow__(PyObject *self, FLOATTYPE exponent) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
 
-  EXTENSION(INLINE_LINMATH PyObject *__round__(PyObject *self));
-  EXTENSION(INLINE_LINMATH PyObject *__floor__(PyObject *self));
-  EXTENSION(INLINE_LINMATH PyObject *__ceil__(PyObject *self));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__round__(PyObject *self));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__floor__(PyObject *self));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ceil__(PyObject *self));
 
   INLINE_LINMATH FLOATNAME(LVecBase3) fmax(const FLOATNAME(LVecBase3) &other) const;
   INLINE_LINMATH FLOATNAME(LVecBase3) fmin(const FLOATNAME(LVecBase3) &other) const;
@@ -185,9 +181,7 @@ PUBLISHED:
   INLINE_LINMATH void write_datagram(Datagram &destination) const;
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
 
 public:
   // The underlying implementation is via the Eigen library, if available.

+ 12 - 18
panda/src/linmath/lvecBase4_src.h

@@ -56,11 +56,9 @@ PUBLISHED:
   INLINE_LINMATH static const FLOATNAME(LVecBase4) &unit_z();
   INLINE_LINMATH static const FLOATNAME(LVecBase4) &unit_w();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH FLOATTYPE operator [](int i) const;
   INLINE_LINMATH FLOATTYPE &operator [](int i);
@@ -162,19 +160,17 @@ PUBLISHED:
 
   INLINE_LINMATH void componentwise_mult(const FLOATNAME(LVecBase4) &other);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__rmul__(PyObject *self, FLOATTYPE scalar) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__rmul__(PyObject *self, FLOATTYPE scalar) const);
 
-  EXTENSION(INLINE_LINMATH PyObject *__floordiv__(PyObject *self, FLOATTYPE scalar) const);
-  EXTENSION(INLINE_LINMATH PyObject *__ifloordiv__(PyObject *self, FLOATTYPE scalar));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__floordiv__(PyObject *self, FLOATTYPE scalar) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ifloordiv__(PyObject *self, FLOATTYPE scalar));
 
-  EXTENSION(INLINE_LINMATH PyObject *__pow__(PyObject *self, FLOATTYPE exponent) const);
-  EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__pow__(PyObject *self, FLOATTYPE exponent) const);
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ipow__(PyObject *self, FLOATTYPE exponent));
 
-  EXTENSION(INLINE_LINMATH PyObject *__round__(PyObject *self));
-  EXTENSION(INLINE_LINMATH PyObject *__floor__(PyObject *self));
-  EXTENSION(INLINE_LINMATH PyObject *__ceil__(PyObject *self));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__round__(PyObject *self));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__floor__(PyObject *self));
+  PY_EXTENSION(INLINE_LINMATH PyObject *__ceil__(PyObject *self));
 
   INLINE_LINMATH FLOATNAME(LVecBase4) fmax(const FLOATNAME(LVecBase4) &other) const;
   INLINE_LINMATH FLOATNAME(LVecBase4) fmin(const FLOATNAME(LVecBase4) &other) const;
@@ -191,9 +187,7 @@ PUBLISHED:
   INLINE_LINMATH void write_datagram(Datagram &destination) const;
   INLINE_LINMATH void read_datagram(DatagramIterator &source);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
 
 public:
   // The underlying implementation is via the Eigen library, if available.

+ 2 - 4
panda/src/linmath/lvector2_src.h

@@ -22,10 +22,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE fill_value);
   INLINE_LINMATH FLOATNAME(LVector2)(FLOATTYPE x, FLOATTYPE y);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LVector2) &zero();
   INLINE_LINMATH static const FLOATNAME(LVector2) &unit_x();

+ 2 - 4
panda/src/linmath/lvector3_src.h

@@ -26,10 +26,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LVector3)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z);
   INLINE_LINMATH FLOATNAME(LVector3)(const FLOATNAME(LVecBase2) &copy, FLOATTYPE z);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LVector3) &zero();
   INLINE_LINMATH static const FLOATNAME(LVector3) &unit_x();

+ 2 - 4
panda/src/linmath/lvector4_src.h

@@ -22,10 +22,8 @@ PUBLISHED:
   INLINE_LINMATH FLOATNAME(LVector4)(FLOATTYPE x, FLOATTYPE y, FLOATTYPE z, FLOATTYPE w);
   INLINE_LINMATH FLOATNAME(LVector4)(const FLOATNAME(LVecBase3) &copy, FLOATTYPE w);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
-  EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE_LINMATH PyObject *__getattr__(PyObject *self, const std::string &attr_name) const);
+  PY_EXTENSION(INLINE_LINMATH int __setattr__(PyObject *self, const std::string &attr_name, PyObject *assign));
 
   INLINE_LINMATH static const FLOATNAME(LVector4) &zero();
   INLINE_LINMATH static const FLOATNAME(LVector4) &unit_x();

+ 5 - 5
panda/src/ode/odeBody.h

@@ -51,7 +51,7 @@ PUBLISHED:
   INLINE void set_auto_disable_flag(int do_auto_disable);
   INLINE void set_auto_disable_defaults();
   INLINE void set_data(void *data);
-  EXTENSION(void set_data(PyObject *data));
+  PY_EXTENSION(void set_data(PyObject *data));
 
   INLINE void set_position(dReal x, dReal y, dReal z);
   INLINE void set_position(const LVecBase3f &pos);
@@ -71,8 +71,8 @@ PUBLISHED:
   INLINE int   get_auto_disable_flag() const;
 #ifndef CPPPARSER
   INLINE void *get_data() const;
-#endif
-  EXTENSION(PyObject *get_data() const);
+#endif // CPPPARSER
+  PY_EXTENSION(PyObject *get_data() const);
 
   INLINE LVecBase3f  get_position() const;
   INLINE LMatrix3f  get_rotation() const;
@@ -132,8 +132,8 @@ PUBLISHED:
   INLINE int get_num_joints() const;
   OdeJoint get_joint(int index) const;
   MAKE_SEQ(get_joints, get_num_joints, get_joint);
-  EXTENSION(INLINE PyObject *get_converted_joint(int i) const);
-  MAKE_SEQ_PROPERTY(joints, get_num_joints, get_converted_joint);
+  PY_EXTENSION(INLINE PyObject *get_converted_joint(int i) const);
+  PY_MAKE_SEQ_PROPERTY(joints, get_num_joints, get_converted_joint);
 
   INLINE void enable();
   INLINE void disable();

+ 3 - 3
panda/src/ode/odeGeom.h

@@ -84,7 +84,7 @@ PUBLISHED:
   INLINE LMatrix3f get_rotation() const;
   INLINE LQuaternionf get_quaternion() const;
   INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const;
-  EXTENSION(INLINE PyObject *get_AA_bounds() const);
+  PY_EXTENSION(INLINE PyObject *get_AA_bounds() const);
   INLINE int is_space();
   INLINE int get_class() const;
   INLINE void set_category_bits(const BitMask32 &bits);
@@ -114,13 +114,13 @@ PUBLISHED:
   // int test_collide_id( int collide_id);
 
   OdeSpace get_space() const;
-  EXTENSION(INLINE PyObject *get_converted_space() const);
+  PY_EXTENSION(INLINE PyObject *get_converted_space() const);
 
   virtual void write(std::ostream &out = std::cout, unsigned int indent=0) const;
   operator bool () const;
   INLINE int compare_to(const OdeGeom &other) const;
 
-  EXTENSION(PyObject *convert() const);
+  PY_EXTENSION(PyObject *convert() const);
   OdeBoxGeom convert_to_box() const;
   OdeCappedCylinderGeom convert_to_capped_cylinder() const;
   // OdeConvexGeom convert_to_convex() const;

+ 2 - 2
panda/src/ode/odeJoint.h

@@ -83,7 +83,7 @@ PUBLISHED:
   INLINE void set_feedback(bool flag = true);
   INLINE OdeJointFeedback *get_feedback();
 
-  EXTENSION(void attach(PyObject *body1, PyObject *body2));
+  PY_EXTENSION(void attach(PyObject *body1, PyObject *body2));
   void attach_bodies(const OdeBody &body1, const OdeBody &body2);
   void attach_body(const OdeBody &body, int index);
   void detach();
@@ -93,7 +93,7 @@ PUBLISHED:
   INLINE bool operator == (const OdeJoint &other) const;
   operator bool () const;
 
-  EXTENSION(PyObject *convert() const);
+  PY_EXTENSION(PyObject *convert() const);
   OdeBallJoint convert_to_ball() const;
   OdeHingeJoint convert_to_hinge() const;
   OdeSliderJoint convert_to_slider() const;

+ 5 - 5
panda/src/ode/odeSpace.h

@@ -52,7 +52,7 @@ PUBLISHED:
   int query(const OdeSpace& space) const;
   INLINE int get_num_geoms() const;
   INLINE void get_AABB(LVecBase3f &min, LVecBase3f &max) const;
-  EXTENSION(INLINE PyObject *get_AA_bounds() const);
+  PY_EXTENSION(INLINE PyObject *get_AA_bounds() const);
   INLINE int is_space();
   INLINE int get_class() const;
   INLINE void set_category_bits(const BitMask32 &bits);
@@ -82,12 +82,12 @@ PUBLISHED:
   OdeHashSpace convert_to_hash_space() const;
   OdeQuadTreeSpace convert_to_quad_tree_space() const;
 
-  EXTENSION(PyObject *convert() const);
-  EXTENSION(INLINE PyObject *get_converted_geom(int i) const);
-  EXTENSION(INLINE PyObject *get_converted_space() const);
+  PY_EXTENSION(PyObject *convert() const);
+  PY_EXTENSION(INLINE PyObject *get_converted_geom(int i) const);
+  PY_EXTENSION(INLINE PyObject *get_converted_space() const);
 
   void auto_collide();
-  EXTENSION(int collide(PyObject* arg, PyObject* near_callback));
+  PY_EXTENSION(int collide(PyObject* arg, PyObject* near_callback));
   int set_collide_id(int collide_id, dGeomID id);
   int set_collide_id(OdeGeom& geom, int collide_id);
   void set_surface_type( int surface_type, dGeomID id);

+ 3 - 3
panda/src/ode/odeUtil.h

@@ -41,10 +41,10 @@ PUBLISHED:
                                      const OdeBody &body2,
                                      const int joint_type);
   static PT(OdeCollisionEntry) collide(const OdeGeom &geom1, const OdeGeom &geom2,
-                                      const short int max_contacts = 150);
+                                       const short int max_contacts = 150);
 
-  EXTENSION(static int collide2(const OdeGeom &geom1, const OdeGeom &geom2,
-                                PyObject* arg, PyObject* callback));
+  PY_EXTENSION(static int collide2(const OdeGeom &geom1, const OdeGeom &geom2,
+                                   PyObject* arg, PyObject* callback));
 
   static OdeGeom space_to_geom(const OdeSpace &space);
 

+ 4 - 8
panda/src/pgraph/loaderFileTypeRegistry.h

@@ -38,12 +38,10 @@ public:
   void unregister_type(LoaderFileType *type);
 
 PUBLISHED:
-#ifdef HAVE_PYTHON
-  EXTENSION(void register_type(PyObject *type));
-  EXTENSION(void register_deferred_type(PyObject *entry_point));
+  PY_EXTENSION(void register_type(PyObject *type));
+  PY_EXTENSION(void register_deferred_type(PyObject *entry_point));
 
-  EXTENSION(void unregister_type(PyObject *type));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(void unregister_type(PyObject *type));
 
   int get_num_types() const;
   LoaderFileType *get_type(int n) const;
@@ -55,9 +53,7 @@ PUBLISHED:
 
   static LoaderFileTypeRegistry *get_global_ptr();
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__reduce__() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__reduce__() const);
 
 private:
   void record_extension(const std::string &extension, LoaderFileType *type);

+ 22 - 30
panda/src/pgraph/nodePath.h

@@ -183,11 +183,9 @@ PUBLISHED:
   INLINE void clear();
 
   EXTENSION(NodePath __copy__() const);
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__deepcopy__(PyObject *self, PyObject *memo) const);
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-  EXTENSION(PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__deepcopy__(PyObject *self, PyObject *memo) const);
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const);
 
   INLINE static NodePath not_found();
   INLINE static NodePath removed();
@@ -668,10 +666,8 @@ PUBLISHED:
   INLINE void set_shader_input(CPT_InternalName id, PN_stdfloat n1, PN_stdfloat n2,
                                PN_stdfloat n3=0, PN_stdfloat n4=0, int priority=0);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(void set_shader_input(CPT_InternalName, PyObject *, int priority=0));
-  EXTENSION(void set_shader_inputs(PyObject *args, PyObject *kwargs));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(void set_shader_input(CPT_InternalName, PyObject *, int priority=0));
+  PY_EXTENSION(void set_shader_inputs(PyObject *args, PyObject *kwargs));
 
   void clear_shader_input(CPT_InternalName id);
   void set_instance_count(int instance_count);
@@ -915,9 +911,7 @@ PUBLISHED:
                          const NodePath &other = NodePath(),
                          Thread *current_thread = Thread::get_current_thread()) const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_tight_bounds(const NodePath &other = NodePath()) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_tight_bounds(const NodePath &other = NodePath()) const);
 
   // void analyze() const;
 
@@ -938,24 +932,22 @@ PUBLISHED:
 
   MAKE_MAP_PROPERTY(net_tags, has_net_tag, get_net_tag);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(INLINE PyObject *get_tags() const);
-  EXTENSION(INLINE PyObject *get_tag_keys() const);
-  MAKE_PROPERTY(tags, get_tags);
-
-  EXTENSION(PyObject *get_python_tags());
-  EXTENSION(INLINE void set_python_tag(PyObject *keys, PyObject *value));
-  EXTENSION(INLINE PyObject *get_python_tag(PyObject *keys) const);
-  EXTENSION(INLINE PyObject *get_python_tag_keys() const);
-  EXTENSION(INLINE bool has_python_tag(PyObject *keys) const);
-  EXTENSION(INLINE void clear_python_tag(PyObject *keys));
-  EXTENSION(INLINE PyObject *get_net_python_tag(PyObject *keys) const);
-  EXTENSION(INLINE bool has_net_python_tag(PyObject *keys) const);
-  EXTENSION(NodePath find_net_python_tag(PyObject *keys) const);
-  MAKE_PROPERTY(python_tags, get_python_tags);
-
-  EXTENSION(int __traverse__(visitproc visit, void *arg));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(INLINE PyObject *get_tags() const);
+  PY_EXTENSION(INLINE PyObject *get_tag_keys() const);
+  PY_MAKE_PROPERTY(tags, get_tags);
+
+  PY_EXTENSION(PyObject *get_python_tags());
+  PY_EXTENSION(INLINE void set_python_tag(PyObject *keys, PyObject *value));
+  PY_EXTENSION(INLINE PyObject *get_python_tag(PyObject *keys) const);
+  PY_EXTENSION(INLINE PyObject *get_python_tag_keys() const);
+  PY_EXTENSION(INLINE bool has_python_tag(PyObject *keys) const);
+  PY_EXTENSION(INLINE void clear_python_tag(PyObject *keys));
+  PY_EXTENSION(INLINE PyObject *get_net_python_tag(PyObject *keys) const);
+  PY_EXTENSION(INLINE bool has_net_python_tag(PyObject *keys) const);
+  PY_EXTENSION(NodePath find_net_python_tag(PyObject *keys) const);
+  PY_MAKE_PROPERTY(python_tags, get_python_tags);
+
+  PY_EXTENSION(int __traverse__(visitproc visit, void *arg));
 
   INLINE void list_tags() const;
 

+ 3 - 7
panda/src/pgraph/nodePathCollection.h

@@ -27,10 +27,8 @@ class EXPCL_PANDA_PGRAPH NodePathCollection {
 PUBLISHED:
   NodePathCollection() = default;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(NodePathCollection(PyObject *self, PyObject *sequence));
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(NodePathCollection(PyObject *self, PyObject *sequence));
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
   void add_path(const NodePath &node_path);
   bool remove_path(const NodePath &node_path);
@@ -74,9 +72,7 @@ PUBLISHED:
 
   bool calc_tight_bounds(LPoint3 &min_point, LPoint3 &max_point) const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_tight_bounds() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_tight_bounds() const);
 
   void set_texture(Texture *tex, int priority = 0);
   void set_texture(TextureStage *stage, Texture *tex, int priority = 0);

+ 10 - 14
panda/src/pgraph/pandaNode.h

@@ -106,10 +106,8 @@ PUBLISHED:
   virtual PandaNode *make_copy() const;
   PT(PandaNode) copy_subgraph(Thread *current_thread = Thread::get_current_thread()) const;
 
-#ifdef HAVE_PYTHON
   EXTENSION(PT(PandaNode) __copy__() const);
-  EXTENSION(PyObject *__deepcopy__(PyObject *self, PyObject *memo) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__deepcopy__(PyObject *self, PyObject *memo) const);
 
   INLINE int get_num_parents(Thread *current_thread = Thread::get_current_thread()) const;
   INLINE PandaNode *get_parent(int n, Thread *current_thread = Thread::get_current_thread()) const;
@@ -206,19 +204,17 @@ PUBLISHED:
   MAKE_MAP_PROPERTY(tags, has_tag, get_tag, set_tag, clear_tag);
   MAKE_MAP_KEYS_SEQ(tags, get_num_tags, get_tag_key);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_tag_keys() const);
+  PY_EXTENSION(PyObject *get_tag_keys() const);
 
-  EXTENSION(PyObject *get_python_tags());
-  EXTENSION(void set_python_tag(PyObject *key, PyObject *value));
-  EXTENSION(PyObject *get_python_tag(PyObject *key) const);
-  EXTENSION(bool has_python_tag(PyObject *key) const);
-  EXTENSION(void clear_python_tag(PyObject *key));
-  EXTENSION(PyObject *get_python_tag_keys() const);
-  MAKE_PROPERTY(python_tags, get_python_tags);
+  PY_EXTENSION(PyObject *get_python_tags());
+  PY_EXTENSION(void set_python_tag(PyObject *key, PyObject *value));
+  PY_EXTENSION(PyObject *get_python_tag(PyObject *key) const);
+  PY_EXTENSION(bool has_python_tag(PyObject *key) const);
+  PY_EXTENSION(void clear_python_tag(PyObject *key));
+  PY_EXTENSION(PyObject *get_python_tag_keys() const);
+  PY_MAKE_PROPERTY(python_tags, get_python_tags);
 
-  EXTENSION(int __traverse__(visitproc visit, void *arg));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(int __traverse__(visitproc visit, void *arg));
 
   INLINE bool has_tags() const;
   void copy_tags(PandaNode *other);

+ 5 - 9
panda/src/pgraph/renderState.h

@@ -71,7 +71,7 @@ PUBLISHED:
   bool cull_callback(CullTraverser *trav, const CullTraverserData &data) const;
 
   INLINE static CPT(RenderState) make_empty();
-  EXTENSION(static explicit CPT(RenderState) make(PyObject *args, PyObject *kwargs));
+  PY_EXTENSION(static explicit CPT(RenderState) make(PyObject *args, PyObject *kwargs));
 
 public:
   static CPT(RenderState) make(const RenderAttrib *attrib, int override = 0);
@@ -132,10 +132,8 @@ PUBLISHED:
   INLINE size_t get_invert_composition_cache_size() const;
   INLINE const RenderState *get_invert_composition_cache_source(size_t n) const;
   INLINE const RenderState *get_invert_composition_cache_result(size_t n) const;
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_composition_cache() const);
-  EXTENSION(PyObject *get_invert_composition_cache() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_composition_cache() const);
+  PY_EXTENSION(PyObject *get_invert_composition_cache() const);
 
   void output(std::ostream &out) const;
   void write(std::ostream &out, int indent_level) const;
@@ -150,10 +148,8 @@ PUBLISHED:
   static void list_cycles(std::ostream &out);
   static void list_states(std::ostream &out);
   static bool validate_states();
-#ifdef HAVE_PYTHON
-  EXTENSION(static PyObject *get_states());
-  EXTENSION(static PyObject *get_unused_states());
-#endif // HAVE_PYTHON
+  PY_EXTENSION(static PyObject *get_states());
+  PY_EXTENSION(static PyObject *get_unused_states());
 
 PUBLISHED:
   // These methods are intended for use by low-level code, but they're also

+ 2 - 4
panda/src/pgraph/shaderAttrib.h

@@ -96,10 +96,8 @@ public:
   CPT(RenderAttrib) set_shader_inputs(const pvector<ShaderInput> &inputs) const;
 
 PUBLISHED:
-#ifdef HAVE_PYTHON
-  EXTENSION(CPT(RenderAttrib) set_shader_input(CPT_InternalName, PyObject *, int priority=0) const);
-  EXTENSION(CPT(RenderAttrib) set_shader_inputs(PyObject *args, PyObject *kwargs) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(CPT(RenderAttrib) set_shader_input(CPT_InternalName, PyObject *, int priority=0) const);
+  PY_EXTENSION(CPT(RenderAttrib) set_shader_inputs(PyObject *args, PyObject *kwargs) const);
 
   CPT(RenderAttrib) set_instance_count(int instance_count) const;
 

+ 1 - 3
panda/src/pgraph/shaderInput.h

@@ -49,9 +49,7 @@ PUBLISHED:
   static const ShaderInput &get_blank();
   INLINE explicit ShaderInput(CPT_InternalName name, int priority=0);
 
-#ifdef HAVE_PYTHON
-  EXTENSION(explicit ShaderInput(CPT_InternalName name, PyObject *value, int priority=0));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(explicit ShaderInput(CPT_InternalName name, PyObject *value, int priority=0));
 
 public:
   INLINE ShaderInput(CPT_InternalName name, Texture *tex, int priority=0);

+ 4 - 8
panda/src/pgraph/transformState.h

@@ -194,10 +194,8 @@ PUBLISHED:
   INLINE const TransformState *get_invert_composition_cache_source(size_t n) const;
   INLINE const TransformState *get_invert_composition_cache_result(size_t n) const;
   bool validate_composition_cache() const;
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_composition_cache() const);
-  EXTENSION(PyObject *get_invert_composition_cache() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_composition_cache() const);
+  PY_EXTENSION(PyObject *get_invert_composition_cache() const);
 
   void output(std::ostream &out) const;
   void write(std::ostream &out, int indent_level) const;
@@ -210,10 +208,8 @@ PUBLISHED:
   static void list_cycles(std::ostream &out);
   static void list_states(std::ostream &out);
   static bool validate_states();
-#ifdef HAVE_PYTHON
-  EXTENSION(static PyObject *get_states());
-  EXTENSION(static PyObject *get_unused_states());
-#endif // HAVE_PYTHON
+  PY_EXTENSION(static PyObject *get_states());
+  PY_EXTENSION(static PyObject *get_unused_states());
 
 public:
   static void init_states();

+ 73 - 14
panda/src/pgraphnodes/shaderGenerator.cxx

@@ -38,6 +38,7 @@
 #include "texture.h"
 #include "ambientLight.h"
 #include "directionalLight.h"
+#include "renderModeAttrib.h"
 #include "rescaleNormalAttrib.h"
 #include "pointLight.h"
 #include "sphereLight.h"
@@ -804,6 +805,12 @@ analyze_renderstate(ShaderKey &key, const RenderState *rs) {
   if (rs->get_attrib(fog) && !fog->is_off()) {
     key._flags |= ((int)fog->get_fog()->get_mode() + 1) << ShaderKey::F_FOG_MODE_SHIFT;
   }
+
+  // Must we calculate the point size in the shader?
+  const RenderModeAttrib *render_mode;
+  if (rs->get_attrib(render_mode) && render_mode->get_perspective()) {
+    key._flags |= ShaderKey::F_perspective_points;
+  }
 }
 
 /**
@@ -997,6 +1004,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
   bool need_eye_position = key._flags & ShaderKey::F_lighting;
   bool need_eye_normal = !key._lights.empty() || ((key._flags & ShaderKey::F_out_aux_normal) != 0);
   bool need_tangents = ((key._texture_flags & ShaderKey::TF_map_normal) != 0);
+  bool need_point_size = key._flags & ShaderKey::F_perspective_points;
 
   // If we have binormal/tangent and eye position, we can pack eye normal in
   // the w channels of the others.
@@ -1024,23 +1032,34 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
     }
   }
 
+  bool need_eye_reflection = false;
+  bool need_fragment_view_to_world = false;
+
   text << "void vshader(\n";
   for (size_t i = 0; i < key._textures.size(); ++i) {
     const ShaderKey::TextureInfo &tex = key._textures[i];
 
     switch (tex._gen_mode) {
-    case TexGenAttrib::M_world_position:
-      need_world_position = true;
+    case TexGenAttrib::M_world_cube_map:
+      need_fragment_view_to_world = true;
+    case TexGenAttrib::M_eye_sphere_map:
+    case TexGenAttrib::M_eye_cube_map:
+      need_eye_position = true;
+      need_eye_normal = true;
+      need_eye_reflection = true;
       break;
     case TexGenAttrib::M_world_normal:
       need_world_normal = true;
       break;
-    case TexGenAttrib::M_eye_position:
-      need_eye_position = true;
-      break;
     case TexGenAttrib::M_eye_normal:
       need_eye_normal = true;
       break;
+    case TexGenAttrib::M_world_position:
+      need_world_position = true;
+      break;
+    case TexGenAttrib::M_eye_position:
+      need_eye_position = true;
+      break;
     default:
       break;
     }
@@ -1109,7 +1128,7 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
     text << "\t uniform float3x4 trans_model_to_view,\n";
     eye_position_freg = alloc_freg();
     text << "\t out float4 l_eye_position : " << eye_position_freg << ",\n";
-  } else if (need_tangents) {
+  } else if (need_tangents || need_point_size) {
     text << "\t uniform float3x4 trans_model_to_view,\n";
   }
   if (need_eye_normal) {
@@ -1154,6 +1173,10 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
       text << "\t in uint4 vtx_transform_index : BLENDINDICES,\n";
     }
   }
+  if (need_point_size) {
+    text << "\t uniform float3 attr_pointparams,\n";
+    text << "\t out float l_point_size : PSIZE,\n";
+  }
   text << "\t in float4 vtx_position : POSITION,\n";
   text << "\t out float4 l_position : POSITION,\n";
   text << "\t uniform float4x4 mat_modelproj\n";
@@ -1188,6 +1211,13 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
   if (need_eye_position) {
     text << "\t l_eye_position = float4(mul(trans_model_to_view, vtx_position), 1);\n";
   }
+  else if (need_point_size) {
+    text << "\t float4 l_eye_position = mul(trans_model_to_view, vtx_position);\n";
+  }
+  if (need_point_size) {
+    text << "\t l_point_size = attr_pointparams.y + attr_pointparams.z / length(l_eye_position.xyz);\n";
+  }
+
   pmap<const InternalName *, const char *>::const_iterator it;
   for (it = texcoord_fregs.begin(); it != texcoord_fregs.end(); ++it) {
     // Pass through all texcoord inputs as-is.
@@ -1271,6 +1301,13 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
     if (tex._flags & ShaderKey::TF_uses_color) {
       text << "\t uniform float4 texcolor_" << i << ",\n";
     }
+
+    if (tex._gen_mode == TexGenAttrib::M_constant) {
+      text << "\t uniform float4 texconst_" << i << ",\n";
+    }
+  }
+  if (need_fragment_view_to_world) {
+    text << "\t uniform float3x3 trans_view_to_world,\n";
   }
   if (need_tangents) {
     text << "\t in float4 l_tangent : " << tangent_freg << ",\n";
@@ -1348,6 +1385,17 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
   if (need_eye_normal && pack_eye_normal) {
     text << "\t float3 l_eye_normal = float3(l_tangent.w, l_binormal.w, l_eye_position.w);\n";
   }
+  if (need_eye_normal) {
+    text << "\t // Correct the surface normal for interpolation effects\n";
+    text << "\t l_eye_normal = normalize(l_eye_normal);\n";
+  }
+  if (need_eye_reflection ||
+      (need_eye_position && have_specular && (key._flags & Material::F_local) != 0 && !key._lights.empty())) {
+    text << "\t float3 norm_eye_position = normalize(l_eye_position.xyz);\n";
+  }
+  if (need_eye_reflection) {
+    text << "\t float3 eye_reflection = norm_eye_position - l_eye_normal * 2 * dot(l_eye_normal, norm_eye_position);\n";
+  }
 
   text << "\t float4 result;\n";
   if (key._flags & (ShaderKey::F_out_aux_normal | ShaderKey::F_out_aux_glow)) {
@@ -1366,17 +1414,29 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
       // Cg seems to be able to optimize this temporary away when appropriate.
       text << "\t float4 texcoord" << i << " = l_" << tex._texcoord_name->join("_") << ";\n";
       break;
-    case TexGenAttrib::M_world_position:
-      text << "\t float4 texcoord" << i << " = l_world_position;\n";
+    case TexGenAttrib::M_eye_sphere_map:
+      text << "\t float4 texcoord" << i << " = float4(eye_reflection.xz * (1.0f / (2.0f * length(eye_reflection + float3(0, -1, 0)))) + float2(0.5f, 0.5f), 0.0f, 1.0f);\n";
+      break;
+    case TexGenAttrib::M_world_cube_map:
+      text << "\t float4 texcoord" << i << " = float4(mul(trans_view_to_world, eye_reflection), 1.0f);\n";
+      break;
+    case TexGenAttrib::M_eye_cube_map:
+      text << "\t float4 texcoord" << i << " = float4(eye_reflection, 1.0f);\n";
       break;
     case TexGenAttrib::M_world_normal:
       text << "\t float4 texcoord" << i << " = l_world_normal;\n";
       break;
+    case TexGenAttrib::M_eye_normal:
+      text << "\t float4 texcoord" << i << " = float4(l_eye_normal, 1.0f);\n";
+      break;
+    case TexGenAttrib::M_world_position:
+      text << "\t float4 texcoord" << i << " = l_world_position;\n";
+      break;
     case TexGenAttrib::M_eye_position:
       text << "\t float4 texcoord" << i << " = float4(l_eye_position.xyz, 1.0f);\n";
       break;
-    case TexGenAttrib::M_eye_normal:
-      text << "\t float4 texcoord" << i << " = float4(l_eye_normal, 1.0f);\n";
+    case TexGenAttrib::M_constant:
+      text << "\t float4 texcoord" << i << " = texconst_" << i << ";\n";
       break;
     default:
       text << "\t float4 texcoord" << i << " = float4(0, 0, 0, 0);\n";
@@ -1469,10 +1529,6 @@ synthesize_shader(const RenderState *rs, const GeomVertexAnimationSpec &anim) {
       text << ");\n";
     }
   }
-  if (need_eye_normal) {
-    text << "\t // Correct the surface normal for interpolation effects\n";
-    text << "\t l_eye_normal = normalize(l_eye_normal);\n";
-  }
   if (need_tangents) {
     text << "\t // Translate tangent-space normal in map to view-space.\n";
 
@@ -1977,6 +2033,9 @@ make_attrib(const ShaderKey &key, Shader *shader) {
   if (key._flags & ShaderKey::F_disable_alpha_write) {
     flags |= ShaderAttrib::F_disable_alpha_write;
   }
+  if (key._flags & ShaderKey::F_perspective_points) {
+    flags |= ShaderAttrib::F_shader_point_size;
+  }
   if (flags != 0) {
     shattr = DCAST(ShaderAttrib, shattr)->set_flag(flags, true);
   }

+ 1 - 0
panda/src/pgraphnodes/shaderGenerator.h

@@ -121,6 +121,7 @@ protected:
       F_ALPHA_TEST_MASK       = 0x07000000,
 
       F_use_shadow_filter     = 0x08000000,
+      F_perspective_points    = 0x10000000,
     };
 
     enum TextureFlags {

+ 2 - 4
panda/src/pipeline/pmutex.h

@@ -49,11 +49,9 @@ PUBLISHED:
 
   void operator = (const Mutex &copy) = delete;
 
-#ifdef HAVE_PYTHON
   EXTENSION(bool acquire(bool blocking=true) const);
-  EXTENSION(bool __enter__());
-  EXTENSION(void __exit__(PyObject *, PyObject *, PyObject *));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(bool __enter__());
+  PY_EXTENSION(void __exit__(PyObject *, PyObject *, PyObject *));
 public:
   // This is a global mutex set aside for the purpose of protecting Notify
   // messages from being interleaved between threads.

+ 2 - 4
panda/src/pipeline/reMutex.h

@@ -43,11 +43,9 @@ PUBLISHED:
 
   void operator = (const ReMutex &copy) = delete;
 
-#ifdef HAVE_PYTHON
   EXTENSION(bool acquire(bool blocking=true) const);
-  EXTENSION(bool __enter__());
-  EXTENSION(void __exit__(PyObject *, PyObject *, PyObject *));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(bool __enter__());
+  PY_EXTENSION(void __exit__(PyObject *, PyObject *, PyObject *));
 };
 
 #include "reMutex.I"

+ 12 - 0
panda/src/pipeline/thread.cxx

@@ -66,6 +66,10 @@ Thread::
   nassertv(_blocked_on_mutex == nullptr &&
            _waiting_on_cvar == nullptr);
 #endif
+
+  if (_pstats_callback != nullptr) {
+    _pstats_callback->delete_hook(this);
+  }
 }
 
 /**
@@ -251,3 +255,11 @@ deactivate_hook(Thread *) {
 void Thread::PStatsCallback::
 activate_hook(Thread *) {
 }
+
+/**
+ * Called when the thread is deleted.  This provides a callback hook for PStats
+ * to remove a thread's data when the thread is removed.
+ */
+void Thread::PStatsCallback::
+delete_hook(Thread *) {
+}

+ 1 - 0
panda/src/pipeline/thread.h

@@ -128,6 +128,7 @@ public:
     virtual ~PStatsCallback();
     virtual void deactivate_hook(Thread *thread);
     virtual void activate_hook(Thread *thread);
+    virtual void delete_hook(Thread *thread);
   };
 
   INLINE void set_pstats_index(int pstats_index);

+ 2 - 4
panda/src/pnmimage/pfmFile.h

@@ -170,11 +170,9 @@ PUBLISHED:
 
   void output(std::ostream &out) const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_points() const);
+  PY_EXTENSION(PyObject *get_points() const);
 
-  EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
-#endif
+  PY_EXTENSION(int __getbuffer__(PyObject *self, Py_buffer *view, int flags) const);
 
 public:
   INLINE const vector_float &get_table() const;

+ 9 - 0
panda/src/pnmimage/pnmImage.cxx

@@ -19,11 +19,16 @@
 #include "config_pnmimage.h"
 #include "perlinNoise2.h"
 #include "stackedPerlinNoise2.h"
+#include "pStatCollector.h"
+#include "pStatTimer.h"
 #include <algorithm>
 
 using std::max;
 using std::min;
 
+static PStatCollector _image_read_pcollector("*:PNMImage:read");
+static PStatCollector _image_write_pcollector("*:PNMImage:write");
+
 /**
  *
  */
@@ -319,6 +324,8 @@ read(std::istream &data, const std::string &filename, PNMFileType *type,
  */
 bool PNMImage::
 read(PNMReader *reader) {
+  PStatTimer timer(_image_read_pcollector);
+
   bool has_read_size = _has_read_size;
   int read_x_size = _read_x_size;
   int read_y_size = _read_y_size;
@@ -437,6 +444,8 @@ write(PNMWriter *writer) const {
     return false;
   }
 
+  PStatTimer timer(_image_write_pcollector);
+
   writer->copy_header_from(*this);
 
   if (!writer->supports_integer()) {

+ 57 - 4
panda/src/pstatclient/pStatClient.cxx

@@ -27,6 +27,8 @@
 #include "clockObject.h"
 #include "neverFreeMemory.h"
 
+#include <algorithm>
+
 using std::string;
 
 PStatCollector PStatClient::_heap_total_size_pcollector("System memory:Heap");
@@ -415,6 +417,7 @@ client_main_tick() {
            vi != indices.end();
            ++vi) {
         InternalThread *thread = get_thread_ptr(*vi);
+        nassertd(thread != nullptr) continue;
         _impl->new_frame(*vi, thread->_frame_number);
         thread->_frame_number = clock->get_frame_count(get_thread_object(*vi));
       }
@@ -483,10 +486,12 @@ client_disconnect() {
   ThreadPointer *threads = _threads.load(std::memory_order_relaxed);
   for (int ti = 0; ti < get_num_threads(); ++ti) {
     InternalThread *thread = threads[ti];
-    thread->_frame_number = 0;
-    thread->_is_active = false;
-    thread->_next_packet = 0.0;
-    thread->_frame_data.clear();
+    if (thread != nullptr) {
+      thread->_frame_number = 0;
+      thread->_is_active = false;
+      thread->_next_packet = 0.0;
+      thread->_frame_data.clear();
+    }
   }
 
   CollectorPointer *collectors = _collectors.load(std::memory_order_relaxed);
@@ -1233,6 +1238,54 @@ activate_hook(Thread *thread) {
   }
 }
 
+/**
+ * Called when the thread is deleted.  This provides a callback hook for PStats
+ * to remove a thread's data when the thread is removed.
+ */
+void PStatClient::
+delete_hook(Thread *thread) {
+  int thread_index = thread->get_pstats_index();
+  if (thread_index < 0) {
+    return;
+  }
+
+  PStatClientImpl *impl;
+  InternalThread *ithread;
+  {
+    ReMutexHolder holder(_lock);
+    impl = _impl;
+    if (impl == nullptr) {
+      return;
+    }
+
+    if (!impl->client_is_connected()) {
+      return;
+    }
+
+    MultiThingsByName::iterator ni;
+
+    ni = _threads_by_name.find(thread->get_name());
+    if (ni != _threads_by_name.end()) {
+      ni->second.erase(std::remove(ni->second.begin(), ni->second.end(), thread_index));
+    }
+
+    ni = _threads_by_sync_name.find(thread->get_sync_name());
+    if (ni != _threads_by_sync_name.end()) {
+      ni->second.erase(std::remove(ni->second.begin(), ni->second.end(), thread_index));
+    }
+
+    // This load can be relaxed because we hold the lock.
+    ThreadPointer *threads = _threads.load(std::memory_order_relaxed);
+    ithread = threads[thread_index];
+    ithread->_is_active = false;
+    ithread->_thread_active = false;
+    threads[thread_index] = nullptr;
+  }
+
+  impl->remove_thread(thread_index);
+  delete ithread;
+}
+
 /**
  * Creates the new PStatCollectorDef for this collector.
  */

+ 1 - 0
panda/src/pstatclient/pStatClient.h

@@ -151,6 +151,7 @@ private:
 
   virtual void deactivate_hook(Thread *thread);
   virtual void activate_hook(Thread *thread);
+  virtual void delete_hook(Thread *thread);
 
 private:
   // This mutex protects everything in this class.

+ 25 - 7
panda/src/pstatclient/pStatClientImpl.cxx

@@ -328,6 +328,7 @@ new_frame(int thread_index, int frame_number) {
   nassertv(thread_index >= 0 && thread_index < _client->_num_threads);
 
   PStatClient::InternalThread *pthread = _client->get_thread_ptr(thread_index);
+  nassertv(pthread != nullptr);
 
   // If we're the main thread, we should exchange control packets with the
   // server.
@@ -428,6 +429,7 @@ add_frame(int thread_index, int frame_number, PStatFrameData &&frame_data) {
   nassertv(thread_index >= 0 && thread_index < _client->_num_threads);
 
   PStatClient::InternalThread *pthread = _client->get_thread_ptr(thread_index);
+  nassertv(pthread != nullptr);
 
   // If we're the main thread, we should exchange control packets with the
   // server.
@@ -458,6 +460,22 @@ add_frame(int thread_index, int frame_number, PStatFrameData &&frame_data) {
   _client->stop(pstats_index, current_thread_index);
 }
 
+/**
+ * Removes a thread from PStats.
+ */
+void PStatClientImpl::
+remove_thread(int thread_index) {
+  nassertv(thread_index >= 0 && thread_index < _client->_num_threads);
+
+  PStatClientControlMessage message;
+  message._type = PStatClientControlMessage::T_expire_thread;
+  message._first_thread_index = thread_index;
+
+  Datagram datagram;
+  message.encode(datagram);
+  _writer.send(datagram, _tcp_connection, true);
+}
+
 /**
  * Passes off the frame data to the writer thread.  If threading is disabled,
  * transmits it right away.
@@ -541,6 +559,8 @@ transmit_frame_data(int thread_index, int frame_number,
                     const PStatFrameData &frame_data) {
   nassertv(thread_index >= 0 && thread_index < _client->_num_threads);
   PStatClient::InternalThread *thread = _client->get_thread_ptr(thread_index);
+  nassertv(thread != nullptr);
+
   if (_is_connected && thread->_is_active) {
 
     // We don't want to send too many packets in a hurry and flood the server.
@@ -680,12 +700,6 @@ send_hello() {
   message._major_version = get_current_pstat_major_version();
   message._minor_version = get_current_pstat_minor_version();
 
-  // The Python profiling feature may send nested start/stop pairs, so requires
-  // a server version capable of dealing with this.
-  if (pstats_python_profiler && message._major_version <= 3) {
-    message._major_version = 3;
-    message._minor_version = std::max(message._minor_version, 1);
-  }
 
   Datagram datagram;
   message.encode(datagram);
@@ -733,7 +747,11 @@ report_new_threads() {
     PStatClient::ThreadPointer *threads =
       (PStatClient::ThreadPointer *)_client->_threads;
     while (_threads_reported < _client->_num_threads) {
-      message._names.push_back(threads[_threads_reported]->_name);
+      if (threads[_threads_reported] != nullptr) {
+        message._names.push_back(threads[_threads_reported]->_name);
+      } else {
+        message._names.push_back(std::string());
+      }
       _threads_reported++;
     }
 

+ 2 - 0
panda/src/pstatclient/pStatClientImpl.h

@@ -70,6 +70,8 @@ public:
   void new_frame(int thread_index, int frame_number = -1);
   void add_frame(int thread_index, int frame_number, PStatFrameData &&frame_data);
 
+  void remove_thread(int thread_index);
+
 private:
   void enqueue_frame_data(int thread_index, int frame_number,
                           PStatFrameData &&frame_data);

+ 13 - 7
panda/src/pstatclient/pStatFrameData.cxx

@@ -44,7 +44,7 @@ write_datagram(Datagram &destination, PStatClient *client) const {
 
 #if !defined(WORDS_BIGENDIAN) || defined(__GNUC__)
   // Hand-roll this, significantly more efficient for many data points
-  size_t size = (_time_data.size() + _level_data.size()) * 6 + 4;
+  size_t size = (_time_data.size() + _level_data.size()) * 6 + 8;
   PTA_uchar array = destination.modify_array();
   size_t offset = array.size();
   array.resize(offset + size);
@@ -53,7 +53,8 @@ write_datagram(Datagram &destination, PStatClient *client) const {
   uint16_t *ptr = (uint16_t *)data;
 
 #ifdef WORDS_BIGENDIAN
-  *ptr++ = __builtin_bswap16(_time_data.size());
+  *(uint32_t *)ptr = __builtin_bswap32(_time_data.size());
+  ptr += 2;
 
   for (const DataPoint &dp : _time_data) {
     *ptr++ = __builtin_bswap16(dp._index);
@@ -62,7 +63,9 @@ write_datagram(Datagram &destination, PStatClient *client) const {
     ptr += 2;
   }
 
-  *ptr++ = __builtin_bswap16(_level_data.size());
+  *(uint32_t *)ptr = __builtin_bswap16(_level_data.size());
+  ptr += 2;
+
   for (const DataPoint &dp : _level_data) {
     *ptr++ = __builtin_bswap16(dp._index);
     PN_float32 v = (PN_float32)dp._value;
@@ -70,7 +73,8 @@ write_datagram(Datagram &destination, PStatClient *client) const {
     ptr += 2;
   }
 #else
-  *ptr++ = _time_data.size();
+  *(uint32_t *)ptr = _time_data.size();
+  ptr += 2;
 
   for (const DataPoint &dp : _time_data) {
     *ptr++ = dp._index;
@@ -78,7 +82,9 @@ write_datagram(Datagram &destination, PStatClient *client) const {
     ptr += 2;
   }
 
-  *ptr++ = _level_data.size();
+  *(uint32_t *)ptr = _level_data.size();
+  ptr += 2;
+
   for (const DataPoint &dp : _level_data) {
     *ptr++ = dp._index;
     *(PN_float32 *)ptr = dp._value;
@@ -87,12 +93,12 @@ write_datagram(Datagram &destination, PStatClient *client) const {
 #endif
 
 #else
-  destination.add_uint16(_time_data.size());
+  destination.add_uint32(_time_data.size());
   for (const DataPoint &dp : _time_data) {
     destination.add_uint16(dp._index);
     destination.add_float32(dp._value);
   }
-  destination.add_uint16(_level_data.size());
+  destination.add_uint32(_level_data.size());
   for (const DataPoint &dp : _level_data) {
     destination.add_uint16(dp._index);
     destination.add_float32(dp._value);

+ 1 - 1
panda/src/pstatclient/pStatProperties.cxx

@@ -26,7 +26,7 @@
 using std::string;
 
 static const int current_pstat_major_version = 3;
-static const int current_pstat_minor_version = 0;
+static const int current_pstat_minor_version = 2;
 // Initialized at 2.0 on 5/18/01, when version numbers were first added.
 // Incremented to 2.1 on 5/21/01 to add support for TCP frame data.
 // Incremented to 3.0 on 4/28/05 to bump TCP headers to 32 bits.

+ 3 - 9
panda/src/putil/bamReader.h

@@ -149,18 +149,14 @@ PUBLISHED:
   INLINE int get_current_major_ver() const;
   INLINE int get_current_minor_ver() const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *get_file_version() const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *get_file_version() const);
 
 PUBLISHED:
   MAKE_PROPERTY(source, get_source, set_source);
   MAKE_PROPERTY(filename, get_filename);
   MAKE_PROPERTY(loader_options, get_loader_options, set_loader_options);
 
-#ifdef HAVE_PYTHON
-  MAKE_PROPERTY(file_version, get_file_version);
-#endif // HAVE_PYTHON
+  PY_MAKE_PROPERTY(file_version, get_file_version);
   MAKE_PROPERTY(file_endian, get_file_endian);
   MAKE_PROPERTY(file_stdfloat_double, get_file_stdfloat_double);
 
@@ -206,10 +202,8 @@ public:
                                       void *user_data = nullptr);
   INLINE static WritableFactory *get_factory();
 
-#ifdef HAVE_PYTHON
 PUBLISHED:
-  EXTENSION(static void register_factory(TypeHandle handle, PyObject *func));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(static void register_factory(TypeHandle handle, PyObject *func));
 
 private:
   INLINE static void create_factory();

+ 13 - 6
panda/src/putil/bitArray.I

@@ -177,15 +177,15 @@ extract(int low_bit, int size) const {
 
   if (b + size < num_bits_per_word) {
     // The whole thing fits within one word of the array.
-    return get_word(w).extract(b, size);
+    return get_word_internal(w).extract(b, size);
 
   } else {
     // We have to split it across two words.
     int num_lower_bits = num_bits_per_word - b;
     int num_higher_bits = size - num_lower_bits;
 
-    return get_word(w).extract(b, num_lower_bits) |
-      (get_word(w + 1).extract(0, num_higher_bits) << num_lower_bits);
+    return get_word_internal(w).extract(b, num_lower_bits) |
+      (get_word_internal(w + 1).extract(0, num_higher_bits) << num_lower_bits);
   }
 }
 
@@ -241,17 +241,24 @@ get_num_words() const {
  * get_num_words(), but the return value beyond get_num_words() will always be
  * the same.
  */
-INLINE BitArray::MaskType BitArray::
+INLINE BitArray::WordType BitArray::
 get_word(size_t n) const {
+  return get_word_internal(n).get_word();
+}
+
+/**
+ * Internal implementation of get_word that returns MaskType.
+ */
+INLINE BitArray::MaskType BitArray::
+get_word_internal(size_t n) const {
   nassertr(n >= 0, MaskType::all_off());
   if (n < get_num_words()) {
     return _array[n];
   }
   if (_highest_bits) {
     return MaskType::all_on();
-  } else {
-    return MaskType::all_off();
   }
+  return MaskType::all_off();
 }
 
 /**

+ 3 - 3
panda/src/putil/bitArray.cxx

@@ -103,7 +103,7 @@ has_any_of(int low_bit, int size) const {
   }
   if (b + size <= num_bits_per_word) {
     // The whole thing fits within one word of the array.
-    return get_word(w).has_any_of(b, size);
+    return get_word_internal(w).has_any_of(b, size);
   }
 
   int num_high_bits = num_bits_per_word - b;
@@ -156,7 +156,7 @@ has_all_of(int low_bit, int size) const {
   }
   if (b + size <= num_bits_per_word) {
     // The whole thing fits within one word of the array.
-    return get_word(w).has_all_of(b, size);
+    return get_word_internal(w).has_all_of(b, size);
   }
 
   int num_high_bits = num_bits_per_word - b;
@@ -624,7 +624,7 @@ compare_to(const BitArray &other) const {
 
   // Compare from highest-order to lowest-order word.
   for (int i = num_words - 1; i >= 0; --i) {
-    int compare = get_word(i).compare_to(other.get_word(i));
+    int compare = get_word_internal(i).compare_to(other.get_word_internal(i));
     if (compare != 0) {
       return compare;
     }

+ 5 - 8
panda/src/putil/bitArray.h

@@ -49,9 +49,7 @@ PUBLISHED:
 
   INLINE BitArray();
   BitArray(const SparseArray &from);
-#ifdef HAVE_PYTHON
-  EXTENSION(BitArray(PyObject *init_value));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(BitArray(PyObject *init_value));
 
   INLINE static BitArray all_on();
   INLINE static BitArray all_off();
@@ -91,7 +89,7 @@ PUBLISHED:
   int find_off_range(int size, int low_bit = 0);
 
   INLINE size_t get_num_words() const;
-  INLINE MaskType get_word(size_t n) const;
+  INLINE WordType get_word(size_t n) const;
   INLINE void set_word(size_t n, WordType value);
 
   void invert_in_place();
@@ -133,15 +131,14 @@ PUBLISHED:
   void operator >>= (int shift);
 
   EXTENSION(bool __bool__() const);
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__getstate__() const);
-  EXTENSION(void __setstate__(PyObject *state));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__getstate__() const);
+  PY_EXTENSION(void __setstate__(PyObject *state));
 
 public:
   void generate_hash(ChecksumHashGenerator &hashgen) const;
 
 private:
+  INLINE MaskType get_word_internal(size_t n) const;
   INLINE void copy_on_write();
   void ensure_has_word(int n);
   void normalize();

+ 2 - 4
panda/src/putil/bitMask.h

@@ -126,10 +126,8 @@ PUBLISHED:
   INLINE int get_key() const;
 
   EXTENSION(bool __bool__() const);
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__int__() const);
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__int__() const);
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
 public:
   INLINE void generate_hash(ChecksumHashGenerator &hashgen) const;

+ 1 - 3
panda/src/putil/callbackObject.h

@@ -34,9 +34,7 @@ public:
 PUBLISHED:
   virtual void output(std::ostream &out) const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(static PT(CallbackObject) make(PyObject *function));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(static PT(CallbackObject) make(PyObject *function));
 
 public:
   virtual void do_callback(CallbackData *cbdata);

+ 3 - 7
panda/src/putil/doubleBitMask.h

@@ -39,9 +39,7 @@ PUBLISHED:
   };
 
   constexpr DoubleBitMask() = default;
-#ifdef HAVE_PYTHON
-  EXTENSION(DoubleBitMask(PyObject *init_value));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(DoubleBitMask(PyObject *init_value));
 
   INLINE static DoubleBitMask<BMType> all_on();
   INLINE static DoubleBitMask<BMType> all_off();
@@ -115,10 +113,8 @@ PUBLISHED:
   INLINE void operator >>= (int shift);
 
   EXTENSION(bool __bool__() const);
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__int__() const);
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__int__() const);
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
 
 public:
   INLINE void generate_hash(ChecksumHashGenerator &hashgen) const;

+ 2 - 4
panda/src/putil/sparseArray.h

@@ -118,10 +118,8 @@ PUBLISHED:
   INLINE int get_subrange_end(size_t n) const;
 
   EXTENSION(bool __bool__() const);
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__getstate__() const);
-  EXTENSION(void __setstate__(PyObject *state));
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__getstate__() const);
+  PY_EXTENSION(void __setstate__(PyObject *state));
 
 private:
   void do_add_range(int begin, int end);

+ 2 - 4
panda/src/putil/typedWritable.h

@@ -60,10 +60,8 @@ PUBLISHED:
   INLINE void mark_bam_modified();
   INLINE UpdateSeq get_bam_modified() const;
 
-#ifdef HAVE_PYTHON
-  EXTENSION(PyObject *__reduce__(PyObject *self) const);
-  EXTENSION(PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const);
-#endif // HAVE_PYTHON
+  PY_EXTENSION(PyObject *__reduce__(PyObject *self) const);
+  PY_EXTENSION(PyObject *__reduce_persist__(PyObject *self, PyObject *pickler) const);
 
   INLINE vector_uchar encode_to_bam_stream() const;
   bool encode_to_bam_stream(vector_uchar &data, BamWriter *writer = nullptr) const;

+ 9 - 1
panda/src/testbed/pview.cxx

@@ -355,7 +355,7 @@ main(int argc, char **argv) {
 
   extern char *optarg;
   extern int optind;
-  static const char *optflags = "acls:DVhiLP:";
+  static const char *optflags = "acls:DVhiLP:S";
   int flag = getopt(argc, argv, optflags);
 
   while (flag != EOF) {
@@ -399,6 +399,14 @@ main(int argc, char **argv) {
       break;
     }
 
+    case 'S':
+      if (!PStatClient::connect()) {
+        cerr << "Failed to connect to PStats server." << endl;
+        return 1;
+      }
+      PStatClient::main_tick();
+      break;
+
     case 'V':
       report_version();
       return 1;

+ 5 - 6
panda/src/x11display/x11GraphicsWindow.cxx

@@ -133,12 +133,6 @@ x11GraphicsWindow(GraphicsEngine *engine, GraphicsPipe *pipe,
  */
 x11GraphicsWindow::
 ~x11GraphicsWindow() {
-  if (!_cursor_filenames.empty()) {
-    LightReMutexHolder holder(x11GraphicsPipe::_x_mutex);
-    for (auto item : _cursor_filenames) {
-      XFreeCursor(_display, item.second);
-    }
-  }
 }
 
 /**
@@ -1122,6 +1116,11 @@ close_window() {
     _orig_size_id = -1;
   }
 
+  for (auto item : _cursor_filenames) {
+    XFreeCursor(_display, item.second);
+  }
+  _cursor_filenames.clear();
+
   GraphicsWindow::close_window();
 }
 

+ 37 - 2
pandatool/src/deploy-stub/deploy-stub.c

@@ -82,6 +82,16 @@ static struct _inittab extensions[] = {
 static wchar_t *log_pathw = NULL;
 #endif
 
+#if PY_VERSION_HEX >= 0x030b0000
+typedef struct {
+  const char *name;
+  const unsigned char *code;
+  int size;
+} ModuleDef;
+#else
+typedef struct _frozen ModuleDef;
+#endif
+
 /**
  * Sets the main_dir field of the blobinfo structure, but only if it wasn't
  * already set.
@@ -627,7 +637,7 @@ int wmain(int argc, wchar_t *argv[]) {
 int main(int argc, char *argv[]) {
 #endif
   int retval;
-  struct _frozen *moddef;
+  ModuleDef *moddef;
   const char *log_filename;
   void *blob = NULL;
   log_filename = NULL;
@@ -677,6 +687,9 @@ int main(int argc, char *argv[]) {
 
     // Offset the pointers in the module table using the base mmap address.
     moddef = blobinfo.pointers[0];
+#if PY_VERSION_HEX < 0x030b0000
+    PyImport_FrozenModules = moddef;
+#endif
     while (moddef->name) {
       moddef->name = (char *)((uintptr_t)moddef->name + (uintptr_t)blob);
       if (moddef->code != 0) {
@@ -685,6 +698,24 @@ int main(int argc, char *argv[]) {
       //printf("MOD: %s %p %d\n", moddef->name, (void*)moddef->code, moddef->size);
       moddef++;
     }
+
+    // In Python 3.11, we need to convert this to the new structure format.
+#if PY_VERSION_HEX >= 0x030b0000
+    ModuleDef *moddef_end = moddef;
+    ptrdiff_t num_modules = moddef - (ModuleDef *)blobinfo.pointers[0];
+    struct _frozen *new_moddef = (struct _frozen *)calloc(num_modules + 1, sizeof(struct _frozen));
+    PyImport_FrozenModules = new_moddef;
+    for (moddef = blobinfo.pointers[0]; moddef < moddef_end; ++moddef) {
+      new_moddef->name = moddef->name;
+      new_moddef->code = moddef->code;
+      new_moddef->size = moddef->size < 0 ? -(moddef->size) : moddef->size;
+      new_moddef->is_package = moddef->size < 0;
+      new_moddef->get_code = NULL;
+      new_moddef++;
+    }
+#endif
+  } else {
+    PyImport_FrozenModules = blobinfo.pointers[0];
   }
 
   if (log_filename != NULL) {
@@ -707,12 +738,16 @@ int main(int argc, char *argv[]) {
 #endif
 
   // Run frozen application
-  PyImport_FrozenModules = blobinfo.pointers[0];
   retval = Py_FrozenMain(argc, argv);
 
   fflush(stdout);
   fflush(stderr);
 
+#if PY_VERSION_HEX >= 0x030b0000
+  free((void *)PyImport_FrozenModules);
+  PyImport_FrozenModules = NULL;
+#endif
+
   unmap_blob(blob);
   return retval;
 }

+ 2 - 0
pandatool/src/gtk-stats/gtkStatsChartMenu.h

@@ -32,6 +32,8 @@ public:
   GtkStatsChartMenu(GtkStatsMonitor *monitor, int thread_index);
   ~GtkStatsChartMenu();
 
+  int get_thread_index() const { return _thread_index; }
+
   GtkWidget *get_menu_widget();
   void add_to_menu_bar(GtkWidget *menu_bar, int position);
   void remove_from_menu_bar(GtkWidget *menu_bar);

+ 17 - 0
pandatool/src/gtk-stats/gtkStatsMonitor.cxx

@@ -207,6 +207,23 @@ new_data(int thread_index, int frame_number) {
   }
 }
 
+/**
+ * Called when a thread should be removed from the list of threads.
+ */
+void GtkStatsMonitor::
+remove_thread(int thread_index) {
+  for (ChartMenus::iterator it = _chart_menus.begin(); it != _chart_menus.end(); ++it) {
+    GtkStatsChartMenu *chart_menu = *it;
+    if (chart_menu->get_thread_index() == thread_index) {
+      chart_menu->remove_from_menu_bar(_menu_bar);
+      delete chart_menu;
+      _chart_menus.erase(it);
+      --_next_chart_index;
+      return;
+    }
+  }
+}
+
 /**
  * Called whenever the connection to the client has been lost.  This is a
  * permanent state change.  The monitor should update its display to represent

Vissa filer visades inte eftersom för många filer har ändrats