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