From e0b281a505eabec3fdbd79f7df7bbb2c44d0818c Mon Sep 17 00:00:00 2001 From: Miguel Pozo Date: Wed, 13 Aug 2025 16:05:33 +0200 Subject: [PATCH] Fix: GL Compilation Subprocess file locking Prevent the cache file from being locked if the driver hangs during validation. --- source/blender/gpu/opengl/gl_compilation_subprocess.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/blender/gpu/opengl/gl_compilation_subprocess.cc b/source/blender/gpu/opengl/gl_compilation_subprocess.cc index 296a6a72ea7..8b8b9187ec6 100644 --- a/source/blender/gpu/opengl/gl_compilation_subprocess.cc +++ b/source/blender/gpu/opengl/gl_compilation_subprocess.cc @@ -262,6 +262,8 @@ void GPU_compilation_subprocess_run(const char *subprocess_name) /* Use temp memory so we don't overwrite the source hash. */ static char tmp_mem[compilation_subprocess_shared_memory_size]; file.read(tmp_mem, size); + /* Close first in case validation hangs the driver. */ + file.close(); /* Ensure it's valid. */ if (!validate_binary(tmp_mem)) { std::cout << "Compilation Subprocess: Failed to load cached shader binary " << hash_str @@ -269,7 +271,6 @@ void GPU_compilation_subprocess_run(const char *subprocess_name) /* TODO: No longer true. */ /* We can't compile the shader anymore since we have written over the source code, * but we delete the cache for the next time this shader is requested. */ - file.close(); BLI_delete(cache_path.c_str(), false, false); } /* Copy the temp memory to the shared memory now that we know loading the shader doesn't