Debian Codegraph @

src/imagination/vulkan/pvr_descriptor_set.h

raw
1 /*
2 * Copyright © 2022 Imagination Technologies Ltd.
3 *
4 * based in part on anv driver which is:
5 * Copyright © 2015 Intel Corporation
6 *
7 * based in part on radv driver which is:
8 * Copyright © 2016 Red Hat.
9 * Copyright © 2016 Bas Nieuwenhuizen
10 *
11 * SPDX-License-Identifier: MIT
12 */
13
14 #ifndef PVR_DESCRIPTOR_SET_H
15 #define PVR_DESCRIPTOR_SET_H
16
17 #include "util/list.h"
18 #include "util/vma.h"
19
20 #include "vk_descriptor_set_layout.h"
21
22 #include "pvr_common.h"
23 #include "pvr_macros.h"
24 #include "pvr_types.h"
25
26 struct pvr_descriptor_set_layout_binding {
27 VkDescriptorType type;
28 VkDescriptorBindingFlags flags;
29
30 uint32_t stage_flags; /** Which stages can use this binding. */
31
32 uint32_t descriptor_count;
33 uint32_t immutable_sampler_count;
34 struct pvr_sampler **immutable_samplers;
35
36 unsigned offset; /** Offset within the descriptor set. */
37 unsigned dynamic_buffer_idx;
38 unsigned stride; /** Stride of each descriptor in this binding. */
39 };
40
41 struct pvr_descriptor_set_layout {
42 struct vk_descriptor_set_layout vk;
43 VkDescriptorSetLayoutCreateFlagBits flags;
44
45 uint32_t descriptor_count;
46 uint32_t dynamic_buffer_count;
47
48 uint32_t binding_count;
49 struct pvr_descriptor_set_layout_binding *bindings;
50
51 uint32_t immutable_sampler_count;
52 struct pvr_sampler **immutable_samplers;
53
54 uint32_t stage_flags; /** Which stages can use this binding. */
55
56 unsigned size; /** Size in bytes. */
57 };
58
59 struct pvr_descriptor_pool {
60 struct vk_object_base base;
61
62 VkDescriptorType type;
63 VkAllocationCallbacks alloc;
64 VkDescriptorPoolCreateFlags flags;
65
66 /** List of the descriptor sets created using this pool. */
67 struct list_head desc_sets;
68
69 struct pvr_suballoc_bo *pvr_bo; /** Pool buffer object. */
70 void *mapping; /** Pool buffer CPU mapping. */
71 struct util_vma_heap heap; /** Pool (sub)allocation heap. */
72 };
73
74 struct pvr_descriptor {
75 VkDescriptorType type;
76
77 union {
78 struct {
79 struct pvr_buffer_view *bview;
80 pvr_dev_addr_t buffer_dev_addr;
81 VkDeviceSize buffer_desc_range;
82 VkDeviceSize buffer_whole_range;
83 };
84
85 struct {
86 VkImageLayout layout;
87 const struct pvr_image_view *iview;
88 const struct pvr_sampler *sampler;
89 };
90 };
91 };
92
93 struct pvr_descriptor_set {
94 struct vk_object_base base;
95 struct list_head link; /** Link in pvr_descriptor_pool::desc_sets. */
96
97 struct pvr_descriptor_set_layout *layout;
98 struct pvr_descriptor_pool *pool;
99
100 unsigned size; /** Descriptor set size. */
101 pvr_dev_addr_t dev_addr; /** Descriptor set device address. */
102 void *mapping; /** Descriptor set CPU mapping. */
103
104 struct pvr_buffer_descriptor dynamic_buffers[];
105 };
106
107 VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_descriptor_set_layout,
108 vk.base,
109 VkDescriptorSetLayout,
110 VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT)
111
112 VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_descriptor_set,
113 base,
114 VkDescriptorSet,
115 VK_OBJECT_TYPE_DESCRIPTOR_SET)
116
117 VK_DEFINE_NONDISP_HANDLE_CASTS(pvr_descriptor_pool,
118 base,
119 VkDescriptorPool,
120 VK_OBJECT_TYPE_DESCRIPTOR_POOL)
121
122 static inline struct pvr_descriptor_set_layout *
123 vk_to_pvr_descriptor_set_layout(struct vk_descriptor_set_layout *layout)
124 {
125 return container_of(layout, struct pvr_descriptor_set_layout, vk);
126 }
127
128 #ifdef PVR_PER_ARCH
129
130 void PVR_PER_ARCH(descriptor_set_write_immutable_samplers)(
131 struct pvr_descriptor_set_layout *layout,
132 struct pvr_descriptor_set *set);
133
134 #endif
135
136 #endif /* PVR_DESCRIPTOR_SET_H */