From e74f4ea115333d81cb6d753b3a721a057d3f5eda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 5 Mar 2024 14:11:32 +0100 Subject: [PATCH] Vulkan: Don't warn about pipelines cache if missing It used to warn when opening a new project because no cache pre-exists, which isn't particularly helpful. Also include the rendering method in the cache filename, as it differs between Forward+ and Mobile for a same GPU. --- drivers/vulkan/rendering_device_driver_vulkan.cpp | 4 +++- servers/rendering/rendering_device.cpp | 6 +++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/vulkan/rendering_device_driver_vulkan.cpp b/drivers/vulkan/rendering_device_driver_vulkan.cpp index 21cf54b4be28..d8404ac8e414 100644 --- a/drivers/vulkan/rendering_device_driver_vulkan.cpp +++ b/drivers/vulkan/rendering_device_driver_vulkan.cpp @@ -3828,7 +3828,9 @@ bool RenderingDeviceDriverVulkan::pipeline_cache_create(const Vector &p // Parse. { - if (p_data.size() <= (int)sizeof(PipelineCacheHeader)) { + if (p_data.is_empty()) { + // No pre-existing cache, just create it. + } else if (p_data.size() <= (int)sizeof(PipelineCacheHeader)) { WARN_PRINT("Invalid/corrupt pipelines cache."); } else { const PipelineCacheHeader *loaded_header = reinterpret_cast(p_data.ptr()); diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index e1709fdb00e7..dc48ddbd565d 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -5091,12 +5091,12 @@ Error RenderingDevice::initialize(RenderingContextDriver *p_context, DisplayServ if (main_instance) { // Only the instance that is not a local device and is also the singleton is allowed to manage a pipeline cache. - pipeline_cache_file_path = "user://vulkan/pipelines"; - pipeline_cache_file_path += "." + device.name.validate_filename().replace(" ", "_").to_lower(); + pipeline_cache_file_path = vformat("user://vulkan/pipelines.%s.%s", + OS::get_singleton()->get_current_rendering_method(), + device.name.validate_filename().replace(" ", "_").to_lower()); if (Engine::get_singleton()->is_editor_hint()) { pipeline_cache_file_path += ".editor"; } - pipeline_cache_file_path += ".cache"; Vector cache_data = _load_pipeline_cache();