@@ -47,7 +47,13 @@ def get_shader_stages():
4747 return [
4848 "vs" ,
4949 "ps" ,
50- "cs"
50+ "cs" ,
51+ "rg" ,
52+ "ch" ,
53+ "ah" ,
54+ "mi" ,
55+ "is" ,
56+ "ca"
5157 ]
5258
5359
@@ -92,7 +98,8 @@ def get_bindable_resource_keys():
9298 "RWTexture2DArray" ,
9399 "RWTexture3D" ,
94100 "SamplerState" ,
95- "SamplerComparisonState"
101+ "SamplerComparisonState" ,
102+ "RaytracingAccelerationStructure"
96103 ]
97104
98105
@@ -124,6 +131,7 @@ def get_resource_mappings():
124131 {"category" : "textures" , "identifier" : "RWTexture2D" },
125132 {"category" : "textures" , "identifier" : "RWTexture2DArray" },
126133 {"category" : "textures" , "identifier" : "RWTexture3D" },
134+ {"category" : "acceleration_structures" , "identifier" : "RaytracingAccelerationStructure" },
127135 ]
128136
129137
@@ -134,7 +142,8 @@ def get_resource_categories():
134142 "cbuffers" ,
135143 "structured_buffers" ,
136144 "textures" ,
137- "samplers"
145+ "samplers" ,
146+ "acceleration_structures"
138147 ]
139148
140149
@@ -225,9 +234,10 @@ def get_shader_visibility(vis):
225234 stages = {
226235 "vs" : "Vertex" ,
227236 "ps" : "Fragment" ,
228- "cs" : "Compute"
237+ "cs" : "Compute" ,
229238 }
230- return stages [vis [0 ]]
239+ if vis [0 ] in stages :
240+ return stages [vis [0 ]]
231241 return "All"
232242
233243
@@ -763,6 +773,13 @@ def cross_compile_hlsl_metal(info, src, stage, entry_point, temp_filepath, outpu
763773 return 0 , error_list , output_list
764774
765775
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+
766783# compile a hlsl version 2
767784def compile_shader_hlsl (info , src , stage , entry_point , temp_filepath , output_filepath ):
768785 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
775792 if info .shader_platform == "metal" :
776793 error_code , error_list , output_list = cross_compile_hlsl_metal (info , src , stage , entry_point , temp_filepath , output_filepath )
777794 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 )
779796 cmdline += " " + build_pmfx .get_info ().args
780797 error_code , error_list , output_list = build_pmfx .call_wait_subprocess (cmdline )
781798
@@ -940,19 +957,33 @@ def generate_shader_info(pmfx, entry_point, stage, permute=None):
940957 res += "{}\n " .format (pragma )
941958
942959 # resources input structs, textures, buffers etc
960+ added_resources = []
943961 if len (resources ) > 0 :
944962 res += "// resource declarations\n "
945963 for resource in recursive_resources :
964+ if resource in added_resources :
965+ continue
946966 if recursive_resources [resource ]["depth" ] > 0 :
947967 res += recursive_resources [resource ]["declaration" ] + ";\n "
968+ added_resources .append (resource )
948969
949970 for resource in resources :
971+ if resource in added_resources :
972+ continue
950973 res += resources [resource ]["declaration" ] + ";\n "
974+ added_resources .append (resource )
951975
952976 # extract vs_input (input layout)
953977 if stage == "vs" :
954978 vertex_elements = get_vertex_elements (pmfx , entry_point )
955979
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+
956987 # add fwd function decls
957988 if len (forward_decls ) > 0 :
958989 res += "// function foward declarations\n "
0 commit comments