chromium/third_party/vulkan-validation-layers/src/layers/layer_options.cpp

/* Copyright (c) 2020-2024 The Khronos Group Inc.
 * Copyright (c) 2020-2024 Valve Corporation
 * Copyright (c) 2020-2024 LunarG, Inc.
 * Modifications Copyright (C) 2020 Advanced Micro Devices, Inc. All rights reserved.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

#include "layer_options.h"
#include "generated/error_location_helper.h"
#include "utils/hash_util.h"
#include <vulkan/layer/vk_layer_settings.hpp>

#include "generated/chassis.h"
#include "gpu/core/gpu_settings.h"
#include "error_message/logging.h"

#include "sync/sync_settings.h"

// Include new / delete overrides if using mimalloc. This needs to be include exactly once in a file that is
// part of the VVL but not the layer utils library.
#if defined(USE_MIMALLOC) && defined(_WIN64)
#include "mimalloc-new-delete.h"
#endif

const auto &VkValFeatureDisableLookup() {}

const auto &VkValFeatureEnableLookup() {}

const auto &ValidationDisableLookup() {}

const auto &ValidationEnableLookup() {}

// This should mirror the 'DisableFlags' enumerated type
const std::vector<std::string> &GetDisableFlagNameHelper() {}

const std::vector<std::string> &GetEnableFlagNameHelper() {}

// To enable "my_setting",
// Set env var VK_LAYER_MY_SETTING to 1
//
// The ["VK_LAYER_" + toUpper(key)] logic is don in vk_layer_setting (VUL)
//
// To quickly be able to find the env var corresponding to a setting,
// the following `const char*` holding setting names match their corresponding environment variable

// Corresponding to VkValidationFeatureEnableEXT
// ---
const char *VK_LAYER_ENABLES =;
const char *VK_LAYER_VALIDATE_BEST_PRACTICES =;
const char *VK_LAYER_VALIDATE_BEST_PRACTICES_ARM =;
const char *VK_LAYER_VALIDATE_BEST_PRACTICES_AMD =;
const char *VK_LAYER_VALIDATE_BEST_PRACTICES_IMG =;
const char *VK_LAYER_VALIDATE_BEST_PRACTICES_NVIDIA =;
const char *VK_LAYER_VALIDATE_SYNC =;
const char *VK_LAYER_VALIDATE_GPU_BASED =;

// Corresponding to VkValidationFeatureDisableEXT
// ---
const char *VK_LAYER_DISABLES =;
const char *VK_LAYER_CHECK_SHADERS =;
const char *VK_LAYER_THREAD_SAFETY =;
const char *VK_LAYER_STATELESS_PARAM =;
const char *VK_LAYER_OBJECT_LIFETIME =;
const char *VK_LAYER_VALIDATE_CORE =;
const char *VK_LAYER_UNIQUE_HANDLES =;
const char *VK_LAYER_CHECK_SHADERS_CACHING =;

// Additional checks exposed in vkconfig, but not in VkValidationFeatureDisableEXT
// ---
const char *VK_LAYER_CHECK_COMMAND_BUFFER =;
const char *VK_LAYER_CHECK_OBJECT_IN_USE =;
const char *VK_LAYER_CHECK_QUERY =;
const char *VK_LAYER_CHECK_IMAGE_LAYOUT =;

// Options related to debug reporting
// ---
const char *VK_LAYER_MESSAGE_ID_FILTER =;
const char *VK_LAYER_CUSTOM_STYPE_LIST =;
const char *VK_LAYER_DUPLICATE_MESSAGE_LIMIT =;

// GloablSettings
// ---
const char *VK_LAYER_FINE_GRAINED_LOCKING =;
// Debug settings used for internal development
const char *VK_LAYER_DEBUG_DISABLE_SPIRV_VAL =;

// DebugPrintf
// ---
const char *VK_LAYER_PRINTF_TO_STDOUT =;
const char *VK_LAYER_PRINTF_VERBOSE =;
const char *VK_LAYER_PRINTF_BUFFER_SIZE =;

// GPU-AV
// ---
const char *VK_LAYER_GPUAV_SHADER_INSTRUMENTATION =;
const char *VK_LAYER_GPUAV_DESCRIPTORS_CHECKS =;
const char *VK_LAYER_GPUAV_WARN_ON_ROBUST_OOB =;
const char *VK_LAYER_GPUAV_BUFFER_ADDRESS_OOB =;
const char *VK_LAYER_GPUAV_MAX_BUFFER_DEVICE_ADDRESSES =;
const char *VK_LAYER_GPUAV_VALIDATE_RAY_QUERY =;
const char *VK_LAYER_GPUAV_CACHE_INSTRUMENTED_SHADERS =;
const char *VK_LAYER_GPUAV_SELECT_INSTRUMENTED_SHADERS =;

const char *VK_LAYER_GPUAV_BUFFERS_VALIDATION =;
const char *VK_LAYER_GPUAV_INDIRECT_DRAWS_BUFFERS =;
const char *VK_LAYER_GPUAV_INDIRECT_DISPATCHES_BUFFERS =;
const char *VK_LAYER_GPUAV_INDIRECT_TRACE_RAYS_BUFFERS =;
const char *VK_LAYER_GPUAV_BUFFER_COPIES =;

const char *VK_LAYER_GPUAV_RESERVE_BINDING_SLOT =;
const char *VK_LAYER_GPUAV_VMA_LINEAR_OUTPUT =;

const char *VK_LAYER_GPUAV_DEBUG_DISABLE_ALL =;
const char *VK_LAYER_GPUAV_DEBUG_VALIDATE_INSTRUMENTED_SHADERS =;
const char *VK_LAYER_GPUAV_DEBUG_DUMP_INSTRUMENTED_SHADERS =;
const char *VK_LAYER_GPUAV_DEBUG_MAX_INSTRUMENTED_COUNT =;
const char *VK_LAYER_GPUAV_DEBUG_PRINT_INSTRUMENTATION_INFO =;

// SyncVal
// ---
const char *VK_LAYER_SYNCVAL_SUBMIT_TIME_VALIDATION =;
const char *VK_LAYER_SYNCVAL_SHADER_ACCESSES_HEURISTIC =;

// Message Formatting
// ---
const char *VK_LAYER_MESSAGE_FORMAT_DISPLAY_APPLICATION_NAME =;

// These were deprecated after the 1.3.280 SDK release
const char *DEPRECATED_VK_LAYER_GPUAV_VALIDATE_COPIES =;
const char *DEPRECATED_VK_LAYER_GPUAV_VALIDATE_INDIRECT_BUFFER =;
const char *DEPRECATED_VK_LAYER_RESERVE_BINDING_SLOT =;
const char *DEPRECATED_GPUAV_VMA_LINEAR_OUTPUT =;
const char *DEPRECATED_GPUAV_WARN_ON_ROBUST_OOB =;
const char *DEPRECATED_GPUAV_USE_INSTRUMENTED_SHADER_CACHE =;
const char *DEPRECATED_GPUAV_SELECT_INSTRUMENTED_SHADERS =;

// These were deprecated after the 1.3.283 SDK release
const char *DEPRECATED_VK_LAYER_VALIDATE_SYNC_QUEUE_SUBMIT =;

// Set the local disable flag for the appropriate VALIDATION_CHECK_DISABLE enum
void SetValidationDisable(CHECK_DISABLED &disable_data, const ValidationCheckDisables disable_id) {}

// Set the local disable flag for a single VK_VALIDATION_FEATURE_DISABLE_* flag
void SetValidationFeatureDisable(CHECK_DISABLED &disable_data, const VkValidationFeatureDisableEXT feature_disable) {}

// Set the local enable flag for the appropriate VALIDATION_CHECK_ENABLE enum
void SetValidationEnable(CHECK_ENABLED &enable_data, const ValidationCheckEnables enable_id) {}

// Set the local enable flag for a single VK_VALIDATION_FEATURE_ENABLE_* flag
void SetValidationFeatureEnable(CHECK_ENABLED &enable_data, const VkValidationFeatureEnableEXT feature_enable) {}

// Set the local disable flag for settings specified through the VK_EXT_validation_flags extension
void SetValidationFlags(CHECK_DISABLED &disables, const VkValidationFlagsEXT *val_flags_struct) {}

// Process Validation Features flags specified through the ValidationFeature extension
void SetValidationFeatures(CHECK_DISABLED &disable_data, CHECK_ENABLED &enable_data,
                           const VkValidationFeaturesEXT *val_features_struct) {}

std::string GetNextToken(std::string *token_list, const std::string &delimiter, size_t *pos) {}

// Given a string representation of a list of enable enum values, call the appropriate setter function
void SetLocalEnableSetting(std::string list_of_enables, const std::string &delimiter, CHECK_ENABLED &enables) {}

// Given a string representation of a list of disable enum values, call the appropriate setter function
void SetLocalDisableSetting(std::string list_of_disables, const std::string &delimiter, CHECK_DISABLED &disables) {}

uint32_t TokenToUint(std::string &token) {}

void CreateFilterMessageIdList(std::string raw_id_list, const std::string &delimiter, vvl::unordered_set<uint32_t> &filter_list) {}

// Because VkLayerSettingsCreateInfoEXT/VkLayerSettingEXT are passed in and used before everything else, need to do the stateless
// validation here as a special exception
//
// Returns if valid
static bool ValidateLayerSettings(const VkLayerSettingsCreateInfoEXT *layer_settings, DebugReport *debug_report) {}

#if !defined(BUILD_SELF_VVL)
static void SetValidationSetting(VkuLayerSettingSet layer_setting_set, CHECK_DISABLED &disable_data,
                                 const DisableFlags feature_disable, const char *setting) {}

static void SetValidationSetting(VkuLayerSettingSet layer_setting_set, CHECK_ENABLED &enable_data, const EnableFlags feature_enable,
                                 const char *setting) {}

static std::string Merge(const std::vector<std::string> &strings) {}

static const char *GetDefaultPrefix() {}
#endif  // !defined(BUILD_SELF_VVL)

// Process enables and disables set though the vk_layer_settings.txt config file or through an environment variable
void ProcessConfigAndEnvSettings(ConfigAndEnvSettings *settings_data) {}