mirror of
https://github.com/xenia-project/xenia.git
synced 2026-07-11 01:24:34 +02:00
[Build] Replace spirv-remap with spirv-opt --canonicalize-ids
`spirv-remap` is not present in modern Vulkan SDK versions, it was replaced with the `--canonicalize-ids` pass in `spirv-opt`. Overall, canonicalization provides a significant compression improvement, which is important considering that currently Xenia is distributed in a ZIP archive and contains many very similar shaders. With normal DEFLATE compression, canonicalization reduced the size of a ZIP with `xenia.exe` from 3.54 MB to 3.45 MB in a test done before committing. Also disable stripping of debug information from shaders, which apparently was among what `spirv-remap` was doing with `--do-everything`, as binding and uniform buffer member names heavily aid in debugging in RenderDoc. Partially integrated from #2329. Co-authored-by: Herman S. <429230+has207@users.noreply.github.com> Co-authored-by: Gliniak <Gliniak93@gmail.com>
This commit is contained in:
+7
-14
@@ -1016,10 +1016,6 @@ class BuildShadersCommand(Command):
|
|||||||
if not has_bin(spirv_opt):
|
if not has_bin(spirv_opt):
|
||||||
print('ERROR: could not find spirv-opt')
|
print('ERROR: could not find spirv-opt')
|
||||||
return 1
|
return 1
|
||||||
spirv_remap = os.path.join(vulkan_bin_path, 'spirv-remap')
|
|
||||||
if not has_bin(spirv_remap):
|
|
||||||
print('ERROR: could not find spirv-remap')
|
|
||||||
return 1
|
|
||||||
spirv_dis = os.path.join(vulkan_bin_path, 'spirv-dis')
|
spirv_dis = os.path.join(vulkan_bin_path, 'spirv-dis')
|
||||||
if not has_bin(spirv_dis):
|
if not has_bin(spirv_dis):
|
||||||
print('ERROR: could not find spirv-dis')
|
print('ERROR: could not find spirv-dis')
|
||||||
@@ -1079,27 +1075,24 @@ class BuildShadersCommand(Command):
|
|||||||
universal_newlines = True).returncode != 0:
|
universal_newlines = True).returncode != 0:
|
||||||
print('ERROR: failed to build a SPIR-V shader')
|
print('ERROR: failed to build a SPIR-V shader')
|
||||||
return 1
|
return 1
|
||||||
|
# Optimize the shader, and then improve the compression quality
|
||||||
|
# for the application executable via ID canonicalization by
|
||||||
|
# making IDs in similar shaders more likely to be the same.
|
||||||
|
# Don't strip debug information such as binding and buffer
|
||||||
|
# structure member names, however, as it's useful for
|
||||||
|
# investigating issues in debuggers such as RenderDoc.
|
||||||
# spirv-opt input and output files must be different.
|
# spirv-opt input and output files must be different.
|
||||||
spirv_file_path = spirv_file_path_base + '.spv'
|
spirv_file_path = spirv_file_path_base + '.spv'
|
||||||
if subprocess.call([
|
if subprocess.call([
|
||||||
spirv_opt,
|
spirv_opt,
|
||||||
'-O',
|
'-O',
|
||||||
|
'--canonicalize-ids',
|
||||||
spirv_glslang_file_path,
|
spirv_glslang_file_path,
|
||||||
'-o', spirv_file_path,
|
'-o', spirv_file_path,
|
||||||
]) != 0:
|
]) != 0:
|
||||||
print('ERROR: failed to optimize a SPIR-V shader')
|
print('ERROR: failed to optimize a SPIR-V shader')
|
||||||
return 1
|
return 1
|
||||||
os.remove(spirv_glslang_file_path)
|
os.remove(spirv_glslang_file_path)
|
||||||
# spirv-remap takes the output directory, but it may be the same
|
|
||||||
# as the one the input is stored in.
|
|
||||||
if subprocess.call([
|
|
||||||
spirv_remap,
|
|
||||||
'--do-everything',
|
|
||||||
'-i', spirv_file_path,
|
|
||||||
'-o', spirv_dir_path,
|
|
||||||
]) != 0:
|
|
||||||
print('ERROR: failed to remap a SPIR-V shader')
|
|
||||||
return 1
|
|
||||||
spirv_dis_file_path = spirv_file_path_base + '.txt';
|
spirv_dis_file_path = spirv_file_path_base + '.txt';
|
||||||
if subprocess.call([
|
if subprocess.call([
|
||||||
spirv_dis,
|
spirv_dis,
|
||||||
|
|||||||
Reference in New Issue
Block a user