Browse Source

shaderpipeline: Fix build issues on Windows

rdb 1 year ago
parent
commit
f07b0d0106

+ 7 - 0
dtool/src/parser-inc/stdbool.h

@@ -0,0 +1,7 @@
+#ifndef _STDBOOL_H
+#define _STDBOOL_H
+
+#define _Bool bool
+#define __bool_true_false_are_defined 1
+
+#endif

+ 4 - 4
makepanda/makepanda.py

@@ -3931,7 +3931,7 @@ cg_preamble = WriteEmbeddedStringFile('cg_preamble', inputs=[
 ])
 TargetAdd('p3shaderpipeline_cg_preamble.obj', opts=OPTS, input=cg_preamble)
 
-OPTS=['DIR:panda/src/shaderpipeline']
+OPTS=['DIR:panda/src/shaderpipeline', 'SPIRV-TOOLS']
 IGATEFILES=GetDirectoryContents('panda/src/shaderpipeline', ["*.h", "*_composite*.cxx"])
 TargetAdd('libp3shaderpipeline.in', opts=OPTS, input=IGATEFILES)
 TargetAdd('libp3shaderpipeline.in', opts=['IMOD:panda3d.core', 'ILIB:libp3shaderpipeline', 'SRCDIR:panda/src/shaderpipeline'])
@@ -4513,7 +4513,7 @@ if GetTarget() == 'windows':
 #
 
 if GetTarget() == 'windows' and not PkgSkip("DX9"):
-    OPTS=['DIR:panda/src/dxgsg9', 'BUILDING:PANDADX', 'DX9', 'SPIRV-CROSS-HLSL']
+    OPTS=['DIR:panda/src/dxgsg9', 'BUILDING:PANDADX', 'DX9', 'SPIRV-CROSS-HLSL', 'SPIRV-TOOLS']
     TargetAdd('p3dxgsg9_dxGraphicsStateGuardian9.obj', opts=OPTS, input='dxGraphicsStateGuardian9.cxx')
     TargetAdd('p3dxgsg9_composite1.obj', opts=OPTS, input='p3dxgsg9_composite1.cxx')
     OPTS=['DIR:panda/metalibs/pandadx9', 'BUILDING:PANDADX', 'DX9']
@@ -4586,7 +4586,7 @@ TargetAdd('libp3framework.dll', opts=['ADVAPI'])
 #
 
 if not PkgSkip("GL"):
-    OPTS=['DIR:panda/src/glgsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGL', 'GL', 'SPIRV-CROSS-GLSL']
+    OPTS=['DIR:panda/src/glgsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGL', 'GL', 'SPIRV-CROSS-GLSL', 'SPIRV-TOOLS']
     TargetAdd('p3glgsg_config_glgsg.obj', opts=OPTS, input='config_glgsg.cxx')
     TargetAdd('p3glgsg_glgsg.obj', opts=OPTS, input='glgsg.cxx')
 
@@ -4604,7 +4604,7 @@ if not PkgSkip("GLES"):
 #
 
 if not PkgSkip("GLES2"):
-    OPTS=['DIR:panda/src/gles2gsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGLES2', 'GLES2', 'SPIRV-CROSS-GLSL']
+    OPTS=['DIR:panda/src/gles2gsg', 'DIR:panda/src/glstuff', 'BUILDING:PANDAGLES2', 'GLES2', 'SPIRV-CROSS-GLSL', 'SPIRV-TOOLS']
     TargetAdd('p3gles2gsg_config_gles2gsg.obj', opts=OPTS, input='config_gles2gsg.cxx')
     TargetAdd('p3gles2gsg_gles2gsg.obj', opts=OPTS, input='gles2gsg.cxx')
 

+ 2 - 2
panda/src/shaderpipeline/spirVReplaceVariableTypePass.cxx

@@ -208,8 +208,8 @@ transform_function_op(Instruction op) {
 
   case spv::OpSelect:
     // The result type for this op must be the same for both operands.
-    nassertd(_pointer_ids.count(op.args[3]) == _pointer_ids.count(op.args[4]));
-    nassertd(_object_ids.count(op.args[3]) == _object_ids.count(op.args[4]));
+    nassertd(_pointer_ids.count(op.args[3]) == _pointer_ids.count(op.args[4])) {}
+    nassertd(_object_ids.count(op.args[3]) == _object_ids.count(op.args[4])) {}
 
     if (_pointer_ids.count(op.args[3])) {
       Definition &def = _db.modify_definition(op.args[1]);

+ 2 - 2
panda/src/shaderpipeline/spirVTransformPass.I

@@ -116,7 +116,7 @@ INLINE void SpirVTransformPass::
 decorate(uint32_t id, spv::Decoration decoration) {
   nassertv(decoration != spv::DecorationLocation);
   _new_annotations.insert(_new_annotations.end(),
-    {spv::OpDecorate | (3 << spv::WordCountShift), id, decoration});
+    {spv::OpDecorate | (3 << spv::WordCountShift), id, (uint32_t)decoration});
 }
 
 /**
@@ -125,7 +125,7 @@ decorate(uint32_t id, spv::Decoration decoration) {
 INLINE void SpirVTransformPass::
 decorate(uint32_t id, spv::Decoration decoration, uint32_t value) {
   _new_annotations.insert(_new_annotations.end(),
-    {spv::OpDecorate | (4 << spv::WordCountShift), id, decoration, value});
+    {spv::OpDecorate | (4 << spv::WordCountShift), id, (uint32_t)decoration, value});
 
   if (decoration == spv::DecorationLocation) {
     _db.modify_definition(id)._location = (int)value;

+ 1 - 3
panda/src/shaderpipeline/spirv.hpp

@@ -4005,9 +4005,7 @@ inline const char* NamedMaximumNumberOfRegistersToString(NamedMaximumNumberOfReg
 }
 
 inline const char* FPEncodingToString(FPEncoding value) {
-    switch (value) {
-    default: return "Unknown";
-    }
+    return "Unknown";
 }
 
 inline const char* OpToString(Op value) {