Browse Source

Merge branch 'master' into webgl-port

rdb 4 years ago
parent
commit
674fe1d526

+ 4 - 1
direct/src/dist/FreezeTool.py

@@ -1751,7 +1751,7 @@ class Freezer:
         return target
         return target
 
 
     def generateRuntimeFromStub(self, target, stub_file, use_console, fields={},
     def generateRuntimeFromStub(self, target, stub_file, use_console, fields={},
-                                log_append=False):
+                                log_append=False, log_filename_strftime=False):
         self.__replacePaths()
         self.__replacePaths()
 
 
         # We must have a __main__ module to make an exe file.
         # We must have a __main__ module to make an exe file.
@@ -1934,9 +1934,12 @@ class Freezer:
             # A null entry marks the end of the module table.
             # A null entry marks the end of the module table.
             blob += struct.pack(entry_layout, 0, 0, 0)
             blob += struct.pack(entry_layout, 0, 0, 0)
 
 
+            # These flags should match the enum in deploy-stub.c
             flags = 0
             flags = 0
             if log_append:
             if log_append:
                 flags |= 1
                 flags |= 1
+            if log_filename_strftime:
+                flags |= 2
 
 
             # Compose the header we will be writing to the stub, to tell it
             # Compose the header we will be writing to the stub, to tell it
             # where to find the module data blob, as well as other variables.
             # where to find the module data blob, as well as other variables.

+ 6 - 1
direct/src/dist/commands.py

@@ -186,6 +186,7 @@ class build_apps(setuptools.Command):
         self.extra_prc_data = ''
         self.extra_prc_data = ''
         self.default_prc_dir = None
         self.default_prc_dir = None
         self.log_filename = None
         self.log_filename = None
+        self.log_filename_strftime = True
         self.log_append = False
         self.log_append = False
         self.requirements_path = os.path.join(os.getcwd(), 'requirements.txt')
         self.requirements_path = os.path.join(os.getcwd(), 'requirements.txt')
         self.use_optimized_wheels = True
         self.use_optimized_wheels = True
@@ -709,6 +710,10 @@ class build_apps(setuptools.Command):
             else:
             else:
                 temp_file = None
                 temp_file = None
 
 
+            use_strftime = self.log_filename_strftime
+            if not self.log_filename or '%' not in self.log_filename:
+                use_strftime = False
+
             freezer.generateRuntimeFromStub(target_path, stub_file, use_console, {
             freezer.generateRuntimeFromStub(target_path, stub_file, use_console, {
                 'prc_data': prcexport if self.embed_prc_data else None,
                 'prc_data': prcexport if self.embed_prc_data else None,
                 'default_prc_dir': self.default_prc_dir,
                 'default_prc_dir': self.default_prc_dir,
@@ -721,7 +726,7 @@ class build_apps(setuptools.Command):
                 'prc_executable_args_envvar': None,
                 'prc_executable_args_envvar': None,
                 'main_dir': None,
                 'main_dir': None,
                 'log_filename': self.expand_path(self.log_filename, platform),
                 'log_filename': self.expand_path(self.log_filename, platform),
-            }, self.log_append)
+            }, self.log_append, use_strftime)
             stub_file.close()
             stub_file.close()
 
 
             if temp_file:
             if temp_file:

+ 44 - 2
panda/src/glstuff/glGeomMunger_src.cxx

@@ -13,6 +13,12 @@
 
 
 #include "dcast.h"
 #include "dcast.h"
 
 
+#ifdef OPENGLES
+#include <atomic>
+
+static std::atomic_flag warned_downgrade_float64 = ATOMIC_FLAG_INIT;
+#endif
+
 TypeHandle CLP(GeomMunger)::_type_handle;
 TypeHandle CLP(GeomMunger)::_type_handle;
 
 
 ALLOC_DELETED_CHAIN_DEF(CLP(GeomMunger));
 ALLOC_DELETED_CHAIN_DEF(CLP(GeomMunger));
@@ -102,6 +108,7 @@ munge_format_impl(const GeomVertexFormat *orig,
       (InternalName::get_vertex(), 3, NT_int16,
       (InternalName::get_vertex(), 3, NT_int16,
        C_point, vertex_type->get_start(), vertex_type->get_column_alignment());
        C_point, vertex_type->get_start(), vertex_type->get_column_alignment());
   }
   }
+#endif  // !OPENGLES
 
 
   // Convert packed formats that OpenGL may not understand.
   // Convert packed formats that OpenGL may not understand.
   for (size_t i = 0; i < orig->get_num_columns(); ++i) {
   for (size_t i = 0; i < orig->get_num_columns(); ++i) {
@@ -123,8 +130,25 @@ munge_format_impl(const GeomVertexFormat *orig,
                                column->get_contents(), column->get_start(),
                                column->get_contents(), column->get_start(),
                                column->get_column_alignment());
                                column->get_column_alignment());
     }
     }
+#ifdef OPENGLES
+    else if (column->get_numeric_type() == NT_float64) {
+      if (!warned_downgrade_float64.test_and_set()) {
+        GLCAT.warning()
+          << "OpenGL ES does not support 64-bit floats; converting vertex data to 32-bit.\n";
+#ifndef NDEBUG
+        if (vertices_float64) {
+          GLCAT.warning()
+            << "You may want to disable vertices-float64 for better performance.\n";
+        }
+#endif
+      }
+      PT(GeomVertexArrayFormat) array_format = new_format->modify_array(array);
+      array_format->add_column(column->get_name(), column->get_num_components(),
+                               NT_float32, column->get_contents(),
+                               column->get_start(), column->get_column_alignment());
+    }
+#endif
   }
   }
-#endif  // !OPENGLES
 
 
   const GeomVertexColumn *color_type = orig->get_color_column();
   const GeomVertexColumn *color_type = orig->get_color_column();
   if (color_type != nullptr &&
   if (color_type != nullptr &&
@@ -288,6 +312,7 @@ premunge_format_impl(const GeomVertexFormat *orig) {
       (InternalName::get_vertex(), 3, NT_int16,
       (InternalName::get_vertex(), 3, NT_int16,
        C_point, vertex_type->get_start(), vertex_type->get_column_alignment());
        C_point, vertex_type->get_start(), vertex_type->get_column_alignment());
   }
   }
+#endif  // !OPENGLES
 
 
   // Convert packed formats that OpenGL may not understand.
   // Convert packed formats that OpenGL may not understand.
   for (size_t i = 0; i < orig->get_num_columns(); ++i) {
   for (size_t i = 0; i < orig->get_num_columns(); ++i) {
@@ -309,8 +334,25 @@ premunge_format_impl(const GeomVertexFormat *orig) {
                                column->get_contents(), column->get_start(),
                                column->get_contents(), column->get_start(),
                                column->get_column_alignment());
                                column->get_column_alignment());
     }
     }
+#ifdef OPENGLES
+    else if (column->get_numeric_type() == NT_float64) {
+      if (!warned_downgrade_float64.test_and_set()) {
+        GLCAT.warning()
+          << "OpenGL ES does not support 64-bit floats; converting vertex data to 32-bit.\n";
+#ifndef NDEBUG
+        if (vertices_float64) {
+          GLCAT.warning()
+            << "You may want to disable vertices-float64 for better performance.\n";
+        }
+#endif
+      }
+      PT(GeomVertexArrayFormat) array_format = new_format->modify_array(array);
+      array_format->add_column(column->get_name(), column->get_num_components(),
+                               NT_float32, column->get_contents(),
+                               column->get_start(), column->get_column_alignment());
+    }
+#endif
   }
   }
-#endif  // !OPENGLES
 
 
   CPT(GeomVertexFormat) format = GeomVertexFormat::register_format(new_format);
   CPT(GeomVertexFormat) format = GeomVertexFormat::register_format(new_format);
 
 

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

@@ -179,10 +179,11 @@ static const string default_vshader =
   "varying lowp vec4 color;\n"
   "varying lowp vec4 color;\n"
 #endif
 #endif
   "uniform mat4 p3d_ModelViewProjectionMatrix;\n"
   "uniform mat4 p3d_ModelViewProjectionMatrix;\n"
+  "uniform mat4 p3d_TextureMatrix;\n"
   "uniform vec4 p3d_ColorScale;\n"
   "uniform vec4 p3d_ColorScale;\n"
   "void main(void) {\n"
   "void main(void) {\n"
   "  gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n"
   "  gl_Position = p3d_ModelViewProjectionMatrix * p3d_Vertex;\n"
-  "  texcoord = p3d_MultiTexCoord0;\n"
+  "  texcoord = (p3d_TextureMatrix * vec4(p3d_MultiTexCoord0.x, p3d_MultiTexCoord0.y, 0, 1)).xy;\n"
   "  color = p3d_Color * p3d_ColorScale;\n"
   "  color = p3d_Color * p3d_ColorScale;\n"
   "}\n";
   "}\n";
 
 
@@ -203,10 +204,11 @@ static const string default_vshader_fp64 =
   "out vec4 color;\n"
   "out vec4 color;\n"
   "uniform mat4 p3d_ModelViewMatrix;\n"
   "uniform mat4 p3d_ModelViewMatrix;\n"
   "uniform mat4 p3d_ProjectionMatrix;\n"
   "uniform mat4 p3d_ProjectionMatrix;\n"
+  "uniform mat4 p3d_TextureMatrix;\n"
   "uniform vec4 p3d_ColorScale;\n"
   "uniform vec4 p3d_ColorScale;\n"
   "void main(void) {\n" // Apply proj & modelview in two steps, more precise
   "void main(void) {\n" // Apply proj & modelview in two steps, more precise
   "  gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n"
   "  gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n"
-  "  texcoord = vec2(p3d_MultiTexCoord0);\n"
+  "  texcoord = (p3d_TextureMatrix * vec4(p3d_MultiTexCoord0.x, p3d_MultiTexCoord0.y, 0, 1)).xy;\n"
   "  color = p3d_Color * p3d_ColorScale;\n"
   "  color = p3d_Color * p3d_ColorScale;\n"
   "}\n";
   "}\n";
 
 
@@ -220,10 +222,11 @@ static const string default_vshader_fp64_gl41 =
   "out vec4 color;\n"
   "out vec4 color;\n"
   "uniform mat4 p3d_ModelViewMatrix;\n"
   "uniform mat4 p3d_ModelViewMatrix;\n"
   "uniform mat4 p3d_ProjectionMatrix;\n"
   "uniform mat4 p3d_ProjectionMatrix;\n"
+  "uniform mat4 p3d_TextureMatrix;\n"
   "uniform vec4 p3d_ColorScale;\n"
   "uniform vec4 p3d_ColorScale;\n"
   "void main(void) {\n" // Apply proj & modelview in two steps, more precise
   "void main(void) {\n" // Apply proj & modelview in two steps, more precise
   "  gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n"
   "  gl_Position = vec4(dmat4(p3d_ProjectionMatrix) * (dmat4(p3d_ModelViewMatrix) * dvec4(p3d_Vertex, 1)));\n"
-  "  texcoord = vec2(p3d_MultiTexCoord0);\n"
+  "  texcoord = (p3d_TextureMatrix * vec4(p3d_MultiTexCoord0.x, p3d_MultiTexCoord0.y, 0, 1)).xy;\n"
   "  color = p3d_Color * p3d_ColorScale;\n"
   "  color = p3d_Color * p3d_ColorScale;\n"
   "}\n";
   "}\n";
 #endif
 #endif

+ 9 - 0
pandatool/src/deploy-stub/deploy-stub.c

@@ -33,6 +33,7 @@
 /* Stored in the flags field of the blobinfo structure below. */
 /* Stored in the flags field of the blobinfo structure below. */
 enum Flags {
 enum Flags {
   F_log_append = 1,
   F_log_append = 1,
+  F_log_filename_strftime = 2,
 };
 };
 
 
 /* Define an exposed symbol where we store the offset to the module data. */
 /* Define an exposed symbol where we store the offset to the module data. */
@@ -671,6 +672,14 @@ int main(int argc, char *argv[]) {
   }
   }
 
 
   if (log_filename != NULL) {
   if (log_filename != NULL) {
+    char log_filename_buf[4096];
+    if (blobinfo.flags & F_log_filename_strftime) {
+      log_filename_buf[0] = 0;
+      time_t now = time(NULL);
+      if (strftime(log_filename_buf, sizeof(log_filename_buf), log_filename, localtime(&now)) > 0) {
+        log_filename = log_filename_buf;
+      }
+    }
     setup_logging(log_filename, (blobinfo.flags & F_log_append) != 0);
     setup_logging(log_filename, (blobinfo.flags & F_log_append) != 0);
   }
   }