1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
pub use crate::backend::DescriptorSetLayout;
use crate::shader::ShaderStageFlags;
bitflags::bitflags! {
/// Flags that can be set in each [`DescriptorSetLayoutBinding`]
/// to specify options for the corresponding descriptor set layout binding.
/// Note that Vulkan 1.2 is required for any of these flags.
/// That is, the only valid value prior Vulkan 1.2 is `DescriptorBindingFlags::empty()`.
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
pub struct DescriptorBindingFlags: u32 {
/// Allows update binding after set is bound to encoder.
/// Updating binding without this flag would invalidate encoder or built command buffer
/// where set is used.
const UPDATE_AFTER_BIND = 0x00000001;
/// Allows descriptors that are not dynamically used by
/// any shader invocation to be unbound.
const PARTIALLY_BOUND = 0x00000002;
/// Allows updating descriptors in this binding that are not used.
/// while set is bound to pending command buffer.\
/// i.e. when shader may access other descriptors in the set.
///
/// If [`DescriptorBindingFlags::PARTIALLY_BOUND`] is also set then descriptors that are not
/// dynamically used by any shader invocation can be updated.
/// Otherwise only descriptors that are not statically used
/// by any shader invocation can be updated.
const UPDATE_UNUSED_WHILE_PENDING = 0x00000004;
/// Binding with this flag does not have descriptors count defined by layout.
/// Instead count is specified when set instance is created.
/// Allowing sets with same layout to have differently sized
/// arrays of descriptors bound to the binding.
const VARIABLE_DESCRIPTOR_COUNT = 0x00000008;
}
}
bitflags::bitflags! {
/// Flags that can be sed to
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
pub struct DescriptorSetLayoutFlags: u32 {
/// Specifies that set with this layout must not be allocated.
/// And descriptors should be pushed to encoder directly.
const PUSH_DESCRIPTOR = 0x00000001;
/// Allows bindings in this layout to have [`DescriptorBindingFlags::UPDATE_AFTER_BIND`] flags.
const UPDATE_AFTER_BIND_POOL = 0x00000002;
}
}
/// Defines layout for descriptor sets.
#[derive(Clone, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
pub struct DescriptorSetLayoutInfo {
/// Array of bindings in this layout.
/// Every element must have different `.binding` field.
pub bindings: Vec<DescriptorSetLayoutBinding>,
/// Flags to specify options for the descriptor set layout.
pub flags: DescriptorSetLayoutFlags,
}
/// Defines layout for one binding in descriptor set.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
pub struct DescriptorSetLayoutBinding {
/// Binding index.
pub binding: u32,
/// Type of descriptor in the binding.
pub ty: DescriptorType,
/// Number of descriptors in the binding.
pub count: u32,
/// Shader stages where this binding is accessible.
pub stages: ShaderStageFlags,
/// Flags to specify options for the descriptor set layout binding.
pub flags: DescriptorBindingFlags,
}
/// Types of descriptors.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
#[cfg_attr(feature = "serde-1", derive(serde::Serialize, serde::Deserialize))]
pub enum DescriptorType {
/// Sampler descriptor.\
/// Contains [`Sampler`] instances.
Sampler,
/// Combined image and sampler.\
/// Contains both [`ImageView`] and [`Sampler`] instances.
CombinedImageSampler,
/// Image that can be sampled.
/// Contains [`ImageView`] instance.
SampledImage,
/// Formatted view to the buffer data.
UniformTexelBuffer,
/// Formatted view to the buffer data.
/// Unlike [`UniformTexelBuffer`] content of [`StorageTexelBuffer`] can be overwritten by shader.
StorageTexelBuffer,
/// Image that can be used as storage.
/// Allows accessing individual pixels.
/// Unlike [`SampledImage`] [`StorageImage`] can be overwritten by shader.
StorageImage,
/// Buffer with shader uniform data.
UniformBuffer,
/// Buffer that can be used as storage.
/// Unlike [`UniformBuffer`] content of [`StorageBuffer`] can be overwritten by shader.
StorageBuffer,
/// Same as [`UniformBuffer`] but allows specifying offset each time set is bound to encoder.
UniformBufferDynamic,
/// Same as [`StorageBuffer`] but allows specifying offset each time set is bound to encoder.
StorageBufferDynamic,
/// Input attachment descriptor is an image with restricted access.
/// Only fragment shader can read from input attachment.
/// And only to the fragment's location.
/// Must correspond to input attachment configured in render-pass.
InputAttachment,
/// Acceleration structure for ray-tracing shaders and ray queries.
AccelerationStructure,
}