mirror of
https://gitee.com/openharmony/third_party_vulkan-loader
synced 2024-11-23 15:20:52 +00:00
loader: Do not enumerate extensions from disabled implicit layers
This patch adds a check to vkEnumerateInstanceExtensionProperties to omit extensions provided by disabled implicit layers. Per section 31.2 (1.0.51), "When pLayerName parameter is NULL, only extensions provided by the Vulkan implementation or by implicitly enabled layers are returned." Arguably, implicit layers that have been disabled are not "implicitly enabled".
This commit is contained in:
parent
2b3361f3ab
commit
319a7c3e69
@ -1077,28 +1077,7 @@ VkResult loader_add_to_layer_list(const struct loader_instance *inst, struct loa
|
||||
static void loader_add_implicit_layer(const struct loader_instance *inst, const struct loader_layer_properties *prop,
|
||||
struct loader_layer_list *target_list, struct loader_layer_list *expanded_target_list,
|
||||
const struct loader_layer_list *source_list) {
|
||||
bool enable = false;
|
||||
char *env_value = NULL;
|
||||
|
||||
// if no enable_environment variable is specified, this implicit layer
|
||||
// should always be enabled. Otherwise check if the variable is set
|
||||
if (prop->enable_env_var.name[0] == 0) {
|
||||
enable = true;
|
||||
} else {
|
||||
env_value = loader_secure_getenv(prop->enable_env_var.name, inst);
|
||||
if (env_value && !strcmp(prop->enable_env_var.value, env_value)) enable = true;
|
||||
loader_free_getenv(env_value, inst);
|
||||
}
|
||||
|
||||
// disable_environment has priority, i.e. if both enable and disable
|
||||
// environment variables are set, the layer is disabled. Implicit
|
||||
// layers are required to have a disable_environment variables
|
||||
env_value = loader_secure_getenv(prop->disable_env_var.name, inst);
|
||||
if (env_value) {
|
||||
enable = false;
|
||||
}
|
||||
loader_free_getenv(env_value, inst);
|
||||
|
||||
bool enable = loader_is_implicit_layer_enabled(inst, prop);
|
||||
if (enable) {
|
||||
// If not a meta-layer, simply add it.
|
||||
if (0 == (prop->type_flags & VK_LAYER_TYPE_FLAG_META_LAYER)) {
|
||||
@ -3402,6 +3381,31 @@ void loader_implicit_layer_scan(const struct loader_instance *inst, struct loade
|
||||
loader_platform_thread_unlock_mutex(&loader_json_lock);
|
||||
}
|
||||
|
||||
// Check if an implicit layer should be enabled.
|
||||
bool loader_is_implicit_layer_enabled(const struct loader_instance *inst, const struct loader_layer_properties *prop) {
|
||||
bool enable = false;
|
||||
char *env_value = NULL;
|
||||
|
||||
// if no enable_environment variable is specified, this implicit layer
|
||||
// should always be enabled. Otherwise check if the variable is set
|
||||
if (prop->enable_env_var.name[0] == 0) {
|
||||
enable = true;
|
||||
} else {
|
||||
env_value = loader_secure_getenv(prop->enable_env_var.name, inst);
|
||||
if (env_value && !strcmp(prop->enable_env_var.value, env_value)) enable = true;
|
||||
loader_free_getenv(env_value, inst);
|
||||
}
|
||||
|
||||
// disable_environment has priority, i.e. if both enable and disable
|
||||
// environment variables are set, the layer is disabled. Implicit
|
||||
// layers are required to have a disable_environment variables
|
||||
env_value = loader_secure_getenv(prop->disable_env_var.name, inst);
|
||||
if (env_value && !strcmp(prop->disable_env_var.value, env_value)) enable = false;
|
||||
loader_free_getenv(env_value, inst);
|
||||
|
||||
return enable;
|
||||
}
|
||||
|
||||
static VKAPI_ATTR PFN_vkVoidFunction VKAPI_CALL loader_gpdpa_instance_internal(VkInstance inst, const char *pName) {
|
||||
// inst is not wrapped
|
||||
if (inst == VK_NULL_HANDLE) {
|
||||
|
@ -437,6 +437,7 @@ void loader_scanned_icd_clear(const struct loader_instance *inst, struct loader_
|
||||
VkResult loader_icd_scan(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list);
|
||||
void loader_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers);
|
||||
void loader_implicit_layer_scan(const struct loader_instance *inst, struct loader_layer_list *instance_layers);
|
||||
bool loader_is_implicit_layer_enabled(const struct loader_instance *inst, const struct loader_layer_properties *prop);
|
||||
VkResult loader_get_icd_loader_instance_extensions(const struct loader_instance *inst, struct loader_icd_tramp_list *icd_tramp_list,
|
||||
struct loader_extension_list *inst_exts);
|
||||
struct loader_icd_term *loader_get_icd_and_device(const VkDevice device, struct loader_device **found_dev, uint32_t *icd_index);
|
||||
|
@ -143,9 +143,12 @@ LOADER_EXPORT VKAPI_ATTR VkResult VKAPI_CALL vkEnumerateInstanceExtensionPropert
|
||||
}
|
||||
loader_scanned_icd_clear(NULL, &icd_tramp_list);
|
||||
|
||||
// Append implicit layers.
|
||||
// Append enabled implicit layers.
|
||||
loader_implicit_layer_scan(NULL, &instance_layers);
|
||||
for (uint32_t i = 0; i < instance_layers.count; i++) {
|
||||
if (!loader_is_implicit_layer_enabled(NULL, &instance_layers.list[i])) {
|
||||
continue;
|
||||
}
|
||||
struct loader_extension_list *ext_list = &instance_layers.list[i].instance_extension_list;
|
||||
loader_add_to_ext_list(NULL, &local_ext_list, ext_list->count, ext_list->list);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user