v3dv/pipeline_cache: extend pipeline cache envvar

So far V3DV_ENABLE_DEFAULT_PIPELINE_CACHE allowed to configure
pipeline cache to avoid any caching using a pipeline cache.

With this change we can be more detailed. Then envvar is not anymore a
boolean. Allowed values:

  * "off": no pipeline cache at all. PipelineCache objects behaves as
    no-op objects.

  * "no-default-cache": user PipelineCache caches nir/variants, but we
    don't provide a default cache in case the user doesn't provide a
    PipelineCache object, neither for internal pipelines.

  * "full" (default): we provide a default PipelineCache, used when
    the user doesn't provide one when creating a Pipeline, and for
    internal Pipelines.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Alejandro Piñeiro 2020-09-20 22:54:33 +02:00 committed by Marge Bot
parent 93e3b001c6
commit 1ed8252514
3 changed files with 29 additions and 7 deletions

View file

@ -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);

View file

@ -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,

View file

@ -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 */