@@ -47,7 +47,13 @@ def get_shader_stages():
47
47
return [
48
48
"vs" ,
49
49
"ps" ,
50
- "cs"
50
+ "cs" ,
51
+ "rg" ,
52
+ "ch" ,
53
+ "ah" ,
54
+ "mi" ,
55
+ "is" ,
56
+ "ca"
51
57
]
52
58
53
59
@@ -92,7 +98,8 @@ def get_bindable_resource_keys():
92
98
"RWTexture2DArray" ,
93
99
"RWTexture3D" ,
94
100
"SamplerState" ,
95
- "SamplerComparisonState"
101
+ "SamplerComparisonState" ,
102
+ "RaytracingAccelerationStructure"
96
103
]
97
104
98
105
@@ -124,6 +131,7 @@ def get_resource_mappings():
124
131
{"category" : "textures" , "identifier" : "RWTexture2D" },
125
132
{"category" : "textures" , "identifier" : "RWTexture2DArray" },
126
133
{"category" : "textures" , "identifier" : "RWTexture3D" },
134
+ {"category" : "acceleration_structures" , "identifier" : "RaytracingAccelerationStructure" },
127
135
]
128
136
129
137
@@ -134,7 +142,8 @@ def get_resource_categories():
134
142
"cbuffers" ,
135
143
"structured_buffers" ,
136
144
"textures" ,
137
- "samplers"
145
+ "samplers" ,
146
+ "acceleration_structures"
138
147
]
139
148
140
149
@@ -225,9 +234,10 @@ def get_shader_visibility(vis):
225
234
stages = {
226
235
"vs" : "Vertex" ,
227
236
"ps" : "Fragment" ,
228
- "cs" : "Compute"
237
+ "cs" : "Compute" ,
229
238
}
230
- return stages [vis [0 ]]
239
+ if vis [0 ] in stages :
240
+ return stages [vis [0 ]]
231
241
return "All"
232
242
233
243
@@ -763,6 +773,13 @@ def cross_compile_hlsl_metal(info, src, stage, entry_point, temp_filepath, outpu
763
773
return 0 , error_list , output_list
764
774
765
775
776
+ # convert satage to correct hlsl profile
777
+ def hlsl_stage (stage ):
778
+ if stage in ["rg" , "ch" , "ah" , "mi" ]:
779
+ return "lib"
780
+ return stage
781
+
782
+
766
783
# compile a hlsl version 2
767
784
def compile_shader_hlsl (info , src , stage , entry_point , temp_filepath , output_filepath ):
768
785
exe = os .path .join (info .tools_dir , "bin" , "dxc" , "dxc" )
@@ -775,7 +792,7 @@ def compile_shader_hlsl(info, src, stage, entry_point, temp_filepath, output_fil
775
792
if info .shader_platform == "metal" :
776
793
error_code , error_list , output_list = cross_compile_hlsl_metal (info , src , stage , entry_point , temp_filepath , output_filepath )
777
794
elif info .shader_platform == "hlsl" :
778
- cmdline = "{} -T {}_{} -E {} -Fo {} {}" .format (exe , stage , info .shader_version , entry_point , output_filepath , temp_filepath )
795
+ cmdline = "{} -T {}_{} -E {} -Fo {} {}" .format (exe , hlsl_stage ( stage ) , info .shader_version , entry_point , output_filepath , temp_filepath )
779
796
cmdline += " " + build_pmfx .get_info ().args
780
797
error_code , error_list , output_list = build_pmfx .call_wait_subprocess (cmdline )
781
798
@@ -940,19 +957,33 @@ def generate_shader_info(pmfx, entry_point, stage, permute=None):
940
957
res += "{}\n " .format (pragma )
941
958
942
959
# resources input structs, textures, buffers etc
960
+ added_resources = []
943
961
if len (resources ) > 0 :
944
962
res += "// resource declarations\n "
945
963
for resource in recursive_resources :
964
+ if resource in added_resources :
965
+ continue
946
966
if recursive_resources [resource ]["depth" ] > 0 :
947
967
res += recursive_resources [resource ]["declaration" ] + ";\n "
968
+ added_resources .append (resource )
948
969
949
970
for resource in resources :
971
+ if resource in added_resources :
972
+ continue
950
973
res += resources [resource ]["declaration" ] + ";\n "
974
+ added_resources .append (resource )
951
975
952
976
# extract vs_input (input layout)
953
977
if stage == "vs" :
954
978
vertex_elements = get_vertex_elements (pmfx , entry_point )
955
979
980
+ # typedefs
981
+ typedef_decls = cgu .find_typedef_decls (pmfx ["source" ])
982
+ if len (typedef_decls ) > 0 :
983
+ res += "// typedefs\n "
984
+ for typedef_decl in typedef_decls :
985
+ res += typedef_decl + ";\n "
986
+
956
987
# add fwd function decls
957
988
if len (forward_decls ) > 0 :
958
989
res += "// function foward declarations\n "
0 commit comments