1#[cfg(any(feature = "rafx-gles2", feature = "rafx-gles3"))]
2type GLenum = u32;
3
4#[cfg(feature = "rafx-vulkan")]
5use ash::vk;
6#[cfg(feature = "rafx-metal")]
7use metal_rs::MTLPixelFormat;
8#[cfg(feature = "rafx-metal")]
9use metal_rs::MTLVertexFormat;
10#[cfg(feature = "serde-support")]
11use serde::{Deserialize, Serialize};
12#[cfg(feature = "rafx-dx12")]
13use windows::Win32::Graphics::Dxgi::Common as DxgiCommon;
14
15#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
19#[cfg_attr(feature = "serde-support", derive(Serialize, Deserialize))]
20#[allow(non_camel_case_types)]
21pub enum RafxFormat {
22 UNDEFINED,
23 R4G4_UNORM_PACK8,
24 R4G4B4A4_UNORM_PACK16,
25 B4G4R4A4_UNORM_PACK16,
26 R5G6B5_UNORM_PACK16,
27 B5G6R5_UNORM_PACK16,
28 R5G5B5A1_UNORM_PACK16,
29 B5G5R5A1_UNORM_PACK16,
30 A1R5G5B5_UNORM_PACK16,
31 R8_UNORM,
32 R8_SNORM,
33 R8_USCALED,
34 R8_SSCALED,
35 R8_UINT,
36 R8_SINT,
37 R8_SRGB,
38 R8G8_UNORM,
39 R8G8_SNORM,
40 R8G8_USCALED,
41 R8G8_SSCALED,
42 R8G8_UINT,
43 R8G8_SINT,
44 R8G8_SRGB,
45 R8G8B8_UNORM,
46 R8G8B8_SNORM,
47 R8G8B8_USCALED,
48 R8G8B8_SSCALED,
49 R8G8B8_UINT,
50 R8G8B8_SINT,
51 R8G8B8_SRGB,
52 B8G8R8_UNORM,
53 B8G8R8_SNORM,
54 B8G8R8_USCALED,
55 B8G8R8_SSCALED,
56 B8G8R8_UINT,
57 B8G8R8_SINT,
58 B8G8R8_SRGB,
59 R8G8B8A8_UNORM,
60 R8G8B8A8_SNORM,
61 R8G8B8A8_USCALED,
62 R8G8B8A8_SSCALED,
63 R8G8B8A8_UINT,
64 R8G8B8A8_SINT,
65 R8G8B8A8_SRGB,
66 B8G8R8A8_UNORM,
67 B8G8R8A8_SNORM,
68 B8G8R8A8_USCALED,
69 B8G8R8A8_SSCALED,
70 B8G8R8A8_UINT,
71 B8G8R8A8_SINT,
72 B8G8R8A8_SRGB,
73 A8B8G8R8_UNORM_PACK32,
74 A8B8G8R8_SNORM_PACK32,
75 A8B8G8R8_USCALED_PACK32,
76 A8B8G8R8_SSCALED_PACK32,
77 A8B8G8R8_UINT_PACK32,
78 A8B8G8R8_SINT_PACK32,
79 A8B8G8R8_SRGB_PACK32,
80 A2R10G10B10_UNORM_PACK32,
81 A2R10G10B10_SNORM_PACK32,
82 A2R10G10B10_USCALED_PACK32,
83 A2R10G10B10_SSCALED_PACK32,
84 A2R10G10B10_UINT_PACK32,
85 A2R10G10B10_SINT_PACK32,
86 A2B10G10R10_UNORM_PACK32,
87 A2B10G10R10_SNORM_PACK32,
88 A2B10G10R10_USCALED_PACK32,
89 A2B10G10R10_SSCALED_PACK32,
90 A2B10G10R10_UINT_PACK32,
91 A2B10G10R10_SINT_PACK32,
92 R16_UNORM,
93 R16_SNORM,
94 R16_USCALED,
95 R16_SSCALED,
96 R16_UINT,
97 R16_SINT,
98 R16_SFLOAT,
99 R16G16_UNORM,
100 R16G16_SNORM,
101 R16G16_USCALED,
102 R16G16_SSCALED,
103 R16G16_UINT,
104 R16G16_SINT,
105 R16G16_SFLOAT,
106 R16G16B16_UNORM,
107 R16G16B16_SNORM,
108 R16G16B16_USCALED,
109 R16G16B16_SSCALED,
110 R16G16B16_UINT,
111 R16G16B16_SINT,
112 R16G16B16_SFLOAT,
113 R16G16B16A16_UNORM,
114 R16G16B16A16_SNORM,
115 R16G16B16A16_USCALED,
116 R16G16B16A16_SSCALED,
117 R16G16B16A16_UINT,
118 R16G16B16A16_SINT,
119 R16G16B16A16_SFLOAT,
120 R32_UINT,
121 R32_SINT,
122 R32_SFLOAT,
123 R32G32_UINT,
124 R32G32_SINT,
125 R32G32_SFLOAT,
126 R32G32B32_UINT,
127 R32G32B32_SINT,
128 R32G32B32_SFLOAT,
129 R32G32B32A32_UINT,
130 R32G32B32A32_SINT,
131 R32G32B32A32_SFLOAT,
132 R64_UINT,
133 R64_SINT,
134 R64_SFLOAT,
135 R64G64_UINT,
136 R64G64_SINT,
137 R64G64_SFLOAT,
138 R64G64B64_UINT,
139 R64G64B64_SINT,
140 R64G64B64_SFLOAT,
141 R64G64B64A64_UINT,
142 R64G64B64A64_SINT,
143 R64G64B64A64_SFLOAT,
144 B10G11R11_UFLOAT_PACK32,
145 E5B9G9R9_UFLOAT_PACK32,
146 D16_UNORM,
147 X8_D24_UNORM_PACK32,
148 D32_SFLOAT,
149 S8_UINT,
150 D16_UNORM_S8_UINT,
151 D24_UNORM_S8_UINT,
152 D32_SFLOAT_S8_UINT,
153 BC1_RGB_UNORM_BLOCK,
154 BC1_RGB_SRGB_BLOCK,
155 BC1_RGBA_UNORM_BLOCK,
156 BC1_RGBA_SRGB_BLOCK,
157 BC2_UNORM_BLOCK,
158 BC2_SRGB_BLOCK,
159 BC3_UNORM_BLOCK,
160 BC3_SRGB_BLOCK,
161 BC4_UNORM_BLOCK,
162 BC4_SNORM_BLOCK,
163 BC5_UNORM_BLOCK,
164 BC5_SNORM_BLOCK,
165 BC6H_UFLOAT_BLOCK,
166 BC6H_SFLOAT_BLOCK,
167 BC7_UNORM_BLOCK,
168 BC7_SRGB_BLOCK,
169 ETC2_R8G8B8_UNORM_BLOCK,
170 ETC2_R8G8B8_SRGB_BLOCK,
171 ETC2_R8G8B8A1_UNORM_BLOCK,
172 ETC2_R8G8B8A1_SRGB_BLOCK,
173 ETC2_R8G8B8A8_UNORM_BLOCK,
174 ETC2_R8G8B8A8_SRGB_BLOCK,
175 EAC_R11_UNORM_BLOCK,
176 EAC_R11_SNORM_BLOCK,
177 EAC_R11G11_UNORM_BLOCK,
178 EAC_R11G11_SNORM_BLOCK,
179 ASTC_4X4_UNORM_BLOCK,
180 ASTC_4X4_SRGB_BLOCK,
181 ASTC_5X4_UNORM_BLOCK,
182 ASTC_5X4_SRGB_BLOCK,
183 ASTC_5X5_UNORM_BLOCK,
184 ASTC_5X5_SRGB_BLOCK,
185 ASTC_6X5_UNORM_BLOCK,
186 ASTC_6X5_SRGB_BLOCK,
187 ASTC_6X6_UNORM_BLOCK,
188 ASTC_6X6_SRGB_BLOCK,
189 ASTC_8X5_UNORM_BLOCK,
190 ASTC_8X5_SRGB_BLOCK,
191 ASTC_8X6_UNORM_BLOCK,
192 ASTC_8X6_SRGB_BLOCK,
193 ASTC_8X8_UNORM_BLOCK,
194 ASTC_8X8_SRGB_BLOCK,
195 ASTC_10X5_UNORM_BLOCK,
196 ASTC_10X5_SRGB_BLOCK,
197 ASTC_10X6_UNORM_BLOCK,
198 ASTC_10X6_SRGB_BLOCK,
199 ASTC_10X8_UNORM_BLOCK,
200 ASTC_10X8_SRGB_BLOCK,
201 ASTC_10X10_UNORM_BLOCK,
202 ASTC_10X10_SRGB_BLOCK,
203 ASTC_12X10_UNORM_BLOCK,
204 ASTC_12X10_SRGB_BLOCK,
205 ASTC_12X12_UNORM_BLOCK,
206 ASTC_12X12_SRGB_BLOCK,
207}
208
209impl Default for RafxFormat {
210 fn default() -> Self {
211 RafxFormat::UNDEFINED
212 }
213}
214
215#[cfg(feature = "rafx-vulkan")]
216impl Into<vk::Format> for RafxFormat {
217 fn into(self) -> vk::Format {
218 match self {
219 RafxFormat::UNDEFINED => vk::Format::UNDEFINED,
220 RafxFormat::R4G4_UNORM_PACK8 => vk::Format::R4G4_UNORM_PACK8,
221 RafxFormat::R4G4B4A4_UNORM_PACK16 => vk::Format::R4G4B4A4_UNORM_PACK16,
222 RafxFormat::B4G4R4A4_UNORM_PACK16 => vk::Format::B4G4R4A4_UNORM_PACK16,
223 RafxFormat::R5G6B5_UNORM_PACK16 => vk::Format::R5G6B5_UNORM_PACK16,
224 RafxFormat::B5G6R5_UNORM_PACK16 => vk::Format::B5G6R5_UNORM_PACK16,
225 RafxFormat::R5G5B5A1_UNORM_PACK16 => vk::Format::R5G5B5A1_UNORM_PACK16,
226 RafxFormat::B5G5R5A1_UNORM_PACK16 => vk::Format::B5G5R5A1_UNORM_PACK16,
227 RafxFormat::A1R5G5B5_UNORM_PACK16 => vk::Format::A1R5G5B5_UNORM_PACK16,
228 RafxFormat::R8_UNORM => vk::Format::R8_UNORM,
229 RafxFormat::R8_SNORM => vk::Format::R8_SNORM,
230 RafxFormat::R8_USCALED => vk::Format::R8_USCALED,
231 RafxFormat::R8_SSCALED => vk::Format::R8_SSCALED,
232 RafxFormat::R8_UINT => vk::Format::R8_UINT,
233 RafxFormat::R8_SINT => vk::Format::R8_SINT,
234 RafxFormat::R8_SRGB => vk::Format::R8_SRGB,
235 RafxFormat::R8G8_UNORM => vk::Format::R8G8_UNORM,
236 RafxFormat::R8G8_SNORM => vk::Format::R8G8_SNORM,
237 RafxFormat::R8G8_USCALED => vk::Format::R8G8_USCALED,
238 RafxFormat::R8G8_SSCALED => vk::Format::R8G8_SSCALED,
239 RafxFormat::R8G8_UINT => vk::Format::R8G8_UINT,
240 RafxFormat::R8G8_SINT => vk::Format::R8G8_SINT,
241 RafxFormat::R8G8_SRGB => vk::Format::R8G8_SRGB,
242 RafxFormat::R8G8B8_UNORM => vk::Format::R8G8B8_UNORM,
243 RafxFormat::R8G8B8_SNORM => vk::Format::R8G8B8_SNORM,
244 RafxFormat::R8G8B8_USCALED => vk::Format::R8G8B8_USCALED,
245 RafxFormat::R8G8B8_SSCALED => vk::Format::R8G8B8_SSCALED,
246 RafxFormat::R8G8B8_UINT => vk::Format::R8G8B8_UINT,
247 RafxFormat::R8G8B8_SINT => vk::Format::R8G8B8_SINT,
248 RafxFormat::R8G8B8_SRGB => vk::Format::R8G8B8_SRGB,
249 RafxFormat::B8G8R8_UNORM => vk::Format::B8G8R8_UNORM,
250 RafxFormat::B8G8R8_SNORM => vk::Format::B8G8R8_SNORM,
251 RafxFormat::B8G8R8_USCALED => vk::Format::B8G8R8_USCALED,
252 RafxFormat::B8G8R8_SSCALED => vk::Format::B8G8R8_SSCALED,
253 RafxFormat::B8G8R8_UINT => vk::Format::B8G8R8_UINT,
254 RafxFormat::B8G8R8_SINT => vk::Format::B8G8R8_SINT,
255 RafxFormat::B8G8R8_SRGB => vk::Format::B8G8R8_SRGB,
256 RafxFormat::R8G8B8A8_UNORM => vk::Format::R8G8B8A8_UNORM,
257 RafxFormat::R8G8B8A8_SNORM => vk::Format::R8G8B8A8_SNORM,
258 RafxFormat::R8G8B8A8_USCALED => vk::Format::R8G8B8A8_USCALED,
259 RafxFormat::R8G8B8A8_SSCALED => vk::Format::R8G8B8A8_SSCALED,
260 RafxFormat::R8G8B8A8_UINT => vk::Format::R8G8B8A8_UINT,
261 RafxFormat::R8G8B8A8_SINT => vk::Format::R8G8B8A8_SINT,
262 RafxFormat::R8G8B8A8_SRGB => vk::Format::R8G8B8A8_SRGB,
263 RafxFormat::B8G8R8A8_UNORM => vk::Format::B8G8R8A8_UNORM,
264 RafxFormat::B8G8R8A8_SNORM => vk::Format::B8G8R8A8_SNORM,
265 RafxFormat::B8G8R8A8_USCALED => vk::Format::B8G8R8A8_USCALED,
266 RafxFormat::B8G8R8A8_SSCALED => vk::Format::B8G8R8A8_SSCALED,
267 RafxFormat::B8G8R8A8_UINT => vk::Format::B8G8R8A8_UINT,
268 RafxFormat::B8G8R8A8_SINT => vk::Format::B8G8R8A8_SINT,
269 RafxFormat::B8G8R8A8_SRGB => vk::Format::B8G8R8A8_SRGB,
270 RafxFormat::A8B8G8R8_UNORM_PACK32 => vk::Format::A8B8G8R8_UNORM_PACK32,
271 RafxFormat::A8B8G8R8_SNORM_PACK32 => vk::Format::A8B8G8R8_SNORM_PACK32,
272 RafxFormat::A8B8G8R8_USCALED_PACK32 => vk::Format::A8B8G8R8_USCALED_PACK32,
273 RafxFormat::A8B8G8R8_SSCALED_PACK32 => vk::Format::A8B8G8R8_SSCALED_PACK32,
274 RafxFormat::A8B8G8R8_UINT_PACK32 => vk::Format::A8B8G8R8_UINT_PACK32,
275 RafxFormat::A8B8G8R8_SINT_PACK32 => vk::Format::A8B8G8R8_SINT_PACK32,
276 RafxFormat::A8B8G8R8_SRGB_PACK32 => vk::Format::A8B8G8R8_SRGB_PACK32,
277 RafxFormat::A2R10G10B10_UNORM_PACK32 => vk::Format::A2R10G10B10_UNORM_PACK32,
278 RafxFormat::A2R10G10B10_SNORM_PACK32 => vk::Format::A2R10G10B10_SNORM_PACK32,
279 RafxFormat::A2R10G10B10_USCALED_PACK32 => vk::Format::A2R10G10B10_USCALED_PACK32,
280 RafxFormat::A2R10G10B10_SSCALED_PACK32 => vk::Format::A2R10G10B10_SSCALED_PACK32,
281 RafxFormat::A2R10G10B10_UINT_PACK32 => vk::Format::A2R10G10B10_UINT_PACK32,
282 RafxFormat::A2R10G10B10_SINT_PACK32 => vk::Format::A2R10G10B10_SINT_PACK32,
283 RafxFormat::A2B10G10R10_UNORM_PACK32 => vk::Format::A2B10G10R10_UNORM_PACK32,
284 RafxFormat::A2B10G10R10_SNORM_PACK32 => vk::Format::A2B10G10R10_SNORM_PACK32,
285 RafxFormat::A2B10G10R10_USCALED_PACK32 => vk::Format::A2B10G10R10_USCALED_PACK32,
286 RafxFormat::A2B10G10R10_SSCALED_PACK32 => vk::Format::A2B10G10R10_SSCALED_PACK32,
287 RafxFormat::A2B10G10R10_UINT_PACK32 => vk::Format::A2B10G10R10_UINT_PACK32,
288 RafxFormat::A2B10G10R10_SINT_PACK32 => vk::Format::A2B10G10R10_SINT_PACK32,
289 RafxFormat::R16_UNORM => vk::Format::R16_UNORM,
290 RafxFormat::R16_SNORM => vk::Format::R16_SNORM,
291 RafxFormat::R16_USCALED => vk::Format::R16_USCALED,
292 RafxFormat::R16_SSCALED => vk::Format::R16_SSCALED,
293 RafxFormat::R16_UINT => vk::Format::R16_UINT,
294 RafxFormat::R16_SINT => vk::Format::R16_SINT,
295 RafxFormat::R16_SFLOAT => vk::Format::R16_SFLOAT,
296 RafxFormat::R16G16_UNORM => vk::Format::R16G16_UNORM,
297 RafxFormat::R16G16_SNORM => vk::Format::R16G16_SNORM,
298 RafxFormat::R16G16_USCALED => vk::Format::R16G16_USCALED,
299 RafxFormat::R16G16_SSCALED => vk::Format::R16G16_SSCALED,
300 RafxFormat::R16G16_UINT => vk::Format::R16G16_UINT,
301 RafxFormat::R16G16_SINT => vk::Format::R16G16_SINT,
302 RafxFormat::R16G16_SFLOAT => vk::Format::R16G16_SFLOAT,
303 RafxFormat::R16G16B16_UNORM => vk::Format::R16G16B16_UNORM,
304 RafxFormat::R16G16B16_SNORM => vk::Format::R16G16B16_SNORM,
305 RafxFormat::R16G16B16_USCALED => vk::Format::R16G16B16_USCALED,
306 RafxFormat::R16G16B16_SSCALED => vk::Format::R16G16B16_SSCALED,
307 RafxFormat::R16G16B16_UINT => vk::Format::R16G16B16_UINT,
308 RafxFormat::R16G16B16_SINT => vk::Format::R16G16B16_SINT,
309 RafxFormat::R16G16B16_SFLOAT => vk::Format::R16G16B16_SFLOAT,
310 RafxFormat::R16G16B16A16_UNORM => vk::Format::R16G16B16A16_UNORM,
311 RafxFormat::R16G16B16A16_SNORM => vk::Format::R16G16B16A16_SNORM,
312 RafxFormat::R16G16B16A16_USCALED => vk::Format::R16G16B16A16_USCALED,
313 RafxFormat::R16G16B16A16_SSCALED => vk::Format::R16G16B16A16_SSCALED,
314 RafxFormat::R16G16B16A16_UINT => vk::Format::R16G16B16A16_UINT,
315 RafxFormat::R16G16B16A16_SINT => vk::Format::R16G16B16A16_SINT,
316 RafxFormat::R16G16B16A16_SFLOAT => vk::Format::R16G16B16A16_SFLOAT,
317 RafxFormat::R32_UINT => vk::Format::R32_UINT,
318 RafxFormat::R32_SINT => vk::Format::R32_SINT,
319 RafxFormat::R32_SFLOAT => vk::Format::R32_SFLOAT,
320 RafxFormat::R32G32_UINT => vk::Format::R32G32_UINT,
321 RafxFormat::R32G32_SINT => vk::Format::R32G32_SINT,
322 RafxFormat::R32G32_SFLOAT => vk::Format::R32G32_SFLOAT,
323 RafxFormat::R32G32B32_UINT => vk::Format::R32G32B32_UINT,
324 RafxFormat::R32G32B32_SINT => vk::Format::R32G32B32_SINT,
325 RafxFormat::R32G32B32_SFLOAT => vk::Format::R32G32B32_SFLOAT,
326 RafxFormat::R32G32B32A32_UINT => vk::Format::R32G32B32A32_UINT,
327 RafxFormat::R32G32B32A32_SINT => vk::Format::R32G32B32A32_SINT,
328 RafxFormat::R32G32B32A32_SFLOAT => vk::Format::R32G32B32A32_SFLOAT,
329 RafxFormat::R64_UINT => vk::Format::R64_UINT,
330 RafxFormat::R64_SINT => vk::Format::R64_SINT,
331 RafxFormat::R64_SFLOAT => vk::Format::R64_SFLOAT,
332 RafxFormat::R64G64_UINT => vk::Format::R64G64_UINT,
333 RafxFormat::R64G64_SINT => vk::Format::R64G64_SINT,
334 RafxFormat::R64G64_SFLOAT => vk::Format::R64G64_SFLOAT,
335 RafxFormat::R64G64B64_UINT => vk::Format::R64G64B64_UINT,
336 RafxFormat::R64G64B64_SINT => vk::Format::R64G64B64_SINT,
337 RafxFormat::R64G64B64_SFLOAT => vk::Format::R64G64B64_SFLOAT,
338 RafxFormat::R64G64B64A64_UINT => vk::Format::R64G64B64A64_UINT,
339 RafxFormat::R64G64B64A64_SINT => vk::Format::R64G64B64A64_SINT,
340 RafxFormat::R64G64B64A64_SFLOAT => vk::Format::R64G64B64A64_SFLOAT,
341 RafxFormat::B10G11R11_UFLOAT_PACK32 => vk::Format::B10G11R11_UFLOAT_PACK32,
342 RafxFormat::E5B9G9R9_UFLOAT_PACK32 => vk::Format::E5B9G9R9_UFLOAT_PACK32,
343 RafxFormat::D16_UNORM => vk::Format::D16_UNORM,
344 RafxFormat::X8_D24_UNORM_PACK32 => vk::Format::X8_D24_UNORM_PACK32,
345 RafxFormat::D32_SFLOAT => vk::Format::D32_SFLOAT,
346 RafxFormat::S8_UINT => vk::Format::S8_UINT,
347 RafxFormat::D16_UNORM_S8_UINT => vk::Format::D16_UNORM_S8_UINT,
348 RafxFormat::D24_UNORM_S8_UINT => vk::Format::D24_UNORM_S8_UINT,
349 RafxFormat::D32_SFLOAT_S8_UINT => vk::Format::D32_SFLOAT_S8_UINT,
350 RafxFormat::BC1_RGB_UNORM_BLOCK => vk::Format::BC1_RGB_UNORM_BLOCK,
351 RafxFormat::BC1_RGB_SRGB_BLOCK => vk::Format::BC1_RGB_SRGB_BLOCK,
352 RafxFormat::BC1_RGBA_UNORM_BLOCK => vk::Format::BC1_RGBA_UNORM_BLOCK,
353 RafxFormat::BC1_RGBA_SRGB_BLOCK => vk::Format::BC1_RGBA_SRGB_BLOCK,
354 RafxFormat::BC2_UNORM_BLOCK => vk::Format::BC2_UNORM_BLOCK,
355 RafxFormat::BC2_SRGB_BLOCK => vk::Format::BC2_SRGB_BLOCK,
356 RafxFormat::BC3_UNORM_BLOCK => vk::Format::BC3_UNORM_BLOCK,
357 RafxFormat::BC3_SRGB_BLOCK => vk::Format::BC3_SRGB_BLOCK,
358 RafxFormat::BC4_UNORM_BLOCK => vk::Format::BC4_UNORM_BLOCK,
359 RafxFormat::BC4_SNORM_BLOCK => vk::Format::BC4_SNORM_BLOCK,
360 RafxFormat::BC5_UNORM_BLOCK => vk::Format::BC5_UNORM_BLOCK,
361 RafxFormat::BC5_SNORM_BLOCK => vk::Format::BC5_SNORM_BLOCK,
362 RafxFormat::BC6H_UFLOAT_BLOCK => vk::Format::BC6H_UFLOAT_BLOCK,
363 RafxFormat::BC6H_SFLOAT_BLOCK => vk::Format::BC6H_SFLOAT_BLOCK,
364 RafxFormat::BC7_UNORM_BLOCK => vk::Format::BC7_UNORM_BLOCK,
365 RafxFormat::BC7_SRGB_BLOCK => vk::Format::BC7_SRGB_BLOCK,
366 RafxFormat::ETC2_R8G8B8_UNORM_BLOCK => vk::Format::ETC2_R8G8B8_UNORM_BLOCK,
367 RafxFormat::ETC2_R8G8B8_SRGB_BLOCK => vk::Format::ETC2_R8G8B8_SRGB_BLOCK,
368 RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK => vk::Format::ETC2_R8G8B8A1_UNORM_BLOCK,
369 RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK => vk::Format::ETC2_R8G8B8A1_SRGB_BLOCK,
370 RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK => vk::Format::ETC2_R8G8B8A8_UNORM_BLOCK,
371 RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK => vk::Format::ETC2_R8G8B8A8_SRGB_BLOCK,
372 RafxFormat::EAC_R11_UNORM_BLOCK => vk::Format::EAC_R11_UNORM_BLOCK,
373 RafxFormat::EAC_R11_SNORM_BLOCK => vk::Format::EAC_R11_SNORM_BLOCK,
374 RafxFormat::EAC_R11G11_UNORM_BLOCK => vk::Format::EAC_R11G11_UNORM_BLOCK,
375 RafxFormat::EAC_R11G11_SNORM_BLOCK => vk::Format::EAC_R11G11_SNORM_BLOCK,
376 RafxFormat::ASTC_4X4_UNORM_BLOCK => vk::Format::ASTC_4X4_UNORM_BLOCK,
377 RafxFormat::ASTC_4X4_SRGB_BLOCK => vk::Format::ASTC_4X4_SRGB_BLOCK,
378 RafxFormat::ASTC_5X4_UNORM_BLOCK => vk::Format::ASTC_5X4_UNORM_BLOCK,
379 RafxFormat::ASTC_5X4_SRGB_BLOCK => vk::Format::ASTC_5X4_SRGB_BLOCK,
380 RafxFormat::ASTC_5X5_UNORM_BLOCK => vk::Format::ASTC_5X5_UNORM_BLOCK,
381 RafxFormat::ASTC_5X5_SRGB_BLOCK => vk::Format::ASTC_5X5_SRGB_BLOCK,
382 RafxFormat::ASTC_6X5_UNORM_BLOCK => vk::Format::ASTC_6X5_UNORM_BLOCK,
383 RafxFormat::ASTC_6X5_SRGB_BLOCK => vk::Format::ASTC_6X5_SRGB_BLOCK,
384 RafxFormat::ASTC_6X6_UNORM_BLOCK => vk::Format::ASTC_6X6_UNORM_BLOCK,
385 RafxFormat::ASTC_6X6_SRGB_BLOCK => vk::Format::ASTC_6X6_SRGB_BLOCK,
386 RafxFormat::ASTC_8X5_UNORM_BLOCK => vk::Format::ASTC_8X5_UNORM_BLOCK,
387 RafxFormat::ASTC_8X5_SRGB_BLOCK => vk::Format::ASTC_8X5_SRGB_BLOCK,
388 RafxFormat::ASTC_8X6_UNORM_BLOCK => vk::Format::ASTC_8X6_UNORM_BLOCK,
389 RafxFormat::ASTC_8X6_SRGB_BLOCK => vk::Format::ASTC_8X6_SRGB_BLOCK,
390 RafxFormat::ASTC_8X8_UNORM_BLOCK => vk::Format::ASTC_8X8_UNORM_BLOCK,
391 RafxFormat::ASTC_8X8_SRGB_BLOCK => vk::Format::ASTC_8X8_SRGB_BLOCK,
392 RafxFormat::ASTC_10X5_UNORM_BLOCK => vk::Format::ASTC_10X5_UNORM_BLOCK,
393 RafxFormat::ASTC_10X5_SRGB_BLOCK => vk::Format::ASTC_10X5_SRGB_BLOCK,
394 RafxFormat::ASTC_10X6_UNORM_BLOCK => vk::Format::ASTC_10X6_UNORM_BLOCK,
395 RafxFormat::ASTC_10X6_SRGB_BLOCK => vk::Format::ASTC_10X6_SRGB_BLOCK,
396 RafxFormat::ASTC_10X8_UNORM_BLOCK => vk::Format::ASTC_10X8_UNORM_BLOCK,
397 RafxFormat::ASTC_10X8_SRGB_BLOCK => vk::Format::ASTC_10X8_SRGB_BLOCK,
398 RafxFormat::ASTC_10X10_UNORM_BLOCK => vk::Format::ASTC_10X10_UNORM_BLOCK,
399 RafxFormat::ASTC_10X10_SRGB_BLOCK => vk::Format::ASTC_10X10_SRGB_BLOCK,
400 RafxFormat::ASTC_12X10_UNORM_BLOCK => vk::Format::ASTC_12X10_UNORM_BLOCK,
401 RafxFormat::ASTC_12X10_SRGB_BLOCK => vk::Format::ASTC_12X10_SRGB_BLOCK,
402 RafxFormat::ASTC_12X12_UNORM_BLOCK => vk::Format::ASTC_12X12_UNORM_BLOCK,
403 RafxFormat::ASTC_12X12_SRGB_BLOCK => vk::Format::ASTC_12X12_SRGB_BLOCK,
404 }
405 }
406}
407
408#[cfg(feature = "rafx-vulkan")]
409impl From<vk::Format> for RafxFormat {
410 fn from(format: vk::Format) -> RafxFormat {
411 match format {
412 vk::Format::UNDEFINED => RafxFormat::UNDEFINED,
413 vk::Format::R4G4_UNORM_PACK8 => RafxFormat::R4G4_UNORM_PACK8,
414 vk::Format::R4G4B4A4_UNORM_PACK16 => RafxFormat::R4G4B4A4_UNORM_PACK16,
415 vk::Format::B4G4R4A4_UNORM_PACK16 => RafxFormat::B4G4R4A4_UNORM_PACK16,
416 vk::Format::R5G6B5_UNORM_PACK16 => RafxFormat::R5G6B5_UNORM_PACK16,
417 vk::Format::B5G6R5_UNORM_PACK16 => RafxFormat::B5G6R5_UNORM_PACK16,
418 vk::Format::R5G5B5A1_UNORM_PACK16 => RafxFormat::R5G5B5A1_UNORM_PACK16,
419 vk::Format::B5G5R5A1_UNORM_PACK16 => RafxFormat::B5G5R5A1_UNORM_PACK16,
420 vk::Format::A1R5G5B5_UNORM_PACK16 => RafxFormat::A1R5G5B5_UNORM_PACK16,
421 vk::Format::R8_UNORM => RafxFormat::R8_UNORM,
422 vk::Format::R8_SNORM => RafxFormat::R8_SNORM,
423 vk::Format::R8_USCALED => RafxFormat::R8_USCALED,
424 vk::Format::R8_SSCALED => RafxFormat::R8_SSCALED,
425 vk::Format::R8_UINT => RafxFormat::R8_UINT,
426 vk::Format::R8_SINT => RafxFormat::R8_SINT,
427 vk::Format::R8_SRGB => RafxFormat::R8_SRGB,
428 vk::Format::R8G8_UNORM => RafxFormat::R8G8_UNORM,
429 vk::Format::R8G8_SNORM => RafxFormat::R8G8_SNORM,
430 vk::Format::R8G8_USCALED => RafxFormat::R8G8_USCALED,
431 vk::Format::R8G8_SSCALED => RafxFormat::R8G8_SSCALED,
432 vk::Format::R8G8_UINT => RafxFormat::R8G8_UINT,
433 vk::Format::R8G8_SINT => RafxFormat::R8G8_SINT,
434 vk::Format::R8G8_SRGB => RafxFormat::R8G8_SRGB,
435 vk::Format::R8G8B8_UNORM => RafxFormat::R8G8B8_UNORM,
436 vk::Format::R8G8B8_SNORM => RafxFormat::R8G8B8_SNORM,
437 vk::Format::R8G8B8_USCALED => RafxFormat::R8G8B8_USCALED,
438 vk::Format::R8G8B8_SSCALED => RafxFormat::R8G8B8_SSCALED,
439 vk::Format::R8G8B8_UINT => RafxFormat::R8G8B8_UINT,
440 vk::Format::R8G8B8_SINT => RafxFormat::R8G8B8_SINT,
441 vk::Format::R8G8B8_SRGB => RafxFormat::R8G8B8_SRGB,
442 vk::Format::B8G8R8_UNORM => RafxFormat::B8G8R8_UNORM,
443 vk::Format::B8G8R8_SNORM => RafxFormat::B8G8R8_SNORM,
444 vk::Format::B8G8R8_USCALED => RafxFormat::B8G8R8_USCALED,
445 vk::Format::B8G8R8_SSCALED => RafxFormat::B8G8R8_SSCALED,
446 vk::Format::B8G8R8_UINT => RafxFormat::B8G8R8_UINT,
447 vk::Format::B8G8R8_SINT => RafxFormat::B8G8R8_SINT,
448 vk::Format::B8G8R8_SRGB => RafxFormat::B8G8R8_SRGB,
449 vk::Format::R8G8B8A8_UNORM => RafxFormat::R8G8B8A8_UNORM,
450 vk::Format::R8G8B8A8_SNORM => RafxFormat::R8G8B8A8_SNORM,
451 vk::Format::R8G8B8A8_USCALED => RafxFormat::R8G8B8A8_USCALED,
452 vk::Format::R8G8B8A8_SSCALED => RafxFormat::R8G8B8A8_SSCALED,
453 vk::Format::R8G8B8A8_UINT => RafxFormat::R8G8B8A8_UINT,
454 vk::Format::R8G8B8A8_SINT => RafxFormat::R8G8B8A8_SINT,
455 vk::Format::R8G8B8A8_SRGB => RafxFormat::R8G8B8A8_SRGB,
456 vk::Format::B8G8R8A8_UNORM => RafxFormat::B8G8R8A8_UNORM,
457 vk::Format::B8G8R8A8_SNORM => RafxFormat::B8G8R8A8_SNORM,
458 vk::Format::B8G8R8A8_USCALED => RafxFormat::B8G8R8A8_USCALED,
459 vk::Format::B8G8R8A8_SSCALED => RafxFormat::B8G8R8A8_SSCALED,
460 vk::Format::B8G8R8A8_UINT => RafxFormat::B8G8R8A8_UINT,
461 vk::Format::B8G8R8A8_SINT => RafxFormat::B8G8R8A8_SINT,
462 vk::Format::B8G8R8A8_SRGB => RafxFormat::B8G8R8A8_SRGB,
463 vk::Format::A8B8G8R8_UNORM_PACK32 => RafxFormat::A8B8G8R8_UNORM_PACK32,
464 vk::Format::A8B8G8R8_SNORM_PACK32 => RafxFormat::A8B8G8R8_SNORM_PACK32,
465 vk::Format::A8B8G8R8_USCALED_PACK32 => RafxFormat::A8B8G8R8_USCALED_PACK32,
466 vk::Format::A8B8G8R8_SSCALED_PACK32 => RafxFormat::A8B8G8R8_SSCALED_PACK32,
467 vk::Format::A8B8G8R8_UINT_PACK32 => RafxFormat::A8B8G8R8_UINT_PACK32,
468 vk::Format::A8B8G8R8_SINT_PACK32 => RafxFormat::A8B8G8R8_SINT_PACK32,
469 vk::Format::A8B8G8R8_SRGB_PACK32 => RafxFormat::A8B8G8R8_SRGB_PACK32,
470 vk::Format::A2R10G10B10_UNORM_PACK32 => RafxFormat::A2R10G10B10_UNORM_PACK32,
471 vk::Format::A2R10G10B10_SNORM_PACK32 => RafxFormat::A2R10G10B10_SNORM_PACK32,
472 vk::Format::A2R10G10B10_USCALED_PACK32 => RafxFormat::A2R10G10B10_USCALED_PACK32,
473 vk::Format::A2R10G10B10_SSCALED_PACK32 => RafxFormat::A2R10G10B10_SSCALED_PACK32,
474 vk::Format::A2R10G10B10_UINT_PACK32 => RafxFormat::A2R10G10B10_UINT_PACK32,
475 vk::Format::A2R10G10B10_SINT_PACK32 => RafxFormat::A2R10G10B10_SINT_PACK32,
476 vk::Format::A2B10G10R10_UNORM_PACK32 => RafxFormat::A2B10G10R10_UNORM_PACK32,
477 vk::Format::A2B10G10R10_SNORM_PACK32 => RafxFormat::A2B10G10R10_SNORM_PACK32,
478 vk::Format::A2B10G10R10_USCALED_PACK32 => RafxFormat::A2B10G10R10_USCALED_PACK32,
479 vk::Format::A2B10G10R10_SSCALED_PACK32 => RafxFormat::A2B10G10R10_SSCALED_PACK32,
480 vk::Format::A2B10G10R10_UINT_PACK32 => RafxFormat::A2B10G10R10_UINT_PACK32,
481 vk::Format::A2B10G10R10_SINT_PACK32 => RafxFormat::A2B10G10R10_SINT_PACK32,
482 vk::Format::R16_UNORM => RafxFormat::R16_UNORM,
483 vk::Format::R16_SNORM => RafxFormat::R16_SNORM,
484 vk::Format::R16_USCALED => RafxFormat::R16_USCALED,
485 vk::Format::R16_SSCALED => RafxFormat::R16_SSCALED,
486 vk::Format::R16_UINT => RafxFormat::R16_UINT,
487 vk::Format::R16_SINT => RafxFormat::R16_SINT,
488 vk::Format::R16_SFLOAT => RafxFormat::R16_SFLOAT,
489 vk::Format::R16G16_UNORM => RafxFormat::R16G16_UNORM,
490 vk::Format::R16G16_SNORM => RafxFormat::R16G16_SNORM,
491 vk::Format::R16G16_USCALED => RafxFormat::R16G16_USCALED,
492 vk::Format::R16G16_SSCALED => RafxFormat::R16G16_SSCALED,
493 vk::Format::R16G16_UINT => RafxFormat::R16G16_UINT,
494 vk::Format::R16G16_SINT => RafxFormat::R16G16_SINT,
495 vk::Format::R16G16_SFLOAT => RafxFormat::R16G16_SFLOAT,
496 vk::Format::R16G16B16_UNORM => RafxFormat::R16G16B16_UNORM,
497 vk::Format::R16G16B16_SNORM => RafxFormat::R16G16B16_SNORM,
498 vk::Format::R16G16B16_USCALED => RafxFormat::R16G16B16_USCALED,
499 vk::Format::R16G16B16_SSCALED => RafxFormat::R16G16B16_SSCALED,
500 vk::Format::R16G16B16_UINT => RafxFormat::R16G16B16_UINT,
501 vk::Format::R16G16B16_SINT => RafxFormat::R16G16B16_SINT,
502 vk::Format::R16G16B16_SFLOAT => RafxFormat::R16G16B16_SFLOAT,
503 vk::Format::R16G16B16A16_UNORM => RafxFormat::R16G16B16A16_UNORM,
504 vk::Format::R16G16B16A16_SNORM => RafxFormat::R16G16B16A16_SNORM,
505 vk::Format::R16G16B16A16_USCALED => RafxFormat::R16G16B16A16_USCALED,
506 vk::Format::R16G16B16A16_SSCALED => RafxFormat::R16G16B16A16_SSCALED,
507 vk::Format::R16G16B16A16_UINT => RafxFormat::R16G16B16A16_UINT,
508 vk::Format::R16G16B16A16_SINT => RafxFormat::R16G16B16A16_SINT,
509 vk::Format::R16G16B16A16_SFLOAT => RafxFormat::R16G16B16A16_SFLOAT,
510 vk::Format::R32_UINT => RafxFormat::R32_UINT,
511 vk::Format::R32_SINT => RafxFormat::R32_SINT,
512 vk::Format::R32_SFLOAT => RafxFormat::R32_SFLOAT,
513 vk::Format::R32G32_UINT => RafxFormat::R32G32_UINT,
514 vk::Format::R32G32_SINT => RafxFormat::R32G32_SINT,
515 vk::Format::R32G32_SFLOAT => RafxFormat::R32G32_SFLOAT,
516 vk::Format::R32G32B32_UINT => RafxFormat::R32G32B32_UINT,
517 vk::Format::R32G32B32_SINT => RafxFormat::R32G32B32_SINT,
518 vk::Format::R32G32B32_SFLOAT => RafxFormat::R32G32B32_SFLOAT,
519 vk::Format::R32G32B32A32_UINT => RafxFormat::R32G32B32A32_UINT,
520 vk::Format::R32G32B32A32_SINT => RafxFormat::R32G32B32A32_SINT,
521 vk::Format::R32G32B32A32_SFLOAT => RafxFormat::R32G32B32A32_SFLOAT,
522 vk::Format::R64_UINT => RafxFormat::R64_UINT,
523 vk::Format::R64_SINT => RafxFormat::R64_SINT,
524 vk::Format::R64_SFLOAT => RafxFormat::R64_SFLOAT,
525 vk::Format::R64G64_UINT => RafxFormat::R64G64_UINT,
526 vk::Format::R64G64_SINT => RafxFormat::R64G64_SINT,
527 vk::Format::R64G64_SFLOAT => RafxFormat::R64G64_SFLOAT,
528 vk::Format::R64G64B64_UINT => RafxFormat::R64G64B64_UINT,
529 vk::Format::R64G64B64_SINT => RafxFormat::R64G64B64_SINT,
530 vk::Format::R64G64B64_SFLOAT => RafxFormat::R64G64B64_SFLOAT,
531 vk::Format::R64G64B64A64_UINT => RafxFormat::R64G64B64A64_UINT,
532 vk::Format::R64G64B64A64_SINT => RafxFormat::R64G64B64A64_SINT,
533 vk::Format::R64G64B64A64_SFLOAT => RafxFormat::R64G64B64A64_SFLOAT,
534 vk::Format::B10G11R11_UFLOAT_PACK32 => RafxFormat::B10G11R11_UFLOAT_PACK32,
535 vk::Format::E5B9G9R9_UFLOAT_PACK32 => RafxFormat::E5B9G9R9_UFLOAT_PACK32,
536 vk::Format::D16_UNORM => RafxFormat::D16_UNORM,
537 vk::Format::X8_D24_UNORM_PACK32 => RafxFormat::X8_D24_UNORM_PACK32,
538 vk::Format::D32_SFLOAT => RafxFormat::D32_SFLOAT,
539 vk::Format::S8_UINT => RafxFormat::S8_UINT,
540 vk::Format::D16_UNORM_S8_UINT => RafxFormat::D16_UNORM_S8_UINT,
541 vk::Format::D24_UNORM_S8_UINT => RafxFormat::D24_UNORM_S8_UINT,
542 vk::Format::D32_SFLOAT_S8_UINT => RafxFormat::D32_SFLOAT_S8_UINT,
543 vk::Format::BC1_RGB_UNORM_BLOCK => RafxFormat::BC1_RGB_UNORM_BLOCK,
544 vk::Format::BC1_RGB_SRGB_BLOCK => RafxFormat::BC1_RGB_SRGB_BLOCK,
545 vk::Format::BC1_RGBA_UNORM_BLOCK => RafxFormat::BC1_RGBA_UNORM_BLOCK,
546 vk::Format::BC1_RGBA_SRGB_BLOCK => RafxFormat::BC1_RGBA_SRGB_BLOCK,
547 vk::Format::BC2_UNORM_BLOCK => RafxFormat::BC2_UNORM_BLOCK,
548 vk::Format::BC2_SRGB_BLOCK => RafxFormat::BC2_SRGB_BLOCK,
549 vk::Format::BC3_UNORM_BLOCK => RafxFormat::BC3_UNORM_BLOCK,
550 vk::Format::BC3_SRGB_BLOCK => RafxFormat::BC3_SRGB_BLOCK,
551 vk::Format::BC4_UNORM_BLOCK => RafxFormat::BC4_UNORM_BLOCK,
552 vk::Format::BC4_SNORM_BLOCK => RafxFormat::BC4_SNORM_BLOCK,
553 vk::Format::BC5_UNORM_BLOCK => RafxFormat::BC5_UNORM_BLOCK,
554 vk::Format::BC5_SNORM_BLOCK => RafxFormat::BC5_SNORM_BLOCK,
555 vk::Format::BC6H_UFLOAT_BLOCK => RafxFormat::BC6H_UFLOAT_BLOCK,
556 vk::Format::BC6H_SFLOAT_BLOCK => RafxFormat::BC6H_SFLOAT_BLOCK,
557 vk::Format::BC7_UNORM_BLOCK => RafxFormat::BC7_UNORM_BLOCK,
558 vk::Format::BC7_SRGB_BLOCK => RafxFormat::BC7_SRGB_BLOCK,
559 vk::Format::ETC2_R8G8B8_UNORM_BLOCK => RafxFormat::ETC2_R8G8B8_UNORM_BLOCK,
560 vk::Format::ETC2_R8G8B8_SRGB_BLOCK => RafxFormat::ETC2_R8G8B8_SRGB_BLOCK,
561 vk::Format::ETC2_R8G8B8A1_UNORM_BLOCK => RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK,
562 vk::Format::ETC2_R8G8B8A1_SRGB_BLOCK => RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK,
563 vk::Format::ETC2_R8G8B8A8_UNORM_BLOCK => RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK,
564 vk::Format::ETC2_R8G8B8A8_SRGB_BLOCK => RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK,
565 vk::Format::EAC_R11_UNORM_BLOCK => RafxFormat::EAC_R11_UNORM_BLOCK,
566 vk::Format::EAC_R11_SNORM_BLOCK => RafxFormat::EAC_R11_SNORM_BLOCK,
567 vk::Format::EAC_R11G11_UNORM_BLOCK => RafxFormat::EAC_R11G11_UNORM_BLOCK,
568 vk::Format::EAC_R11G11_SNORM_BLOCK => RafxFormat::EAC_R11G11_SNORM_BLOCK,
569 vk::Format::ASTC_4X4_UNORM_BLOCK => RafxFormat::ASTC_4X4_UNORM_BLOCK,
570 vk::Format::ASTC_4X4_SRGB_BLOCK => RafxFormat::ASTC_4X4_SRGB_BLOCK,
571 vk::Format::ASTC_5X4_UNORM_BLOCK => RafxFormat::ASTC_5X4_UNORM_BLOCK,
572 vk::Format::ASTC_5X4_SRGB_BLOCK => RafxFormat::ASTC_5X4_SRGB_BLOCK,
573 vk::Format::ASTC_5X5_UNORM_BLOCK => RafxFormat::ASTC_5X5_UNORM_BLOCK,
574 vk::Format::ASTC_5X5_SRGB_BLOCK => RafxFormat::ASTC_5X5_SRGB_BLOCK,
575 vk::Format::ASTC_6X5_UNORM_BLOCK => RafxFormat::ASTC_6X5_UNORM_BLOCK,
576 vk::Format::ASTC_6X5_SRGB_BLOCK => RafxFormat::ASTC_6X5_SRGB_BLOCK,
577 vk::Format::ASTC_6X6_UNORM_BLOCK => RafxFormat::ASTC_6X6_UNORM_BLOCK,
578 vk::Format::ASTC_6X6_SRGB_BLOCK => RafxFormat::ASTC_6X6_SRGB_BLOCK,
579 vk::Format::ASTC_8X5_UNORM_BLOCK => RafxFormat::ASTC_8X5_UNORM_BLOCK,
580 vk::Format::ASTC_8X5_SRGB_BLOCK => RafxFormat::ASTC_8X5_SRGB_BLOCK,
581 vk::Format::ASTC_8X6_UNORM_BLOCK => RafxFormat::ASTC_8X6_UNORM_BLOCK,
582 vk::Format::ASTC_8X6_SRGB_BLOCK => RafxFormat::ASTC_8X6_SRGB_BLOCK,
583 vk::Format::ASTC_8X8_UNORM_BLOCK => RafxFormat::ASTC_8X8_UNORM_BLOCK,
584 vk::Format::ASTC_8X8_SRGB_BLOCK => RafxFormat::ASTC_8X8_SRGB_BLOCK,
585 vk::Format::ASTC_10X5_UNORM_BLOCK => RafxFormat::ASTC_10X5_UNORM_BLOCK,
586 vk::Format::ASTC_10X5_SRGB_BLOCK => RafxFormat::ASTC_10X5_SRGB_BLOCK,
587 vk::Format::ASTC_10X6_UNORM_BLOCK => RafxFormat::ASTC_10X6_UNORM_BLOCK,
588 vk::Format::ASTC_10X6_SRGB_BLOCK => RafxFormat::ASTC_10X6_SRGB_BLOCK,
589 vk::Format::ASTC_10X8_UNORM_BLOCK => RafxFormat::ASTC_10X8_UNORM_BLOCK,
590 vk::Format::ASTC_10X8_SRGB_BLOCK => RafxFormat::ASTC_10X8_SRGB_BLOCK,
591 vk::Format::ASTC_10X10_UNORM_BLOCK => RafxFormat::ASTC_10X10_UNORM_BLOCK,
592 vk::Format::ASTC_10X10_SRGB_BLOCK => RafxFormat::ASTC_10X10_SRGB_BLOCK,
593 vk::Format::ASTC_12X10_UNORM_BLOCK => RafxFormat::ASTC_12X10_UNORM_BLOCK,
594 vk::Format::ASTC_12X10_SRGB_BLOCK => RafxFormat::ASTC_12X10_SRGB_BLOCK,
595 vk::Format::ASTC_12X12_UNORM_BLOCK => RafxFormat::ASTC_12X12_UNORM_BLOCK,
596 vk::Format::ASTC_12X12_SRGB_BLOCK => RafxFormat::ASTC_12X12_SRGB_BLOCK,
597 _ => unimplemented!(),
598 }
599 }
600}
601
602#[cfg(feature = "rafx-dx12")]
603impl Into<DxgiCommon::DXGI_FORMAT> for RafxFormat {
604 fn into(self) -> DxgiCommon::DXGI_FORMAT {
605 match self {
606 RafxFormat::UNDEFINED => DxgiCommon::DXGI_FORMAT_UNKNOWN,
607 RafxFormat::B4G4R4A4_UNORM_PACK16 => DxgiCommon::DXGI_FORMAT_B4G4R4A4_UNORM,
610 RafxFormat::B5G6R5_UNORM_PACK16 => DxgiCommon::DXGI_FORMAT_B5G6R5_UNORM,
612 RafxFormat::B5G5R5A1_UNORM_PACK16 => DxgiCommon::DXGI_FORMAT_B5G5R5A1_UNORM,
614 RafxFormat::R8_UNORM => DxgiCommon::DXGI_FORMAT_R8_UNORM,
616 RafxFormat::R8_SNORM => DxgiCommon::DXGI_FORMAT_R8_SNORM,
617 RafxFormat::R8_UINT => DxgiCommon::DXGI_FORMAT_R8_UINT,
620 RafxFormat::R8_SINT => DxgiCommon::DXGI_FORMAT_R8_SINT,
621 RafxFormat::R8G8_UNORM => DxgiCommon::DXGI_FORMAT_R8G8_UNORM,
623 RafxFormat::R8G8_SNORM => DxgiCommon::DXGI_FORMAT_R8G8_SNORM,
624 RafxFormat::R8G8_UINT => DxgiCommon::DXGI_FORMAT_R8G8_UINT,
627 RafxFormat::R8G8_SINT => DxgiCommon::DXGI_FORMAT_R8G8_SINT,
628 RafxFormat::R8G8B8A8_UNORM => DxgiCommon::DXGI_FORMAT_R8G8B8A8_UNORM,
644 RafxFormat::R8G8B8A8_SNORM => DxgiCommon::DXGI_FORMAT_R8G8B8A8_SNORM,
645 RafxFormat::R8G8B8A8_UINT => DxgiCommon::DXGI_FORMAT_R8G8B8A8_UINT,
648 RafxFormat::R8G8B8A8_SINT => DxgiCommon::DXGI_FORMAT_R8G8B8A8_SINT,
649 RafxFormat::R8G8B8A8_SRGB => DxgiCommon::DXGI_FORMAT_R8G8B8A8_UNORM_SRGB,
650 RafxFormat::B8G8R8A8_UNORM => DxgiCommon::DXGI_FORMAT_B8G8R8A8_UNORM,
651 RafxFormat::B8G8R8A8_SRGB => DxgiCommon::DXGI_FORMAT_B8G8R8A8_UNORM_SRGB,
657 RafxFormat::A2R10G10B10_UNORM_PACK32 => DxgiCommon::DXGI_FORMAT_R10G10B10A2_UNORM,
665 RafxFormat::A2R10G10B10_UINT_PACK32 => DxgiCommon::DXGI_FORMAT_R10G10B10A2_UINT,
669 RafxFormat::R16_UNORM => DxgiCommon::DXGI_FORMAT_R16_UNORM,
677 RafxFormat::R16_SNORM => DxgiCommon::DXGI_FORMAT_R16_SNORM,
678 RafxFormat::R16_UINT => DxgiCommon::DXGI_FORMAT_R16_UINT,
681 RafxFormat::R16_SINT => DxgiCommon::DXGI_FORMAT_R16_SINT,
682 RafxFormat::R16_SFLOAT => DxgiCommon::DXGI_FORMAT_R16_FLOAT,
683 RafxFormat::R16G16_UNORM => DxgiCommon::DXGI_FORMAT_R16G16_UNORM,
684 RafxFormat::R16G16_SNORM => DxgiCommon::DXGI_FORMAT_R16G16_SNORM,
685 RafxFormat::R16G16_UINT => DxgiCommon::DXGI_FORMAT_R16G16_UINT,
688 RafxFormat::R16G16_SINT => DxgiCommon::DXGI_FORMAT_R16G16_SINT,
689 RafxFormat::R16G16_SFLOAT => DxgiCommon::DXGI_FORMAT_R16G16_FLOAT,
690 RafxFormat::R16G16B16A16_UNORM => DxgiCommon::DXGI_FORMAT_R16G16B16A16_UNORM,
698 RafxFormat::R16G16B16A16_SNORM => DxgiCommon::DXGI_FORMAT_R16G16B16A16_SNORM,
699 RafxFormat::R16G16B16A16_UINT => DxgiCommon::DXGI_FORMAT_R16G16B16A16_UINT,
702 RafxFormat::R16G16B16A16_SINT => DxgiCommon::DXGI_FORMAT_R16G16B16A16_SINT,
703 RafxFormat::R16G16B16A16_SFLOAT => DxgiCommon::DXGI_FORMAT_R16G16B16A16_FLOAT,
704 RafxFormat::R32_UINT => DxgiCommon::DXGI_FORMAT_R32_UINT,
705 RafxFormat::R32_SINT => DxgiCommon::DXGI_FORMAT_R32_SINT,
706 RafxFormat::R32_SFLOAT => DxgiCommon::DXGI_FORMAT_R32_FLOAT,
707 RafxFormat::R32G32_UINT => DxgiCommon::DXGI_FORMAT_R32G32_UINT,
708 RafxFormat::R32G32_SINT => DxgiCommon::DXGI_FORMAT_R32G32_SINT,
709 RafxFormat::R32G32_SFLOAT => DxgiCommon::DXGI_FORMAT_R32G32_FLOAT,
710 RafxFormat::R32G32B32_UINT => DxgiCommon::DXGI_FORMAT_R32G32B32_UINT,
711 RafxFormat::R32G32B32_SINT => DxgiCommon::DXGI_FORMAT_R32G32B32_SINT,
712 RafxFormat::R32G32B32_SFLOAT => DxgiCommon::DXGI_FORMAT_R32G32B32_FLOAT,
713 RafxFormat::R32G32B32A32_UINT => DxgiCommon::DXGI_FORMAT_R32G32B32A32_UINT,
714 RafxFormat::R32G32B32A32_SINT => DxgiCommon::DXGI_FORMAT_R32G32B32A32_SINT,
715 RafxFormat::R32G32B32A32_SFLOAT => DxgiCommon::DXGI_FORMAT_R32G32B32A32_FLOAT,
716 RafxFormat::D16_UNORM => DxgiCommon::DXGI_FORMAT_D16_UNORM,
731 RafxFormat::X8_D24_UNORM_PACK32 => DxgiCommon::DXGI_FORMAT_D24_UNORM_S8_UINT,
732 RafxFormat::D32_SFLOAT => DxgiCommon::DXGI_FORMAT_D32_FLOAT,
733 RafxFormat::D24_UNORM_S8_UINT => DxgiCommon::DXGI_FORMAT_D24_UNORM_S8_UINT,
736 RafxFormat::D32_SFLOAT_S8_UINT => DxgiCommon::DXGI_FORMAT_D32_FLOAT_S8X24_UINT,
737 RafxFormat::BC1_RGB_UNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC1_UNORM,
738 RafxFormat::BC1_RGB_SRGB_BLOCK => DxgiCommon::DXGI_FORMAT_BC1_UNORM_SRGB,
739 RafxFormat::BC1_RGBA_UNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC1_UNORM,
740 RafxFormat::BC1_RGBA_SRGB_BLOCK => DxgiCommon::DXGI_FORMAT_BC1_UNORM_SRGB,
741 RafxFormat::BC2_UNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC2_UNORM,
742 RafxFormat::BC2_SRGB_BLOCK => DxgiCommon::DXGI_FORMAT_BC2_UNORM_SRGB,
743 RafxFormat::BC3_UNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC3_UNORM,
744 RafxFormat::BC3_SRGB_BLOCK => DxgiCommon::DXGI_FORMAT_BC3_UNORM_SRGB,
745 RafxFormat::BC4_UNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC4_UNORM,
746 RafxFormat::BC4_SNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC4_SNORM,
747 RafxFormat::BC5_UNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC5_UNORM,
748 RafxFormat::BC5_SNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC5_SNORM,
749 RafxFormat::BC6H_UFLOAT_BLOCK => DxgiCommon::DXGI_FORMAT_BC6H_UF16,
750 RafxFormat::BC6H_SFLOAT_BLOCK => DxgiCommon::DXGI_FORMAT_BC6H_SF16,
751 RafxFormat::BC7_UNORM_BLOCK => DxgiCommon::DXGI_FORMAT_BC7_UNORM,
752 RafxFormat::BC7_SRGB_BLOCK => DxgiCommon::DXGI_FORMAT_BC7_UNORM_SRGB,
753 _ => unimplemented!(),
792 }
793 }
794}
795
796#[cfg(feature = "rafx-dx12")]
797impl From<DxgiCommon::DXGI_FORMAT> for RafxFormat {
798 fn from(format: DxgiCommon::DXGI_FORMAT) -> RafxFormat {
799 match format {
800 DxgiCommon::DXGI_FORMAT_UNKNOWN => RafxFormat::UNDEFINED,
801 DxgiCommon::DXGI_FORMAT_B4G4R4A4_UNORM => RafxFormat::B4G4R4A4_UNORM_PACK16,
804 DxgiCommon::DXGI_FORMAT_B5G6R5_UNORM => RafxFormat::B5G6R5_UNORM_PACK16,
806 DxgiCommon::DXGI_FORMAT_B5G5R5A1_UNORM => RafxFormat::B5G5R5A1_UNORM_PACK16,
808 DxgiCommon::DXGI_FORMAT_R8_UNORM => RafxFormat::R8_UNORM,
810 DxgiCommon::DXGI_FORMAT_R8_SNORM => RafxFormat::R8_SNORM,
811 DxgiCommon::DXGI_FORMAT_R8_UINT => RafxFormat::R8_UINT,
814 DxgiCommon::DXGI_FORMAT_R8_SINT => RafxFormat::R8_SINT,
815 DxgiCommon::DXGI_FORMAT_R8G8_UNORM => RafxFormat::R8G8_UNORM,
817 DxgiCommon::DXGI_FORMAT_R8G8_SNORM => RafxFormat::R8G8_SNORM,
818 DxgiCommon::DXGI_FORMAT_R8G8_UINT => RafxFormat::R8G8_UINT,
821 DxgiCommon::DXGI_FORMAT_R8G8_SINT => RafxFormat::R8G8_SINT,
822 DxgiCommon::DXGI_FORMAT_R8G8B8A8_UNORM => RafxFormat::R8G8B8A8_UNORM,
838 DxgiCommon::DXGI_FORMAT_R8G8B8A8_SNORM => RafxFormat::R8G8B8A8_SNORM,
839 DxgiCommon::DXGI_FORMAT_R8G8B8A8_UINT => RafxFormat::R8G8B8A8_UINT,
842 DxgiCommon::DXGI_FORMAT_R8G8B8A8_SINT => RafxFormat::R8G8B8A8_SINT,
843 DxgiCommon::DXGI_FORMAT_R8G8B8A8_UNORM_SRGB => RafxFormat::R8G8B8A8_SRGB,
844 DxgiCommon::DXGI_FORMAT_B8G8R8A8_UNORM => RafxFormat::B8G8R8A8_UNORM,
845 DxgiCommon::DXGI_FORMAT_B8G8R8A8_UNORM_SRGB => RafxFormat::B8G8R8A8_SRGB,
851 DxgiCommon::DXGI_FORMAT_R10G10B10A2_UNORM => RafxFormat::A2R10G10B10_UNORM_PACK32,
859 DxgiCommon::DXGI_FORMAT_R10G10B10A2_UINT => RafxFormat::A2R10G10B10_UINT_PACK32,
863 DxgiCommon::DXGI_FORMAT_R16_UNORM => RafxFormat::R16_UNORM,
871 DxgiCommon::DXGI_FORMAT_R16_SNORM => RafxFormat::R16_SNORM,
872 DxgiCommon::DXGI_FORMAT_R16_UINT => RafxFormat::R16_UINT,
875 DxgiCommon::DXGI_FORMAT_R16_SINT => RafxFormat::R16_SINT,
876 DxgiCommon::DXGI_FORMAT_R16_FLOAT => RafxFormat::R16_SFLOAT,
877 DxgiCommon::DXGI_FORMAT_R16G16_UNORM => RafxFormat::R16G16_UNORM,
878 DxgiCommon::DXGI_FORMAT_R16G16_SNORM => RafxFormat::R16G16_SNORM,
879 DxgiCommon::DXGI_FORMAT_R16G16_UINT => RafxFormat::R16G16_UINT,
882 DxgiCommon::DXGI_FORMAT_R16G16_SINT => RafxFormat::R16G16_SINT,
883 DxgiCommon::DXGI_FORMAT_R16G16_FLOAT => RafxFormat::R16G16_SFLOAT,
884 DxgiCommon::DXGI_FORMAT_R16G16B16A16_UNORM => RafxFormat::R16G16B16A16_UNORM,
892 DxgiCommon::DXGI_FORMAT_R16G16B16A16_SNORM => RafxFormat::R16G16B16A16_SNORM,
893 DxgiCommon::DXGI_FORMAT_R16G16B16A16_UINT => RafxFormat::R16G16B16A16_UINT,
896 DxgiCommon::DXGI_FORMAT_R16G16B16A16_SINT => RafxFormat::R16G16B16A16_SINT,
897 DxgiCommon::DXGI_FORMAT_R16G16B16A16_FLOAT => RafxFormat::R16G16B16A16_SFLOAT,
898 DxgiCommon::DXGI_FORMAT_R32_UINT => RafxFormat::R32_UINT,
899 DxgiCommon::DXGI_FORMAT_R32_SINT => RafxFormat::R32_SINT,
900 DxgiCommon::DXGI_FORMAT_R32_FLOAT => RafxFormat::R32_SFLOAT,
901 DxgiCommon::DXGI_FORMAT_R32G32_UINT => RafxFormat::R32G32_UINT,
902 DxgiCommon::DXGI_FORMAT_R32G32_SINT => RafxFormat::R32G32_SINT,
903 DxgiCommon::DXGI_FORMAT_R32G32_FLOAT => RafxFormat::R32G32_SFLOAT,
904 DxgiCommon::DXGI_FORMAT_R32G32B32_UINT => RafxFormat::R32G32B32_UINT,
905 DxgiCommon::DXGI_FORMAT_R32G32B32_SINT => RafxFormat::R32G32B32_SINT,
906 DxgiCommon::DXGI_FORMAT_R32G32B32_FLOAT => RafxFormat::R32G32B32_SFLOAT,
907 DxgiCommon::DXGI_FORMAT_R32G32B32A32_UINT => RafxFormat::R32G32B32A32_UINT,
908 DxgiCommon::DXGI_FORMAT_R32G32B32A32_SINT => RafxFormat::R32G32B32A32_SINT,
909 DxgiCommon::DXGI_FORMAT_R32G32B32A32_FLOAT => RafxFormat::R32G32B32A32_SFLOAT,
910 DxgiCommon::DXGI_FORMAT_D16_UNORM => RafxFormat::D16_UNORM,
925 DxgiCommon::DXGI_FORMAT_D24_UNORM_S8_UINT => RafxFormat::X8_D24_UNORM_PACK32,
926 DxgiCommon::DXGI_FORMAT_D32_FLOAT => RafxFormat::D32_SFLOAT,
927 DxgiCommon::DXGI_FORMAT_D24_UNORM_S8_UINT => RafxFormat::D24_UNORM_S8_UINT,
930 DxgiCommon::DXGI_FORMAT_D32_FLOAT_S8X24_UINT => RafxFormat::D32_SFLOAT_S8_UINT,
931 DxgiCommon::DXGI_FORMAT_BC1_UNORM => RafxFormat::BC1_RGB_UNORM_BLOCK,
932 DxgiCommon::DXGI_FORMAT_BC1_UNORM_SRGB => RafxFormat::BC1_RGB_SRGB_BLOCK,
933 DxgiCommon::DXGI_FORMAT_BC1_UNORM => RafxFormat::BC1_RGBA_UNORM_BLOCK,
934 DxgiCommon::DXGI_FORMAT_BC1_UNORM_SRGB => RafxFormat::BC1_RGBA_SRGB_BLOCK,
935 DxgiCommon::DXGI_FORMAT_BC2_UNORM => RafxFormat::BC2_UNORM_BLOCK,
936 DxgiCommon::DXGI_FORMAT_BC2_UNORM_SRGB => RafxFormat::BC2_SRGB_BLOCK,
937 DxgiCommon::DXGI_FORMAT_BC3_UNORM => RafxFormat::BC3_UNORM_BLOCK,
938 DxgiCommon::DXGI_FORMAT_BC3_UNORM_SRGB => RafxFormat::BC3_SRGB_BLOCK,
939 DxgiCommon::DXGI_FORMAT_BC4_UNORM => RafxFormat::BC4_UNORM_BLOCK,
940 DxgiCommon::DXGI_FORMAT_BC4_SNORM => RafxFormat::BC4_SNORM_BLOCK,
941 DxgiCommon::DXGI_FORMAT_BC5_UNORM => RafxFormat::BC5_UNORM_BLOCK,
942 DxgiCommon::DXGI_FORMAT_BC5_SNORM => RafxFormat::BC5_SNORM_BLOCK,
943 DxgiCommon::DXGI_FORMAT_BC6H_UF16 => RafxFormat::BC6H_UFLOAT_BLOCK,
944 DxgiCommon::DXGI_FORMAT_BC6H_SF16 => RafxFormat::BC6H_SFLOAT_BLOCK,
945 DxgiCommon::DXGI_FORMAT_BC7_UNORM => RafxFormat::BC7_UNORM_BLOCK,
946 DxgiCommon::DXGI_FORMAT_BC7_UNORM_SRGB => RafxFormat::BC7_SRGB_BLOCK,
947 _ => unimplemented!(),
986 }
987 }
988}
989
990#[cfg(feature = "rafx-metal")]
991impl Into<MTLPixelFormat> for RafxFormat {
992 fn into(self) -> MTLPixelFormat {
993 match self {
994 RafxFormat::UNDEFINED => MTLPixelFormat::Invalid,
995 RafxFormat::B5G6R5_UNORM_PACK16 => MTLPixelFormat::B5G6R5Unorm,
1000 RafxFormat::B5G5R5A1_UNORM_PACK16 => MTLPixelFormat::BGR5A1Unorm,
1002 RafxFormat::R8_UNORM => MTLPixelFormat::R8Unorm,
1004 RafxFormat::R8_SNORM => MTLPixelFormat::R8Snorm,
1005 RafxFormat::R8_UINT => MTLPixelFormat::R8Uint,
1008 RafxFormat::R8_SINT => MTLPixelFormat::R8Sint,
1009 RafxFormat::R8_SRGB => MTLPixelFormat::R8Unorm_sRGB,
1010 RafxFormat::R8G8_UNORM => MTLPixelFormat::RG8Unorm,
1011 RafxFormat::R8G8_SNORM => MTLPixelFormat::RG8Snorm,
1012 RafxFormat::R8G8_UINT => MTLPixelFormat::RG8Uint,
1015 RafxFormat::R8G8_SINT => MTLPixelFormat::RG8Sint,
1016 RafxFormat::R8G8_SRGB => MTLPixelFormat::RG8Unorm_sRGB,
1017 RafxFormat::R8G8B8A8_UNORM => MTLPixelFormat::RGBA8Unorm,
1032 RafxFormat::R8G8B8A8_SNORM => MTLPixelFormat::RGBA8Snorm,
1033 RafxFormat::R8G8B8A8_UINT => MTLPixelFormat::RGBA8Uint,
1036 RafxFormat::R8G8B8A8_SINT => MTLPixelFormat::RGBA8Sint,
1037 RafxFormat::R8G8B8A8_SRGB => MTLPixelFormat::RGBA8Unorm_sRGB,
1038 RafxFormat::B8G8R8A8_UNORM => MTLPixelFormat::BGRA8Unorm,
1039 RafxFormat::B8G8R8A8_SRGB => MTLPixelFormat::BGRA8Unorm_sRGB,
1045 RafxFormat::R16_UNORM => MTLPixelFormat::R16Unorm,
1065 RafxFormat::R16_SNORM => MTLPixelFormat::R16Snorm,
1066 RafxFormat::R16_UINT => MTLPixelFormat::R16Uint,
1069 RafxFormat::R16_SINT => MTLPixelFormat::R16Sint,
1070 RafxFormat::R16_SFLOAT => MTLPixelFormat::R16Float,
1071 RafxFormat::R16G16_UNORM => MTLPixelFormat::RG16Float,
1072 RafxFormat::R16G16_SNORM => MTLPixelFormat::RG16Snorm,
1073 RafxFormat::R16G16_UINT => MTLPixelFormat::RG16Uint,
1076 RafxFormat::R16G16_SINT => MTLPixelFormat::RG16Sint,
1077 RafxFormat::R16G16_SFLOAT => MTLPixelFormat::RG16Float,
1078 RafxFormat::R16G16B16A16_UNORM => MTLPixelFormat::RGBA16Unorm,
1086 RafxFormat::R16G16B16A16_SNORM => MTLPixelFormat::RGBA16Snorm,
1087 RafxFormat::R16G16B16A16_UINT => MTLPixelFormat::RGBA16Uint,
1090 RafxFormat::R16G16B16A16_SINT => MTLPixelFormat::RGBA16Sint,
1091 RafxFormat::R16G16B16A16_SFLOAT => MTLPixelFormat::RGBA16Float,
1092 RafxFormat::R32_UINT => MTLPixelFormat::R32Uint,
1093 RafxFormat::R32_SINT => MTLPixelFormat::R32Sint,
1094 RafxFormat::R32_SFLOAT => MTLPixelFormat::R32Float,
1095 RafxFormat::R32G32_UINT => MTLPixelFormat::RG32Uint,
1096 RafxFormat::R32G32_SINT => MTLPixelFormat::RG32Sint,
1097 RafxFormat::R32G32_SFLOAT => MTLPixelFormat::RG32Float,
1098 RafxFormat::R32G32B32A32_UINT => MTLPixelFormat::RGBA32Uint,
1102 RafxFormat::R32G32B32A32_SINT => MTLPixelFormat::RGBA32Sint,
1103 RafxFormat::R32G32B32A32_SFLOAT => MTLPixelFormat::RGBA32Float,
1104 RafxFormat::D16_UNORM => MTLPixelFormat::Depth16Unorm,
1119 RafxFormat::D32_SFLOAT => MTLPixelFormat::Depth32Float,
1121 RafxFormat::S8_UINT => MTLPixelFormat::Stencil8,
1122 RafxFormat::D24_UNORM_S8_UINT => MTLPixelFormat::Depth24Unorm_Stencil8,
1124 RafxFormat::D32_SFLOAT_S8_UINT => MTLPixelFormat::Depth32Float_Stencil8,
1125 RafxFormat::BC1_RGBA_UNORM_BLOCK => MTLPixelFormat::BC1_RGBA,
1128 RafxFormat::BC1_RGBA_SRGB_BLOCK => MTLPixelFormat::BC1_RGBA_sRGB,
1129 RafxFormat::BC2_UNORM_BLOCK => MTLPixelFormat::BC2_RGBA,
1130 RafxFormat::BC2_SRGB_BLOCK => MTLPixelFormat::BC2_RGBA_sRGB,
1131 RafxFormat::BC3_UNORM_BLOCK => MTLPixelFormat::BC3_RGBA,
1132 RafxFormat::BC3_SRGB_BLOCK => MTLPixelFormat::BC3_RGBA_sRGB,
1133 RafxFormat::BC4_UNORM_BLOCK => MTLPixelFormat::BC4_RUnorm,
1134 RafxFormat::BC4_SNORM_BLOCK => MTLPixelFormat::BC4_RSnorm,
1135 RafxFormat::BC5_UNORM_BLOCK => MTLPixelFormat::BC5_RGUnorm,
1136 RafxFormat::BC5_SNORM_BLOCK => MTLPixelFormat::BC5_RGSnorm,
1137 RafxFormat::BC6H_UFLOAT_BLOCK => MTLPixelFormat::BC6H_RGBUfloat,
1138 RafxFormat::BC6H_SFLOAT_BLOCK => MTLPixelFormat::BC6H_RGBFloat,
1139 RafxFormat::BC7_UNORM_BLOCK => MTLPixelFormat::BC7_RGBAUnorm,
1140 RafxFormat::BC7_SRGB_BLOCK => MTLPixelFormat::BC7_RGBAUnorm_sRGB,
1141 RafxFormat::ETC2_R8G8B8_UNORM_BLOCK => MTLPixelFormat::ETC2_RGB8,
1142 RafxFormat::ETC2_R8G8B8_SRGB_BLOCK => MTLPixelFormat::ETC2_RGB8_sRGB,
1143 RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK => MTLPixelFormat::ETC2_RGB8A1,
1144 RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK => MTLPixelFormat::ETC2_RGB8A1_sRGB,
1145 RafxFormat::EAC_R11_UNORM_BLOCK => MTLPixelFormat::EAC_R11Unorm,
1148 RafxFormat::EAC_R11_SNORM_BLOCK => MTLPixelFormat::EAC_R11Snorm,
1149 RafxFormat::EAC_R11G11_UNORM_BLOCK => MTLPixelFormat::EAC_RG11Unorm,
1150 RafxFormat::EAC_R11G11_SNORM_BLOCK => MTLPixelFormat::EAC_RG11Snorm,
1151 RafxFormat::ASTC_4X4_UNORM_BLOCK => MTLPixelFormat::ASTC_4x4_LDR,
1152 RafxFormat::ASTC_4X4_SRGB_BLOCK => MTLPixelFormat::ASTC_4x4_sRGB,
1153 RafxFormat::ASTC_5X4_UNORM_BLOCK => MTLPixelFormat::ASTC_5x4_LDR,
1154 RafxFormat::ASTC_5X4_SRGB_BLOCK => MTLPixelFormat::ASTC_5x4_sRGB,
1155 RafxFormat::ASTC_5X5_UNORM_BLOCK => MTLPixelFormat::ASTC_5x5_LDR,
1156 RafxFormat::ASTC_5X5_SRGB_BLOCK => MTLPixelFormat::ASTC_5x5_sRGB,
1157 RafxFormat::ASTC_6X5_UNORM_BLOCK => MTLPixelFormat::ASTC_6x5_LDR,
1158 RafxFormat::ASTC_6X5_SRGB_BLOCK => MTLPixelFormat::ASTC_6x5_sRGB,
1159 RafxFormat::ASTC_6X6_UNORM_BLOCK => MTLPixelFormat::ASTC_6x6_LDR,
1160 RafxFormat::ASTC_6X6_SRGB_BLOCK => MTLPixelFormat::ASTC_6x6_sRGB,
1161 RafxFormat::ASTC_8X5_UNORM_BLOCK => MTLPixelFormat::ASTC_8x5_LDR,
1162 RafxFormat::ASTC_8X5_SRGB_BLOCK => MTLPixelFormat::ASTC_8x5_sRGB,
1163 RafxFormat::ASTC_8X6_UNORM_BLOCK => MTLPixelFormat::ASTC_8x6_LDR,
1164 RafxFormat::ASTC_8X6_SRGB_BLOCK => MTLPixelFormat::ASTC_8x6_sRGB,
1165 RafxFormat::ASTC_8X8_UNORM_BLOCK => MTLPixelFormat::ASTC_8x8_LDR,
1166 RafxFormat::ASTC_8X8_SRGB_BLOCK => MTLPixelFormat::ASTC_8x8_sRGB,
1167 RafxFormat::ASTC_10X5_UNORM_BLOCK => MTLPixelFormat::ASTC_10x5_LDR,
1168 RafxFormat::ASTC_10X5_SRGB_BLOCK => MTLPixelFormat::ASTC_10x5_sRGB,
1169 RafxFormat::ASTC_10X6_UNORM_BLOCK => MTLPixelFormat::ASTC_10x6_LDR,
1170 RafxFormat::ASTC_10X6_SRGB_BLOCK => MTLPixelFormat::ASTC_10x6_sRGB,
1171 RafxFormat::ASTC_10X8_UNORM_BLOCK => MTLPixelFormat::ASTC_10x8_LDR,
1172 RafxFormat::ASTC_10X8_SRGB_BLOCK => MTLPixelFormat::ASTC_10x8_sRGB,
1173 RafxFormat::ASTC_10X10_UNORM_BLOCK => MTLPixelFormat::ASTC_10x10_LDR,
1174 RafxFormat::ASTC_10X10_SRGB_BLOCK => MTLPixelFormat::ASTC_10x10_sRGB,
1175 RafxFormat::ASTC_12X10_UNORM_BLOCK => MTLPixelFormat::ASTC_12x10_LDR,
1176 RafxFormat::ASTC_12X10_SRGB_BLOCK => MTLPixelFormat::ASTC_12x10_sRGB,
1177 RafxFormat::ASTC_12X12_UNORM_BLOCK => MTLPixelFormat::ASTC_12x12_LDR,
1178 RafxFormat::ASTC_12X12_SRGB_BLOCK => MTLPixelFormat::ASTC_12x12_sRGB,
1179 _ => unimplemented!(),
1180 }
1181 }
1182}
1183
1184#[cfg(feature = "rafx-metal")]
1185impl Into<MTLVertexFormat> for RafxFormat {
1186 fn into(self) -> MTLVertexFormat {
1187 match self {
1188 RafxFormat::R8_UNORM => MTLVertexFormat::UCharNormalized,
1189 RafxFormat::R8_SNORM => MTLVertexFormat::CharNormalized,
1190 RafxFormat::R8_UINT => MTLVertexFormat::UChar,
1191 RafxFormat::R8_SINT => MTLVertexFormat::Char,
1192 RafxFormat::R8G8_UNORM => MTLVertexFormat::UChar2Normalized,
1193 RafxFormat::R8G8_SNORM => MTLVertexFormat::Char2Normalized,
1194 RafxFormat::R8G8_UINT => MTLVertexFormat::UChar2,
1195 RafxFormat::R8G8_SINT => MTLVertexFormat::Char2,
1196 RafxFormat::R8G8B8_UNORM => MTLVertexFormat::UChar3Normalized,
1197 RafxFormat::R8G8B8_SNORM => MTLVertexFormat::Char3Normalized,
1198 RafxFormat::R8G8B8_UINT => MTLVertexFormat::UChar3,
1199 RafxFormat::R8G8B8_SINT => MTLVertexFormat::Char3,
1200 RafxFormat::R8G8B8A8_UNORM => MTLVertexFormat::UChar4Normalized,
1201 RafxFormat::R8G8B8A8_SNORM => MTLVertexFormat::Char4Normalized,
1202 RafxFormat::R8G8B8A8_UINT => MTLVertexFormat::UChar4,
1203 RafxFormat::R8G8B8A8_SINT => MTLVertexFormat::Char4,
1204 RafxFormat::B8G8R8A8_UNORM => MTLVertexFormat::UChar4Normalized_BGRA,
1205 RafxFormat::R16_UNORM => MTLVertexFormat::UShortNormalized,
1206 RafxFormat::R16_SNORM => MTLVertexFormat::ShortNormalized,
1207 RafxFormat::R16_UINT => MTLVertexFormat::UShort,
1208 RafxFormat::R16_SINT => MTLVertexFormat::Short,
1209 RafxFormat::R16_SFLOAT => MTLVertexFormat::Half,
1210 RafxFormat::R16G16_UNORM => MTLVertexFormat::UShort2Normalized,
1211 RafxFormat::R16G16_SNORM => MTLVertexFormat::Short2Normalized,
1212 RafxFormat::R16G16_UINT => MTLVertexFormat::UShort2,
1213 RafxFormat::R16G16_SINT => MTLVertexFormat::Short2,
1214 RafxFormat::R16G16_SFLOAT => MTLVertexFormat::Half2,
1215 RafxFormat::R16G16B16_UNORM => MTLVertexFormat::UShort3Normalized,
1216 RafxFormat::R16G16B16_SNORM => MTLVertexFormat::Short3Normalized,
1217 RafxFormat::R16G16B16_UINT => MTLVertexFormat::UShort3,
1218 RafxFormat::R16G16B16_SINT => MTLVertexFormat::Short3,
1219 RafxFormat::R16G16B16_SFLOAT => MTLVertexFormat::Half3,
1220 RafxFormat::R16G16B16A16_UNORM => MTLVertexFormat::UShort4Normalized,
1221 RafxFormat::R16G16B16A16_SNORM => MTLVertexFormat::Short4Normalized,
1222 RafxFormat::R16G16B16A16_UINT => MTLVertexFormat::UShort4,
1223 RafxFormat::R16G16B16A16_SINT => MTLVertexFormat::Short4,
1224 RafxFormat::R16G16B16A16_SFLOAT => MTLVertexFormat::Half4,
1225 RafxFormat::R32_UINT => MTLVertexFormat::UInt,
1226 RafxFormat::R32_SINT => MTLVertexFormat::Int,
1227 RafxFormat::R32_SFLOAT => MTLVertexFormat::Float,
1228 RafxFormat::R32G32_UINT => MTLVertexFormat::UInt2,
1229 RafxFormat::R32G32_SINT => MTLVertexFormat::Int2,
1230 RafxFormat::R32G32_SFLOAT => MTLVertexFormat::Float2,
1231 RafxFormat::R32G32B32_UINT => MTLVertexFormat::UInt3,
1232 RafxFormat::R32G32B32_SINT => MTLVertexFormat::Int3,
1233 RafxFormat::R32G32B32_SFLOAT => MTLVertexFormat::Float3,
1234 RafxFormat::R32G32B32A32_UINT => MTLVertexFormat::UInt4,
1235 RafxFormat::R32G32B32A32_SINT => MTLVertexFormat::Int4,
1236 RafxFormat::R32G32B32A32_SFLOAT => MTLVertexFormat::Float4,
1237 _ => unimplemented!("into MTLVertexFormat unimplemented for {:?}", self),
1238 }
1239 }
1240}
1241
1242#[cfg(any(feature = "rafx-gles2", feature = "rafx-gles3"))]
1243#[derive(Debug)]
1244pub struct GlTextureFormatInfo {
1245 pub gl_format: GLenum,
1246 pub gl_type: GLenum,
1247 pub gl_internal_format: i32,
1248}
1249
1250#[rustfmt::skip]
1256#[cfg(feature = "rafx-gles2")]
1257impl RafxFormat {
1258 pub fn gles2_type(self) -> Option<GLenum> {
1259 use crate::gles2::gles2_bindings as gl;
1260 match self {
1261 RafxFormat::R4G4_UNORM_PACK8 => Some(gl::UNSIGNED_SHORT_4_4_4_4),
1262 RafxFormat::R4G4B4A4_UNORM_PACK16 => Some(gl::UNSIGNED_SHORT_4_4_4_4),
1263 RafxFormat::R5G6B5_UNORM_PACK16 => Some(gl::UNSIGNED_SHORT_5_6_5),
1265 RafxFormat::R5G5B5A1_UNORM_PACK16 => Some(gl::UNSIGNED_SHORT_5_5_5_1),
1267 RafxFormat::R8_UNORM => Some(gl::UNSIGNED_BYTE),
1270 RafxFormat::R8_SNORM => Some(gl::BYTE),
1271 RafxFormat::R8_UINT => Some(gl::UNSIGNED_BYTE),
1274 RafxFormat::R8_SINT => Some(gl::BYTE),
1275 RafxFormat::R8_SRGB => Some(gl::UNSIGNED_BYTE),
1276 RafxFormat::R8G8_UNORM => Some(gl::UNSIGNED_BYTE),
1277 RafxFormat::R8G8_SNORM => Some(gl::BYTE),
1278 RafxFormat::R8G8_UINT => Some(gl::UNSIGNED_BYTE),
1281 RafxFormat::R8G8_SINT => Some(gl::BYTE),
1282 RafxFormat::R8G8_SRGB => Some(gl::UNSIGNED_BYTE),
1283 RafxFormat::R8G8B8_UNORM => Some(gl::UNSIGNED_BYTE),
1284 RafxFormat::R8G8B8_SNORM => Some(gl::BYTE),
1285 RafxFormat::R8G8B8_UINT => Some(gl::UNSIGNED_BYTE),
1288 RafxFormat::R8G8B8_SINT => Some(gl::BYTE),
1289 RafxFormat::R8G8B8_SRGB => Some(gl::UNSIGNED_BYTE),
1290 RafxFormat::B8G8R8_UNORM => Some(gl::UNSIGNED_BYTE),
1291 RafxFormat::B8G8R8_SNORM => Some(gl::BYTE),
1292 RafxFormat::B8G8R8_UINT => Some(gl::UNSIGNED_BYTE),
1295 RafxFormat::B8G8R8_SINT => Some(gl::BYTE),
1296 RafxFormat::B8G8R8_SRGB => Some(gl::UNSIGNED_BYTE),
1297 RafxFormat::R8G8B8A8_UNORM => Some(gl::UNSIGNED_BYTE),
1298 RafxFormat::R8G8B8A8_SNORM => Some(gl::BYTE),
1299 RafxFormat::R8G8B8A8_UINT => Some(gl::UNSIGNED_BYTE),
1302 RafxFormat::R8G8B8A8_SINT => Some(gl::BYTE),
1303 RafxFormat::R8G8B8A8_SRGB => Some(gl::UNSIGNED_BYTE),
1304 RafxFormat::B8G8R8A8_UNORM => Some(gl::UNSIGNED_BYTE),
1305 RafxFormat::B8G8R8A8_SNORM => Some(gl::BYTE),
1306 RafxFormat::B8G8R8A8_UINT => Some(gl::UNSIGNED_BYTE),
1309 RafxFormat::B8G8R8A8_SINT => Some(gl::BYTE),
1310 RafxFormat::B8G8R8A8_SRGB => Some(gl::UNSIGNED_BYTE),
1311 RafxFormat::R16_UNORM => Some(gl::UNSIGNED_SHORT),
1331 RafxFormat::R16_SNORM => Some(gl::SHORT),
1332 RafxFormat::R16_UINT => Some(gl::UNSIGNED_SHORT),
1335 RafxFormat::R16_SINT => Some(gl::SHORT),
1336 RafxFormat::R16G16_UNORM => Some(gl::UNSIGNED_SHORT),
1338 RafxFormat::R16G16_SNORM => Some(gl::SHORT),
1339 RafxFormat::R16G16_UINT => Some(gl::UNSIGNED_SHORT),
1342 RafxFormat::R16G16_SINT => Some(gl::SHORT),
1343 RafxFormat::R16G16B16_UNORM => Some(gl::UNSIGNED_SHORT),
1345 RafxFormat::R16G16B16_SNORM => Some(gl::SHORT),
1346 RafxFormat::R16G16B16_UINT => Some(gl::UNSIGNED_SHORT),
1349 RafxFormat::R16G16B16_SINT => Some(gl::SHORT),
1350 RafxFormat::R16G16B16A16_UNORM => Some(gl::UNSIGNED_SHORT),
1352 RafxFormat::R16G16B16A16_SNORM => Some(gl::SHORT),
1353 RafxFormat::R16G16B16A16_UINT => Some(gl::UNSIGNED_SHORT),
1356 RafxFormat::R16G16B16A16_SINT => Some(gl::SHORT),
1357 RafxFormat::R32_UINT => Some(gl::UNSIGNED_INT),
1359 RafxFormat::R32_SINT => Some(gl::INT),
1360 RafxFormat::R32_SFLOAT => Some(gl::FLOAT),
1361 RafxFormat::R32G32_UINT => Some(gl::UNSIGNED_INT),
1362 RafxFormat::R32G32_SINT => Some(gl::INT),
1363 RafxFormat::R32G32_SFLOAT => Some(gl::FLOAT),
1364 RafxFormat::R32G32B32_UINT => Some(gl::UNSIGNED_INT),
1365 RafxFormat::R32G32B32_SINT => Some(gl::INT),
1366 RafxFormat::R32G32B32_SFLOAT => Some(gl::FLOAT),
1367 RafxFormat::R32G32B32A32_UINT => Some(gl::UNSIGNED_INT),
1368 RafxFormat::R32G32B32A32_SINT => Some(gl::INT),
1369 RafxFormat::R32G32B32A32_SFLOAT => Some(gl::FLOAT),
1370 RafxFormat::D16_UNORM => Some(gl::UNSIGNED_SHORT),
1385 RafxFormat::D32_SFLOAT => Some(gl::FLOAT),
1387 RafxFormat::S8_UINT => Some(gl::UNSIGNED_BYTE),
1388 _ => None,
1446 }
1447 }
1448
1449 pub fn gles2_texture_format_info(self) -> Option<GlTextureFormatInfo> {
1450 use crate::gles2::gles2_bindings as gl;
1451 #[rustfmt::skip]
1452 let formats = match self {
1453 RafxFormat::R4G4B4A4_UNORM_PACK16 => Some((gl::RGBA, gl::RGBA)),
1456 RafxFormat::R5G6B5_UNORM_PACK16 => Some((gl::RGB, gl::RGB)),
1458 RafxFormat::R5G5B5A1_UNORM_PACK16 => Some((gl::RGBA, gl::RGBA)),
1460 RafxFormat::R8_UNORM => Some((gl::LUMINANCE, gl::LUMINANCE)),
1463 RafxFormat::R8G8B8_UNORM => Some((gl::RGB, gl::RGB)),
1477 RafxFormat::R8G8B8A8_UNORM => Some((gl::RGBA, gl::RGBA)),
1491 _ => None,
1639 };
1640
1641 let gl_type = self.gles2_type()?;
1642 formats.map(|(gl_format, gl_internal_format)| GlTextureFormatInfo {
1643 gl_format,
1644 gl_type,
1645 gl_internal_format: gl_internal_format as i32
1646 })
1647 }
1648}
1649
1650#[rustfmt::skip]
1651#[cfg(feature = "rafx-gles3")]
1652impl RafxFormat {
1653 pub fn gles3_type(self) -> Option<GLenum> {
1654 use crate::gles3::gles3_bindings as gl;
1655 match self {
1656 RafxFormat::R4G4_UNORM_PACK8 => Some(gl::UNSIGNED_SHORT_4_4_4_4),
1657 RafxFormat::R4G4B4A4_UNORM_PACK16 => Some(gl::UNSIGNED_SHORT_4_4_4_4),
1658 RafxFormat::R5G6B5_UNORM_PACK16 => Some(gl::UNSIGNED_SHORT_5_6_5),
1660 RafxFormat::R5G5B5A1_UNORM_PACK16 => Some(gl::UNSIGNED_SHORT_5_5_5_1),
1662 RafxFormat::R8_UNORM => Some(gl::UNSIGNED_BYTE),
1665 RafxFormat::R8_SNORM => Some(gl::BYTE),
1666 RafxFormat::R8_UINT => Some(gl::UNSIGNED_BYTE),
1669 RafxFormat::R8_SINT => Some(gl::BYTE),
1670 RafxFormat::R8_SRGB => Some(gl::UNSIGNED_BYTE),
1671 RafxFormat::R8G8_UNORM => Some(gl::UNSIGNED_BYTE),
1672 RafxFormat::R8G8_SNORM => Some(gl::BYTE),
1673 RafxFormat::R8G8_UINT => Some(gl::UNSIGNED_BYTE),
1676 RafxFormat::R8G8_SINT => Some(gl::BYTE),
1677 RafxFormat::R8G8_SRGB => Some(gl::UNSIGNED_BYTE),
1678 RafxFormat::R8G8B8_UNORM => Some(gl::UNSIGNED_BYTE),
1679 RafxFormat::R8G8B8_SNORM => Some(gl::BYTE),
1680 RafxFormat::R8G8B8_UINT => Some(gl::UNSIGNED_BYTE),
1683 RafxFormat::R8G8B8_SINT => Some(gl::BYTE),
1684 RafxFormat::R8G8B8_SRGB => Some(gl::UNSIGNED_BYTE),
1685 RafxFormat::B8G8R8_UNORM => Some(gl::UNSIGNED_BYTE),
1686 RafxFormat::B8G8R8_SNORM => Some(gl::BYTE),
1687 RafxFormat::B8G8R8_UINT => Some(gl::UNSIGNED_BYTE),
1690 RafxFormat::B8G8R8_SINT => Some(gl::BYTE),
1691 RafxFormat::B8G8R8_SRGB => Some(gl::UNSIGNED_BYTE),
1692 RafxFormat::R8G8B8A8_UNORM => Some(gl::UNSIGNED_BYTE),
1693 RafxFormat::R8G8B8A8_SNORM => Some(gl::BYTE),
1694 RafxFormat::R8G8B8A8_UINT => Some(gl::UNSIGNED_BYTE),
1697 RafxFormat::R8G8B8A8_SINT => Some(gl::BYTE),
1698 RafxFormat::R8G8B8A8_SRGB => Some(gl::UNSIGNED_BYTE),
1699 RafxFormat::B8G8R8A8_UNORM => Some(gl::UNSIGNED_BYTE),
1700 RafxFormat::B8G8R8A8_SNORM => Some(gl::BYTE),
1701 RafxFormat::B8G8R8A8_UINT => Some(gl::UNSIGNED_BYTE),
1704 RafxFormat::B8G8R8A8_SINT => Some(gl::BYTE),
1705 RafxFormat::B8G8R8A8_SRGB => Some(gl::UNSIGNED_BYTE),
1706 RafxFormat::R16_UNORM => Some(gl::UNSIGNED_SHORT),
1726 RafxFormat::R16_SNORM => Some(gl::SHORT),
1727 RafxFormat::R16_UINT => Some(gl::UNSIGNED_SHORT),
1730 RafxFormat::R16_SINT => Some(gl::SHORT),
1731 RafxFormat::R16G16_UNORM => Some(gl::UNSIGNED_SHORT),
1733 RafxFormat::R16G16_SNORM => Some(gl::SHORT),
1734 RafxFormat::R16G16_UINT => Some(gl::UNSIGNED_SHORT),
1737 RafxFormat::R16G16_SINT => Some(gl::SHORT),
1738 RafxFormat::R16G16B16_UNORM => Some(gl::UNSIGNED_SHORT),
1740 RafxFormat::R16G16B16_SNORM => Some(gl::SHORT),
1741 RafxFormat::R16G16B16_UINT => Some(gl::UNSIGNED_SHORT),
1744 RafxFormat::R16G16B16_SINT => Some(gl::SHORT),
1745 RafxFormat::R16G16B16A16_UNORM => Some(gl::UNSIGNED_SHORT),
1747 RafxFormat::R16G16B16A16_SNORM => Some(gl::SHORT),
1748 RafxFormat::R16G16B16A16_UINT => Some(gl::UNSIGNED_SHORT),
1751 RafxFormat::R16G16B16A16_SINT => Some(gl::SHORT),
1752 RafxFormat::R32_UINT => Some(gl::UNSIGNED_INT),
1754 RafxFormat::R32_SINT => Some(gl::INT),
1755 RafxFormat::R32_SFLOAT => Some(gl::FLOAT),
1756 RafxFormat::R32G32_UINT => Some(gl::UNSIGNED_INT),
1757 RafxFormat::R32G32_SINT => Some(gl::INT),
1758 RafxFormat::R32G32_SFLOAT => Some(gl::FLOAT),
1759 RafxFormat::R32G32B32_UINT => Some(gl::UNSIGNED_INT),
1760 RafxFormat::R32G32B32_SINT => Some(gl::INT),
1761 RafxFormat::R32G32B32_SFLOAT => Some(gl::FLOAT),
1762 RafxFormat::R32G32B32A32_UINT => Some(gl::UNSIGNED_INT),
1763 RafxFormat::R32G32B32A32_SINT => Some(gl::INT),
1764 RafxFormat::R32G32B32A32_SFLOAT => Some(gl::FLOAT),
1765 RafxFormat::D16_UNORM => Some(gl::UNSIGNED_SHORT),
1780 RafxFormat::D32_SFLOAT => Some(gl::FLOAT),
1782 RafxFormat::S8_UINT => Some(gl::UNSIGNED_BYTE),
1783 RafxFormat::D16_UNORM_S8_UINT => Some(gl::UNSIGNED_INT_24_8),
1784 RafxFormat::D24_UNORM_S8_UINT => Some(gl::FLOAT_32_UNSIGNED_INT_24_8_REV),
1785 _ => None,
1841 }
1842 }
1843
1844 pub fn gles3_texture_format_info(self) -> Option<GlTextureFormatInfo> {
1845 use crate::gles3::gles3_bindings as gl;
1846 #[rustfmt::skip]
1847 let formats = match self {
1848 RafxFormat::R4G4B4A4_UNORM_PACK16 => Some((gl::RGBA, gl::RGBA)),
1851 RafxFormat::R5G6B5_UNORM_PACK16 => Some((gl::RGB, gl::RGB)),
1853 RafxFormat::R5G5B5A1_UNORM_PACK16 => Some((gl::RGBA, gl::RGBA)),
1855 RafxFormat::R8_UNORM => Some((gl::RED, gl::R8)),
1858 RafxFormat::R8G8B8_UNORM => Some((gl::RGB, gl::RGB)),
1872 RafxFormat::R8G8B8_SRGB => Some((gl::RGB, gl::SRGB8)),
1878 RafxFormat::R8G8B8A8_UNORM => Some((gl::RGBA, gl::RGBA)),
1886 RafxFormat::R8G8B8A8_SRGB => Some((gl::RGBA, gl::SRGB8_ALPHA8)),
1892 RafxFormat::R32G32B32A32_SFLOAT => Some((gl::RGBA, gl::RGBA32F)),
1958 RafxFormat::D16_UNORM => Some((gl::DEPTH_COMPONENT, gl::DEPTH_COMPONENT16)),
1973 RafxFormat::D32_SFLOAT => Some((gl::DEPTH_COMPONENT, gl::DEPTH_COMPONENT32F)),
1975 RafxFormat::D24_UNORM_S8_UINT => Some((gl::DEPTH_STENCIL, gl::DEPTH24_STENCIL8)),
1978 RafxFormat::D32_SFLOAT_S8_UINT => Some((gl::DEPTH_STENCIL, gl::DEPTH32F_STENCIL8)),
1979 _ => None,
2034 };
2035
2036 let gl_type = self.gles3_type()?;
2037 formats.map(|(gl_format, gl_internal_format)| GlTextureFormatInfo {
2038 gl_format,
2039 gl_type,
2040 gl_internal_format: gl_internal_format as i32
2041 })
2042 }
2043}
2044
2045impl RafxFormat {
2047 pub fn is_depth_only(self) -> bool {
2048 match self {
2049 RafxFormat::D16_UNORM | RafxFormat::X8_D24_UNORM_PACK32 | RafxFormat::D32_SFLOAT => {
2050 true
2051 }
2052 _ => false,
2053 }
2054 }
2055
2056 pub fn is_stencil_only(self) -> bool {
2057 self == RafxFormat::S8_UINT
2058 }
2059
2060 pub fn is_depth_and_stencil(self) -> bool {
2061 match self {
2062 RafxFormat::D16_UNORM_S8_UINT
2063 | RafxFormat::D24_UNORM_S8_UINT
2064 | RafxFormat::D32_SFLOAT_S8_UINT => true,
2065 _ => false,
2066 }
2067 }
2068
2069 pub fn has_depth(self) -> bool {
2070 self.is_depth_and_stencil() || self.is_depth_only()
2071 }
2072
2073 pub fn has_stencil(self) -> bool {
2074 self.is_depth_and_stencil() || self.is_stencil_only()
2075 }
2076
2077 pub fn has_depth_or_stencil(self) -> bool {
2078 self.is_depth_and_stencil() || self.is_stencil_only() || self.is_depth_only()
2079 }
2080
2081 pub fn is_undefined(self) -> bool {
2082 self == RafxFormat::UNDEFINED
2083 }
2084
2085 pub fn is_srgb(self) -> bool {
2086 match self {
2087 RafxFormat::UNDEFINED => false,
2088 RafxFormat::R4G4_UNORM_PACK8 => false,
2089 RafxFormat::R4G4B4A4_UNORM_PACK16 => false,
2090 RafxFormat::B4G4R4A4_UNORM_PACK16 => false,
2091 RafxFormat::R5G6B5_UNORM_PACK16 => false,
2092 RafxFormat::B5G6R5_UNORM_PACK16 => false,
2093 RafxFormat::R5G5B5A1_UNORM_PACK16 => false,
2094 RafxFormat::B5G5R5A1_UNORM_PACK16 => false,
2095 RafxFormat::A1R5G5B5_UNORM_PACK16 => false,
2096 RafxFormat::R8_UNORM => false,
2097 RafxFormat::R8_SNORM => false,
2098 RafxFormat::R8_USCALED => false,
2099 RafxFormat::R8_SSCALED => false,
2100 RafxFormat::R8_UINT => false,
2101 RafxFormat::R8_SINT => false,
2102 RafxFormat::R8_SRGB => true,
2103 RafxFormat::R8G8_UNORM => false,
2104 RafxFormat::R8G8_SNORM => false,
2105 RafxFormat::R8G8_USCALED => false,
2106 RafxFormat::R8G8_SSCALED => false,
2107 RafxFormat::R8G8_UINT => false,
2108 RafxFormat::R8G8_SINT => false,
2109 RafxFormat::R8G8_SRGB => true,
2110 RafxFormat::R8G8B8_UNORM => false,
2111 RafxFormat::R8G8B8_SNORM => false,
2112 RafxFormat::R8G8B8_USCALED => false,
2113 RafxFormat::R8G8B8_SSCALED => false,
2114 RafxFormat::R8G8B8_UINT => false,
2115 RafxFormat::R8G8B8_SINT => false,
2116 RafxFormat::R8G8B8_SRGB => true,
2117 RafxFormat::B8G8R8_UNORM => false,
2118 RafxFormat::B8G8R8_SNORM => false,
2119 RafxFormat::B8G8R8_USCALED => false,
2120 RafxFormat::B8G8R8_SSCALED => false,
2121 RafxFormat::B8G8R8_UINT => false,
2122 RafxFormat::B8G8R8_SINT => false,
2123 RafxFormat::B8G8R8_SRGB => true,
2124 RafxFormat::R8G8B8A8_UNORM => false,
2125 RafxFormat::R8G8B8A8_SNORM => false,
2126 RafxFormat::R8G8B8A8_USCALED => false,
2127 RafxFormat::R8G8B8A8_SSCALED => false,
2128 RafxFormat::R8G8B8A8_UINT => false,
2129 RafxFormat::R8G8B8A8_SINT => false,
2130 RafxFormat::R8G8B8A8_SRGB => true,
2131 RafxFormat::B8G8R8A8_UNORM => false,
2132 RafxFormat::B8G8R8A8_SNORM => false,
2133 RafxFormat::B8G8R8A8_USCALED => false,
2134 RafxFormat::B8G8R8A8_SSCALED => false,
2135 RafxFormat::B8G8R8A8_UINT => false,
2136 RafxFormat::B8G8R8A8_SINT => false,
2137 RafxFormat::B8G8R8A8_SRGB => true,
2138 RafxFormat::A8B8G8R8_UNORM_PACK32 => false,
2139 RafxFormat::A8B8G8R8_SNORM_PACK32 => false,
2140 RafxFormat::A8B8G8R8_USCALED_PACK32 => false,
2141 RafxFormat::A8B8G8R8_SSCALED_PACK32 => false,
2142 RafxFormat::A8B8G8R8_UINT_PACK32 => false,
2143 RafxFormat::A8B8G8R8_SINT_PACK32 => false,
2144 RafxFormat::A8B8G8R8_SRGB_PACK32 => true,
2145 RafxFormat::A2R10G10B10_UNORM_PACK32 => false,
2146 RafxFormat::A2R10G10B10_SNORM_PACK32 => false,
2147 RafxFormat::A2R10G10B10_USCALED_PACK32 => false,
2148 RafxFormat::A2R10G10B10_SSCALED_PACK32 => false,
2149 RafxFormat::A2R10G10B10_UINT_PACK32 => false,
2150 RafxFormat::A2R10G10B10_SINT_PACK32 => false,
2151 RafxFormat::A2B10G10R10_UNORM_PACK32 => false,
2152 RafxFormat::A2B10G10R10_SNORM_PACK32 => false,
2153 RafxFormat::A2B10G10R10_USCALED_PACK32 => false,
2154 RafxFormat::A2B10G10R10_SSCALED_PACK32 => false,
2155 RafxFormat::A2B10G10R10_UINT_PACK32 => false,
2156 RafxFormat::A2B10G10R10_SINT_PACK32 => false,
2157 RafxFormat::R16_UNORM => false,
2158 RafxFormat::R16_SNORM => false,
2159 RafxFormat::R16_USCALED => false,
2160 RafxFormat::R16_SSCALED => false,
2161 RafxFormat::R16_UINT => false,
2162 RafxFormat::R16_SINT => false,
2163 RafxFormat::R16_SFLOAT => false,
2164 RafxFormat::R16G16_UNORM => false,
2165 RafxFormat::R16G16_SNORM => false,
2166 RafxFormat::R16G16_USCALED => false,
2167 RafxFormat::R16G16_SSCALED => false,
2168 RafxFormat::R16G16_UINT => false,
2169 RafxFormat::R16G16_SINT => false,
2170 RafxFormat::R16G16_SFLOAT => false,
2171 RafxFormat::R16G16B16_UNORM => false,
2172 RafxFormat::R16G16B16_SNORM => false,
2173 RafxFormat::R16G16B16_USCALED => false,
2174 RafxFormat::R16G16B16_SSCALED => false,
2175 RafxFormat::R16G16B16_UINT => false,
2176 RafxFormat::R16G16B16_SINT => false,
2177 RafxFormat::R16G16B16_SFLOAT => false,
2178 RafxFormat::R16G16B16A16_UNORM => false,
2179 RafxFormat::R16G16B16A16_SNORM => false,
2180 RafxFormat::R16G16B16A16_USCALED => false,
2181 RafxFormat::R16G16B16A16_SSCALED => false,
2182 RafxFormat::R16G16B16A16_UINT => false,
2183 RafxFormat::R16G16B16A16_SINT => false,
2184 RafxFormat::R16G16B16A16_SFLOAT => false,
2185 RafxFormat::R32_UINT => false,
2186 RafxFormat::R32_SINT => false,
2187 RafxFormat::R32_SFLOAT => false,
2188 RafxFormat::R32G32_UINT => false,
2189 RafxFormat::R32G32_SINT => false,
2190 RafxFormat::R32G32_SFLOAT => false,
2191 RafxFormat::R32G32B32_UINT => false,
2192 RafxFormat::R32G32B32_SINT => false,
2193 RafxFormat::R32G32B32_SFLOAT => false,
2194 RafxFormat::R32G32B32A32_UINT => false,
2195 RafxFormat::R32G32B32A32_SINT => false,
2196 RafxFormat::R32G32B32A32_SFLOAT => false,
2197 RafxFormat::R64_UINT => false,
2198 RafxFormat::R64_SINT => false,
2199 RafxFormat::R64_SFLOAT => false,
2200 RafxFormat::R64G64_UINT => false,
2201 RafxFormat::R64G64_SINT => false,
2202 RafxFormat::R64G64_SFLOAT => false,
2203 RafxFormat::R64G64B64_UINT => false,
2204 RafxFormat::R64G64B64_SINT => false,
2205 RafxFormat::R64G64B64_SFLOAT => false,
2206 RafxFormat::R64G64B64A64_UINT => false,
2207 RafxFormat::R64G64B64A64_SINT => false,
2208 RafxFormat::R64G64B64A64_SFLOAT => false,
2209 RafxFormat::B10G11R11_UFLOAT_PACK32 => false,
2210 RafxFormat::E5B9G9R9_UFLOAT_PACK32 => false,
2211 RafxFormat::D16_UNORM => false,
2212 RafxFormat::X8_D24_UNORM_PACK32 => false,
2213 RafxFormat::D32_SFLOAT => false,
2214 RafxFormat::S8_UINT => false,
2215 RafxFormat::D16_UNORM_S8_UINT => false,
2216 RafxFormat::D24_UNORM_S8_UINT => false,
2217 RafxFormat::D32_SFLOAT_S8_UINT => false,
2218 RafxFormat::BC1_RGB_UNORM_BLOCK => false,
2219 RafxFormat::BC1_RGB_SRGB_BLOCK => true,
2220 RafxFormat::BC1_RGBA_UNORM_BLOCK => false,
2221 RafxFormat::BC1_RGBA_SRGB_BLOCK => true,
2222 RafxFormat::BC2_UNORM_BLOCK => false,
2223 RafxFormat::BC2_SRGB_BLOCK => true,
2224 RafxFormat::BC3_UNORM_BLOCK => false,
2225 RafxFormat::BC3_SRGB_BLOCK => true,
2226 RafxFormat::BC4_UNORM_BLOCK => false,
2227 RafxFormat::BC4_SNORM_BLOCK => false,
2228 RafxFormat::BC5_UNORM_BLOCK => false,
2229 RafxFormat::BC5_SNORM_BLOCK => false,
2230 RafxFormat::BC6H_UFLOAT_BLOCK => false,
2231 RafxFormat::BC6H_SFLOAT_BLOCK => false,
2232 RafxFormat::BC7_UNORM_BLOCK => false,
2233 RafxFormat::BC7_SRGB_BLOCK => true,
2234 RafxFormat::ETC2_R8G8B8_UNORM_BLOCK => false,
2235 RafxFormat::ETC2_R8G8B8_SRGB_BLOCK => true,
2236 RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK => false,
2237 RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK => true,
2238 RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK => false,
2239 RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK => true,
2240 RafxFormat::EAC_R11_UNORM_BLOCK => false,
2241 RafxFormat::EAC_R11_SNORM_BLOCK => false,
2242 RafxFormat::EAC_R11G11_UNORM_BLOCK => false,
2243 RafxFormat::EAC_R11G11_SNORM_BLOCK => false,
2244 RafxFormat::ASTC_4X4_UNORM_BLOCK => false,
2245 RafxFormat::ASTC_4X4_SRGB_BLOCK => true,
2246 RafxFormat::ASTC_5X4_UNORM_BLOCK => false,
2247 RafxFormat::ASTC_5X4_SRGB_BLOCK => true,
2248 RafxFormat::ASTC_5X5_UNORM_BLOCK => false,
2249 RafxFormat::ASTC_5X5_SRGB_BLOCK => true,
2250 RafxFormat::ASTC_6X5_UNORM_BLOCK => false,
2251 RafxFormat::ASTC_6X5_SRGB_BLOCK => true,
2252 RafxFormat::ASTC_6X6_UNORM_BLOCK => false,
2253 RafxFormat::ASTC_6X6_SRGB_BLOCK => true,
2254 RafxFormat::ASTC_8X5_UNORM_BLOCK => false,
2255 RafxFormat::ASTC_8X5_SRGB_BLOCK => true,
2256 RafxFormat::ASTC_8X6_UNORM_BLOCK => false,
2257 RafxFormat::ASTC_8X6_SRGB_BLOCK => true,
2258 RafxFormat::ASTC_8X8_UNORM_BLOCK => false,
2259 RafxFormat::ASTC_8X8_SRGB_BLOCK => true,
2260 RafxFormat::ASTC_10X5_UNORM_BLOCK => false,
2261 RafxFormat::ASTC_10X5_SRGB_BLOCK => true,
2262 RafxFormat::ASTC_10X6_UNORM_BLOCK => false,
2263 RafxFormat::ASTC_10X6_SRGB_BLOCK => true,
2264 RafxFormat::ASTC_10X8_UNORM_BLOCK => false,
2265 RafxFormat::ASTC_10X8_SRGB_BLOCK => true,
2266 RafxFormat::ASTC_10X10_UNORM_BLOCK => false,
2267 RafxFormat::ASTC_10X10_SRGB_BLOCK => true,
2268 RafxFormat::ASTC_12X10_UNORM_BLOCK => false,
2269 RafxFormat::ASTC_12X10_SRGB_BLOCK => true,
2270 RafxFormat::ASTC_12X12_UNORM_BLOCK => false,
2271 RafxFormat::ASTC_12X12_SRGB_BLOCK => true,
2272 }
2273 }
2274
2275 pub fn is_compressed(self) -> bool {
2276 match self {
2277 RafxFormat::BC1_RGB_UNORM_BLOCK
2278 | RafxFormat::BC1_RGB_SRGB_BLOCK
2279 | RafxFormat::BC1_RGBA_UNORM_BLOCK
2280 | RafxFormat::BC1_RGBA_SRGB_BLOCK
2281 | RafxFormat::BC2_UNORM_BLOCK
2282 | RafxFormat::BC2_SRGB_BLOCK
2283 | RafxFormat::BC3_UNORM_BLOCK
2284 | RafxFormat::BC3_SRGB_BLOCK
2285 | RafxFormat::BC4_UNORM_BLOCK
2286 | RafxFormat::BC4_SNORM_BLOCK
2287 | RafxFormat::BC5_UNORM_BLOCK
2288 | RafxFormat::BC5_SNORM_BLOCK
2289 | RafxFormat::BC6H_UFLOAT_BLOCK
2290 | RafxFormat::BC6H_SFLOAT_BLOCK
2291 | RafxFormat::BC7_UNORM_BLOCK
2292 | RafxFormat::BC7_SRGB_BLOCK
2293 | RafxFormat::ETC2_R8G8B8_UNORM_BLOCK
2294 | RafxFormat::ETC2_R8G8B8_SRGB_BLOCK
2295 | RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK
2296 | RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK
2297 | RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK
2298 | RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK
2299 | RafxFormat::EAC_R11_UNORM_BLOCK
2300 | RafxFormat::EAC_R11_SNORM_BLOCK
2301 | RafxFormat::EAC_R11G11_UNORM_BLOCK
2302 | RafxFormat::EAC_R11G11_SNORM_BLOCK
2303 | RafxFormat::ASTC_4X4_UNORM_BLOCK
2304 | RafxFormat::ASTC_4X4_SRGB_BLOCK
2305 | RafxFormat::ASTC_5X4_UNORM_BLOCK
2306 | RafxFormat::ASTC_5X4_SRGB_BLOCK
2307 | RafxFormat::ASTC_5X5_UNORM_BLOCK
2308 | RafxFormat::ASTC_5X5_SRGB_BLOCK
2309 | RafxFormat::ASTC_6X5_UNORM_BLOCK
2310 | RafxFormat::ASTC_6X5_SRGB_BLOCK
2311 | RafxFormat::ASTC_6X6_UNORM_BLOCK
2312 | RafxFormat::ASTC_6X6_SRGB_BLOCK
2313 | RafxFormat::ASTC_8X5_UNORM_BLOCK
2314 | RafxFormat::ASTC_8X5_SRGB_BLOCK
2315 | RafxFormat::ASTC_8X6_UNORM_BLOCK
2316 | RafxFormat::ASTC_8X6_SRGB_BLOCK
2317 | RafxFormat::ASTC_8X8_UNORM_BLOCK
2318 | RafxFormat::ASTC_8X8_SRGB_BLOCK
2319 | RafxFormat::ASTC_10X5_UNORM_BLOCK
2320 | RafxFormat::ASTC_10X5_SRGB_BLOCK
2321 | RafxFormat::ASTC_10X6_UNORM_BLOCK
2322 | RafxFormat::ASTC_10X6_SRGB_BLOCK
2323 | RafxFormat::ASTC_10X8_UNORM_BLOCK
2324 | RafxFormat::ASTC_10X8_SRGB_BLOCK
2325 | RafxFormat::ASTC_10X10_UNORM_BLOCK
2326 | RafxFormat::ASTC_10X10_SRGB_BLOCK
2327 | RafxFormat::ASTC_12X10_UNORM_BLOCK
2328 | RafxFormat::ASTC_12X10_SRGB_BLOCK
2329 | RafxFormat::ASTC_12X12_UNORM_BLOCK
2330 | RafxFormat::ASTC_12X12_SRGB_BLOCK => true,
2331 _ => false,
2332 }
2333 }
2334
2335 pub fn block_or_pixel_size_in_bytes(self) -> u32 {
2336 match self {
2337 RafxFormat::UNDEFINED => unimplemented!(),
2338
2339 RafxFormat::R4G4_UNORM_PACK8 => 1,
2341 RafxFormat::R4G4B4A4_UNORM_PACK16 => 2,
2342 RafxFormat::B4G4R4A4_UNORM_PACK16 => 2,
2343 RafxFormat::R5G6B5_UNORM_PACK16 => 2,
2344 RafxFormat::B5G6R5_UNORM_PACK16 => 2,
2345 RafxFormat::R5G5B5A1_UNORM_PACK16 => 2,
2346 RafxFormat::B5G5R5A1_UNORM_PACK16 => 2,
2347 RafxFormat::A1R5G5B5_UNORM_PACK16 => 2,
2348 RafxFormat::R8_UNORM => 1,
2349 RafxFormat::R8_SNORM => 1,
2350 RafxFormat::R8_USCALED => 1,
2351 RafxFormat::R8_SSCALED => 1,
2352 RafxFormat::R8_UINT => 1,
2353 RafxFormat::R8_SINT => 1,
2354 RafxFormat::R8_SRGB => 1,
2355 RafxFormat::R8G8_UNORM => 2,
2356 RafxFormat::R8G8_SNORM => 2,
2357 RafxFormat::R8G8_USCALED => 2,
2358 RafxFormat::R8G8_SSCALED => 2,
2359 RafxFormat::R8G8_UINT => 2,
2360 RafxFormat::R8G8_SINT => 2,
2361 RafxFormat::R8G8_SRGB => 2,
2362 RafxFormat::R8G8B8_UNORM => 3,
2363 RafxFormat::R8G8B8_SNORM => 3,
2364 RafxFormat::R8G8B8_USCALED => 3,
2365 RafxFormat::R8G8B8_SSCALED => 3,
2366 RafxFormat::R8G8B8_UINT => 3,
2367 RafxFormat::R8G8B8_SINT => 3,
2368 RafxFormat::R8G8B8_SRGB => 3,
2369 RafxFormat::B8G8R8_UNORM => 3,
2370 RafxFormat::B8G8R8_SNORM => 3,
2371 RafxFormat::B8G8R8_USCALED => 3,
2372 RafxFormat::B8G8R8_SSCALED => 3,
2373 RafxFormat::B8G8R8_UINT => 3,
2374 RafxFormat::B8G8R8_SINT => 3,
2375 RafxFormat::B8G8R8_SRGB => 3,
2376 RafxFormat::R8G8B8A8_UNORM => 4,
2377 RafxFormat::R8G8B8A8_SNORM => 4,
2378 RafxFormat::R8G8B8A8_USCALED => 4,
2379 RafxFormat::R8G8B8A8_SSCALED => 4,
2380 RafxFormat::R8G8B8A8_UINT => 4,
2381 RafxFormat::R8G8B8A8_SINT => 4,
2382 RafxFormat::R8G8B8A8_SRGB => 4,
2383 RafxFormat::B8G8R8A8_UNORM => 4,
2384 RafxFormat::B8G8R8A8_SNORM => 4,
2385 RafxFormat::B8G8R8A8_USCALED => 4,
2386 RafxFormat::B8G8R8A8_SSCALED => 4,
2387 RafxFormat::B8G8R8A8_UINT => 4,
2388 RafxFormat::B8G8R8A8_SINT => 4,
2389 RafxFormat::B8G8R8A8_SRGB => 4,
2390 RafxFormat::A8B8G8R8_UNORM_PACK32 => 4,
2391 RafxFormat::A8B8G8R8_SNORM_PACK32 => 4,
2392 RafxFormat::A8B8G8R8_USCALED_PACK32 => 4,
2393 RafxFormat::A8B8G8R8_SSCALED_PACK32 => 4,
2394 RafxFormat::A8B8G8R8_UINT_PACK32 => 4,
2395 RafxFormat::A8B8G8R8_SINT_PACK32 => 4,
2396 RafxFormat::A8B8G8R8_SRGB_PACK32 => 4,
2397 RafxFormat::A2R10G10B10_UNORM_PACK32 => 4,
2398 RafxFormat::A2R10G10B10_SNORM_PACK32 => 4,
2399 RafxFormat::A2R10G10B10_USCALED_PACK32 => 4,
2400 RafxFormat::A2R10G10B10_SSCALED_PACK32 => 4,
2401 RafxFormat::A2R10G10B10_UINT_PACK32 => 4,
2402 RafxFormat::A2R10G10B10_SINT_PACK32 => 4,
2403 RafxFormat::A2B10G10R10_UNORM_PACK32 => 4,
2404 RafxFormat::A2B10G10R10_SNORM_PACK32 => 4,
2405 RafxFormat::A2B10G10R10_USCALED_PACK32 => 4,
2406 RafxFormat::A2B10G10R10_SSCALED_PACK32 => 4,
2407 RafxFormat::A2B10G10R10_UINT_PACK32 => 4,
2408 RafxFormat::A2B10G10R10_SINT_PACK32 => 4,
2409 RafxFormat::R16_UNORM => 2,
2410 RafxFormat::R16_SNORM => 2,
2411 RafxFormat::R16_USCALED => 2,
2412 RafxFormat::R16_SSCALED => 2,
2413 RafxFormat::R16_UINT => 2,
2414 RafxFormat::R16_SINT => 2,
2415 RafxFormat::R16_SFLOAT => 2,
2416 RafxFormat::R16G16_UNORM => 4,
2417 RafxFormat::R16G16_SNORM => 4,
2418 RafxFormat::R16G16_USCALED => 4,
2419 RafxFormat::R16G16_SSCALED => 4,
2420 RafxFormat::R16G16_UINT => 4,
2421 RafxFormat::R16G16_SINT => 4,
2422 RafxFormat::R16G16_SFLOAT => 4,
2423 RafxFormat::R16G16B16_UNORM => 6,
2424 RafxFormat::R16G16B16_SNORM => 6,
2425 RafxFormat::R16G16B16_USCALED => 6,
2426 RafxFormat::R16G16B16_SSCALED => 6,
2427 RafxFormat::R16G16B16_UINT => 6,
2428 RafxFormat::R16G16B16_SINT => 6,
2429 RafxFormat::R16G16B16_SFLOAT => 6,
2430 RafxFormat::R16G16B16A16_UNORM => 8,
2431 RafxFormat::R16G16B16A16_SNORM => 8,
2432 RafxFormat::R16G16B16A16_USCALED => 8,
2433 RafxFormat::R16G16B16A16_SSCALED => 8,
2434 RafxFormat::R16G16B16A16_UINT => 8,
2435 RafxFormat::R16G16B16A16_SINT => 8,
2436 RafxFormat::R16G16B16A16_SFLOAT => 8,
2437 RafxFormat::R32_UINT => 4,
2438 RafxFormat::R32_SINT => 4,
2439 RafxFormat::R32_SFLOAT => 4,
2440 RafxFormat::R32G32_UINT => 8,
2441 RafxFormat::R32G32_SINT => 8,
2442 RafxFormat::R32G32_SFLOAT => 8,
2443 RafxFormat::R32G32B32_UINT => 12,
2444 RafxFormat::R32G32B32_SINT => 12,
2445 RafxFormat::R32G32B32_SFLOAT => 12,
2446 RafxFormat::R32G32B32A32_UINT => 16,
2447 RafxFormat::R32G32B32A32_SINT => 16,
2448 RafxFormat::R32G32B32A32_SFLOAT => 16,
2449 RafxFormat::R64_UINT => 8,
2450 RafxFormat::R64_SINT => 8,
2451 RafxFormat::R64_SFLOAT => 8,
2452 RafxFormat::R64G64_UINT => 16,
2453 RafxFormat::R64G64_SINT => 16,
2454 RafxFormat::R64G64_SFLOAT => 16,
2455 RafxFormat::R64G64B64_UINT => 24,
2456 RafxFormat::R64G64B64_SINT => 24,
2457 RafxFormat::R64G64B64_SFLOAT => 24,
2458 RafxFormat::R64G64B64A64_UINT => 32,
2459 RafxFormat::R64G64B64A64_SINT => 32,
2460 RafxFormat::R64G64B64A64_SFLOAT => 32,
2461 RafxFormat::B10G11R11_UFLOAT_PACK32 => 4,
2462 RafxFormat::E5B9G9R9_UFLOAT_PACK32 => 4,
2463 RafxFormat::D16_UNORM => 2,
2464 RafxFormat::X8_D24_UNORM_PACK32 => 4,
2465 RafxFormat::D32_SFLOAT => 4,
2466 RafxFormat::S8_UINT => 1,
2467 RafxFormat::D16_UNORM_S8_UINT => 3,
2468 RafxFormat::D24_UNORM_S8_UINT => 4,
2469 RafxFormat::D32_SFLOAT_S8_UINT => 5,
2470
2471 RafxFormat::BC1_RGB_UNORM_BLOCK => 8,
2473 RafxFormat::BC1_RGB_SRGB_BLOCK => 8,
2474 RafxFormat::BC1_RGBA_UNORM_BLOCK => 8,
2475 RafxFormat::BC1_RGBA_SRGB_BLOCK => 8,
2476 RafxFormat::BC2_UNORM_BLOCK => 16,
2477 RafxFormat::BC2_SRGB_BLOCK => 16,
2478 RafxFormat::BC3_UNORM_BLOCK => 16,
2479 RafxFormat::BC3_SRGB_BLOCK => 16,
2480 RafxFormat::BC4_UNORM_BLOCK => 8,
2481 RafxFormat::BC4_SNORM_BLOCK => 8,
2482 RafxFormat::BC5_UNORM_BLOCK => 16,
2483 RafxFormat::BC5_SNORM_BLOCK => 16,
2484 RafxFormat::BC6H_UFLOAT_BLOCK => 16,
2485 RafxFormat::BC6H_SFLOAT_BLOCK => 16,
2486 RafxFormat::BC7_UNORM_BLOCK => 16,
2487 RafxFormat::BC7_SRGB_BLOCK => 16,
2488 RafxFormat::ETC2_R8G8B8_UNORM_BLOCK => 8,
2489 RafxFormat::ETC2_R8G8B8_SRGB_BLOCK => 8,
2490 RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK => 8,
2491 RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK => 8,
2492 RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK => 8,
2493 RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK => 8,
2494 RafxFormat::EAC_R11_UNORM_BLOCK => 8,
2495 RafxFormat::EAC_R11_SNORM_BLOCK => 8,
2496 RafxFormat::EAC_R11G11_UNORM_BLOCK => 8,
2497 RafxFormat::EAC_R11G11_SNORM_BLOCK => 8,
2498 RafxFormat::ASTC_4X4_UNORM_BLOCK => 16,
2499 RafxFormat::ASTC_4X4_SRGB_BLOCK => 16,
2500 RafxFormat::ASTC_5X4_UNORM_BLOCK => 16,
2501 RafxFormat::ASTC_5X4_SRGB_BLOCK => 16,
2502 RafxFormat::ASTC_5X5_UNORM_BLOCK => 16,
2503 RafxFormat::ASTC_5X5_SRGB_BLOCK => 16,
2504 RafxFormat::ASTC_6X5_UNORM_BLOCK => 16,
2505 RafxFormat::ASTC_6X5_SRGB_BLOCK => 16,
2506 RafxFormat::ASTC_6X6_UNORM_BLOCK => 16,
2507 RafxFormat::ASTC_6X6_SRGB_BLOCK => 16,
2508 RafxFormat::ASTC_8X5_UNORM_BLOCK => 16,
2509 RafxFormat::ASTC_8X5_SRGB_BLOCK => 16,
2510 RafxFormat::ASTC_8X6_UNORM_BLOCK => 16,
2511 RafxFormat::ASTC_8X6_SRGB_BLOCK => 16,
2512 RafxFormat::ASTC_8X8_UNORM_BLOCK => 16,
2513 RafxFormat::ASTC_8X8_SRGB_BLOCK => 16,
2514 RafxFormat::ASTC_10X5_UNORM_BLOCK => 16,
2515 RafxFormat::ASTC_10X5_SRGB_BLOCK => 16,
2516 RafxFormat::ASTC_10X6_UNORM_BLOCK => 16,
2517 RafxFormat::ASTC_10X6_SRGB_BLOCK => 16,
2518 RafxFormat::ASTC_10X8_UNORM_BLOCK => 16,
2519 RafxFormat::ASTC_10X8_SRGB_BLOCK => 16,
2520 RafxFormat::ASTC_10X10_UNORM_BLOCK => 16,
2521 RafxFormat::ASTC_10X10_SRGB_BLOCK => 16,
2522 RafxFormat::ASTC_12X10_UNORM_BLOCK => 16,
2523 RafxFormat::ASTC_12X10_SRGB_BLOCK => 16,
2524 RafxFormat::ASTC_12X12_UNORM_BLOCK => 16,
2525 RafxFormat::ASTC_12X12_SRGB_BLOCK => 16,
2526 }
2527 }
2528
2529 pub fn block_width_in_pixels(self) -> u32 {
2530 match self {
2531 RafxFormat::UNDEFINED => unimplemented!(),
2532
2533 RafxFormat::BC1_RGB_UNORM_BLOCK => 4,
2534 RafxFormat::BC1_RGB_SRGB_BLOCK => 4,
2535 RafxFormat::BC1_RGBA_UNORM_BLOCK => 4,
2536 RafxFormat::BC1_RGBA_SRGB_BLOCK => 4,
2537 RafxFormat::BC2_UNORM_BLOCK => 4,
2538 RafxFormat::BC2_SRGB_BLOCK => 4,
2539 RafxFormat::BC3_UNORM_BLOCK => 4,
2540 RafxFormat::BC3_SRGB_BLOCK => 4,
2541 RafxFormat::BC4_UNORM_BLOCK => 4,
2542 RafxFormat::BC4_SNORM_BLOCK => 4,
2543 RafxFormat::BC5_UNORM_BLOCK => 4,
2544 RafxFormat::BC5_SNORM_BLOCK => 4,
2545 RafxFormat::BC6H_UFLOAT_BLOCK => 4,
2546 RafxFormat::BC6H_SFLOAT_BLOCK => 4,
2547 RafxFormat::BC7_UNORM_BLOCK => 4,
2548 RafxFormat::BC7_SRGB_BLOCK => 4,
2549 RafxFormat::ETC2_R8G8B8_UNORM_BLOCK => 4,
2550 RafxFormat::ETC2_R8G8B8_SRGB_BLOCK => 4,
2551 RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK => 4,
2552 RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK => 4,
2553 RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK => 4,
2554 RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK => 4,
2555 RafxFormat::EAC_R11_UNORM_BLOCK => 4,
2556 RafxFormat::EAC_R11_SNORM_BLOCK => 4,
2557 RafxFormat::EAC_R11G11_UNORM_BLOCK => 4,
2558 RafxFormat::EAC_R11G11_SNORM_BLOCK => 4,
2559 RafxFormat::ASTC_4X4_UNORM_BLOCK => 4,
2560 RafxFormat::ASTC_4X4_SRGB_BLOCK => 4,
2561 RafxFormat::ASTC_5X4_UNORM_BLOCK => 5,
2562 RafxFormat::ASTC_5X4_SRGB_BLOCK => 5,
2563 RafxFormat::ASTC_5X5_UNORM_BLOCK => 5,
2564 RafxFormat::ASTC_5X5_SRGB_BLOCK => 5,
2565 RafxFormat::ASTC_6X5_UNORM_BLOCK => 6,
2566 RafxFormat::ASTC_6X5_SRGB_BLOCK => 6,
2567 RafxFormat::ASTC_6X6_UNORM_BLOCK => 6,
2568 RafxFormat::ASTC_6X6_SRGB_BLOCK => 6,
2569 RafxFormat::ASTC_8X5_UNORM_BLOCK => 8,
2570 RafxFormat::ASTC_8X5_SRGB_BLOCK => 8,
2571 RafxFormat::ASTC_8X6_UNORM_BLOCK => 8,
2572 RafxFormat::ASTC_8X6_SRGB_BLOCK => 8,
2573 RafxFormat::ASTC_8X8_UNORM_BLOCK => 8,
2574 RafxFormat::ASTC_8X8_SRGB_BLOCK => 8,
2575 RafxFormat::ASTC_10X5_UNORM_BLOCK => 10,
2576 RafxFormat::ASTC_10X5_SRGB_BLOCK => 10,
2577 RafxFormat::ASTC_10X6_UNORM_BLOCK => 10,
2578 RafxFormat::ASTC_10X6_SRGB_BLOCK => 10,
2579 RafxFormat::ASTC_10X8_UNORM_BLOCK => 10,
2580 RafxFormat::ASTC_10X8_SRGB_BLOCK => 10,
2581 RafxFormat::ASTC_10X10_UNORM_BLOCK => 10,
2582 RafxFormat::ASTC_10X10_SRGB_BLOCK => 10,
2583 RafxFormat::ASTC_12X10_UNORM_BLOCK => 12,
2584 RafxFormat::ASTC_12X10_SRGB_BLOCK => 12,
2585 RafxFormat::ASTC_12X12_UNORM_BLOCK => 12,
2586 RafxFormat::ASTC_12X12_SRGB_BLOCK => 12,
2587
2588 _ => 1,
2589 }
2590 }
2591
2592 pub fn block_height_in_pixels(self) -> u32 {
2593 match self {
2594 RafxFormat::UNDEFINED => unimplemented!(),
2595
2596 RafxFormat::BC1_RGB_UNORM_BLOCK => 4,
2597 RafxFormat::BC1_RGB_SRGB_BLOCK => 4,
2598 RafxFormat::BC1_RGBA_UNORM_BLOCK => 4,
2599 RafxFormat::BC1_RGBA_SRGB_BLOCK => 4,
2600 RafxFormat::BC2_UNORM_BLOCK => 4,
2601 RafxFormat::BC2_SRGB_BLOCK => 4,
2602 RafxFormat::BC3_UNORM_BLOCK => 4,
2603 RafxFormat::BC3_SRGB_BLOCK => 4,
2604 RafxFormat::BC4_UNORM_BLOCK => 4,
2605 RafxFormat::BC4_SNORM_BLOCK => 4,
2606 RafxFormat::BC5_UNORM_BLOCK => 4,
2607 RafxFormat::BC5_SNORM_BLOCK => 4,
2608 RafxFormat::BC6H_UFLOAT_BLOCK => 4,
2609 RafxFormat::BC6H_SFLOAT_BLOCK => 4,
2610 RafxFormat::BC7_UNORM_BLOCK => 4,
2611 RafxFormat::BC7_SRGB_BLOCK => 4,
2612 RafxFormat::ETC2_R8G8B8_UNORM_BLOCK => 4,
2613 RafxFormat::ETC2_R8G8B8_SRGB_BLOCK => 4,
2614 RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK => 4,
2615 RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK => 4,
2616 RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK => 4,
2617 RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK => 4,
2618 RafxFormat::EAC_R11_UNORM_BLOCK => 4,
2619 RafxFormat::EAC_R11_SNORM_BLOCK => 4,
2620 RafxFormat::EAC_R11G11_UNORM_BLOCK => 4,
2621 RafxFormat::EAC_R11G11_SNORM_BLOCK => 4,
2622 RafxFormat::ASTC_4X4_UNORM_BLOCK => 4,
2623 RafxFormat::ASTC_4X4_SRGB_BLOCK => 4,
2624 RafxFormat::ASTC_5X4_UNORM_BLOCK => 4,
2625 RafxFormat::ASTC_5X4_SRGB_BLOCK => 4,
2626 RafxFormat::ASTC_5X5_UNORM_BLOCK => 5,
2627 RafxFormat::ASTC_5X5_SRGB_BLOCK => 5,
2628 RafxFormat::ASTC_6X5_UNORM_BLOCK => 5,
2629 RafxFormat::ASTC_6X5_SRGB_BLOCK => 5,
2630 RafxFormat::ASTC_6X6_UNORM_BLOCK => 6,
2631 RafxFormat::ASTC_6X6_SRGB_BLOCK => 6,
2632 RafxFormat::ASTC_8X5_UNORM_BLOCK => 5,
2633 RafxFormat::ASTC_8X5_SRGB_BLOCK => 5,
2634 RafxFormat::ASTC_8X6_UNORM_BLOCK => 6,
2635 RafxFormat::ASTC_8X6_SRGB_BLOCK => 6,
2636 RafxFormat::ASTC_8X8_UNORM_BLOCK => 8,
2637 RafxFormat::ASTC_8X8_SRGB_BLOCK => 8,
2638 RafxFormat::ASTC_10X5_UNORM_BLOCK => 5,
2639 RafxFormat::ASTC_10X5_SRGB_BLOCK => 5,
2640 RafxFormat::ASTC_10X6_UNORM_BLOCK => 6,
2641 RafxFormat::ASTC_10X6_SRGB_BLOCK => 6,
2642 RafxFormat::ASTC_10X8_UNORM_BLOCK => 8,
2643 RafxFormat::ASTC_10X8_SRGB_BLOCK => 8,
2644 RafxFormat::ASTC_10X10_UNORM_BLOCK => 10,
2645 RafxFormat::ASTC_10X10_SRGB_BLOCK => 10,
2646 RafxFormat::ASTC_12X10_UNORM_BLOCK => 10,
2647 RafxFormat::ASTC_12X10_SRGB_BLOCK => 10,
2648 RafxFormat::ASTC_12X12_UNORM_BLOCK => 12,
2649 RafxFormat::ASTC_12X12_SRGB_BLOCK => 12,
2650 _ => 1,
2651 }
2652 }
2653
2654 pub fn channel_count(self) -> u32 {
2655 match self {
2656 RafxFormat::UNDEFINED => unimplemented!(),
2657
2658 RafxFormat::R4G4_UNORM_PACK8 => 2,
2660 RafxFormat::R4G4B4A4_UNORM_PACK16 => 4,
2661 RafxFormat::B4G4R4A4_UNORM_PACK16 => 4,
2662 RafxFormat::R5G6B5_UNORM_PACK16 => 3,
2663 RafxFormat::B5G6R5_UNORM_PACK16 => 3,
2664 RafxFormat::R5G5B5A1_UNORM_PACK16 => 4,
2665 RafxFormat::B5G5R5A1_UNORM_PACK16 => 4,
2666 RafxFormat::A1R5G5B5_UNORM_PACK16 => 4,
2667 RafxFormat::R8_UNORM => 1,
2668 RafxFormat::R8_SNORM => 1,
2669 RafxFormat::R8_USCALED => 1,
2670 RafxFormat::R8_SSCALED => 1,
2671 RafxFormat::R8_UINT => 1,
2672 RafxFormat::R8_SINT => 1,
2673 RafxFormat::R8_SRGB => 1,
2674 RafxFormat::R8G8_UNORM => 2,
2675 RafxFormat::R8G8_SNORM => 2,
2676 RafxFormat::R8G8_USCALED => 2,
2677 RafxFormat::R8G8_SSCALED => 2,
2678 RafxFormat::R8G8_UINT => 2,
2679 RafxFormat::R8G8_SINT => 2,
2680 RafxFormat::R8G8_SRGB => 2,
2681 RafxFormat::R8G8B8_UNORM => 3,
2682 RafxFormat::R8G8B8_SNORM => 3,
2683 RafxFormat::R8G8B8_USCALED => 3,
2684 RafxFormat::R8G8B8_SSCALED => 3,
2685 RafxFormat::R8G8B8_UINT => 3,
2686 RafxFormat::R8G8B8_SINT => 3,
2687 RafxFormat::R8G8B8_SRGB => 3,
2688 RafxFormat::B8G8R8_UNORM => 3,
2689 RafxFormat::B8G8R8_SNORM => 3,
2690 RafxFormat::B8G8R8_USCALED => 3,
2691 RafxFormat::B8G8R8_SSCALED => 3,
2692 RafxFormat::B8G8R8_UINT => 3,
2693 RafxFormat::B8G8R8_SINT => 3,
2694 RafxFormat::B8G8R8_SRGB => 3,
2695 RafxFormat::R8G8B8A8_UNORM => 4,
2696 RafxFormat::R8G8B8A8_SNORM => 4,
2697 RafxFormat::R8G8B8A8_USCALED => 4,
2698 RafxFormat::R8G8B8A8_SSCALED => 4,
2699 RafxFormat::R8G8B8A8_UINT => 4,
2700 RafxFormat::R8G8B8A8_SINT => 4,
2701 RafxFormat::R8G8B8A8_SRGB => 4,
2702 RafxFormat::B8G8R8A8_UNORM => 4,
2703 RafxFormat::B8G8R8A8_SNORM => 4,
2704 RafxFormat::B8G8R8A8_USCALED => 4,
2705 RafxFormat::B8G8R8A8_SSCALED => 4,
2706 RafxFormat::B8G8R8A8_UINT => 4,
2707 RafxFormat::B8G8R8A8_SINT => 4,
2708 RafxFormat::B8G8R8A8_SRGB => 4,
2709 RafxFormat::A8B8G8R8_UNORM_PACK32 => 4,
2710 RafxFormat::A8B8G8R8_SNORM_PACK32 => 4,
2711 RafxFormat::A8B8G8R8_USCALED_PACK32 => 4,
2712 RafxFormat::A8B8G8R8_SSCALED_PACK32 => 4,
2713 RafxFormat::A8B8G8R8_UINT_PACK32 => 4,
2714 RafxFormat::A8B8G8R8_SINT_PACK32 => 4,
2715 RafxFormat::A8B8G8R8_SRGB_PACK32 => 4,
2716 RafxFormat::A2R10G10B10_UNORM_PACK32 => 4,
2717 RafxFormat::A2R10G10B10_SNORM_PACK32 => 4,
2718 RafxFormat::A2R10G10B10_USCALED_PACK32 => 4,
2719 RafxFormat::A2R10G10B10_SSCALED_PACK32 => 4,
2720 RafxFormat::A2R10G10B10_UINT_PACK32 => 4,
2721 RafxFormat::A2R10G10B10_SINT_PACK32 => 4,
2722 RafxFormat::A2B10G10R10_UNORM_PACK32 => 4,
2723 RafxFormat::A2B10G10R10_SNORM_PACK32 => 4,
2724 RafxFormat::A2B10G10R10_USCALED_PACK32 => 4,
2725 RafxFormat::A2B10G10R10_SSCALED_PACK32 => 4,
2726 RafxFormat::A2B10G10R10_UINT_PACK32 => 4,
2727 RafxFormat::A2B10G10R10_SINT_PACK32 => 4,
2728 RafxFormat::R16_UNORM => 1,
2729 RafxFormat::R16_SNORM => 1,
2730 RafxFormat::R16_USCALED => 1,
2731 RafxFormat::R16_SSCALED => 1,
2732 RafxFormat::R16_UINT => 1,
2733 RafxFormat::R16_SINT => 1,
2734 RafxFormat::R16_SFLOAT => 1,
2735 RafxFormat::R16G16_UNORM => 2,
2736 RafxFormat::R16G16_SNORM => 2,
2737 RafxFormat::R16G16_USCALED => 2,
2738 RafxFormat::R16G16_SSCALED => 2,
2739 RafxFormat::R16G16_UINT => 2,
2740 RafxFormat::R16G16_SINT => 2,
2741 RafxFormat::R16G16_SFLOAT => 2,
2742 RafxFormat::R16G16B16_UNORM => 3,
2743 RafxFormat::R16G16B16_SNORM => 3,
2744 RafxFormat::R16G16B16_USCALED => 3,
2745 RafxFormat::R16G16B16_SSCALED => 3,
2746 RafxFormat::R16G16B16_UINT => 3,
2747 RafxFormat::R16G16B16_SINT => 3,
2748 RafxFormat::R16G16B16_SFLOAT => 3,
2749 RafxFormat::R16G16B16A16_UNORM => 4,
2750 RafxFormat::R16G16B16A16_SNORM => 4,
2751 RafxFormat::R16G16B16A16_USCALED => 4,
2752 RafxFormat::R16G16B16A16_SSCALED => 4,
2753 RafxFormat::R16G16B16A16_UINT => 4,
2754 RafxFormat::R16G16B16A16_SINT => 4,
2755 RafxFormat::R16G16B16A16_SFLOAT => 4,
2756 RafxFormat::R32_UINT => 1,
2757 RafxFormat::R32_SINT => 1,
2758 RafxFormat::R32_SFLOAT => 1,
2759 RafxFormat::R32G32_UINT => 2,
2760 RafxFormat::R32G32_SINT => 2,
2761 RafxFormat::R32G32_SFLOAT => 2,
2762 RafxFormat::R32G32B32_UINT => 3,
2763 RafxFormat::R32G32B32_SINT => 3,
2764 RafxFormat::R32G32B32_SFLOAT => 3,
2765 RafxFormat::R32G32B32A32_UINT => 4,
2766 RafxFormat::R32G32B32A32_SINT => 4,
2767 RafxFormat::R32G32B32A32_SFLOAT => 4,
2768 RafxFormat::R64_UINT => 1,
2769 RafxFormat::R64_SINT => 1,
2770 RafxFormat::R64_SFLOAT => 1,
2771 RafxFormat::R64G64_UINT => 2,
2772 RafxFormat::R64G64_SINT => 2,
2773 RafxFormat::R64G64_SFLOAT => 2,
2774 RafxFormat::R64G64B64_UINT => 3,
2775 RafxFormat::R64G64B64_SINT => 3,
2776 RafxFormat::R64G64B64_SFLOAT => 3,
2777 RafxFormat::R64G64B64A64_UINT => 4,
2778 RafxFormat::R64G64B64A64_SINT => 4,
2779 RafxFormat::R64G64B64A64_SFLOAT => 4,
2780 RafxFormat::B10G11R11_UFLOAT_PACK32 => 3,
2781 RafxFormat::E5B9G9R9_UFLOAT_PACK32 => 4,
2782 RafxFormat::D16_UNORM => 1,
2783 RafxFormat::X8_D24_UNORM_PACK32 => 2,
2784 RafxFormat::D32_SFLOAT => 1,
2785 RafxFormat::S8_UINT => 1,
2786 RafxFormat::D16_UNORM_S8_UINT => 2,
2787 RafxFormat::D24_UNORM_S8_UINT => 2,
2788 RafxFormat::D32_SFLOAT_S8_UINT => 2,
2789
2790 RafxFormat::BC1_RGB_UNORM_BLOCK => 3,
2792 RafxFormat::BC1_RGB_SRGB_BLOCK => 3,
2793 RafxFormat::BC1_RGBA_UNORM_BLOCK => 4,
2794 RafxFormat::BC1_RGBA_SRGB_BLOCK => 4,
2795 RafxFormat::BC2_UNORM_BLOCK => 4,
2796 RafxFormat::BC2_SRGB_BLOCK => 4,
2797 RafxFormat::BC3_UNORM_BLOCK => 4,
2798 RafxFormat::BC3_SRGB_BLOCK => 4,
2799 RafxFormat::BC4_UNORM_BLOCK => 1,
2800 RafxFormat::BC4_SNORM_BLOCK => 1,
2801 RafxFormat::BC5_UNORM_BLOCK => 2,
2802 RafxFormat::BC5_SNORM_BLOCK => 2,
2803 RafxFormat::BC6H_UFLOAT_BLOCK => 3,
2804 RafxFormat::BC6H_SFLOAT_BLOCK => 3,
2805 RafxFormat::BC7_UNORM_BLOCK => 4,
2806 RafxFormat::BC7_SRGB_BLOCK => 4,
2807 RafxFormat::ETC2_R8G8B8_UNORM_BLOCK => 3,
2808 RafxFormat::ETC2_R8G8B8_SRGB_BLOCK => 3,
2809 RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK => 4,
2810 RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK => 4,
2811 RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK => 4,
2812 RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK => 4,
2813 RafxFormat::EAC_R11_UNORM_BLOCK => 1,
2814 RafxFormat::EAC_R11_SNORM_BLOCK => 1,
2815 RafxFormat::EAC_R11G11_UNORM_BLOCK => 2,
2816 RafxFormat::EAC_R11G11_SNORM_BLOCK => 2,
2817 RafxFormat::ASTC_4X4_UNORM_BLOCK => 4,
2818 RafxFormat::ASTC_4X4_SRGB_BLOCK => 4,
2819 RafxFormat::ASTC_5X4_UNORM_BLOCK => 4,
2820 RafxFormat::ASTC_5X4_SRGB_BLOCK => 4,
2821 RafxFormat::ASTC_5X5_UNORM_BLOCK => 4,
2822 RafxFormat::ASTC_5X5_SRGB_BLOCK => 4,
2823 RafxFormat::ASTC_6X5_UNORM_BLOCK => 4,
2824 RafxFormat::ASTC_6X5_SRGB_BLOCK => 4,
2825 RafxFormat::ASTC_6X6_UNORM_BLOCK => 4,
2826 RafxFormat::ASTC_6X6_SRGB_BLOCK => 4,
2827 RafxFormat::ASTC_8X5_UNORM_BLOCK => 4,
2828 RafxFormat::ASTC_8X5_SRGB_BLOCK => 4,
2829 RafxFormat::ASTC_8X6_UNORM_BLOCK => 4,
2830 RafxFormat::ASTC_8X6_SRGB_BLOCK => 4,
2831 RafxFormat::ASTC_8X8_UNORM_BLOCK => 4,
2832 RafxFormat::ASTC_8X8_SRGB_BLOCK => 4,
2833 RafxFormat::ASTC_10X5_UNORM_BLOCK => 4,
2834 RafxFormat::ASTC_10X5_SRGB_BLOCK => 4,
2835 RafxFormat::ASTC_10X6_UNORM_BLOCK => 4,
2836 RafxFormat::ASTC_10X6_SRGB_BLOCK => 4,
2837 RafxFormat::ASTC_10X8_UNORM_BLOCK => 4,
2838 RafxFormat::ASTC_10X8_SRGB_BLOCK => 4,
2839 RafxFormat::ASTC_10X10_UNORM_BLOCK => 4,
2840 RafxFormat::ASTC_10X10_SRGB_BLOCK => 4,
2841 RafxFormat::ASTC_12X10_UNORM_BLOCK => 4,
2842 RafxFormat::ASTC_12X10_SRGB_BLOCK => 4,
2843 RafxFormat::ASTC_12X12_UNORM_BLOCK => 4,
2844 RafxFormat::ASTC_12X12_SRGB_BLOCK => 4,
2845 }
2846 }
2847
2848 pub fn is_normalized(self) -> bool {
2849 match self {
2850 RafxFormat::UNDEFINED => unimplemented!(),
2851
2852 RafxFormat::R4G4_UNORM_PACK8 => true,
2854 RafxFormat::R4G4B4A4_UNORM_PACK16 => true,
2855 RafxFormat::B4G4R4A4_UNORM_PACK16 => true,
2856 RafxFormat::R5G6B5_UNORM_PACK16 => true,
2857 RafxFormat::B5G6R5_UNORM_PACK16 => true,
2858 RafxFormat::R5G5B5A1_UNORM_PACK16 => true,
2859 RafxFormat::B5G5R5A1_UNORM_PACK16 => true,
2860 RafxFormat::A1R5G5B5_UNORM_PACK16 => true,
2861 RafxFormat::R8_UNORM => true,
2862 RafxFormat::R8_SNORM => true,
2863 RafxFormat::R8_SRGB => true,
2864 RafxFormat::R8G8_UNORM => true,
2865 RafxFormat::R8G8_SNORM => true,
2866 RafxFormat::R8G8_SRGB => true,
2867 RafxFormat::R8G8B8_UNORM => true,
2868 RafxFormat::R8G8B8_SNORM => true,
2869 RafxFormat::R8G8B8_SRGB => true,
2870 RafxFormat::B8G8R8_UNORM => true,
2871 RafxFormat::B8G8R8_SNORM => true,
2872 RafxFormat::B8G8R8_SRGB => true,
2873 RafxFormat::R8G8B8A8_UNORM => true,
2874 RafxFormat::R8G8B8A8_SNORM => true,
2875 RafxFormat::R8G8B8A8_SRGB => true,
2876 RafxFormat::B8G8R8A8_UNORM => true,
2877 RafxFormat::B8G8R8A8_SNORM => true,
2878 RafxFormat::B8G8R8A8_SRGB => true,
2879 RafxFormat::A8B8G8R8_UNORM_PACK32 => true,
2880 RafxFormat::A8B8G8R8_SNORM_PACK32 => true,
2881 RafxFormat::A8B8G8R8_SRGB_PACK32 => true,
2882 RafxFormat::A2R10G10B10_UNORM_PACK32 => true,
2883 RafxFormat::A2R10G10B10_SNORM_PACK32 => true,
2884 RafxFormat::A2B10G10R10_UNORM_PACK32 => true,
2885 RafxFormat::A2B10G10R10_SNORM_PACK32 => true,
2886 RafxFormat::R16_UNORM => true,
2887 RafxFormat::R16_SNORM => true,
2888 RafxFormat::R16G16_UNORM => true,
2889 RafxFormat::R16G16_SNORM => true,
2890 RafxFormat::R16G16B16_UNORM => true,
2891 RafxFormat::R16G16B16_SNORM => true,
2892 RafxFormat::R16G16B16A16_UNORM => true,
2893 RafxFormat::R16G16B16A16_SNORM => true,
2894 RafxFormat::D16_UNORM => true,
2895 RafxFormat::X8_D24_UNORM_PACK32 => true,
2896 RafxFormat::D16_UNORM_S8_UINT => true,
2897 RafxFormat::D24_UNORM_S8_UINT => true,
2898
2899 RafxFormat::BC1_RGB_UNORM_BLOCK => true,
2901 RafxFormat::BC1_RGB_SRGB_BLOCK => true,
2902 RafxFormat::BC1_RGBA_UNORM_BLOCK => true,
2903 RafxFormat::BC1_RGBA_SRGB_BLOCK => true,
2904 RafxFormat::BC2_UNORM_BLOCK => true,
2905 RafxFormat::BC2_SRGB_BLOCK => true,
2906 RafxFormat::BC3_UNORM_BLOCK => true,
2907 RafxFormat::BC3_SRGB_BLOCK => true,
2908 RafxFormat::BC4_UNORM_BLOCK => true,
2909 RafxFormat::BC4_SNORM_BLOCK => true,
2910 RafxFormat::BC5_UNORM_BLOCK => true,
2911 RafxFormat::BC5_SNORM_BLOCK => true,
2912 RafxFormat::BC7_UNORM_BLOCK => true,
2913 RafxFormat::BC7_SRGB_BLOCK => true,
2914 RafxFormat::ETC2_R8G8B8_UNORM_BLOCK => true,
2915 RafxFormat::ETC2_R8G8B8_SRGB_BLOCK => true,
2916 RafxFormat::ETC2_R8G8B8A1_UNORM_BLOCK => true,
2917 RafxFormat::ETC2_R8G8B8A1_SRGB_BLOCK => true,
2918 RafxFormat::ETC2_R8G8B8A8_UNORM_BLOCK => true,
2919 RafxFormat::ETC2_R8G8B8A8_SRGB_BLOCK => true,
2920 RafxFormat::EAC_R11_UNORM_BLOCK => true,
2921 RafxFormat::EAC_R11_SNORM_BLOCK => true,
2922 RafxFormat::EAC_R11G11_UNORM_BLOCK => true,
2923 RafxFormat::EAC_R11G11_SNORM_BLOCK => true,
2924 RafxFormat::ASTC_4X4_UNORM_BLOCK => true,
2925 RafxFormat::ASTC_4X4_SRGB_BLOCK => true,
2926 RafxFormat::ASTC_5X4_UNORM_BLOCK => true,
2927 RafxFormat::ASTC_5X4_SRGB_BLOCK => true,
2928 RafxFormat::ASTC_5X5_UNORM_BLOCK => true,
2929 RafxFormat::ASTC_5X5_SRGB_BLOCK => true,
2930 RafxFormat::ASTC_6X5_UNORM_BLOCK => true,
2931 RafxFormat::ASTC_6X5_SRGB_BLOCK => true,
2932 RafxFormat::ASTC_6X6_UNORM_BLOCK => true,
2933 RafxFormat::ASTC_6X6_SRGB_BLOCK => true,
2934 RafxFormat::ASTC_8X5_UNORM_BLOCK => true,
2935 RafxFormat::ASTC_8X5_SRGB_BLOCK => true,
2936 RafxFormat::ASTC_8X6_UNORM_BLOCK => true,
2937 RafxFormat::ASTC_8X6_SRGB_BLOCK => true,
2938 RafxFormat::ASTC_8X8_UNORM_BLOCK => true,
2939 RafxFormat::ASTC_8X8_SRGB_BLOCK => true,
2940 RafxFormat::ASTC_10X5_UNORM_BLOCK => true,
2941 RafxFormat::ASTC_10X5_SRGB_BLOCK => true,
2942 RafxFormat::ASTC_10X6_UNORM_BLOCK => true,
2943 RafxFormat::ASTC_10X6_SRGB_BLOCK => true,
2944 RafxFormat::ASTC_10X8_UNORM_BLOCK => true,
2945 RafxFormat::ASTC_10X8_SRGB_BLOCK => true,
2946 RafxFormat::ASTC_10X10_UNORM_BLOCK => true,
2947 RafxFormat::ASTC_10X10_SRGB_BLOCK => true,
2948 RafxFormat::ASTC_12X10_UNORM_BLOCK => true,
2949 RafxFormat::ASTC_12X10_SRGB_BLOCK => true,
2950 RafxFormat::ASTC_12X12_UNORM_BLOCK => true,
2951 RafxFormat::ASTC_12X12_SRGB_BLOCK => true,
2952
2953 _ => false,
2954 }
2955 }
2956}
2957
2958pub mod recommended_formats {
2963 use super::RafxFormat;
2964
2965 pub const COLOR_FORMATS_SDR: [RafxFormat; 1] = [
2967 RafxFormat::R8G8B8A8_SNORM, ];
2969
2970 pub const COLOR_FORMATS_HDR: [RafxFormat; 2] = [
2971 RafxFormat::R16G16B16A16_SFLOAT, RafxFormat::R32G32B32A32_SFLOAT, ];
2974
2975 pub const DEPTH_FORMATS: [RafxFormat; 4] = [
2976 RafxFormat::D32_SFLOAT, RafxFormat::D32_SFLOAT_S8_UINT, RafxFormat::D24_UNORM_S8_UINT,
2979 RafxFormat::D16_UNORM, ];
2981}