Skip to content

Commit 68f4d58

Browse files
committed
[ET-VK][ez] Small fix to SPIR-V compilation artifact caching
## Context There was a bug in the SPIR-V cache; essentially, once a shader variant is processed it will save the source GLSL to the cache. However, if another variant that uses the same source GLSL then checks the cache, it will think that the source file is unchanged and therefore will not recompile. To fix this, defer saving the source GLSL files only when all shaders have been compiled. Differential Revision: [D71973524](https://our.internmc.facebook.com/intern/diff/D71973524/) ghstack-source-id: 274443433 Pull Request resolved: #9716
1 parent 95702dc commit 68f4d58

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

backends/vulkan/runtime/gen_vulkan_spv.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,7 @@ def process_shader(shader_paths_pair):
801801
output_file.write(output_text)
802802

803803
if cache_dir is not None:
804-
# Otherwise, store the generated and source GLSL files in the cache
805-
shutil.copyfile(source_glsl, cached_source_glsl)
804+
# Otherwise, store the generated GLSL files in the cache
806805
shutil.copyfile(glsl_out_path, cached_glsl_out_path)
807806

808807
# If no GLSL compiler is specified, then only write out the generated GLSL shaders.
@@ -852,6 +851,15 @@ def process_shader(shader_paths_pair):
852851
):
853852
output_file_map[spv_out_path] = glsl_out_path
854853

854+
# Save all source GLSL files to the cache. Only do this at the very end since
855+
# multiple variants may use the same source file.
856+
if cache_dir is not None:
857+
for _, source_glsl in self.glsl_src_files.items():
858+
cached_source_glsl = os.path.join(
859+
cache_dir, os.path.basename(source_glsl) + ".t"
860+
)
861+
shutil.copyfile(source_glsl, cached_source_glsl)
862+
855863
return output_file_map
856864

857865

0 commit comments

Comments
 (0)