diff --git a/src/broadcom/vulkan/v3dv_device.c b/src/broadcom/vulkan/v3dv_device.c index 7b8bd7a4a77..dcde552ec77 100644 --- a/src/broadcom/vulkan/v3dv_device.c +++ b/src/broadcom/vulkan/v3dv_device.c @@ -220,12 +220,33 @@ v3dv_CreateInstance(const VkInstanceCreateInfo *pCreateInfo, return vk_error(NULL, result); } - instance->pipeline_cache_enabled = - env_var_as_boolean("V3DV_ENABLE_PIPELINE_CACHE", true); + + /* We start with the default values for the pipeline_cache envvars */ + instance->pipeline_cache_enabled = true; + instance->default_pipeline_cache_enabled = true; + const char *pipeline_cache_str = getenv("V3DV_ENABLE_PIPELINE_CACHE"); + if (pipeline_cache_str != NULL) { + if (strncmp(pipeline_cache_str, "full", 4) == 0) { + /* nothing to do, just to filter correct values */ + } else if (strncmp(pipeline_cache_str, "no-default-cache", 16) == 0) { + instance->default_pipeline_cache_enabled = false; + } else if (strncmp(pipeline_cache_str, "off", 3) == 0) { + instance->pipeline_cache_enabled = false; + instance->default_pipeline_cache_enabled = false; + } else { + fprintf(stderr, "Wrong value for envvar V3DV_ENABLE_PIPELINE_CACHE. " + "Allowed values are: full, no-default-cache, off\n"); + } + } if (instance->pipeline_cache_enabled == false) { fprintf(stderr, "WARNING: v3dv pipeline cache is disabled. Performance " "can be affected negatively\n"); + } else { + if (instance->default_pipeline_cache_enabled == false) { + fprintf(stderr, "WARNING: default v3dv pipeline cache is disabled. " + "Performance can be affected negatively\n"); + } } glsl_type_singleton_init_or_ref(); @@ -1333,7 +1354,7 @@ v3dv_CreateDevice(VkPhysicalDevice physicalDevice, init_device_meta(device); v3dv_bo_cache_init(device); v3dv_pipeline_cache_init(&device->default_pipeline_cache, device, - device->instance->pipeline_cache_enabled); + device->instance->default_pipeline_cache_enabled); *pDevice = v3dv_device_to_handle(device); diff --git a/src/broadcom/vulkan/v3dv_pipeline.c b/src/broadcom/vulkan/v3dv_pipeline.c index 9916d658441..379b0eb6ea2 100644 --- a/src/broadcom/vulkan/v3dv_pipeline.c +++ b/src/broadcom/vulkan/v3dv_pipeline.c @@ -1513,7 +1513,7 @@ v3dv_get_shader_variant(struct v3dv_pipeline_stage *p_stage, struct v3dv_pipeline *pipeline = p_stage->pipeline; struct v3dv_device *device = pipeline->device; - if (cache == NULL && device->instance->pipeline_cache_enabled) + if (cache == NULL && device->instance->default_pipeline_cache_enabled) cache = &device->default_pipeline_cache; struct v3dv_shader_variant *variant = @@ -1639,7 +1639,7 @@ pregenerate_shader_variants(struct v3dv_pipeline_stage *p_stage, if (*out_vk_result != VK_SUCCESS) return variant_16; - if (!p_stage->pipeline->device->instance->pipeline_cache_enabled) { + if (!p_stage->pipeline->device->instance->default_pipeline_cache_enabled) { /* If pipeline cache is disabled it doesn't make sense to pre-generate, * as we are relying on the default pipeline cache to save the different * pre-compiled variants @@ -2988,7 +2988,7 @@ graphics_pipeline_create(VkDevice _device, VkResult result; /* Use the default pipeline cache if none is specified */ - if (cache == NULL && device->instance->pipeline_cache_enabled) + if (cache == NULL && device->instance->default_pipeline_cache_enabled) cache = &device->default_pipeline_cache; pipeline = vk_zalloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8, @@ -3143,7 +3143,7 @@ compute_pipeline_create(VkDevice _device, VkResult result; /* Use the default pipeline cache if none is specified */ - if (cache == NULL && device->instance->pipeline_cache_enabled) + if (cache == NULL && device->instance->default_pipeline_cache_enabled) cache = &device->default_pipeline_cache; pipeline = vk_zalloc2(&device->alloc, pAllocator, sizeof(*pipeline), 8, diff --git a/src/broadcom/vulkan/v3dv_private.h b/src/broadcom/vulkan/v3dv_private.h index e2eb7b2482f..7cbbf6bcbcb 100644 --- a/src/broadcom/vulkan/v3dv_private.h +++ b/src/broadcom/vulkan/v3dv_private.h @@ -190,6 +190,7 @@ struct v3dv_instance { struct vk_debug_report_instance debug_report_callbacks; bool pipeline_cache_enabled; + bool default_pipeline_cache_enabled; }; /* Tracks wait threads spawned from a single vkQueueSubmit call */