1 /* 2 * Copyright © 2022 Collabora Ltd. and Red Hat Inc. 3 * SPDX-License-Identifier: MIT 4 */ 5 #ifndef NVK_DESCRIPTOR_SET_LAYOUT 6 #define NVK_DESCRIPTOR_SET_LAYOUT 1 7 8 #include "nvk_private.h" 9 10 #include "vk_descriptor_set_layout.h" 11 #include "vk_object.h" 12 13 struct nvk_device; 14 struct nvk_physical_device; 15 struct nvk_sampler; 16 struct vk_pipeline_layout; 17 18 struct nvk_descriptor_set_binding_layout { 19 /* The type of the descriptors in this binding */ 20 VkDescriptorType type; 21 22 /* Flags provided when this binding was created */ 23 VkDescriptorBindingFlags flags; 24 25 /* Number of array elements in this binding (or size in bytes for inline 26 * uniform data) 27 */ 28 uint32_t array_size; 29 30 /* Offset into the descriptor buffer where this descriptor lives */ 31 uint32_t offset; 32 33 /* Stride between array elements in the descriptor buffer */ 34 uint8_t stride; 35 36 /* Index into the dynamic buffer binding array */ 37 uint8_t dynamic_buffer_index; 38 39 /* Immutable samplers (or NULL if no immutable samplers) */ 40 struct nvk_sampler **immutable_samplers; 41 }; 42 43 struct nvk_descriptor_set_layout { 44 struct vk_descriptor_set_layout vk; 45 46 /* Size of the descriptor buffer for this descriptor set */ 47 /* Does not contain the size needed for variable count descriptors */ 48 uint32_t non_variable_descriptor_buffer_size; 49 50 /* Number of dynamic UBO bindings in this set */ 51 uint8_t dynamic_buffer_count; 52 53 /* Number of bindings in this descriptor set */ 54 uint32_t binding_count; 55 56 /* Bindings in this descriptor set */ 57 struct nvk_descriptor_set_binding_layout binding[0]; 58 }; 59 60 VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_descriptor_set_layout, vk.base, 61 VkDescriptorSetLayout, 62 VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT) 63 64 void 65 nvk_descriptor_stride_align_for_type(const struct nvk_physical_device *pdev, 66 VkDescriptorType type, 67 const VkMutableDescriptorTypeListEXT *type_list, 68 uint32_t *stride, uint32_t *alignment); 69 70 static inline struct nvk_descriptor_set_layout * vk_to_nvk_descriptor_set_layout(struct vk_descriptor_set_layout * layout)71vk_to_nvk_descriptor_set_layout(struct vk_descriptor_set_layout *layout) 72 { 73 return container_of(layout, struct nvk_descriptor_set_layout, vk); 74 } 75 76 #endif 77