chromium/third_party/vulkan-validation-layers/src/layers/state_tracker/descriptor_sets.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 "state_tracker/descriptor_sets.h"
#include "state_tracker/image_state.h"
#include "state_tracker/buffer_state.h"
#include "state_tracker/cmd_buffer_state.h"
#include "state_tracker/ray_tracing_state.h"
#include "state_tracker/sampler_state.h"
#include "state_tracker/shader_module.h"

static vvl::DescriptorPool::TypeCountMap GetMaxTypeCounts(const VkDescriptorPoolCreateInfo *create_info) {}

vvl::DescriptorPool::DescriptorPool(ValidationStateTracker &dev, const VkDescriptorPool handle,
                                    const VkDescriptorPoolCreateInfo *pCreateInfo)
    :{}

void vvl::DescriptorPool::Allocate(const VkDescriptorSetAllocateInfo *alloc_info, const VkDescriptorSet *descriptor_sets,
                                   const vvl::AllocateDescriptorSetsData &ds_data) {}

void vvl::DescriptorPool::Free(uint32_t count, const VkDescriptorSet *descriptor_sets) {}

void vvl::DescriptorPool::Reset() {}

const VulkanTypedHandle *vvl::DescriptorPool::InUse() const {}

void vvl::DescriptorPool::Destroy() {}

// ExtendedBinding collects a VkDescriptorSetLayoutBinding and any extended
// state that comes from a different array/structure so they can stay together
// while being sorted by binding number.
struct ExtendedBinding {};

struct BindingNumCmp {};

vvl::DescriptorClass vvl::DescriptorTypeToClass(VkDescriptorType type) {}

DescriptorSet;
DescriptorSetLayout;
DescriptorSetLayoutDef;
DescriptorSetLayoutId;

// Canonical dictionary of DescriptorSetLayoutDef (without any handle/device specific information)
vvl::DescriptorSetLayoutDict descriptor_set_layout_dict;

DescriptorSetLayoutId GetCanonicalId(const VkDescriptorSetLayoutCreateInfo *p_create_info) {}

bool operator==(const DescriptorSetLayoutDef &lhs, const DescriptorSetLayoutDef &rhs) {}

std::string DescriptorSetLayoutDef::DescribeDifference(uint32_t index, const DescriptorSetLayoutDef &other) const {}

// Construct DescriptorSetLayout instance from given create info
// Proactively reserve and resize as possible, as the reallocation was visible in profiling
vvl::DescriptorSetLayoutDef::DescriptorSetLayoutDef(const VkDescriptorSetLayoutCreateInfo *p_create_info)
    :{}

size_t vvl::DescriptorSetLayoutDef::hash() const {}
//

// Return valid index or "end" i.e. binding_count_;
// The asserts in "Get" are reduced to the set where no valid answer(like null or 0) could be given
// Common code for all binding lookups.
uint32_t vvl::DescriptorSetLayoutDef::GetIndexFromBinding(uint32_t binding) const {}
VkDescriptorSetLayoutBinding const *vvl::DescriptorSetLayoutDef::GetDescriptorSetLayoutBindingPtrFromIndex(
    const uint32_t index) const {}
// Return descriptorCount for given index, 0 if index is unavailable
uint32_t vvl::DescriptorSetLayoutDef::GetDescriptorCountFromIndex(const uint32_t index) const {}
// For the given index, return descriptorType
VkDescriptorType vvl::DescriptorSetLayoutDef::GetTypeFromIndex(const uint32_t index) const {}
// Return binding flags for given index, 0 if index is unavailable
VkDescriptorBindingFlags vvl::DescriptorSetLayoutDef::GetDescriptorBindingFlagsFromIndex(const uint32_t index) const {}

const vvl::IndexRange &vvl::DescriptorSetLayoutDef::GetGlobalIndexRangeFromIndex(uint32_t index) const {}

// For the given binding, return the global index range (half open)
// As start and end are often needed in pairs, get both with a single lookup.
const vvl::IndexRange &vvl::DescriptorSetLayoutDef::GetGlobalIndexRangeFromBinding(
    const uint32_t binding) const {}

// Move to next valid binding having a non-zero binding count
uint32_t vvl::DescriptorSetLayoutDef::GetNextValidBinding(const uint32_t binding) const {}
// For given index, return ptr to ImmutableSampler array
VkSampler const *vvl::DescriptorSetLayoutDef::GetImmutableSamplerPtrFromIndex(const uint32_t index) const {}

bool vvl::DescriptorSetLayoutDef::IsTypeMutable(const VkDescriptorType type, uint32_t binding) const {}

const std::vector<std::vector<VkDescriptorType>> &vvl::DescriptorSetLayoutDef::GetMutableTypes() const {}

const std::vector<VkDescriptorType> &vvl::DescriptorSetLayoutDef::GetMutableTypes(uint32_t binding) const {}

void vvl::DescriptorSetLayout::SetLayoutSizeInBytes(const VkDeviceSize *layout_size_in_bytes_) {}

const VkDeviceSize *vvl::DescriptorSetLayout::GetLayoutSizeInBytes() const {}

// If our layout is compatible with rh_ds_layout, return true.
bool vvl::DescriptorSetLayout::IsCompatible(DescriptorSetLayout const *rh_ds_layout) const {}

// The DescriptorSetLayout stores the per handle data for a descriptor set layout, and references the common defintion for the
// handle invariant portion
vvl::DescriptorSetLayout::DescriptorSetLayout(const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
                                              const VkDescriptorSetLayout handle)
    :{}

void vvl::AllocateDescriptorSetsData::Init(uint32_t count) {}

vvl::DescriptorSet::DescriptorSet(const VkDescriptorSet handle, vvl::DescriptorPool *pool_state,
                                  const std::shared_ptr<DescriptorSetLayout const> &layout, uint32_t variable_count,
                                  vvl::DescriptorSet::StateTracker *state_data)
    :{}

void vvl::DescriptorSet::LinkChildNodes() {}

void vvl::DescriptorSet::NotifyInvalidate(const NodeList &invalid_nodes, bool unlink) {}

uint32_t vvl::DescriptorSet::GetDynamicOffsetIndexFromBinding(uint32_t dynamic_binding) const {}

void vvl::DescriptorSet::Destroy() {}
// Loop through the write updates to do for a push descriptor set, ignoring dstSet
void vvl::DescriptorSet::PerformPushDescriptorsUpdate(uint32_t write_count, const VkWriteDescriptorSet *write_descs) {}

// Perform write update in given update struct
void vvl::DescriptorSet::PerformWriteUpdate(const VkWriteDescriptorSet &update) {}
// Perform Copy update
void vvl::DescriptorSet::PerformCopyUpdate(const VkCopyDescriptorSet &update, const DescriptorSet &src_set) {}

// Update the drawing state for the affected descriptors.
// Set cb_state to this set and this set to cb_state.
// Add the bindings of the descriptor
// Set the layout based on the current descriptor layout (will mask subsequent layer mismatch errors)
// TODO: Modify the UpdateDrawState virtural functions to *only* set initial layout and not change layouts
// Prereq: This should be called for a set that has been confirmed to be active for the given cb_state, meaning it's going
//   to be used in a draw by the given cb_state
void vvl::DescriptorSet::UpdateDrawState(ValidationStateTracker *device_data, vvl::CommandBuffer *cb_state, vvl::Func command,
                                         const vvl::Pipeline *pipe, const BindingVariableMap &binding_req_map) {}

// Helper template to change shared pointer members of a Descriptor, while
// correctly managing links to the parent DescriptorSet.
// src and dst are shared pointers.
template <typename T>
static void ReplaceStatePtr(DescriptorSet &set_state, T &dst, const T &src, bool is_bindless) {}

void vvl::SamplerDescriptor::WriteUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                     const VkWriteDescriptorSet &update, const uint32_t index, bool is_bindless) {}

void vvl::SamplerDescriptor::CopyUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                    const Descriptor &src, bool is_bindless, VkDescriptorType) {}

VkSampler vvl::SamplerDescriptor::GetSampler() const {}

void vvl::SamplerDescriptor::SetSamplerState(std::shared_ptr<vvl::Sampler> &&state) {}

bool vvl::SamplerDescriptor::AddParent(StateObject *state_object) {}
void vvl::SamplerDescriptor::RemoveParent(StateObject *state_object) {}
bool vvl::SamplerDescriptor::Invalid() const {}

void vvl::ImageSamplerDescriptor::WriteUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                          const VkWriteDescriptorSet &update, const uint32_t index,
                                                          bool is_bindless) {}

void vvl::ImageSamplerDescriptor::CopyUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                         const Descriptor &src, bool is_bindless, VkDescriptorType src_type) {}

VkSampler vvl::ImageSamplerDescriptor::GetSampler() const {}

void vvl::ImageSamplerDescriptor::SetSamplerState(std::shared_ptr<vvl::Sampler> &&state) {}

bool vvl::ImageSamplerDescriptor::AddParent(StateObject *state_object) {}
void vvl::ImageSamplerDescriptor::RemoveParent(StateObject *state_object) {}

bool vvl::ImageSamplerDescriptor::Invalid() const {}

void vvl::ImageDescriptor::WriteUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                   const VkWriteDescriptorSet &update, const uint32_t index, bool is_bindless) {}

void vvl::ImageDescriptor::CopyUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                  const Descriptor &src, bool is_bindless, VkDescriptorType src_type) {}

void vvl::ImageDescriptor::UpdateDrawState(ValidationStateTracker *dev_data, vvl::CommandBuffer *cb_state) {}

VkImageView vvl::ImageDescriptor::GetImageView() const {}

bool vvl::ImageDescriptor::AddParent(StateObject *state_object) {}
void vvl::ImageDescriptor::RemoveParent(StateObject *state_object) {}
void vvl::ImageDescriptor::InvalidateNode(const std::shared_ptr<StateObject> &invalid_node, bool unlink) {}

bool vvl::ImageDescriptor::Invalid() const {}
bool vvl::ImageDescriptor::ComputeInvalid() const {}
void vvl::ImageDescriptor::UpdateKnownValidView(bool is_bindless) {}

void vvl::BufferDescriptor::WriteUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                    const VkWriteDescriptorSet &update, const uint32_t index, bool is_bindless) {}

void vvl::BufferDescriptor::CopyUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                   const Descriptor &src, bool is_bindless, VkDescriptorType src_type) {}

VkBuffer vvl::BufferDescriptor::GetBuffer() const {}

bool vvl::BufferDescriptor::AddParent(StateObject *state_object) {}
void vvl::BufferDescriptor::RemoveParent(StateObject *state_object) {}
bool vvl::BufferDescriptor::Invalid() const {}

VkDeviceSize vvl::BufferDescriptor::GetEffectiveRange() const {}

void vvl::TexelDescriptor::WriteUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                   const VkWriteDescriptorSet &update, const uint32_t index, bool is_bindless) {}

void vvl::TexelDescriptor::CopyUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                  const Descriptor &src, bool is_bindless, VkDescriptorType src_type) {}

VkBufferView vvl::TexelDescriptor::GetBufferView() const {}

bool vvl::TexelDescriptor::AddParent(StateObject *state_object) {}
void vvl::TexelDescriptor::RemoveParent(StateObject *state_object) {}

bool vvl::TexelDescriptor::Invalid() const {}

void vvl::AccelerationStructureDescriptor::WriteUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                                   const VkWriteDescriptorSet &update, const uint32_t index,
                                                                   bool is_bindless) {}

void vvl::AccelerationStructureDescriptor::CopyUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                                  const Descriptor &src, bool is_bindless,
                                                                  VkDescriptorType src_type) {}

bool vvl::AccelerationStructureDescriptor::AddParent(StateObject *state_object) {}
void vvl::AccelerationStructureDescriptor::RemoveParent(StateObject *state_object) {}
bool vvl::AccelerationStructureDescriptor::Invalid() const {}

vvl::MutableDescriptor::MutableDescriptor()
    :{}

void vvl::MutableDescriptor::WriteUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                     const VkWriteDescriptorSet &update, const uint32_t index, bool is_bindless) {}

void vvl::MutableDescriptor::CopyUpdate(DescriptorSet &set_state, const ValidationStateTracker &dev_data,
                                                    const Descriptor &src, bool is_bindless, VkDescriptorType src_type) {}

void vvl::MutableDescriptor::SetDescriptorType(VkDescriptorType type, VkDeviceSize buffer_size) {}
void vvl::MutableDescriptor::SetDescriptorType(VkDescriptorType src_type, const Descriptor *src) {}

VkDeviceSize vvl::MutableDescriptor::GetEffectiveRange() const {}

void vvl::MutableDescriptor::UpdateDrawState(ValidationStateTracker *dev_data, vvl::CommandBuffer *cb_state) {}

bool vvl::MutableDescriptor::AddParent(StateObject *state_object) {}
void vvl::MutableDescriptor::RemoveParent(StateObject *state_object) {}

bool vvl::MutableDescriptor::Invalid() const {}