spirv_types/image_params.rs
1// Hack: u8 requires the Int8 capability, so instead of compiling this to a u8, compile it to a
2// u32. It's a little less efficient, but doesn't require the Int8 cap (and Arrayed values
3// shouldn't be stored in memory anyway, so it's no less memory used)
4#[repr(u32)]
5/// The access permissions for the image.
6#[derive(Copy, Clone, PartialEq, Eq)]
7pub enum AccessQualifier {
8 /// A read only image.
9 ReadOnly = 0,
10 /// A write only image.
11 WriteOnly = 1,
12 /// A readable and writable image.
13 ReadWrite = 2,
14}
15
16/// Whether the image uses arrayed content.
17#[repr(u32)]
18#[derive(Copy, Clone, PartialEq, Eq)]
19pub enum Arrayed {
20 /// The image uses not arrayed content.
21 False = 0,
22 /// The image uses arrayed content.
23 True = 1,
24}
25
26impl From<bool> for Arrayed {
27 fn from(val: bool) -> Self {
28 if val {
29 Self::True
30 } else {
31 Self::False
32 }
33 }
34}
35
36/// The dimension of the image.
37#[repr(u32)]
38#[derive(Copy, Clone, PartialEq, Eq)]
39pub enum Dimensionality {
40 /// 1D
41 OneD = 0,
42 /// 2D
43 TwoD = 1,
44 /// 3D
45 ThreeD = 2,
46 /// 2D Cubemap texture
47 Cube = 3,
48 /// 2D Rectangle texture
49 Rect = 4,
50 /// 1D Buffer texture
51 Buffer = 5,
52 /// Vulkan subpass buffer
53 SubpassData = 6,
54}
55
56/// Whether a given image contains [depth] information. **Note** Whether or not
57/// to perform depth comparisons is a property of the sampling code, not of this
58/// type.
59///
60/// [depth]: https://en.wikipedia.org/wiki/Depth_map
61#[repr(u32)]
62#[derive(Copy, Clone, PartialEq, Eq)]
63pub enum ImageDepth {
64 /// Indicates that the image does not contain depth information.
65 False = 0,
66 /// Indicates that the image contains depth information.
67 True = 1,
68 /// Indicates that is not known ahead of time whether the image has depth
69 /// information or not.
70 Unknown = 2,
71}
72
73#[cfg(not(target_arch = "spirv"))]
74impl From<Option<bool>> for ImageDepth {
75 fn from(val: Option<bool>) -> Self {
76 match val {
77 Some(true) => Self::True,
78 Some(false) => Self::False,
79 None => Self::Unknown,
80 }
81 }
82}
83
84impl From<bool> for ImageDepth {
85 fn from(val: bool) -> Self {
86 match val {
87 true => Self::True,
88 false => Self::False,
89 }
90 }
91}
92
93/// Whether the image uses arrayed content.
94#[repr(u32)]
95#[derive(Copy, Clone, PartialEq, Eq)]
96pub enum Multisampled {
97 /// The image contains single-sampled content.
98 False = 0,
99 /// The image contains multisampled content.
100 True = 1,
101}
102
103impl From<bool> for Multisampled {
104 fn from(val: bool) -> Self {
105 if val {
106 Self::True
107 } else {
108 Self::False
109 }
110 }
111}
112
113/// Whether or not the image will be accessed in combination with a sampler.
114#[repr(u32)]
115#[derive(Copy, Clone, PartialEq, Eq)]
116pub enum Sampled {
117 /// Indicates that it is not known ahead of time whether the image will use
118 /// a sampler or not.
119 Unknown = 0,
120 /// The image will be used with a sampler.
121 Yes = 1,
122 /// The image will not be used with a sampler.
123 No = 2,
124}
125
126#[cfg(not(target_arch = "spirv"))]
127impl From<Option<bool>> for Sampled {
128 fn from(val: Option<bool>) -> Self {
129 match val {
130 Some(true) => Self::Yes,
131 Some(false) => Self::No,
132 None => Self::Unknown,
133 }
134 }
135}
136
137impl From<bool> for Sampled {
138 fn from(val: bool) -> Self {
139 match val {
140 true => Self::Yes,
141 false => Self::No,
142 }
143 }
144}
145
146/// The underlying internal representation of the image.
147#[repr(u32)]
148#[derive(PartialEq, Eq)]
149pub enum ImageFormat {
150 /// Representation not known at compile time.
151 Unknown,
152 /// RGBA channels, 32 bit floating point per channel.
153 Rgba32f,
154 /// RGBA channels, 16 bit floating point per channel.
155 Rgba16f,
156 /// Single red channel, 32 bit floating point.
157 R32f,
158 /// RGBA channels, 8 bit unsigned normalized integer per channel.
159 Rgba8,
160 /// RGBA channels, 8 bit signed normalized integer per channel.
161 Rgba8Snorm,
162 /// Red+Green channels, 32 bit floating point per channel.
163 Rg32f,
164 /// Red+Green channels, 16 bit floating point per channel.
165 Rg16f,
166 /// 32 bits containing two 11 bit floating point numbers for the Red and Green
167 /// channels, and a 10 bit floating point number for the Blue channel.
168 R11fG11fB10f,
169 /// Single red channel, 16 bit floating point.
170 R16f,
171 /// RGBA channels, 16 bit unsigned normalized integer per channel.
172 Rgba16,
173 /// 32 bits containing three 10 bit unsigned normalized integers for the Red, Green, and Blue
174 /// channels, and a 2 bit unsigned normalized integer for the Alpha channel.
175 Rgb10A2,
176 /// Red+Green channels, 16 bit unsigned normalized integer per channel.
177 Rg16,
178 /// Red+Green channels, 8 bit unsigned normalized integer per channel.
179 Rg8,
180 /// Single red channel, 16 bit unsigned normalized integer.
181 R16,
182 /// Single red channel, 8 bit unsigned normalized integer.
183 R8,
184 /// RGBA channels, 16 bit signed normalized integer per channel.
185 Rgba16Snorm,
186 /// Red+Green channels, 16 bit signed normalized integer per channel.
187 Rg16Snorm,
188 /// Red+Green channels, 8 bit signed normalized integer per channel.
189 Rg8Snorm,
190 /// Single red channel, 16 bit signed normalized integer.
191 R16Snorm,
192 /// Single red channel, 8 bit signed normalized integer.
193 R8Snorm,
194 /// RGBA channels, 32 bit signed integer per channel (not normalized).
195 Rgba32i,
196 /// RGBA channels, 16 bit signed integer per channel (not normalized).
197 Rgba16i,
198 /// RGBA channels, 8 bit signed integer per channel (not normalized).
199 Rgba8i,
200 /// Single red channel, 32 bit signed integer (not normalized).
201 R32i,
202 /// Red+Green channels, 32 bit signed integer per channel (not normalized).
203 Rg32i,
204 /// Red+Green channels, 16 bit signed integer per channel (not normalized).
205 Rg16i,
206 /// Red+Green channels, 8 bit signed integer per channel (not normalized).
207 Rg8i,
208 /// Single red channel, 16 bit signed integer (not normalized).
209 R16i,
210 /// Single red channel, 8 bit signed integer (not normalized).
211 R8i,
212 /// RGBA channels, 32 bit unsigned integer per channel (not normalized).
213 Rgba32ui,
214 /// RGBA channels, 16 bit unsigned integer per channel (not normalized).
215 Rgba16ui,
216 /// RGBA channels, 8 bit unsigned integer per channel (not normalized).
217 Rgba8ui,
218 /// Single red channel, 32 bit unsigned integer (not normalized).
219 R32ui,
220 /// 32 bits containing three 10 bit unsigned integers for the Red, Green, and Blue channels,
221 /// and a 2 bit unsigned integer for the Alpha channel.
222 Rgb10A2ui,
223 /// Red+Green channels, 32 bit unsigned integer per channel (not normalized).
224 Rg32ui,
225 /// Red+Green channels, 16 bit unsigned integer per channel (not normalized).
226 Rg16ui,
227 /// Red+Green channels, 8 bit unsigned integer per channel (not normalized).
228 Rg8ui,
229 /// Single red channel, 16 bit unsigned integer (not normalized).
230 R16ui,
231 /// Single red channel, 8 bit unsigned integer (not normalized).
232 R8ui,
233 /// Single red channel, 64 bit unsigned integer (not normalized).
234 R64ui,
235 /// Single red channel, 64 bit signed integer (not normalized).
236 R64i,
237}