1/* 2 * Copyright © 2016 Bas Nieuwenhuizen 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the 9 * Software is furnished to do so, subject to the following conditions: 10 * 11 * The above copyright notice and this permission notice (including the next 12 * paragraph) shall be included in all copies or substantial portions of the 13 * Software. 14 * 15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 21 * DEALINGS IN THE SOFTWARE. 22 */ 23 24#ifndef TU_DESCRIPTOR_SET_H 25#define TU_DESCRIPTOR_SET_H 26 27#include <vulkan/vulkan.h> 28 29#define MAX_SETS 32 30 31struct tu_descriptor_set_binding_layout 32{ 33 VkDescriptorType type; 34 35 /* Number of array elements in this binding */ 36 uint32_t array_size; 37 38 uint32_t offset; 39 uint32_t buffer_offset; 40 uint16_t dynamic_offset_offset; 41 42 uint16_t dynamic_offset_count; 43 /* redundant with the type, each for a single array element */ 44 uint32_t size; 45 46 /* Offset in the tu_descriptor_set_layout of the immutable samplers, or 0 47 * if there are no immutable samplers. */ 48 uint32_t immutable_samplers_offset; 49}; 50 51struct tu_descriptor_set_layout 52{ 53 /* The create flags for this descriptor set layout */ 54 VkDescriptorSetLayoutCreateFlags flags; 55 56 /* Number of bindings in this descriptor set */ 57 uint32_t binding_count; 58 59 /* Total size of the descriptor set with room for all array entries */ 60 uint32_t size; 61 62 /* Shader stages affected by this descriptor set */ 63 uint16_t shader_stages; 64 uint16_t dynamic_shader_stages; 65 66 /* Number of buffers in this descriptor set */ 67 uint32_t buffer_count; 68 69 /* Number of dynamic offsets used by this descriptor set */ 70 uint16_t dynamic_offset_count; 71 72 bool has_immutable_samplers; 73 bool has_variable_descriptors; 74 75 /* Bindings in this descriptor set */ 76 struct tu_descriptor_set_binding_layout binding[0]; 77}; 78 79struct tu_pipeline_layout 80{ 81 struct 82 { 83 struct tu_descriptor_set_layout *layout; 84 uint32_t size; 85 uint32_t dynamic_offset_start; 86 } set[MAX_SETS]; 87 88 uint32_t num_sets; 89 uint32_t push_constant_size; 90 uint32_t dynamic_offset_count; 91 92 unsigned char sha1[20]; 93}; 94 95static inline const uint32_t * 96tu_immutable_samplers(const struct tu_descriptor_set_layout *set, 97 const struct tu_descriptor_set_binding_layout *binding) 98{ 99 return (const uint32_t *) ((const char *) set + 100 binding->immutable_samplers_offset); 101} 102#endif /* TU_DESCRIPTOR_SET_H */ 103