Kaynağa Gözat

shaderpipeline: Fix issues with VOID definition on Windows

rdb 1 hafta önce
ebeveyn
işleme
a430271758

+ 2 - 0
panda/src/display/shaderInputBinding_impls.cxx

@@ -26,6 +26,8 @@
 #include "pointLight.h"
 #include "sphereLight.h"
 
+#undef VOID
+
 using std::string;
 using State = ShaderInputBinding::State;
 

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

@@ -38,6 +38,8 @@
 #define SPIRV_CROSS_EXCEPTIONS_TO_ASSERTIONS
 #include <spirv_cross/spirv_glsl.hpp>
 
+#undef VOID
+
 using std::dec;
 using std::hex;
 using std::max;

+ 9 - 0
panda/src/gobj/shaderType.cxx

@@ -13,6 +13,11 @@
 
 #include "shaderType.h"
 
+#ifdef _WIN32
+#pragma push_macro("VOID")
+#undef VOID
+#endif
+
 static const char *texture_type_suffixes[] = {
   "1D", "2D", "3D", "2DArray", "Cube", "Buffer", "CubeArray", "1DArray",
 };
@@ -1546,4 +1551,8 @@ make_from_bam(const FactoryParams &params) {
   return type;
 }
 
+#ifdef _WIN32
+#pragma pop_macro("VOID")
+#endif
+
 #endif  // CPPPARSER

+ 8 - 2
panda/src/gobj/shaderType.h

@@ -20,8 +20,10 @@
 #include "stl_compares.h"
 #include "texture.h"
 
-// Defined in Windows headers, conflicts with VOID definition below
+#ifdef _WIN32
+#pragma push_macro("VOID")
 #undef VOID
+#endif
 
 /**
  * This represents a single type as defined in a shader.  There is only ever a
@@ -87,7 +89,7 @@ PUBLISHED:
   // Fundamental types, as singletons, defined as upper-case because they are
   // essentially enum-like constants (ie. ShaderType.FLOAT from Python).
 #ifdef CPPPARSER
-  static const ShaderType *const VOID;
+  //static const ShaderType *const VOID;
   static const ShaderType::Scalar *const BOOL;
   static const ShaderType::Scalar *const INT;
   static const ShaderType::Scalar *const UINT;
@@ -692,4 +694,8 @@ private:
 #include "shaderType.I"
 #endif
 
+#ifdef _WIN32
+#pragma pop_macro("VOID")
+#endif
+
 #endif  // SHADERTYPE_H

+ 2 - 2
tests/display/test_glsl_types.py

@@ -30,7 +30,7 @@ def compile_struct(members, layout=None):
 
 
 def test_glsl_scalar_singletons():
-    assert isinstance(ShaderType.VOID, ShaderType)
+    #assert isinstance(ShaderType.VOID, ShaderType)
     assert isinstance(ShaderType.BOOL, ShaderType.Scalar)
     assert isinstance(ShaderType.INT, ShaderType.Scalar)
     assert isinstance(ShaderType.UINT, ShaderType.Scalar)
@@ -128,7 +128,7 @@ def test_glsl_types_std140():
 
 
 def test_glsl_scalar_str():
-    assert str(ShaderType.VOID) == "void"
+    #assert str(ShaderType.VOID) == "void"
     assert str(ShaderType.BOOL) == "bool"
     assert str(ShaderType.INT) == "int"
     assert str(ShaderType.UINT) == "uint"