Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/src/freedreno/vulkan/tu_descriptor_set.h
4565 views
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
/* The hardware supports 5 descriptor sets, but we reserve 1 for dynamic
30
* descriptors and input attachments.
31
*/
32
#define MAX_SETS 4
33
34
struct tu_descriptor_set_binding_layout
35
{
36
VkDescriptorType type;
37
38
/* Number of array elements in this binding */
39
uint32_t array_size;
40
41
/* The size in bytes of each Vulkan descriptor. */
42
uint32_t size;
43
44
uint32_t offset;
45
46
/* Index into the pDynamicOffsets array for dynamic descriptors, as well as
47
* the array of dynamic descriptors (offsetted by
48
* tu_pipeline_layout::set::dynamic_offset_start).
49
*/
50
uint32_t dynamic_offset_offset;
51
52
/* Offset in the tu_descriptor_set_layout of the immutable samplers, or 0
53
* if there are no immutable samplers. */
54
uint32_t immutable_samplers_offset;
55
56
/* Offset in the tu_descriptor_set_layout of the ycbcr samplers, or 0
57
* if there are no immutable samplers. */
58
uint32_t ycbcr_samplers_offset;
59
60
/* Shader stages that use this binding */
61
uint32_t shader_stages;
62
};
63
64
struct tu_descriptor_set_layout
65
{
66
struct vk_object_base base;
67
68
/* The create flags for this descriptor set layout */
69
VkDescriptorSetLayoutCreateFlags flags;
70
71
/* Number of bindings in this descriptor set */
72
uint32_t binding_count;
73
74
/* Total size of the descriptor set with room for all array entries */
75
uint32_t size;
76
77
/* Shader stages affected by this descriptor set */
78
uint16_t shader_stages;
79
80
/* Number of dynamic offsets used by this descriptor set */
81
uint16_t dynamic_offset_count;
82
83
/* A bitfield of which dynamic buffers are ubo's, to make the
84
* descriptor-binding-time patching easier.
85
*/
86
uint32_t dynamic_ubo;
87
88
bool has_immutable_samplers;
89
bool has_variable_descriptors;
90
91
/* Bindings in this descriptor set */
92
struct tu_descriptor_set_binding_layout binding[0];
93
};
94
95
struct tu_pipeline_layout
96
{
97
struct vk_object_base base;
98
99
struct
100
{
101
struct tu_descriptor_set_layout *layout;
102
uint32_t size;
103
uint32_t dynamic_offset_start;
104
} set[MAX_SETS];
105
106
uint32_t num_sets;
107
uint32_t push_constant_size;
108
uint32_t dynamic_offset_count;
109
};
110
111
static inline const struct tu_sampler *
112
tu_immutable_samplers(const struct tu_descriptor_set_layout *set,
113
const struct tu_descriptor_set_binding_layout *binding)
114
{
115
return (void *) ((const char *) set + binding->immutable_samplers_offset);
116
}
117
118
static inline const struct tu_sampler_ycbcr_conversion *
119
tu_immutable_ycbcr_samplers(const struct tu_descriptor_set_layout *set,
120
const struct tu_descriptor_set_binding_layout *binding)
121
{
122
if (!binding->ycbcr_samplers_offset)
123
return NULL;
124
125
return (void *) ((const char *) set + binding->ycbcr_samplers_offset);
126
}
127
128
#endif /* TU_DESCRIPTOR_SET_H */
129
130