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