chromium/third_party/vulkan-validation-layers/src/layers/stateless/sl_utils.cpp

/* Copyright (c) 2015-2024 The Khronos Group Inc.
 * Copyright (c) 2015-2024 Valve Corporation
 * Copyright (c) 2015-2024 LunarG, Inc.
 * Copyright (C) 2015-2024 Google Inc.
 *
 * 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 "stateless/stateless_validation.h"

#include "generated/chassis.h"

bool StatelessValidation::CheckPromotedApiAgainstVulkanVersion(VkInstance instance, const Location &loc,
                                                               const uint32_t promoted_version) const {}

bool StatelessValidation::CheckPromotedApiAgainstVulkanVersion(VkPhysicalDevice pdev, const Location &loc,
                                                               const uint32_t promoted_version) const {}

bool StatelessValidation::OutputExtensionError(const Location &loc, const vvl::Extensions &exentsions) const {}

bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, vvl::Extension extension) const {}

static const uint8_t kUtF8OneByteCode =;
static const uint8_t kUtF8OneByteMask =;
static const uint8_t kUtF8TwoByteCode =;
static const uint8_t kUtF8TwoByteMask =;
static const uint8_t kUtF8ThreeByteCode =;
static const uint8_t kUtF8ThreeByteMask =;
static const uint8_t kUtF8DataByteCode =;
static const uint8_t kUtF8DataByteMask =;

static VkStringErrorFlags ValidateVkString(const int max_length, const char *utf8) {}

static const int kMaxParamCheckerStringLength =;
bool StatelessValidation::ValidateString(const Location &loc, const std::string &vuid, const char *validateString) const {}

bool StatelessValidation::ValidateNotZero(bool is_zero, const std::string &vuid, const Location &loc) const {}

/**
 * Validate a required pointer.
 *
 * Verify that a required pointer is not NULL.
 *
 * @param loc Name of API call being validated.
 * @param value Pointer to validate.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateRequiredPointer(const Location &loc, const void *value, const std::string &vuid) const {}

bool StatelessValidation::ValidateAllocationCallbacks(const VkAllocationCallbacks &callback, const Location &loc) const {}

/**
 * Validate string array count and content.
 *
 * Verify that required count and array parameters are not 0 or NULL.  If the
 * count parameter is not optional, verify that it is not 0.  If the array
 * parameter is NULL, and it is not optional, verify that count is 0.  If the
 * array parameter is not NULL, verify that none of the strings are NULL.
 *
 * @param count_loc Name of count parameter.
 * @param array_loc Name of array parameter.
 * @param count Number of strings in the array.
 * @param array Array of strings to validate.
 * @param countRequired The 'count' parameter may not be 0 when true.
 * @param arrayRequired The 'array' parameter may not be NULL when true.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateStringArray(const Location &count_loc, const Location &array_loc, uint32_t count,
                                              const char *const *array, bool countRequired, bool arrayRequired,
                                              const char *count_required_vuid, const char *array_required_vuid) const {}

/**
 * Validate a structure's pNext member.
 *
 * Verify that the specified pNext value points to the head of a list of
 * allowed extension structures.  If no extension structures are allowed,
 * verify that pNext is null.
 *
 * @param loc Name of API call being validated.
 * @param next Pointer to validate.
 * @param allowed_type_count Total number of allowed structure types.
 * @param allowed_types Array of structure types allowed for pNext.
 * @param header_version Version of header defining the pNext validation rules.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateStructPnext(const Location &loc, const void *next, size_t allowed_type_count,
                                              const VkStructureType *allowed_types, uint32_t header_version, const char *pnext_vuid,
                                              const char *stype_vuid, VkPhysicalDevice caller_physical_device,
                                              const bool is_const_param) const {}

/**
 * Validate a VkBool32 value.
 *
 * Generate an error if a VkBool32 value is neither VK_TRUE nor VK_FALSE.
 *
 * @param loc Name of API call being validated.
 * @param value Boolean value to validate.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateBool32(const Location &loc, VkBool32 value) const {}

/**
 * Validate an array of VkBool32 values.
 *
 * Generate an error if any VkBool32 value in an array is neither VK_TRUE nor VK_FALSE.
 *
 * @param count_loc Name of count parameter.
 * @param array_loc Name of array parameter.
 * @param count Number of values in the array.
 * @param array Array of VkBool32 values to validate.
 * @param countRequired The 'count' parameter may not be 0 when true.
 * @param arrayRequired The 'array' parameter may not be NULL when true.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateBool32Array(const Location &count_loc, const Location &array_loc, uint32_t count,
                                              const VkBool32 *array, bool countRequired, bool arrayRequired,
                                              const char *count_required_vuid, const char *array_required_vuid) const {}

/**
 * Verify that a reserved VkFlags value is zero.
 *
 * Verify that the specified value is zero, to check VkFlags values that are reserved for
 * future use.
 *
 * @param loc Name of API call being validated.
 * @param value Value to validate.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateReservedFlags(const Location &loc, VkFlags value, const char *vuid) const {}

// helper to implement validation of both 32 bit and 64 bit flags.
template <typename FlagTypedef>
bool StatelessValidation::ValidateFlagsImplementation(const Location &loc, vvl::FlagBitmask flag_bitmask, FlagTypedef all_flags,
                                                      FlagTypedef value, const FlagType flag_type, const char *vuid,
                                                      const char *flags_zero_vuid) const {}

/**
 * Validate a 32 bit Vulkan bitmask value.
 *
 * Generate a warning if a value with a VkFlags derived type does not contain valid flag bits
 * for that type.
 *
 * @param loc Name of API call being validated.
 * @param flag_bitmask Name of the VkFlags type being validated.
 * @param all_flags A bit mask combining all valid flag bits for the VkFlags type being validated.
 * @param value VkFlags value to validate.
 * @param flag_type The type of flag, like optional, or single bit.
 * @param vuid VUID used for flag that is outside defined bits (or has more than one bit for Bits type).
 * @param flags_zero_vuid VUID used for non-optional Flags that are zero.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateFlags(const Location &loc, vvl::FlagBitmask flag_bitmask, VkFlags all_flags, VkFlags value,
                                        const FlagType flag_type, const char *vuid, const char *flags_zero_vuid) const {}

/**
 * Validate a 64 bit Vulkan bitmask value.
 *
 * Generate a warning if a value with a VkFlags64 derived type does not contain valid flag bits
 * for that type.
 *
 * @param loc Name of API call being validated.
 * @param flag_bitmask Name of the VkFlags64 type being validated.
 * @param all_flags A bit mask combining all valid flag bits for the VkFlags64 type being validated.
 * @param value VkFlags64 value to validate.
 * @param flag_type The type of flag, like optional, or single bit.
 * @param vuid VUID used for flag that is outside defined bits (or has more than one bit for Bits type).
 * @param flags_zero_vuid VUID used for non-optional Flags that are zero.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateFlags(const Location &loc, vvl::FlagBitmask flag_bitmask, VkFlags64 all_flags, VkFlags64 value,
                                        const FlagType flag_type, const char *vuid, const char *flags_zero_vuid) const {}

/**
 * Validate an array of Vulkan bitmask values.
 *
 * Generate a warning if a value with a VkFlags derived type does not contain valid flag bits
 * for that type.
 *
 * @param count_loc Name of parameter being validated.
 * @param array_loc Name of parameter being validated.
 * @param flag_bitmask Name of the VkFlags type being validated.
 * @param all_flags A bitmask combining all valid flag bits for the VkFlags type being validated.
 * @param count Number of VkFlags values in the array.
 * @param array Array of VkFlags value to validate.
 * @param count_required The 'count' parameter may not be 0 when true.
 * @param array_required_vuid The VUID for the 'array' parameter.
 * @return Boolean value indicating that the call should be skipped.
 */
bool StatelessValidation::ValidateFlagsArray(const Location &count_loc, const Location &array_loc, vvl::FlagBitmask flag_bitmask,
                                             VkFlags all_flags, uint32_t count, const VkFlags *array, bool count_required,
                                             const char *count_required_vuid, const char *array_required_vuid) const {}