• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright 2019 Google LLC
3  * SPDX-License-Identifier: MIT
4  *
5  * based in part on anv and radv which are:
6  * Copyright © 2015 Intel Corporation
7  * Copyright © 2016 Red Hat.
8  * Copyright © 2016 Bas Nieuwenhuizen
9  */
10 
11 #ifndef VN_DESCRIPTOR_SET_H
12 #define VN_DESCRIPTOR_SET_H
13 
14 #include "vn_common.h"
15 
16 enum vn_descriptor_type {
17    VN_DESCRIPTOR_TYPE_SAMPLER,
18    VN_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
19    VN_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
20    VN_DESCRIPTOR_TYPE_STORAGE_IMAGE,
21    VN_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER,
22    VN_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER,
23    VN_DESCRIPTOR_TYPE_UNIFORM_BUFFER,
24    VN_DESCRIPTOR_TYPE_STORAGE_BUFFER,
25    VN_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC,
26    VN_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC,
27    VN_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
28    VN_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK,
29 
30    /* add new enum types before this line */
31    VN_NUM_DESCRIPTOR_TYPES,
32 };
33 
34 /* TODO refactor struct to track enum vn_descriptor_type type.
35  * On VkDescriptorSetLayout creation. When we check against
36  * VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK, it will be against
37  * VN_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK instead
38  */
39 struct vn_descriptor_set_layout_binding {
40    VkDescriptorType type;
41    uint32_t count;
42    bool has_immutable_samplers;
43 };
44 
45 struct vn_descriptor_set_layout {
46    struct vn_object_base base;
47 
48    struct vn_refcount refcount;
49 
50    uint32_t last_binding;
51    bool has_variable_descriptor_count;
52 
53    /* bindings must be the last field in the layout */
54    struct vn_descriptor_set_layout_binding bindings[];
55 };
56 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_set_layout,
57                                base.base,
58                                VkDescriptorSetLayout,
59                                VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT)
60 
61 struct vn_descriptor_pool_state {
62    uint32_t set_count;
63    uint32_t iub_binding_count;
64    uint32_t descriptor_counts[VN_NUM_DESCRIPTOR_TYPES];
65 };
66 
67 struct vn_descriptor_pool {
68    struct vn_object_base base;
69 
70    VkAllocationCallbacks allocator;
71    bool async_set_allocation;
72    struct vn_descriptor_pool_state max;
73    struct vn_descriptor_pool_state used;
74 
75    struct list_head descriptor_sets;
76 };
77 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_pool,
78                                base.base,
79                                VkDescriptorPool,
80                                VK_OBJECT_TYPE_DESCRIPTOR_POOL)
81 
82 struct vn_update_descriptor_sets {
83    uint32_t write_count;
84    VkWriteDescriptorSet *writes;
85    VkDescriptorImageInfo *images;
86    VkDescriptorBufferInfo *buffers;
87    VkBufferView *views;
88    VkWriteDescriptorSetInlineUniformBlock *iubs;
89 };
90 
91 struct vn_descriptor_set {
92    struct vn_object_base base;
93 
94    struct vn_descriptor_set_layout *layout;
95    uint32_t last_binding_descriptor_count;
96 
97    struct list_head head;
98 };
99 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_set,
100                                base.base,
101                                VkDescriptorSet,
102                                VK_OBJECT_TYPE_DESCRIPTOR_SET)
103 
104 struct vn_descriptor_update_template_entry {
105    size_t offset;
106    size_t stride;
107 };
108 
109 struct vn_descriptor_update_template {
110    struct vn_object_base base;
111 
112    mtx_t mutex;
113    struct vn_update_descriptor_sets *update;
114 
115    struct vn_descriptor_update_template_entry entries[];
116 };
117 VK_DEFINE_NONDISP_HANDLE_CASTS(vn_descriptor_update_template,
118                                base.base,
119                                VkDescriptorUpdateTemplate,
120                                VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE)
121 
122 #endif /* VN_DESCRIPTOR_SET_H */
123