@@ -470,6 +470,11 @@ def validate_shader_hlsl(shader, force_no_external_validation, paths):
470470 test_glslang = False
471471 if '.task' in shader or '.mesh' in shader :
472472 test_glslang = False
473+ if shader_is_library (shader ):
474+ # Library HLSL output has no entry point; glslangValidator's -e main
475+ # would fail. Skip the round-trip — the output is meant to be
476+ # included by HLSL/GLSL source rather than compiled standalone.
477+ test_glslang = False
473478
474479 hlsl_args = [paths .glslang , '--amb' , '-e' , 'main' , '-D' , '--target-env' , 'vulkan1.1' , '-V' , shader ]
475480 if '.sm30.' in shader :
@@ -522,7 +527,12 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati
522527 spirv_16 = '.spv16.' in shader
523528 spirv_14 = '.spv14.' in shader
524529
525- if spirv_16 :
530+ if shader_is_library (shader ):
531+ # Library modules use the Linkage capability, which is rejected
532+ # by Vulkan target envs. Use a universal/spv target instead.
533+ spirv_env = 'spv1.5'
534+ glslang_env = 'spirv1.5'
535+ elif spirv_16 :
526536 spirv_env = 'spv1.6'
527537 glslang_env = 'vulkan1.3'
528538 elif spirv_14 :
@@ -551,7 +561,14 @@ def cross_compile_hlsl(shader, spirv, opt, force_no_external_validation, iterati
551561
552562 sm = shader_to_sm (shader )
553563
554- hlsl_args = [spirv_cross_path , '--entry' , 'main' , '--output' , hlsl_path , spirv_path , '--hlsl-enable-compat' , '--hlsl' , '--shader-model' , sm , '--iterations' , str (iterations )]
564+ # Library SPIR-V modules (e.g. dxc -T lib_6_*) have no OpEntryPoint;
565+ # skip the --entry flag for those so spirv-cross does not try to
566+ # select an entry point that does not exist.
567+ is_library = shader_is_library (shader )
568+ hlsl_args = [spirv_cross_path ]
569+ if not is_library :
570+ hlsl_args += ['--entry' , 'main' ]
571+ hlsl_args += ['--output' , hlsl_path , spirv_path , '--hlsl-enable-compat' , '--hlsl' , '--shader-model' , sm , '--iterations' , str (iterations )]
555572 if '.line.' in shader :
556573 hlsl_args .append ('--emit-line-directives' )
557574 if '.flatten.' in shader :
@@ -845,6 +862,12 @@ def shader_is_eliminate_dead_variables(shader):
845862def shader_is_spirv (shader ):
846863 return '.asm.' in shader
847864
865+ def shader_is_library (shader ):
866+ # SPIR-V library module: no OpEntryPoint, exports declared via
867+ # OpDecorate ... LinkageAttributes ... Export. Recognised by the
868+ # `.lib` filename suffix (e.g. foo.asm.lib).
869+ return shader .endswith ('.lib' )
870+
848871def shader_is_invalid_spirv (shader ):
849872 return '.invalid.' in shader
850873
0 commit comments