Path: blob/21.2-virgl/src/freedreno/vulkan/tu_descriptor_set.h
4565 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 OTHER20* DEALINGS IN THE SOFTWARE.21*/2223#ifndef TU_DESCRIPTOR_SET_H24#define TU_DESCRIPTOR_SET_H2526#include <vulkan/vulkan.h>2728/* The hardware supports 5 descriptor sets, but we reserve 1 for dynamic29* descriptors and input attachments.30*/31#define MAX_SETS 43233struct tu_descriptor_set_binding_layout34{35VkDescriptorType type;3637/* Number of array elements in this binding */38uint32_t array_size;3940/* The size in bytes of each Vulkan descriptor. */41uint32_t size;4243uint32_t offset;4445/* Index into the pDynamicOffsets array for dynamic descriptors, as well as46* the array of dynamic descriptors (offsetted by47* tu_pipeline_layout::set::dynamic_offset_start).48*/49uint32_t dynamic_offset_offset;5051/* Offset in the tu_descriptor_set_layout of the immutable samplers, or 052* if there are no immutable samplers. */53uint32_t immutable_samplers_offset;5455/* Offset in the tu_descriptor_set_layout of the ycbcr samplers, or 056* if there are no immutable samplers. */57uint32_t ycbcr_samplers_offset;5859/* Shader stages that use this binding */60uint32_t shader_stages;61};6263struct tu_descriptor_set_layout64{65struct vk_object_base base;6667/* The create flags for this descriptor set layout */68VkDescriptorSetLayoutCreateFlags flags;6970/* Number of bindings in this descriptor set */71uint32_t binding_count;7273/* Total size of the descriptor set with room for all array entries */74uint32_t size;7576/* Shader stages affected by this descriptor set */77uint16_t shader_stages;7879/* Number of dynamic offsets used by this descriptor set */80uint16_t dynamic_offset_count;8182/* A bitfield of which dynamic buffers are ubo's, to make the83* descriptor-binding-time patching easier.84*/85uint32_t dynamic_ubo;8687bool has_immutable_samplers;88bool has_variable_descriptors;8990/* Bindings in this descriptor set */91struct tu_descriptor_set_binding_layout binding[0];92};9394struct tu_pipeline_layout95{96struct vk_object_base base;9798struct99{100struct tu_descriptor_set_layout *layout;101uint32_t size;102uint32_t dynamic_offset_start;103} set[MAX_SETS];104105uint32_t num_sets;106uint32_t push_constant_size;107uint32_t dynamic_offset_count;108};109110static inline const struct tu_sampler *111tu_immutable_samplers(const struct tu_descriptor_set_layout *set,112const struct tu_descriptor_set_binding_layout *binding)113{114return (void *) ((const char *) set + binding->immutable_samplers_offset);115}116117static inline const struct tu_sampler_ycbcr_conversion *118tu_immutable_ycbcr_samplers(const struct tu_descriptor_set_layout *set,119const struct tu_descriptor_set_binding_layout *binding)120{121if (!binding->ycbcr_samplers_offset)122return NULL;123124return (void *) ((const char *) set + binding->ycbcr_samplers_offset);125}126127#endif /* TU_DESCRIPTOR_SET_H */128129130