@@ -878,6 +878,29 @@ def replace_conditional_blocks(source):
878878 return source
879879
880880
881+ def us (v ):
882+ if v == - 1 :
883+ return 65535
884+ return v
885+
886+
887+ def strip_empty_vs_inputs (vs_input , vs_main ):
888+ conditioned = vs_input .replace ("\n " , "" ).replace (";" , "" ).replace (";" , "" ).replace ("}" , "" ).replace ("{" , "" )
889+ tokens = conditioned .split (" " )
890+ for t in tokens :
891+ if t == "" :
892+ tokens .remove (t )
893+ if len (tokens ) == 2 :
894+ # input is empty so remove from vs_main args
895+ vs_input = ""
896+ name = tokens [1 ]
897+ pos = vs_main .find (name )
898+ prev_delim = max (us (vs_main [:pos ].rfind ("," )), us (vs_main [:pos ].rfind ("(" )))
899+ next_delim = pos + min (us (vs_main [pos :].find ("," )), us (vs_main [pos :].find (")" )))
900+ vs_main = vs_main .replace (vs_main [prev_delim :next_delim ], " " )
901+ return vs_input , vs_main
902+
903+
881904def create_vsc_psc (filename , shader_file_text , vs_name , ps_name , technique_name , permutation ):
882905 mf = open (macros_file )
883906 macros_text = mf .read ()
@@ -936,8 +959,12 @@ def create_vsc_psc(filename, shader_file_text, vs_name, ps_name, technique_name,
936959 vs_input_source = find_struct (shader_file_text , "struct " + vs_vertex_input_struct_name )
937960
938961 # evaluate conditional inputs
939- instance_input_source = evaluate_conditional_blocks (instance_input_source , permutation )
940962 vs_input_source = evaluate_conditional_blocks (vs_input_source , permutation )
963+ instance_input_source = evaluate_conditional_blocks (instance_input_source , permutation )
964+
965+ # remove empty inputs
966+ vs_input_source , vs_main = strip_empty_vs_inputs (vs_input_source , vs_main )
967+ instance_input_source , vs_main = strip_empty_vs_inputs (instance_input_source , vs_main )
941968
942969 vs_output_source = find_struct (shader_file_text , "struct " + vs_output_struct_name )
943970 ps_output_source = find_struct (shader_file_text , "struct " + ps_output_struct_name )
0 commit comments