@@ -21,7 +21,8 @@ class BuildInfo:
21
21
metal_min_os = "" # iOS (9.0 - 13.0), macOS (10.11 - 10.15)
22
22
debug = False # generate shader with debug info
23
23
inputs = [] # array of input files or directories
24
- extensions = [] # array of shader extension currently for glsl
24
+ extensions = [] # array of shader extension currently for glsl/gles
25
+ nvn_extensions = [] # array of shader extensions for nvn/glsl
25
26
root_dir = "" # cwd dir to run from
26
27
build_config = "" # json contents of build_config.json
27
28
pmfx_dir = "" # location of pmfx
@@ -120,44 +121,48 @@ def parse_args():
120
121
_info .inputs .append (sys .argv [j ])
121
122
j = j + 1
122
123
i = j
123
- if sys .argv [i ] == "-o" :
124
+ elif sys .argv [i ] == "-o" :
124
125
_info .output_dir = sys .argv [i + 1 ]
125
- if sys .argv [i ] == "-h" :
126
+ elif sys .argv [i ] == "-h" :
126
127
_info .struct_dir = sys .argv [i + 1 ]
127
- if sys .argv [i ] == "-t" :
128
+ elif sys .argv [i ] == "-t" :
128
129
_info .temp_dir = sys .argv [i + 1 ]
129
- if sys .argv [i ] == "-source" :
130
+ elif sys .argv [i ] == "-source" :
130
131
_info .compiled = False
131
- if sys .argv [i ] == "-cbuffer_offset" :
132
+ elif sys .argv [i ] == "-cbuffer_offset" :
132
133
_info .cbuffer_offset = sys .argv [i + 1 ]
133
- if sys .argv [i ] == "-texture_offset" :
134
+ elif sys .argv [i ] == "-texture_offset" :
134
135
_info .cbuffer_offset = sys .argv [i + 1 ]
135
- if sys .argv [i ] == "-stage_in" :
136
+ elif sys .argv [i ] == "-stage_in" :
136
137
_info .stage_in = sys .argv [i + 1 ]
137
- if sys .argv [i ] == "-v_flip" :
138
+ elif sys .argv [i ] == "-v_flip" :
138
139
_info .v_flip = True
139
- if sys .argv [i ] == "-d" :
140
+ elif sys .argv [i ] == "-d" :
140
141
_info .debug = False
141
- if sys .argv [i ] == "-metal_min_os" :
142
+ elif sys .argv [i ] == "-metal_min_os" :
142
143
_info .metal_min_os = sys .argv [i + 1 ]
143
- if sys .argv [i ] == "-metal_sdk" :
144
+ elif sys .argv [i ] == "-metal_sdk" :
144
145
_info .metal_sdk = sys .argv [i + 1 ]
145
- if sys .argv [i ] == "-nvn_exe" :
146
+ elif sys .argv [i ] == "-nvn_exe" :
146
147
_info .nvn_exe = sys .argv [i + 1 ]
147
- if sys .argv [i ] == "-extensions" :
148
+ elif sys .argv [i ] == "-extensions" :
148
149
j = i + 1
149
150
while j < len (sys .argv ) and sys .argv [j ][0 ] != '-' :
150
151
_info .extensions .append (sys .argv [j ])
151
152
j = j + 1
152
153
i = j
154
+ elif sys .argv [i ] == "-nvn_extensions" :
155
+ j = i + 1
156
+ while j < len (sys .argv ) and sys .argv [j ][0 ] != '-' :
157
+ _info .nvn_extensions .append (sys .argv [j ])
158
+ j = j + 1
159
+ i = j
153
160
required = [
154
161
"-shader_platform" ,
155
162
"-i" ,
156
163
"-o" ,
157
164
"-t"
158
165
]
159
- if _info .shader_platform == "metal" :
160
- required .append ("-metal_sdk" )
161
166
if _info .shader_platform == "nvm" :
162
167
required .append ("-nvn_exe" )
163
168
missing = False
@@ -167,7 +172,8 @@ def parse_args():
167
172
missing = True
168
173
if missing :
169
174
print ("exit" )
170
- sys .exit (1 )
175
+ sys .exit (1 )
176
+
171
177
172
178
173
179
# display help for args
@@ -182,9 +188,10 @@ def display_help():
182
188
print (" metal: 2.0 (default)" )
183
189
print (" nvn: (glsl)" )
184
190
print (" -metal_sdk [metal only] <iphoneos, macosx, appletvos>" )
185
- print (" -metal_min_os (optional) <9.0 - 13.0 (ios), 10.11 - 10.15 (macos)>" )
191
+ print (" -metal_min_os (optional) [metal only] <9.0 - 13.0 (ios), 10.11 - 10.15 (macos)>" )
186
192
print (" -nvn_exe [nvn only] <path to execulatble that can compile glsl to nvn glslc>" )
187
- print (" -extensions (optional) <list of glsl extension strings separated by spaces>" )
193
+ print (" -extensions (optional) [glsl/gles only] <list of glsl extension strings separated by spaces>" )
194
+ print (" -nvn_extensions (optional) [nvn only] <list of nvn glsl extension strings separated by spaces>" )
188
195
print (" -i <list of input files or directories separated by spaces>" )
189
196
print (" -o <output dir for shaders>" )
190
197
print (" -t <output dir for temp files>" )
@@ -198,7 +205,7 @@ def display_help():
198
205
print (" specifies an offset applied to cbuffer locations to avoid collisions with vertex buffers" )
199
206
print (" -texture_offset (optional) [vulkan only] (default 32) " )
200
207
print (" specifies an offset applied to texture locations to avoid collisions with buffers" )
201
- print (" -v_flip (optional) (inserts glsl uniform to conditionally flip verts in the y axis)" )
208
+ print (" -v_flip (optional) [glsl only] (inserts glsl uniform to conditionally flip verts in the y axis)" )
202
209
sys .stdout .flush ()
203
210
sys .exit (0 )
204
211
@@ -1761,6 +1768,13 @@ def compile_glsl(_info, pmfx_name, _tp, _shader):
1761
1768
shader_source += "#define PMFX_GLES_COMPUTE\n "
1762
1769
else :
1763
1770
shader_source += "#version " + _tp .shader_version + " core\n "
1771
+ # extensions
1772
+ for ext in _info .extensions :
1773
+ shader_source += "#extension " + ext + " : require\n "
1774
+ shader_source += "#define PMFX_" + ext + " 1\n "
1775
+ for ext in _info .nvn_extensions :
1776
+ shader_source += "#extension " + ext + " : enable\n "
1777
+ shader_source += "#define PMFX_" + ext + " 1\n "
1764
1778
shader_source += "#define GLSL\n "
1765
1779
if binding_points :
1766
1780
shader_source += "#define PMFX_BINDING_POINTS\n "
@@ -2885,6 +2899,7 @@ def parse_pmfx(file, root):
2885
2899
else :
2886
2900
print (output_name + " failed to compile" , flush = True )
2887
2901
pmfx_output_info ["failures" ][c .pmfx_name ] = True
2902
+ _info .error_code = 1
2888
2903
for out in c .output_list :
2889
2904
print (out , flush = True )
2890
2905
for err in c .error_list :
@@ -3033,7 +3048,7 @@ def build_executable():
3033
3048
# zip
3034
3049
exe_names = {
3035
3050
"win64" : "Windows-x64" ,
3036
- "osx" : "macOS-universal " ,
3037
- "linux" : "Linux-aarch64 "
3051
+ "osx" : "macOS-x64 " ,
3052
+ "linux" : "Linux-x64 "
3038
3053
}
3039
3054
shutil .make_archive ("dist/" + exe_names [platform ], 'zip' , "dist/{}" .format (platform ))
0 commit comments