Path: blob/21.2-virgl/src/amd/vulkan/radv_descriptor_set.h
7233 views
/*1* Copyright © 2016 Bas Nieuwenhuizen2*3* Permission is hereby granted, free of charge, to any person obtaining a4* copy of this software and associated documentation files (the "Software"),5* to deal in the Software without restriction, including without limitation6* the rights to use, copy, modify, merge, publish, distribute, sublicense,7* and/or sell copies of the Software, and to permit persons to whom the8* Software is furnished to do so, subject to the following conditions:9*10* The above copyright notice and this permission notice (including the next11* paragraph) shall be included in all copies or substantial portions of the12* Software.13*14* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR15* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,16* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL17* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER18* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING19* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS20* IN THE SOFTWARE.21*/2223#ifndef RADV_DESCRIPTOR_SET_H24#define RADV_DESCRIPTOR_SET_H2526#include "radv_constants.h"2728#include "vulkan/util/vk_object.h"2930#include <vulkan/vulkan.h>3132struct radv_descriptor_set_binding_layout {33VkDescriptorType type;3435/* Number of array elements in this binding */36uint32_t array_size;3738uint32_t offset;39uint32_t buffer_offset;40uint16_t dynamic_offset_offset;4142uint16_t dynamic_offset_count;43/* redundant with the type, each for a single array element */44uint32_t size;4546/* Offset in the radv_descriptor_set_layout of the immutable samplers, or 047* if there are no immutable samplers. */48uint32_t immutable_samplers_offset;49bool immutable_samplers_equal;50};5152struct radv_descriptor_set_layout {53struct vk_object_base base;5455/* The create flags for this descriptor set layout */56VkDescriptorSetLayoutCreateFlags flags;5758/* Number of bindings in this descriptor set */59uint32_t binding_count;6061/* Total size of the descriptor set with room for all array entries */62uint32_t size;6364/* CPU size of this struct + all associated data, for hashing. */65uint32_t layout_size;6667/* Shader stages affected by this descriptor set */68uint16_t shader_stages;69uint16_t dynamic_shader_stages;7071/* Number of buffers in this descriptor set */72uint32_t buffer_count;7374/* Number of dynamic offsets used by this descriptor set */75uint16_t dynamic_offset_count;7677bool has_immutable_samplers;78bool has_variable_descriptors;7980uint32_t ycbcr_sampler_offsets_offset;8182/* Bindings in this descriptor set */83struct radv_descriptor_set_binding_layout binding[0];84};8586struct radv_pipeline_layout {87struct vk_object_base base;88struct {89struct radv_descriptor_set_layout *layout;90uint32_t size;91uint32_t dynamic_offset_start;92} set[MAX_SETS];9394uint32_t num_sets;95uint32_t push_constant_size;96uint32_t dynamic_offset_count;97uint16_t dynamic_shader_stages;9899unsigned char sha1[20];100};101102static inline const uint32_t *103radv_immutable_samplers(const struct radv_descriptor_set_layout *set,104const struct radv_descriptor_set_binding_layout *binding)105{106return (const uint32_t *)((const char *)set + binding->immutable_samplers_offset);107}108109static inline unsigned110radv_combined_image_descriptor_sampler_offset(111const struct radv_descriptor_set_binding_layout *binding)112{113return binding->size - ((!binding->immutable_samplers_equal) ? 16 : 0);114}115116static inline const struct radv_sampler_ycbcr_conversion *117radv_immutable_ycbcr_samplers(const struct radv_descriptor_set_layout *set, unsigned binding_index)118{119if (!set->ycbcr_sampler_offsets_offset)120return NULL;121122const uint32_t *offsets =123(const uint32_t *)((const char *)set + set->ycbcr_sampler_offsets_offset);124125if (offsets[binding_index] == 0)126return NULL;127return (const struct radv_sampler_ycbcr_conversion *)((const char *)set +128offsets[binding_index]);129}130#endif /* RADV_DESCRIPTOR_SET_H */131132133