From ecaafa6001e47ee0f8157e0e4846afd6e758a436 Mon Sep 17 00:00:00 2001 From: Dario Date: Fri, 5 Apr 2024 13:00:20 -0300 Subject: [PATCH] Add toggle for enabling or disabling RenderingDevice's pipeline cache. --- core/config/project_settings.cpp | 1 + doc/classes/ProjectSettings.xml | 4 ++++ servers/rendering/rendering_device.cpp | 3 ++- 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/core/config/project_settings.cpp b/core/config/project_settings.cpp index 14023c5c759..1508469e277 100644 --- a/core/config/project_settings.cpp +++ b/core/config/project_settings.cpp @@ -1538,6 +1538,7 @@ ProjectSettings::ProjectSettings() { GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/rendering_device/staging_buffer/block_size_kb", PROPERTY_HINT_RANGE, "4,2048,1,or_greater"), 256); GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/rendering_device/staging_buffer/max_size_mb", PROPERTY_HINT_RANGE, "1,1024,1,or_greater"), 128); GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/rendering_device/staging_buffer/texture_upload_region_size_px", PROPERTY_HINT_RANGE, "1,256,1,or_greater"), 64); + GLOBAL_DEF_RST(PropertyInfo(Variant::BOOL, "rendering/rendering_device/pipeline_cache/enable"), true); GLOBAL_DEF(PropertyInfo(Variant::FLOAT, "rendering/rendering_device/pipeline_cache/save_chunk_size_mb", PROPERTY_HINT_RANGE, "0.000001,64.0,0.001,or_greater"), 3.0); GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/rendering_device/vulkan/max_descriptors_per_pool", PROPERTY_HINT_RANGE, "1,256,1,or_greater"), 64); diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 4d3e838bb18..6a6f53ac602 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -2727,6 +2727,10 @@ Windows override for [member rendering/rendering_device/driver]. + + Enable the pipeline cache that is saved to disk if the graphics API supports it. + [b]Note:[/b] This property is unable to control the pipeline caching the GPU driver itself does. Only turn this off along with deleting the contents of the driver's cache if you wish to simulate the experience a user will get when starting the game for the first time. + Determines at which interval pipeline cache is saved to disk. The lower the value, the more often it is saved. diff --git a/servers/rendering/rendering_device.cpp b/servers/rendering/rendering_device.cpp index 7dfff0b76f3..1fdccb929b5 100644 --- a/servers/rendering/rendering_device.cpp +++ b/servers/rendering/rendering_device.cpp @@ -5089,7 +5089,8 @@ Error RenderingDevice::initialize(RenderingContextDriver *p_context, DisplayServ draw_list = nullptr; compute_list = nullptr; - if (main_instance) { + bool project_pipeline_cache_enable = GLOBAL_GET("rendering/rendering_device/pipeline_cache/enable"); + if (main_instance && project_pipeline_cache_enable) { // 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 = vformat("user://vulkan/pipelines.%s.%s", OS::get_singleton()->get_current_rendering_method(),