Added mesh and task shader support to shader compilation scripts

Simplified file extension checks
Fixes #1143
This commit is contained in:
Sascha Willems 2024-06-23 20:09:05 +02:00
parent d868ac8277
commit 4d2117d3d9
2 changed files with 13 additions and 2 deletions

View file

@ -30,12 +30,14 @@ def findGlslang():
sys.exit("Could not find glslangvalidator executable on PATH, and was not specified with --glslang") sys.exit("Could not find glslangvalidator executable on PATH, and was not specified with --glslang")
file_extensions = tuple([".vert", ".frag", ".comp", ".geom", ".tesc", ".tese", ".rgen", ".rchit", ".rmiss", ".mesh", ".task"])
glslang_path = findGlslang() glslang_path = findGlslang()
dir_path = os.path.dirname(os.path.realpath(__file__)) dir_path = os.path.dirname(os.path.realpath(__file__))
dir_path = dir_path.replace('\\', '/') dir_path = dir_path.replace('\\', '/')
for root, dirs, files in os.walk(dir_path): for root, dirs, files in os.walk(dir_path):
for file in files: for file in files:
if file.endswith(".vert") or file.endswith(".frag") or file.endswith(".comp") or file.endswith(".geom") or file.endswith(".tesc") or file.endswith(".tese") or file.endswith(".rgen") or file.endswith(".rchit") or file.endswith(".rmiss"): if file.endswith(file_extensions):
input_file = os.path.join(root, file) input_file = os.path.join(root, file)
output_file = input_file + ".spv" output_file = input_file + ".spv"
@ -50,6 +52,9 @@ for root, dirs, files in os.walk(dir_path):
# Same goes for samples that use ray queries # Same goes for samples that use ray queries
if root.endswith("rayquery") and file.endswith(".frag"): if root.endswith("rayquery") and file.endswith(".frag"):
add_params = add_params + " --target-env vulkan1.2" add_params = add_params + " --target-env vulkan1.2"
# Mesh and task shader also require different settings
if file.endswith(".mesh") or file.endswith(".task"):
add_params = add_params + " --target-env spirv1.4"
res = subprocess.call("%s -V %s -o %s %s" % (glslang_path, input_file, output_file, add_params), shell=True) res = subprocess.call("%s -V %s -o %s %s" % (glslang_path, input_file, output_file, add_params), shell=True)
if res != 0: if res != 0:

View file

@ -29,12 +29,14 @@ def findDXC():
sys.exit("Could not find DXC executable on PATH, and was not specified with --dxc") sys.exit("Could not find DXC executable on PATH, and was not specified with --dxc")
file_extensions = tuple([".vert", ".frag", ".comp", ".geom", ".tesc", ".tese", ".rgen", ".rchit", ".rmiss", ".mesh", ".task"])
dxc_path = findDXC() dxc_path = findDXC()
dir_path = os.path.dirname(os.path.realpath(__file__)) dir_path = os.path.dirname(os.path.realpath(__file__))
dir_path = dir_path.replace('\\', '/') dir_path = dir_path.replace('\\', '/')
for root, dirs, files in os.walk(dir_path): for root, dirs, files in os.walk(dir_path):
for file in files: for file in files:
if file.endswith(".vert") or file.endswith(".frag") or file.endswith(".comp") or file.endswith(".geom") or file.endswith(".tesc") or file.endswith(".tese") or file.endswith(".rgen") or file.endswith(".rchit") or file.endswith(".rmiss") or file.endswith(".mesh") : if file.endswith(file_extensions):
hlsl_file = os.path.join(root, file) hlsl_file = os.path.join(root, file)
spv_out = hlsl_file + ".spv" spv_out = hlsl_file + ".spv"
@ -62,6 +64,10 @@ for root, dirs, files in os.walk(dir_path):
target='-fspv-target-env=vulkan1.2' target='-fspv-target-env=vulkan1.2'
additional_exts = '-fspv-extension=SPV_EXT_mesh_shader' additional_exts = '-fspv-extension=SPV_EXT_mesh_shader'
profile = 'ms_6_6' profile = 'ms_6_6'
elif(hlsl_file.find('.task') != -1):
target='-fspv-target-env=vulkan1.2'
additional_exts = '-fspv-extension=SPV_EXT_mesh_shader'
profile = 'as_6_6'
if root.endswith("debugprintf"): if root.endswith("debugprintf"):
additional_exts = '-fspv-extension=SPV_KHR_non_semantic_info' additional_exts = '-fspv-extension=SPV_KHR_non_semantic_info'