1mod enums {
2 #![allow(dead_code, unused_imports)]
3 use crate::ffi;
4 use bitflags::bitflags;
5 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
6 pub enum WGSLLanguageFeatureName {
7 ReadonlyAndReadwriteStorageTextures,
8 Packed4X8IntegerDotProduct,
9 UnrestrictedPointerParameters,
10 PointerCompositeAccess,
11 UniformBufferStandardLayout,
12 SubgroupId,
13 TextureAndSamplerLet,
14 SubgroupUniformity,
15 TextureFormatsTier1,
16 ChromiumTestingUnimplemented,
17 ChromiumTestingUnsafeExperimental,
18 ChromiumTestingExperimental,
19 ChromiumTestingShippedWithKillswitch,
20 ChromiumTestingShipped,
21 SizedBindingArray,
22 TexelBuffers,
23 ChromiumPrint,
24 FragmentDepth,
25 ImmediateAddressSpace,
26 BufferView,
27 FilteringParameters,
28 SwizzleAssignment,
29 LinearIndexing,
30 }
31 impl From<ffi::WGPUWGSLLanguageFeatureName> for WGSLLanguageFeatureName {
32 fn from(value: ffi::WGPUWGSLLanguageFeatureName) -> Self {
33 match value {
34 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures => {
35 WGSLLanguageFeatureName::ReadonlyAndReadwriteStorageTextures
36 }
37 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct => {
38 WGSLLanguageFeatureName::Packed4X8IntegerDotProduct
39 }
40 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters => {
41 WGSLLanguageFeatureName::UnrestrictedPointerParameters
42 }
43 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_PointerCompositeAccess => {
44 WGSLLanguageFeatureName::PointerCompositeAccess
45 }
46 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_UniformBufferStandardLayout => {
47 WGSLLanguageFeatureName::UniformBufferStandardLayout
48 }
49 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SubgroupId => {
50 WGSLLanguageFeatureName::SubgroupId
51 }
52 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TextureAndSamplerLet => {
53 WGSLLanguageFeatureName::TextureAndSamplerLet
54 }
55 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SubgroupUniformity => {
56 WGSLLanguageFeatureName::SubgroupUniformity
57 }
58 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TextureFormatsTier1 => {
59 WGSLLanguageFeatureName::TextureFormatsTier1
60 }
61 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingUnimplemented => {
62 WGSLLanguageFeatureName::ChromiumTestingUnimplemented
63 }
64 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingUnsafeExperimental => {
65 WGSLLanguageFeatureName::ChromiumTestingUnsafeExperimental
66 }
67 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingExperimental => {
68 WGSLLanguageFeatureName::ChromiumTestingExperimental
69 }
70 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingShippedWithKillswitch => {
71 WGSLLanguageFeatureName::ChromiumTestingShippedWithKillswitch
72 }
73 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingShipped => {
74 WGSLLanguageFeatureName::ChromiumTestingShipped
75 }
76 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SizedBindingArray => {
77 WGSLLanguageFeatureName::SizedBindingArray
78 }
79 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TexelBuffers => {
80 WGSLLanguageFeatureName::TexelBuffers
81 }
82 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumPrint => {
83 WGSLLanguageFeatureName::ChromiumPrint
84 }
85 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_FragmentDepth => {
86 WGSLLanguageFeatureName::FragmentDepth
87 }
88 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ImmediateAddressSpace => {
89 WGSLLanguageFeatureName::ImmediateAddressSpace
90 }
91 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_BufferView => {
92 WGSLLanguageFeatureName::BufferView
93 }
94 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_FilteringParameters => {
95 WGSLLanguageFeatureName::FilteringParameters
96 }
97 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SwizzleAssignment => {
98 WGSLLanguageFeatureName::SwizzleAssignment
99 }
100 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_LinearIndexing => {
101 WGSLLanguageFeatureName::LinearIndexing
102 }
103 _ => WGSLLanguageFeatureName::ReadonlyAndReadwriteStorageTextures,
104 }
105 }
106 }
107 impl From<WGSLLanguageFeatureName> for ffi::WGPUWGSLLanguageFeatureName {
108 fn from(value: WGSLLanguageFeatureName) -> Self {
109 match value {
110 WGSLLanguageFeatureName::ReadonlyAndReadwriteStorageTextures => {
111 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures
112 }
113 WGSLLanguageFeatureName::Packed4X8IntegerDotProduct => {
114 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct
115 }
116 WGSLLanguageFeatureName::UnrestrictedPointerParameters => {
117 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters
118 }
119 WGSLLanguageFeatureName::PointerCompositeAccess => {
120 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_PointerCompositeAccess
121 }
122 WGSLLanguageFeatureName::UniformBufferStandardLayout => {
123 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_UniformBufferStandardLayout
124 }
125 WGSLLanguageFeatureName::SubgroupId => {
126 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SubgroupId
127 }
128 WGSLLanguageFeatureName::TextureAndSamplerLet => {
129 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TextureAndSamplerLet
130 }
131 WGSLLanguageFeatureName::SubgroupUniformity => {
132 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SubgroupUniformity
133 }
134 WGSLLanguageFeatureName::TextureFormatsTier1 => {
135 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TextureFormatsTier1
136 }
137 WGSLLanguageFeatureName::ChromiumTestingUnimplemented => {
138 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingUnimplemented
139 }
140 WGSLLanguageFeatureName::ChromiumTestingUnsafeExperimental => {
141 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingUnsafeExperimental
142 }
143 WGSLLanguageFeatureName::ChromiumTestingExperimental => {
144 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingExperimental
145 }
146 WGSLLanguageFeatureName::ChromiumTestingShippedWithKillswitch => {
147 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingShippedWithKillswitch
148 }
149 WGSLLanguageFeatureName::ChromiumTestingShipped => {
150 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingShipped
151 }
152 WGSLLanguageFeatureName::SizedBindingArray => {
153 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SizedBindingArray
154 }
155 WGSLLanguageFeatureName::TexelBuffers => {
156 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TexelBuffers
157 }
158 WGSLLanguageFeatureName::ChromiumPrint => {
159 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumPrint
160 }
161 WGSLLanguageFeatureName::FragmentDepth => {
162 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_FragmentDepth
163 }
164 WGSLLanguageFeatureName::ImmediateAddressSpace => {
165 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ImmediateAddressSpace
166 }
167 WGSLLanguageFeatureName::BufferView => {
168 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_BufferView
169 }
170 WGSLLanguageFeatureName::FilteringParameters => {
171 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_FilteringParameters
172 }
173 WGSLLanguageFeatureName::SwizzleAssignment => {
174 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SwizzleAssignment
175 }
176 WGSLLanguageFeatureName::LinearIndexing => {
177 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_LinearIndexing
178 }
179 }
180 }
181 }
182 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
183 pub enum AdapterType {
184 DiscreteGpu,
185 IntegratedGpu,
186 Cpu,
187 Unknown,
188 }
189 impl From<ffi::WGPUAdapterType> for AdapterType {
190 fn from(value: ffi::WGPUAdapterType) -> Self {
191 match value {
192 ffi::WGPUAdapterType_WGPUAdapterType_DiscreteGPU => {
193 AdapterType::DiscreteGpu
194 }
195 ffi::WGPUAdapterType_WGPUAdapterType_IntegratedGPU => {
196 AdapterType::IntegratedGpu
197 }
198 ffi::WGPUAdapterType_WGPUAdapterType_CPU => AdapterType::Cpu,
199 ffi::WGPUAdapterType_WGPUAdapterType_Unknown => AdapterType::Unknown,
200 _ => AdapterType::DiscreteGpu,
201 }
202 }
203 }
204 impl From<AdapterType> for ffi::WGPUAdapterType {
205 fn from(value: AdapterType) -> Self {
206 match value {
207 AdapterType::DiscreteGpu => {
208 ffi::WGPUAdapterType_WGPUAdapterType_DiscreteGPU
209 }
210 AdapterType::IntegratedGpu => {
211 ffi::WGPUAdapterType_WGPUAdapterType_IntegratedGPU
212 }
213 AdapterType::Cpu => ffi::WGPUAdapterType_WGPUAdapterType_CPU,
214 AdapterType::Unknown => ffi::WGPUAdapterType_WGPUAdapterType_Unknown,
215 }
216 }
217 }
218 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
219 pub enum AddressMode {
220 Undefined,
221 ClampToEdge,
222 Repeat,
223 MirrorRepeat,
224 }
225 impl From<ffi::WGPUAddressMode> for AddressMode {
226 fn from(value: ffi::WGPUAddressMode) -> Self {
227 match value {
228 ffi::WGPUAddressMode_WGPUAddressMode_Undefined => AddressMode::Undefined,
229 ffi::WGPUAddressMode_WGPUAddressMode_ClampToEdge => {
230 AddressMode::ClampToEdge
231 }
232 ffi::WGPUAddressMode_WGPUAddressMode_Repeat => AddressMode::Repeat,
233 ffi::WGPUAddressMode_WGPUAddressMode_MirrorRepeat => {
234 AddressMode::MirrorRepeat
235 }
236 _ => AddressMode::Undefined,
237 }
238 }
239 }
240 impl From<AddressMode> for ffi::WGPUAddressMode {
241 fn from(value: AddressMode) -> Self {
242 match value {
243 AddressMode::Undefined => ffi::WGPUAddressMode_WGPUAddressMode_Undefined,
244 AddressMode::ClampToEdge => {
245 ffi::WGPUAddressMode_WGPUAddressMode_ClampToEdge
246 }
247 AddressMode::Repeat => ffi::WGPUAddressMode_WGPUAddressMode_Repeat,
248 AddressMode::MirrorRepeat => {
249 ffi::WGPUAddressMode_WGPUAddressMode_MirrorRepeat
250 }
251 }
252 }
253 }
254 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
255 pub enum AlphaMode {
256 Opaque,
257 Premultiplied,
258 Unpremultiplied,
259 }
260 impl From<ffi::WGPUAlphaMode> for AlphaMode {
261 fn from(value: ffi::WGPUAlphaMode) -> Self {
262 match value {
263 ffi::WGPUAlphaMode_WGPUAlphaMode_Opaque => AlphaMode::Opaque,
264 ffi::WGPUAlphaMode_WGPUAlphaMode_Premultiplied => {
265 AlphaMode::Premultiplied
266 }
267 ffi::WGPUAlphaMode_WGPUAlphaMode_Unpremultiplied => {
268 AlphaMode::Unpremultiplied
269 }
270 _ => AlphaMode::Opaque,
271 }
272 }
273 }
274 impl From<AlphaMode> for ffi::WGPUAlphaMode {
275 fn from(value: AlphaMode) -> Self {
276 match value {
277 AlphaMode::Opaque => ffi::WGPUAlphaMode_WGPUAlphaMode_Opaque,
278 AlphaMode::Premultiplied => {
279 ffi::WGPUAlphaMode_WGPUAlphaMode_Premultiplied
280 }
281 AlphaMode::Unpremultiplied => {
282 ffi::WGPUAlphaMode_WGPUAlphaMode_Unpremultiplied
283 }
284 }
285 }
286 }
287 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
288 pub enum BackendType {
289 Undefined,
290 Null,
291 WebGPU,
292 D3D11,
293 D3D12,
294 Metal,
295 Vulkan,
296 OpenGL,
297 OpenGLes,
298 }
299 impl From<ffi::WGPUBackendType> for BackendType {
300 fn from(value: ffi::WGPUBackendType) -> Self {
301 match value {
302 ffi::WGPUBackendType_WGPUBackendType_Undefined => BackendType::Undefined,
303 ffi::WGPUBackendType_WGPUBackendType_Null => BackendType::Null,
304 ffi::WGPUBackendType_WGPUBackendType_WebGPU => BackendType::WebGPU,
305 ffi::WGPUBackendType_WGPUBackendType_D3D11 => BackendType::D3D11,
306 ffi::WGPUBackendType_WGPUBackendType_D3D12 => BackendType::D3D12,
307 ffi::WGPUBackendType_WGPUBackendType_Metal => BackendType::Metal,
308 ffi::WGPUBackendType_WGPUBackendType_Vulkan => BackendType::Vulkan,
309 ffi::WGPUBackendType_WGPUBackendType_OpenGL => BackendType::OpenGL,
310 ffi::WGPUBackendType_WGPUBackendType_OpenGLES => BackendType::OpenGLes,
311 _ => BackendType::Undefined,
312 }
313 }
314 }
315 impl From<BackendType> for ffi::WGPUBackendType {
316 fn from(value: BackendType) -> Self {
317 match value {
318 BackendType::Undefined => ffi::WGPUBackendType_WGPUBackendType_Undefined,
319 BackendType::Null => ffi::WGPUBackendType_WGPUBackendType_Null,
320 BackendType::WebGPU => ffi::WGPUBackendType_WGPUBackendType_WebGPU,
321 BackendType::D3D11 => ffi::WGPUBackendType_WGPUBackendType_D3D11,
322 BackendType::D3D12 => ffi::WGPUBackendType_WGPUBackendType_D3D12,
323 BackendType::Metal => ffi::WGPUBackendType_WGPUBackendType_Metal,
324 BackendType::Vulkan => ffi::WGPUBackendType_WGPUBackendType_Vulkan,
325 BackendType::OpenGL => ffi::WGPUBackendType_WGPUBackendType_OpenGL,
326 BackendType::OpenGLes => ffi::WGPUBackendType_WGPUBackendType_OpenGLES,
327 }
328 }
329 }
330 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
331 pub enum BlendFactor {
332 Undefined,
333 Zero,
334 One,
335 Src,
336 OneMinusSrc,
337 SrcAlpha,
338 OneMinusSrcAlpha,
339 Dst,
340 OneMinusDst,
341 DstAlpha,
342 OneMinusDstAlpha,
343 SrcAlphaSaturated,
344 Constant,
345 OneMinusConstant,
346 Src1,
347 OneMinusSrc1,
348 Src1Alpha,
349 OneMinusSrc1Alpha,
350 }
351 impl From<ffi::WGPUBlendFactor> for BlendFactor {
352 fn from(value: ffi::WGPUBlendFactor) -> Self {
353 match value {
354 ffi::WGPUBlendFactor_WGPUBlendFactor_Undefined => BlendFactor::Undefined,
355 ffi::WGPUBlendFactor_WGPUBlendFactor_Zero => BlendFactor::Zero,
356 ffi::WGPUBlendFactor_WGPUBlendFactor_One => BlendFactor::One,
357 ffi::WGPUBlendFactor_WGPUBlendFactor_Src => BlendFactor::Src,
358 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc => {
359 BlendFactor::OneMinusSrc
360 }
361 ffi::WGPUBlendFactor_WGPUBlendFactor_SrcAlpha => BlendFactor::SrcAlpha,
362 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrcAlpha => {
363 BlendFactor::OneMinusSrcAlpha
364 }
365 ffi::WGPUBlendFactor_WGPUBlendFactor_Dst => BlendFactor::Dst,
366 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusDst => {
367 BlendFactor::OneMinusDst
368 }
369 ffi::WGPUBlendFactor_WGPUBlendFactor_DstAlpha => BlendFactor::DstAlpha,
370 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusDstAlpha => {
371 BlendFactor::OneMinusDstAlpha
372 }
373 ffi::WGPUBlendFactor_WGPUBlendFactor_SrcAlphaSaturated => {
374 BlendFactor::SrcAlphaSaturated
375 }
376 ffi::WGPUBlendFactor_WGPUBlendFactor_Constant => BlendFactor::Constant,
377 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusConstant => {
378 BlendFactor::OneMinusConstant
379 }
380 ffi::WGPUBlendFactor_WGPUBlendFactor_Src1 => BlendFactor::Src1,
381 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc1 => {
382 BlendFactor::OneMinusSrc1
383 }
384 ffi::WGPUBlendFactor_WGPUBlendFactor_Src1Alpha => BlendFactor::Src1Alpha,
385 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc1Alpha => {
386 BlendFactor::OneMinusSrc1Alpha
387 }
388 _ => BlendFactor::Undefined,
389 }
390 }
391 }
392 impl From<BlendFactor> for ffi::WGPUBlendFactor {
393 fn from(value: BlendFactor) -> Self {
394 match value {
395 BlendFactor::Undefined => ffi::WGPUBlendFactor_WGPUBlendFactor_Undefined,
396 BlendFactor::Zero => ffi::WGPUBlendFactor_WGPUBlendFactor_Zero,
397 BlendFactor::One => ffi::WGPUBlendFactor_WGPUBlendFactor_One,
398 BlendFactor::Src => ffi::WGPUBlendFactor_WGPUBlendFactor_Src,
399 BlendFactor::OneMinusSrc => {
400 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc
401 }
402 BlendFactor::SrcAlpha => ffi::WGPUBlendFactor_WGPUBlendFactor_SrcAlpha,
403 BlendFactor::OneMinusSrcAlpha => {
404 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrcAlpha
405 }
406 BlendFactor::Dst => ffi::WGPUBlendFactor_WGPUBlendFactor_Dst,
407 BlendFactor::OneMinusDst => {
408 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusDst
409 }
410 BlendFactor::DstAlpha => ffi::WGPUBlendFactor_WGPUBlendFactor_DstAlpha,
411 BlendFactor::OneMinusDstAlpha => {
412 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusDstAlpha
413 }
414 BlendFactor::SrcAlphaSaturated => {
415 ffi::WGPUBlendFactor_WGPUBlendFactor_SrcAlphaSaturated
416 }
417 BlendFactor::Constant => ffi::WGPUBlendFactor_WGPUBlendFactor_Constant,
418 BlendFactor::OneMinusConstant => {
419 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusConstant
420 }
421 BlendFactor::Src1 => ffi::WGPUBlendFactor_WGPUBlendFactor_Src1,
422 BlendFactor::OneMinusSrc1 => {
423 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc1
424 }
425 BlendFactor::Src1Alpha => ffi::WGPUBlendFactor_WGPUBlendFactor_Src1Alpha,
426 BlendFactor::OneMinusSrc1Alpha => {
427 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc1Alpha
428 }
429 }
430 }
431 }
432 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
433 pub enum BlendOperation {
434 Undefined,
435 Add,
436 Subtract,
437 ReverseSubtract,
438 Min,
439 Max,
440 }
441 impl From<ffi::WGPUBlendOperation> for BlendOperation {
442 fn from(value: ffi::WGPUBlendOperation) -> Self {
443 match value {
444 ffi::WGPUBlendOperation_WGPUBlendOperation_Undefined => {
445 BlendOperation::Undefined
446 }
447 ffi::WGPUBlendOperation_WGPUBlendOperation_Add => BlendOperation::Add,
448 ffi::WGPUBlendOperation_WGPUBlendOperation_Subtract => {
449 BlendOperation::Subtract
450 }
451 ffi::WGPUBlendOperation_WGPUBlendOperation_ReverseSubtract => {
452 BlendOperation::ReverseSubtract
453 }
454 ffi::WGPUBlendOperation_WGPUBlendOperation_Min => BlendOperation::Min,
455 ffi::WGPUBlendOperation_WGPUBlendOperation_Max => BlendOperation::Max,
456 _ => BlendOperation::Undefined,
457 }
458 }
459 }
460 impl From<BlendOperation> for ffi::WGPUBlendOperation {
461 fn from(value: BlendOperation) -> Self {
462 match value {
463 BlendOperation::Undefined => {
464 ffi::WGPUBlendOperation_WGPUBlendOperation_Undefined
465 }
466 BlendOperation::Add => ffi::WGPUBlendOperation_WGPUBlendOperation_Add,
467 BlendOperation::Subtract => {
468 ffi::WGPUBlendOperation_WGPUBlendOperation_Subtract
469 }
470 BlendOperation::ReverseSubtract => {
471 ffi::WGPUBlendOperation_WGPUBlendOperation_ReverseSubtract
472 }
473 BlendOperation::Min => ffi::WGPUBlendOperation_WGPUBlendOperation_Min,
474 BlendOperation::Max => ffi::WGPUBlendOperation_WGPUBlendOperation_Max,
475 }
476 }
477 }
478 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
479 pub enum BufferBindingType {
480 BindingNotUsed,
481 Undefined,
482 Uniform,
483 Storage,
484 ReadOnlyStorage,
485 }
486 impl From<ffi::WGPUBufferBindingType> for BufferBindingType {
487 fn from(value: ffi::WGPUBufferBindingType) -> Self {
488 match value {
489 ffi::WGPUBufferBindingType_WGPUBufferBindingType_BindingNotUsed => {
490 BufferBindingType::BindingNotUsed
491 }
492 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Undefined => {
493 BufferBindingType::Undefined
494 }
495 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Uniform => {
496 BufferBindingType::Uniform
497 }
498 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Storage => {
499 BufferBindingType::Storage
500 }
501 ffi::WGPUBufferBindingType_WGPUBufferBindingType_ReadOnlyStorage => {
502 BufferBindingType::ReadOnlyStorage
503 }
504 _ => BufferBindingType::BindingNotUsed,
505 }
506 }
507 }
508 impl From<BufferBindingType> for ffi::WGPUBufferBindingType {
509 fn from(value: BufferBindingType) -> Self {
510 match value {
511 BufferBindingType::BindingNotUsed => {
512 ffi::WGPUBufferBindingType_WGPUBufferBindingType_BindingNotUsed
513 }
514 BufferBindingType::Undefined => {
515 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Undefined
516 }
517 BufferBindingType::Uniform => {
518 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Uniform
519 }
520 BufferBindingType::Storage => {
521 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Storage
522 }
523 BufferBindingType::ReadOnlyStorage => {
524 ffi::WGPUBufferBindingType_WGPUBufferBindingType_ReadOnlyStorage
525 }
526 }
527 }
528 }
529 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
530 pub enum BufferMapState {
531 Unmapped,
532 Pending,
533 Mapped,
534 }
535 impl From<ffi::WGPUBufferMapState> for BufferMapState {
536 fn from(value: ffi::WGPUBufferMapState) -> Self {
537 match value {
538 ffi::WGPUBufferMapState_WGPUBufferMapState_Unmapped => {
539 BufferMapState::Unmapped
540 }
541 ffi::WGPUBufferMapState_WGPUBufferMapState_Pending => {
542 BufferMapState::Pending
543 }
544 ffi::WGPUBufferMapState_WGPUBufferMapState_Mapped => {
545 BufferMapState::Mapped
546 }
547 _ => BufferMapState::Unmapped,
548 }
549 }
550 }
551 impl From<BufferMapState> for ffi::WGPUBufferMapState {
552 fn from(value: BufferMapState) -> Self {
553 match value {
554 BufferMapState::Unmapped => {
555 ffi::WGPUBufferMapState_WGPUBufferMapState_Unmapped
556 }
557 BufferMapState::Pending => {
558 ffi::WGPUBufferMapState_WGPUBufferMapState_Pending
559 }
560 BufferMapState::Mapped => {
561 ffi::WGPUBufferMapState_WGPUBufferMapState_Mapped
562 }
563 }
564 }
565 }
566 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
567 pub enum CallbackMode {
568 WaitAnyOnly,
569 AllowProcessEvents,
570 AllowSpontaneous,
571 }
572 impl From<ffi::WGPUCallbackMode> for CallbackMode {
573 fn from(value: ffi::WGPUCallbackMode) -> Self {
574 match value {
575 ffi::WGPUCallbackMode_WGPUCallbackMode_WaitAnyOnly => {
576 CallbackMode::WaitAnyOnly
577 }
578 ffi::WGPUCallbackMode_WGPUCallbackMode_AllowProcessEvents => {
579 CallbackMode::AllowProcessEvents
580 }
581 ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous => {
582 CallbackMode::AllowSpontaneous
583 }
584 _ => CallbackMode::WaitAnyOnly,
585 }
586 }
587 }
588 impl From<CallbackMode> for ffi::WGPUCallbackMode {
589 fn from(value: CallbackMode) -> Self {
590 match value {
591 CallbackMode::WaitAnyOnly => {
592 ffi::WGPUCallbackMode_WGPUCallbackMode_WaitAnyOnly
593 }
594 CallbackMode::AllowProcessEvents => {
595 ffi::WGPUCallbackMode_WGPUCallbackMode_AllowProcessEvents
596 }
597 CallbackMode::AllowSpontaneous => {
598 ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous
599 }
600 }
601 }
602 }
603 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
604 pub enum CompareFunction {
605 Undefined,
606 Never,
607 Less,
608 Equal,
609 LessEqual,
610 Greater,
611 NotEqual,
612 GreaterEqual,
613 Always,
614 }
615 impl From<ffi::WGPUCompareFunction> for CompareFunction {
616 fn from(value: ffi::WGPUCompareFunction) -> Self {
617 match value {
618 ffi::WGPUCompareFunction_WGPUCompareFunction_Undefined => {
619 CompareFunction::Undefined
620 }
621 ffi::WGPUCompareFunction_WGPUCompareFunction_Never => {
622 CompareFunction::Never
623 }
624 ffi::WGPUCompareFunction_WGPUCompareFunction_Less => {
625 CompareFunction::Less
626 }
627 ffi::WGPUCompareFunction_WGPUCompareFunction_Equal => {
628 CompareFunction::Equal
629 }
630 ffi::WGPUCompareFunction_WGPUCompareFunction_LessEqual => {
631 CompareFunction::LessEqual
632 }
633 ffi::WGPUCompareFunction_WGPUCompareFunction_Greater => {
634 CompareFunction::Greater
635 }
636 ffi::WGPUCompareFunction_WGPUCompareFunction_NotEqual => {
637 CompareFunction::NotEqual
638 }
639 ffi::WGPUCompareFunction_WGPUCompareFunction_GreaterEqual => {
640 CompareFunction::GreaterEqual
641 }
642 ffi::WGPUCompareFunction_WGPUCompareFunction_Always => {
643 CompareFunction::Always
644 }
645 _ => CompareFunction::Undefined,
646 }
647 }
648 }
649 impl From<CompareFunction> for ffi::WGPUCompareFunction {
650 fn from(value: CompareFunction) -> Self {
651 match value {
652 CompareFunction::Undefined => {
653 ffi::WGPUCompareFunction_WGPUCompareFunction_Undefined
654 }
655 CompareFunction::Never => {
656 ffi::WGPUCompareFunction_WGPUCompareFunction_Never
657 }
658 CompareFunction::Less => {
659 ffi::WGPUCompareFunction_WGPUCompareFunction_Less
660 }
661 CompareFunction::Equal => {
662 ffi::WGPUCompareFunction_WGPUCompareFunction_Equal
663 }
664 CompareFunction::LessEqual => {
665 ffi::WGPUCompareFunction_WGPUCompareFunction_LessEqual
666 }
667 CompareFunction::Greater => {
668 ffi::WGPUCompareFunction_WGPUCompareFunction_Greater
669 }
670 CompareFunction::NotEqual => {
671 ffi::WGPUCompareFunction_WGPUCompareFunction_NotEqual
672 }
673 CompareFunction::GreaterEqual => {
674 ffi::WGPUCompareFunction_WGPUCompareFunction_GreaterEqual
675 }
676 CompareFunction::Always => {
677 ffi::WGPUCompareFunction_WGPUCompareFunction_Always
678 }
679 }
680 }
681 }
682 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
683 pub enum CompilationInfoRequestStatus {
684 Success,
685 CallbackCancelled,
686 }
687 impl From<ffi::WGPUCompilationInfoRequestStatus> for CompilationInfoRequestStatus {
688 fn from(value: ffi::WGPUCompilationInfoRequestStatus) -> Self {
689 match value {
690 ffi::WGPUCompilationInfoRequestStatus_WGPUCompilationInfoRequestStatus_Success => {
691 CompilationInfoRequestStatus::Success
692 }
693 ffi::WGPUCompilationInfoRequestStatus_WGPUCompilationInfoRequestStatus_CallbackCancelled => {
694 CompilationInfoRequestStatus::CallbackCancelled
695 }
696 _ => CompilationInfoRequestStatus::Success,
697 }
698 }
699 }
700 impl From<CompilationInfoRequestStatus> for ffi::WGPUCompilationInfoRequestStatus {
701 fn from(value: CompilationInfoRequestStatus) -> Self {
702 match value {
703 CompilationInfoRequestStatus::Success => {
704 ffi::WGPUCompilationInfoRequestStatus_WGPUCompilationInfoRequestStatus_Success
705 }
706 CompilationInfoRequestStatus::CallbackCancelled => {
707 ffi::WGPUCompilationInfoRequestStatus_WGPUCompilationInfoRequestStatus_CallbackCancelled
708 }
709 }
710 }
711 }
712 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
713 pub enum CompilationMessageType {
714 Error,
715 Warning,
716 Info,
717 }
718 impl From<ffi::WGPUCompilationMessageType> for CompilationMessageType {
719 fn from(value: ffi::WGPUCompilationMessageType) -> Self {
720 match value {
721 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Error => {
722 CompilationMessageType::Error
723 }
724 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Warning => {
725 CompilationMessageType::Warning
726 }
727 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Info => {
728 CompilationMessageType::Info
729 }
730 _ => CompilationMessageType::Error,
731 }
732 }
733 }
734 impl From<CompilationMessageType> for ffi::WGPUCompilationMessageType {
735 fn from(value: CompilationMessageType) -> Self {
736 match value {
737 CompilationMessageType::Error => {
738 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Error
739 }
740 CompilationMessageType::Warning => {
741 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Warning
742 }
743 CompilationMessageType::Info => {
744 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Info
745 }
746 }
747 }
748 }
749 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
750 pub enum ComponentSwizzle {
751 Undefined,
752 Zero,
753 One,
754 R,
755 G,
756 B,
757 A,
758 }
759 impl From<ffi::WGPUComponentSwizzle> for ComponentSwizzle {
760 fn from(value: ffi::WGPUComponentSwizzle) -> Self {
761 match value {
762 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_Undefined => {
763 ComponentSwizzle::Undefined
764 }
765 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_Zero => {
766 ComponentSwizzle::Zero
767 }
768 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_One => {
769 ComponentSwizzle::One
770 }
771 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_R => ComponentSwizzle::R,
772 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_G => ComponentSwizzle::G,
773 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_B => ComponentSwizzle::B,
774 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_A => ComponentSwizzle::A,
775 _ => ComponentSwizzle::Undefined,
776 }
777 }
778 }
779 impl From<ComponentSwizzle> for ffi::WGPUComponentSwizzle {
780 fn from(value: ComponentSwizzle) -> Self {
781 match value {
782 ComponentSwizzle::Undefined => {
783 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_Undefined
784 }
785 ComponentSwizzle::Zero => {
786 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_Zero
787 }
788 ComponentSwizzle::One => {
789 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_One
790 }
791 ComponentSwizzle::R => ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_R,
792 ComponentSwizzle::G => ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_G,
793 ComponentSwizzle::B => ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_B,
794 ComponentSwizzle::A => ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_A,
795 }
796 }
797 }
798 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
799 pub enum CompositeAlphaMode {
800 Auto,
801 Opaque,
802 Premultiplied,
803 Unpremultiplied,
804 Inherit,
805 }
806 impl From<ffi::WGPUCompositeAlphaMode> for CompositeAlphaMode {
807 fn from(value: ffi::WGPUCompositeAlphaMode) -> Self {
808 match value {
809 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Auto => {
810 CompositeAlphaMode::Auto
811 }
812 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Opaque => {
813 CompositeAlphaMode::Opaque
814 }
815 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Premultiplied => {
816 CompositeAlphaMode::Premultiplied
817 }
818 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Unpremultiplied => {
819 CompositeAlphaMode::Unpremultiplied
820 }
821 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Inherit => {
822 CompositeAlphaMode::Inherit
823 }
824 _ => CompositeAlphaMode::Auto,
825 }
826 }
827 }
828 impl From<CompositeAlphaMode> for ffi::WGPUCompositeAlphaMode {
829 fn from(value: CompositeAlphaMode) -> Self {
830 match value {
831 CompositeAlphaMode::Auto => {
832 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Auto
833 }
834 CompositeAlphaMode::Opaque => {
835 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Opaque
836 }
837 CompositeAlphaMode::Premultiplied => {
838 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Premultiplied
839 }
840 CompositeAlphaMode::Unpremultiplied => {
841 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Unpremultiplied
842 }
843 CompositeAlphaMode::Inherit => {
844 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Inherit
845 }
846 }
847 }
848 }
849 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
850 pub enum CreatePipelineAsyncStatus {
851 Success,
852 CallbackCancelled,
853 ValidationError,
854 InternalError,
855 }
856 impl From<ffi::WGPUCreatePipelineAsyncStatus> for CreatePipelineAsyncStatus {
857 fn from(value: ffi::WGPUCreatePipelineAsyncStatus) -> Self {
858 match value {
859 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_Success => {
860 CreatePipelineAsyncStatus::Success
861 }
862 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_CallbackCancelled => {
863 CreatePipelineAsyncStatus::CallbackCancelled
864 }
865 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_ValidationError => {
866 CreatePipelineAsyncStatus::ValidationError
867 }
868 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_InternalError => {
869 CreatePipelineAsyncStatus::InternalError
870 }
871 _ => CreatePipelineAsyncStatus::Success,
872 }
873 }
874 }
875 impl From<CreatePipelineAsyncStatus> for ffi::WGPUCreatePipelineAsyncStatus {
876 fn from(value: CreatePipelineAsyncStatus) -> Self {
877 match value {
878 CreatePipelineAsyncStatus::Success => {
879 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_Success
880 }
881 CreatePipelineAsyncStatus::CallbackCancelled => {
882 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_CallbackCancelled
883 }
884 CreatePipelineAsyncStatus::ValidationError => {
885 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_ValidationError
886 }
887 CreatePipelineAsyncStatus::InternalError => {
888 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_InternalError
889 }
890 }
891 }
892 }
893 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
894 pub enum CullMode {
895 Undefined,
896 None,
897 Front,
898 Back,
899 }
900 impl From<ffi::WGPUCullMode> for CullMode {
901 fn from(value: ffi::WGPUCullMode) -> Self {
902 match value {
903 ffi::WGPUCullMode_WGPUCullMode_Undefined => CullMode::Undefined,
904 ffi::WGPUCullMode_WGPUCullMode_None => CullMode::None,
905 ffi::WGPUCullMode_WGPUCullMode_Front => CullMode::Front,
906 ffi::WGPUCullMode_WGPUCullMode_Back => CullMode::Back,
907 _ => CullMode::Undefined,
908 }
909 }
910 }
911 impl From<CullMode> for ffi::WGPUCullMode {
912 fn from(value: CullMode) -> Self {
913 match value {
914 CullMode::Undefined => ffi::WGPUCullMode_WGPUCullMode_Undefined,
915 CullMode::None => ffi::WGPUCullMode_WGPUCullMode_None,
916 CullMode::Front => ffi::WGPUCullMode_WGPUCullMode_Front,
917 CullMode::Back => ffi::WGPUCullMode_WGPUCullMode_Back,
918 }
919 }
920 }
921 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
922 pub enum DeviceLostReason {
923 Unknown,
924 Destroyed,
925 CallbackCancelled,
926 FailedCreation,
927 }
928 impl From<ffi::WGPUDeviceLostReason> for DeviceLostReason {
929 fn from(value: ffi::WGPUDeviceLostReason) -> Self {
930 match value {
931 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_Unknown => {
932 DeviceLostReason::Unknown
933 }
934 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_Destroyed => {
935 DeviceLostReason::Destroyed
936 }
937 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_CallbackCancelled => {
938 DeviceLostReason::CallbackCancelled
939 }
940 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_FailedCreation => {
941 DeviceLostReason::FailedCreation
942 }
943 _ => DeviceLostReason::Unknown,
944 }
945 }
946 }
947 impl From<DeviceLostReason> for ffi::WGPUDeviceLostReason {
948 fn from(value: DeviceLostReason) -> Self {
949 match value {
950 DeviceLostReason::Unknown => {
951 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_Unknown
952 }
953 DeviceLostReason::Destroyed => {
954 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_Destroyed
955 }
956 DeviceLostReason::CallbackCancelled => {
957 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_CallbackCancelled
958 }
959 DeviceLostReason::FailedCreation => {
960 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_FailedCreation
961 }
962 }
963 }
964 }
965 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
966 pub enum ErrorFilter {
967 Validation,
968 OutOfMemory,
969 Internal,
970 }
971 impl From<ffi::WGPUErrorFilter> for ErrorFilter {
972 fn from(value: ffi::WGPUErrorFilter) -> Self {
973 match value {
974 ffi::WGPUErrorFilter_WGPUErrorFilter_Validation => {
975 ErrorFilter::Validation
976 }
977 ffi::WGPUErrorFilter_WGPUErrorFilter_OutOfMemory => {
978 ErrorFilter::OutOfMemory
979 }
980 ffi::WGPUErrorFilter_WGPUErrorFilter_Internal => ErrorFilter::Internal,
981 _ => ErrorFilter::Validation,
982 }
983 }
984 }
985 impl From<ErrorFilter> for ffi::WGPUErrorFilter {
986 fn from(value: ErrorFilter) -> Self {
987 match value {
988 ErrorFilter::Validation => {
989 ffi::WGPUErrorFilter_WGPUErrorFilter_Validation
990 }
991 ErrorFilter::OutOfMemory => {
992 ffi::WGPUErrorFilter_WGPUErrorFilter_OutOfMemory
993 }
994 ErrorFilter::Internal => ffi::WGPUErrorFilter_WGPUErrorFilter_Internal,
995 }
996 }
997 }
998 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
999 pub enum ErrorType {
1000 NoError,
1001 Validation,
1002 OutOfMemory,
1003 Internal,
1004 Unknown,
1005 }
1006 impl From<ffi::WGPUErrorType> for ErrorType {
1007 fn from(value: ffi::WGPUErrorType) -> Self {
1008 match value {
1009 ffi::WGPUErrorType_WGPUErrorType_NoError => ErrorType::NoError,
1010 ffi::WGPUErrorType_WGPUErrorType_Validation => ErrorType::Validation,
1011 ffi::WGPUErrorType_WGPUErrorType_OutOfMemory => ErrorType::OutOfMemory,
1012 ffi::WGPUErrorType_WGPUErrorType_Internal => ErrorType::Internal,
1013 ffi::WGPUErrorType_WGPUErrorType_Unknown => ErrorType::Unknown,
1014 _ => ErrorType::NoError,
1015 }
1016 }
1017 }
1018 impl From<ErrorType> for ffi::WGPUErrorType {
1019 fn from(value: ErrorType) -> Self {
1020 match value {
1021 ErrorType::NoError => ffi::WGPUErrorType_WGPUErrorType_NoError,
1022 ErrorType::Validation => ffi::WGPUErrorType_WGPUErrorType_Validation,
1023 ErrorType::OutOfMemory => ffi::WGPUErrorType_WGPUErrorType_OutOfMemory,
1024 ErrorType::Internal => ffi::WGPUErrorType_WGPUErrorType_Internal,
1025 ErrorType::Unknown => ffi::WGPUErrorType_WGPUErrorType_Unknown,
1026 }
1027 }
1028 }
1029 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1030 pub enum ExternalTextureRotation {
1031 Rotate0Degrees,
1032 Rotate90Degrees,
1033 Rotate180Degrees,
1034 Rotate270Degrees,
1035 }
1036 impl From<ffi::WGPUExternalTextureRotation> for ExternalTextureRotation {
1037 fn from(value: ffi::WGPUExternalTextureRotation) -> Self {
1038 match value {
1039 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate0Degrees => {
1040 ExternalTextureRotation::Rotate0Degrees
1041 }
1042 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate90Degrees => {
1043 ExternalTextureRotation::Rotate90Degrees
1044 }
1045 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate180Degrees => {
1046 ExternalTextureRotation::Rotate180Degrees
1047 }
1048 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate270Degrees => {
1049 ExternalTextureRotation::Rotate270Degrees
1050 }
1051 _ => ExternalTextureRotation::Rotate0Degrees,
1052 }
1053 }
1054 }
1055 impl From<ExternalTextureRotation> for ffi::WGPUExternalTextureRotation {
1056 fn from(value: ExternalTextureRotation) -> Self {
1057 match value {
1058 ExternalTextureRotation::Rotate0Degrees => {
1059 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate0Degrees
1060 }
1061 ExternalTextureRotation::Rotate90Degrees => {
1062 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate90Degrees
1063 }
1064 ExternalTextureRotation::Rotate180Degrees => {
1065 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate180Degrees
1066 }
1067 ExternalTextureRotation::Rotate270Degrees => {
1068 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate270Degrees
1069 }
1070 }
1071 }
1072 }
1073 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1074 pub enum FeatureLevel {
1075 Undefined,
1076 Compatibility,
1077 Core,
1078 }
1079 impl From<ffi::WGPUFeatureLevel> for FeatureLevel {
1080 fn from(value: ffi::WGPUFeatureLevel) -> Self {
1081 match value {
1082 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Undefined => {
1083 FeatureLevel::Undefined
1084 }
1085 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Compatibility => {
1086 FeatureLevel::Compatibility
1087 }
1088 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Core => FeatureLevel::Core,
1089 _ => FeatureLevel::Undefined,
1090 }
1091 }
1092 }
1093 impl From<FeatureLevel> for ffi::WGPUFeatureLevel {
1094 fn from(value: FeatureLevel) -> Self {
1095 match value {
1096 FeatureLevel::Undefined => {
1097 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Undefined
1098 }
1099 FeatureLevel::Compatibility => {
1100 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Compatibility
1101 }
1102 FeatureLevel::Core => ffi::WGPUFeatureLevel_WGPUFeatureLevel_Core,
1103 }
1104 }
1105 }
1106 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1107 pub enum FeatureName {
1108 CoreFeaturesAndLimits,
1109 DepthClipControl,
1110 Depth32FloatStencil8,
1111 TextureCompressionBc,
1112 TextureCompressionBcSliced3D,
1113 TextureCompressionEtc2,
1114 TextureCompressionAstc,
1115 TextureCompressionAstcSliced3D,
1116 TimestampQuery,
1117 IndirectFirstInstance,
1118 ShaderF16,
1119 Rg11B10UfloatRenderable,
1120 Bgra8UnormStorage,
1121 Float32Filterable,
1122 Float32Blendable,
1123 ClipDistances,
1124 DualSourceBlending,
1125 Subgroups,
1126 TextureFormatsTier1,
1127 TextureFormatsTier2,
1128 PrimitiveIndex,
1129 TextureComponentSwizzle,
1130 DawnInternalUsages,
1131 DawnMultiPlanarFormats,
1132 DawnNative,
1133 ChromiumExperimentalTimestampQueryInsidePasses,
1134 ImplicitDeviceSynchronization,
1135 TransientAttachments,
1136 MsaaRenderToSingleSampled,
1137 D3D11MultithreadProtected,
1138 AngleTextureSharing,
1139 PixelLocalStorageCoherent,
1140 PixelLocalStorageNonCoherent,
1141 Unorm16TextureFormats,
1142 MultiPlanarFormatExtendedUsages,
1143 MultiPlanarFormatP010,
1144 HostMappedPointer,
1145 MultiPlanarRenderTargets,
1146 MultiPlanarFormatNv12A,
1147 FramebufferFetch,
1148 BufferMapExtendedUsages,
1149 AdapterPropertiesMemoryHeaps,
1150 AdapterPropertiesD3D,
1151 AdapterPropertiesVk,
1152 DawnFormatCapabilities,
1153 DawnDrmFormatCapabilities,
1154 MultiPlanarFormatNv16,
1155 MultiPlanarFormatNv24,
1156 MultiPlanarFormatP210,
1157 MultiPlanarFormatP410,
1158 SharedTextureMemoryVkDedicatedAllocation,
1159 SharedTextureMemoryAHardwareBuffer,
1160 SharedTextureMemoryDmaBuf,
1161 SharedTextureMemoryOpaqueFD,
1162 SharedTextureMemoryZirconHandle,
1163 SharedTextureMemoryDXGISharedHandle,
1164 SharedTextureMemoryD3D11Texture2D,
1165 SharedTextureMemoryIOSurface,
1166 SharedTextureMemoryEGLImage,
1167 SharedFenceVkSemaphoreOpaqueFD,
1168 SharedFenceSyncFD,
1169 SharedFenceVkSemaphoreZirconHandle,
1170 SharedFenceDXGISharedHandle,
1171 SharedFenceMTLSharedEvent,
1172 SharedBufferMemoryD3D12Resource,
1173 StaticSamplers,
1174 YCbCrVulkanSamplers,
1175 ShaderModuleCompilationOptions,
1176 DawnLoadResolveTexture,
1177 DawnPartialLoadResolveTexture,
1178 MultiDrawIndirect,
1179 DawnTexelCopyBufferRowAlignment,
1180 FlexibleTextureViews,
1181 ChromiumExperimentalSubgroupMatrix,
1182 SharedFenceEGLSync,
1183 DawnDeviceAllocatorControl,
1184 AdapterPropertiesWGPU,
1185 SharedBufferMemoryD3D12SharedMemoryFileMappingHandle,
1186 SharedTextureMemoryD3D12Resource,
1187 ChromiumExperimentalSamplingResourceTable,
1188 ChromiumExperimentalSubgroupSizeControl,
1189 AtomicVec2UMinMax,
1190 Unorm16FormatsForExternalTexture,
1191 OpaqueYCbCrAndroidForExternalTexture,
1192 Unorm16Filterable,
1193 }
1194 impl From<ffi::WGPUFeatureName> for FeatureName {
1195 fn from(value: ffi::WGPUFeatureName) -> Self {
1196 match value {
1197 ffi::WGPUFeatureName_WGPUFeatureName_CoreFeaturesAndLimits => {
1198 FeatureName::CoreFeaturesAndLimits
1199 }
1200 ffi::WGPUFeatureName_WGPUFeatureName_DepthClipControl => {
1201 FeatureName::DepthClipControl
1202 }
1203 ffi::WGPUFeatureName_WGPUFeatureName_Depth32FloatStencil8 => {
1204 FeatureName::Depth32FloatStencil8
1205 }
1206 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBC => {
1207 FeatureName::TextureCompressionBc
1208 }
1209 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBCSliced3D => {
1210 FeatureName::TextureCompressionBcSliced3D
1211 }
1212 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionETC2 => {
1213 FeatureName::TextureCompressionEtc2
1214 }
1215 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTC => {
1216 FeatureName::TextureCompressionAstc
1217 }
1218 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTCSliced3D => {
1219 FeatureName::TextureCompressionAstcSliced3D
1220 }
1221 ffi::WGPUFeatureName_WGPUFeatureName_TimestampQuery => {
1222 FeatureName::TimestampQuery
1223 }
1224 ffi::WGPUFeatureName_WGPUFeatureName_IndirectFirstInstance => {
1225 FeatureName::IndirectFirstInstance
1226 }
1227 ffi::WGPUFeatureName_WGPUFeatureName_ShaderF16 => FeatureName::ShaderF16,
1228 ffi::WGPUFeatureName_WGPUFeatureName_RG11B10UfloatRenderable => {
1229 FeatureName::Rg11B10UfloatRenderable
1230 }
1231 ffi::WGPUFeatureName_WGPUFeatureName_BGRA8UnormStorage => {
1232 FeatureName::Bgra8UnormStorage
1233 }
1234 ffi::WGPUFeatureName_WGPUFeatureName_Float32Filterable => {
1235 FeatureName::Float32Filterable
1236 }
1237 ffi::WGPUFeatureName_WGPUFeatureName_Float32Blendable => {
1238 FeatureName::Float32Blendable
1239 }
1240 ffi::WGPUFeatureName_WGPUFeatureName_ClipDistances => {
1241 FeatureName::ClipDistances
1242 }
1243 ffi::WGPUFeatureName_WGPUFeatureName_DualSourceBlending => {
1244 FeatureName::DualSourceBlending
1245 }
1246 ffi::WGPUFeatureName_WGPUFeatureName_Subgroups => FeatureName::Subgroups,
1247 ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier1 => {
1248 FeatureName::TextureFormatsTier1
1249 }
1250 ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier2 => {
1251 FeatureName::TextureFormatsTier2
1252 }
1253 ffi::WGPUFeatureName_WGPUFeatureName_PrimitiveIndex => {
1254 FeatureName::PrimitiveIndex
1255 }
1256 ffi::WGPUFeatureName_WGPUFeatureName_TextureComponentSwizzle => {
1257 FeatureName::TextureComponentSwizzle
1258 }
1259 ffi::WGPUFeatureName_WGPUFeatureName_DawnInternalUsages => {
1260 FeatureName::DawnInternalUsages
1261 }
1262 ffi::WGPUFeatureName_WGPUFeatureName_DawnMultiPlanarFormats => {
1263 FeatureName::DawnMultiPlanarFormats
1264 }
1265 ffi::WGPUFeatureName_WGPUFeatureName_DawnNative => {
1266 FeatureName::DawnNative
1267 }
1268 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalTimestampQueryInsidePasses => {
1269 FeatureName::ChromiumExperimentalTimestampQueryInsidePasses
1270 }
1271 ffi::WGPUFeatureName_WGPUFeatureName_ImplicitDeviceSynchronization => {
1272 FeatureName::ImplicitDeviceSynchronization
1273 }
1274 ffi::WGPUFeatureName_WGPUFeatureName_TransientAttachments => {
1275 FeatureName::TransientAttachments
1276 }
1277 ffi::WGPUFeatureName_WGPUFeatureName_MSAARenderToSingleSampled => {
1278 FeatureName::MsaaRenderToSingleSampled
1279 }
1280 ffi::WGPUFeatureName_WGPUFeatureName_D3D11MultithreadProtected => {
1281 FeatureName::D3D11MultithreadProtected
1282 }
1283 ffi::WGPUFeatureName_WGPUFeatureName_ANGLETextureSharing => {
1284 FeatureName::AngleTextureSharing
1285 }
1286 ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageCoherent => {
1287 FeatureName::PixelLocalStorageCoherent
1288 }
1289 ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageNonCoherent => {
1290 FeatureName::PixelLocalStorageNonCoherent
1291 }
1292 ffi::WGPUFeatureName_WGPUFeatureName_Unorm16TextureFormats => {
1293 FeatureName::Unorm16TextureFormats
1294 }
1295 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatExtendedUsages => {
1296 FeatureName::MultiPlanarFormatExtendedUsages
1297 }
1298 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP010 => {
1299 FeatureName::MultiPlanarFormatP010
1300 }
1301 ffi::WGPUFeatureName_WGPUFeatureName_HostMappedPointer => {
1302 FeatureName::HostMappedPointer
1303 }
1304 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarRenderTargets => {
1305 FeatureName::MultiPlanarRenderTargets
1306 }
1307 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv12a => {
1308 FeatureName::MultiPlanarFormatNv12A
1309 }
1310 ffi::WGPUFeatureName_WGPUFeatureName_FramebufferFetch => {
1311 FeatureName::FramebufferFetch
1312 }
1313 ffi::WGPUFeatureName_WGPUFeatureName_BufferMapExtendedUsages => {
1314 FeatureName::BufferMapExtendedUsages
1315 }
1316 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesMemoryHeaps => {
1317 FeatureName::AdapterPropertiesMemoryHeaps
1318 }
1319 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesD3D => {
1320 FeatureName::AdapterPropertiesD3D
1321 }
1322 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesVk => {
1323 FeatureName::AdapterPropertiesVk
1324 }
1325 ffi::WGPUFeatureName_WGPUFeatureName_DawnFormatCapabilities => {
1326 FeatureName::DawnFormatCapabilities
1327 }
1328 ffi::WGPUFeatureName_WGPUFeatureName_DawnDrmFormatCapabilities => {
1329 FeatureName::DawnDrmFormatCapabilities
1330 }
1331 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv16 => {
1332 FeatureName::MultiPlanarFormatNv16
1333 }
1334 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv24 => {
1335 FeatureName::MultiPlanarFormatNv24
1336 }
1337 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP210 => {
1338 FeatureName::MultiPlanarFormatP210
1339 }
1340 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP410 => {
1341 FeatureName::MultiPlanarFormatP410
1342 }
1343 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryVkDedicatedAllocation => {
1344 FeatureName::SharedTextureMemoryVkDedicatedAllocation
1345 }
1346 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryAHardwareBuffer => {
1347 FeatureName::SharedTextureMemoryAHardwareBuffer
1348 }
1349 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDmaBuf => {
1350 FeatureName::SharedTextureMemoryDmaBuf
1351 }
1352 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryOpaqueFD => {
1353 FeatureName::SharedTextureMemoryOpaqueFD
1354 }
1355 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryZirconHandle => {
1356 FeatureName::SharedTextureMemoryZirconHandle
1357 }
1358 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDXGISharedHandle => {
1359 FeatureName::SharedTextureMemoryDXGISharedHandle
1360 }
1361 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D11Texture2D => {
1362 FeatureName::SharedTextureMemoryD3D11Texture2D
1363 }
1364 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryIOSurface => {
1365 FeatureName::SharedTextureMemoryIOSurface
1366 }
1367 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryEGLImage => {
1368 FeatureName::SharedTextureMemoryEGLImage
1369 }
1370 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreOpaqueFD => {
1371 FeatureName::SharedFenceVkSemaphoreOpaqueFD
1372 }
1373 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceSyncFD => {
1374 FeatureName::SharedFenceSyncFD
1375 }
1376 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreZirconHandle => {
1377 FeatureName::SharedFenceVkSemaphoreZirconHandle
1378 }
1379 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceDXGISharedHandle => {
1380 FeatureName::SharedFenceDXGISharedHandle
1381 }
1382 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceMTLSharedEvent => {
1383 FeatureName::SharedFenceMTLSharedEvent
1384 }
1385 ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12Resource => {
1386 FeatureName::SharedBufferMemoryD3D12Resource
1387 }
1388 ffi::WGPUFeatureName_WGPUFeatureName_StaticSamplers => {
1389 FeatureName::StaticSamplers
1390 }
1391 ffi::WGPUFeatureName_WGPUFeatureName_YCbCrVulkanSamplers => {
1392 FeatureName::YCbCrVulkanSamplers
1393 }
1394 ffi::WGPUFeatureName_WGPUFeatureName_ShaderModuleCompilationOptions => {
1395 FeatureName::ShaderModuleCompilationOptions
1396 }
1397 ffi::WGPUFeatureName_WGPUFeatureName_DawnLoadResolveTexture => {
1398 FeatureName::DawnLoadResolveTexture
1399 }
1400 ffi::WGPUFeatureName_WGPUFeatureName_DawnPartialLoadResolveTexture => {
1401 FeatureName::DawnPartialLoadResolveTexture
1402 }
1403 ffi::WGPUFeatureName_WGPUFeatureName_MultiDrawIndirect => {
1404 FeatureName::MultiDrawIndirect
1405 }
1406 ffi::WGPUFeatureName_WGPUFeatureName_DawnTexelCopyBufferRowAlignment => {
1407 FeatureName::DawnTexelCopyBufferRowAlignment
1408 }
1409 ffi::WGPUFeatureName_WGPUFeatureName_FlexibleTextureViews => {
1410 FeatureName::FlexibleTextureViews
1411 }
1412 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupMatrix => {
1413 FeatureName::ChromiumExperimentalSubgroupMatrix
1414 }
1415 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceEGLSync => {
1416 FeatureName::SharedFenceEGLSync
1417 }
1418 ffi::WGPUFeatureName_WGPUFeatureName_DawnDeviceAllocatorControl => {
1419 FeatureName::DawnDeviceAllocatorControl
1420 }
1421 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesWGPU => {
1422 FeatureName::AdapterPropertiesWGPU
1423 }
1424 ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12SharedMemoryFileMappingHandle => {
1425 FeatureName::SharedBufferMemoryD3D12SharedMemoryFileMappingHandle
1426 }
1427 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D12Resource => {
1428 FeatureName::SharedTextureMemoryD3D12Resource
1429 }
1430 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSamplingResourceTable => {
1431 FeatureName::ChromiumExperimentalSamplingResourceTable
1432 }
1433 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupSizeControl => {
1434 FeatureName::ChromiumExperimentalSubgroupSizeControl
1435 }
1436 ffi::WGPUFeatureName_WGPUFeatureName_AtomicVec2uMinMax => {
1437 FeatureName::AtomicVec2UMinMax
1438 }
1439 ffi::WGPUFeatureName_WGPUFeatureName_Unorm16FormatsForExternalTexture => {
1440 FeatureName::Unorm16FormatsForExternalTexture
1441 }
1442 ffi::WGPUFeatureName_WGPUFeatureName_OpaqueYCbCrAndroidForExternalTexture => {
1443 FeatureName::OpaqueYCbCrAndroidForExternalTexture
1444 }
1445 ffi::WGPUFeatureName_WGPUFeatureName_Unorm16Filterable => {
1446 FeatureName::Unorm16Filterable
1447 }
1448 _ => FeatureName::CoreFeaturesAndLimits,
1449 }
1450 }
1451 }
1452 impl From<FeatureName> for ffi::WGPUFeatureName {
1453 fn from(value: FeatureName) -> Self {
1454 match value {
1455 FeatureName::CoreFeaturesAndLimits => {
1456 ffi::WGPUFeatureName_WGPUFeatureName_CoreFeaturesAndLimits
1457 }
1458 FeatureName::DepthClipControl => {
1459 ffi::WGPUFeatureName_WGPUFeatureName_DepthClipControl
1460 }
1461 FeatureName::Depth32FloatStencil8 => {
1462 ffi::WGPUFeatureName_WGPUFeatureName_Depth32FloatStencil8
1463 }
1464 FeatureName::TextureCompressionBc => {
1465 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBC
1466 }
1467 FeatureName::TextureCompressionBcSliced3D => {
1468 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBCSliced3D
1469 }
1470 FeatureName::TextureCompressionEtc2 => {
1471 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionETC2
1472 }
1473 FeatureName::TextureCompressionAstc => {
1474 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTC
1475 }
1476 FeatureName::TextureCompressionAstcSliced3D => {
1477 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTCSliced3D
1478 }
1479 FeatureName::TimestampQuery => {
1480 ffi::WGPUFeatureName_WGPUFeatureName_TimestampQuery
1481 }
1482 FeatureName::IndirectFirstInstance => {
1483 ffi::WGPUFeatureName_WGPUFeatureName_IndirectFirstInstance
1484 }
1485 FeatureName::ShaderF16 => ffi::WGPUFeatureName_WGPUFeatureName_ShaderF16,
1486 FeatureName::Rg11B10UfloatRenderable => {
1487 ffi::WGPUFeatureName_WGPUFeatureName_RG11B10UfloatRenderable
1488 }
1489 FeatureName::Bgra8UnormStorage => {
1490 ffi::WGPUFeatureName_WGPUFeatureName_BGRA8UnormStorage
1491 }
1492 FeatureName::Float32Filterable => {
1493 ffi::WGPUFeatureName_WGPUFeatureName_Float32Filterable
1494 }
1495 FeatureName::Float32Blendable => {
1496 ffi::WGPUFeatureName_WGPUFeatureName_Float32Blendable
1497 }
1498 FeatureName::ClipDistances => {
1499 ffi::WGPUFeatureName_WGPUFeatureName_ClipDistances
1500 }
1501 FeatureName::DualSourceBlending => {
1502 ffi::WGPUFeatureName_WGPUFeatureName_DualSourceBlending
1503 }
1504 FeatureName::Subgroups => ffi::WGPUFeatureName_WGPUFeatureName_Subgroups,
1505 FeatureName::TextureFormatsTier1 => {
1506 ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier1
1507 }
1508 FeatureName::TextureFormatsTier2 => {
1509 ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier2
1510 }
1511 FeatureName::PrimitiveIndex => {
1512 ffi::WGPUFeatureName_WGPUFeatureName_PrimitiveIndex
1513 }
1514 FeatureName::TextureComponentSwizzle => {
1515 ffi::WGPUFeatureName_WGPUFeatureName_TextureComponentSwizzle
1516 }
1517 FeatureName::DawnInternalUsages => {
1518 ffi::WGPUFeatureName_WGPUFeatureName_DawnInternalUsages
1519 }
1520 FeatureName::DawnMultiPlanarFormats => {
1521 ffi::WGPUFeatureName_WGPUFeatureName_DawnMultiPlanarFormats
1522 }
1523 FeatureName::DawnNative => {
1524 ffi::WGPUFeatureName_WGPUFeatureName_DawnNative
1525 }
1526 FeatureName::ChromiumExperimentalTimestampQueryInsidePasses => {
1527 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalTimestampQueryInsidePasses
1528 }
1529 FeatureName::ImplicitDeviceSynchronization => {
1530 ffi::WGPUFeatureName_WGPUFeatureName_ImplicitDeviceSynchronization
1531 }
1532 FeatureName::TransientAttachments => {
1533 ffi::WGPUFeatureName_WGPUFeatureName_TransientAttachments
1534 }
1535 FeatureName::MsaaRenderToSingleSampled => {
1536 ffi::WGPUFeatureName_WGPUFeatureName_MSAARenderToSingleSampled
1537 }
1538 FeatureName::D3D11MultithreadProtected => {
1539 ffi::WGPUFeatureName_WGPUFeatureName_D3D11MultithreadProtected
1540 }
1541 FeatureName::AngleTextureSharing => {
1542 ffi::WGPUFeatureName_WGPUFeatureName_ANGLETextureSharing
1543 }
1544 FeatureName::PixelLocalStorageCoherent => {
1545 ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageCoherent
1546 }
1547 FeatureName::PixelLocalStorageNonCoherent => {
1548 ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageNonCoherent
1549 }
1550 FeatureName::Unorm16TextureFormats => {
1551 ffi::WGPUFeatureName_WGPUFeatureName_Unorm16TextureFormats
1552 }
1553 FeatureName::MultiPlanarFormatExtendedUsages => {
1554 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatExtendedUsages
1555 }
1556 FeatureName::MultiPlanarFormatP010 => {
1557 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP010
1558 }
1559 FeatureName::HostMappedPointer => {
1560 ffi::WGPUFeatureName_WGPUFeatureName_HostMappedPointer
1561 }
1562 FeatureName::MultiPlanarRenderTargets => {
1563 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarRenderTargets
1564 }
1565 FeatureName::MultiPlanarFormatNv12A => {
1566 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv12a
1567 }
1568 FeatureName::FramebufferFetch => {
1569 ffi::WGPUFeatureName_WGPUFeatureName_FramebufferFetch
1570 }
1571 FeatureName::BufferMapExtendedUsages => {
1572 ffi::WGPUFeatureName_WGPUFeatureName_BufferMapExtendedUsages
1573 }
1574 FeatureName::AdapterPropertiesMemoryHeaps => {
1575 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesMemoryHeaps
1576 }
1577 FeatureName::AdapterPropertiesD3D => {
1578 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesD3D
1579 }
1580 FeatureName::AdapterPropertiesVk => {
1581 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesVk
1582 }
1583 FeatureName::DawnFormatCapabilities => {
1584 ffi::WGPUFeatureName_WGPUFeatureName_DawnFormatCapabilities
1585 }
1586 FeatureName::DawnDrmFormatCapabilities => {
1587 ffi::WGPUFeatureName_WGPUFeatureName_DawnDrmFormatCapabilities
1588 }
1589 FeatureName::MultiPlanarFormatNv16 => {
1590 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv16
1591 }
1592 FeatureName::MultiPlanarFormatNv24 => {
1593 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv24
1594 }
1595 FeatureName::MultiPlanarFormatP210 => {
1596 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP210
1597 }
1598 FeatureName::MultiPlanarFormatP410 => {
1599 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP410
1600 }
1601 FeatureName::SharedTextureMemoryVkDedicatedAllocation => {
1602 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryVkDedicatedAllocation
1603 }
1604 FeatureName::SharedTextureMemoryAHardwareBuffer => {
1605 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryAHardwareBuffer
1606 }
1607 FeatureName::SharedTextureMemoryDmaBuf => {
1608 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDmaBuf
1609 }
1610 FeatureName::SharedTextureMemoryOpaqueFD => {
1611 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryOpaqueFD
1612 }
1613 FeatureName::SharedTextureMemoryZirconHandle => {
1614 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryZirconHandle
1615 }
1616 FeatureName::SharedTextureMemoryDXGISharedHandle => {
1617 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDXGISharedHandle
1618 }
1619 FeatureName::SharedTextureMemoryD3D11Texture2D => {
1620 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D11Texture2D
1621 }
1622 FeatureName::SharedTextureMemoryIOSurface => {
1623 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryIOSurface
1624 }
1625 FeatureName::SharedTextureMemoryEGLImage => {
1626 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryEGLImage
1627 }
1628 FeatureName::SharedFenceVkSemaphoreOpaqueFD => {
1629 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreOpaqueFD
1630 }
1631 FeatureName::SharedFenceSyncFD => {
1632 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceSyncFD
1633 }
1634 FeatureName::SharedFenceVkSemaphoreZirconHandle => {
1635 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreZirconHandle
1636 }
1637 FeatureName::SharedFenceDXGISharedHandle => {
1638 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceDXGISharedHandle
1639 }
1640 FeatureName::SharedFenceMTLSharedEvent => {
1641 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceMTLSharedEvent
1642 }
1643 FeatureName::SharedBufferMemoryD3D12Resource => {
1644 ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12Resource
1645 }
1646 FeatureName::StaticSamplers => {
1647 ffi::WGPUFeatureName_WGPUFeatureName_StaticSamplers
1648 }
1649 FeatureName::YCbCrVulkanSamplers => {
1650 ffi::WGPUFeatureName_WGPUFeatureName_YCbCrVulkanSamplers
1651 }
1652 FeatureName::ShaderModuleCompilationOptions => {
1653 ffi::WGPUFeatureName_WGPUFeatureName_ShaderModuleCompilationOptions
1654 }
1655 FeatureName::DawnLoadResolveTexture => {
1656 ffi::WGPUFeatureName_WGPUFeatureName_DawnLoadResolveTexture
1657 }
1658 FeatureName::DawnPartialLoadResolveTexture => {
1659 ffi::WGPUFeatureName_WGPUFeatureName_DawnPartialLoadResolveTexture
1660 }
1661 FeatureName::MultiDrawIndirect => {
1662 ffi::WGPUFeatureName_WGPUFeatureName_MultiDrawIndirect
1663 }
1664 FeatureName::DawnTexelCopyBufferRowAlignment => {
1665 ffi::WGPUFeatureName_WGPUFeatureName_DawnTexelCopyBufferRowAlignment
1666 }
1667 FeatureName::FlexibleTextureViews => {
1668 ffi::WGPUFeatureName_WGPUFeatureName_FlexibleTextureViews
1669 }
1670 FeatureName::ChromiumExperimentalSubgroupMatrix => {
1671 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupMatrix
1672 }
1673 FeatureName::SharedFenceEGLSync => {
1674 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceEGLSync
1675 }
1676 FeatureName::DawnDeviceAllocatorControl => {
1677 ffi::WGPUFeatureName_WGPUFeatureName_DawnDeviceAllocatorControl
1678 }
1679 FeatureName::AdapterPropertiesWGPU => {
1680 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesWGPU
1681 }
1682 FeatureName::SharedBufferMemoryD3D12SharedMemoryFileMappingHandle => {
1683 ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12SharedMemoryFileMappingHandle
1684 }
1685 FeatureName::SharedTextureMemoryD3D12Resource => {
1686 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D12Resource
1687 }
1688 FeatureName::ChromiumExperimentalSamplingResourceTable => {
1689 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSamplingResourceTable
1690 }
1691 FeatureName::ChromiumExperimentalSubgroupSizeControl => {
1692 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupSizeControl
1693 }
1694 FeatureName::AtomicVec2UMinMax => {
1695 ffi::WGPUFeatureName_WGPUFeatureName_AtomicVec2uMinMax
1696 }
1697 FeatureName::Unorm16FormatsForExternalTexture => {
1698 ffi::WGPUFeatureName_WGPUFeatureName_Unorm16FormatsForExternalTexture
1699 }
1700 FeatureName::OpaqueYCbCrAndroidForExternalTexture => {
1701 ffi::WGPUFeatureName_WGPUFeatureName_OpaqueYCbCrAndroidForExternalTexture
1702 }
1703 FeatureName::Unorm16Filterable => {
1704 ffi::WGPUFeatureName_WGPUFeatureName_Unorm16Filterable
1705 }
1706 }
1707 }
1708 }
1709 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1710 pub enum FilterMode {
1711 Undefined,
1712 Nearest,
1713 Linear,
1714 }
1715 impl From<ffi::WGPUFilterMode> for FilterMode {
1716 fn from(value: ffi::WGPUFilterMode) -> Self {
1717 match value {
1718 ffi::WGPUFilterMode_WGPUFilterMode_Undefined => FilterMode::Undefined,
1719 ffi::WGPUFilterMode_WGPUFilterMode_Nearest => FilterMode::Nearest,
1720 ffi::WGPUFilterMode_WGPUFilterMode_Linear => FilterMode::Linear,
1721 _ => FilterMode::Undefined,
1722 }
1723 }
1724 }
1725 impl From<FilterMode> for ffi::WGPUFilterMode {
1726 fn from(value: FilterMode) -> Self {
1727 match value {
1728 FilterMode::Undefined => ffi::WGPUFilterMode_WGPUFilterMode_Undefined,
1729 FilterMode::Nearest => ffi::WGPUFilterMode_WGPUFilterMode_Nearest,
1730 FilterMode::Linear => ffi::WGPUFilterMode_WGPUFilterMode_Linear,
1731 }
1732 }
1733 }
1734 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1735 pub enum FrontFace {
1736 Undefined,
1737 Ccw,
1738 Cw,
1739 }
1740 impl From<ffi::WGPUFrontFace> for FrontFace {
1741 fn from(value: ffi::WGPUFrontFace) -> Self {
1742 match value {
1743 ffi::WGPUFrontFace_WGPUFrontFace_Undefined => FrontFace::Undefined,
1744 ffi::WGPUFrontFace_WGPUFrontFace_CCW => FrontFace::Ccw,
1745 ffi::WGPUFrontFace_WGPUFrontFace_CW => FrontFace::Cw,
1746 _ => FrontFace::Undefined,
1747 }
1748 }
1749 }
1750 impl From<FrontFace> for ffi::WGPUFrontFace {
1751 fn from(value: FrontFace) -> Self {
1752 match value {
1753 FrontFace::Undefined => ffi::WGPUFrontFace_WGPUFrontFace_Undefined,
1754 FrontFace::Ccw => ffi::WGPUFrontFace_WGPUFrontFace_CCW,
1755 FrontFace::Cw => ffi::WGPUFrontFace_WGPUFrontFace_CW,
1756 }
1757 }
1758 }
1759 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1760 pub enum IndexFormat {
1761 Undefined,
1762 Uint16,
1763 Uint32,
1764 }
1765 impl From<ffi::WGPUIndexFormat> for IndexFormat {
1766 fn from(value: ffi::WGPUIndexFormat) -> Self {
1767 match value {
1768 ffi::WGPUIndexFormat_WGPUIndexFormat_Undefined => IndexFormat::Undefined,
1769 ffi::WGPUIndexFormat_WGPUIndexFormat_Uint16 => IndexFormat::Uint16,
1770 ffi::WGPUIndexFormat_WGPUIndexFormat_Uint32 => IndexFormat::Uint32,
1771 _ => IndexFormat::Undefined,
1772 }
1773 }
1774 }
1775 impl From<IndexFormat> for ffi::WGPUIndexFormat {
1776 fn from(value: IndexFormat) -> Self {
1777 match value {
1778 IndexFormat::Undefined => ffi::WGPUIndexFormat_WGPUIndexFormat_Undefined,
1779 IndexFormat::Uint16 => ffi::WGPUIndexFormat_WGPUIndexFormat_Uint16,
1780 IndexFormat::Uint32 => ffi::WGPUIndexFormat_WGPUIndexFormat_Uint32,
1781 }
1782 }
1783 }
1784 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1785 pub enum InstanceFeatureName {
1786 TimedWaitAny,
1787 ShaderSourceSPIRV,
1788 MultipleDevicesPerAdapter,
1789 }
1790 impl From<ffi::WGPUInstanceFeatureName> for InstanceFeatureName {
1791 fn from(value: ffi::WGPUInstanceFeatureName) -> Self {
1792 match value {
1793 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_TimedWaitAny => {
1794 InstanceFeatureName::TimedWaitAny
1795 }
1796 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_ShaderSourceSPIRV => {
1797 InstanceFeatureName::ShaderSourceSPIRV
1798 }
1799 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_MultipleDevicesPerAdapter => {
1800 InstanceFeatureName::MultipleDevicesPerAdapter
1801 }
1802 _ => InstanceFeatureName::TimedWaitAny,
1803 }
1804 }
1805 }
1806 impl From<InstanceFeatureName> for ffi::WGPUInstanceFeatureName {
1807 fn from(value: InstanceFeatureName) -> Self {
1808 match value {
1809 InstanceFeatureName::TimedWaitAny => {
1810 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_TimedWaitAny
1811 }
1812 InstanceFeatureName::ShaderSourceSPIRV => {
1813 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_ShaderSourceSPIRV
1814 }
1815 InstanceFeatureName::MultipleDevicesPerAdapter => {
1816 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_MultipleDevicesPerAdapter
1817 }
1818 }
1819 }
1820 }
1821 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1822 pub enum LoadOp {
1823 Undefined,
1824 Load,
1825 Clear,
1826 ExpandResolveTexture,
1827 }
1828 impl From<ffi::WGPULoadOp> for LoadOp {
1829 fn from(value: ffi::WGPULoadOp) -> Self {
1830 match value {
1831 ffi::WGPULoadOp_WGPULoadOp_Undefined => LoadOp::Undefined,
1832 ffi::WGPULoadOp_WGPULoadOp_Load => LoadOp::Load,
1833 ffi::WGPULoadOp_WGPULoadOp_Clear => LoadOp::Clear,
1834 ffi::WGPULoadOp_WGPULoadOp_ExpandResolveTexture => {
1835 LoadOp::ExpandResolveTexture
1836 }
1837 _ => LoadOp::Undefined,
1838 }
1839 }
1840 }
1841 impl From<LoadOp> for ffi::WGPULoadOp {
1842 fn from(value: LoadOp) -> Self {
1843 match value {
1844 LoadOp::Undefined => ffi::WGPULoadOp_WGPULoadOp_Undefined,
1845 LoadOp::Load => ffi::WGPULoadOp_WGPULoadOp_Load,
1846 LoadOp::Clear => ffi::WGPULoadOp_WGPULoadOp_Clear,
1847 LoadOp::ExpandResolveTexture => {
1848 ffi::WGPULoadOp_WGPULoadOp_ExpandResolveTexture
1849 }
1850 }
1851 }
1852 }
1853 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1854 pub enum LoggingType {
1855 Verbose,
1856 Info,
1857 Warning,
1858 Error,
1859 }
1860 impl From<ffi::WGPULoggingType> for LoggingType {
1861 fn from(value: ffi::WGPULoggingType) -> Self {
1862 match value {
1863 ffi::WGPULoggingType_WGPULoggingType_Verbose => LoggingType::Verbose,
1864 ffi::WGPULoggingType_WGPULoggingType_Info => LoggingType::Info,
1865 ffi::WGPULoggingType_WGPULoggingType_Warning => LoggingType::Warning,
1866 ffi::WGPULoggingType_WGPULoggingType_Error => LoggingType::Error,
1867 _ => LoggingType::Verbose,
1868 }
1869 }
1870 }
1871 impl From<LoggingType> for ffi::WGPULoggingType {
1872 fn from(value: LoggingType) -> Self {
1873 match value {
1874 LoggingType::Verbose => ffi::WGPULoggingType_WGPULoggingType_Verbose,
1875 LoggingType::Info => ffi::WGPULoggingType_WGPULoggingType_Info,
1876 LoggingType::Warning => ffi::WGPULoggingType_WGPULoggingType_Warning,
1877 LoggingType::Error => ffi::WGPULoggingType_WGPULoggingType_Error,
1878 }
1879 }
1880 }
1881 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1882 pub enum MapAsyncStatus {
1883 Success,
1884 CallbackCancelled,
1885 Error,
1886 Aborted,
1887 }
1888 impl From<ffi::WGPUMapAsyncStatus> for MapAsyncStatus {
1889 fn from(value: ffi::WGPUMapAsyncStatus) -> Self {
1890 match value {
1891 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Success => {
1892 MapAsyncStatus::Success
1893 }
1894 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_CallbackCancelled => {
1895 MapAsyncStatus::CallbackCancelled
1896 }
1897 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Error => MapAsyncStatus::Error,
1898 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Aborted => {
1899 MapAsyncStatus::Aborted
1900 }
1901 _ => MapAsyncStatus::Success,
1902 }
1903 }
1904 }
1905 impl From<MapAsyncStatus> for ffi::WGPUMapAsyncStatus {
1906 fn from(value: MapAsyncStatus) -> Self {
1907 match value {
1908 MapAsyncStatus::Success => {
1909 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Success
1910 }
1911 MapAsyncStatus::CallbackCancelled => {
1912 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_CallbackCancelled
1913 }
1914 MapAsyncStatus::Error => ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Error,
1915 MapAsyncStatus::Aborted => {
1916 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Aborted
1917 }
1918 }
1919 }
1920 }
1921 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1922 pub enum MipmapFilterMode {
1923 Undefined,
1924 Nearest,
1925 Linear,
1926 }
1927 impl From<ffi::WGPUMipmapFilterMode> for MipmapFilterMode {
1928 fn from(value: ffi::WGPUMipmapFilterMode) -> Self {
1929 match value {
1930 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Undefined => {
1931 MipmapFilterMode::Undefined
1932 }
1933 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Nearest => {
1934 MipmapFilterMode::Nearest
1935 }
1936 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Linear => {
1937 MipmapFilterMode::Linear
1938 }
1939 _ => MipmapFilterMode::Undefined,
1940 }
1941 }
1942 }
1943 impl From<MipmapFilterMode> for ffi::WGPUMipmapFilterMode {
1944 fn from(value: MipmapFilterMode) -> Self {
1945 match value {
1946 MipmapFilterMode::Undefined => {
1947 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Undefined
1948 }
1949 MipmapFilterMode::Nearest => {
1950 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Nearest
1951 }
1952 MipmapFilterMode::Linear => {
1953 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Linear
1954 }
1955 }
1956 }
1957 }
1958 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1959 pub enum OptionalBool {
1960 False,
1961 True,
1962 Undefined,
1963 }
1964 impl From<ffi::WGPUOptionalBool> for OptionalBool {
1965 fn from(value: ffi::WGPUOptionalBool) -> Self {
1966 match value {
1967 ffi::WGPUOptionalBool_WGPUOptionalBool_False => OptionalBool::False,
1968 ffi::WGPUOptionalBool_WGPUOptionalBool_True => OptionalBool::True,
1969 ffi::WGPUOptionalBool_WGPUOptionalBool_Undefined => {
1970 OptionalBool::Undefined
1971 }
1972 _ => OptionalBool::False,
1973 }
1974 }
1975 }
1976 impl From<OptionalBool> for ffi::WGPUOptionalBool {
1977 fn from(value: OptionalBool) -> Self {
1978 match value {
1979 OptionalBool::False => ffi::WGPUOptionalBool_WGPUOptionalBool_False,
1980 OptionalBool::True => ffi::WGPUOptionalBool_WGPUOptionalBool_True,
1981 OptionalBool::Undefined => {
1982 ffi::WGPUOptionalBool_WGPUOptionalBool_Undefined
1983 }
1984 }
1985 }
1986 }
1987 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1988 pub enum PopErrorScopeStatus {
1989 Success,
1990 CallbackCancelled,
1991 Error,
1992 }
1993 impl From<ffi::WGPUPopErrorScopeStatus> for PopErrorScopeStatus {
1994 fn from(value: ffi::WGPUPopErrorScopeStatus) -> Self {
1995 match value {
1996 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Success => {
1997 PopErrorScopeStatus::Success
1998 }
1999 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_CallbackCancelled => {
2000 PopErrorScopeStatus::CallbackCancelled
2001 }
2002 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Error => {
2003 PopErrorScopeStatus::Error
2004 }
2005 _ => PopErrorScopeStatus::Success,
2006 }
2007 }
2008 }
2009 impl From<PopErrorScopeStatus> for ffi::WGPUPopErrorScopeStatus {
2010 fn from(value: PopErrorScopeStatus) -> Self {
2011 match value {
2012 PopErrorScopeStatus::Success => {
2013 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Success
2014 }
2015 PopErrorScopeStatus::CallbackCancelled => {
2016 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_CallbackCancelled
2017 }
2018 PopErrorScopeStatus::Error => {
2019 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Error
2020 }
2021 }
2022 }
2023 }
2024 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2025 pub enum PowerPreference {
2026 Undefined,
2027 LowPower,
2028 HighPerformance,
2029 }
2030 impl From<ffi::WGPUPowerPreference> for PowerPreference {
2031 fn from(value: ffi::WGPUPowerPreference) -> Self {
2032 match value {
2033 ffi::WGPUPowerPreference_WGPUPowerPreference_Undefined => {
2034 PowerPreference::Undefined
2035 }
2036 ffi::WGPUPowerPreference_WGPUPowerPreference_LowPower => {
2037 PowerPreference::LowPower
2038 }
2039 ffi::WGPUPowerPreference_WGPUPowerPreference_HighPerformance => {
2040 PowerPreference::HighPerformance
2041 }
2042 _ => PowerPreference::Undefined,
2043 }
2044 }
2045 }
2046 impl From<PowerPreference> for ffi::WGPUPowerPreference {
2047 fn from(value: PowerPreference) -> Self {
2048 match value {
2049 PowerPreference::Undefined => {
2050 ffi::WGPUPowerPreference_WGPUPowerPreference_Undefined
2051 }
2052 PowerPreference::LowPower => {
2053 ffi::WGPUPowerPreference_WGPUPowerPreference_LowPower
2054 }
2055 PowerPreference::HighPerformance => {
2056 ffi::WGPUPowerPreference_WGPUPowerPreference_HighPerformance
2057 }
2058 }
2059 }
2060 }
2061 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2062 pub enum PredefinedColorSpace {
2063 SRgb,
2064 DisplayP3,
2065 }
2066 impl From<ffi::WGPUPredefinedColorSpace> for PredefinedColorSpace {
2067 fn from(value: ffi::WGPUPredefinedColorSpace) -> Self {
2068 match value {
2069 ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_SRGB => {
2070 PredefinedColorSpace::SRgb
2071 }
2072 ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_DisplayP3 => {
2073 PredefinedColorSpace::DisplayP3
2074 }
2075 _ => PredefinedColorSpace::SRgb,
2076 }
2077 }
2078 }
2079 impl From<PredefinedColorSpace> for ffi::WGPUPredefinedColorSpace {
2080 fn from(value: PredefinedColorSpace) -> Self {
2081 match value {
2082 PredefinedColorSpace::SRgb => {
2083 ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_SRGB
2084 }
2085 PredefinedColorSpace::DisplayP3 => {
2086 ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_DisplayP3
2087 }
2088 }
2089 }
2090 }
2091 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2092 pub enum PresentMode {
2093 Undefined,
2094 Fifo,
2095 FifoRelaxed,
2096 Immediate,
2097 Mailbox,
2098 }
2099 impl From<ffi::WGPUPresentMode> for PresentMode {
2100 fn from(value: ffi::WGPUPresentMode) -> Self {
2101 match value {
2102 ffi::WGPUPresentMode_WGPUPresentMode_Undefined => PresentMode::Undefined,
2103 ffi::WGPUPresentMode_WGPUPresentMode_Fifo => PresentMode::Fifo,
2104 ffi::WGPUPresentMode_WGPUPresentMode_FifoRelaxed => {
2105 PresentMode::FifoRelaxed
2106 }
2107 ffi::WGPUPresentMode_WGPUPresentMode_Immediate => PresentMode::Immediate,
2108 ffi::WGPUPresentMode_WGPUPresentMode_Mailbox => PresentMode::Mailbox,
2109 _ => PresentMode::Undefined,
2110 }
2111 }
2112 }
2113 impl From<PresentMode> for ffi::WGPUPresentMode {
2114 fn from(value: PresentMode) -> Self {
2115 match value {
2116 PresentMode::Undefined => ffi::WGPUPresentMode_WGPUPresentMode_Undefined,
2117 PresentMode::Fifo => ffi::WGPUPresentMode_WGPUPresentMode_Fifo,
2118 PresentMode::FifoRelaxed => {
2119 ffi::WGPUPresentMode_WGPUPresentMode_FifoRelaxed
2120 }
2121 PresentMode::Immediate => ffi::WGPUPresentMode_WGPUPresentMode_Immediate,
2122 PresentMode::Mailbox => ffi::WGPUPresentMode_WGPUPresentMode_Mailbox,
2123 }
2124 }
2125 }
2126 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2127 pub enum PrimitiveTopology {
2128 Undefined,
2129 PointList,
2130 LineList,
2131 LineStrip,
2132 TriangleList,
2133 TriangleStrip,
2134 }
2135 impl From<ffi::WGPUPrimitiveTopology> for PrimitiveTopology {
2136 fn from(value: ffi::WGPUPrimitiveTopology) -> Self {
2137 match value {
2138 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_Undefined => {
2139 PrimitiveTopology::Undefined
2140 }
2141 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_PointList => {
2142 PrimitiveTopology::PointList
2143 }
2144 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineList => {
2145 PrimitiveTopology::LineList
2146 }
2147 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineStrip => {
2148 PrimitiveTopology::LineStrip
2149 }
2150 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleList => {
2151 PrimitiveTopology::TriangleList
2152 }
2153 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleStrip => {
2154 PrimitiveTopology::TriangleStrip
2155 }
2156 _ => PrimitiveTopology::Undefined,
2157 }
2158 }
2159 }
2160 impl From<PrimitiveTopology> for ffi::WGPUPrimitiveTopology {
2161 fn from(value: PrimitiveTopology) -> Self {
2162 match value {
2163 PrimitiveTopology::Undefined => {
2164 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_Undefined
2165 }
2166 PrimitiveTopology::PointList => {
2167 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_PointList
2168 }
2169 PrimitiveTopology::LineList => {
2170 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineList
2171 }
2172 PrimitiveTopology::LineStrip => {
2173 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineStrip
2174 }
2175 PrimitiveTopology::TriangleList => {
2176 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleList
2177 }
2178 PrimitiveTopology::TriangleStrip => {
2179 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleStrip
2180 }
2181 }
2182 }
2183 }
2184 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2185 pub enum QueryType {
2186 Occlusion,
2187 Timestamp,
2188 }
2189 impl From<ffi::WGPUQueryType> for QueryType {
2190 fn from(value: ffi::WGPUQueryType) -> Self {
2191 match value {
2192 ffi::WGPUQueryType_WGPUQueryType_Occlusion => QueryType::Occlusion,
2193 ffi::WGPUQueryType_WGPUQueryType_Timestamp => QueryType::Timestamp,
2194 _ => QueryType::Occlusion,
2195 }
2196 }
2197 }
2198 impl From<QueryType> for ffi::WGPUQueryType {
2199 fn from(value: QueryType) -> Self {
2200 match value {
2201 QueryType::Occlusion => ffi::WGPUQueryType_WGPUQueryType_Occlusion,
2202 QueryType::Timestamp => ffi::WGPUQueryType_WGPUQueryType_Timestamp,
2203 }
2204 }
2205 }
2206 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2207 pub enum QueueWorkDoneStatus {
2208 Success,
2209 CallbackCancelled,
2210 Error,
2211 }
2212 impl From<ffi::WGPUQueueWorkDoneStatus> for QueueWorkDoneStatus {
2213 fn from(value: ffi::WGPUQueueWorkDoneStatus) -> Self {
2214 match value {
2215 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Success => {
2216 QueueWorkDoneStatus::Success
2217 }
2218 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_CallbackCancelled => {
2219 QueueWorkDoneStatus::CallbackCancelled
2220 }
2221 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Error => {
2222 QueueWorkDoneStatus::Error
2223 }
2224 _ => QueueWorkDoneStatus::Success,
2225 }
2226 }
2227 }
2228 impl From<QueueWorkDoneStatus> for ffi::WGPUQueueWorkDoneStatus {
2229 fn from(value: QueueWorkDoneStatus) -> Self {
2230 match value {
2231 QueueWorkDoneStatus::Success => {
2232 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Success
2233 }
2234 QueueWorkDoneStatus::CallbackCancelled => {
2235 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_CallbackCancelled
2236 }
2237 QueueWorkDoneStatus::Error => {
2238 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Error
2239 }
2240 }
2241 }
2242 }
2243 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2244 pub enum RequestAdapterStatus {
2245 Success,
2246 CallbackCancelled,
2247 Unavailable,
2248 Error,
2249 }
2250 impl From<ffi::WGPURequestAdapterStatus> for RequestAdapterStatus {
2251 fn from(value: ffi::WGPURequestAdapterStatus) -> Self {
2252 match value {
2253 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Success => {
2254 RequestAdapterStatus::Success
2255 }
2256 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_CallbackCancelled => {
2257 RequestAdapterStatus::CallbackCancelled
2258 }
2259 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Unavailable => {
2260 RequestAdapterStatus::Unavailable
2261 }
2262 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Error => {
2263 RequestAdapterStatus::Error
2264 }
2265 _ => RequestAdapterStatus::Success,
2266 }
2267 }
2268 }
2269 impl From<RequestAdapterStatus> for ffi::WGPURequestAdapterStatus {
2270 fn from(value: RequestAdapterStatus) -> Self {
2271 match value {
2272 RequestAdapterStatus::Success => {
2273 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Success
2274 }
2275 RequestAdapterStatus::CallbackCancelled => {
2276 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_CallbackCancelled
2277 }
2278 RequestAdapterStatus::Unavailable => {
2279 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Unavailable
2280 }
2281 RequestAdapterStatus::Error => {
2282 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Error
2283 }
2284 }
2285 }
2286 }
2287 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2288 pub enum RequestDeviceStatus {
2289 Success,
2290 CallbackCancelled,
2291 Error,
2292 }
2293 impl From<ffi::WGPURequestDeviceStatus> for RequestDeviceStatus {
2294 fn from(value: ffi::WGPURequestDeviceStatus) -> Self {
2295 match value {
2296 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Success => {
2297 RequestDeviceStatus::Success
2298 }
2299 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_CallbackCancelled => {
2300 RequestDeviceStatus::CallbackCancelled
2301 }
2302 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Error => {
2303 RequestDeviceStatus::Error
2304 }
2305 _ => RequestDeviceStatus::Success,
2306 }
2307 }
2308 }
2309 impl From<RequestDeviceStatus> for ffi::WGPURequestDeviceStatus {
2310 fn from(value: RequestDeviceStatus) -> Self {
2311 match value {
2312 RequestDeviceStatus::Success => {
2313 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Success
2314 }
2315 RequestDeviceStatus::CallbackCancelled => {
2316 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_CallbackCancelled
2317 }
2318 RequestDeviceStatus::Error => {
2319 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Error
2320 }
2321 }
2322 }
2323 }
2324 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2325 pub enum SType {
2326 ShaderSourceSPIRV,
2327 ShaderSourceWGSL,
2328 RenderPassMaxDrawCount,
2329 SurfaceSourceMetalLayer,
2330 SurfaceSourceWindowsHWND,
2331 SurfaceSourceXlibWindow,
2332 SurfaceSourceWaylandSurface,
2333 SurfaceSourceAndroidNativeWindow,
2334 SurfaceSourceXCBWindow,
2335 SurfaceColorManagement,
2336 RequestAdapterWebXROptions,
2337 TextureComponentSwizzleDescriptor,
2338 CompatibilityModeLimits,
2339 TextureBindingViewDimensionDescriptor,
2340 EmscriptenSurfaceSourceCanvasHTMLSelector,
2341 SurfaceDescriptorFromWindowsCoreWindow,
2342 ExternalTextureBindingEntry,
2343 ExternalTextureBindingLayout,
2344 SurfaceDescriptorFromWindowsUWPSwapChainPanel,
2345 DawnTextureInternalUsageDescriptor,
2346 DawnEncoderInternalUsageDescriptor,
2347 DawnInstanceDescriptor,
2348 DawnCacheDeviceDescriptor,
2349 DawnAdapterPropertiesPowerPreference,
2350 DawnBufferDescriptorErrorInfoFromWireClient,
2351 DawnTogglesDescriptor,
2352 DawnShaderModuleSPIRVOptionsDescriptor,
2353 RequestAdapterOptionsLuid,
2354 RequestAdapterOptionsGetGlProc,
2355 RequestAdapterOptionsD3D11Device,
2356 DawnRenderPassSampleCount,
2357 RenderPassPixelLocalStorage,
2358 PipelineLayoutPixelLocalStorage,
2359 BufferHostMappedPointer,
2360 AdapterPropertiesMemoryHeaps,
2361 AdapterPropertiesD3D,
2362 AdapterPropertiesVk,
2363 DawnWireWGSLControl,
2364 DawnWGSLBlocklist,
2365 DawnDrmFormatCapabilities,
2366 ShaderModuleCompilationOptions,
2367 ColorTargetStateExpandResolveTextureDawn,
2368 RenderPassDescriptorExpandResolveRect,
2369 SharedTextureMemoryVkDedicatedAllocationDescriptor,
2370 SharedTextureMemoryAHardwareBufferDescriptor,
2371 SharedTextureMemoryDmaBufDescriptor,
2372 SharedTextureMemoryOpaqueFDDescriptor,
2373 SharedTextureMemoryZirconHandleDescriptor,
2374 SharedTextureMemoryDXGISharedHandleDescriptor,
2375 SharedTextureMemoryD3D11Texture2DDescriptor,
2376 SharedTextureMemoryIOSurfaceDescriptor,
2377 SharedTextureMemoryEGLImageDescriptor,
2378 SharedTextureMemoryInitializedBeginState,
2379 SharedTextureMemoryInitializedEndState,
2380 SharedTextureMemoryVkImageLayoutBeginState,
2381 SharedTextureMemoryVkImageLayoutEndState,
2382 SharedTextureMemoryD3DSwapchainBeginState,
2383 SharedFenceVkSemaphoreOpaqueFDDescriptor,
2384 SharedFenceVkSemaphoreOpaqueFDExportInfo,
2385 SharedFenceSyncFDDescriptor,
2386 SharedFenceSyncFDExportInfo,
2387 SharedFenceVkSemaphoreZirconHandleDescriptor,
2388 SharedFenceVkSemaphoreZirconHandleExportInfo,
2389 SharedFenceDXGISharedHandleDescriptor,
2390 SharedFenceDXGISharedHandleExportInfo,
2391 SharedFenceMTLSharedEventDescriptor,
2392 SharedFenceMTLSharedEventExportInfo,
2393 SharedBufferMemoryD3D12ResourceDescriptor,
2394 StaticSamplerBindingLayout,
2395 YCbCrVkDescriptor,
2396 SharedTextureMemoryAHardwareBufferProperties,
2397 AHardwareBufferProperties,
2398 DawnTexelCopyBufferRowAlignmentLimits,
2399 AdapterPropertiesSubgroupMatrixConfigs,
2400 SharedFenceEGLSyncDescriptor,
2401 SharedFenceEGLSyncExportInfo,
2402 DawnInjectedInvalidSType,
2403 DawnCompilationMessageUtf16,
2404 DawnFakeBufferOOMForTesting,
2405 SurfaceDescriptorFromWindowsWinUISwapChainPanel,
2406 DawnDeviceAllocatorControl,
2407 DawnHostMappedPointerLimits,
2408 RenderPassDescriptorResolveRect,
2409 RequestAdapterWebGPUBackendOptions,
2410 DawnFakeDeviceInitializeErrorForTesting,
2411 SharedTextureMemoryD3D11BeginState,
2412 DawnConsumeAdapterDescriptor,
2413 TexelBufferBindingEntry,
2414 TexelBufferBindingLayout,
2415 SharedTextureMemoryMetalEndAccessState,
2416 AdapterPropertiesWGPU,
2417 SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
2418 SharedTextureMemoryD3D12ResourceDescriptor,
2419 RequestAdapterOptionsAngleVirtualizationGroup,
2420 PipelineLayoutResourceTable,
2421 AdapterPropertiesExplicitComputeSubgroupSizeConfigs,
2422 }
2423 impl From<ffi::WGPUSType> for SType {
2424 fn from(value: ffi::WGPUSType) -> Self {
2425 match value {
2426 ffi::WGPUSType_WGPUSType_ShaderSourceSPIRV => SType::ShaderSourceSPIRV,
2427 ffi::WGPUSType_WGPUSType_ShaderSourceWGSL => SType::ShaderSourceWGSL,
2428 ffi::WGPUSType_WGPUSType_RenderPassMaxDrawCount => {
2429 SType::RenderPassMaxDrawCount
2430 }
2431 ffi::WGPUSType_WGPUSType_SurfaceSourceMetalLayer => {
2432 SType::SurfaceSourceMetalLayer
2433 }
2434 ffi::WGPUSType_WGPUSType_SurfaceSourceWindowsHWND => {
2435 SType::SurfaceSourceWindowsHWND
2436 }
2437 ffi::WGPUSType_WGPUSType_SurfaceSourceXlibWindow => {
2438 SType::SurfaceSourceXlibWindow
2439 }
2440 ffi::WGPUSType_WGPUSType_SurfaceSourceWaylandSurface => {
2441 SType::SurfaceSourceWaylandSurface
2442 }
2443 ffi::WGPUSType_WGPUSType_SurfaceSourceAndroidNativeWindow => {
2444 SType::SurfaceSourceAndroidNativeWindow
2445 }
2446 ffi::WGPUSType_WGPUSType_SurfaceSourceXCBWindow => {
2447 SType::SurfaceSourceXCBWindow
2448 }
2449 ffi::WGPUSType_WGPUSType_SurfaceColorManagement => {
2450 SType::SurfaceColorManagement
2451 }
2452 ffi::WGPUSType_WGPUSType_RequestAdapterWebXROptions => {
2453 SType::RequestAdapterWebXROptions
2454 }
2455 ffi::WGPUSType_WGPUSType_TextureComponentSwizzleDescriptor => {
2456 SType::TextureComponentSwizzleDescriptor
2457 }
2458 ffi::WGPUSType_WGPUSType_CompatibilityModeLimits => {
2459 SType::CompatibilityModeLimits
2460 }
2461 ffi::WGPUSType_WGPUSType_TextureBindingViewDimensionDescriptor => {
2462 SType::TextureBindingViewDimensionDescriptor
2463 }
2464 ffi::WGPUSType_WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector => {
2465 SType::EmscriptenSurfaceSourceCanvasHTMLSelector
2466 }
2467 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsCoreWindow => {
2468 SType::SurfaceDescriptorFromWindowsCoreWindow
2469 }
2470 ffi::WGPUSType_WGPUSType_ExternalTextureBindingEntry => {
2471 SType::ExternalTextureBindingEntry
2472 }
2473 ffi::WGPUSType_WGPUSType_ExternalTextureBindingLayout => {
2474 SType::ExternalTextureBindingLayout
2475 }
2476 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsUWPSwapChainPanel => {
2477 SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel
2478 }
2479 ffi::WGPUSType_WGPUSType_DawnTextureInternalUsageDescriptor => {
2480 SType::DawnTextureInternalUsageDescriptor
2481 }
2482 ffi::WGPUSType_WGPUSType_DawnEncoderInternalUsageDescriptor => {
2483 SType::DawnEncoderInternalUsageDescriptor
2484 }
2485 ffi::WGPUSType_WGPUSType_DawnInstanceDescriptor => {
2486 SType::DawnInstanceDescriptor
2487 }
2488 ffi::WGPUSType_WGPUSType_DawnCacheDeviceDescriptor => {
2489 SType::DawnCacheDeviceDescriptor
2490 }
2491 ffi::WGPUSType_WGPUSType_DawnAdapterPropertiesPowerPreference => {
2492 SType::DawnAdapterPropertiesPowerPreference
2493 }
2494 ffi::WGPUSType_WGPUSType_DawnBufferDescriptorErrorInfoFromWireClient => {
2495 SType::DawnBufferDescriptorErrorInfoFromWireClient
2496 }
2497 ffi::WGPUSType_WGPUSType_DawnTogglesDescriptor => {
2498 SType::DawnTogglesDescriptor
2499 }
2500 ffi::WGPUSType_WGPUSType_DawnShaderModuleSPIRVOptionsDescriptor => {
2501 SType::DawnShaderModuleSPIRVOptionsDescriptor
2502 }
2503 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsLUID => {
2504 SType::RequestAdapterOptionsLuid
2505 }
2506 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsGetGLProc => {
2507 SType::RequestAdapterOptionsGetGlProc
2508 }
2509 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsD3D11Device => {
2510 SType::RequestAdapterOptionsD3D11Device
2511 }
2512 ffi::WGPUSType_WGPUSType_DawnRenderPassSampleCount => {
2513 SType::DawnRenderPassSampleCount
2514 }
2515 ffi::WGPUSType_WGPUSType_RenderPassPixelLocalStorage => {
2516 SType::RenderPassPixelLocalStorage
2517 }
2518 ffi::WGPUSType_WGPUSType_PipelineLayoutPixelLocalStorage => {
2519 SType::PipelineLayoutPixelLocalStorage
2520 }
2521 ffi::WGPUSType_WGPUSType_BufferHostMappedPointer => {
2522 SType::BufferHostMappedPointer
2523 }
2524 ffi::WGPUSType_WGPUSType_AdapterPropertiesMemoryHeaps => {
2525 SType::AdapterPropertiesMemoryHeaps
2526 }
2527 ffi::WGPUSType_WGPUSType_AdapterPropertiesD3D => {
2528 SType::AdapterPropertiesD3D
2529 }
2530 ffi::WGPUSType_WGPUSType_AdapterPropertiesVk => {
2531 SType::AdapterPropertiesVk
2532 }
2533 ffi::WGPUSType_WGPUSType_DawnWireWGSLControl => {
2534 SType::DawnWireWGSLControl
2535 }
2536 ffi::WGPUSType_WGPUSType_DawnWGSLBlocklist => SType::DawnWGSLBlocklist,
2537 ffi::WGPUSType_WGPUSType_DawnDrmFormatCapabilities => {
2538 SType::DawnDrmFormatCapabilities
2539 }
2540 ffi::WGPUSType_WGPUSType_ShaderModuleCompilationOptions => {
2541 SType::ShaderModuleCompilationOptions
2542 }
2543 ffi::WGPUSType_WGPUSType_ColorTargetStateExpandResolveTextureDawn => {
2544 SType::ColorTargetStateExpandResolveTextureDawn
2545 }
2546 ffi::WGPUSType_WGPUSType_RenderPassDescriptorExpandResolveRect => {
2547 SType::RenderPassDescriptorExpandResolveRect
2548 }
2549 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkDedicatedAllocationDescriptor => {
2550 SType::SharedTextureMemoryVkDedicatedAllocationDescriptor
2551 }
2552 ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferDescriptor => {
2553 SType::SharedTextureMemoryAHardwareBufferDescriptor
2554 }
2555 ffi::WGPUSType_WGPUSType_SharedTextureMemoryDmaBufDescriptor => {
2556 SType::SharedTextureMemoryDmaBufDescriptor
2557 }
2558 ffi::WGPUSType_WGPUSType_SharedTextureMemoryOpaqueFDDescriptor => {
2559 SType::SharedTextureMemoryOpaqueFDDescriptor
2560 }
2561 ffi::WGPUSType_WGPUSType_SharedTextureMemoryZirconHandleDescriptor => {
2562 SType::SharedTextureMemoryZirconHandleDescriptor
2563 }
2564 ffi::WGPUSType_WGPUSType_SharedTextureMemoryDXGISharedHandleDescriptor => {
2565 SType::SharedTextureMemoryDXGISharedHandleDescriptor
2566 }
2567 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11Texture2DDescriptor => {
2568 SType::SharedTextureMemoryD3D11Texture2DDescriptor
2569 }
2570 ffi::WGPUSType_WGPUSType_SharedTextureMemoryIOSurfaceDescriptor => {
2571 SType::SharedTextureMemoryIOSurfaceDescriptor
2572 }
2573 ffi::WGPUSType_WGPUSType_SharedTextureMemoryEGLImageDescriptor => {
2574 SType::SharedTextureMemoryEGLImageDescriptor
2575 }
2576 ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedBeginState => {
2577 SType::SharedTextureMemoryInitializedBeginState
2578 }
2579 ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedEndState => {
2580 SType::SharedTextureMemoryInitializedEndState
2581 }
2582 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutBeginState => {
2583 SType::SharedTextureMemoryVkImageLayoutBeginState
2584 }
2585 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutEndState => {
2586 SType::SharedTextureMemoryVkImageLayoutEndState
2587 }
2588 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3DSwapchainBeginState => {
2589 SType::SharedTextureMemoryD3DSwapchainBeginState
2590 }
2591 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDDescriptor => {
2592 SType::SharedFenceVkSemaphoreOpaqueFDDescriptor
2593 }
2594 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDExportInfo => {
2595 SType::SharedFenceVkSemaphoreOpaqueFDExportInfo
2596 }
2597 ffi::WGPUSType_WGPUSType_SharedFenceSyncFDDescriptor => {
2598 SType::SharedFenceSyncFDDescriptor
2599 }
2600 ffi::WGPUSType_WGPUSType_SharedFenceSyncFDExportInfo => {
2601 SType::SharedFenceSyncFDExportInfo
2602 }
2603 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleDescriptor => {
2604 SType::SharedFenceVkSemaphoreZirconHandleDescriptor
2605 }
2606 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleExportInfo => {
2607 SType::SharedFenceVkSemaphoreZirconHandleExportInfo
2608 }
2609 ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleDescriptor => {
2610 SType::SharedFenceDXGISharedHandleDescriptor
2611 }
2612 ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleExportInfo => {
2613 SType::SharedFenceDXGISharedHandleExportInfo
2614 }
2615 ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventDescriptor => {
2616 SType::SharedFenceMTLSharedEventDescriptor
2617 }
2618 ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventExportInfo => {
2619 SType::SharedFenceMTLSharedEventExportInfo
2620 }
2621 ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor => {
2622 SType::SharedBufferMemoryD3D12ResourceDescriptor
2623 }
2624 ffi::WGPUSType_WGPUSType_StaticSamplerBindingLayout => {
2625 SType::StaticSamplerBindingLayout
2626 }
2627 ffi::WGPUSType_WGPUSType_YCbCrVkDescriptor => SType::YCbCrVkDescriptor,
2628 ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferProperties => {
2629 SType::SharedTextureMemoryAHardwareBufferProperties
2630 }
2631 ffi::WGPUSType_WGPUSType_AHardwareBufferProperties => {
2632 SType::AHardwareBufferProperties
2633 }
2634 ffi::WGPUSType_WGPUSType_DawnTexelCopyBufferRowAlignmentLimits => {
2635 SType::DawnTexelCopyBufferRowAlignmentLimits
2636 }
2637 ffi::WGPUSType_WGPUSType_AdapterPropertiesSubgroupMatrixConfigs => {
2638 SType::AdapterPropertiesSubgroupMatrixConfigs
2639 }
2640 ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncDescriptor => {
2641 SType::SharedFenceEGLSyncDescriptor
2642 }
2643 ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncExportInfo => {
2644 SType::SharedFenceEGLSyncExportInfo
2645 }
2646 ffi::WGPUSType_WGPUSType_DawnInjectedInvalidSType => {
2647 SType::DawnInjectedInvalidSType
2648 }
2649 ffi::WGPUSType_WGPUSType_DawnCompilationMessageUtf16 => {
2650 SType::DawnCompilationMessageUtf16
2651 }
2652 ffi::WGPUSType_WGPUSType_DawnFakeBufferOOMForTesting => {
2653 SType::DawnFakeBufferOOMForTesting
2654 }
2655 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsWinUISwapChainPanel => {
2656 SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel
2657 }
2658 ffi::WGPUSType_WGPUSType_DawnDeviceAllocatorControl => {
2659 SType::DawnDeviceAllocatorControl
2660 }
2661 ffi::WGPUSType_WGPUSType_DawnHostMappedPointerLimits => {
2662 SType::DawnHostMappedPointerLimits
2663 }
2664 ffi::WGPUSType_WGPUSType_RenderPassDescriptorResolveRect => {
2665 SType::RenderPassDescriptorResolveRect
2666 }
2667 ffi::WGPUSType_WGPUSType_RequestAdapterWebGPUBackendOptions => {
2668 SType::RequestAdapterWebGPUBackendOptions
2669 }
2670 ffi::WGPUSType_WGPUSType_DawnFakeDeviceInitializeErrorForTesting => {
2671 SType::DawnFakeDeviceInitializeErrorForTesting
2672 }
2673 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11BeginState => {
2674 SType::SharedTextureMemoryD3D11BeginState
2675 }
2676 ffi::WGPUSType_WGPUSType_DawnConsumeAdapterDescriptor => {
2677 SType::DawnConsumeAdapterDescriptor
2678 }
2679 ffi::WGPUSType_WGPUSType_TexelBufferBindingEntry => {
2680 SType::TexelBufferBindingEntry
2681 }
2682 ffi::WGPUSType_WGPUSType_TexelBufferBindingLayout => {
2683 SType::TexelBufferBindingLayout
2684 }
2685 ffi::WGPUSType_WGPUSType_SharedTextureMemoryMetalEndAccessState => {
2686 SType::SharedTextureMemoryMetalEndAccessState
2687 }
2688 ffi::WGPUSType_WGPUSType_AdapterPropertiesWGPU => {
2689 SType::AdapterPropertiesWGPU
2690 }
2691 ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor => {
2692 SType::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor
2693 }
2694 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D12ResourceDescriptor => {
2695 SType::SharedTextureMemoryD3D12ResourceDescriptor
2696 }
2697 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsAngleVirtualizationGroup => {
2698 SType::RequestAdapterOptionsAngleVirtualizationGroup
2699 }
2700 ffi::WGPUSType_WGPUSType_PipelineLayoutResourceTable => {
2701 SType::PipelineLayoutResourceTable
2702 }
2703 ffi::WGPUSType_WGPUSType_AdapterPropertiesExplicitComputeSubgroupSizeConfigs => {
2704 SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs
2705 }
2706 _ => SType::ShaderSourceSPIRV,
2707 }
2708 }
2709 }
2710 impl From<SType> for ffi::WGPUSType {
2711 fn from(value: SType) -> Self {
2712 match value {
2713 SType::ShaderSourceSPIRV => ffi::WGPUSType_WGPUSType_ShaderSourceSPIRV,
2714 SType::ShaderSourceWGSL => ffi::WGPUSType_WGPUSType_ShaderSourceWGSL,
2715 SType::RenderPassMaxDrawCount => {
2716 ffi::WGPUSType_WGPUSType_RenderPassMaxDrawCount
2717 }
2718 SType::SurfaceSourceMetalLayer => {
2719 ffi::WGPUSType_WGPUSType_SurfaceSourceMetalLayer
2720 }
2721 SType::SurfaceSourceWindowsHWND => {
2722 ffi::WGPUSType_WGPUSType_SurfaceSourceWindowsHWND
2723 }
2724 SType::SurfaceSourceXlibWindow => {
2725 ffi::WGPUSType_WGPUSType_SurfaceSourceXlibWindow
2726 }
2727 SType::SurfaceSourceWaylandSurface => {
2728 ffi::WGPUSType_WGPUSType_SurfaceSourceWaylandSurface
2729 }
2730 SType::SurfaceSourceAndroidNativeWindow => {
2731 ffi::WGPUSType_WGPUSType_SurfaceSourceAndroidNativeWindow
2732 }
2733 SType::SurfaceSourceXCBWindow => {
2734 ffi::WGPUSType_WGPUSType_SurfaceSourceXCBWindow
2735 }
2736 SType::SurfaceColorManagement => {
2737 ffi::WGPUSType_WGPUSType_SurfaceColorManagement
2738 }
2739 SType::RequestAdapterWebXROptions => {
2740 ffi::WGPUSType_WGPUSType_RequestAdapterWebXROptions
2741 }
2742 SType::TextureComponentSwizzleDescriptor => {
2743 ffi::WGPUSType_WGPUSType_TextureComponentSwizzleDescriptor
2744 }
2745 SType::CompatibilityModeLimits => {
2746 ffi::WGPUSType_WGPUSType_CompatibilityModeLimits
2747 }
2748 SType::TextureBindingViewDimensionDescriptor => {
2749 ffi::WGPUSType_WGPUSType_TextureBindingViewDimensionDescriptor
2750 }
2751 SType::EmscriptenSurfaceSourceCanvasHTMLSelector => {
2752 ffi::WGPUSType_WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector
2753 }
2754 SType::SurfaceDescriptorFromWindowsCoreWindow => {
2755 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsCoreWindow
2756 }
2757 SType::ExternalTextureBindingEntry => {
2758 ffi::WGPUSType_WGPUSType_ExternalTextureBindingEntry
2759 }
2760 SType::ExternalTextureBindingLayout => {
2761 ffi::WGPUSType_WGPUSType_ExternalTextureBindingLayout
2762 }
2763 SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel => {
2764 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsUWPSwapChainPanel
2765 }
2766 SType::DawnTextureInternalUsageDescriptor => {
2767 ffi::WGPUSType_WGPUSType_DawnTextureInternalUsageDescriptor
2768 }
2769 SType::DawnEncoderInternalUsageDescriptor => {
2770 ffi::WGPUSType_WGPUSType_DawnEncoderInternalUsageDescriptor
2771 }
2772 SType::DawnInstanceDescriptor => {
2773 ffi::WGPUSType_WGPUSType_DawnInstanceDescriptor
2774 }
2775 SType::DawnCacheDeviceDescriptor => {
2776 ffi::WGPUSType_WGPUSType_DawnCacheDeviceDescriptor
2777 }
2778 SType::DawnAdapterPropertiesPowerPreference => {
2779 ffi::WGPUSType_WGPUSType_DawnAdapterPropertiesPowerPreference
2780 }
2781 SType::DawnBufferDescriptorErrorInfoFromWireClient => {
2782 ffi::WGPUSType_WGPUSType_DawnBufferDescriptorErrorInfoFromWireClient
2783 }
2784 SType::DawnTogglesDescriptor => {
2785 ffi::WGPUSType_WGPUSType_DawnTogglesDescriptor
2786 }
2787 SType::DawnShaderModuleSPIRVOptionsDescriptor => {
2788 ffi::WGPUSType_WGPUSType_DawnShaderModuleSPIRVOptionsDescriptor
2789 }
2790 SType::RequestAdapterOptionsLuid => {
2791 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsLUID
2792 }
2793 SType::RequestAdapterOptionsGetGlProc => {
2794 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsGetGLProc
2795 }
2796 SType::RequestAdapterOptionsD3D11Device => {
2797 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsD3D11Device
2798 }
2799 SType::DawnRenderPassSampleCount => {
2800 ffi::WGPUSType_WGPUSType_DawnRenderPassSampleCount
2801 }
2802 SType::RenderPassPixelLocalStorage => {
2803 ffi::WGPUSType_WGPUSType_RenderPassPixelLocalStorage
2804 }
2805 SType::PipelineLayoutPixelLocalStorage => {
2806 ffi::WGPUSType_WGPUSType_PipelineLayoutPixelLocalStorage
2807 }
2808 SType::BufferHostMappedPointer => {
2809 ffi::WGPUSType_WGPUSType_BufferHostMappedPointer
2810 }
2811 SType::AdapterPropertiesMemoryHeaps => {
2812 ffi::WGPUSType_WGPUSType_AdapterPropertiesMemoryHeaps
2813 }
2814 SType::AdapterPropertiesD3D => {
2815 ffi::WGPUSType_WGPUSType_AdapterPropertiesD3D
2816 }
2817 SType::AdapterPropertiesVk => {
2818 ffi::WGPUSType_WGPUSType_AdapterPropertiesVk
2819 }
2820 SType::DawnWireWGSLControl => {
2821 ffi::WGPUSType_WGPUSType_DawnWireWGSLControl
2822 }
2823 SType::DawnWGSLBlocklist => ffi::WGPUSType_WGPUSType_DawnWGSLBlocklist,
2824 SType::DawnDrmFormatCapabilities => {
2825 ffi::WGPUSType_WGPUSType_DawnDrmFormatCapabilities
2826 }
2827 SType::ShaderModuleCompilationOptions => {
2828 ffi::WGPUSType_WGPUSType_ShaderModuleCompilationOptions
2829 }
2830 SType::ColorTargetStateExpandResolveTextureDawn => {
2831 ffi::WGPUSType_WGPUSType_ColorTargetStateExpandResolveTextureDawn
2832 }
2833 SType::RenderPassDescriptorExpandResolveRect => {
2834 ffi::WGPUSType_WGPUSType_RenderPassDescriptorExpandResolveRect
2835 }
2836 SType::SharedTextureMemoryVkDedicatedAllocationDescriptor => {
2837 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkDedicatedAllocationDescriptor
2838 }
2839 SType::SharedTextureMemoryAHardwareBufferDescriptor => {
2840 ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferDescriptor
2841 }
2842 SType::SharedTextureMemoryDmaBufDescriptor => {
2843 ffi::WGPUSType_WGPUSType_SharedTextureMemoryDmaBufDescriptor
2844 }
2845 SType::SharedTextureMemoryOpaqueFDDescriptor => {
2846 ffi::WGPUSType_WGPUSType_SharedTextureMemoryOpaqueFDDescriptor
2847 }
2848 SType::SharedTextureMemoryZirconHandleDescriptor => {
2849 ffi::WGPUSType_WGPUSType_SharedTextureMemoryZirconHandleDescriptor
2850 }
2851 SType::SharedTextureMemoryDXGISharedHandleDescriptor => {
2852 ffi::WGPUSType_WGPUSType_SharedTextureMemoryDXGISharedHandleDescriptor
2853 }
2854 SType::SharedTextureMemoryD3D11Texture2DDescriptor => {
2855 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11Texture2DDescriptor
2856 }
2857 SType::SharedTextureMemoryIOSurfaceDescriptor => {
2858 ffi::WGPUSType_WGPUSType_SharedTextureMemoryIOSurfaceDescriptor
2859 }
2860 SType::SharedTextureMemoryEGLImageDescriptor => {
2861 ffi::WGPUSType_WGPUSType_SharedTextureMemoryEGLImageDescriptor
2862 }
2863 SType::SharedTextureMemoryInitializedBeginState => {
2864 ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedBeginState
2865 }
2866 SType::SharedTextureMemoryInitializedEndState => {
2867 ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedEndState
2868 }
2869 SType::SharedTextureMemoryVkImageLayoutBeginState => {
2870 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutBeginState
2871 }
2872 SType::SharedTextureMemoryVkImageLayoutEndState => {
2873 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutEndState
2874 }
2875 SType::SharedTextureMemoryD3DSwapchainBeginState => {
2876 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3DSwapchainBeginState
2877 }
2878 SType::SharedFenceVkSemaphoreOpaqueFDDescriptor => {
2879 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDDescriptor
2880 }
2881 SType::SharedFenceVkSemaphoreOpaqueFDExportInfo => {
2882 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDExportInfo
2883 }
2884 SType::SharedFenceSyncFDDescriptor => {
2885 ffi::WGPUSType_WGPUSType_SharedFenceSyncFDDescriptor
2886 }
2887 SType::SharedFenceSyncFDExportInfo => {
2888 ffi::WGPUSType_WGPUSType_SharedFenceSyncFDExportInfo
2889 }
2890 SType::SharedFenceVkSemaphoreZirconHandleDescriptor => {
2891 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleDescriptor
2892 }
2893 SType::SharedFenceVkSemaphoreZirconHandleExportInfo => {
2894 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleExportInfo
2895 }
2896 SType::SharedFenceDXGISharedHandleDescriptor => {
2897 ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleDescriptor
2898 }
2899 SType::SharedFenceDXGISharedHandleExportInfo => {
2900 ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleExportInfo
2901 }
2902 SType::SharedFenceMTLSharedEventDescriptor => {
2903 ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventDescriptor
2904 }
2905 SType::SharedFenceMTLSharedEventExportInfo => {
2906 ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventExportInfo
2907 }
2908 SType::SharedBufferMemoryD3D12ResourceDescriptor => {
2909 ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor
2910 }
2911 SType::StaticSamplerBindingLayout => {
2912 ffi::WGPUSType_WGPUSType_StaticSamplerBindingLayout
2913 }
2914 SType::YCbCrVkDescriptor => ffi::WGPUSType_WGPUSType_YCbCrVkDescriptor,
2915 SType::SharedTextureMemoryAHardwareBufferProperties => {
2916 ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferProperties
2917 }
2918 SType::AHardwareBufferProperties => {
2919 ffi::WGPUSType_WGPUSType_AHardwareBufferProperties
2920 }
2921 SType::DawnTexelCopyBufferRowAlignmentLimits => {
2922 ffi::WGPUSType_WGPUSType_DawnTexelCopyBufferRowAlignmentLimits
2923 }
2924 SType::AdapterPropertiesSubgroupMatrixConfigs => {
2925 ffi::WGPUSType_WGPUSType_AdapterPropertiesSubgroupMatrixConfigs
2926 }
2927 SType::SharedFenceEGLSyncDescriptor => {
2928 ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncDescriptor
2929 }
2930 SType::SharedFenceEGLSyncExportInfo => {
2931 ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncExportInfo
2932 }
2933 SType::DawnInjectedInvalidSType => {
2934 ffi::WGPUSType_WGPUSType_DawnInjectedInvalidSType
2935 }
2936 SType::DawnCompilationMessageUtf16 => {
2937 ffi::WGPUSType_WGPUSType_DawnCompilationMessageUtf16
2938 }
2939 SType::DawnFakeBufferOOMForTesting => {
2940 ffi::WGPUSType_WGPUSType_DawnFakeBufferOOMForTesting
2941 }
2942 SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel => {
2943 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsWinUISwapChainPanel
2944 }
2945 SType::DawnDeviceAllocatorControl => {
2946 ffi::WGPUSType_WGPUSType_DawnDeviceAllocatorControl
2947 }
2948 SType::DawnHostMappedPointerLimits => {
2949 ffi::WGPUSType_WGPUSType_DawnHostMappedPointerLimits
2950 }
2951 SType::RenderPassDescriptorResolveRect => {
2952 ffi::WGPUSType_WGPUSType_RenderPassDescriptorResolveRect
2953 }
2954 SType::RequestAdapterWebGPUBackendOptions => {
2955 ffi::WGPUSType_WGPUSType_RequestAdapterWebGPUBackendOptions
2956 }
2957 SType::DawnFakeDeviceInitializeErrorForTesting => {
2958 ffi::WGPUSType_WGPUSType_DawnFakeDeviceInitializeErrorForTesting
2959 }
2960 SType::SharedTextureMemoryD3D11BeginState => {
2961 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11BeginState
2962 }
2963 SType::DawnConsumeAdapterDescriptor => {
2964 ffi::WGPUSType_WGPUSType_DawnConsumeAdapterDescriptor
2965 }
2966 SType::TexelBufferBindingEntry => {
2967 ffi::WGPUSType_WGPUSType_TexelBufferBindingEntry
2968 }
2969 SType::TexelBufferBindingLayout => {
2970 ffi::WGPUSType_WGPUSType_TexelBufferBindingLayout
2971 }
2972 SType::SharedTextureMemoryMetalEndAccessState => {
2973 ffi::WGPUSType_WGPUSType_SharedTextureMemoryMetalEndAccessState
2974 }
2975 SType::AdapterPropertiesWGPU => {
2976 ffi::WGPUSType_WGPUSType_AdapterPropertiesWGPU
2977 }
2978 SType::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor => {
2979 ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor
2980 }
2981 SType::SharedTextureMemoryD3D12ResourceDescriptor => {
2982 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D12ResourceDescriptor
2983 }
2984 SType::RequestAdapterOptionsAngleVirtualizationGroup => {
2985 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsAngleVirtualizationGroup
2986 }
2987 SType::PipelineLayoutResourceTable => {
2988 ffi::WGPUSType_WGPUSType_PipelineLayoutResourceTable
2989 }
2990 SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs => {
2991 ffi::WGPUSType_WGPUSType_AdapterPropertiesExplicitComputeSubgroupSizeConfigs
2992 }
2993 }
2994 }
2995 }
2996 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2997 pub enum SamplerBindingType {
2998 BindingNotUsed,
2999 Undefined,
3000 Filtering,
3001 NonFiltering,
3002 Comparison,
3003 }
3004 impl From<ffi::WGPUSamplerBindingType> for SamplerBindingType {
3005 fn from(value: ffi::WGPUSamplerBindingType) -> Self {
3006 match value {
3007 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_BindingNotUsed => {
3008 SamplerBindingType::BindingNotUsed
3009 }
3010 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Undefined => {
3011 SamplerBindingType::Undefined
3012 }
3013 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Filtering => {
3014 SamplerBindingType::Filtering
3015 }
3016 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_NonFiltering => {
3017 SamplerBindingType::NonFiltering
3018 }
3019 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Comparison => {
3020 SamplerBindingType::Comparison
3021 }
3022 _ => SamplerBindingType::BindingNotUsed,
3023 }
3024 }
3025 }
3026 impl From<SamplerBindingType> for ffi::WGPUSamplerBindingType {
3027 fn from(value: SamplerBindingType) -> Self {
3028 match value {
3029 SamplerBindingType::BindingNotUsed => {
3030 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_BindingNotUsed
3031 }
3032 SamplerBindingType::Undefined => {
3033 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Undefined
3034 }
3035 SamplerBindingType::Filtering => {
3036 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Filtering
3037 }
3038 SamplerBindingType::NonFiltering => {
3039 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_NonFiltering
3040 }
3041 SamplerBindingType::Comparison => {
3042 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Comparison
3043 }
3044 }
3045 }
3046 }
3047 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3048 pub enum SharedFenceType {
3049 VkSemaphoreOpaqueFD,
3050 SyncFD,
3051 VkSemaphoreZirconHandle,
3052 DXGISharedHandle,
3053 MTLSharedEvent,
3054 EGLSync,
3055 }
3056 impl From<ffi::WGPUSharedFenceType> for SharedFenceType {
3057 fn from(value: ffi::WGPUSharedFenceType) -> Self {
3058 match value {
3059 ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreOpaqueFD => {
3060 SharedFenceType::VkSemaphoreOpaqueFD
3061 }
3062 ffi::WGPUSharedFenceType_WGPUSharedFenceType_SyncFD => {
3063 SharedFenceType::SyncFD
3064 }
3065 ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreZirconHandle => {
3066 SharedFenceType::VkSemaphoreZirconHandle
3067 }
3068 ffi::WGPUSharedFenceType_WGPUSharedFenceType_DXGISharedHandle => {
3069 SharedFenceType::DXGISharedHandle
3070 }
3071 ffi::WGPUSharedFenceType_WGPUSharedFenceType_MTLSharedEvent => {
3072 SharedFenceType::MTLSharedEvent
3073 }
3074 ffi::WGPUSharedFenceType_WGPUSharedFenceType_EGLSync => {
3075 SharedFenceType::EGLSync
3076 }
3077 _ => SharedFenceType::VkSemaphoreOpaqueFD,
3078 }
3079 }
3080 }
3081 impl From<SharedFenceType> for ffi::WGPUSharedFenceType {
3082 fn from(value: SharedFenceType) -> Self {
3083 match value {
3084 SharedFenceType::VkSemaphoreOpaqueFD => {
3085 ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreOpaqueFD
3086 }
3087 SharedFenceType::SyncFD => {
3088 ffi::WGPUSharedFenceType_WGPUSharedFenceType_SyncFD
3089 }
3090 SharedFenceType::VkSemaphoreZirconHandle => {
3091 ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreZirconHandle
3092 }
3093 SharedFenceType::DXGISharedHandle => {
3094 ffi::WGPUSharedFenceType_WGPUSharedFenceType_DXGISharedHandle
3095 }
3096 SharedFenceType::MTLSharedEvent => {
3097 ffi::WGPUSharedFenceType_WGPUSharedFenceType_MTLSharedEvent
3098 }
3099 SharedFenceType::EGLSync => {
3100 ffi::WGPUSharedFenceType_WGPUSharedFenceType_EGLSync
3101 }
3102 }
3103 }
3104 }
3105 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3106 pub enum Status {
3107 Success,
3108 Error,
3109 }
3110 impl From<ffi::WGPUStatus> for Status {
3111 fn from(value: ffi::WGPUStatus) -> Self {
3112 match value {
3113 ffi::WGPUStatus_WGPUStatus_Success => Status::Success,
3114 ffi::WGPUStatus_WGPUStatus_Error => Status::Error,
3115 _ => Status::Success,
3116 }
3117 }
3118 }
3119 impl From<Status> for ffi::WGPUStatus {
3120 fn from(value: Status) -> Self {
3121 match value {
3122 Status::Success => ffi::WGPUStatus_WGPUStatus_Success,
3123 Status::Error => ffi::WGPUStatus_WGPUStatus_Error,
3124 }
3125 }
3126 }
3127 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3128 pub enum StencilOperation {
3129 Undefined,
3130 Keep,
3131 Zero,
3132 Replace,
3133 Invert,
3134 IncrementClamp,
3135 DecrementClamp,
3136 IncrementWrap,
3137 DecrementWrap,
3138 }
3139 impl From<ffi::WGPUStencilOperation> for StencilOperation {
3140 fn from(value: ffi::WGPUStencilOperation) -> Self {
3141 match value {
3142 ffi::WGPUStencilOperation_WGPUStencilOperation_Undefined => {
3143 StencilOperation::Undefined
3144 }
3145 ffi::WGPUStencilOperation_WGPUStencilOperation_Keep => {
3146 StencilOperation::Keep
3147 }
3148 ffi::WGPUStencilOperation_WGPUStencilOperation_Zero => {
3149 StencilOperation::Zero
3150 }
3151 ffi::WGPUStencilOperation_WGPUStencilOperation_Replace => {
3152 StencilOperation::Replace
3153 }
3154 ffi::WGPUStencilOperation_WGPUStencilOperation_Invert => {
3155 StencilOperation::Invert
3156 }
3157 ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementClamp => {
3158 StencilOperation::IncrementClamp
3159 }
3160 ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementClamp => {
3161 StencilOperation::DecrementClamp
3162 }
3163 ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementWrap => {
3164 StencilOperation::IncrementWrap
3165 }
3166 ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementWrap => {
3167 StencilOperation::DecrementWrap
3168 }
3169 _ => StencilOperation::Undefined,
3170 }
3171 }
3172 }
3173 impl From<StencilOperation> for ffi::WGPUStencilOperation {
3174 fn from(value: StencilOperation) -> Self {
3175 match value {
3176 StencilOperation::Undefined => {
3177 ffi::WGPUStencilOperation_WGPUStencilOperation_Undefined
3178 }
3179 StencilOperation::Keep => {
3180 ffi::WGPUStencilOperation_WGPUStencilOperation_Keep
3181 }
3182 StencilOperation::Zero => {
3183 ffi::WGPUStencilOperation_WGPUStencilOperation_Zero
3184 }
3185 StencilOperation::Replace => {
3186 ffi::WGPUStencilOperation_WGPUStencilOperation_Replace
3187 }
3188 StencilOperation::Invert => {
3189 ffi::WGPUStencilOperation_WGPUStencilOperation_Invert
3190 }
3191 StencilOperation::IncrementClamp => {
3192 ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementClamp
3193 }
3194 StencilOperation::DecrementClamp => {
3195 ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementClamp
3196 }
3197 StencilOperation::IncrementWrap => {
3198 ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementWrap
3199 }
3200 StencilOperation::DecrementWrap => {
3201 ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementWrap
3202 }
3203 }
3204 }
3205 }
3206 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3207 pub enum StorageTextureAccess {
3208 BindingNotUsed,
3209 Undefined,
3210 WriteOnly,
3211 ReadOnly,
3212 ReadWrite,
3213 }
3214 impl From<ffi::WGPUStorageTextureAccess> for StorageTextureAccess {
3215 fn from(value: ffi::WGPUStorageTextureAccess) -> Self {
3216 match value {
3217 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_BindingNotUsed => {
3218 StorageTextureAccess::BindingNotUsed
3219 }
3220 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_Undefined => {
3221 StorageTextureAccess::Undefined
3222 }
3223 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_WriteOnly => {
3224 StorageTextureAccess::WriteOnly
3225 }
3226 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadOnly => {
3227 StorageTextureAccess::ReadOnly
3228 }
3229 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadWrite => {
3230 StorageTextureAccess::ReadWrite
3231 }
3232 _ => StorageTextureAccess::BindingNotUsed,
3233 }
3234 }
3235 }
3236 impl From<StorageTextureAccess> for ffi::WGPUStorageTextureAccess {
3237 fn from(value: StorageTextureAccess) -> Self {
3238 match value {
3239 StorageTextureAccess::BindingNotUsed => {
3240 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_BindingNotUsed
3241 }
3242 StorageTextureAccess::Undefined => {
3243 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_Undefined
3244 }
3245 StorageTextureAccess::WriteOnly => {
3246 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_WriteOnly
3247 }
3248 StorageTextureAccess::ReadOnly => {
3249 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadOnly
3250 }
3251 StorageTextureAccess::ReadWrite => {
3252 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadWrite
3253 }
3254 }
3255 }
3256 }
3257 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3258 pub enum StoreOp {
3259 Undefined,
3260 Store,
3261 Discard,
3262 }
3263 impl From<ffi::WGPUStoreOp> for StoreOp {
3264 fn from(value: ffi::WGPUStoreOp) -> Self {
3265 match value {
3266 ffi::WGPUStoreOp_WGPUStoreOp_Undefined => StoreOp::Undefined,
3267 ffi::WGPUStoreOp_WGPUStoreOp_Store => StoreOp::Store,
3268 ffi::WGPUStoreOp_WGPUStoreOp_Discard => StoreOp::Discard,
3269 _ => StoreOp::Undefined,
3270 }
3271 }
3272 }
3273 impl From<StoreOp> for ffi::WGPUStoreOp {
3274 fn from(value: StoreOp) -> Self {
3275 match value {
3276 StoreOp::Undefined => ffi::WGPUStoreOp_WGPUStoreOp_Undefined,
3277 StoreOp::Store => ffi::WGPUStoreOp_WGPUStoreOp_Store,
3278 StoreOp::Discard => ffi::WGPUStoreOp_WGPUStoreOp_Discard,
3279 }
3280 }
3281 }
3282 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3283 pub enum SubgroupMatrixComponentType {
3284 F32,
3285 F16,
3286 U32,
3287 I32,
3288 U8,
3289 I8,
3290 }
3291 impl From<ffi::WGPUSubgroupMatrixComponentType> for SubgroupMatrixComponentType {
3292 fn from(value: ffi::WGPUSubgroupMatrixComponentType) -> Self {
3293 match value {
3294 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F32 => {
3295 SubgroupMatrixComponentType::F32
3296 }
3297 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F16 => {
3298 SubgroupMatrixComponentType::F16
3299 }
3300 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U32 => {
3301 SubgroupMatrixComponentType::U32
3302 }
3303 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I32 => {
3304 SubgroupMatrixComponentType::I32
3305 }
3306 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U8 => {
3307 SubgroupMatrixComponentType::U8
3308 }
3309 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I8 => {
3310 SubgroupMatrixComponentType::I8
3311 }
3312 _ => SubgroupMatrixComponentType::F32,
3313 }
3314 }
3315 }
3316 impl From<SubgroupMatrixComponentType> for ffi::WGPUSubgroupMatrixComponentType {
3317 fn from(value: SubgroupMatrixComponentType) -> Self {
3318 match value {
3319 SubgroupMatrixComponentType::F32 => {
3320 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F32
3321 }
3322 SubgroupMatrixComponentType::F16 => {
3323 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F16
3324 }
3325 SubgroupMatrixComponentType::U32 => {
3326 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U32
3327 }
3328 SubgroupMatrixComponentType::I32 => {
3329 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I32
3330 }
3331 SubgroupMatrixComponentType::U8 => {
3332 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U8
3333 }
3334 SubgroupMatrixComponentType::I8 => {
3335 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I8
3336 }
3337 }
3338 }
3339 }
3340 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3341 pub enum SurfaceGetCurrentTextureStatus {
3342 SuccessOptimal,
3343 SuccessSuboptimal,
3344 Timeout,
3345 Outdated,
3346 Lost,
3347 Error,
3348 }
3349 impl From<ffi::WGPUSurfaceGetCurrentTextureStatus>
3350 for SurfaceGetCurrentTextureStatus {
3351 fn from(value: ffi::WGPUSurfaceGetCurrentTextureStatus) -> Self {
3352 match value {
3353 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal => {
3354 SurfaceGetCurrentTextureStatus::SuccessOptimal
3355 }
3356 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal => {
3357 SurfaceGetCurrentTextureStatus::SuccessSuboptimal
3358 }
3359 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Timeout => {
3360 SurfaceGetCurrentTextureStatus::Timeout
3361 }
3362 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Outdated => {
3363 SurfaceGetCurrentTextureStatus::Outdated
3364 }
3365 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Lost => {
3366 SurfaceGetCurrentTextureStatus::Lost
3367 }
3368 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Error => {
3369 SurfaceGetCurrentTextureStatus::Error
3370 }
3371 _ => SurfaceGetCurrentTextureStatus::SuccessOptimal,
3372 }
3373 }
3374 }
3375 impl From<SurfaceGetCurrentTextureStatus>
3376 for ffi::WGPUSurfaceGetCurrentTextureStatus {
3377 fn from(value: SurfaceGetCurrentTextureStatus) -> Self {
3378 match value {
3379 SurfaceGetCurrentTextureStatus::SuccessOptimal => {
3380 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal
3381 }
3382 SurfaceGetCurrentTextureStatus::SuccessSuboptimal => {
3383 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal
3384 }
3385 SurfaceGetCurrentTextureStatus::Timeout => {
3386 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Timeout
3387 }
3388 SurfaceGetCurrentTextureStatus::Outdated => {
3389 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Outdated
3390 }
3391 SurfaceGetCurrentTextureStatus::Lost => {
3392 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Lost
3393 }
3394 SurfaceGetCurrentTextureStatus::Error => {
3395 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Error
3396 }
3397 }
3398 }
3399 }
3400 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3401 pub enum TexelBufferAccess {
3402 Undefined,
3403 ReadOnly,
3404 ReadWrite,
3405 }
3406 impl From<ffi::WGPUTexelBufferAccess> for TexelBufferAccess {
3407 fn from(value: ffi::WGPUTexelBufferAccess) -> Self {
3408 match value {
3409 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_Undefined => {
3410 TexelBufferAccess::Undefined
3411 }
3412 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadOnly => {
3413 TexelBufferAccess::ReadOnly
3414 }
3415 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadWrite => {
3416 TexelBufferAccess::ReadWrite
3417 }
3418 _ => TexelBufferAccess::Undefined,
3419 }
3420 }
3421 }
3422 impl From<TexelBufferAccess> for ffi::WGPUTexelBufferAccess {
3423 fn from(value: TexelBufferAccess) -> Self {
3424 match value {
3425 TexelBufferAccess::Undefined => {
3426 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_Undefined
3427 }
3428 TexelBufferAccess::ReadOnly => {
3429 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadOnly
3430 }
3431 TexelBufferAccess::ReadWrite => {
3432 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadWrite
3433 }
3434 }
3435 }
3436 }
3437 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3438 pub enum TextureAspect {
3439 Undefined,
3440 All,
3441 StencilOnly,
3442 DepthOnly,
3443 Plane0Only,
3444 Plane1Only,
3445 Plane2Only,
3446 }
3447 impl From<ffi::WGPUTextureAspect> for TextureAspect {
3448 fn from(value: ffi::WGPUTextureAspect) -> Self {
3449 match value {
3450 ffi::WGPUTextureAspect_WGPUTextureAspect_Undefined => {
3451 TextureAspect::Undefined
3452 }
3453 ffi::WGPUTextureAspect_WGPUTextureAspect_All => TextureAspect::All,
3454 ffi::WGPUTextureAspect_WGPUTextureAspect_StencilOnly => {
3455 TextureAspect::StencilOnly
3456 }
3457 ffi::WGPUTextureAspect_WGPUTextureAspect_DepthOnly => {
3458 TextureAspect::DepthOnly
3459 }
3460 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane0Only => {
3461 TextureAspect::Plane0Only
3462 }
3463 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane1Only => {
3464 TextureAspect::Plane1Only
3465 }
3466 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane2Only => {
3467 TextureAspect::Plane2Only
3468 }
3469 _ => TextureAspect::Undefined,
3470 }
3471 }
3472 }
3473 impl From<TextureAspect> for ffi::WGPUTextureAspect {
3474 fn from(value: TextureAspect) -> Self {
3475 match value {
3476 TextureAspect::Undefined => {
3477 ffi::WGPUTextureAspect_WGPUTextureAspect_Undefined
3478 }
3479 TextureAspect::All => ffi::WGPUTextureAspect_WGPUTextureAspect_All,
3480 TextureAspect::StencilOnly => {
3481 ffi::WGPUTextureAspect_WGPUTextureAspect_StencilOnly
3482 }
3483 TextureAspect::DepthOnly => {
3484 ffi::WGPUTextureAspect_WGPUTextureAspect_DepthOnly
3485 }
3486 TextureAspect::Plane0Only => {
3487 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane0Only
3488 }
3489 TextureAspect::Plane1Only => {
3490 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane1Only
3491 }
3492 TextureAspect::Plane2Only => {
3493 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane2Only
3494 }
3495 }
3496 }
3497 }
3498 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3499 pub enum TextureDimension {
3500 Undefined,
3501 D1,
3502 D2,
3503 D3,
3504 }
3505 impl From<ffi::WGPUTextureDimension> for TextureDimension {
3506 fn from(value: ffi::WGPUTextureDimension) -> Self {
3507 match value {
3508 ffi::WGPUTextureDimension_WGPUTextureDimension_Undefined => {
3509 TextureDimension::Undefined
3510 }
3511 ffi::WGPUTextureDimension_WGPUTextureDimension_1D => TextureDimension::D1,
3512 ffi::WGPUTextureDimension_WGPUTextureDimension_2D => TextureDimension::D2,
3513 ffi::WGPUTextureDimension_WGPUTextureDimension_3D => TextureDimension::D3,
3514 _ => TextureDimension::Undefined,
3515 }
3516 }
3517 }
3518 impl From<TextureDimension> for ffi::WGPUTextureDimension {
3519 fn from(value: TextureDimension) -> Self {
3520 match value {
3521 TextureDimension::Undefined => {
3522 ffi::WGPUTextureDimension_WGPUTextureDimension_Undefined
3523 }
3524 TextureDimension::D1 => ffi::WGPUTextureDimension_WGPUTextureDimension_1D,
3525 TextureDimension::D2 => ffi::WGPUTextureDimension_WGPUTextureDimension_2D,
3526 TextureDimension::D3 => ffi::WGPUTextureDimension_WGPUTextureDimension_3D,
3527 }
3528 }
3529 }
3530 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3531 pub enum TextureFormat {
3532 Undefined,
3533 R8Unorm,
3534 R8Snorm,
3535 R8Uint,
3536 R8Sint,
3537 R16Unorm,
3538 R16Snorm,
3539 R16Uint,
3540 R16Sint,
3541 R16Float,
3542 Rg8Unorm,
3543 Rg8Snorm,
3544 Rg8Uint,
3545 Rg8Sint,
3546 R32Float,
3547 R32Uint,
3548 R32Sint,
3549 Rg16Unorm,
3550 Rg16Snorm,
3551 Rg16Uint,
3552 Rg16Sint,
3553 Rg16Float,
3554 Rgba8Unorm,
3555 Rgba8UnormSrgb,
3556 Rgba8Snorm,
3557 Rgba8Uint,
3558 Rgba8Sint,
3559 Bgra8Unorm,
3560 Bgra8UnormSrgb,
3561 Rgb10A2Uint,
3562 Rgb10A2Unorm,
3563 Rg11B10Ufloat,
3564 Rgb9E5Ufloat,
3565 Rg32Float,
3566 Rg32Uint,
3567 Rg32Sint,
3568 Rgba16Unorm,
3569 Rgba16Snorm,
3570 Rgba16Uint,
3571 Rgba16Sint,
3572 Rgba16Float,
3573 Rgba32Float,
3574 Rgba32Uint,
3575 Rgba32Sint,
3576 Stencil8,
3577 Depth16Unorm,
3578 Depth24Plus,
3579 Depth24PlusStencil8,
3580 Depth32Float,
3581 Depth32FloatStencil8,
3582 Bc1RgbaUnorm,
3583 Bc1RgbaUnormSrgb,
3584 Bc2RgbaUnorm,
3585 Bc2RgbaUnormSrgb,
3586 Bc3RgbaUnorm,
3587 Bc3RgbaUnormSrgb,
3588 Bc4RUnorm,
3589 Bc4RSnorm,
3590 Bc5RgUnorm,
3591 Bc5RgSnorm,
3592 Bc6HRgbUfloat,
3593 Bc6HRgbFloat,
3594 Bc7RgbaUnorm,
3595 Bc7RgbaUnormSrgb,
3596 Etc2Rgb8Unorm,
3597 Etc2Rgb8UnormSrgb,
3598 Etc2Rgb8A1Unorm,
3599 Etc2Rgb8A1UnormSrgb,
3600 Etc2Rgba8Unorm,
3601 Etc2Rgba8UnormSrgb,
3602 EacR11Unorm,
3603 EacR11Snorm,
3604 EacRg11Unorm,
3605 EacRg11Snorm,
3606 Astc4X4Unorm,
3607 Astc4X4UnormSrgb,
3608 Astc5X4Unorm,
3609 Astc5X4UnormSrgb,
3610 Astc5X5Unorm,
3611 Astc5X5UnormSrgb,
3612 Astc6X5Unorm,
3613 Astc6X5UnormSrgb,
3614 Astc6X6Unorm,
3615 Astc6X6UnormSrgb,
3616 Astc8X5Unorm,
3617 Astc8X5UnormSrgb,
3618 Astc8X6Unorm,
3619 Astc8X6UnormSrgb,
3620 Astc8X8Unorm,
3621 Astc8X8UnormSrgb,
3622 Astc10X5Unorm,
3623 Astc10X5UnormSrgb,
3624 Astc10X6Unorm,
3625 Astc10X6UnormSrgb,
3626 Astc10X8Unorm,
3627 Astc10X8UnormSrgb,
3628 Astc10X10Unorm,
3629 Astc10X10UnormSrgb,
3630 Astc12X10Unorm,
3631 Astc12X10UnormSrgb,
3632 Astc12X12Unorm,
3633 Astc12X12UnormSrgb,
3634 R8Bg8Biplanar420Unorm,
3635 R10X6Bg10X6Biplanar420Unorm,
3636 R8Bg8A8Triplanar420Unorm,
3637 R8Bg8Biplanar422Unorm,
3638 R8Bg8Biplanar444Unorm,
3639 R10X6Bg10X6Biplanar422Unorm,
3640 R10X6Bg10X6Biplanar444Unorm,
3641 OpaqueYCbCrAndroid,
3642 }
3643 impl From<ffi::WGPUTextureFormat> for TextureFormat {
3644 fn from(value: ffi::WGPUTextureFormat) -> Self {
3645 match value {
3646 ffi::WGPUTextureFormat_WGPUTextureFormat_Undefined => {
3647 TextureFormat::Undefined
3648 }
3649 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Unorm => {
3650 TextureFormat::R8Unorm
3651 }
3652 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Snorm => {
3653 TextureFormat::R8Snorm
3654 }
3655 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Uint => TextureFormat::R8Uint,
3656 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Sint => TextureFormat::R8Sint,
3657 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Unorm => {
3658 TextureFormat::R16Unorm
3659 }
3660 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Snorm => {
3661 TextureFormat::R16Snorm
3662 }
3663 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Uint => {
3664 TextureFormat::R16Uint
3665 }
3666 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Sint => {
3667 TextureFormat::R16Sint
3668 }
3669 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Float => {
3670 TextureFormat::R16Float
3671 }
3672 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Unorm => {
3673 TextureFormat::Rg8Unorm
3674 }
3675 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Snorm => {
3676 TextureFormat::Rg8Snorm
3677 }
3678 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Uint => {
3679 TextureFormat::Rg8Uint
3680 }
3681 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Sint => {
3682 TextureFormat::Rg8Sint
3683 }
3684 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Float => {
3685 TextureFormat::R32Float
3686 }
3687 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Uint => {
3688 TextureFormat::R32Uint
3689 }
3690 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Sint => {
3691 TextureFormat::R32Sint
3692 }
3693 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Unorm => {
3694 TextureFormat::Rg16Unorm
3695 }
3696 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Snorm => {
3697 TextureFormat::Rg16Snorm
3698 }
3699 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Uint => {
3700 TextureFormat::Rg16Uint
3701 }
3702 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Sint => {
3703 TextureFormat::Rg16Sint
3704 }
3705 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Float => {
3706 TextureFormat::Rg16Float
3707 }
3708 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Unorm => {
3709 TextureFormat::Rgba8Unorm
3710 }
3711 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8UnormSrgb => {
3712 TextureFormat::Rgba8UnormSrgb
3713 }
3714 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Snorm => {
3715 TextureFormat::Rgba8Snorm
3716 }
3717 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Uint => {
3718 TextureFormat::Rgba8Uint
3719 }
3720 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Sint => {
3721 TextureFormat::Rgba8Sint
3722 }
3723 ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8Unorm => {
3724 TextureFormat::Bgra8Unorm
3725 }
3726 ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8UnormSrgb => {
3727 TextureFormat::Bgra8UnormSrgb
3728 }
3729 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Uint => {
3730 TextureFormat::Rgb10A2Uint
3731 }
3732 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Unorm => {
3733 TextureFormat::Rgb10A2Unorm
3734 }
3735 ffi::WGPUTextureFormat_WGPUTextureFormat_RG11B10Ufloat => {
3736 TextureFormat::Rg11B10Ufloat
3737 }
3738 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB9E5Ufloat => {
3739 TextureFormat::Rgb9E5Ufloat
3740 }
3741 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Float => {
3742 TextureFormat::Rg32Float
3743 }
3744 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Uint => {
3745 TextureFormat::Rg32Uint
3746 }
3747 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Sint => {
3748 TextureFormat::Rg32Sint
3749 }
3750 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Unorm => {
3751 TextureFormat::Rgba16Unorm
3752 }
3753 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Snorm => {
3754 TextureFormat::Rgba16Snorm
3755 }
3756 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Uint => {
3757 TextureFormat::Rgba16Uint
3758 }
3759 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Sint => {
3760 TextureFormat::Rgba16Sint
3761 }
3762 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Float => {
3763 TextureFormat::Rgba16Float
3764 }
3765 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Float => {
3766 TextureFormat::Rgba32Float
3767 }
3768 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Uint => {
3769 TextureFormat::Rgba32Uint
3770 }
3771 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Sint => {
3772 TextureFormat::Rgba32Sint
3773 }
3774 ffi::WGPUTextureFormat_WGPUTextureFormat_Stencil8 => {
3775 TextureFormat::Stencil8
3776 }
3777 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth16Unorm => {
3778 TextureFormat::Depth16Unorm
3779 }
3780 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24Plus => {
3781 TextureFormat::Depth24Plus
3782 }
3783 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24PlusStencil8 => {
3784 TextureFormat::Depth24PlusStencil8
3785 }
3786 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32Float => {
3787 TextureFormat::Depth32Float
3788 }
3789 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32FloatStencil8 => {
3790 TextureFormat::Depth32FloatStencil8
3791 }
3792 ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnorm => {
3793 TextureFormat::Bc1RgbaUnorm
3794 }
3795 ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnormSrgb => {
3796 TextureFormat::Bc1RgbaUnormSrgb
3797 }
3798 ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnorm => {
3799 TextureFormat::Bc2RgbaUnorm
3800 }
3801 ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnormSrgb => {
3802 TextureFormat::Bc2RgbaUnormSrgb
3803 }
3804 ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnorm => {
3805 TextureFormat::Bc3RgbaUnorm
3806 }
3807 ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnormSrgb => {
3808 TextureFormat::Bc3RgbaUnormSrgb
3809 }
3810 ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RUnorm => {
3811 TextureFormat::Bc4RUnorm
3812 }
3813 ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RSnorm => {
3814 TextureFormat::Bc4RSnorm
3815 }
3816 ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGUnorm => {
3817 TextureFormat::Bc5RgUnorm
3818 }
3819 ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGSnorm => {
3820 TextureFormat::Bc5RgSnorm
3821 }
3822 ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBUfloat => {
3823 TextureFormat::Bc6HRgbUfloat
3824 }
3825 ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBFloat => {
3826 TextureFormat::Bc6HRgbFloat
3827 }
3828 ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnorm => {
3829 TextureFormat::Bc7RgbaUnorm
3830 }
3831 ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnormSrgb => {
3832 TextureFormat::Bc7RgbaUnormSrgb
3833 }
3834 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8Unorm => {
3835 TextureFormat::Etc2Rgb8Unorm
3836 }
3837 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8UnormSrgb => {
3838 TextureFormat::Etc2Rgb8UnormSrgb
3839 }
3840 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1Unorm => {
3841 TextureFormat::Etc2Rgb8A1Unorm
3842 }
3843 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1UnormSrgb => {
3844 TextureFormat::Etc2Rgb8A1UnormSrgb
3845 }
3846 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8Unorm => {
3847 TextureFormat::Etc2Rgba8Unorm
3848 }
3849 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8UnormSrgb => {
3850 TextureFormat::Etc2Rgba8UnormSrgb
3851 }
3852 ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Unorm => {
3853 TextureFormat::EacR11Unorm
3854 }
3855 ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Snorm => {
3856 TextureFormat::EacR11Snorm
3857 }
3858 ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Unorm => {
3859 TextureFormat::EacRg11Unorm
3860 }
3861 ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Snorm => {
3862 TextureFormat::EacRg11Snorm
3863 }
3864 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4Unorm => {
3865 TextureFormat::Astc4X4Unorm
3866 }
3867 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4UnormSrgb => {
3868 TextureFormat::Astc4X4UnormSrgb
3869 }
3870 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4Unorm => {
3871 TextureFormat::Astc5X4Unorm
3872 }
3873 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4UnormSrgb => {
3874 TextureFormat::Astc5X4UnormSrgb
3875 }
3876 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5Unorm => {
3877 TextureFormat::Astc5X5Unorm
3878 }
3879 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5UnormSrgb => {
3880 TextureFormat::Astc5X5UnormSrgb
3881 }
3882 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5Unorm => {
3883 TextureFormat::Astc6X5Unorm
3884 }
3885 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5UnormSrgb => {
3886 TextureFormat::Astc6X5UnormSrgb
3887 }
3888 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6Unorm => {
3889 TextureFormat::Astc6X6Unorm
3890 }
3891 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6UnormSrgb => {
3892 TextureFormat::Astc6X6UnormSrgb
3893 }
3894 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5Unorm => {
3895 TextureFormat::Astc8X5Unorm
3896 }
3897 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5UnormSrgb => {
3898 TextureFormat::Astc8X5UnormSrgb
3899 }
3900 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6Unorm => {
3901 TextureFormat::Astc8X6Unorm
3902 }
3903 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6UnormSrgb => {
3904 TextureFormat::Astc8X6UnormSrgb
3905 }
3906 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8Unorm => {
3907 TextureFormat::Astc8X8Unorm
3908 }
3909 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8UnormSrgb => {
3910 TextureFormat::Astc8X8UnormSrgb
3911 }
3912 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5Unorm => {
3913 TextureFormat::Astc10X5Unorm
3914 }
3915 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5UnormSrgb => {
3916 TextureFormat::Astc10X5UnormSrgb
3917 }
3918 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6Unorm => {
3919 TextureFormat::Astc10X6Unorm
3920 }
3921 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6UnormSrgb => {
3922 TextureFormat::Astc10X6UnormSrgb
3923 }
3924 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8Unorm => {
3925 TextureFormat::Astc10X8Unorm
3926 }
3927 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8UnormSrgb => {
3928 TextureFormat::Astc10X8UnormSrgb
3929 }
3930 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10Unorm => {
3931 TextureFormat::Astc10X10Unorm
3932 }
3933 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10UnormSrgb => {
3934 TextureFormat::Astc10X10UnormSrgb
3935 }
3936 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10Unorm => {
3937 TextureFormat::Astc12X10Unorm
3938 }
3939 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10UnormSrgb => {
3940 TextureFormat::Astc12X10UnormSrgb
3941 }
3942 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12Unorm => {
3943 TextureFormat::Astc12X12Unorm
3944 }
3945 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12UnormSrgb => {
3946 TextureFormat::Astc12X12UnormSrgb
3947 }
3948 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar420Unorm => {
3949 TextureFormat::R8Bg8Biplanar420Unorm
3950 }
3951 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar420Unorm => {
3952 TextureFormat::R10X6Bg10X6Biplanar420Unorm
3953 }
3954 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8A8Triplanar420Unorm => {
3955 TextureFormat::R8Bg8A8Triplanar420Unorm
3956 }
3957 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar422Unorm => {
3958 TextureFormat::R8Bg8Biplanar422Unorm
3959 }
3960 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar444Unorm => {
3961 TextureFormat::R8Bg8Biplanar444Unorm
3962 }
3963 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar422Unorm => {
3964 TextureFormat::R10X6Bg10X6Biplanar422Unorm
3965 }
3966 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar444Unorm => {
3967 TextureFormat::R10X6Bg10X6Biplanar444Unorm
3968 }
3969 ffi::WGPUTextureFormat_WGPUTextureFormat_OpaqueYCbCrAndroid => {
3970 TextureFormat::OpaqueYCbCrAndroid
3971 }
3972 _ => TextureFormat::Undefined,
3973 }
3974 }
3975 }
3976 impl From<TextureFormat> for ffi::WGPUTextureFormat {
3977 fn from(value: TextureFormat) -> Self {
3978 match value {
3979 TextureFormat::Undefined => {
3980 ffi::WGPUTextureFormat_WGPUTextureFormat_Undefined
3981 }
3982 TextureFormat::R8Unorm => {
3983 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Unorm
3984 }
3985 TextureFormat::R8Snorm => {
3986 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Snorm
3987 }
3988 TextureFormat::R8Uint => ffi::WGPUTextureFormat_WGPUTextureFormat_R8Uint,
3989 TextureFormat::R8Sint => ffi::WGPUTextureFormat_WGPUTextureFormat_R8Sint,
3990 TextureFormat::R16Unorm => {
3991 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Unorm
3992 }
3993 TextureFormat::R16Snorm => {
3994 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Snorm
3995 }
3996 TextureFormat::R16Uint => {
3997 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Uint
3998 }
3999 TextureFormat::R16Sint => {
4000 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Sint
4001 }
4002 TextureFormat::R16Float => {
4003 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Float
4004 }
4005 TextureFormat::Rg8Unorm => {
4006 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Unorm
4007 }
4008 TextureFormat::Rg8Snorm => {
4009 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Snorm
4010 }
4011 TextureFormat::Rg8Uint => {
4012 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Uint
4013 }
4014 TextureFormat::Rg8Sint => {
4015 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Sint
4016 }
4017 TextureFormat::R32Float => {
4018 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Float
4019 }
4020 TextureFormat::R32Uint => {
4021 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Uint
4022 }
4023 TextureFormat::R32Sint => {
4024 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Sint
4025 }
4026 TextureFormat::Rg16Unorm => {
4027 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Unorm
4028 }
4029 TextureFormat::Rg16Snorm => {
4030 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Snorm
4031 }
4032 TextureFormat::Rg16Uint => {
4033 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Uint
4034 }
4035 TextureFormat::Rg16Sint => {
4036 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Sint
4037 }
4038 TextureFormat::Rg16Float => {
4039 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Float
4040 }
4041 TextureFormat::Rgba8Unorm => {
4042 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Unorm
4043 }
4044 TextureFormat::Rgba8UnormSrgb => {
4045 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8UnormSrgb
4046 }
4047 TextureFormat::Rgba8Snorm => {
4048 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Snorm
4049 }
4050 TextureFormat::Rgba8Uint => {
4051 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Uint
4052 }
4053 TextureFormat::Rgba8Sint => {
4054 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Sint
4055 }
4056 TextureFormat::Bgra8Unorm => {
4057 ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8Unorm
4058 }
4059 TextureFormat::Bgra8UnormSrgb => {
4060 ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8UnormSrgb
4061 }
4062 TextureFormat::Rgb10A2Uint => {
4063 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Uint
4064 }
4065 TextureFormat::Rgb10A2Unorm => {
4066 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Unorm
4067 }
4068 TextureFormat::Rg11B10Ufloat => {
4069 ffi::WGPUTextureFormat_WGPUTextureFormat_RG11B10Ufloat
4070 }
4071 TextureFormat::Rgb9E5Ufloat => {
4072 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB9E5Ufloat
4073 }
4074 TextureFormat::Rg32Float => {
4075 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Float
4076 }
4077 TextureFormat::Rg32Uint => {
4078 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Uint
4079 }
4080 TextureFormat::Rg32Sint => {
4081 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Sint
4082 }
4083 TextureFormat::Rgba16Unorm => {
4084 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Unorm
4085 }
4086 TextureFormat::Rgba16Snorm => {
4087 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Snorm
4088 }
4089 TextureFormat::Rgba16Uint => {
4090 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Uint
4091 }
4092 TextureFormat::Rgba16Sint => {
4093 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Sint
4094 }
4095 TextureFormat::Rgba16Float => {
4096 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Float
4097 }
4098 TextureFormat::Rgba32Float => {
4099 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Float
4100 }
4101 TextureFormat::Rgba32Uint => {
4102 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Uint
4103 }
4104 TextureFormat::Rgba32Sint => {
4105 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Sint
4106 }
4107 TextureFormat::Stencil8 => {
4108 ffi::WGPUTextureFormat_WGPUTextureFormat_Stencil8
4109 }
4110 TextureFormat::Depth16Unorm => {
4111 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth16Unorm
4112 }
4113 TextureFormat::Depth24Plus => {
4114 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24Plus
4115 }
4116 TextureFormat::Depth24PlusStencil8 => {
4117 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24PlusStencil8
4118 }
4119 TextureFormat::Depth32Float => {
4120 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32Float
4121 }
4122 TextureFormat::Depth32FloatStencil8 => {
4123 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32FloatStencil8
4124 }
4125 TextureFormat::Bc1RgbaUnorm => {
4126 ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnorm
4127 }
4128 TextureFormat::Bc1RgbaUnormSrgb => {
4129 ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnormSrgb
4130 }
4131 TextureFormat::Bc2RgbaUnorm => {
4132 ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnorm
4133 }
4134 TextureFormat::Bc2RgbaUnormSrgb => {
4135 ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnormSrgb
4136 }
4137 TextureFormat::Bc3RgbaUnorm => {
4138 ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnorm
4139 }
4140 TextureFormat::Bc3RgbaUnormSrgb => {
4141 ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnormSrgb
4142 }
4143 TextureFormat::Bc4RUnorm => {
4144 ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RUnorm
4145 }
4146 TextureFormat::Bc4RSnorm => {
4147 ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RSnorm
4148 }
4149 TextureFormat::Bc5RgUnorm => {
4150 ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGUnorm
4151 }
4152 TextureFormat::Bc5RgSnorm => {
4153 ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGSnorm
4154 }
4155 TextureFormat::Bc6HRgbUfloat => {
4156 ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBUfloat
4157 }
4158 TextureFormat::Bc6HRgbFloat => {
4159 ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBFloat
4160 }
4161 TextureFormat::Bc7RgbaUnorm => {
4162 ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnorm
4163 }
4164 TextureFormat::Bc7RgbaUnormSrgb => {
4165 ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnormSrgb
4166 }
4167 TextureFormat::Etc2Rgb8Unorm => {
4168 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8Unorm
4169 }
4170 TextureFormat::Etc2Rgb8UnormSrgb => {
4171 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8UnormSrgb
4172 }
4173 TextureFormat::Etc2Rgb8A1Unorm => {
4174 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1Unorm
4175 }
4176 TextureFormat::Etc2Rgb8A1UnormSrgb => {
4177 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1UnormSrgb
4178 }
4179 TextureFormat::Etc2Rgba8Unorm => {
4180 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8Unorm
4181 }
4182 TextureFormat::Etc2Rgba8UnormSrgb => {
4183 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8UnormSrgb
4184 }
4185 TextureFormat::EacR11Unorm => {
4186 ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Unorm
4187 }
4188 TextureFormat::EacR11Snorm => {
4189 ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Snorm
4190 }
4191 TextureFormat::EacRg11Unorm => {
4192 ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Unorm
4193 }
4194 TextureFormat::EacRg11Snorm => {
4195 ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Snorm
4196 }
4197 TextureFormat::Astc4X4Unorm => {
4198 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4Unorm
4199 }
4200 TextureFormat::Astc4X4UnormSrgb => {
4201 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4UnormSrgb
4202 }
4203 TextureFormat::Astc5X4Unorm => {
4204 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4Unorm
4205 }
4206 TextureFormat::Astc5X4UnormSrgb => {
4207 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4UnormSrgb
4208 }
4209 TextureFormat::Astc5X5Unorm => {
4210 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5Unorm
4211 }
4212 TextureFormat::Astc5X5UnormSrgb => {
4213 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5UnormSrgb
4214 }
4215 TextureFormat::Astc6X5Unorm => {
4216 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5Unorm
4217 }
4218 TextureFormat::Astc6X5UnormSrgb => {
4219 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5UnormSrgb
4220 }
4221 TextureFormat::Astc6X6Unorm => {
4222 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6Unorm
4223 }
4224 TextureFormat::Astc6X6UnormSrgb => {
4225 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6UnormSrgb
4226 }
4227 TextureFormat::Astc8X5Unorm => {
4228 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5Unorm
4229 }
4230 TextureFormat::Astc8X5UnormSrgb => {
4231 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5UnormSrgb
4232 }
4233 TextureFormat::Astc8X6Unorm => {
4234 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6Unorm
4235 }
4236 TextureFormat::Astc8X6UnormSrgb => {
4237 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6UnormSrgb
4238 }
4239 TextureFormat::Astc8X8Unorm => {
4240 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8Unorm
4241 }
4242 TextureFormat::Astc8X8UnormSrgb => {
4243 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8UnormSrgb
4244 }
4245 TextureFormat::Astc10X5Unorm => {
4246 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5Unorm
4247 }
4248 TextureFormat::Astc10X5UnormSrgb => {
4249 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5UnormSrgb
4250 }
4251 TextureFormat::Astc10X6Unorm => {
4252 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6Unorm
4253 }
4254 TextureFormat::Astc10X6UnormSrgb => {
4255 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6UnormSrgb
4256 }
4257 TextureFormat::Astc10X8Unorm => {
4258 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8Unorm
4259 }
4260 TextureFormat::Astc10X8UnormSrgb => {
4261 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8UnormSrgb
4262 }
4263 TextureFormat::Astc10X10Unorm => {
4264 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10Unorm
4265 }
4266 TextureFormat::Astc10X10UnormSrgb => {
4267 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10UnormSrgb
4268 }
4269 TextureFormat::Astc12X10Unorm => {
4270 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10Unorm
4271 }
4272 TextureFormat::Astc12X10UnormSrgb => {
4273 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10UnormSrgb
4274 }
4275 TextureFormat::Astc12X12Unorm => {
4276 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12Unorm
4277 }
4278 TextureFormat::Astc12X12UnormSrgb => {
4279 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12UnormSrgb
4280 }
4281 TextureFormat::R8Bg8Biplanar420Unorm => {
4282 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar420Unorm
4283 }
4284 TextureFormat::R10X6Bg10X6Biplanar420Unorm => {
4285 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar420Unorm
4286 }
4287 TextureFormat::R8Bg8A8Triplanar420Unorm => {
4288 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8A8Triplanar420Unorm
4289 }
4290 TextureFormat::R8Bg8Biplanar422Unorm => {
4291 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar422Unorm
4292 }
4293 TextureFormat::R8Bg8Biplanar444Unorm => {
4294 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar444Unorm
4295 }
4296 TextureFormat::R10X6Bg10X6Biplanar422Unorm => {
4297 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar422Unorm
4298 }
4299 TextureFormat::R10X6Bg10X6Biplanar444Unorm => {
4300 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar444Unorm
4301 }
4302 TextureFormat::OpaqueYCbCrAndroid => {
4303 ffi::WGPUTextureFormat_WGPUTextureFormat_OpaqueYCbCrAndroid
4304 }
4305 }
4306 }
4307 }
4308 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4309 pub enum TextureSampleType {
4310 BindingNotUsed,
4311 Undefined,
4312 Float,
4313 UnfilterableFloat,
4314 Depth,
4315 Sint,
4316 Uint,
4317 }
4318 impl From<ffi::WGPUTextureSampleType> for TextureSampleType {
4319 fn from(value: ffi::WGPUTextureSampleType) -> Self {
4320 match value {
4321 ffi::WGPUTextureSampleType_WGPUTextureSampleType_BindingNotUsed => {
4322 TextureSampleType::BindingNotUsed
4323 }
4324 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Undefined => {
4325 TextureSampleType::Undefined
4326 }
4327 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Float => {
4328 TextureSampleType::Float
4329 }
4330 ffi::WGPUTextureSampleType_WGPUTextureSampleType_UnfilterableFloat => {
4331 TextureSampleType::UnfilterableFloat
4332 }
4333 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Depth => {
4334 TextureSampleType::Depth
4335 }
4336 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Sint => {
4337 TextureSampleType::Sint
4338 }
4339 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Uint => {
4340 TextureSampleType::Uint
4341 }
4342 _ => TextureSampleType::BindingNotUsed,
4343 }
4344 }
4345 }
4346 impl From<TextureSampleType> for ffi::WGPUTextureSampleType {
4347 fn from(value: TextureSampleType) -> Self {
4348 match value {
4349 TextureSampleType::BindingNotUsed => {
4350 ffi::WGPUTextureSampleType_WGPUTextureSampleType_BindingNotUsed
4351 }
4352 TextureSampleType::Undefined => {
4353 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Undefined
4354 }
4355 TextureSampleType::Float => {
4356 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Float
4357 }
4358 TextureSampleType::UnfilterableFloat => {
4359 ffi::WGPUTextureSampleType_WGPUTextureSampleType_UnfilterableFloat
4360 }
4361 TextureSampleType::Depth => {
4362 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Depth
4363 }
4364 TextureSampleType::Sint => {
4365 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Sint
4366 }
4367 TextureSampleType::Uint => {
4368 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Uint
4369 }
4370 }
4371 }
4372 }
4373 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4374 pub enum TextureViewDimension {
4375 Undefined,
4376 D1,
4377 D2,
4378 D2Array,
4379 Cube,
4380 CubeArray,
4381 D3,
4382 }
4383 impl From<ffi::WGPUTextureViewDimension> for TextureViewDimension {
4384 fn from(value: ffi::WGPUTextureViewDimension) -> Self {
4385 match value {
4386 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Undefined => {
4387 TextureViewDimension::Undefined
4388 }
4389 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_1D => {
4390 TextureViewDimension::D1
4391 }
4392 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2D => {
4393 TextureViewDimension::D2
4394 }
4395 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2DArray => {
4396 TextureViewDimension::D2Array
4397 }
4398 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Cube => {
4399 TextureViewDimension::Cube
4400 }
4401 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_CubeArray => {
4402 TextureViewDimension::CubeArray
4403 }
4404 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_3D => {
4405 TextureViewDimension::D3
4406 }
4407 _ => TextureViewDimension::Undefined,
4408 }
4409 }
4410 }
4411 impl From<TextureViewDimension> for ffi::WGPUTextureViewDimension {
4412 fn from(value: TextureViewDimension) -> Self {
4413 match value {
4414 TextureViewDimension::Undefined => {
4415 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Undefined
4416 }
4417 TextureViewDimension::D1 => {
4418 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_1D
4419 }
4420 TextureViewDimension::D2 => {
4421 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2D
4422 }
4423 TextureViewDimension::D2Array => {
4424 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2DArray
4425 }
4426 TextureViewDimension::Cube => {
4427 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Cube
4428 }
4429 TextureViewDimension::CubeArray => {
4430 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_CubeArray
4431 }
4432 TextureViewDimension::D3 => {
4433 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_3D
4434 }
4435 }
4436 }
4437 }
4438 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4439 pub enum ToneMappingMode {
4440 Standard,
4441 Extended,
4442 }
4443 impl From<ffi::WGPUToneMappingMode> for ToneMappingMode {
4444 fn from(value: ffi::WGPUToneMappingMode) -> Self {
4445 match value {
4446 ffi::WGPUToneMappingMode_WGPUToneMappingMode_Standard => {
4447 ToneMappingMode::Standard
4448 }
4449 ffi::WGPUToneMappingMode_WGPUToneMappingMode_Extended => {
4450 ToneMappingMode::Extended
4451 }
4452 _ => ToneMappingMode::Standard,
4453 }
4454 }
4455 }
4456 impl From<ToneMappingMode> for ffi::WGPUToneMappingMode {
4457 fn from(value: ToneMappingMode) -> Self {
4458 match value {
4459 ToneMappingMode::Standard => {
4460 ffi::WGPUToneMappingMode_WGPUToneMappingMode_Standard
4461 }
4462 ToneMappingMode::Extended => {
4463 ffi::WGPUToneMappingMode_WGPUToneMappingMode_Extended
4464 }
4465 }
4466 }
4467 }
4468 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4469 pub enum VertexFormat {
4470 Uint8,
4471 Uint8X2,
4472 Uint8X4,
4473 Sint8,
4474 Sint8X2,
4475 Sint8X4,
4476 Unorm8,
4477 Unorm8X2,
4478 Unorm8X4,
4479 Snorm8,
4480 Snorm8X2,
4481 Snorm8X4,
4482 Uint16,
4483 Uint16X2,
4484 Uint16X4,
4485 Sint16,
4486 Sint16X2,
4487 Sint16X4,
4488 Unorm16,
4489 Unorm16X2,
4490 Unorm16X4,
4491 Snorm16,
4492 Snorm16X2,
4493 Snorm16X4,
4494 Float16,
4495 Float16X2,
4496 Float16X4,
4497 Float32,
4498 Float32X2,
4499 Float32X3,
4500 Float32X4,
4501 Uint32,
4502 Uint32X2,
4503 Uint32X3,
4504 Uint32X4,
4505 Sint32,
4506 Sint32X2,
4507 Sint32X3,
4508 Sint32X4,
4509 Unorm1010102,
4510 Unorm8X4Bgra,
4511 }
4512 impl From<ffi::WGPUVertexFormat> for VertexFormat {
4513 fn from(value: ffi::WGPUVertexFormat) -> Self {
4514 match value {
4515 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8 => VertexFormat::Uint8,
4516 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x2 => VertexFormat::Uint8X2,
4517 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x4 => VertexFormat::Uint8X4,
4518 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8 => VertexFormat::Sint8,
4519 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x2 => VertexFormat::Sint8X2,
4520 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x4 => VertexFormat::Sint8X4,
4521 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8 => VertexFormat::Unorm8,
4522 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x2 => VertexFormat::Unorm8X2,
4523 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4 => VertexFormat::Unorm8X4,
4524 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8 => VertexFormat::Snorm8,
4525 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x2 => VertexFormat::Snorm8X2,
4526 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x4 => VertexFormat::Snorm8X4,
4527 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16 => VertexFormat::Uint16,
4528 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x2 => VertexFormat::Uint16X2,
4529 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x4 => VertexFormat::Uint16X4,
4530 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16 => VertexFormat::Sint16,
4531 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x2 => VertexFormat::Sint16X2,
4532 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x4 => VertexFormat::Sint16X4,
4533 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16 => VertexFormat::Unorm16,
4534 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x2 => {
4535 VertexFormat::Unorm16X2
4536 }
4537 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x4 => {
4538 VertexFormat::Unorm16X4
4539 }
4540 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16 => VertexFormat::Snorm16,
4541 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x2 => {
4542 VertexFormat::Snorm16X2
4543 }
4544 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x4 => {
4545 VertexFormat::Snorm16X4
4546 }
4547 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16 => VertexFormat::Float16,
4548 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x2 => {
4549 VertexFormat::Float16X2
4550 }
4551 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x4 => {
4552 VertexFormat::Float16X4
4553 }
4554 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32 => VertexFormat::Float32,
4555 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x2 => {
4556 VertexFormat::Float32X2
4557 }
4558 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x3 => {
4559 VertexFormat::Float32X3
4560 }
4561 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x4 => {
4562 VertexFormat::Float32X4
4563 }
4564 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32 => VertexFormat::Uint32,
4565 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x2 => VertexFormat::Uint32X2,
4566 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x3 => VertexFormat::Uint32X3,
4567 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x4 => VertexFormat::Uint32X4,
4568 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32 => VertexFormat::Sint32,
4569 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x2 => VertexFormat::Sint32X2,
4570 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x3 => VertexFormat::Sint32X3,
4571 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x4 => VertexFormat::Sint32X4,
4572 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm10_10_10_2 => {
4573 VertexFormat::Unorm1010102
4574 }
4575 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4BGRA => {
4576 VertexFormat::Unorm8X4Bgra
4577 }
4578 _ => VertexFormat::Uint8,
4579 }
4580 }
4581 }
4582 impl From<VertexFormat> for ffi::WGPUVertexFormat {
4583 fn from(value: VertexFormat) -> Self {
4584 match value {
4585 VertexFormat::Uint8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8,
4586 VertexFormat::Uint8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x2,
4587 VertexFormat::Uint8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x4,
4588 VertexFormat::Sint8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8,
4589 VertexFormat::Sint8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x2,
4590 VertexFormat::Sint8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x4,
4591 VertexFormat::Unorm8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8,
4592 VertexFormat::Unorm8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x2,
4593 VertexFormat::Unorm8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4,
4594 VertexFormat::Snorm8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8,
4595 VertexFormat::Snorm8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x2,
4596 VertexFormat::Snorm8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x4,
4597 VertexFormat::Uint16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16,
4598 VertexFormat::Uint16X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x2,
4599 VertexFormat::Uint16X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x4,
4600 VertexFormat::Sint16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16,
4601 VertexFormat::Sint16X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x2,
4602 VertexFormat::Sint16X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x4,
4603 VertexFormat::Unorm16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16,
4604 VertexFormat::Unorm16X2 => {
4605 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x2
4606 }
4607 VertexFormat::Unorm16X4 => {
4608 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x4
4609 }
4610 VertexFormat::Snorm16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16,
4611 VertexFormat::Snorm16X2 => {
4612 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x2
4613 }
4614 VertexFormat::Snorm16X4 => {
4615 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x4
4616 }
4617 VertexFormat::Float16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Float16,
4618 VertexFormat::Float16X2 => {
4619 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x2
4620 }
4621 VertexFormat::Float16X4 => {
4622 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x4
4623 }
4624 VertexFormat::Float32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Float32,
4625 VertexFormat::Float32X2 => {
4626 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x2
4627 }
4628 VertexFormat::Float32X3 => {
4629 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x3
4630 }
4631 VertexFormat::Float32X4 => {
4632 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x4
4633 }
4634 VertexFormat::Uint32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32,
4635 VertexFormat::Uint32X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x2,
4636 VertexFormat::Uint32X3 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x3,
4637 VertexFormat::Uint32X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x4,
4638 VertexFormat::Sint32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32,
4639 VertexFormat::Sint32X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x2,
4640 VertexFormat::Sint32X3 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x3,
4641 VertexFormat::Sint32X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x4,
4642 VertexFormat::Unorm1010102 => {
4643 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm10_10_10_2
4644 }
4645 VertexFormat::Unorm8X4Bgra => {
4646 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4BGRA
4647 }
4648 }
4649 }
4650 }
4651 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4652 pub enum VertexStepMode {
4653 Undefined,
4654 Vertex,
4655 Instance,
4656 }
4657 impl From<ffi::WGPUVertexStepMode> for VertexStepMode {
4658 fn from(value: ffi::WGPUVertexStepMode) -> Self {
4659 match value {
4660 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Undefined => {
4661 VertexStepMode::Undefined
4662 }
4663 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Vertex => {
4664 VertexStepMode::Vertex
4665 }
4666 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Instance => {
4667 VertexStepMode::Instance
4668 }
4669 _ => VertexStepMode::Undefined,
4670 }
4671 }
4672 }
4673 impl From<VertexStepMode> for ffi::WGPUVertexStepMode {
4674 fn from(value: VertexStepMode) -> Self {
4675 match value {
4676 VertexStepMode::Undefined => {
4677 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Undefined
4678 }
4679 VertexStepMode::Vertex => {
4680 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Vertex
4681 }
4682 VertexStepMode::Instance => {
4683 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Instance
4684 }
4685 }
4686 }
4687 }
4688 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4689 pub enum WaitStatus {
4690 Success,
4691 TimedOut,
4692 Error,
4693 }
4694 impl From<ffi::WGPUWaitStatus> for WaitStatus {
4695 fn from(value: ffi::WGPUWaitStatus) -> Self {
4696 match value {
4697 ffi::WGPUWaitStatus_WGPUWaitStatus_Success => WaitStatus::Success,
4698 ffi::WGPUWaitStatus_WGPUWaitStatus_TimedOut => WaitStatus::TimedOut,
4699 ffi::WGPUWaitStatus_WGPUWaitStatus_Error => WaitStatus::Error,
4700 _ => WaitStatus::Success,
4701 }
4702 }
4703 }
4704 impl From<WaitStatus> for ffi::WGPUWaitStatus {
4705 fn from(value: WaitStatus) -> Self {
4706 match value {
4707 WaitStatus::Success => ffi::WGPUWaitStatus_WGPUWaitStatus_Success,
4708 WaitStatus::TimedOut => ffi::WGPUWaitStatus_WGPUWaitStatus_TimedOut,
4709 WaitStatus::Error => ffi::WGPUWaitStatus_WGPUWaitStatus_Error,
4710 }
4711 }
4712 }
4713 bitflags! {
4714 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct BufferUsage : u64 {
4715 const NONE = ffi::WGPUBufferUsage_None as u64; const MAP_READ =
4716 ffi::WGPUBufferUsage_MapRead as u64; const MAP_WRITE =
4717 ffi::WGPUBufferUsage_MapWrite as u64; const COPY_SRC =
4718 ffi::WGPUBufferUsage_CopySrc as u64; const COPY_DST =
4719 ffi::WGPUBufferUsage_CopyDst as u64; const INDEX = ffi::WGPUBufferUsage_Index as
4720 u64; const VERTEX = ffi::WGPUBufferUsage_Vertex as u64; const UNIFORM =
4721 ffi::WGPUBufferUsage_Uniform as u64; const STORAGE = ffi::WGPUBufferUsage_Storage
4722 as u64; const INDIRECT = ffi::WGPUBufferUsage_Indirect as u64; const
4723 QUERY_RESOLVE = ffi::WGPUBufferUsage_QueryResolve as u64; const TEXEL_BUFFER =
4724 ffi::WGPUBufferUsage_TexelBuffer as u64; }
4725 }
4726 impl From<ffi::WGPUBufferUsage> for BufferUsage {
4727 fn from(value: ffi::WGPUBufferUsage) -> Self {
4728 BufferUsage::from_bits_truncate(value as u64)
4729 }
4730 }
4731 impl From<BufferUsage> for ffi::WGPUBufferUsage {
4732 fn from(value: BufferUsage) -> Self {
4733 value.bits() as ffi::WGPUBufferUsage
4734 }
4735 }
4736 bitflags! {
4737 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ColorWriteMask :
4738 u64 { const NONE = ffi::WGPUColorWriteMask_None as u64; const RED =
4739 ffi::WGPUColorWriteMask_Red as u64; const GREEN = ffi::WGPUColorWriteMask_Green
4740 as u64; const BLUE = ffi::WGPUColorWriteMask_Blue as u64; const ALPHA =
4741 ffi::WGPUColorWriteMask_Alpha as u64; const ALL = ffi::WGPUColorWriteMask_All as
4742 u64; }
4743 }
4744 impl From<ffi::WGPUColorWriteMask> for ColorWriteMask {
4745 fn from(value: ffi::WGPUColorWriteMask) -> Self {
4746 ColorWriteMask::from_bits_truncate(value as u64)
4747 }
4748 }
4749 impl From<ColorWriteMask> for ffi::WGPUColorWriteMask {
4750 fn from(value: ColorWriteMask) -> Self {
4751 value.bits() as ffi::WGPUColorWriteMask
4752 }
4753 }
4754 bitflags! {
4755 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct HeapProperty : u64
4756 { const NONE = ffi::WGPUHeapProperty_None as u64; const DEVICE_LOCAL =
4757 ffi::WGPUHeapProperty_DeviceLocal as u64; const HOST_VISIBLE =
4758 ffi::WGPUHeapProperty_HostVisible as u64; const HOST_COHERENT =
4759 ffi::WGPUHeapProperty_HostCoherent as u64; const HOST_UNCACHED =
4760 ffi::WGPUHeapProperty_HostUncached as u64; const HOST_CACHED =
4761 ffi::WGPUHeapProperty_HostCached as u64; }
4762 }
4763 impl From<ffi::WGPUHeapProperty> for HeapProperty {
4764 fn from(value: ffi::WGPUHeapProperty) -> Self {
4765 HeapProperty::from_bits_truncate(value as u64)
4766 }
4767 }
4768 impl From<HeapProperty> for ffi::WGPUHeapProperty {
4769 fn from(value: HeapProperty) -> Self {
4770 value.bits() as ffi::WGPUHeapProperty
4771 }
4772 }
4773 bitflags! {
4774 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct MapMode : u64 {
4775 const NONE = ffi::WGPUMapMode_None as u64; const READ = ffi::WGPUMapMode_Read as
4776 u64; const WRITE = ffi::WGPUMapMode_Write as u64; }
4777 }
4778 impl From<ffi::WGPUMapMode> for MapMode {
4779 fn from(value: ffi::WGPUMapMode) -> Self {
4780 MapMode::from_bits_truncate(value as u64)
4781 }
4782 }
4783 impl From<MapMode> for ffi::WGPUMapMode {
4784 fn from(value: MapMode) -> Self {
4785 value.bits() as ffi::WGPUMapMode
4786 }
4787 }
4788 bitflags! {
4789 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ShaderStage : u64 {
4790 const NONE = ffi::WGPUShaderStage_None as u64; const VERTEX =
4791 ffi::WGPUShaderStage_Vertex as u64; const FRAGMENT =
4792 ffi::WGPUShaderStage_Fragment as u64; const COMPUTE =
4793 ffi::WGPUShaderStage_Compute as u64; }
4794 }
4795 impl From<ffi::WGPUShaderStage> for ShaderStage {
4796 fn from(value: ffi::WGPUShaderStage) -> Self {
4797 ShaderStage::from_bits_truncate(value as u64)
4798 }
4799 }
4800 impl From<ShaderStage> for ffi::WGPUShaderStage {
4801 fn from(value: ShaderStage) -> Self {
4802 value.bits() as ffi::WGPUShaderStage
4803 }
4804 }
4805 bitflags! {
4806 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct TextureUsage : u64
4807 { const NONE = ffi::WGPUTextureUsage_None as u64; const COPY_SRC =
4808 ffi::WGPUTextureUsage_CopySrc as u64; const COPY_DST =
4809 ffi::WGPUTextureUsage_CopyDst as u64; const TEXTURE_BINDING =
4810 ffi::WGPUTextureUsage_TextureBinding as u64; const STORAGE_BINDING =
4811 ffi::WGPUTextureUsage_StorageBinding as u64; const RENDER_ATTACHMENT =
4812 ffi::WGPUTextureUsage_RenderAttachment as u64; const TRANSIENT_ATTACHMENT =
4813 ffi::WGPUTextureUsage_TransientAttachment as u64; const STORAGE_ATTACHMENT =
4814 ffi::WGPUTextureUsage_StorageAttachment as u64; }
4815 }
4816 impl From<ffi::WGPUTextureUsage> for TextureUsage {
4817 fn from(value: ffi::WGPUTextureUsage) -> Self {
4818 TextureUsage::from_bits_truncate(value as u64)
4819 }
4820 }
4821 impl From<TextureUsage> for ffi::WGPUTextureUsage {
4822 fn from(value: TextureUsage) -> Self {
4823 value.bits() as ffi::WGPUTextureUsage
4824 }
4825 }
4826}
4827mod structs {
4828 #![allow(dead_code, unused_imports)]
4829 use crate::ffi;
4830 use crate::generated::*;
4831 use std::any::Any;
4832 use std::ffi::CStr;
4833 pub(crate) fn string_view_to_string(view: ffi::WGPUStringView) -> String {
4834 if view.data.is_null() || view.length == 0 {
4835 return String::new();
4836 }
4837 let data = view.data.cast::<u8>();
4838 let slice = unsafe { std::slice::from_raw_parts(data, view.length) };
4839 String::from_utf8_lossy(slice).into_owned()
4840 }
4841 pub struct AHardwareBufferProperties {
4842 pub y_cb_cr_info: Option<YCbCrVkDescriptor>,
4843 }
4844 impl Default for AHardwareBufferProperties {
4845 fn default() -> Self {
4846 Self { y_cb_cr_info: None }
4847 }
4848 }
4849 impl AHardwareBufferProperties {
4850 pub fn new() -> Self {
4851 Self::default()
4852 }
4853 pub(crate) fn to_ffi(
4854 &self,
4855 ) -> (ffi::WGPUAHardwareBufferProperties, ChainedStructStorage) {
4856 let mut storage = ChainedStructStorage::new();
4857 let mut raw: ffi::WGPUAHardwareBufferProperties = unsafe {
4858 std::mem::zeroed()
4859 };
4860 if let Some(value) = &self.y_cb_cr_info {
4861 let (raw_value, storage_value) = value.to_ffi();
4862 raw.yCbCrInfo = raw_value;
4863 storage.push_storage(storage_value);
4864 }
4865 (raw, storage)
4866 }
4867 pub(crate) fn from_ffi(value: ffi::WGPUAHardwareBufferProperties) -> Self {
4868 Self {
4869 y_cb_cr_info: Some(YCbCrVkDescriptor::from_ffi(value.yCbCrInfo)),
4870 }
4871 }
4872 }
4873 pub struct AdapterInfo {
4874 pub(crate) extensions: Vec<AdapterInfoExtension>,
4875 pub vendor: Option<String>,
4876 pub architecture: Option<String>,
4877 pub device: Option<String>,
4878 pub description: Option<String>,
4879 pub backend_type: Option<BackendType>,
4880 pub adapter_type: Option<AdapterType>,
4881 pub vendor_id: Option<u32>,
4882 pub device_id: Option<u32>,
4883 pub subgroup_min_size: Option<u32>,
4884 pub subgroup_max_size: Option<u32>,
4885 #[doc(hidden)]
4886 pub(crate) _free_members: Option<ffi::WGPUAdapterInfo>,
4887 }
4888 impl Default for AdapterInfo {
4889 fn default() -> Self {
4890 Self {
4891 extensions: Vec::new(),
4892 vendor: None,
4893 architecture: None,
4894 device: None,
4895 description: None,
4896 backend_type: None,
4897 adapter_type: None,
4898 vendor_id: None,
4899 device_id: None,
4900 subgroup_min_size: None,
4901 subgroup_max_size: None,
4902 _free_members: None,
4903 }
4904 }
4905 }
4906 impl AdapterInfo {
4907 pub fn new() -> Self {
4908 Self::default()
4909 }
4910 pub(crate) fn to_ffi(&self) -> (ffi::WGPUAdapterInfo, ChainedStructStorage) {
4911 let mut storage = ChainedStructStorage::new();
4912 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
4913 for ext in self.extensions.iter().rev() {
4914 next = ext.push_chain(&mut storage, next);
4915 }
4916 let mut raw: ffi::WGPUAdapterInfo = unsafe { std::mem::zeroed() };
4917 raw.nextInChain = next;
4918 if let Some(value) = &self.vendor {
4919 raw.vendor = ffi::WGPUStringView {
4920 data: value.as_ptr().cast(),
4921 length: value.len(),
4922 };
4923 } else {
4924 raw.vendor = ffi::WGPUStringView {
4925 data: std::ptr::null(),
4926 length: 0,
4927 };
4928 }
4929 if let Some(value) = &self.architecture {
4930 raw.architecture = ffi::WGPUStringView {
4931 data: value.as_ptr().cast(),
4932 length: value.len(),
4933 };
4934 } else {
4935 raw.architecture = ffi::WGPUStringView {
4936 data: std::ptr::null(),
4937 length: 0,
4938 };
4939 }
4940 if let Some(value) = &self.device {
4941 raw.device = ffi::WGPUStringView {
4942 data: value.as_ptr().cast(),
4943 length: value.len(),
4944 };
4945 } else {
4946 raw.device = ffi::WGPUStringView {
4947 data: std::ptr::null(),
4948 length: 0,
4949 };
4950 }
4951 if let Some(value) = &self.description {
4952 raw.description = ffi::WGPUStringView {
4953 data: value.as_ptr().cast(),
4954 length: value.len(),
4955 };
4956 } else {
4957 raw.description = ffi::WGPUStringView {
4958 data: std::ptr::null(),
4959 length: 0,
4960 };
4961 }
4962 if let Some(value) = self.backend_type {
4963 raw.backendType = value.into();
4964 } else {
4965 raw.backendType = 0 as ffi::WGPUBackendType;
4966 }
4967 if let Some(value) = self.adapter_type {
4968 raw.adapterType = value.into();
4969 } else {
4970 raw.adapterType = 0 as ffi::WGPUAdapterType;
4971 }
4972 if let Some(value) = self.vendor_id {
4973 raw.vendorID = value;
4974 }
4975 if let Some(value) = self.device_id {
4976 raw.deviceID = value;
4977 }
4978 if let Some(value) = self.subgroup_min_size {
4979 raw.subgroupMinSize = value;
4980 }
4981 if let Some(value) = self.subgroup_max_size {
4982 raw.subgroupMaxSize = value;
4983 }
4984 (raw, storage)
4985 }
4986 pub fn with_extension(mut self, extension: AdapterInfoExtension) -> Self {
4987 self.extensions.push(extension);
4988 self
4989 }
4990 pub(crate) fn from_ffi(value: ffi::WGPUAdapterInfo) -> Self {
4991 Self {
4992 extensions: Vec::new(),
4993 vendor: Some(string_view_to_string(value.vendor)),
4994 architecture: Some(string_view_to_string(value.architecture)),
4995 device: Some(string_view_to_string(value.device)),
4996 description: Some(string_view_to_string(value.description)),
4997 backend_type: Some(value.backendType.into()),
4998 adapter_type: Some(value.adapterType.into()),
4999 vendor_id: Some(value.vendorID),
5000 device_id: Some(value.deviceID),
5001 subgroup_min_size: Some(value.subgroupMinSize),
5002 subgroup_max_size: Some(value.subgroupMaxSize),
5003 _free_members: Some(value),
5004 }
5005 }
5006 pub(crate) fn free_members(value: ffi::WGPUAdapterInfo) {
5007 unsafe { ffi::wgpuAdapterInfoFreeMembers(value) };
5008 }
5009 }
5010 impl Drop for AdapterInfo {
5011 fn drop(&mut self) {
5012 if let Some(value) = self._free_members.take() {
5013 unsafe { ffi::wgpuAdapterInfoFreeMembers(value) };
5014 }
5015 }
5016 }
5017 pub struct AdapterPropertiesD3D {
5018 pub shader_model: Option<u32>,
5019 }
5020 impl Default for AdapterPropertiesD3D {
5021 fn default() -> Self {
5022 Self { shader_model: None }
5023 }
5024 }
5025 impl AdapterPropertiesD3D {
5026 pub fn new() -> Self {
5027 Self::default()
5028 }
5029 pub(crate) fn to_ffi(
5030 &self,
5031 ) -> (ffi::WGPUAdapterPropertiesD3D, ChainedStructStorage) {
5032 let mut storage = ChainedStructStorage::new();
5033 let mut raw: ffi::WGPUAdapterPropertiesD3D = unsafe { std::mem::zeroed() };
5034 if let Some(value) = self.shader_model {
5035 raw.shaderModel = value;
5036 }
5037 (raw, storage)
5038 }
5039 pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesD3D) -> Self {
5040 Self {
5041 shader_model: Some(value.shaderModel),
5042 }
5043 }
5044 }
5045 pub struct AdapterPropertiesWGPU {
5046 pub backend_type: Option<BackendType>,
5047 }
5048 impl Default for AdapterPropertiesWGPU {
5049 fn default() -> Self {
5050 Self { backend_type: None }
5051 }
5052 }
5053 impl AdapterPropertiesWGPU {
5054 pub fn new() -> Self {
5055 Self::default()
5056 }
5057 pub(crate) fn to_ffi(
5058 &self,
5059 ) -> (ffi::WGPUAdapterPropertiesWGPU, ChainedStructStorage) {
5060 let mut storage = ChainedStructStorage::new();
5061 let mut raw: ffi::WGPUAdapterPropertiesWGPU = unsafe { std::mem::zeroed() };
5062 if let Some(value) = self.backend_type {
5063 raw.backendType = value.into();
5064 } else {
5065 raw.backendType = 0 as ffi::WGPUBackendType;
5066 }
5067 (raw, storage)
5068 }
5069 pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesWGPU) -> Self {
5070 Self {
5071 backend_type: Some(value.backendType.into()),
5072 }
5073 }
5074 }
5075 pub struct AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5076 pub min_explicit_compute_subgroup_size: Option<u32>,
5077 pub max_explicit_compute_subgroup_size: Option<u32>,
5078 pub max_compute_workgroup_subgroups: Option<u32>,
5079 }
5080 impl Default for AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5081 fn default() -> Self {
5082 Self {
5083 min_explicit_compute_subgroup_size: None,
5084 max_explicit_compute_subgroup_size: None,
5085 max_compute_workgroup_subgroups: None,
5086 }
5087 }
5088 }
5089 impl AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5090 pub fn new() -> Self {
5091 Self::default()
5092 }
5093 pub(crate) fn to_ffi(
5094 &self,
5095 ) -> (
5096 ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs,
5097 ChainedStructStorage,
5098 ) {
5099 let mut storage = ChainedStructStorage::new();
5100 let mut raw: ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs = unsafe {
5101 std::mem::zeroed()
5102 };
5103 if let Some(value) = self.min_explicit_compute_subgroup_size {
5104 raw.minExplicitComputeSubgroupSize = value;
5105 }
5106 if let Some(value) = self.max_explicit_compute_subgroup_size {
5107 raw.maxExplicitComputeSubgroupSize = value;
5108 }
5109 if let Some(value) = self.max_compute_workgroup_subgroups {
5110 raw.maxComputeWorkgroupSubgroups = value;
5111 }
5112 (raw, storage)
5113 }
5114 pub(crate) fn from_ffi(
5115 value: ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs,
5116 ) -> Self {
5117 Self {
5118 min_explicit_compute_subgroup_size: Some(
5119 value.minExplicitComputeSubgroupSize,
5120 ),
5121 max_explicit_compute_subgroup_size: Some(
5122 value.maxExplicitComputeSubgroupSize,
5123 ),
5124 max_compute_workgroup_subgroups: Some(value.maxComputeWorkgroupSubgroups),
5125 }
5126 }
5127 }
5128 pub struct AdapterPropertiesMemoryHeaps {
5129 pub heap_info: Option<Vec<MemoryHeapInfo>>,
5130 #[doc(hidden)]
5131 pub(crate) _free_members: Option<ffi::WGPUAdapterPropertiesMemoryHeaps>,
5132 }
5133 impl Default for AdapterPropertiesMemoryHeaps {
5134 fn default() -> Self {
5135 Self {
5136 heap_info: None,
5137 _free_members: None,
5138 }
5139 }
5140 }
5141 impl AdapterPropertiesMemoryHeaps {
5142 pub fn new() -> Self {
5143 Self::default()
5144 }
5145 pub(crate) fn to_ffi(
5146 &self,
5147 ) -> (ffi::WGPUAdapterPropertiesMemoryHeaps, ChainedStructStorage) {
5148 let mut storage = ChainedStructStorage::new();
5149 let mut raw: ffi::WGPUAdapterPropertiesMemoryHeaps = unsafe {
5150 std::mem::zeroed()
5151 };
5152 raw.heapCount = self.heap_info.as_ref().map(|v| v.len()).unwrap_or(0);
5153 if let Some(values) = &self.heap_info {
5154 let len_value = values.len();
5155 let mut raw_vec: Vec<ffi::WGPUMemoryHeapInfo> = Vec::with_capacity(
5156 values.len(),
5157 );
5158 for item in values.iter() {
5159 let (raw_item, storage_item) = item.to_ffi();
5160 raw_vec.push(raw_item);
5161 storage.push_storage(storage_item);
5162 }
5163 let ptr = storage.push_vec(raw_vec);
5164 raw.heapInfo = ptr;
5165 raw.heapCount = len_value;
5166 } else {
5167 raw.heapInfo = std::ptr::null();
5168 raw.heapCount = 0;
5169 }
5170 (raw, storage)
5171 }
5172 pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesMemoryHeaps) -> Self {
5173 Self {
5174 heap_info: if value.heapInfo.is_null() {
5175 None
5176 } else {
5177 Some(
5178 unsafe {
5179 std::slice::from_raw_parts(
5180 value.heapInfo,
5181 value.heapCount as usize,
5182 )
5183 }
5184 .iter()
5185 .map(|raw| MemoryHeapInfo::from_ffi(*raw))
5186 .collect(),
5187 )
5188 },
5189 _free_members: Some(value),
5190 }
5191 }
5192 pub(crate) fn free_members(value: ffi::WGPUAdapterPropertiesMemoryHeaps) {
5193 unsafe { ffi::wgpuAdapterPropertiesMemoryHeapsFreeMembers(value) };
5194 }
5195 }
5196 impl Drop for AdapterPropertiesMemoryHeaps {
5197 fn drop(&mut self) {
5198 if let Some(value) = self._free_members.take() {
5199 unsafe { ffi::wgpuAdapterPropertiesMemoryHeapsFreeMembers(value) };
5200 }
5201 }
5202 }
5203 pub struct AdapterPropertiesSubgroupMatrixConfigs {
5204 pub configs: Option<Vec<SubgroupMatrixConfig>>,
5205 #[doc(hidden)]
5206 pub(crate) _free_members: Option<
5207 ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5208 >,
5209 }
5210 impl Default for AdapterPropertiesSubgroupMatrixConfigs {
5211 fn default() -> Self {
5212 Self {
5213 configs: None,
5214 _free_members: None,
5215 }
5216 }
5217 }
5218 impl AdapterPropertiesSubgroupMatrixConfigs {
5219 pub fn new() -> Self {
5220 Self::default()
5221 }
5222 pub(crate) fn to_ffi(
5223 &self,
5224 ) -> (ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs, ChainedStructStorage) {
5225 let mut storage = ChainedStructStorage::new();
5226 let mut raw: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs = unsafe {
5227 std::mem::zeroed()
5228 };
5229 raw.configCount = self.configs.as_ref().map(|v| v.len()).unwrap_or(0);
5230 if let Some(values) = &self.configs {
5231 let len_value = values.len();
5232 let mut raw_vec: Vec<ffi::WGPUSubgroupMatrixConfig> = Vec::with_capacity(
5233 values.len(),
5234 );
5235 for item in values.iter() {
5236 let (raw_item, storage_item) = item.to_ffi();
5237 raw_vec.push(raw_item);
5238 storage.push_storage(storage_item);
5239 }
5240 let ptr = storage.push_vec(raw_vec);
5241 raw.configs = ptr;
5242 raw.configCount = len_value;
5243 } else {
5244 raw.configs = std::ptr::null();
5245 raw.configCount = 0;
5246 }
5247 (raw, storage)
5248 }
5249 pub(crate) fn from_ffi(
5250 value: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5251 ) -> Self {
5252 Self {
5253 configs: if value.configs.is_null() {
5254 None
5255 } else {
5256 Some(
5257 unsafe {
5258 std::slice::from_raw_parts(
5259 value.configs,
5260 value.configCount as usize,
5261 )
5262 }
5263 .iter()
5264 .map(|raw| SubgroupMatrixConfig::from_ffi(*raw))
5265 .collect(),
5266 )
5267 },
5268 _free_members: Some(value),
5269 }
5270 }
5271 pub(crate) fn free_members(
5272 value: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5273 ) {
5274 unsafe { ffi::wgpuAdapterPropertiesSubgroupMatrixConfigsFreeMembers(value) };
5275 }
5276 }
5277 impl Drop for AdapterPropertiesSubgroupMatrixConfigs {
5278 fn drop(&mut self) {
5279 if let Some(value) = self._free_members.take() {
5280 unsafe {
5281 ffi::wgpuAdapterPropertiesSubgroupMatrixConfigsFreeMembers(value)
5282 };
5283 }
5284 }
5285 }
5286 pub struct AdapterPropertiesVk {
5287 pub driver_version: Option<u32>,
5288 }
5289 impl Default for AdapterPropertiesVk {
5290 fn default() -> Self {
5291 Self { driver_version: None }
5292 }
5293 }
5294 impl AdapterPropertiesVk {
5295 pub fn new() -> Self {
5296 Self::default()
5297 }
5298 pub(crate) fn to_ffi(
5299 &self,
5300 ) -> (ffi::WGPUAdapterPropertiesVk, ChainedStructStorage) {
5301 let mut storage = ChainedStructStorage::new();
5302 let mut raw: ffi::WGPUAdapterPropertiesVk = unsafe { std::mem::zeroed() };
5303 if let Some(value) = self.driver_version {
5304 raw.driverVersion = value;
5305 }
5306 (raw, storage)
5307 }
5308 pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesVk) -> Self {
5309 Self {
5310 driver_version: Some(value.driverVersion),
5311 }
5312 }
5313 }
5314 pub struct BindGroupDescriptor {
5315 pub(crate) extensions: Vec<BindGroupDescriptorExtension>,
5316 pub label: Option<String>,
5317 pub layout: Option<BindGroupLayout>,
5318 pub entries: Option<Vec<BindGroupEntry>>,
5319 }
5320 impl Default for BindGroupDescriptor {
5321 fn default() -> Self {
5322 Self {
5323 extensions: Vec::new(),
5324 label: None,
5325 layout: None,
5326 entries: None,
5327 }
5328 }
5329 }
5330 impl BindGroupDescriptor {
5331 pub fn new() -> Self {
5332 Self::default()
5333 }
5334 pub(crate) fn to_ffi(
5335 &self,
5336 ) -> (ffi::WGPUBindGroupDescriptor, ChainedStructStorage) {
5337 let mut storage = ChainedStructStorage::new();
5338 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5339 for ext in self.extensions.iter().rev() {
5340 next = ext.push_chain(&mut storage, next);
5341 }
5342 let mut raw: ffi::WGPUBindGroupDescriptor = unsafe { std::mem::zeroed() };
5343 raw.nextInChain = next;
5344 if let Some(value) = &self.label {
5345 raw.label = ffi::WGPUStringView {
5346 data: value.as_ptr().cast(),
5347 length: value.len(),
5348 };
5349 } else {
5350 raw.label = ffi::WGPUStringView {
5351 data: std::ptr::null(),
5352 length: 0,
5353 };
5354 }
5355 raw.layout = self
5356 .layout
5357 .as_ref()
5358 .map(|v| v.as_raw())
5359 .unwrap_or(std::ptr::null_mut());
5360 raw.entryCount = self.entries.as_ref().map(|v| v.len()).unwrap_or(0);
5361 if let Some(values) = &self.entries {
5362 let len_value = values.len();
5363 let mut raw_vec: Vec<ffi::WGPUBindGroupEntry> = Vec::with_capacity(
5364 values.len(),
5365 );
5366 for item in values.iter() {
5367 let (raw_item, storage_item) = item.to_ffi();
5368 raw_vec.push(raw_item);
5369 storage.push_storage(storage_item);
5370 }
5371 let ptr = storage.push_vec(raw_vec);
5372 raw.entries = ptr;
5373 raw.entryCount = len_value;
5374 } else {
5375 raw.entries = std::ptr::null();
5376 raw.entryCount = 0;
5377 }
5378 (raw, storage)
5379 }
5380 pub fn with_extension(
5381 mut self,
5382 extension: BindGroupDescriptorExtension,
5383 ) -> Self {
5384 self.extensions.push(extension);
5385 self
5386 }
5387 pub(crate) fn from_ffi(value: ffi::WGPUBindGroupDescriptor) -> Self {
5388 Self {
5389 extensions: Vec::new(),
5390 label: if value.label.data.is_null() || value.label.length == 0 {
5391 None
5392 } else {
5393 Some(string_view_to_string(value.label))
5394 },
5395 layout: Some(unsafe { BindGroupLayout::from_raw(value.layout) }),
5396 entries: if value.entries.is_null() {
5397 None
5398 } else {
5399 Some(
5400 unsafe {
5401 std::slice::from_raw_parts(
5402 value.entries,
5403 value.entryCount as usize,
5404 )
5405 }
5406 .iter()
5407 .map(|raw| BindGroupEntry::from_ffi(*raw))
5408 .collect(),
5409 )
5410 },
5411 }
5412 }
5413 }
5414 pub struct BindGroupEntry {
5415 pub(crate) extensions: Vec<BindGroupEntryExtension>,
5416 pub binding: Option<u32>,
5417 pub buffer: Option<Buffer>,
5418 pub offset: Option<u64>,
5419 pub size: Option<u64>,
5420 pub sampler: Option<Sampler>,
5421 pub texture_view: Option<TextureView>,
5422 }
5423 impl Default for BindGroupEntry {
5424 fn default() -> Self {
5425 Self {
5426 extensions: Vec::new(),
5427 binding: None,
5428 buffer: None,
5429 offset: Some(0),
5430 size: Some(WHOLE_SIZE),
5431 sampler: None,
5432 texture_view: None,
5433 }
5434 }
5435 }
5436 impl BindGroupEntry {
5437 pub fn new() -> Self {
5438 Self::default()
5439 }
5440 pub(crate) fn to_ffi(&self) -> (ffi::WGPUBindGroupEntry, ChainedStructStorage) {
5441 let mut storage = ChainedStructStorage::new();
5442 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5443 for ext in self.extensions.iter().rev() {
5444 next = ext.push_chain(&mut storage, next);
5445 }
5446 let mut raw: ffi::WGPUBindGroupEntry = unsafe { std::mem::zeroed() };
5447 raw.nextInChain = next;
5448 if let Some(value) = self.binding {
5449 raw.binding = value;
5450 }
5451 raw.buffer = self
5452 .buffer
5453 .as_ref()
5454 .map(|v| v.as_raw())
5455 .unwrap_or(std::ptr::null_mut());
5456 if let Some(value) = self.offset {
5457 raw.offset = value;
5458 }
5459 if let Some(value) = self.size {
5460 raw.size = value;
5461 }
5462 raw.sampler = self
5463 .sampler
5464 .as_ref()
5465 .map(|v| v.as_raw())
5466 .unwrap_or(std::ptr::null_mut());
5467 raw.textureView = self
5468 .texture_view
5469 .as_ref()
5470 .map(|v| v.as_raw())
5471 .unwrap_or(std::ptr::null_mut());
5472 (raw, storage)
5473 }
5474 pub fn with_extension(mut self, extension: BindGroupEntryExtension) -> Self {
5475 self.extensions.push(extension);
5476 self
5477 }
5478 pub(crate) fn from_ffi(value: ffi::WGPUBindGroupEntry) -> Self {
5479 Self {
5480 extensions: Vec::new(),
5481 binding: Some(value.binding),
5482 buffer: if value.buffer.is_null() {
5483 None
5484 } else {
5485 Some(unsafe { Buffer::from_raw(value.buffer) })
5486 },
5487 offset: Some(value.offset),
5488 size: Some(value.size),
5489 sampler: if value.sampler.is_null() {
5490 None
5491 } else {
5492 Some(unsafe { Sampler::from_raw(value.sampler) })
5493 },
5494 texture_view: if value.textureView.is_null() {
5495 None
5496 } else {
5497 Some(unsafe { TextureView::from_raw(value.textureView) })
5498 },
5499 }
5500 }
5501 }
5502 pub struct BindGroupLayoutDescriptor {
5503 pub(crate) extensions: Vec<BindGroupLayoutDescriptorExtension>,
5504 pub label: Option<String>,
5505 pub entries: Option<Vec<BindGroupLayoutEntry>>,
5506 }
5507 impl Default for BindGroupLayoutDescriptor {
5508 fn default() -> Self {
5509 Self {
5510 extensions: Vec::new(),
5511 label: None,
5512 entries: None,
5513 }
5514 }
5515 }
5516 impl BindGroupLayoutDescriptor {
5517 pub fn new() -> Self {
5518 Self::default()
5519 }
5520 pub(crate) fn to_ffi(
5521 &self,
5522 ) -> (ffi::WGPUBindGroupLayoutDescriptor, ChainedStructStorage) {
5523 let mut storage = ChainedStructStorage::new();
5524 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5525 for ext in self.extensions.iter().rev() {
5526 next = ext.push_chain(&mut storage, next);
5527 }
5528 let mut raw: ffi::WGPUBindGroupLayoutDescriptor = unsafe {
5529 std::mem::zeroed()
5530 };
5531 raw.nextInChain = next;
5532 if let Some(value) = &self.label {
5533 raw.label = ffi::WGPUStringView {
5534 data: value.as_ptr().cast(),
5535 length: value.len(),
5536 };
5537 } else {
5538 raw.label = ffi::WGPUStringView {
5539 data: std::ptr::null(),
5540 length: 0,
5541 };
5542 }
5543 raw.entryCount = self.entries.as_ref().map(|v| v.len()).unwrap_or(0);
5544 if let Some(values) = &self.entries {
5545 let len_value = values.len();
5546 let mut raw_vec: Vec<ffi::WGPUBindGroupLayoutEntry> = Vec::with_capacity(
5547 values.len(),
5548 );
5549 for item in values.iter() {
5550 let (raw_item, storage_item) = item.to_ffi();
5551 raw_vec.push(raw_item);
5552 storage.push_storage(storage_item);
5553 }
5554 let ptr = storage.push_vec(raw_vec);
5555 raw.entries = ptr;
5556 raw.entryCount = len_value;
5557 } else {
5558 raw.entries = std::ptr::null();
5559 raw.entryCount = 0;
5560 }
5561 (raw, storage)
5562 }
5563 pub fn with_extension(
5564 mut self,
5565 extension: BindGroupLayoutDescriptorExtension,
5566 ) -> Self {
5567 self.extensions.push(extension);
5568 self
5569 }
5570 pub(crate) fn from_ffi(value: ffi::WGPUBindGroupLayoutDescriptor) -> Self {
5571 Self {
5572 extensions: Vec::new(),
5573 label: if value.label.data.is_null() || value.label.length == 0 {
5574 None
5575 } else {
5576 Some(string_view_to_string(value.label))
5577 },
5578 entries: if value.entries.is_null() {
5579 None
5580 } else {
5581 Some(
5582 unsafe {
5583 std::slice::from_raw_parts(
5584 value.entries,
5585 value.entryCount as usize,
5586 )
5587 }
5588 .iter()
5589 .map(|raw| BindGroupLayoutEntry::from_ffi(*raw))
5590 .collect(),
5591 )
5592 },
5593 }
5594 }
5595 }
5596 pub struct BindGroupLayoutEntry {
5597 pub(crate) extensions: Vec<BindGroupLayoutEntryExtension>,
5598 pub binding: Option<u32>,
5599 pub visibility: Option<ShaderStage>,
5600 pub binding_array_size: Option<u32>,
5601 pub buffer: Option<BufferBindingLayout>,
5602 pub sampler: Option<SamplerBindingLayout>,
5603 pub texture: Option<TextureBindingLayout>,
5604 pub storage_texture: Option<StorageTextureBindingLayout>,
5605 }
5606 impl Default for BindGroupLayoutEntry {
5607 fn default() -> Self {
5608 Self {
5609 extensions: Vec::new(),
5610 binding: None,
5611 visibility: None,
5612 binding_array_size: Some(0),
5613 buffer: None,
5614 sampler: None,
5615 texture: None,
5616 storage_texture: None,
5617 }
5618 }
5619 }
5620 impl BindGroupLayoutEntry {
5621 pub fn new() -> Self {
5622 Self::default()
5623 }
5624 pub(crate) fn to_ffi(
5625 &self,
5626 ) -> (ffi::WGPUBindGroupLayoutEntry, ChainedStructStorage) {
5627 let mut storage = ChainedStructStorage::new();
5628 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5629 for ext in self.extensions.iter().rev() {
5630 next = ext.push_chain(&mut storage, next);
5631 }
5632 let mut raw: ffi::WGPUBindGroupLayoutEntry = unsafe { std::mem::zeroed() };
5633 raw.nextInChain = next;
5634 if let Some(value) = self.binding {
5635 raw.binding = value;
5636 }
5637 if let Some(value) = self.visibility {
5638 raw.visibility = value.into();
5639 } else {
5640 raw.visibility = 0 as ffi::WGPUShaderStage;
5641 }
5642 if let Some(value) = self.binding_array_size {
5643 raw.bindingArraySize = value;
5644 }
5645 if let Some(value) = &self.buffer {
5646 let (raw_value, storage_value) = value.to_ffi();
5647 raw.buffer = raw_value;
5648 storage.push_storage(storage_value);
5649 }
5650 if let Some(value) = &self.sampler {
5651 let (raw_value, storage_value) = value.to_ffi();
5652 raw.sampler = raw_value;
5653 storage.push_storage(storage_value);
5654 }
5655 if let Some(value) = &self.texture {
5656 let (raw_value, storage_value) = value.to_ffi();
5657 raw.texture = raw_value;
5658 storage.push_storage(storage_value);
5659 }
5660 if let Some(value) = &self.storage_texture {
5661 let (raw_value, storage_value) = value.to_ffi();
5662 raw.storageTexture = raw_value;
5663 storage.push_storage(storage_value);
5664 }
5665 (raw, storage)
5666 }
5667 pub fn with_extension(
5668 mut self,
5669 extension: BindGroupLayoutEntryExtension,
5670 ) -> Self {
5671 self.extensions.push(extension);
5672 self
5673 }
5674 pub(crate) fn from_ffi(value: ffi::WGPUBindGroupLayoutEntry) -> Self {
5675 Self {
5676 extensions: Vec::new(),
5677 binding: Some(value.binding),
5678 visibility: Some(value.visibility.into()),
5679 binding_array_size: Some(value.bindingArraySize),
5680 buffer: Some(BufferBindingLayout::from_ffi(value.buffer)),
5681 sampler: Some(SamplerBindingLayout::from_ffi(value.sampler)),
5682 texture: Some(TextureBindingLayout::from_ffi(value.texture)),
5683 storage_texture: Some(
5684 StorageTextureBindingLayout::from_ffi(value.storageTexture),
5685 ),
5686 }
5687 }
5688 }
5689 pub struct BindingResource {
5690 pub(crate) extensions: Vec<BindingResourceExtension>,
5691 pub buffer: Option<Buffer>,
5692 pub offset: Option<u64>,
5693 pub size: Option<u64>,
5694 pub sampler: Option<Sampler>,
5695 pub texture_view: Option<TextureView>,
5696 }
5697 impl Default for BindingResource {
5698 fn default() -> Self {
5699 Self {
5700 extensions: Vec::new(),
5701 buffer: None,
5702 offset: Some(0),
5703 size: Some(WHOLE_SIZE),
5704 sampler: None,
5705 texture_view: None,
5706 }
5707 }
5708 }
5709 impl BindingResource {
5710 pub fn new() -> Self {
5711 Self::default()
5712 }
5713 pub(crate) fn to_ffi(&self) -> (ffi::WGPUBindingResource, ChainedStructStorage) {
5714 let mut storage = ChainedStructStorage::new();
5715 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5716 for ext in self.extensions.iter().rev() {
5717 next = ext.push_chain(&mut storage, next);
5718 }
5719 let mut raw: ffi::WGPUBindingResource = unsafe { std::mem::zeroed() };
5720 raw.nextInChain = next;
5721 raw.buffer = self
5722 .buffer
5723 .as_ref()
5724 .map(|v| v.as_raw())
5725 .unwrap_or(std::ptr::null_mut());
5726 if let Some(value) = self.offset {
5727 raw.offset = value;
5728 }
5729 if let Some(value) = self.size {
5730 raw.size = value;
5731 }
5732 raw.sampler = self
5733 .sampler
5734 .as_ref()
5735 .map(|v| v.as_raw())
5736 .unwrap_or(std::ptr::null_mut());
5737 raw.textureView = self
5738 .texture_view
5739 .as_ref()
5740 .map(|v| v.as_raw())
5741 .unwrap_or(std::ptr::null_mut());
5742 (raw, storage)
5743 }
5744 pub fn with_extension(mut self, extension: BindingResourceExtension) -> Self {
5745 self.extensions.push(extension);
5746 self
5747 }
5748 pub(crate) fn from_ffi(value: ffi::WGPUBindingResource) -> Self {
5749 Self {
5750 extensions: Vec::new(),
5751 buffer: if value.buffer.is_null() {
5752 None
5753 } else {
5754 Some(unsafe { Buffer::from_raw(value.buffer) })
5755 },
5756 offset: Some(value.offset),
5757 size: Some(value.size),
5758 sampler: if value.sampler.is_null() {
5759 None
5760 } else {
5761 Some(unsafe { Sampler::from_raw(value.sampler) })
5762 },
5763 texture_view: if value.textureView.is_null() {
5764 None
5765 } else {
5766 Some(unsafe { TextureView::from_raw(value.textureView) })
5767 },
5768 }
5769 }
5770 }
5771 pub struct BlendComponent {
5772 pub operation: Option<BlendOperation>,
5773 pub src_factor: Option<BlendFactor>,
5774 pub dst_factor: Option<BlendFactor>,
5775 }
5776 impl Default for BlendComponent {
5777 fn default() -> Self {
5778 Self {
5779 operation: Some(BlendOperation::Add),
5780 src_factor: Some(BlendFactor::One),
5781 dst_factor: Some(BlendFactor::Zero),
5782 }
5783 }
5784 }
5785 impl BlendComponent {
5786 pub fn new() -> Self {
5787 Self::default()
5788 }
5789 pub(crate) fn to_ffi(&self) -> (ffi::WGPUBlendComponent, ChainedStructStorage) {
5790 let mut storage = ChainedStructStorage::new();
5791 let mut raw: ffi::WGPUBlendComponent = unsafe { std::mem::zeroed() };
5792 if let Some(value) = self.operation {
5793 raw.operation = value.into();
5794 } else {
5795 raw.operation = 0 as ffi::WGPUBlendOperation;
5796 }
5797 if let Some(value) = self.src_factor {
5798 raw.srcFactor = value.into();
5799 } else {
5800 raw.srcFactor = 0 as ffi::WGPUBlendFactor;
5801 }
5802 if let Some(value) = self.dst_factor {
5803 raw.dstFactor = value.into();
5804 } else {
5805 raw.dstFactor = 0 as ffi::WGPUBlendFactor;
5806 }
5807 (raw, storage)
5808 }
5809 pub(crate) fn from_ffi(value: ffi::WGPUBlendComponent) -> Self {
5810 Self {
5811 operation: Some(value.operation.into()),
5812 src_factor: Some(value.srcFactor.into()),
5813 dst_factor: Some(value.dstFactor.into()),
5814 }
5815 }
5816 }
5817 pub struct BlendState {
5818 pub color: Option<BlendComponent>,
5819 pub alpha: Option<BlendComponent>,
5820 }
5821 impl Default for BlendState {
5822 fn default() -> Self {
5823 Self { color: None, alpha: None }
5824 }
5825 }
5826 impl BlendState {
5827 pub fn new() -> Self {
5828 Self::default()
5829 }
5830 pub(crate) fn to_ffi(&self) -> (ffi::WGPUBlendState, ChainedStructStorage) {
5831 let mut storage = ChainedStructStorage::new();
5832 let mut raw: ffi::WGPUBlendState = unsafe { std::mem::zeroed() };
5833 if let Some(value) = &self.color {
5834 let (raw_value, storage_value) = value.to_ffi();
5835 raw.color = raw_value;
5836 storage.push_storage(storage_value);
5837 }
5838 if let Some(value) = &self.alpha {
5839 let (raw_value, storage_value) = value.to_ffi();
5840 raw.alpha = raw_value;
5841 storage.push_storage(storage_value);
5842 }
5843 (raw, storage)
5844 }
5845 pub(crate) fn from_ffi(value: ffi::WGPUBlendState) -> Self {
5846 Self {
5847 color: Some(BlendComponent::from_ffi(value.color)),
5848 alpha: Some(BlendComponent::from_ffi(value.alpha)),
5849 }
5850 }
5851 }
5852 pub struct BufferBindingLayout {
5853 pub(crate) extensions: Vec<BufferBindingLayoutExtension>,
5854 pub r#type: Option<BufferBindingType>,
5855 pub has_dynamic_offset: Option<bool>,
5856 pub min_binding_size: Option<u64>,
5857 }
5858 impl Default for BufferBindingLayout {
5859 fn default() -> Self {
5860 Self {
5861 extensions: Vec::new(),
5862 r#type: Some(BufferBindingType::Uniform),
5863 has_dynamic_offset: None,
5864 min_binding_size: Some(0),
5865 }
5866 }
5867 }
5868 impl BufferBindingLayout {
5869 pub fn new() -> Self {
5870 Self::default()
5871 }
5872 pub(crate) fn to_ffi(
5873 &self,
5874 ) -> (ffi::WGPUBufferBindingLayout, ChainedStructStorage) {
5875 let mut storage = ChainedStructStorage::new();
5876 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5877 for ext in self.extensions.iter().rev() {
5878 next = ext.push_chain(&mut storage, next);
5879 }
5880 let mut raw: ffi::WGPUBufferBindingLayout = unsafe { std::mem::zeroed() };
5881 raw.nextInChain = next;
5882 if let Some(value) = self.r#type {
5883 raw.type_ = value.into();
5884 } else {
5885 raw.type_ = 0 as ffi::WGPUBufferBindingType;
5886 }
5887 raw.hasDynamicOffset = if self.has_dynamic_offset.unwrap_or(false) {
5888 1
5889 } else {
5890 0
5891 };
5892 if let Some(value) = self.min_binding_size {
5893 raw.minBindingSize = value;
5894 }
5895 (raw, storage)
5896 }
5897 pub fn with_extension(
5898 mut self,
5899 extension: BufferBindingLayoutExtension,
5900 ) -> Self {
5901 self.extensions.push(extension);
5902 self
5903 }
5904 pub(crate) fn from_ffi(value: ffi::WGPUBufferBindingLayout) -> Self {
5905 Self {
5906 extensions: Vec::new(),
5907 r#type: Some(value.type_.into()),
5908 has_dynamic_offset: Some(value.hasDynamicOffset != 0),
5909 min_binding_size: Some(value.minBindingSize),
5910 }
5911 }
5912 }
5913 pub struct BufferDescriptor {
5914 pub(crate) extensions: Vec<BufferDescriptorExtension>,
5915 pub label: Option<String>,
5916 pub usage: Option<BufferUsage>,
5917 pub size: Option<u64>,
5918 pub mapped_at_creation: Option<bool>,
5919 }
5920 impl Default for BufferDescriptor {
5921 fn default() -> Self {
5922 Self {
5923 extensions: Vec::new(),
5924 label: None,
5925 usage: None,
5926 size: None,
5927 mapped_at_creation: None,
5928 }
5929 }
5930 }
5931 impl BufferDescriptor {
5932 pub fn new() -> Self {
5933 Self::default()
5934 }
5935 pub(crate) fn to_ffi(
5936 &self,
5937 ) -> (ffi::WGPUBufferDescriptor, ChainedStructStorage) {
5938 let mut storage = ChainedStructStorage::new();
5939 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5940 for ext in self.extensions.iter().rev() {
5941 next = ext.push_chain(&mut storage, next);
5942 }
5943 let mut raw: ffi::WGPUBufferDescriptor = unsafe { std::mem::zeroed() };
5944 raw.nextInChain = next;
5945 if let Some(value) = &self.label {
5946 raw.label = ffi::WGPUStringView {
5947 data: value.as_ptr().cast(),
5948 length: value.len(),
5949 };
5950 } else {
5951 raw.label = ffi::WGPUStringView {
5952 data: std::ptr::null(),
5953 length: 0,
5954 };
5955 }
5956 if let Some(value) = self.usage {
5957 raw.usage = value.into();
5958 } else {
5959 raw.usage = 0 as ffi::WGPUBufferUsage;
5960 }
5961 if let Some(value) = self.size {
5962 raw.size = value;
5963 }
5964 raw.mappedAtCreation = if self.mapped_at_creation.unwrap_or(false) {
5965 1
5966 } else {
5967 0
5968 };
5969 (raw, storage)
5970 }
5971 pub fn with_extension(mut self, extension: BufferDescriptorExtension) -> Self {
5972 self.extensions.push(extension);
5973 self
5974 }
5975 pub(crate) fn from_ffi(value: ffi::WGPUBufferDescriptor) -> Self {
5976 Self {
5977 extensions: Vec::new(),
5978 label: if value.label.data.is_null() || value.label.length == 0 {
5979 None
5980 } else {
5981 Some(string_view_to_string(value.label))
5982 },
5983 usage: Some(value.usage.into()),
5984 size: Some(value.size),
5985 mapped_at_creation: Some(value.mappedAtCreation != 0),
5986 }
5987 }
5988 }
5989 pub struct BufferHostMappedPointer {
5990 pub pointer: Option<*mut std::ffi::c_void>,
5991 pub dispose_callback: Option<Callback>,
5992 pub userdata: Option<*mut std::ffi::c_void>,
5993 }
5994 impl Default for BufferHostMappedPointer {
5995 fn default() -> Self {
5996 Self {
5997 pointer: None,
5998 dispose_callback: None,
5999 userdata: None,
6000 }
6001 }
6002 }
6003 impl BufferHostMappedPointer {
6004 pub fn new() -> Self {
6005 Self::default()
6006 }
6007 pub(crate) fn to_ffi(
6008 &self,
6009 ) -> (ffi::WGPUBufferHostMappedPointer, ChainedStructStorage) {
6010 let mut storage = ChainedStructStorage::new();
6011 let mut raw: ffi::WGPUBufferHostMappedPointer = unsafe {
6012 std::mem::zeroed()
6013 };
6014 if let Some(value) = self.pointer {
6015 raw.pointer = value;
6016 }
6017 if let Some(value) = self.dispose_callback {
6018 raw.disposeCallback = value;
6019 }
6020 if let Some(value) = self.userdata {
6021 raw.userdata = value;
6022 }
6023 (raw, storage)
6024 }
6025 pub(crate) fn from_ffi(value: ffi::WGPUBufferHostMappedPointer) -> Self {
6026 Self {
6027 pointer: Some(value.pointer),
6028 dispose_callback: Some(value.disposeCallback),
6029 userdata: Some(value.userdata),
6030 }
6031 }
6032 }
6033 pub struct Color {
6034 pub r: Option<f64>,
6035 pub g: Option<f64>,
6036 pub b: Option<f64>,
6037 pub a: Option<f64>,
6038 }
6039 impl Default for Color {
6040 fn default() -> Self {
6041 Self {
6042 r: None,
6043 g: None,
6044 b: None,
6045 a: None,
6046 }
6047 }
6048 }
6049 impl Color {
6050 pub fn new() -> Self {
6051 Self::default()
6052 }
6053 pub(crate) fn to_ffi(&self) -> (ffi::WGPUColor, ChainedStructStorage) {
6054 let mut storage = ChainedStructStorage::new();
6055 let mut raw: ffi::WGPUColor = unsafe { std::mem::zeroed() };
6056 if let Some(value) = self.r {
6057 raw.r = value;
6058 }
6059 if let Some(value) = self.g {
6060 raw.g = value;
6061 }
6062 if let Some(value) = self.b {
6063 raw.b = value;
6064 }
6065 if let Some(value) = self.a {
6066 raw.a = value;
6067 }
6068 (raw, storage)
6069 }
6070 pub(crate) fn from_ffi(value: ffi::WGPUColor) -> Self {
6071 Self {
6072 r: Some(value.r),
6073 g: Some(value.g),
6074 b: Some(value.b),
6075 a: Some(value.a),
6076 }
6077 }
6078 }
6079 pub struct ColorTargetState {
6080 pub(crate) extensions: Vec<ColorTargetStateExtension>,
6081 pub format: Option<TextureFormat>,
6082 pub blend: Option<BlendState>,
6083 pub write_mask: Option<ColorWriteMask>,
6084 }
6085 impl Default for ColorTargetState {
6086 fn default() -> Self {
6087 Self {
6088 extensions: Vec::new(),
6089 format: None,
6090 blend: None,
6091 write_mask: Some(ColorWriteMask::ALL),
6092 }
6093 }
6094 }
6095 impl ColorTargetState {
6096 pub fn new() -> Self {
6097 Self::default()
6098 }
6099 pub(crate) fn to_ffi(
6100 &self,
6101 ) -> (ffi::WGPUColorTargetState, ChainedStructStorage) {
6102 let mut storage = ChainedStructStorage::new();
6103 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6104 for ext in self.extensions.iter().rev() {
6105 next = ext.push_chain(&mut storage, next);
6106 }
6107 let mut raw: ffi::WGPUColorTargetState = unsafe { std::mem::zeroed() };
6108 raw.nextInChain = next;
6109 if let Some(value) = self.format {
6110 raw.format = value.into();
6111 } else {
6112 raw.format = 0 as ffi::WGPUTextureFormat;
6113 }
6114 if let Some(value) = &self.blend {
6115 let (raw_value, storage_value) = value.to_ffi();
6116 let ptr = storage.push_value(raw_value);
6117 raw.blend = ptr;
6118 storage.push_storage(storage_value);
6119 } else {
6120 raw.blend = std::ptr::null();
6121 }
6122 if let Some(value) = self.write_mask {
6123 raw.writeMask = value.into();
6124 } else {
6125 raw.writeMask = 0 as ffi::WGPUColorWriteMask;
6126 }
6127 (raw, storage)
6128 }
6129 pub fn with_extension(mut self, extension: ColorTargetStateExtension) -> Self {
6130 self.extensions.push(extension);
6131 self
6132 }
6133 pub(crate) fn from_ffi(value: ffi::WGPUColorTargetState) -> Self {
6134 Self {
6135 extensions: Vec::new(),
6136 format: Some(value.format.into()),
6137 blend: if value.blend.is_null() {
6138 None
6139 } else {
6140 Some(BlendState::from_ffi(unsafe { *value.blend }))
6141 },
6142 write_mask: Some(value.writeMask.into()),
6143 }
6144 }
6145 }
6146 pub struct ColorTargetStateExpandResolveTextureDawn {
6147 pub enabled: Option<bool>,
6148 }
6149 impl Default for ColorTargetStateExpandResolveTextureDawn {
6150 fn default() -> Self {
6151 Self { enabled: None }
6152 }
6153 }
6154 impl ColorTargetStateExpandResolveTextureDawn {
6155 pub fn new() -> Self {
6156 Self::default()
6157 }
6158 pub(crate) fn to_ffi(
6159 &self,
6160 ) -> (ffi::WGPUColorTargetStateExpandResolveTextureDawn, ChainedStructStorage) {
6161 let mut storage = ChainedStructStorage::new();
6162 let mut raw: ffi::WGPUColorTargetStateExpandResolveTextureDawn = unsafe {
6163 std::mem::zeroed()
6164 };
6165 raw.enabled = if self.enabled.unwrap_or(false) { 1 } else { 0 };
6166 (raw, storage)
6167 }
6168 pub(crate) fn from_ffi(
6169 value: ffi::WGPUColorTargetStateExpandResolveTextureDawn,
6170 ) -> Self {
6171 Self {
6172 enabled: Some(value.enabled != 0),
6173 }
6174 }
6175 }
6176 pub struct CommandBufferDescriptor {
6177 pub(crate) extensions: Vec<CommandBufferDescriptorExtension>,
6178 pub label: Option<String>,
6179 }
6180 impl Default for CommandBufferDescriptor {
6181 fn default() -> Self {
6182 Self {
6183 extensions: Vec::new(),
6184 label: None,
6185 }
6186 }
6187 }
6188 impl CommandBufferDescriptor {
6189 pub fn new() -> Self {
6190 Self::default()
6191 }
6192 pub(crate) fn to_ffi(
6193 &self,
6194 ) -> (ffi::WGPUCommandBufferDescriptor, ChainedStructStorage) {
6195 let mut storage = ChainedStructStorage::new();
6196 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6197 for ext in self.extensions.iter().rev() {
6198 next = ext.push_chain(&mut storage, next);
6199 }
6200 let mut raw: ffi::WGPUCommandBufferDescriptor = unsafe {
6201 std::mem::zeroed()
6202 };
6203 raw.nextInChain = next;
6204 if let Some(value) = &self.label {
6205 raw.label = ffi::WGPUStringView {
6206 data: value.as_ptr().cast(),
6207 length: value.len(),
6208 };
6209 } else {
6210 raw.label = ffi::WGPUStringView {
6211 data: std::ptr::null(),
6212 length: 0,
6213 };
6214 }
6215 (raw, storage)
6216 }
6217 pub fn with_extension(
6218 mut self,
6219 extension: CommandBufferDescriptorExtension,
6220 ) -> Self {
6221 self.extensions.push(extension);
6222 self
6223 }
6224 pub(crate) fn from_ffi(value: ffi::WGPUCommandBufferDescriptor) -> Self {
6225 Self {
6226 extensions: Vec::new(),
6227 label: if value.label.data.is_null() || value.label.length == 0 {
6228 None
6229 } else {
6230 Some(string_view_to_string(value.label))
6231 },
6232 }
6233 }
6234 }
6235 pub struct CommandEncoderDescriptor {
6236 pub(crate) extensions: Vec<CommandEncoderDescriptorExtension>,
6237 pub label: Option<String>,
6238 }
6239 impl Default for CommandEncoderDescriptor {
6240 fn default() -> Self {
6241 Self {
6242 extensions: Vec::new(),
6243 label: None,
6244 }
6245 }
6246 }
6247 impl CommandEncoderDescriptor {
6248 pub fn new() -> Self {
6249 Self::default()
6250 }
6251 pub(crate) fn to_ffi(
6252 &self,
6253 ) -> (ffi::WGPUCommandEncoderDescriptor, ChainedStructStorage) {
6254 let mut storage = ChainedStructStorage::new();
6255 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6256 for ext in self.extensions.iter().rev() {
6257 next = ext.push_chain(&mut storage, next);
6258 }
6259 let mut raw: ffi::WGPUCommandEncoderDescriptor = unsafe {
6260 std::mem::zeroed()
6261 };
6262 raw.nextInChain = next;
6263 if let Some(value) = &self.label {
6264 raw.label = ffi::WGPUStringView {
6265 data: value.as_ptr().cast(),
6266 length: value.len(),
6267 };
6268 } else {
6269 raw.label = ffi::WGPUStringView {
6270 data: std::ptr::null(),
6271 length: 0,
6272 };
6273 }
6274 (raw, storage)
6275 }
6276 pub fn with_extension(
6277 mut self,
6278 extension: CommandEncoderDescriptorExtension,
6279 ) -> Self {
6280 self.extensions.push(extension);
6281 self
6282 }
6283 pub(crate) fn from_ffi(value: ffi::WGPUCommandEncoderDescriptor) -> Self {
6284 Self {
6285 extensions: Vec::new(),
6286 label: if value.label.data.is_null() || value.label.length == 0 {
6287 None
6288 } else {
6289 Some(string_view_to_string(value.label))
6290 },
6291 }
6292 }
6293 }
6294 pub struct CompilationInfo {
6295 pub(crate) extensions: Vec<CompilationInfoExtension>,
6296 pub messages: Option<Vec<CompilationMessage>>,
6297 }
6298 impl Default for CompilationInfo {
6299 fn default() -> Self {
6300 Self {
6301 extensions: Vec::new(),
6302 messages: None,
6303 }
6304 }
6305 }
6306 impl CompilationInfo {
6307 pub fn new() -> Self {
6308 Self::default()
6309 }
6310 pub(crate) fn to_ffi(&self) -> (ffi::WGPUCompilationInfo, ChainedStructStorage) {
6311 let mut storage = ChainedStructStorage::new();
6312 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6313 for ext in self.extensions.iter().rev() {
6314 next = ext.push_chain(&mut storage, next);
6315 }
6316 let mut raw: ffi::WGPUCompilationInfo = unsafe { std::mem::zeroed() };
6317 raw.nextInChain = next;
6318 raw.messageCount = self.messages.as_ref().map(|v| v.len()).unwrap_or(0);
6319 if let Some(values) = &self.messages {
6320 let len_value = values.len();
6321 let mut raw_vec: Vec<ffi::WGPUCompilationMessage> = Vec::with_capacity(
6322 values.len(),
6323 );
6324 for item in values.iter() {
6325 let (raw_item, storage_item) = item.to_ffi();
6326 raw_vec.push(raw_item);
6327 storage.push_storage(storage_item);
6328 }
6329 let ptr = storage.push_vec(raw_vec);
6330 raw.messages = ptr;
6331 raw.messageCount = len_value;
6332 } else {
6333 raw.messages = std::ptr::null();
6334 raw.messageCount = 0;
6335 }
6336 (raw, storage)
6337 }
6338 pub fn with_extension(mut self, extension: CompilationInfoExtension) -> Self {
6339 self.extensions.push(extension);
6340 self
6341 }
6342 pub(crate) fn from_ffi(value: ffi::WGPUCompilationInfo) -> Self {
6343 Self {
6344 extensions: Vec::new(),
6345 messages: if value.messages.is_null() {
6346 None
6347 } else {
6348 Some(
6349 unsafe {
6350 std::slice::from_raw_parts(
6351 value.messages,
6352 value.messageCount as usize,
6353 )
6354 }
6355 .iter()
6356 .map(|raw| CompilationMessage::from_ffi(*raw))
6357 .collect(),
6358 )
6359 },
6360 }
6361 }
6362 }
6363 pub struct CompilationMessage {
6364 pub(crate) extensions: Vec<CompilationMessageExtension>,
6365 pub message: Option<String>,
6366 pub r#type: Option<CompilationMessageType>,
6367 pub line_num: Option<u64>,
6368 pub line_pos: Option<u64>,
6369 pub offset: Option<u64>,
6370 pub length: Option<u64>,
6371 }
6372 impl Default for CompilationMessage {
6373 fn default() -> Self {
6374 Self {
6375 extensions: Vec::new(),
6376 message: None,
6377 r#type: None,
6378 line_num: None,
6379 line_pos: None,
6380 offset: None,
6381 length: None,
6382 }
6383 }
6384 }
6385 impl CompilationMessage {
6386 pub fn new() -> Self {
6387 Self::default()
6388 }
6389 pub(crate) fn to_ffi(
6390 &self,
6391 ) -> (ffi::WGPUCompilationMessage, ChainedStructStorage) {
6392 let mut storage = ChainedStructStorage::new();
6393 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6394 for ext in self.extensions.iter().rev() {
6395 next = ext.push_chain(&mut storage, next);
6396 }
6397 let mut raw: ffi::WGPUCompilationMessage = unsafe { std::mem::zeroed() };
6398 raw.nextInChain = next;
6399 if let Some(value) = &self.message {
6400 raw.message = ffi::WGPUStringView {
6401 data: value.as_ptr().cast(),
6402 length: value.len(),
6403 };
6404 } else {
6405 raw.message = ffi::WGPUStringView {
6406 data: std::ptr::null(),
6407 length: 0,
6408 };
6409 }
6410 if let Some(value) = self.r#type {
6411 raw.type_ = value.into();
6412 } else {
6413 raw.type_ = 0 as ffi::WGPUCompilationMessageType;
6414 }
6415 if let Some(value) = self.line_num {
6416 raw.lineNum = value;
6417 }
6418 if let Some(value) = self.line_pos {
6419 raw.linePos = value;
6420 }
6421 if let Some(value) = self.offset {
6422 raw.offset = value;
6423 }
6424 if let Some(value) = self.length {
6425 raw.length = value;
6426 }
6427 (raw, storage)
6428 }
6429 pub fn with_extension(mut self, extension: CompilationMessageExtension) -> Self {
6430 self.extensions.push(extension);
6431 self
6432 }
6433 pub(crate) fn from_ffi(value: ffi::WGPUCompilationMessage) -> Self {
6434 Self {
6435 extensions: Vec::new(),
6436 message: Some(string_view_to_string(value.message)),
6437 r#type: Some(value.type_.into()),
6438 line_num: Some(value.lineNum),
6439 line_pos: Some(value.linePos),
6440 offset: Some(value.offset),
6441 length: Some(value.length),
6442 }
6443 }
6444 }
6445 pub struct ComputePassDescriptor {
6446 pub(crate) extensions: Vec<ComputePassDescriptorExtension>,
6447 pub label: Option<String>,
6448 pub timestamp_writes: Option<PassTimestampWrites>,
6449 }
6450 impl Default for ComputePassDescriptor {
6451 fn default() -> Self {
6452 Self {
6453 extensions: Vec::new(),
6454 label: None,
6455 timestamp_writes: None,
6456 }
6457 }
6458 }
6459 impl ComputePassDescriptor {
6460 pub fn new() -> Self {
6461 Self::default()
6462 }
6463 pub(crate) fn to_ffi(
6464 &self,
6465 ) -> (ffi::WGPUComputePassDescriptor, ChainedStructStorage) {
6466 let mut storage = ChainedStructStorage::new();
6467 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6468 for ext in self.extensions.iter().rev() {
6469 next = ext.push_chain(&mut storage, next);
6470 }
6471 let mut raw: ffi::WGPUComputePassDescriptor = unsafe { std::mem::zeroed() };
6472 raw.nextInChain = next;
6473 if let Some(value) = &self.label {
6474 raw.label = ffi::WGPUStringView {
6475 data: value.as_ptr().cast(),
6476 length: value.len(),
6477 };
6478 } else {
6479 raw.label = ffi::WGPUStringView {
6480 data: std::ptr::null(),
6481 length: 0,
6482 };
6483 }
6484 if let Some(value) = &self.timestamp_writes {
6485 let (raw_value, storage_value) = value.to_ffi();
6486 let ptr = storage.push_value(raw_value);
6487 raw.timestampWrites = ptr;
6488 storage.push_storage(storage_value);
6489 } else {
6490 raw.timestampWrites = std::ptr::null();
6491 }
6492 (raw, storage)
6493 }
6494 pub fn with_extension(
6495 mut self,
6496 extension: ComputePassDescriptorExtension,
6497 ) -> Self {
6498 self.extensions.push(extension);
6499 self
6500 }
6501 pub(crate) fn from_ffi(value: ffi::WGPUComputePassDescriptor) -> Self {
6502 Self {
6503 extensions: Vec::new(),
6504 label: if value.label.data.is_null() || value.label.length == 0 {
6505 None
6506 } else {
6507 Some(string_view_to_string(value.label))
6508 },
6509 timestamp_writes: if value.timestampWrites.is_null() {
6510 None
6511 } else {
6512 Some(
6513 PassTimestampWrites::from_ffi(unsafe { *value.timestampWrites }),
6514 )
6515 },
6516 }
6517 }
6518 }
6519 pub struct ComputePipelineDescriptor {
6520 pub(crate) extensions: Vec<ComputePipelineDescriptorExtension>,
6521 pub label: Option<String>,
6522 pub layout: Option<PipelineLayout>,
6523 pub compute: Option<ComputeState>,
6524 }
6525 impl Default for ComputePipelineDescriptor {
6526 fn default() -> Self {
6527 Self {
6528 extensions: Vec::new(),
6529 label: None,
6530 layout: None,
6531 compute: None,
6532 }
6533 }
6534 }
6535 impl ComputePipelineDescriptor {
6536 pub fn new() -> Self {
6537 Self::default()
6538 }
6539 pub(crate) fn to_ffi(
6540 &self,
6541 ) -> (ffi::WGPUComputePipelineDescriptor, ChainedStructStorage) {
6542 let mut storage = ChainedStructStorage::new();
6543 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6544 for ext in self.extensions.iter().rev() {
6545 next = ext.push_chain(&mut storage, next);
6546 }
6547 let mut raw: ffi::WGPUComputePipelineDescriptor = unsafe {
6548 std::mem::zeroed()
6549 };
6550 raw.nextInChain = next;
6551 if let Some(value) = &self.label {
6552 raw.label = ffi::WGPUStringView {
6553 data: value.as_ptr().cast(),
6554 length: value.len(),
6555 };
6556 } else {
6557 raw.label = ffi::WGPUStringView {
6558 data: std::ptr::null(),
6559 length: 0,
6560 };
6561 }
6562 raw.layout = self
6563 .layout
6564 .as_ref()
6565 .map(|v| v.as_raw())
6566 .unwrap_or(std::ptr::null_mut());
6567 if let Some(value) = &self.compute {
6568 let (raw_value, storage_value) = value.to_ffi();
6569 raw.compute = raw_value;
6570 storage.push_storage(storage_value);
6571 }
6572 (raw, storage)
6573 }
6574 pub fn with_extension(
6575 mut self,
6576 extension: ComputePipelineDescriptorExtension,
6577 ) -> Self {
6578 self.extensions.push(extension);
6579 self
6580 }
6581 pub(crate) fn from_ffi(value: ffi::WGPUComputePipelineDescriptor) -> Self {
6582 Self {
6583 extensions: Vec::new(),
6584 label: if value.label.data.is_null() || value.label.length == 0 {
6585 None
6586 } else {
6587 Some(string_view_to_string(value.label))
6588 },
6589 layout: if value.layout.is_null() {
6590 None
6591 } else {
6592 Some(unsafe { PipelineLayout::from_raw(value.layout) })
6593 },
6594 compute: Some(ComputeState::from_ffi(value.compute)),
6595 }
6596 }
6597 }
6598 pub struct ComputeState {
6599 pub(crate) extensions: Vec<ComputeStateExtension>,
6600 pub module: Option<ShaderModule>,
6601 pub entry_point: Option<String>,
6602 pub constants: Option<Vec<ConstantEntry>>,
6603 }
6604 impl Default for ComputeState {
6605 fn default() -> Self {
6606 Self {
6607 extensions: Vec::new(),
6608 module: None,
6609 entry_point: None,
6610 constants: None,
6611 }
6612 }
6613 }
6614 impl ComputeState {
6615 pub fn new() -> Self {
6616 Self::default()
6617 }
6618 pub(crate) fn to_ffi(&self) -> (ffi::WGPUComputeState, ChainedStructStorage) {
6619 let mut storage = ChainedStructStorage::new();
6620 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6621 for ext in self.extensions.iter().rev() {
6622 next = ext.push_chain(&mut storage, next);
6623 }
6624 let mut raw: ffi::WGPUComputeState = unsafe { std::mem::zeroed() };
6625 raw.nextInChain = next;
6626 raw.module = self
6627 .module
6628 .as_ref()
6629 .map(|v| v.as_raw())
6630 .unwrap_or(std::ptr::null_mut());
6631 if let Some(value) = &self.entry_point {
6632 raw.entryPoint = ffi::WGPUStringView {
6633 data: value.as_ptr().cast(),
6634 length: value.len(),
6635 };
6636 } else {
6637 raw.entryPoint = ffi::WGPUStringView {
6638 data: std::ptr::null(),
6639 length: 0,
6640 };
6641 }
6642 raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
6643 if let Some(values) = &self.constants {
6644 let len_value = values.len();
6645 let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
6646 values.len(),
6647 );
6648 for item in values.iter() {
6649 let (raw_item, storage_item) = item.to_ffi();
6650 raw_vec.push(raw_item);
6651 storage.push_storage(storage_item);
6652 }
6653 let ptr = storage.push_vec(raw_vec);
6654 raw.constants = ptr;
6655 raw.constantCount = len_value;
6656 } else {
6657 raw.constants = std::ptr::null();
6658 raw.constantCount = 0;
6659 }
6660 (raw, storage)
6661 }
6662 pub fn with_extension(mut self, extension: ComputeStateExtension) -> Self {
6663 self.extensions.push(extension);
6664 self
6665 }
6666 pub(crate) fn from_ffi(value: ffi::WGPUComputeState) -> Self {
6667 Self {
6668 extensions: Vec::new(),
6669 module: Some(unsafe { ShaderModule::from_raw(value.module) }),
6670 entry_point: if value.entryPoint.data.is_null()
6671 || value.entryPoint.length == 0
6672 {
6673 None
6674 } else {
6675 Some(string_view_to_string(value.entryPoint))
6676 },
6677 constants: if value.constants.is_null() {
6678 None
6679 } else {
6680 Some(
6681 unsafe {
6682 std::slice::from_raw_parts(
6683 value.constants,
6684 value.constantCount as usize,
6685 )
6686 }
6687 .iter()
6688 .map(|raw| ConstantEntry::from_ffi(*raw))
6689 .collect(),
6690 )
6691 },
6692 }
6693 }
6694 }
6695 pub struct ConstantEntry {
6696 pub(crate) extensions: Vec<ConstantEntryExtension>,
6697 pub key: Option<String>,
6698 pub value: Option<f64>,
6699 }
6700 impl Default for ConstantEntry {
6701 fn default() -> Self {
6702 Self {
6703 extensions: Vec::new(),
6704 key: None,
6705 value: None,
6706 }
6707 }
6708 }
6709 impl ConstantEntry {
6710 pub fn new() -> Self {
6711 Self::default()
6712 }
6713 pub(crate) fn to_ffi(&self) -> (ffi::WGPUConstantEntry, ChainedStructStorage) {
6714 let mut storage = ChainedStructStorage::new();
6715 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6716 for ext in self.extensions.iter().rev() {
6717 next = ext.push_chain(&mut storage, next);
6718 }
6719 let mut raw: ffi::WGPUConstantEntry = unsafe { std::mem::zeroed() };
6720 raw.nextInChain = next;
6721 if let Some(value) = &self.key {
6722 raw.key = ffi::WGPUStringView {
6723 data: value.as_ptr().cast(),
6724 length: value.len(),
6725 };
6726 } else {
6727 raw.key = ffi::WGPUStringView {
6728 data: std::ptr::null(),
6729 length: 0,
6730 };
6731 }
6732 if let Some(value) = self.value {
6733 raw.value = value;
6734 }
6735 (raw, storage)
6736 }
6737 pub fn with_extension(mut self, extension: ConstantEntryExtension) -> Self {
6738 self.extensions.push(extension);
6739 self
6740 }
6741 pub(crate) fn from_ffi(value: ffi::WGPUConstantEntry) -> Self {
6742 Self {
6743 extensions: Vec::new(),
6744 key: Some(string_view_to_string(value.key)),
6745 value: Some(value.value),
6746 }
6747 }
6748 }
6749 pub struct CopyTextureForBrowserOptions {
6750 pub(crate) extensions: Vec<CopyTextureForBrowserOptionsExtension>,
6751 pub flip_y: Option<bool>,
6752 pub needs_color_space_conversion: Option<bool>,
6753 pub src_alpha_mode: Option<AlphaMode>,
6754 pub src_transfer_function_parameters: Option<Vec<f32>>,
6755 pub conversion_matrix: Option<Vec<f32>>,
6756 pub dst_transfer_function_parameters: Option<Vec<f32>>,
6757 pub dst_alpha_mode: Option<AlphaMode>,
6758 pub internal_usage: Option<bool>,
6759 }
6760 impl Default for CopyTextureForBrowserOptions {
6761 fn default() -> Self {
6762 Self {
6763 extensions: Vec::new(),
6764 flip_y: None,
6765 needs_color_space_conversion: None,
6766 src_alpha_mode: Some(AlphaMode::Unpremultiplied),
6767 src_transfer_function_parameters: None,
6768 conversion_matrix: None,
6769 dst_transfer_function_parameters: None,
6770 dst_alpha_mode: Some(AlphaMode::Unpremultiplied),
6771 internal_usage: None,
6772 }
6773 }
6774 }
6775 impl CopyTextureForBrowserOptions {
6776 pub fn new() -> Self {
6777 Self::default()
6778 }
6779 pub(crate) fn to_ffi(
6780 &self,
6781 ) -> (ffi::WGPUCopyTextureForBrowserOptions, ChainedStructStorage) {
6782 let mut storage = ChainedStructStorage::new();
6783 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6784 for ext in self.extensions.iter().rev() {
6785 next = ext.push_chain(&mut storage, next);
6786 }
6787 let mut raw: ffi::WGPUCopyTextureForBrowserOptions = unsafe {
6788 std::mem::zeroed()
6789 };
6790 raw.nextInChain = next;
6791 raw.flipY = if self.flip_y.unwrap_or(false) { 1 } else { 0 };
6792 raw.needsColorSpaceConversion = if self
6793 .needs_color_space_conversion
6794 .unwrap_or(false)
6795 {
6796 1
6797 } else {
6798 0
6799 };
6800 if let Some(value) = self.src_alpha_mode {
6801 raw.srcAlphaMode = value.into();
6802 } else {
6803 raw.srcAlphaMode = 0 as ffi::WGPUAlphaMode;
6804 }
6805 if let Some(values) = &self.src_transfer_function_parameters {
6806 let len_value = values.len();
6807 let raw_vec = values.to_vec();
6808 let ptr = storage.push_vec(raw_vec);
6809 raw.srcTransferFunctionParameters = ptr;
6810 } else {
6811 raw.srcTransferFunctionParameters = std::ptr::null();
6812 let _ = 0;
6813 }
6814 if let Some(values) = &self.conversion_matrix {
6815 let len_value = values.len();
6816 let raw_vec = values.to_vec();
6817 let ptr = storage.push_vec(raw_vec);
6818 raw.conversionMatrix = ptr;
6819 } else {
6820 raw.conversionMatrix = std::ptr::null();
6821 let _ = 0;
6822 }
6823 if let Some(values) = &self.dst_transfer_function_parameters {
6824 let len_value = values.len();
6825 let raw_vec = values.to_vec();
6826 let ptr = storage.push_vec(raw_vec);
6827 raw.dstTransferFunctionParameters = ptr;
6828 } else {
6829 raw.dstTransferFunctionParameters = std::ptr::null();
6830 let _ = 0;
6831 }
6832 if let Some(value) = self.dst_alpha_mode {
6833 raw.dstAlphaMode = value.into();
6834 } else {
6835 raw.dstAlphaMode = 0 as ffi::WGPUAlphaMode;
6836 }
6837 raw.internalUsage = if self.internal_usage.unwrap_or(false) { 1 } else { 0 };
6838 (raw, storage)
6839 }
6840 pub fn with_extension(
6841 mut self,
6842 extension: CopyTextureForBrowserOptionsExtension,
6843 ) -> Self {
6844 self.extensions.push(extension);
6845 self
6846 }
6847 pub(crate) fn from_ffi(value: ffi::WGPUCopyTextureForBrowserOptions) -> Self {
6848 Self {
6849 extensions: Vec::new(),
6850 flip_y: Some(value.flipY != 0),
6851 needs_color_space_conversion: Some(value.needsColorSpaceConversion != 0),
6852 src_alpha_mode: Some(value.srcAlphaMode.into()),
6853 src_transfer_function_parameters: if value
6854 .srcTransferFunctionParameters
6855 .is_null()
6856 {
6857 None
6858 } else {
6859 Some(
6860 unsafe {
6861 std::slice::from_raw_parts(
6862 value.srcTransferFunctionParameters,
6863 7usize,
6864 )
6865 }
6866 .to_vec(),
6867 )
6868 },
6869 conversion_matrix: if value.conversionMatrix.is_null() {
6870 None
6871 } else {
6872 Some(
6873 unsafe {
6874 std::slice::from_raw_parts(value.conversionMatrix, 9usize)
6875 }
6876 .to_vec(),
6877 )
6878 },
6879 dst_transfer_function_parameters: if value
6880 .dstTransferFunctionParameters
6881 .is_null()
6882 {
6883 None
6884 } else {
6885 Some(
6886 unsafe {
6887 std::slice::from_raw_parts(
6888 value.dstTransferFunctionParameters,
6889 7usize,
6890 )
6891 }
6892 .to_vec(),
6893 )
6894 },
6895 dst_alpha_mode: Some(value.dstAlphaMode.into()),
6896 internal_usage: Some(value.internalUsage != 0),
6897 }
6898 }
6899 }
6900 pub struct DawnWGSLBlocklist {
6901 pub blocklisted_features: Option<Vec<String>>,
6902 }
6903 impl Default for DawnWGSLBlocklist {
6904 fn default() -> Self {
6905 Self { blocklisted_features: None }
6906 }
6907 }
6908 impl DawnWGSLBlocklist {
6909 pub fn new() -> Self {
6910 Self::default()
6911 }
6912 pub(crate) fn to_ffi(
6913 &self,
6914 ) -> (ffi::WGPUDawnWGSLBlocklist, ChainedStructStorage) {
6915 let mut storage = ChainedStructStorage::new();
6916 let mut raw: ffi::WGPUDawnWGSLBlocklist = unsafe { std::mem::zeroed() };
6917 raw.blocklistedFeatureCount = self
6918 .blocklisted_features
6919 .as_ref()
6920 .map(|v| v.len())
6921 .unwrap_or(0);
6922 if let Some(values) = &self.blocklisted_features {
6923 let len_value = values.len();
6924 let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
6925 values.len(),
6926 );
6927 let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
6928 values.len(),
6929 );
6930 for item in values.iter() {
6931 let c_string = std::ffi::CString::new(item.as_str())
6932 .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
6933 ptrs.push(c_string.as_ptr());
6934 c_strings.push(c_string);
6935 }
6936 let ptr = storage.push_vec(ptrs);
6937 storage.push_any(c_strings);
6938 raw.blocklistedFeatures = ptr;
6939 raw.blocklistedFeatureCount = len_value;
6940 } else {
6941 raw.blocklistedFeatures = std::ptr::null();
6942 raw.blocklistedFeatureCount = 0;
6943 }
6944 (raw, storage)
6945 }
6946 pub(crate) fn from_ffi(value: ffi::WGPUDawnWGSLBlocklist) -> Self {
6947 Self {
6948 blocklisted_features: if value.blocklistedFeatures.is_null() {
6949 None
6950 } else {
6951 Some(
6952 unsafe {
6953 std::slice::from_raw_parts(
6954 value.blocklistedFeatures,
6955 value.blocklistedFeatureCount as usize,
6956 )
6957 }
6958 .iter()
6959 .map(|raw| {
6960 if raw.is_null() {
6961 String::new()
6962 } else {
6963 unsafe { CStr::from_ptr(*raw) }
6964 .to_string_lossy()
6965 .into_owned()
6966 }
6967 })
6968 .collect(),
6969 )
6970 },
6971 }
6972 }
6973 }
6974 pub struct DawnAdapterPropertiesPowerPreference {
6975 pub power_preference: Option<PowerPreference>,
6976 }
6977 impl Default for DawnAdapterPropertiesPowerPreference {
6978 fn default() -> Self {
6979 Self { power_preference: None }
6980 }
6981 }
6982 impl DawnAdapterPropertiesPowerPreference {
6983 pub fn new() -> Self {
6984 Self::default()
6985 }
6986 pub(crate) fn to_ffi(
6987 &self,
6988 ) -> (ffi::WGPUDawnAdapterPropertiesPowerPreference, ChainedStructStorage) {
6989 let mut storage = ChainedStructStorage::new();
6990 let mut raw: ffi::WGPUDawnAdapterPropertiesPowerPreference = unsafe {
6991 std::mem::zeroed()
6992 };
6993 if let Some(value) = self.power_preference {
6994 raw.powerPreference = value.into();
6995 } else {
6996 raw.powerPreference = 0 as ffi::WGPUPowerPreference;
6997 }
6998 (raw, storage)
6999 }
7000 pub(crate) fn from_ffi(
7001 value: ffi::WGPUDawnAdapterPropertiesPowerPreference,
7002 ) -> Self {
7003 Self {
7004 power_preference: Some(value.powerPreference.into()),
7005 }
7006 }
7007 }
7008 pub struct DawnBufferDescriptorErrorInfoFromWireClient {
7009 pub out_of_memory: Option<bool>,
7010 }
7011 impl Default for DawnBufferDescriptorErrorInfoFromWireClient {
7012 fn default() -> Self {
7013 Self { out_of_memory: None }
7014 }
7015 }
7016 impl DawnBufferDescriptorErrorInfoFromWireClient {
7017 pub fn new() -> Self {
7018 Self::default()
7019 }
7020 pub(crate) fn to_ffi(
7021 &self,
7022 ) -> (
7023 ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient,
7024 ChainedStructStorage,
7025 ) {
7026 let mut storage = ChainedStructStorage::new();
7027 let mut raw: ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient = unsafe {
7028 std::mem::zeroed()
7029 };
7030 raw.outOfMemory = if self.out_of_memory.unwrap_or(false) { 1 } else { 0 };
7031 (raw, storage)
7032 }
7033 pub(crate) fn from_ffi(
7034 value: ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient,
7035 ) -> Self {
7036 Self {
7037 out_of_memory: Some(value.outOfMemory != 0),
7038 }
7039 }
7040 }
7041 pub struct DawnCacheDeviceDescriptor {
7042 pub isolation_key: Option<String>,
7043 pub load_data_function: Option<DawnLoadCacheDataFunction>,
7044 pub store_data_function: Option<DawnStoreCacheDataFunction>,
7045 pub function_userdata: Option<*mut std::ffi::c_void>,
7046 }
7047 impl Default for DawnCacheDeviceDescriptor {
7048 fn default() -> Self {
7049 Self {
7050 isolation_key: None,
7051 load_data_function: None,
7052 store_data_function: None,
7053 function_userdata: None,
7054 }
7055 }
7056 }
7057 impl DawnCacheDeviceDescriptor {
7058 pub fn new() -> Self {
7059 Self::default()
7060 }
7061 pub(crate) fn to_ffi(
7062 &self,
7063 ) -> (ffi::WGPUDawnCacheDeviceDescriptor, ChainedStructStorage) {
7064 let mut storage = ChainedStructStorage::new();
7065 let mut raw: ffi::WGPUDawnCacheDeviceDescriptor = unsafe {
7066 std::mem::zeroed()
7067 };
7068 if let Some(value) = &self.isolation_key {
7069 raw.isolationKey = ffi::WGPUStringView {
7070 data: value.as_ptr().cast(),
7071 length: value.len(),
7072 };
7073 } else {
7074 raw.isolationKey = ffi::WGPUStringView {
7075 data: std::ptr::null(),
7076 length: 0,
7077 };
7078 }
7079 if let Some(value) = self.load_data_function {
7080 raw.loadDataFunction = value;
7081 }
7082 if let Some(value) = self.store_data_function {
7083 raw.storeDataFunction = value;
7084 }
7085 if let Some(value) = self.function_userdata {
7086 raw.functionUserdata = value;
7087 }
7088 (raw, storage)
7089 }
7090 pub(crate) fn from_ffi(value: ffi::WGPUDawnCacheDeviceDescriptor) -> Self {
7091 Self {
7092 isolation_key: Some(string_view_to_string(value.isolationKey)),
7093 load_data_function: Some(value.loadDataFunction),
7094 store_data_function: Some(value.storeDataFunction),
7095 function_userdata: Some(value.functionUserdata),
7096 }
7097 }
7098 }
7099 pub struct DawnCompilationMessageUtf16 {
7100 pub line_pos: Option<u64>,
7101 pub offset: Option<u64>,
7102 pub length: Option<u64>,
7103 }
7104 impl Default for DawnCompilationMessageUtf16 {
7105 fn default() -> Self {
7106 Self {
7107 line_pos: None,
7108 offset: None,
7109 length: None,
7110 }
7111 }
7112 }
7113 impl DawnCompilationMessageUtf16 {
7114 pub fn new() -> Self {
7115 Self::default()
7116 }
7117 pub(crate) fn to_ffi(
7118 &self,
7119 ) -> (ffi::WGPUDawnCompilationMessageUtf16, ChainedStructStorage) {
7120 let mut storage = ChainedStructStorage::new();
7121 let mut raw: ffi::WGPUDawnCompilationMessageUtf16 = unsafe {
7122 std::mem::zeroed()
7123 };
7124 if let Some(value) = self.line_pos {
7125 raw.linePos = value;
7126 }
7127 if let Some(value) = self.offset {
7128 raw.offset = value;
7129 }
7130 if let Some(value) = self.length {
7131 raw.length = value;
7132 }
7133 (raw, storage)
7134 }
7135 pub(crate) fn from_ffi(value: ffi::WGPUDawnCompilationMessageUtf16) -> Self {
7136 Self {
7137 line_pos: Some(value.linePos),
7138 offset: Some(value.offset),
7139 length: Some(value.length),
7140 }
7141 }
7142 }
7143 pub struct DawnConsumeAdapterDescriptor {
7144 pub consume_adapter: Option<bool>,
7145 }
7146 impl Default for DawnConsumeAdapterDescriptor {
7147 fn default() -> Self {
7148 Self { consume_adapter: None }
7149 }
7150 }
7151 impl DawnConsumeAdapterDescriptor {
7152 pub fn new() -> Self {
7153 Self::default()
7154 }
7155 pub(crate) fn to_ffi(
7156 &self,
7157 ) -> (ffi::WGPUDawnConsumeAdapterDescriptor, ChainedStructStorage) {
7158 let mut storage = ChainedStructStorage::new();
7159 let mut raw: ffi::WGPUDawnConsumeAdapterDescriptor = unsafe {
7160 std::mem::zeroed()
7161 };
7162 raw.consumeAdapter = if self.consume_adapter.unwrap_or(false) {
7163 1
7164 } else {
7165 0
7166 };
7167 (raw, storage)
7168 }
7169 pub(crate) fn from_ffi(value: ffi::WGPUDawnConsumeAdapterDescriptor) -> Self {
7170 Self {
7171 consume_adapter: Some(value.consumeAdapter != 0),
7172 }
7173 }
7174 }
7175 pub struct DawnDeviceAllocatorControl {
7176 pub allocator_heap_block_size: Option<usize>,
7177 }
7178 impl Default for DawnDeviceAllocatorControl {
7179 fn default() -> Self {
7180 Self {
7181 allocator_heap_block_size: Some(0),
7182 }
7183 }
7184 }
7185 impl DawnDeviceAllocatorControl {
7186 pub fn new() -> Self {
7187 Self::default()
7188 }
7189 pub(crate) fn to_ffi(
7190 &self,
7191 ) -> (ffi::WGPUDawnDeviceAllocatorControl, ChainedStructStorage) {
7192 let mut storage = ChainedStructStorage::new();
7193 let mut raw: ffi::WGPUDawnDeviceAllocatorControl = unsafe {
7194 std::mem::zeroed()
7195 };
7196 if let Some(value) = self.allocator_heap_block_size {
7197 raw.allocatorHeapBlockSize = value;
7198 }
7199 (raw, storage)
7200 }
7201 pub(crate) fn from_ffi(value: ffi::WGPUDawnDeviceAllocatorControl) -> Self {
7202 Self {
7203 allocator_heap_block_size: Some(value.allocatorHeapBlockSize),
7204 }
7205 }
7206 }
7207 pub struct DawnDrmFormatCapabilities {
7208 pub properties: Option<Vec<DawnDrmFormatProperties>>,
7209 #[doc(hidden)]
7210 pub(crate) _free_members: Option<ffi::WGPUDawnDrmFormatCapabilities>,
7211 }
7212 impl Default for DawnDrmFormatCapabilities {
7213 fn default() -> Self {
7214 Self {
7215 properties: None,
7216 _free_members: None,
7217 }
7218 }
7219 }
7220 impl DawnDrmFormatCapabilities {
7221 pub fn new() -> Self {
7222 Self::default()
7223 }
7224 pub(crate) fn to_ffi(
7225 &self,
7226 ) -> (ffi::WGPUDawnDrmFormatCapabilities, ChainedStructStorage) {
7227 let mut storage = ChainedStructStorage::new();
7228 let mut raw: ffi::WGPUDawnDrmFormatCapabilities = unsafe {
7229 std::mem::zeroed()
7230 };
7231 raw.propertiesCount = self.properties.as_ref().map(|v| v.len()).unwrap_or(0);
7232 if let Some(values) = &self.properties {
7233 let len_value = values.len();
7234 let mut raw_vec: Vec<ffi::WGPUDawnDrmFormatProperties> = Vec::with_capacity(
7235 values.len(),
7236 );
7237 for item in values.iter() {
7238 let (raw_item, storage_item) = item.to_ffi();
7239 raw_vec.push(raw_item);
7240 storage.push_storage(storage_item);
7241 }
7242 let ptr = storage.push_vec(raw_vec);
7243 raw.properties = ptr;
7244 raw.propertiesCount = len_value;
7245 } else {
7246 raw.properties = std::ptr::null();
7247 raw.propertiesCount = 0;
7248 }
7249 (raw, storage)
7250 }
7251 pub(crate) fn from_ffi(value: ffi::WGPUDawnDrmFormatCapabilities) -> Self {
7252 Self {
7253 properties: if value.properties.is_null() {
7254 None
7255 } else {
7256 Some(
7257 unsafe {
7258 std::slice::from_raw_parts(
7259 value.properties,
7260 value.propertiesCount as usize,
7261 )
7262 }
7263 .iter()
7264 .map(|raw| DawnDrmFormatProperties::from_ffi(*raw))
7265 .collect(),
7266 )
7267 },
7268 _free_members: Some(value),
7269 }
7270 }
7271 pub(crate) fn free_members(value: ffi::WGPUDawnDrmFormatCapabilities) {
7272 unsafe { ffi::wgpuDawnDrmFormatCapabilitiesFreeMembers(value) };
7273 }
7274 }
7275 impl Drop for DawnDrmFormatCapabilities {
7276 fn drop(&mut self) {
7277 if let Some(value) = self._free_members.take() {
7278 unsafe { ffi::wgpuDawnDrmFormatCapabilitiesFreeMembers(value) };
7279 }
7280 }
7281 }
7282 pub struct DawnDrmFormatProperties {
7283 pub modifier: Option<u64>,
7284 pub modifier_plane_count: Option<u32>,
7285 }
7286 impl Default for DawnDrmFormatProperties {
7287 fn default() -> Self {
7288 Self {
7289 modifier: None,
7290 modifier_plane_count: None,
7291 }
7292 }
7293 }
7294 impl DawnDrmFormatProperties {
7295 pub fn new() -> Self {
7296 Self::default()
7297 }
7298 pub(crate) fn to_ffi(
7299 &self,
7300 ) -> (ffi::WGPUDawnDrmFormatProperties, ChainedStructStorage) {
7301 let mut storage = ChainedStructStorage::new();
7302 let mut raw: ffi::WGPUDawnDrmFormatProperties = unsafe {
7303 std::mem::zeroed()
7304 };
7305 if let Some(value) = self.modifier {
7306 raw.modifier = value;
7307 }
7308 if let Some(value) = self.modifier_plane_count {
7309 raw.modifierPlaneCount = value;
7310 }
7311 (raw, storage)
7312 }
7313 pub(crate) fn from_ffi(value: ffi::WGPUDawnDrmFormatProperties) -> Self {
7314 Self {
7315 modifier: Some(value.modifier),
7316 modifier_plane_count: Some(value.modifierPlaneCount),
7317 }
7318 }
7319 }
7320 pub struct DawnEncoderInternalUsageDescriptor {
7321 pub use_internal_usages: Option<bool>,
7322 }
7323 impl Default for DawnEncoderInternalUsageDescriptor {
7324 fn default() -> Self {
7325 Self { use_internal_usages: None }
7326 }
7327 }
7328 impl DawnEncoderInternalUsageDescriptor {
7329 pub fn new() -> Self {
7330 Self::default()
7331 }
7332 pub(crate) fn to_ffi(
7333 &self,
7334 ) -> (ffi::WGPUDawnEncoderInternalUsageDescriptor, ChainedStructStorage) {
7335 let mut storage = ChainedStructStorage::new();
7336 let mut raw: ffi::WGPUDawnEncoderInternalUsageDescriptor = unsafe {
7337 std::mem::zeroed()
7338 };
7339 raw.useInternalUsages = if self.use_internal_usages.unwrap_or(false) {
7340 1
7341 } else {
7342 0
7343 };
7344 (raw, storage)
7345 }
7346 pub(crate) fn from_ffi(
7347 value: ffi::WGPUDawnEncoderInternalUsageDescriptor,
7348 ) -> Self {
7349 Self {
7350 use_internal_usages: Some(value.useInternalUsages != 0),
7351 }
7352 }
7353 }
7354 pub struct DawnFakeBufferOOMForTesting {
7355 pub fake_oom_at_wire_client_map: Option<bool>,
7356 pub fake_oom_at_native_map: Option<bool>,
7357 pub fake_oom_at_device: Option<bool>,
7358 }
7359 impl Default for DawnFakeBufferOOMForTesting {
7360 fn default() -> Self {
7361 Self {
7362 fake_oom_at_wire_client_map: None,
7363 fake_oom_at_native_map: None,
7364 fake_oom_at_device: None,
7365 }
7366 }
7367 }
7368 impl DawnFakeBufferOOMForTesting {
7369 pub fn new() -> Self {
7370 Self::default()
7371 }
7372 pub(crate) fn to_ffi(
7373 &self,
7374 ) -> (ffi::WGPUDawnFakeBufferOOMForTesting, ChainedStructStorage) {
7375 let mut storage = ChainedStructStorage::new();
7376 let mut raw: ffi::WGPUDawnFakeBufferOOMForTesting = unsafe {
7377 std::mem::zeroed()
7378 };
7379 raw.fakeOOMAtWireClientMap = if self
7380 .fake_oom_at_wire_client_map
7381 .unwrap_or(false)
7382 {
7383 1
7384 } else {
7385 0
7386 };
7387 raw.fakeOOMAtNativeMap = if self.fake_oom_at_native_map.unwrap_or(false) {
7388 1
7389 } else {
7390 0
7391 };
7392 raw.fakeOOMAtDevice = if self.fake_oom_at_device.unwrap_or(false) {
7393 1
7394 } else {
7395 0
7396 };
7397 (raw, storage)
7398 }
7399 pub(crate) fn from_ffi(value: ffi::WGPUDawnFakeBufferOOMForTesting) -> Self {
7400 Self {
7401 fake_oom_at_wire_client_map: Some(value.fakeOOMAtWireClientMap != 0),
7402 fake_oom_at_native_map: Some(value.fakeOOMAtNativeMap != 0),
7403 fake_oom_at_device: Some(value.fakeOOMAtDevice != 0),
7404 }
7405 }
7406 }
7407 pub struct DawnFakeDeviceInitializeErrorForTesting {}
7408 impl Default for DawnFakeDeviceInitializeErrorForTesting {
7409 fn default() -> Self {
7410 Self {}
7411 }
7412 }
7413 impl DawnFakeDeviceInitializeErrorForTesting {
7414 pub fn new() -> Self {
7415 Self::default()
7416 }
7417 pub(crate) fn to_ffi(
7418 &self,
7419 ) -> (ffi::WGPUDawnFakeDeviceInitializeErrorForTesting, ChainedStructStorage) {
7420 let mut storage = ChainedStructStorage::new();
7421 let mut raw: ffi::WGPUDawnFakeDeviceInitializeErrorForTesting = unsafe {
7422 std::mem::zeroed()
7423 };
7424 (raw, storage)
7425 }
7426 pub(crate) fn from_ffi(
7427 value: ffi::WGPUDawnFakeDeviceInitializeErrorForTesting,
7428 ) -> Self {
7429 let _ = value;
7430 Self::default()
7431 }
7432 }
7433 pub struct DawnFormatCapabilities {
7434 pub(crate) extensions: Vec<DawnFormatCapabilitiesExtension>,
7435 }
7436 impl Default for DawnFormatCapabilities {
7437 fn default() -> Self {
7438 Self { extensions: Vec::new() }
7439 }
7440 }
7441 impl DawnFormatCapabilities {
7442 pub fn new() -> Self {
7443 Self::default()
7444 }
7445 pub(crate) fn to_ffi(
7446 &self,
7447 ) -> (ffi::WGPUDawnFormatCapabilities, ChainedStructStorage) {
7448 let mut storage = ChainedStructStorage::new();
7449 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7450 for ext in self.extensions.iter().rev() {
7451 next = ext.push_chain(&mut storage, next);
7452 }
7453 let mut raw: ffi::WGPUDawnFormatCapabilities = unsafe { std::mem::zeroed() };
7454 raw.nextInChain = next;
7455 (raw, storage)
7456 }
7457 pub fn with_extension(
7458 mut self,
7459 extension: DawnFormatCapabilitiesExtension,
7460 ) -> Self {
7461 self.extensions.push(extension);
7462 self
7463 }
7464 pub(crate) fn from_ffi(value: ffi::WGPUDawnFormatCapabilities) -> Self {
7465 Self { extensions: Vec::new() }
7466 }
7467 }
7468 pub struct DawnHostMappedPointerLimits {
7469 pub host_mapped_pointer_alignment: Option<u32>,
7470 }
7471 impl Default for DawnHostMappedPointerLimits {
7472 fn default() -> Self {
7473 Self {
7474 host_mapped_pointer_alignment: Some(LIMIT_U32_UNDEFINED),
7475 }
7476 }
7477 }
7478 impl DawnHostMappedPointerLimits {
7479 pub fn new() -> Self {
7480 Self::default()
7481 }
7482 pub(crate) fn to_ffi(
7483 &self,
7484 ) -> (ffi::WGPUDawnHostMappedPointerLimits, ChainedStructStorage) {
7485 let mut storage = ChainedStructStorage::new();
7486 let mut raw: ffi::WGPUDawnHostMappedPointerLimits = unsafe {
7487 std::mem::zeroed()
7488 };
7489 if let Some(value) = self.host_mapped_pointer_alignment {
7490 raw.hostMappedPointerAlignment = value;
7491 }
7492 (raw, storage)
7493 }
7494 pub(crate) fn from_ffi(value: ffi::WGPUDawnHostMappedPointerLimits) -> Self {
7495 Self {
7496 host_mapped_pointer_alignment: Some(value.hostMappedPointerAlignment),
7497 }
7498 }
7499 }
7500 pub struct DawnInjectedInvalidSType {
7501 pub invalid_s_type: Option<SType>,
7502 }
7503 impl Default for DawnInjectedInvalidSType {
7504 fn default() -> Self {
7505 Self { invalid_s_type: None }
7506 }
7507 }
7508 impl DawnInjectedInvalidSType {
7509 pub fn new() -> Self {
7510 Self::default()
7511 }
7512 pub(crate) fn to_ffi(
7513 &self,
7514 ) -> (ffi::WGPUDawnInjectedInvalidSType, ChainedStructStorage) {
7515 let mut storage = ChainedStructStorage::new();
7516 let mut raw: ffi::WGPUDawnInjectedInvalidSType = unsafe {
7517 std::mem::zeroed()
7518 };
7519 if let Some(value) = self.invalid_s_type {
7520 raw.invalidSType = value.into();
7521 } else {
7522 raw.invalidSType = 0 as ffi::WGPUSType;
7523 }
7524 (raw, storage)
7525 }
7526 pub(crate) fn from_ffi(value: ffi::WGPUDawnInjectedInvalidSType) -> Self {
7527 Self {
7528 invalid_s_type: Some(value.invalidSType.into()),
7529 }
7530 }
7531 }
7532 pub struct DawnRenderPassSampleCount {
7533 pub sample_count: Option<u32>,
7534 }
7535 impl Default for DawnRenderPassSampleCount {
7536 fn default() -> Self {
7537 Self { sample_count: Some(1) }
7538 }
7539 }
7540 impl DawnRenderPassSampleCount {
7541 pub fn new() -> Self {
7542 Self::default()
7543 }
7544 pub(crate) fn to_ffi(
7545 &self,
7546 ) -> (ffi::WGPUDawnRenderPassSampleCount, ChainedStructStorage) {
7547 let mut storage = ChainedStructStorage::new();
7548 let mut raw: ffi::WGPUDawnRenderPassSampleCount = unsafe {
7549 std::mem::zeroed()
7550 };
7551 if let Some(value) = self.sample_count {
7552 raw.sampleCount = value;
7553 }
7554 (raw, storage)
7555 }
7556 pub(crate) fn from_ffi(value: ffi::WGPUDawnRenderPassSampleCount) -> Self {
7557 Self {
7558 sample_count: Some(value.sampleCount),
7559 }
7560 }
7561 }
7562 pub struct DawnShaderModuleSPIRVOptionsDescriptor {
7563 pub allow_non_uniform_derivatives: Option<bool>,
7564 }
7565 impl Default for DawnShaderModuleSPIRVOptionsDescriptor {
7566 fn default() -> Self {
7567 Self {
7568 allow_non_uniform_derivatives: None,
7569 }
7570 }
7571 }
7572 impl DawnShaderModuleSPIRVOptionsDescriptor {
7573 pub fn new() -> Self {
7574 Self::default()
7575 }
7576 pub(crate) fn to_ffi(
7577 &self,
7578 ) -> (ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor, ChainedStructStorage) {
7579 let mut storage = ChainedStructStorage::new();
7580 let mut raw: ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor = unsafe {
7581 std::mem::zeroed()
7582 };
7583 raw.allowNonUniformDerivatives = if self
7584 .allow_non_uniform_derivatives
7585 .unwrap_or(false)
7586 {
7587 1
7588 } else {
7589 0
7590 };
7591 (raw, storage)
7592 }
7593 pub(crate) fn from_ffi(
7594 value: ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor,
7595 ) -> Self {
7596 Self {
7597 allow_non_uniform_derivatives: Some(
7598 value.allowNonUniformDerivatives != 0,
7599 ),
7600 }
7601 }
7602 }
7603 pub struct DawnTexelCopyBufferRowAlignmentLimits {
7604 pub min_texel_copy_buffer_row_alignment: Option<u32>,
7605 }
7606 impl Default for DawnTexelCopyBufferRowAlignmentLimits {
7607 fn default() -> Self {
7608 Self {
7609 min_texel_copy_buffer_row_alignment: Some(LIMIT_U32_UNDEFINED),
7610 }
7611 }
7612 }
7613 impl DawnTexelCopyBufferRowAlignmentLimits {
7614 pub fn new() -> Self {
7615 Self::default()
7616 }
7617 pub(crate) fn to_ffi(
7618 &self,
7619 ) -> (ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits, ChainedStructStorage) {
7620 let mut storage = ChainedStructStorage::new();
7621 let mut raw: ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits = unsafe {
7622 std::mem::zeroed()
7623 };
7624 if let Some(value) = self.min_texel_copy_buffer_row_alignment {
7625 raw.minTexelCopyBufferRowAlignment = value;
7626 }
7627 (raw, storage)
7628 }
7629 pub(crate) fn from_ffi(
7630 value: ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits,
7631 ) -> Self {
7632 Self {
7633 min_texel_copy_buffer_row_alignment: Some(
7634 value.minTexelCopyBufferRowAlignment,
7635 ),
7636 }
7637 }
7638 }
7639 pub struct DawnTextureInternalUsageDescriptor {
7640 pub internal_usage: Option<TextureUsage>,
7641 }
7642 impl Default for DawnTextureInternalUsageDescriptor {
7643 fn default() -> Self {
7644 Self { internal_usage: None }
7645 }
7646 }
7647 impl DawnTextureInternalUsageDescriptor {
7648 pub fn new() -> Self {
7649 Self::default()
7650 }
7651 pub(crate) fn to_ffi(
7652 &self,
7653 ) -> (ffi::WGPUDawnTextureInternalUsageDescriptor, ChainedStructStorage) {
7654 let mut storage = ChainedStructStorage::new();
7655 let mut raw: ffi::WGPUDawnTextureInternalUsageDescriptor = unsafe {
7656 std::mem::zeroed()
7657 };
7658 if let Some(value) = self.internal_usage {
7659 raw.internalUsage = value.into();
7660 } else {
7661 raw.internalUsage = 0 as ffi::WGPUTextureUsage;
7662 }
7663 (raw, storage)
7664 }
7665 pub(crate) fn from_ffi(
7666 value: ffi::WGPUDawnTextureInternalUsageDescriptor,
7667 ) -> Self {
7668 Self {
7669 internal_usage: Some(value.internalUsage.into()),
7670 }
7671 }
7672 }
7673 pub struct DawnTogglesDescriptor {
7674 pub enabled_toggles: Option<Vec<String>>,
7675 pub disabled_toggles: Option<Vec<String>>,
7676 }
7677 impl Default for DawnTogglesDescriptor {
7678 fn default() -> Self {
7679 Self {
7680 enabled_toggles: None,
7681 disabled_toggles: None,
7682 }
7683 }
7684 }
7685 impl DawnTogglesDescriptor {
7686 pub fn new() -> Self {
7687 Self::default()
7688 }
7689 pub(crate) fn to_ffi(
7690 &self,
7691 ) -> (ffi::WGPUDawnTogglesDescriptor, ChainedStructStorage) {
7692 let mut storage = ChainedStructStorage::new();
7693 let mut raw: ffi::WGPUDawnTogglesDescriptor = unsafe { std::mem::zeroed() };
7694 raw.enabledToggleCount = self
7695 .enabled_toggles
7696 .as_ref()
7697 .map(|v| v.len())
7698 .unwrap_or(0);
7699 if let Some(values) = &self.enabled_toggles {
7700 let len_value = values.len();
7701 let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
7702 values.len(),
7703 );
7704 let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
7705 values.len(),
7706 );
7707 for item in values.iter() {
7708 let c_string = std::ffi::CString::new(item.as_str())
7709 .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
7710 ptrs.push(c_string.as_ptr());
7711 c_strings.push(c_string);
7712 }
7713 let ptr = storage.push_vec(ptrs);
7714 storage.push_any(c_strings);
7715 raw.enabledToggles = ptr;
7716 raw.enabledToggleCount = len_value;
7717 } else {
7718 raw.enabledToggles = std::ptr::null();
7719 raw.enabledToggleCount = 0;
7720 }
7721 raw.disabledToggleCount = self
7722 .disabled_toggles
7723 .as_ref()
7724 .map(|v| v.len())
7725 .unwrap_or(0);
7726 if let Some(values) = &self.disabled_toggles {
7727 let len_value = values.len();
7728 let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
7729 values.len(),
7730 );
7731 let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
7732 values.len(),
7733 );
7734 for item in values.iter() {
7735 let c_string = std::ffi::CString::new(item.as_str())
7736 .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
7737 ptrs.push(c_string.as_ptr());
7738 c_strings.push(c_string);
7739 }
7740 let ptr = storage.push_vec(ptrs);
7741 storage.push_any(c_strings);
7742 raw.disabledToggles = ptr;
7743 raw.disabledToggleCount = len_value;
7744 } else {
7745 raw.disabledToggles = std::ptr::null();
7746 raw.disabledToggleCount = 0;
7747 }
7748 (raw, storage)
7749 }
7750 pub(crate) fn from_ffi(value: ffi::WGPUDawnTogglesDescriptor) -> Self {
7751 Self {
7752 enabled_toggles: if value.enabledToggles.is_null() {
7753 None
7754 } else {
7755 Some(
7756 unsafe {
7757 std::slice::from_raw_parts(
7758 value.enabledToggles,
7759 value.enabledToggleCount as usize,
7760 )
7761 }
7762 .iter()
7763 .map(|raw| {
7764 if raw.is_null() {
7765 String::new()
7766 } else {
7767 unsafe { CStr::from_ptr(*raw) }
7768 .to_string_lossy()
7769 .into_owned()
7770 }
7771 })
7772 .collect(),
7773 )
7774 },
7775 disabled_toggles: if value.disabledToggles.is_null() {
7776 None
7777 } else {
7778 Some(
7779 unsafe {
7780 std::slice::from_raw_parts(
7781 value.disabledToggles,
7782 value.disabledToggleCount as usize,
7783 )
7784 }
7785 .iter()
7786 .map(|raw| {
7787 if raw.is_null() {
7788 String::new()
7789 } else {
7790 unsafe { CStr::from_ptr(*raw) }
7791 .to_string_lossy()
7792 .into_owned()
7793 }
7794 })
7795 .collect(),
7796 )
7797 },
7798 }
7799 }
7800 }
7801 pub struct DawnWireWGSLControl {
7802 pub enable_experimental: Option<bool>,
7803 pub enable_unsafe: Option<bool>,
7804 pub enable_testing: Option<bool>,
7805 }
7806 impl Default for DawnWireWGSLControl {
7807 fn default() -> Self {
7808 Self {
7809 enable_experimental: None,
7810 enable_unsafe: None,
7811 enable_testing: None,
7812 }
7813 }
7814 }
7815 impl DawnWireWGSLControl {
7816 pub fn new() -> Self {
7817 Self::default()
7818 }
7819 pub(crate) fn to_ffi(
7820 &self,
7821 ) -> (ffi::WGPUDawnWireWGSLControl, ChainedStructStorage) {
7822 let mut storage = ChainedStructStorage::new();
7823 let mut raw: ffi::WGPUDawnWireWGSLControl = unsafe { std::mem::zeroed() };
7824 raw.enableExperimental = if self.enable_experimental.unwrap_or(false) {
7825 1
7826 } else {
7827 0
7828 };
7829 raw.enableUnsafe = if self.enable_unsafe.unwrap_or(false) { 1 } else { 0 };
7830 raw.enableTesting = if self.enable_testing.unwrap_or(false) { 1 } else { 0 };
7831 (raw, storage)
7832 }
7833 pub(crate) fn from_ffi(value: ffi::WGPUDawnWireWGSLControl) -> Self {
7834 Self {
7835 enable_experimental: Some(value.enableExperimental != 0),
7836 enable_unsafe: Some(value.enableUnsafe != 0),
7837 enable_testing: Some(value.enableTesting != 0),
7838 }
7839 }
7840 }
7841 pub struct DepthStencilState {
7842 pub(crate) extensions: Vec<DepthStencilStateExtension>,
7843 pub format: Option<TextureFormat>,
7844 pub depth_write_enabled: Option<OptionalBool>,
7845 pub depth_compare: Option<CompareFunction>,
7846 pub stencil_front: Option<StencilFaceState>,
7847 pub stencil_back: Option<StencilFaceState>,
7848 pub stencil_read_mask: Option<u32>,
7849 pub stencil_write_mask: Option<u32>,
7850 pub depth_bias: Option<i32>,
7851 pub depth_bias_slope_scale: Option<f32>,
7852 pub depth_bias_clamp: Option<f32>,
7853 }
7854 impl Default for DepthStencilState {
7855 fn default() -> Self {
7856 Self {
7857 extensions: Vec::new(),
7858 format: None,
7859 depth_write_enabled: None,
7860 depth_compare: None,
7861 stencil_front: None,
7862 stencil_back: None,
7863 stencil_read_mask: Some(4294967295),
7864 stencil_write_mask: Some(4294967295),
7865 depth_bias: Some(0),
7866 depth_bias_slope_scale: None,
7867 depth_bias_clamp: None,
7868 }
7869 }
7870 }
7871 impl DepthStencilState {
7872 pub fn new() -> Self {
7873 Self::default()
7874 }
7875 pub(crate) fn to_ffi(
7876 &self,
7877 ) -> (ffi::WGPUDepthStencilState, ChainedStructStorage) {
7878 let mut storage = ChainedStructStorage::new();
7879 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7880 for ext in self.extensions.iter().rev() {
7881 next = ext.push_chain(&mut storage, next);
7882 }
7883 let mut raw: ffi::WGPUDepthStencilState = unsafe { std::mem::zeroed() };
7884 raw.nextInChain = next;
7885 if let Some(value) = self.format {
7886 raw.format = value.into();
7887 } else {
7888 raw.format = 0 as ffi::WGPUTextureFormat;
7889 }
7890 if let Some(value) = self.depth_write_enabled {
7891 raw.depthWriteEnabled = value.into();
7892 } else {
7893 raw.depthWriteEnabled = 0 as ffi::WGPUOptionalBool;
7894 }
7895 if let Some(value) = self.depth_compare {
7896 raw.depthCompare = value.into();
7897 } else {
7898 raw.depthCompare = 0 as ffi::WGPUCompareFunction;
7899 }
7900 if let Some(value) = &self.stencil_front {
7901 let (raw_value, storage_value) = value.to_ffi();
7902 raw.stencilFront = raw_value;
7903 storage.push_storage(storage_value);
7904 }
7905 if let Some(value) = &self.stencil_back {
7906 let (raw_value, storage_value) = value.to_ffi();
7907 raw.stencilBack = raw_value;
7908 storage.push_storage(storage_value);
7909 }
7910 if let Some(value) = self.stencil_read_mask {
7911 raw.stencilReadMask = value;
7912 }
7913 if let Some(value) = self.stencil_write_mask {
7914 raw.stencilWriteMask = value;
7915 }
7916 if let Some(value) = self.depth_bias {
7917 raw.depthBias = value;
7918 }
7919 if let Some(value) = self.depth_bias_slope_scale {
7920 raw.depthBiasSlopeScale = value;
7921 }
7922 if let Some(value) = self.depth_bias_clamp {
7923 raw.depthBiasClamp = value;
7924 }
7925 (raw, storage)
7926 }
7927 pub fn with_extension(mut self, extension: DepthStencilStateExtension) -> Self {
7928 self.extensions.push(extension);
7929 self
7930 }
7931 pub(crate) fn from_ffi(value: ffi::WGPUDepthStencilState) -> Self {
7932 Self {
7933 extensions: Vec::new(),
7934 format: Some(value.format.into()),
7935 depth_write_enabled: Some(value.depthWriteEnabled.into()),
7936 depth_compare: Some(value.depthCompare.into()),
7937 stencil_front: Some(StencilFaceState::from_ffi(value.stencilFront)),
7938 stencil_back: Some(StencilFaceState::from_ffi(value.stencilBack)),
7939 stencil_read_mask: Some(value.stencilReadMask),
7940 stencil_write_mask: Some(value.stencilWriteMask),
7941 depth_bias: Some(value.depthBias),
7942 depth_bias_slope_scale: Some(value.depthBiasSlopeScale),
7943 depth_bias_clamp: Some(value.depthBiasClamp),
7944 }
7945 }
7946 }
7947 pub struct DeviceDescriptor {
7948 pub(crate) extensions: Vec<DeviceDescriptorExtension>,
7949 pub label: Option<String>,
7950 pub required_features: Option<Vec<FeatureName>>,
7951 pub required_limits: Option<Limits>,
7952 pub default_queue: Option<QueueDescriptor>,
7953 pub device_lost_callback_info: Option<DeviceLostCallbackInfo>,
7954 pub uncaptured_error_callback_info: Option<UncapturedErrorCallbackInfo>,
7955 }
7956 impl Default for DeviceDescriptor {
7957 fn default() -> Self {
7958 Self {
7959 extensions: Vec::new(),
7960 label: None,
7961 required_features: None,
7962 required_limits: None,
7963 default_queue: None,
7964 device_lost_callback_info: None,
7965 uncaptured_error_callback_info: None,
7966 }
7967 }
7968 }
7969 impl DeviceDescriptor {
7970 pub fn new() -> Self {
7971 Self::default()
7972 }
7973 pub(crate) fn to_ffi(
7974 &self,
7975 ) -> (ffi::WGPUDeviceDescriptor, ChainedStructStorage) {
7976 let mut storage = ChainedStructStorage::new();
7977 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7978 for ext in self.extensions.iter().rev() {
7979 next = ext.push_chain(&mut storage, next);
7980 }
7981 let mut raw: ffi::WGPUDeviceDescriptor = unsafe { std::mem::zeroed() };
7982 raw.nextInChain = next;
7983 if let Some(value) = &self.label {
7984 raw.label = ffi::WGPUStringView {
7985 data: value.as_ptr().cast(),
7986 length: value.len(),
7987 };
7988 } else {
7989 raw.label = ffi::WGPUStringView {
7990 data: std::ptr::null(),
7991 length: 0,
7992 };
7993 }
7994 raw.requiredFeatureCount = self
7995 .required_features
7996 .as_ref()
7997 .map(|v| v.len())
7998 .unwrap_or(0);
7999 if let Some(values) = &self.required_features {
8000 let len_value = values.len();
8001 let raw_vec: Vec<ffi::WGPUFeatureName> = values
8002 .iter()
8003 .map(|v| (*v).into())
8004 .collect();
8005 let ptr = storage.push_vec(raw_vec);
8006 raw.requiredFeatures = ptr;
8007 raw.requiredFeatureCount = len_value;
8008 } else {
8009 raw.requiredFeatures = std::ptr::null();
8010 raw.requiredFeatureCount = 0;
8011 }
8012 if let Some(value) = &self.required_limits {
8013 let (raw_value, storage_value) = value.to_ffi();
8014 let ptr = storage.push_value(raw_value);
8015 raw.requiredLimits = ptr;
8016 storage.push_storage(storage_value);
8017 } else {
8018 raw.requiredLimits = std::ptr::null();
8019 }
8020 if let Some(value) = &self.default_queue {
8021 let (raw_value, storage_value) = value.to_ffi();
8022 raw.defaultQueue = raw_value;
8023 storage.push_storage(storage_value);
8024 }
8025 if let Some(info) = &self.device_lost_callback_info {
8026 let mut callback_slot = info.callback.borrow_mut();
8027 let callback = callback_slot.take();
8028 let (
8029 callback_ptr,
8030 userdata1,
8031 ): (ffi::WGPUDeviceLostCallback, *mut std::ffi::c_void) = if let Some(
8032 callback,
8033 ) = callback {
8034 let callback_box: DeviceLostCallback = callback;
8035 let callback_box = Box::new(Some(callback_box));
8036 let userdata = Box::into_raw(callback_box)
8037 .cast::<std::ffi::c_void>();
8038 (Some(device_lost_callback_trampoline), userdata)
8039 } else {
8040 (None, std::ptr::null_mut())
8041 };
8042 let mode = info.mode.unwrap_or(CallbackMode::AllowSpontaneous);
8043 raw.deviceLostCallbackInfo = ffi::WGPUDeviceLostCallbackInfo {
8044 nextInChain: std::ptr::null_mut(),
8045 mode: mode.into(),
8046 callback: callback_ptr,
8047 userdata1,
8048 userdata2: std::ptr::null_mut(),
8049 };
8050 } else {
8051 raw.deviceLostCallbackInfo = ffi::WGPUDeviceLostCallbackInfo {
8052 nextInChain: std::ptr::null_mut(),
8053 mode: CallbackMode::AllowSpontaneous.into(),
8054 callback: None,
8055 userdata1: std::ptr::null_mut(),
8056 userdata2: std::ptr::null_mut(),
8057 };
8058 }
8059 if let Some(info) = &self.uncaptured_error_callback_info {
8060 let mut callback_slot = info.callback.borrow_mut();
8061 let callback = callback_slot.take();
8062 let (
8063 callback_ptr,
8064 userdata1,
8065 ): (ffi::WGPUUncapturedErrorCallback, *mut std::ffi::c_void) = if let Some(
8066 callback,
8067 ) = callback {
8068 let callback_box: UncapturedErrorCallback = callback;
8069 let callback_box = Box::new(Some(callback_box));
8070 let userdata = Box::into_raw(callback_box)
8071 .cast::<std::ffi::c_void>();
8072 (Some(uncaptured_error_callback_trampoline), userdata)
8073 } else {
8074 (None, std::ptr::null_mut())
8075 };
8076 raw.uncapturedErrorCallbackInfo = ffi::WGPUUncapturedErrorCallbackInfo {
8077 nextInChain: std::ptr::null_mut(),
8078 callback: callback_ptr,
8079 userdata1,
8080 userdata2: std::ptr::null_mut(),
8081 };
8082 } else {
8083 raw.uncapturedErrorCallbackInfo = ffi::WGPUUncapturedErrorCallbackInfo {
8084 nextInChain: std::ptr::null_mut(),
8085 callback: None,
8086 userdata1: std::ptr::null_mut(),
8087 userdata2: std::ptr::null_mut(),
8088 };
8089 }
8090 (raw, storage)
8091 }
8092 pub fn with_extension(mut self, extension: DeviceDescriptorExtension) -> Self {
8093 self.extensions.push(extension);
8094 self
8095 }
8096 pub(crate) fn from_ffi(value: ffi::WGPUDeviceDescriptor) -> Self {
8097 Self {
8098 extensions: Vec::new(),
8099 label: if value.label.data.is_null() || value.label.length == 0 {
8100 None
8101 } else {
8102 Some(string_view_to_string(value.label))
8103 },
8104 required_features: if value.requiredFeatures.is_null() {
8105 None
8106 } else {
8107 Some(
8108 unsafe {
8109 std::slice::from_raw_parts(
8110 value.requiredFeatures,
8111 value.requiredFeatureCount as usize,
8112 )
8113 }
8114 .iter()
8115 .map(|raw| FeatureName::from(*raw))
8116 .collect(),
8117 )
8118 },
8119 required_limits: if value.requiredLimits.is_null() {
8120 None
8121 } else {
8122 Some(Limits::from_ffi(unsafe { *value.requiredLimits }))
8123 },
8124 default_queue: Some(QueueDescriptor::from_ffi(value.defaultQueue)),
8125 device_lost_callback_info: None,
8126 uncaptured_error_callback_info: None,
8127 }
8128 }
8129 }
8130 pub struct Extent2D {
8131 pub width: Option<u32>,
8132 pub height: Option<u32>,
8133 }
8134 impl Default for Extent2D {
8135 fn default() -> Self {
8136 Self { width: None, height: None }
8137 }
8138 }
8139 impl Extent2D {
8140 pub fn new() -> Self {
8141 Self::default()
8142 }
8143 pub(crate) fn to_ffi(&self) -> (ffi::WGPUExtent2D, ChainedStructStorage) {
8144 let mut storage = ChainedStructStorage::new();
8145 let mut raw: ffi::WGPUExtent2D = unsafe { std::mem::zeroed() };
8146 if let Some(value) = self.width {
8147 raw.width = value;
8148 }
8149 if let Some(value) = self.height {
8150 raw.height = value;
8151 }
8152 (raw, storage)
8153 }
8154 pub(crate) fn from_ffi(value: ffi::WGPUExtent2D) -> Self {
8155 Self {
8156 width: Some(value.width),
8157 height: Some(value.height),
8158 }
8159 }
8160 }
8161 pub struct Extent3D {
8162 pub width: Option<u32>,
8163 pub height: Option<u32>,
8164 pub depth_or_array_layers: Option<u32>,
8165 }
8166 impl Default for Extent3D {
8167 fn default() -> Self {
8168 Self {
8169 width: None,
8170 height: Some(1),
8171 depth_or_array_layers: Some(1),
8172 }
8173 }
8174 }
8175 impl Extent3D {
8176 pub fn new() -> Self {
8177 Self::default()
8178 }
8179 pub(crate) fn to_ffi(&self) -> (ffi::WGPUExtent3D, ChainedStructStorage) {
8180 let mut storage = ChainedStructStorage::new();
8181 let mut raw: ffi::WGPUExtent3D = unsafe { std::mem::zeroed() };
8182 if let Some(value) = self.width {
8183 raw.width = value;
8184 }
8185 if let Some(value) = self.height {
8186 raw.height = value;
8187 }
8188 if let Some(value) = self.depth_or_array_layers {
8189 raw.depthOrArrayLayers = value;
8190 }
8191 (raw, storage)
8192 }
8193 pub(crate) fn from_ffi(value: ffi::WGPUExtent3D) -> Self {
8194 Self {
8195 width: Some(value.width),
8196 height: Some(value.height),
8197 depth_or_array_layers: Some(value.depthOrArrayLayers),
8198 }
8199 }
8200 }
8201 pub struct ExternalTextureBindingEntry {
8202 pub external_texture: Option<ExternalTexture>,
8203 }
8204 impl Default for ExternalTextureBindingEntry {
8205 fn default() -> Self {
8206 Self { external_texture: None }
8207 }
8208 }
8209 impl ExternalTextureBindingEntry {
8210 pub fn new() -> Self {
8211 Self::default()
8212 }
8213 pub(crate) fn to_ffi(
8214 &self,
8215 ) -> (ffi::WGPUExternalTextureBindingEntry, ChainedStructStorage) {
8216 let mut storage = ChainedStructStorage::new();
8217 let mut raw: ffi::WGPUExternalTextureBindingEntry = unsafe {
8218 std::mem::zeroed()
8219 };
8220 raw.externalTexture = self
8221 .external_texture
8222 .as_ref()
8223 .map(|v| v.as_raw())
8224 .unwrap_or(std::ptr::null_mut());
8225 (raw, storage)
8226 }
8227 pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureBindingEntry) -> Self {
8228 Self {
8229 external_texture: Some(unsafe {
8230 ExternalTexture::from_raw(value.externalTexture)
8231 }),
8232 }
8233 }
8234 }
8235 pub struct ExternalTextureBindingLayout {}
8236 impl Default for ExternalTextureBindingLayout {
8237 fn default() -> Self {
8238 Self {}
8239 }
8240 }
8241 impl ExternalTextureBindingLayout {
8242 pub fn new() -> Self {
8243 Self::default()
8244 }
8245 pub(crate) fn to_ffi(
8246 &self,
8247 ) -> (ffi::WGPUExternalTextureBindingLayout, ChainedStructStorage) {
8248 let mut storage = ChainedStructStorage::new();
8249 let mut raw: ffi::WGPUExternalTextureBindingLayout = unsafe {
8250 std::mem::zeroed()
8251 };
8252 (raw, storage)
8253 }
8254 pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureBindingLayout) -> Self {
8255 let _ = value;
8256 Self::default()
8257 }
8258 }
8259 pub struct ExternalTextureDescriptor {
8260 pub(crate) extensions: Vec<ExternalTextureDescriptorExtension>,
8261 pub label: Option<String>,
8262 pub plane_0: Option<TextureView>,
8263 pub plane_1: Option<TextureView>,
8264 pub crop_origin: Option<Origin2D>,
8265 pub crop_size: Option<Extent2D>,
8266 pub apparent_size: Option<Extent2D>,
8267 pub do_yuv_to_rgb_conversion_only: Option<bool>,
8268 pub yuv_to_rgb_conversion_matrix: Option<Vec<f32>>,
8269 pub src_transfer_function_parameters: Option<Vec<f32>>,
8270 pub dst_transfer_function_parameters: Option<Vec<f32>>,
8271 pub gamut_conversion_matrix: Option<Vec<f32>>,
8272 pub mirrored: Option<bool>,
8273 pub rotation: Option<ExternalTextureRotation>,
8274 }
8275 impl Default for ExternalTextureDescriptor {
8276 fn default() -> Self {
8277 Self {
8278 extensions: Vec::new(),
8279 label: None,
8280 plane_0: None,
8281 plane_1: None,
8282 crop_origin: None,
8283 crop_size: None,
8284 apparent_size: None,
8285 do_yuv_to_rgb_conversion_only: None,
8286 yuv_to_rgb_conversion_matrix: None,
8287 src_transfer_function_parameters: None,
8288 dst_transfer_function_parameters: None,
8289 gamut_conversion_matrix: None,
8290 mirrored: None,
8291 rotation: Some(ExternalTextureRotation::Rotate0Degrees),
8292 }
8293 }
8294 }
8295 impl ExternalTextureDescriptor {
8296 pub fn new() -> Self {
8297 Self::default()
8298 }
8299 pub(crate) fn to_ffi(
8300 &self,
8301 ) -> (ffi::WGPUExternalTextureDescriptor, ChainedStructStorage) {
8302 let mut storage = ChainedStructStorage::new();
8303 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8304 for ext in self.extensions.iter().rev() {
8305 next = ext.push_chain(&mut storage, next);
8306 }
8307 let mut raw: ffi::WGPUExternalTextureDescriptor = unsafe {
8308 std::mem::zeroed()
8309 };
8310 raw.nextInChain = next;
8311 if let Some(value) = &self.label {
8312 raw.label = ffi::WGPUStringView {
8313 data: value.as_ptr().cast(),
8314 length: value.len(),
8315 };
8316 } else {
8317 raw.label = ffi::WGPUStringView {
8318 data: std::ptr::null(),
8319 length: 0,
8320 };
8321 }
8322 raw.plane0 = self
8323 .plane_0
8324 .as_ref()
8325 .map(|v| v.as_raw())
8326 .unwrap_or(std::ptr::null_mut());
8327 raw.plane1 = self
8328 .plane_1
8329 .as_ref()
8330 .map(|v| v.as_raw())
8331 .unwrap_or(std::ptr::null_mut());
8332 if let Some(value) = &self.crop_origin {
8333 let (raw_value, storage_value) = value.to_ffi();
8334 raw.cropOrigin = raw_value;
8335 storage.push_storage(storage_value);
8336 }
8337 if let Some(value) = &self.crop_size {
8338 let (raw_value, storage_value) = value.to_ffi();
8339 raw.cropSize = raw_value;
8340 storage.push_storage(storage_value);
8341 }
8342 if let Some(value) = &self.apparent_size {
8343 let (raw_value, storage_value) = value.to_ffi();
8344 raw.apparentSize = raw_value;
8345 storage.push_storage(storage_value);
8346 }
8347 raw.doYuvToRgbConversionOnly = if self
8348 .do_yuv_to_rgb_conversion_only
8349 .unwrap_or(false)
8350 {
8351 1
8352 } else {
8353 0
8354 };
8355 if let Some(values) = &self.yuv_to_rgb_conversion_matrix {
8356 let len_value = values.len();
8357 let raw_vec = values.to_vec();
8358 let ptr = storage.push_vec(raw_vec);
8359 raw.yuvToRgbConversionMatrix = ptr;
8360 } else {
8361 raw.yuvToRgbConversionMatrix = std::ptr::null();
8362 let _ = 0;
8363 }
8364 if let Some(values) = &self.src_transfer_function_parameters {
8365 let len_value = values.len();
8366 let raw_vec = values.to_vec();
8367 let ptr = storage.push_vec(raw_vec);
8368 raw.srcTransferFunctionParameters = ptr;
8369 } else {
8370 raw.srcTransferFunctionParameters = std::ptr::null();
8371 let _ = 0;
8372 }
8373 if let Some(values) = &self.dst_transfer_function_parameters {
8374 let len_value = values.len();
8375 let raw_vec = values.to_vec();
8376 let ptr = storage.push_vec(raw_vec);
8377 raw.dstTransferFunctionParameters = ptr;
8378 } else {
8379 raw.dstTransferFunctionParameters = std::ptr::null();
8380 let _ = 0;
8381 }
8382 if let Some(values) = &self.gamut_conversion_matrix {
8383 let len_value = values.len();
8384 let raw_vec = values.to_vec();
8385 let ptr = storage.push_vec(raw_vec);
8386 raw.gamutConversionMatrix = ptr;
8387 } else {
8388 raw.gamutConversionMatrix = std::ptr::null();
8389 let _ = 0;
8390 }
8391 raw.mirrored = if self.mirrored.unwrap_or(false) { 1 } else { 0 };
8392 if let Some(value) = self.rotation {
8393 raw.rotation = value.into();
8394 } else {
8395 raw.rotation = 0 as ffi::WGPUExternalTextureRotation;
8396 }
8397 (raw, storage)
8398 }
8399 pub fn with_extension(
8400 mut self,
8401 extension: ExternalTextureDescriptorExtension,
8402 ) -> Self {
8403 self.extensions.push(extension);
8404 self
8405 }
8406 pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureDescriptor) -> Self {
8407 Self {
8408 extensions: Vec::new(),
8409 label: if value.label.data.is_null() || value.label.length == 0 {
8410 None
8411 } else {
8412 Some(string_view_to_string(value.label))
8413 },
8414 plane_0: Some(unsafe { TextureView::from_raw(value.plane0) }),
8415 plane_1: if value.plane1.is_null() {
8416 None
8417 } else {
8418 Some(unsafe { TextureView::from_raw(value.plane1) })
8419 },
8420 crop_origin: Some(Origin2D::from_ffi(value.cropOrigin)),
8421 crop_size: Some(Extent2D::from_ffi(value.cropSize)),
8422 apparent_size: Some(Extent2D::from_ffi(value.apparentSize)),
8423 do_yuv_to_rgb_conversion_only: Some(value.doYuvToRgbConversionOnly != 0),
8424 yuv_to_rgb_conversion_matrix: if value.yuvToRgbConversionMatrix.is_null()
8425 {
8426 None
8427 } else {
8428 Some(
8429 unsafe {
8430 std::slice::from_raw_parts(
8431 value.yuvToRgbConversionMatrix,
8432 12usize,
8433 )
8434 }
8435 .to_vec(),
8436 )
8437 },
8438 src_transfer_function_parameters: if value
8439 .srcTransferFunctionParameters
8440 .is_null()
8441 {
8442 None
8443 } else {
8444 Some(
8445 unsafe {
8446 std::slice::from_raw_parts(
8447 value.srcTransferFunctionParameters,
8448 7usize,
8449 )
8450 }
8451 .to_vec(),
8452 )
8453 },
8454 dst_transfer_function_parameters: if value
8455 .dstTransferFunctionParameters
8456 .is_null()
8457 {
8458 None
8459 } else {
8460 Some(
8461 unsafe {
8462 std::slice::from_raw_parts(
8463 value.dstTransferFunctionParameters,
8464 7usize,
8465 )
8466 }
8467 .to_vec(),
8468 )
8469 },
8470 gamut_conversion_matrix: if value.gamutConversionMatrix.is_null() {
8471 None
8472 } else {
8473 Some(
8474 unsafe {
8475 std::slice::from_raw_parts(
8476 value.gamutConversionMatrix,
8477 9usize,
8478 )
8479 }
8480 .to_vec(),
8481 )
8482 },
8483 mirrored: Some(value.mirrored != 0),
8484 rotation: Some(value.rotation.into()),
8485 }
8486 }
8487 }
8488 pub struct FragmentState {
8489 pub(crate) extensions: Vec<FragmentStateExtension>,
8490 pub module: Option<ShaderModule>,
8491 pub entry_point: Option<String>,
8492 pub constants: Option<Vec<ConstantEntry>>,
8493 pub targets: Option<Vec<ColorTargetState>>,
8494 }
8495 impl Default for FragmentState {
8496 fn default() -> Self {
8497 Self {
8498 extensions: Vec::new(),
8499 module: None,
8500 entry_point: None,
8501 constants: None,
8502 targets: None,
8503 }
8504 }
8505 }
8506 impl FragmentState {
8507 pub fn new() -> Self {
8508 Self::default()
8509 }
8510 pub(crate) fn to_ffi(&self) -> (ffi::WGPUFragmentState, ChainedStructStorage) {
8511 let mut storage = ChainedStructStorage::new();
8512 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8513 for ext in self.extensions.iter().rev() {
8514 next = ext.push_chain(&mut storage, next);
8515 }
8516 let mut raw: ffi::WGPUFragmentState = unsafe { std::mem::zeroed() };
8517 raw.nextInChain = next;
8518 raw.module = self
8519 .module
8520 .as_ref()
8521 .map(|v| v.as_raw())
8522 .unwrap_or(std::ptr::null_mut());
8523 if let Some(value) = &self.entry_point {
8524 raw.entryPoint = ffi::WGPUStringView {
8525 data: value.as_ptr().cast(),
8526 length: value.len(),
8527 };
8528 } else {
8529 raw.entryPoint = ffi::WGPUStringView {
8530 data: std::ptr::null(),
8531 length: 0,
8532 };
8533 }
8534 raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
8535 if let Some(values) = &self.constants {
8536 let len_value = values.len();
8537 let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
8538 values.len(),
8539 );
8540 for item in values.iter() {
8541 let (raw_item, storage_item) = item.to_ffi();
8542 raw_vec.push(raw_item);
8543 storage.push_storage(storage_item);
8544 }
8545 let ptr = storage.push_vec(raw_vec);
8546 raw.constants = ptr;
8547 raw.constantCount = len_value;
8548 } else {
8549 raw.constants = std::ptr::null();
8550 raw.constantCount = 0;
8551 }
8552 raw.targetCount = self.targets.as_ref().map(|v| v.len()).unwrap_or(0);
8553 if let Some(values) = &self.targets {
8554 let len_value = values.len();
8555 let mut raw_vec: Vec<ffi::WGPUColorTargetState> = Vec::with_capacity(
8556 values.len(),
8557 );
8558 for item in values.iter() {
8559 let (raw_item, storage_item) = item.to_ffi();
8560 raw_vec.push(raw_item);
8561 storage.push_storage(storage_item);
8562 }
8563 let ptr = storage.push_vec(raw_vec);
8564 raw.targets = ptr;
8565 raw.targetCount = len_value;
8566 } else {
8567 raw.targets = std::ptr::null();
8568 raw.targetCount = 0;
8569 }
8570 (raw, storage)
8571 }
8572 pub fn with_extension(mut self, extension: FragmentStateExtension) -> Self {
8573 self.extensions.push(extension);
8574 self
8575 }
8576 pub(crate) fn from_ffi(value: ffi::WGPUFragmentState) -> Self {
8577 Self {
8578 extensions: Vec::new(),
8579 module: Some(unsafe { ShaderModule::from_raw(value.module) }),
8580 entry_point: if value.entryPoint.data.is_null()
8581 || value.entryPoint.length == 0
8582 {
8583 None
8584 } else {
8585 Some(string_view_to_string(value.entryPoint))
8586 },
8587 constants: if value.constants.is_null() {
8588 None
8589 } else {
8590 Some(
8591 unsafe {
8592 std::slice::from_raw_parts(
8593 value.constants,
8594 value.constantCount as usize,
8595 )
8596 }
8597 .iter()
8598 .map(|raw| ConstantEntry::from_ffi(*raw))
8599 .collect(),
8600 )
8601 },
8602 targets: if value.targets.is_null() {
8603 None
8604 } else {
8605 Some(
8606 unsafe {
8607 std::slice::from_raw_parts(
8608 value.targets,
8609 value.targetCount as usize,
8610 )
8611 }
8612 .iter()
8613 .map(|raw| ColorTargetState::from_ffi(*raw))
8614 .collect(),
8615 )
8616 },
8617 }
8618 }
8619 }
8620 pub struct Future {
8621 pub id: Option<u64>,
8622 }
8623 impl Default for Future {
8624 fn default() -> Self {
8625 Self { id: None }
8626 }
8627 }
8628 impl Future {
8629 pub fn new() -> Self {
8630 Self::default()
8631 }
8632 pub(crate) fn to_ffi(&self) -> (ffi::WGPUFuture, ChainedStructStorage) {
8633 let mut storage = ChainedStructStorage::new();
8634 let mut raw: ffi::WGPUFuture = unsafe { std::mem::zeroed() };
8635 if let Some(value) = self.id {
8636 raw.id = value;
8637 }
8638 (raw, storage)
8639 }
8640 pub(crate) fn from_ffi(value: ffi::WGPUFuture) -> Self {
8641 Self { id: Some(value.id) }
8642 }
8643 }
8644 pub struct FutureWaitInfo {
8645 pub future: Option<Future>,
8646 pub completed: Option<bool>,
8647 }
8648 impl Default for FutureWaitInfo {
8649 fn default() -> Self {
8650 Self {
8651 future: None,
8652 completed: None,
8653 }
8654 }
8655 }
8656 impl FutureWaitInfo {
8657 pub fn new() -> Self {
8658 Self::default()
8659 }
8660 pub(crate) fn to_ffi(&self) -> (ffi::WGPUFutureWaitInfo, ChainedStructStorage) {
8661 let mut storage = ChainedStructStorage::new();
8662 let mut raw: ffi::WGPUFutureWaitInfo = unsafe { std::mem::zeroed() };
8663 if let Some(value) = &self.future {
8664 let (raw_value, storage_value) = value.to_ffi();
8665 raw.future = raw_value;
8666 storage.push_storage(storage_value);
8667 }
8668 raw.completed = if self.completed.unwrap_or(false) { 1 } else { 0 };
8669 (raw, storage)
8670 }
8671 pub(crate) fn from_ffi(value: ffi::WGPUFutureWaitInfo) -> Self {
8672 Self {
8673 future: Some(Future::from_ffi(value.future)),
8674 completed: Some(value.completed != 0),
8675 }
8676 }
8677 }
8678 pub struct ImageCopyExternalTexture {
8679 pub(crate) extensions: Vec<ImageCopyExternalTextureExtension>,
8680 pub external_texture: Option<ExternalTexture>,
8681 pub origin: Option<Origin3D>,
8682 pub natural_size: Option<Extent2D>,
8683 }
8684 impl Default for ImageCopyExternalTexture {
8685 fn default() -> Self {
8686 Self {
8687 extensions: Vec::new(),
8688 external_texture: None,
8689 origin: None,
8690 natural_size: None,
8691 }
8692 }
8693 }
8694 impl ImageCopyExternalTexture {
8695 pub fn new() -> Self {
8696 Self::default()
8697 }
8698 pub(crate) fn to_ffi(
8699 &self,
8700 ) -> (ffi::WGPUImageCopyExternalTexture, ChainedStructStorage) {
8701 let mut storage = ChainedStructStorage::new();
8702 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8703 for ext in self.extensions.iter().rev() {
8704 next = ext.push_chain(&mut storage, next);
8705 }
8706 let mut raw: ffi::WGPUImageCopyExternalTexture = unsafe {
8707 std::mem::zeroed()
8708 };
8709 raw.nextInChain = next;
8710 raw.externalTexture = self
8711 .external_texture
8712 .as_ref()
8713 .map(|v| v.as_raw())
8714 .unwrap_or(std::ptr::null_mut());
8715 if let Some(value) = &self.origin {
8716 let (raw_value, storage_value) = value.to_ffi();
8717 raw.origin = raw_value;
8718 storage.push_storage(storage_value);
8719 }
8720 if let Some(value) = &self.natural_size {
8721 let (raw_value, storage_value) = value.to_ffi();
8722 raw.naturalSize = raw_value;
8723 storage.push_storage(storage_value);
8724 }
8725 (raw, storage)
8726 }
8727 pub fn with_extension(
8728 mut self,
8729 extension: ImageCopyExternalTextureExtension,
8730 ) -> Self {
8731 self.extensions.push(extension);
8732 self
8733 }
8734 pub(crate) fn from_ffi(value: ffi::WGPUImageCopyExternalTexture) -> Self {
8735 Self {
8736 extensions: Vec::new(),
8737 external_texture: Some(unsafe {
8738 ExternalTexture::from_raw(value.externalTexture)
8739 }),
8740 origin: Some(Origin3D::from_ffi(value.origin)),
8741 natural_size: Some(Extent2D::from_ffi(value.naturalSize)),
8742 }
8743 }
8744 }
8745 pub struct InstanceDescriptor {
8746 pub(crate) extensions: Vec<InstanceDescriptorExtension>,
8747 pub required_features: Option<Vec<InstanceFeatureName>>,
8748 pub required_limits: Option<InstanceLimits>,
8749 }
8750 impl Default for InstanceDescriptor {
8751 fn default() -> Self {
8752 Self {
8753 extensions: Vec::new(),
8754 required_features: None,
8755 required_limits: None,
8756 }
8757 }
8758 }
8759 impl InstanceDescriptor {
8760 pub fn new() -> Self {
8761 Self::default()
8762 }
8763 pub(crate) fn to_ffi(
8764 &self,
8765 ) -> (ffi::WGPUInstanceDescriptor, ChainedStructStorage) {
8766 let mut storage = ChainedStructStorage::new();
8767 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8768 for ext in self.extensions.iter().rev() {
8769 next = ext.push_chain(&mut storage, next);
8770 }
8771 let mut raw: ffi::WGPUInstanceDescriptor = unsafe { std::mem::zeroed() };
8772 raw.nextInChain = next;
8773 raw.requiredFeatureCount = self
8774 .required_features
8775 .as_ref()
8776 .map(|v| v.len())
8777 .unwrap_or(0);
8778 if let Some(values) = &self.required_features {
8779 let len_value = values.len();
8780 let raw_vec: Vec<ffi::WGPUInstanceFeatureName> = values
8781 .iter()
8782 .map(|v| (*v).into())
8783 .collect();
8784 let ptr = storage.push_vec(raw_vec);
8785 raw.requiredFeatures = ptr;
8786 raw.requiredFeatureCount = len_value;
8787 } else {
8788 raw.requiredFeatures = std::ptr::null();
8789 raw.requiredFeatureCount = 0;
8790 }
8791 if let Some(value) = &self.required_limits {
8792 let (raw_value, storage_value) = value.to_ffi();
8793 let ptr = storage.push_value(raw_value);
8794 raw.requiredLimits = ptr;
8795 storage.push_storage(storage_value);
8796 } else {
8797 raw.requiredLimits = std::ptr::null();
8798 }
8799 (raw, storage)
8800 }
8801 pub fn with_extension(mut self, extension: InstanceDescriptorExtension) -> Self {
8802 self.extensions.push(extension);
8803 self
8804 }
8805 pub(crate) fn from_ffi(value: ffi::WGPUInstanceDescriptor) -> Self {
8806 Self {
8807 extensions: Vec::new(),
8808 required_features: if value.requiredFeatures.is_null() {
8809 None
8810 } else {
8811 Some(
8812 unsafe {
8813 std::slice::from_raw_parts(
8814 value.requiredFeatures,
8815 value.requiredFeatureCount as usize,
8816 )
8817 }
8818 .iter()
8819 .map(|raw| InstanceFeatureName::from(*raw))
8820 .collect(),
8821 )
8822 },
8823 required_limits: if value.requiredLimits.is_null() {
8824 None
8825 } else {
8826 Some(InstanceLimits::from_ffi(unsafe { *value.requiredLimits }))
8827 },
8828 }
8829 }
8830 }
8831 pub struct InstanceLimits {
8832 pub(crate) extensions: Vec<InstanceLimitsExtension>,
8833 pub timed_wait_any_max_count: Option<usize>,
8834 }
8835 impl Default for InstanceLimits {
8836 fn default() -> Self {
8837 Self {
8838 extensions: Vec::new(),
8839 timed_wait_any_max_count: Some(0),
8840 }
8841 }
8842 }
8843 impl InstanceLimits {
8844 pub fn new() -> Self {
8845 Self::default()
8846 }
8847 pub(crate) fn to_ffi(&self) -> (ffi::WGPUInstanceLimits, ChainedStructStorage) {
8848 let mut storage = ChainedStructStorage::new();
8849 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8850 for ext in self.extensions.iter().rev() {
8851 next = ext.push_chain(&mut storage, next);
8852 }
8853 let mut raw: ffi::WGPUInstanceLimits = unsafe { std::mem::zeroed() };
8854 raw.nextInChain = next;
8855 if let Some(value) = self.timed_wait_any_max_count {
8856 raw.timedWaitAnyMaxCount = value;
8857 }
8858 (raw, storage)
8859 }
8860 pub fn with_extension(mut self, extension: InstanceLimitsExtension) -> Self {
8861 self.extensions.push(extension);
8862 self
8863 }
8864 pub(crate) fn from_ffi(value: ffi::WGPUInstanceLimits) -> Self {
8865 Self {
8866 extensions: Vec::new(),
8867 timed_wait_any_max_count: Some(value.timedWaitAnyMaxCount),
8868 }
8869 }
8870 }
8871 pub struct Limits {
8872 pub(crate) extensions: Vec<LimitsExtension>,
8873 pub max_texture_dimension_1d: Option<u32>,
8874 pub max_texture_dimension_2d: Option<u32>,
8875 pub max_texture_dimension_3d: Option<u32>,
8876 pub max_texture_array_layers: Option<u32>,
8877 pub max_bind_groups: Option<u32>,
8878 pub max_bind_groups_plus_vertex_buffers: Option<u32>,
8879 pub max_bindings_per_bind_group: Option<u32>,
8880 pub max_dynamic_uniform_buffers_per_pipeline_layout: Option<u32>,
8881 pub max_dynamic_storage_buffers_per_pipeline_layout: Option<u32>,
8882 pub max_sampled_textures_per_shader_stage: Option<u32>,
8883 pub max_samplers_per_shader_stage: Option<u32>,
8884 pub max_storage_buffers_per_shader_stage: Option<u32>,
8885 pub max_storage_textures_per_shader_stage: Option<u32>,
8886 pub max_uniform_buffers_per_shader_stage: Option<u32>,
8887 pub max_uniform_buffer_binding_size: Option<u64>,
8888 pub max_storage_buffer_binding_size: Option<u64>,
8889 pub min_uniform_buffer_offset_alignment: Option<u32>,
8890 pub min_storage_buffer_offset_alignment: Option<u32>,
8891 pub max_vertex_buffers: Option<u32>,
8892 pub max_buffer_size: Option<u64>,
8893 pub max_vertex_attributes: Option<u32>,
8894 pub max_vertex_buffer_array_stride: Option<u32>,
8895 pub max_inter_stage_shader_variables: Option<u32>,
8896 pub max_color_attachments: Option<u32>,
8897 pub max_color_attachment_bytes_per_sample: Option<u32>,
8898 pub max_compute_workgroup_storage_size: Option<u32>,
8899 pub max_compute_invocations_per_workgroup: Option<u32>,
8900 pub max_compute_workgroup_size_x: Option<u32>,
8901 pub max_compute_workgroup_size_y: Option<u32>,
8902 pub max_compute_workgroup_size_z: Option<u32>,
8903 pub max_compute_workgroups_per_dimension: Option<u32>,
8904 pub max_immediate_size: Option<u32>,
8905 }
8906 impl Default for Limits {
8907 fn default() -> Self {
8908 Self {
8909 extensions: Vec::new(),
8910 max_texture_dimension_1d: Some(LIMIT_U32_UNDEFINED),
8911 max_texture_dimension_2d: Some(LIMIT_U32_UNDEFINED),
8912 max_texture_dimension_3d: Some(LIMIT_U32_UNDEFINED),
8913 max_texture_array_layers: Some(LIMIT_U32_UNDEFINED),
8914 max_bind_groups: Some(LIMIT_U32_UNDEFINED),
8915 max_bind_groups_plus_vertex_buffers: Some(LIMIT_U32_UNDEFINED),
8916 max_bindings_per_bind_group: Some(LIMIT_U32_UNDEFINED),
8917 max_dynamic_uniform_buffers_per_pipeline_layout: Some(
8918 LIMIT_U32_UNDEFINED,
8919 ),
8920 max_dynamic_storage_buffers_per_pipeline_layout: Some(
8921 LIMIT_U32_UNDEFINED,
8922 ),
8923 max_sampled_textures_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8924 max_samplers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8925 max_storage_buffers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8926 max_storage_textures_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8927 max_uniform_buffers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8928 max_uniform_buffer_binding_size: Some(LIMIT_U64_UNDEFINED),
8929 max_storage_buffer_binding_size: Some(LIMIT_U64_UNDEFINED),
8930 min_uniform_buffer_offset_alignment: Some(LIMIT_U32_UNDEFINED),
8931 min_storage_buffer_offset_alignment: Some(LIMIT_U32_UNDEFINED),
8932 max_vertex_buffers: Some(LIMIT_U32_UNDEFINED),
8933 max_buffer_size: Some(LIMIT_U64_UNDEFINED),
8934 max_vertex_attributes: Some(LIMIT_U32_UNDEFINED),
8935 max_vertex_buffer_array_stride: Some(LIMIT_U32_UNDEFINED),
8936 max_inter_stage_shader_variables: Some(LIMIT_U32_UNDEFINED),
8937 max_color_attachments: Some(LIMIT_U32_UNDEFINED),
8938 max_color_attachment_bytes_per_sample: Some(LIMIT_U32_UNDEFINED),
8939 max_compute_workgroup_storage_size: Some(LIMIT_U32_UNDEFINED),
8940 max_compute_invocations_per_workgroup: Some(LIMIT_U32_UNDEFINED),
8941 max_compute_workgroup_size_x: Some(LIMIT_U32_UNDEFINED),
8942 max_compute_workgroup_size_y: Some(LIMIT_U32_UNDEFINED),
8943 max_compute_workgroup_size_z: Some(LIMIT_U32_UNDEFINED),
8944 max_compute_workgroups_per_dimension: Some(LIMIT_U32_UNDEFINED),
8945 max_immediate_size: Some(LIMIT_U32_UNDEFINED),
8946 }
8947 }
8948 }
8949 impl Limits {
8950 pub fn new() -> Self {
8951 Self::default()
8952 }
8953 pub(crate) fn to_ffi(&self) -> (ffi::WGPULimits, ChainedStructStorage) {
8954 let mut storage = ChainedStructStorage::new();
8955 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8956 for ext in self.extensions.iter().rev() {
8957 next = ext.push_chain(&mut storage, next);
8958 }
8959 let mut raw: ffi::WGPULimits = unsafe { std::mem::zeroed() };
8960 raw.nextInChain = next;
8961 if let Some(value) = self.max_texture_dimension_1d {
8962 raw.maxTextureDimension1D = value;
8963 }
8964 if let Some(value) = self.max_texture_dimension_2d {
8965 raw.maxTextureDimension2D = value;
8966 }
8967 if let Some(value) = self.max_texture_dimension_3d {
8968 raw.maxTextureDimension3D = value;
8969 }
8970 if let Some(value) = self.max_texture_array_layers {
8971 raw.maxTextureArrayLayers = value;
8972 }
8973 if let Some(value) = self.max_bind_groups {
8974 raw.maxBindGroups = value;
8975 }
8976 if let Some(value) = self.max_bind_groups_plus_vertex_buffers {
8977 raw.maxBindGroupsPlusVertexBuffers = value;
8978 }
8979 if let Some(value) = self.max_bindings_per_bind_group {
8980 raw.maxBindingsPerBindGroup = value;
8981 }
8982 if let Some(value) = self.max_dynamic_uniform_buffers_per_pipeline_layout {
8983 raw.maxDynamicUniformBuffersPerPipelineLayout = value;
8984 }
8985 if let Some(value) = self.max_dynamic_storage_buffers_per_pipeline_layout {
8986 raw.maxDynamicStorageBuffersPerPipelineLayout = value;
8987 }
8988 if let Some(value) = self.max_sampled_textures_per_shader_stage {
8989 raw.maxSampledTexturesPerShaderStage = value;
8990 }
8991 if let Some(value) = self.max_samplers_per_shader_stage {
8992 raw.maxSamplersPerShaderStage = value;
8993 }
8994 if let Some(value) = self.max_storage_buffers_per_shader_stage {
8995 raw.maxStorageBuffersPerShaderStage = value;
8996 }
8997 if let Some(value) = self.max_storage_textures_per_shader_stage {
8998 raw.maxStorageTexturesPerShaderStage = value;
8999 }
9000 if let Some(value) = self.max_uniform_buffers_per_shader_stage {
9001 raw.maxUniformBuffersPerShaderStage = value;
9002 }
9003 if let Some(value) = self.max_uniform_buffer_binding_size {
9004 raw.maxUniformBufferBindingSize = value;
9005 }
9006 if let Some(value) = self.max_storage_buffer_binding_size {
9007 raw.maxStorageBufferBindingSize = value;
9008 }
9009 if let Some(value) = self.min_uniform_buffer_offset_alignment {
9010 raw.minUniformBufferOffsetAlignment = value;
9011 }
9012 if let Some(value) = self.min_storage_buffer_offset_alignment {
9013 raw.minStorageBufferOffsetAlignment = value;
9014 }
9015 if let Some(value) = self.max_vertex_buffers {
9016 raw.maxVertexBuffers = value;
9017 }
9018 if let Some(value) = self.max_buffer_size {
9019 raw.maxBufferSize = value;
9020 }
9021 if let Some(value) = self.max_vertex_attributes {
9022 raw.maxVertexAttributes = value;
9023 }
9024 if let Some(value) = self.max_vertex_buffer_array_stride {
9025 raw.maxVertexBufferArrayStride = value;
9026 }
9027 if let Some(value) = self.max_inter_stage_shader_variables {
9028 raw.maxInterStageShaderVariables = value;
9029 }
9030 if let Some(value) = self.max_color_attachments {
9031 raw.maxColorAttachments = value;
9032 }
9033 if let Some(value) = self.max_color_attachment_bytes_per_sample {
9034 raw.maxColorAttachmentBytesPerSample = value;
9035 }
9036 if let Some(value) = self.max_compute_workgroup_storage_size {
9037 raw.maxComputeWorkgroupStorageSize = value;
9038 }
9039 if let Some(value) = self.max_compute_invocations_per_workgroup {
9040 raw.maxComputeInvocationsPerWorkgroup = value;
9041 }
9042 if let Some(value) = self.max_compute_workgroup_size_x {
9043 raw.maxComputeWorkgroupSizeX = value;
9044 }
9045 if let Some(value) = self.max_compute_workgroup_size_y {
9046 raw.maxComputeWorkgroupSizeY = value;
9047 }
9048 if let Some(value) = self.max_compute_workgroup_size_z {
9049 raw.maxComputeWorkgroupSizeZ = value;
9050 }
9051 if let Some(value) = self.max_compute_workgroups_per_dimension {
9052 raw.maxComputeWorkgroupsPerDimension = value;
9053 }
9054 if let Some(value) = self.max_immediate_size {
9055 raw.maxImmediateSize = value;
9056 }
9057 (raw, storage)
9058 }
9059 pub fn with_extension(mut self, extension: LimitsExtension) -> Self {
9060 self.extensions.push(extension);
9061 self
9062 }
9063 pub(crate) fn from_ffi(value: ffi::WGPULimits) -> Self {
9064 Self {
9065 extensions: Vec::new(),
9066 max_texture_dimension_1d: Some(value.maxTextureDimension1D),
9067 max_texture_dimension_2d: Some(value.maxTextureDimension2D),
9068 max_texture_dimension_3d: Some(value.maxTextureDimension3D),
9069 max_texture_array_layers: Some(value.maxTextureArrayLayers),
9070 max_bind_groups: Some(value.maxBindGroups),
9071 max_bind_groups_plus_vertex_buffers: Some(
9072 value.maxBindGroupsPlusVertexBuffers,
9073 ),
9074 max_bindings_per_bind_group: Some(value.maxBindingsPerBindGroup),
9075 max_dynamic_uniform_buffers_per_pipeline_layout: Some(
9076 value.maxDynamicUniformBuffersPerPipelineLayout,
9077 ),
9078 max_dynamic_storage_buffers_per_pipeline_layout: Some(
9079 value.maxDynamicStorageBuffersPerPipelineLayout,
9080 ),
9081 max_sampled_textures_per_shader_stage: Some(
9082 value.maxSampledTexturesPerShaderStage,
9083 ),
9084 max_samplers_per_shader_stage: Some(value.maxSamplersPerShaderStage),
9085 max_storage_buffers_per_shader_stage: Some(
9086 value.maxStorageBuffersPerShaderStage,
9087 ),
9088 max_storage_textures_per_shader_stage: Some(
9089 value.maxStorageTexturesPerShaderStage,
9090 ),
9091 max_uniform_buffers_per_shader_stage: Some(
9092 value.maxUniformBuffersPerShaderStage,
9093 ),
9094 max_uniform_buffer_binding_size: Some(value.maxUniformBufferBindingSize),
9095 max_storage_buffer_binding_size: Some(value.maxStorageBufferBindingSize),
9096 min_uniform_buffer_offset_alignment: Some(
9097 value.minUniformBufferOffsetAlignment,
9098 ),
9099 min_storage_buffer_offset_alignment: Some(
9100 value.minStorageBufferOffsetAlignment,
9101 ),
9102 max_vertex_buffers: Some(value.maxVertexBuffers),
9103 max_buffer_size: Some(value.maxBufferSize),
9104 max_vertex_attributes: Some(value.maxVertexAttributes),
9105 max_vertex_buffer_array_stride: Some(value.maxVertexBufferArrayStride),
9106 max_inter_stage_shader_variables: Some(
9107 value.maxInterStageShaderVariables,
9108 ),
9109 max_color_attachments: Some(value.maxColorAttachments),
9110 max_color_attachment_bytes_per_sample: Some(
9111 value.maxColorAttachmentBytesPerSample,
9112 ),
9113 max_compute_workgroup_storage_size: Some(
9114 value.maxComputeWorkgroupStorageSize,
9115 ),
9116 max_compute_invocations_per_workgroup: Some(
9117 value.maxComputeInvocationsPerWorkgroup,
9118 ),
9119 max_compute_workgroup_size_x: Some(value.maxComputeWorkgroupSizeX),
9120 max_compute_workgroup_size_y: Some(value.maxComputeWorkgroupSizeY),
9121 max_compute_workgroup_size_z: Some(value.maxComputeWorkgroupSizeZ),
9122 max_compute_workgroups_per_dimension: Some(
9123 value.maxComputeWorkgroupsPerDimension,
9124 ),
9125 max_immediate_size: Some(value.maxImmediateSize),
9126 }
9127 }
9128 }
9129 pub struct MemoryHeapInfo {
9130 pub properties: Option<HeapProperty>,
9131 pub size: Option<u64>,
9132 }
9133 impl Default for MemoryHeapInfo {
9134 fn default() -> Self {
9135 Self {
9136 properties: None,
9137 size: None,
9138 }
9139 }
9140 }
9141 impl MemoryHeapInfo {
9142 pub fn new() -> Self {
9143 Self::default()
9144 }
9145 pub(crate) fn to_ffi(&self) -> (ffi::WGPUMemoryHeapInfo, ChainedStructStorage) {
9146 let mut storage = ChainedStructStorage::new();
9147 let mut raw: ffi::WGPUMemoryHeapInfo = unsafe { std::mem::zeroed() };
9148 if let Some(value) = self.properties {
9149 raw.properties = value.into();
9150 } else {
9151 raw.properties = 0 as ffi::WGPUHeapProperty;
9152 }
9153 if let Some(value) = self.size {
9154 raw.size = value;
9155 }
9156 (raw, storage)
9157 }
9158 pub(crate) fn from_ffi(value: ffi::WGPUMemoryHeapInfo) -> Self {
9159 Self {
9160 properties: Some(value.properties.into()),
9161 size: Some(value.size),
9162 }
9163 }
9164 }
9165 pub struct MultisampleState {
9166 pub(crate) extensions: Vec<MultisampleStateExtension>,
9167 pub count: Option<u32>,
9168 pub mask: Option<u32>,
9169 pub alpha_to_coverage_enabled: Option<bool>,
9170 }
9171 impl Default for MultisampleState {
9172 fn default() -> Self {
9173 Self {
9174 extensions: Vec::new(),
9175 count: Some(1),
9176 mask: Some(4294967295),
9177 alpha_to_coverage_enabled: None,
9178 }
9179 }
9180 }
9181 impl MultisampleState {
9182 pub fn new() -> Self {
9183 Self::default()
9184 }
9185 pub(crate) fn to_ffi(
9186 &self,
9187 ) -> (ffi::WGPUMultisampleState, ChainedStructStorage) {
9188 let mut storage = ChainedStructStorage::new();
9189 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9190 for ext in self.extensions.iter().rev() {
9191 next = ext.push_chain(&mut storage, next);
9192 }
9193 let mut raw: ffi::WGPUMultisampleState = unsafe { std::mem::zeroed() };
9194 raw.nextInChain = next;
9195 if let Some(value) = self.count {
9196 raw.count = value;
9197 }
9198 if let Some(value) = self.mask {
9199 raw.mask = value;
9200 }
9201 raw.alphaToCoverageEnabled = if self
9202 .alpha_to_coverage_enabled
9203 .unwrap_or(false)
9204 {
9205 1
9206 } else {
9207 0
9208 };
9209 (raw, storage)
9210 }
9211 pub fn with_extension(mut self, extension: MultisampleStateExtension) -> Self {
9212 self.extensions.push(extension);
9213 self
9214 }
9215 pub(crate) fn from_ffi(value: ffi::WGPUMultisampleState) -> Self {
9216 Self {
9217 extensions: Vec::new(),
9218 count: Some(value.count),
9219 mask: Some(value.mask),
9220 alpha_to_coverage_enabled: Some(value.alphaToCoverageEnabled != 0),
9221 }
9222 }
9223 }
9224 pub struct Origin2D {
9225 pub x: Option<u32>,
9226 pub y: Option<u32>,
9227 }
9228 impl Default for Origin2D {
9229 fn default() -> Self {
9230 Self { x: Some(0), y: Some(0) }
9231 }
9232 }
9233 impl Origin2D {
9234 pub fn new() -> Self {
9235 Self::default()
9236 }
9237 pub(crate) fn to_ffi(&self) -> (ffi::WGPUOrigin2D, ChainedStructStorage) {
9238 let mut storage = ChainedStructStorage::new();
9239 let mut raw: ffi::WGPUOrigin2D = unsafe { std::mem::zeroed() };
9240 if let Some(value) = self.x {
9241 raw.x = value;
9242 }
9243 if let Some(value) = self.y {
9244 raw.y = value;
9245 }
9246 (raw, storage)
9247 }
9248 pub(crate) fn from_ffi(value: ffi::WGPUOrigin2D) -> Self {
9249 Self {
9250 x: Some(value.x),
9251 y: Some(value.y),
9252 }
9253 }
9254 }
9255 pub struct Origin3D {
9256 pub x: Option<u32>,
9257 pub y: Option<u32>,
9258 pub z: Option<u32>,
9259 }
9260 impl Default for Origin3D {
9261 fn default() -> Self {
9262 Self {
9263 x: Some(0),
9264 y: Some(0),
9265 z: Some(0),
9266 }
9267 }
9268 }
9269 impl Origin3D {
9270 pub fn new() -> Self {
9271 Self::default()
9272 }
9273 pub(crate) fn to_ffi(&self) -> (ffi::WGPUOrigin3D, ChainedStructStorage) {
9274 let mut storage = ChainedStructStorage::new();
9275 let mut raw: ffi::WGPUOrigin3D = unsafe { std::mem::zeroed() };
9276 if let Some(value) = self.x {
9277 raw.x = value;
9278 }
9279 if let Some(value) = self.y {
9280 raw.y = value;
9281 }
9282 if let Some(value) = self.z {
9283 raw.z = value;
9284 }
9285 (raw, storage)
9286 }
9287 pub(crate) fn from_ffi(value: ffi::WGPUOrigin3D) -> Self {
9288 Self {
9289 x: Some(value.x),
9290 y: Some(value.y),
9291 z: Some(value.z),
9292 }
9293 }
9294 }
9295 pub struct PassTimestampWrites {
9296 pub(crate) extensions: Vec<PassTimestampWritesExtension>,
9297 pub query_set: Option<QuerySet>,
9298 pub beginning_of_pass_write_index: Option<u32>,
9299 pub end_of_pass_write_index: Option<u32>,
9300 }
9301 impl Default for PassTimestampWrites {
9302 fn default() -> Self {
9303 Self {
9304 extensions: Vec::new(),
9305 query_set: None,
9306 beginning_of_pass_write_index: Some(QUERY_SET_INDEX_UNDEFINED),
9307 end_of_pass_write_index: Some(QUERY_SET_INDEX_UNDEFINED),
9308 }
9309 }
9310 }
9311 impl PassTimestampWrites {
9312 pub fn new() -> Self {
9313 Self::default()
9314 }
9315 pub(crate) fn to_ffi(
9316 &self,
9317 ) -> (ffi::WGPUPassTimestampWrites, ChainedStructStorage) {
9318 let mut storage = ChainedStructStorage::new();
9319 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9320 for ext in self.extensions.iter().rev() {
9321 next = ext.push_chain(&mut storage, next);
9322 }
9323 let mut raw: ffi::WGPUPassTimestampWrites = unsafe { std::mem::zeroed() };
9324 raw.nextInChain = next;
9325 raw.querySet = self
9326 .query_set
9327 .as_ref()
9328 .map(|v| v.as_raw())
9329 .unwrap_or(std::ptr::null_mut());
9330 if let Some(value) = self.beginning_of_pass_write_index {
9331 raw.beginningOfPassWriteIndex = value;
9332 }
9333 if let Some(value) = self.end_of_pass_write_index {
9334 raw.endOfPassWriteIndex = value;
9335 }
9336 (raw, storage)
9337 }
9338 pub fn with_extension(
9339 mut self,
9340 extension: PassTimestampWritesExtension,
9341 ) -> Self {
9342 self.extensions.push(extension);
9343 self
9344 }
9345 pub(crate) fn from_ffi(value: ffi::WGPUPassTimestampWrites) -> Self {
9346 Self {
9347 extensions: Vec::new(),
9348 query_set: Some(unsafe { QuerySet::from_raw(value.querySet) }),
9349 beginning_of_pass_write_index: Some(value.beginningOfPassWriteIndex),
9350 end_of_pass_write_index: Some(value.endOfPassWriteIndex),
9351 }
9352 }
9353 }
9354 pub struct PipelineLayoutDescriptor {
9355 pub(crate) extensions: Vec<PipelineLayoutDescriptorExtension>,
9356 pub label: Option<String>,
9357 pub bind_group_layouts: Option<Vec<BindGroupLayout>>,
9358 pub immediate_size: Option<u32>,
9359 }
9360 impl Default for PipelineLayoutDescriptor {
9361 fn default() -> Self {
9362 Self {
9363 extensions: Vec::new(),
9364 label: None,
9365 bind_group_layouts: None,
9366 immediate_size: Some(0),
9367 }
9368 }
9369 }
9370 impl PipelineLayoutDescriptor {
9371 pub fn new() -> Self {
9372 Self::default()
9373 }
9374 pub(crate) fn to_ffi(
9375 &self,
9376 ) -> (ffi::WGPUPipelineLayoutDescriptor, ChainedStructStorage) {
9377 let mut storage = ChainedStructStorage::new();
9378 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9379 for ext in self.extensions.iter().rev() {
9380 next = ext.push_chain(&mut storage, next);
9381 }
9382 let mut raw: ffi::WGPUPipelineLayoutDescriptor = unsafe {
9383 std::mem::zeroed()
9384 };
9385 raw.nextInChain = next;
9386 if let Some(value) = &self.label {
9387 raw.label = ffi::WGPUStringView {
9388 data: value.as_ptr().cast(),
9389 length: value.len(),
9390 };
9391 } else {
9392 raw.label = ffi::WGPUStringView {
9393 data: std::ptr::null(),
9394 length: 0,
9395 };
9396 }
9397 raw.bindGroupLayoutCount = self
9398 .bind_group_layouts
9399 .as_ref()
9400 .map(|v| v.len())
9401 .unwrap_or(0);
9402 if let Some(values) = &self.bind_group_layouts {
9403 let len_value = values.len();
9404 let raw_vec: Vec<ffi::WGPUBindGroupLayout> = values
9405 .iter()
9406 .map(|v| v.as_raw())
9407 .collect();
9408 let ptr = storage.push_vec(raw_vec);
9409 raw.bindGroupLayouts = ptr;
9410 raw.bindGroupLayoutCount = len_value;
9411 } else {
9412 raw.bindGroupLayouts = std::ptr::null();
9413 raw.bindGroupLayoutCount = 0;
9414 }
9415 if let Some(value) = self.immediate_size {
9416 raw.immediateSize = value;
9417 }
9418 (raw, storage)
9419 }
9420 pub fn with_extension(
9421 mut self,
9422 extension: PipelineLayoutDescriptorExtension,
9423 ) -> Self {
9424 self.extensions.push(extension);
9425 self
9426 }
9427 pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutDescriptor) -> Self {
9428 Self {
9429 extensions: Vec::new(),
9430 label: if value.label.data.is_null() || value.label.length == 0 {
9431 None
9432 } else {
9433 Some(string_view_to_string(value.label))
9434 },
9435 bind_group_layouts: if value.bindGroupLayouts.is_null() {
9436 None
9437 } else {
9438 Some(
9439 unsafe {
9440 std::slice::from_raw_parts(
9441 value.bindGroupLayouts,
9442 value.bindGroupLayoutCount as usize,
9443 )
9444 }
9445 .iter()
9446 .map(|raw| unsafe { BindGroupLayout::from_raw(*raw) })
9447 .collect(),
9448 )
9449 },
9450 immediate_size: Some(value.immediateSize),
9451 }
9452 }
9453 }
9454 pub struct PipelineLayoutPixelLocalStorage {
9455 pub total_pixel_local_storage_size: Option<u64>,
9456 pub storage_attachments: Option<Vec<PipelineLayoutStorageAttachment>>,
9457 }
9458 impl Default for PipelineLayoutPixelLocalStorage {
9459 fn default() -> Self {
9460 Self {
9461 total_pixel_local_storage_size: None,
9462 storage_attachments: None,
9463 }
9464 }
9465 }
9466 impl PipelineLayoutPixelLocalStorage {
9467 pub fn new() -> Self {
9468 Self::default()
9469 }
9470 pub(crate) fn to_ffi(
9471 &self,
9472 ) -> (ffi::WGPUPipelineLayoutPixelLocalStorage, ChainedStructStorage) {
9473 let mut storage = ChainedStructStorage::new();
9474 let mut raw: ffi::WGPUPipelineLayoutPixelLocalStorage = unsafe {
9475 std::mem::zeroed()
9476 };
9477 if let Some(value) = self.total_pixel_local_storage_size {
9478 raw.totalPixelLocalStorageSize = value;
9479 }
9480 raw.storageAttachmentCount = self
9481 .storage_attachments
9482 .as_ref()
9483 .map(|v| v.len())
9484 .unwrap_or(0);
9485 if let Some(values) = &self.storage_attachments {
9486 let len_value = values.len();
9487 let mut raw_vec: Vec<ffi::WGPUPipelineLayoutStorageAttachment> = Vec::with_capacity(
9488 values.len(),
9489 );
9490 for item in values.iter() {
9491 let (raw_item, storage_item) = item.to_ffi();
9492 raw_vec.push(raw_item);
9493 storage.push_storage(storage_item);
9494 }
9495 let ptr = storage.push_vec(raw_vec);
9496 raw.storageAttachments = ptr;
9497 raw.storageAttachmentCount = len_value;
9498 } else {
9499 raw.storageAttachments = std::ptr::null();
9500 raw.storageAttachmentCount = 0;
9501 }
9502 (raw, storage)
9503 }
9504 pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutPixelLocalStorage) -> Self {
9505 Self {
9506 total_pixel_local_storage_size: Some(value.totalPixelLocalStorageSize),
9507 storage_attachments: if value.storageAttachments.is_null() {
9508 None
9509 } else {
9510 Some(
9511 unsafe {
9512 std::slice::from_raw_parts(
9513 value.storageAttachments,
9514 value.storageAttachmentCount as usize,
9515 )
9516 }
9517 .iter()
9518 .map(|raw| PipelineLayoutStorageAttachment::from_ffi(*raw))
9519 .collect(),
9520 )
9521 },
9522 }
9523 }
9524 }
9525 pub struct PipelineLayoutResourceTable {
9526 pub uses_resource_table: Option<bool>,
9527 }
9528 impl Default for PipelineLayoutResourceTable {
9529 fn default() -> Self {
9530 Self { uses_resource_table: None }
9531 }
9532 }
9533 impl PipelineLayoutResourceTable {
9534 pub fn new() -> Self {
9535 Self::default()
9536 }
9537 pub(crate) fn to_ffi(
9538 &self,
9539 ) -> (ffi::WGPUPipelineLayoutResourceTable, ChainedStructStorage) {
9540 let mut storage = ChainedStructStorage::new();
9541 let mut raw: ffi::WGPUPipelineLayoutResourceTable = unsafe {
9542 std::mem::zeroed()
9543 };
9544 raw.usesResourceTable = if self.uses_resource_table.unwrap_or(false) {
9545 1
9546 } else {
9547 0
9548 };
9549 (raw, storage)
9550 }
9551 pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutResourceTable) -> Self {
9552 Self {
9553 uses_resource_table: Some(value.usesResourceTable != 0),
9554 }
9555 }
9556 }
9557 pub struct PipelineLayoutStorageAttachment {
9558 pub(crate) extensions: Vec<PipelineLayoutStorageAttachmentExtension>,
9559 pub offset: Option<u64>,
9560 pub format: Option<TextureFormat>,
9561 }
9562 impl Default for PipelineLayoutStorageAttachment {
9563 fn default() -> Self {
9564 Self {
9565 extensions: Vec::new(),
9566 offset: Some(0),
9567 format: None,
9568 }
9569 }
9570 }
9571 impl PipelineLayoutStorageAttachment {
9572 pub fn new() -> Self {
9573 Self::default()
9574 }
9575 pub(crate) fn to_ffi(
9576 &self,
9577 ) -> (ffi::WGPUPipelineLayoutStorageAttachment, ChainedStructStorage) {
9578 let mut storage = ChainedStructStorage::new();
9579 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9580 for ext in self.extensions.iter().rev() {
9581 next = ext.push_chain(&mut storage, next);
9582 }
9583 let mut raw: ffi::WGPUPipelineLayoutStorageAttachment = unsafe {
9584 std::mem::zeroed()
9585 };
9586 raw.nextInChain = next;
9587 if let Some(value) = self.offset {
9588 raw.offset = value;
9589 }
9590 if let Some(value) = self.format {
9591 raw.format = value.into();
9592 } else {
9593 raw.format = 0 as ffi::WGPUTextureFormat;
9594 }
9595 (raw, storage)
9596 }
9597 pub fn with_extension(
9598 mut self,
9599 extension: PipelineLayoutStorageAttachmentExtension,
9600 ) -> Self {
9601 self.extensions.push(extension);
9602 self
9603 }
9604 pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutStorageAttachment) -> Self {
9605 Self {
9606 extensions: Vec::new(),
9607 offset: Some(value.offset),
9608 format: Some(value.format.into()),
9609 }
9610 }
9611 }
9612 pub struct PrimitiveState {
9613 pub(crate) extensions: Vec<PrimitiveStateExtension>,
9614 pub topology: Option<PrimitiveTopology>,
9615 pub strip_index_format: Option<IndexFormat>,
9616 pub front_face: Option<FrontFace>,
9617 pub cull_mode: Option<CullMode>,
9618 pub unclipped_depth: Option<bool>,
9619 }
9620 impl Default for PrimitiveState {
9621 fn default() -> Self {
9622 Self {
9623 extensions: Vec::new(),
9624 topology: Some(PrimitiveTopology::TriangleList),
9625 strip_index_format: None,
9626 front_face: Some(FrontFace::Ccw),
9627 cull_mode: Some(CullMode::None),
9628 unclipped_depth: None,
9629 }
9630 }
9631 }
9632 impl PrimitiveState {
9633 pub fn new() -> Self {
9634 Self::default()
9635 }
9636 pub(crate) fn to_ffi(&self) -> (ffi::WGPUPrimitiveState, ChainedStructStorage) {
9637 let mut storage = ChainedStructStorage::new();
9638 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9639 for ext in self.extensions.iter().rev() {
9640 next = ext.push_chain(&mut storage, next);
9641 }
9642 let mut raw: ffi::WGPUPrimitiveState = unsafe { std::mem::zeroed() };
9643 raw.nextInChain = next;
9644 if let Some(value) = self.topology {
9645 raw.topology = value.into();
9646 } else {
9647 raw.topology = 0 as ffi::WGPUPrimitiveTopology;
9648 }
9649 if let Some(value) = self.strip_index_format {
9650 raw.stripIndexFormat = value.into();
9651 } else {
9652 raw.stripIndexFormat = 0 as ffi::WGPUIndexFormat;
9653 }
9654 if let Some(value) = self.front_face {
9655 raw.frontFace = value.into();
9656 } else {
9657 raw.frontFace = 0 as ffi::WGPUFrontFace;
9658 }
9659 if let Some(value) = self.cull_mode {
9660 raw.cullMode = value.into();
9661 } else {
9662 raw.cullMode = 0 as ffi::WGPUCullMode;
9663 }
9664 raw.unclippedDepth = if self.unclipped_depth.unwrap_or(false) {
9665 1
9666 } else {
9667 0
9668 };
9669 (raw, storage)
9670 }
9671 pub fn with_extension(mut self, extension: PrimitiveStateExtension) -> Self {
9672 self.extensions.push(extension);
9673 self
9674 }
9675 pub(crate) fn from_ffi(value: ffi::WGPUPrimitiveState) -> Self {
9676 Self {
9677 extensions: Vec::new(),
9678 topology: Some(value.topology.into()),
9679 strip_index_format: Some(value.stripIndexFormat.into()),
9680 front_face: Some(value.frontFace.into()),
9681 cull_mode: Some(value.cullMode.into()),
9682 unclipped_depth: Some(value.unclippedDepth != 0),
9683 }
9684 }
9685 }
9686 pub struct QuerySetDescriptor {
9687 pub(crate) extensions: Vec<QuerySetDescriptorExtension>,
9688 pub label: Option<String>,
9689 pub r#type: Option<QueryType>,
9690 pub count: Option<u32>,
9691 }
9692 impl Default for QuerySetDescriptor {
9693 fn default() -> Self {
9694 Self {
9695 extensions: Vec::new(),
9696 label: None,
9697 r#type: None,
9698 count: None,
9699 }
9700 }
9701 }
9702 impl QuerySetDescriptor {
9703 pub fn new() -> Self {
9704 Self::default()
9705 }
9706 pub(crate) fn to_ffi(
9707 &self,
9708 ) -> (ffi::WGPUQuerySetDescriptor, ChainedStructStorage) {
9709 let mut storage = ChainedStructStorage::new();
9710 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9711 for ext in self.extensions.iter().rev() {
9712 next = ext.push_chain(&mut storage, next);
9713 }
9714 let mut raw: ffi::WGPUQuerySetDescriptor = unsafe { std::mem::zeroed() };
9715 raw.nextInChain = next;
9716 if let Some(value) = &self.label {
9717 raw.label = ffi::WGPUStringView {
9718 data: value.as_ptr().cast(),
9719 length: value.len(),
9720 };
9721 } else {
9722 raw.label = ffi::WGPUStringView {
9723 data: std::ptr::null(),
9724 length: 0,
9725 };
9726 }
9727 if let Some(value) = self.r#type {
9728 raw.type_ = value.into();
9729 } else {
9730 raw.type_ = 0 as ffi::WGPUQueryType;
9731 }
9732 if let Some(value) = self.count {
9733 raw.count = value;
9734 }
9735 (raw, storage)
9736 }
9737 pub fn with_extension(mut self, extension: QuerySetDescriptorExtension) -> Self {
9738 self.extensions.push(extension);
9739 self
9740 }
9741 pub(crate) fn from_ffi(value: ffi::WGPUQuerySetDescriptor) -> Self {
9742 Self {
9743 extensions: Vec::new(),
9744 label: if value.label.data.is_null() || value.label.length == 0 {
9745 None
9746 } else {
9747 Some(string_view_to_string(value.label))
9748 },
9749 r#type: Some(value.type_.into()),
9750 count: Some(value.count),
9751 }
9752 }
9753 }
9754 pub struct QueueDescriptor {
9755 pub(crate) extensions: Vec<QueueDescriptorExtension>,
9756 pub label: Option<String>,
9757 }
9758 impl Default for QueueDescriptor {
9759 fn default() -> Self {
9760 Self {
9761 extensions: Vec::new(),
9762 label: None,
9763 }
9764 }
9765 }
9766 impl QueueDescriptor {
9767 pub fn new() -> Self {
9768 Self::default()
9769 }
9770 pub(crate) fn to_ffi(&self) -> (ffi::WGPUQueueDescriptor, ChainedStructStorage) {
9771 let mut storage = ChainedStructStorage::new();
9772 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9773 for ext in self.extensions.iter().rev() {
9774 next = ext.push_chain(&mut storage, next);
9775 }
9776 let mut raw: ffi::WGPUQueueDescriptor = unsafe { std::mem::zeroed() };
9777 raw.nextInChain = next;
9778 if let Some(value) = &self.label {
9779 raw.label = ffi::WGPUStringView {
9780 data: value.as_ptr().cast(),
9781 length: value.len(),
9782 };
9783 } else {
9784 raw.label = ffi::WGPUStringView {
9785 data: std::ptr::null(),
9786 length: 0,
9787 };
9788 }
9789 (raw, storage)
9790 }
9791 pub fn with_extension(mut self, extension: QueueDescriptorExtension) -> Self {
9792 self.extensions.push(extension);
9793 self
9794 }
9795 pub(crate) fn from_ffi(value: ffi::WGPUQueueDescriptor) -> Self {
9796 Self {
9797 extensions: Vec::new(),
9798 label: if value.label.data.is_null() || value.label.length == 0 {
9799 None
9800 } else {
9801 Some(string_view_to_string(value.label))
9802 },
9803 }
9804 }
9805 }
9806 pub struct RenderBundleDescriptor {
9807 pub(crate) extensions: Vec<RenderBundleDescriptorExtension>,
9808 pub label: Option<String>,
9809 }
9810 impl Default for RenderBundleDescriptor {
9811 fn default() -> Self {
9812 Self {
9813 extensions: Vec::new(),
9814 label: None,
9815 }
9816 }
9817 }
9818 impl RenderBundleDescriptor {
9819 pub fn new() -> Self {
9820 Self::default()
9821 }
9822 pub(crate) fn to_ffi(
9823 &self,
9824 ) -> (ffi::WGPURenderBundleDescriptor, ChainedStructStorage) {
9825 let mut storage = ChainedStructStorage::new();
9826 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9827 for ext in self.extensions.iter().rev() {
9828 next = ext.push_chain(&mut storage, next);
9829 }
9830 let mut raw: ffi::WGPURenderBundleDescriptor = unsafe { std::mem::zeroed() };
9831 raw.nextInChain = next;
9832 if let Some(value) = &self.label {
9833 raw.label = ffi::WGPUStringView {
9834 data: value.as_ptr().cast(),
9835 length: value.len(),
9836 };
9837 } else {
9838 raw.label = ffi::WGPUStringView {
9839 data: std::ptr::null(),
9840 length: 0,
9841 };
9842 }
9843 (raw, storage)
9844 }
9845 pub fn with_extension(
9846 mut self,
9847 extension: RenderBundleDescriptorExtension,
9848 ) -> Self {
9849 self.extensions.push(extension);
9850 self
9851 }
9852 pub(crate) fn from_ffi(value: ffi::WGPURenderBundleDescriptor) -> Self {
9853 Self {
9854 extensions: Vec::new(),
9855 label: if value.label.data.is_null() || value.label.length == 0 {
9856 None
9857 } else {
9858 Some(string_view_to_string(value.label))
9859 },
9860 }
9861 }
9862 }
9863 pub struct RenderBundleEncoderDescriptor {
9864 pub(crate) extensions: Vec<RenderBundleEncoderDescriptorExtension>,
9865 pub label: Option<String>,
9866 pub color_formats: Option<Vec<TextureFormat>>,
9867 pub depth_stencil_format: Option<TextureFormat>,
9868 pub sample_count: Option<u32>,
9869 pub depth_read_only: Option<bool>,
9870 pub stencil_read_only: Option<bool>,
9871 }
9872 impl Default for RenderBundleEncoderDescriptor {
9873 fn default() -> Self {
9874 Self {
9875 extensions: Vec::new(),
9876 label: None,
9877 color_formats: None,
9878 depth_stencil_format: None,
9879 sample_count: Some(1),
9880 depth_read_only: None,
9881 stencil_read_only: None,
9882 }
9883 }
9884 }
9885 impl RenderBundleEncoderDescriptor {
9886 pub fn new() -> Self {
9887 Self::default()
9888 }
9889 pub(crate) fn to_ffi(
9890 &self,
9891 ) -> (ffi::WGPURenderBundleEncoderDescriptor, ChainedStructStorage) {
9892 let mut storage = ChainedStructStorage::new();
9893 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9894 for ext in self.extensions.iter().rev() {
9895 next = ext.push_chain(&mut storage, next);
9896 }
9897 let mut raw: ffi::WGPURenderBundleEncoderDescriptor = unsafe {
9898 std::mem::zeroed()
9899 };
9900 raw.nextInChain = next;
9901 if let Some(value) = &self.label {
9902 raw.label = ffi::WGPUStringView {
9903 data: value.as_ptr().cast(),
9904 length: value.len(),
9905 };
9906 } else {
9907 raw.label = ffi::WGPUStringView {
9908 data: std::ptr::null(),
9909 length: 0,
9910 };
9911 }
9912 raw.colorFormatCount = self
9913 .color_formats
9914 .as_ref()
9915 .map(|v| v.len())
9916 .unwrap_or(0);
9917 if let Some(values) = &self.color_formats {
9918 let len_value = values.len();
9919 let raw_vec: Vec<ffi::WGPUTextureFormat> = values
9920 .iter()
9921 .map(|v| (*v).into())
9922 .collect();
9923 let ptr = storage.push_vec(raw_vec);
9924 raw.colorFormats = ptr;
9925 raw.colorFormatCount = len_value;
9926 } else {
9927 raw.colorFormats = std::ptr::null();
9928 raw.colorFormatCount = 0;
9929 }
9930 if let Some(value) = self.depth_stencil_format {
9931 raw.depthStencilFormat = value.into();
9932 } else {
9933 raw.depthStencilFormat = 0 as ffi::WGPUTextureFormat;
9934 }
9935 if let Some(value) = self.sample_count {
9936 raw.sampleCount = value;
9937 }
9938 raw.depthReadOnly = if self.depth_read_only.unwrap_or(false) {
9939 1
9940 } else {
9941 0
9942 };
9943 raw.stencilReadOnly = if self.stencil_read_only.unwrap_or(false) {
9944 1
9945 } else {
9946 0
9947 };
9948 (raw, storage)
9949 }
9950 pub fn with_extension(
9951 mut self,
9952 extension: RenderBundleEncoderDescriptorExtension,
9953 ) -> Self {
9954 self.extensions.push(extension);
9955 self
9956 }
9957 pub(crate) fn from_ffi(value: ffi::WGPURenderBundleEncoderDescriptor) -> Self {
9958 Self {
9959 extensions: Vec::new(),
9960 label: if value.label.data.is_null() || value.label.length == 0 {
9961 None
9962 } else {
9963 Some(string_view_to_string(value.label))
9964 },
9965 color_formats: if value.colorFormats.is_null() {
9966 None
9967 } else {
9968 Some(
9969 unsafe {
9970 std::slice::from_raw_parts(
9971 value.colorFormats,
9972 value.colorFormatCount as usize,
9973 )
9974 }
9975 .iter()
9976 .map(|raw| TextureFormat::from(*raw))
9977 .collect(),
9978 )
9979 },
9980 depth_stencil_format: Some(value.depthStencilFormat.into()),
9981 sample_count: Some(value.sampleCount),
9982 depth_read_only: Some(value.depthReadOnly != 0),
9983 stencil_read_only: Some(value.stencilReadOnly != 0),
9984 }
9985 }
9986 }
9987 pub struct RenderPassColorAttachment {
9988 pub(crate) extensions: Vec<RenderPassColorAttachmentExtension>,
9989 pub view: Option<TextureView>,
9990 pub depth_slice: Option<u32>,
9991 pub resolve_target: Option<TextureView>,
9992 pub load_op: Option<LoadOp>,
9993 pub store_op: Option<StoreOp>,
9994 pub clear_value: Option<Color>,
9995 }
9996 impl Default for RenderPassColorAttachment {
9997 fn default() -> Self {
9998 Self {
9999 extensions: Vec::new(),
10000 view: None,
10001 depth_slice: Some(DEPTH_SLICE_UNDEFINED),
10002 resolve_target: None,
10003 load_op: None,
10004 store_op: None,
10005 clear_value: None,
10006 }
10007 }
10008 }
10009 impl RenderPassColorAttachment {
10010 pub fn new() -> Self {
10011 Self::default()
10012 }
10013 pub(crate) fn to_ffi(
10014 &self,
10015 ) -> (ffi::WGPURenderPassColorAttachment, ChainedStructStorage) {
10016 let mut storage = ChainedStructStorage::new();
10017 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10018 for ext in self.extensions.iter().rev() {
10019 next = ext.push_chain(&mut storage, next);
10020 }
10021 let mut raw: ffi::WGPURenderPassColorAttachment = unsafe {
10022 std::mem::zeroed()
10023 };
10024 raw.nextInChain = next;
10025 raw.view = self
10026 .view
10027 .as_ref()
10028 .map(|v| v.as_raw())
10029 .unwrap_or(std::ptr::null_mut());
10030 if let Some(value) = self.depth_slice {
10031 raw.depthSlice = value;
10032 }
10033 raw.resolveTarget = self
10034 .resolve_target
10035 .as_ref()
10036 .map(|v| v.as_raw())
10037 .unwrap_or(std::ptr::null_mut());
10038 if let Some(value) = self.load_op {
10039 raw.loadOp = value.into();
10040 } else {
10041 raw.loadOp = 0 as ffi::WGPULoadOp;
10042 }
10043 if let Some(value) = self.store_op {
10044 raw.storeOp = value.into();
10045 } else {
10046 raw.storeOp = 0 as ffi::WGPUStoreOp;
10047 }
10048 if let Some(value) = &self.clear_value {
10049 let (raw_value, storage_value) = value.to_ffi();
10050 raw.clearValue = raw_value;
10051 storage.push_storage(storage_value);
10052 }
10053 (raw, storage)
10054 }
10055 pub fn with_extension(
10056 mut self,
10057 extension: RenderPassColorAttachmentExtension,
10058 ) -> Self {
10059 self.extensions.push(extension);
10060 self
10061 }
10062 pub(crate) fn from_ffi(value: ffi::WGPURenderPassColorAttachment) -> Self {
10063 Self {
10064 extensions: Vec::new(),
10065 view: if value.view.is_null() {
10066 None
10067 } else {
10068 Some(unsafe { TextureView::from_raw(value.view) })
10069 },
10070 depth_slice: Some(value.depthSlice),
10071 resolve_target: if value.resolveTarget.is_null() {
10072 None
10073 } else {
10074 Some(unsafe { TextureView::from_raw(value.resolveTarget) })
10075 },
10076 load_op: Some(value.loadOp.into()),
10077 store_op: Some(value.storeOp.into()),
10078 clear_value: Some(Color::from_ffi(value.clearValue)),
10079 }
10080 }
10081 }
10082 pub struct RenderPassDepthStencilAttachment {
10083 pub(crate) extensions: Vec<RenderPassDepthStencilAttachmentExtension>,
10084 pub view: Option<TextureView>,
10085 pub depth_load_op: Option<LoadOp>,
10086 pub depth_store_op: Option<StoreOp>,
10087 pub depth_clear_value: Option<f32>,
10088 pub depth_read_only: Option<bool>,
10089 pub stencil_load_op: Option<LoadOp>,
10090 pub stencil_store_op: Option<StoreOp>,
10091 pub stencil_clear_value: Option<u32>,
10092 pub stencil_read_only: Option<bool>,
10093 }
10094 impl Default for RenderPassDepthStencilAttachment {
10095 fn default() -> Self {
10096 Self {
10097 extensions: Vec::new(),
10098 view: None,
10099 depth_load_op: None,
10100 depth_store_op: None,
10101 depth_clear_value: Some(DEPTH_CLEAR_VALUE_UNDEFINED),
10102 depth_read_only: None,
10103 stencil_load_op: None,
10104 stencil_store_op: None,
10105 stencil_clear_value: Some(0),
10106 stencil_read_only: None,
10107 }
10108 }
10109 }
10110 impl RenderPassDepthStencilAttachment {
10111 pub fn new() -> Self {
10112 Self::default()
10113 }
10114 pub(crate) fn to_ffi(
10115 &self,
10116 ) -> (ffi::WGPURenderPassDepthStencilAttachment, ChainedStructStorage) {
10117 let mut storage = ChainedStructStorage::new();
10118 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10119 for ext in self.extensions.iter().rev() {
10120 next = ext.push_chain(&mut storage, next);
10121 }
10122 let mut raw: ffi::WGPURenderPassDepthStencilAttachment = unsafe {
10123 std::mem::zeroed()
10124 };
10125 raw.nextInChain = next;
10126 raw.view = self
10127 .view
10128 .as_ref()
10129 .map(|v| v.as_raw())
10130 .unwrap_or(std::ptr::null_mut());
10131 if let Some(value) = self.depth_load_op {
10132 raw.depthLoadOp = value.into();
10133 } else {
10134 raw.depthLoadOp = 0 as ffi::WGPULoadOp;
10135 }
10136 if let Some(value) = self.depth_store_op {
10137 raw.depthStoreOp = value.into();
10138 } else {
10139 raw.depthStoreOp = 0 as ffi::WGPUStoreOp;
10140 }
10141 if let Some(value) = self.depth_clear_value {
10142 raw.depthClearValue = value;
10143 }
10144 raw.depthReadOnly = if self.depth_read_only.unwrap_or(false) {
10145 1
10146 } else {
10147 0
10148 };
10149 if let Some(value) = self.stencil_load_op {
10150 raw.stencilLoadOp = value.into();
10151 } else {
10152 raw.stencilLoadOp = 0 as ffi::WGPULoadOp;
10153 }
10154 if let Some(value) = self.stencil_store_op {
10155 raw.stencilStoreOp = value.into();
10156 } else {
10157 raw.stencilStoreOp = 0 as ffi::WGPUStoreOp;
10158 }
10159 if let Some(value) = self.stencil_clear_value {
10160 raw.stencilClearValue = value;
10161 }
10162 raw.stencilReadOnly = if self.stencil_read_only.unwrap_or(false) {
10163 1
10164 } else {
10165 0
10166 };
10167 (raw, storage)
10168 }
10169 pub fn with_extension(
10170 mut self,
10171 extension: RenderPassDepthStencilAttachmentExtension,
10172 ) -> Self {
10173 self.extensions.push(extension);
10174 self
10175 }
10176 pub(crate) fn from_ffi(
10177 value: ffi::WGPURenderPassDepthStencilAttachment,
10178 ) -> Self {
10179 Self {
10180 extensions: Vec::new(),
10181 view: Some(unsafe { TextureView::from_raw(value.view) }),
10182 depth_load_op: Some(value.depthLoadOp.into()),
10183 depth_store_op: Some(value.depthStoreOp.into()),
10184 depth_clear_value: Some(value.depthClearValue),
10185 depth_read_only: Some(value.depthReadOnly != 0),
10186 stencil_load_op: Some(value.stencilLoadOp.into()),
10187 stencil_store_op: Some(value.stencilStoreOp.into()),
10188 stencil_clear_value: Some(value.stencilClearValue),
10189 stencil_read_only: Some(value.stencilReadOnly != 0),
10190 }
10191 }
10192 }
10193 pub struct RenderPassDescriptor {
10194 pub(crate) extensions: Vec<RenderPassDescriptorExtension>,
10195 pub label: Option<String>,
10196 pub color_attachments: Option<Vec<RenderPassColorAttachment>>,
10197 pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachment>,
10198 pub occlusion_query_set: Option<QuerySet>,
10199 pub timestamp_writes: Option<PassTimestampWrites>,
10200 }
10201 impl Default for RenderPassDescriptor {
10202 fn default() -> Self {
10203 Self {
10204 extensions: Vec::new(),
10205 label: None,
10206 color_attachments: None,
10207 depth_stencil_attachment: None,
10208 occlusion_query_set: None,
10209 timestamp_writes: None,
10210 }
10211 }
10212 }
10213 impl RenderPassDescriptor {
10214 pub fn new() -> Self {
10215 Self::default()
10216 }
10217 pub(crate) fn to_ffi(
10218 &self,
10219 ) -> (ffi::WGPURenderPassDescriptor, ChainedStructStorage) {
10220 let mut storage = ChainedStructStorage::new();
10221 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10222 for ext in self.extensions.iter().rev() {
10223 next = ext.push_chain(&mut storage, next);
10224 }
10225 let mut raw: ffi::WGPURenderPassDescriptor = unsafe { std::mem::zeroed() };
10226 raw.nextInChain = next;
10227 if let Some(value) = &self.label {
10228 raw.label = ffi::WGPUStringView {
10229 data: value.as_ptr().cast(),
10230 length: value.len(),
10231 };
10232 } else {
10233 raw.label = ffi::WGPUStringView {
10234 data: std::ptr::null(),
10235 length: 0,
10236 };
10237 }
10238 raw.colorAttachmentCount = self
10239 .color_attachments
10240 .as_ref()
10241 .map(|v| v.len())
10242 .unwrap_or(0);
10243 if let Some(values) = &self.color_attachments {
10244 let len_value = values.len();
10245 let mut raw_vec: Vec<ffi::WGPURenderPassColorAttachment> = Vec::with_capacity(
10246 values.len(),
10247 );
10248 for item in values.iter() {
10249 let (raw_item, storage_item) = item.to_ffi();
10250 raw_vec.push(raw_item);
10251 storage.push_storage(storage_item);
10252 }
10253 let ptr = storage.push_vec(raw_vec);
10254 raw.colorAttachments = ptr;
10255 raw.colorAttachmentCount = len_value;
10256 } else {
10257 raw.colorAttachments = std::ptr::null();
10258 raw.colorAttachmentCount = 0;
10259 }
10260 if let Some(value) = &self.depth_stencil_attachment {
10261 let (raw_value, storage_value) = value.to_ffi();
10262 let ptr = storage.push_value(raw_value);
10263 raw.depthStencilAttachment = ptr;
10264 storage.push_storage(storage_value);
10265 } else {
10266 raw.depthStencilAttachment = std::ptr::null();
10267 }
10268 raw.occlusionQuerySet = self
10269 .occlusion_query_set
10270 .as_ref()
10271 .map(|v| v.as_raw())
10272 .unwrap_or(std::ptr::null_mut());
10273 if let Some(value) = &self.timestamp_writes {
10274 let (raw_value, storage_value) = value.to_ffi();
10275 let ptr = storage.push_value(raw_value);
10276 raw.timestampWrites = ptr;
10277 storage.push_storage(storage_value);
10278 } else {
10279 raw.timestampWrites = std::ptr::null();
10280 }
10281 (raw, storage)
10282 }
10283 pub fn with_extension(
10284 mut self,
10285 extension: RenderPassDescriptorExtension,
10286 ) -> Self {
10287 self.extensions.push(extension);
10288 self
10289 }
10290 pub(crate) fn from_ffi(value: ffi::WGPURenderPassDescriptor) -> Self {
10291 Self {
10292 extensions: Vec::new(),
10293 label: if value.label.data.is_null() || value.label.length == 0 {
10294 None
10295 } else {
10296 Some(string_view_to_string(value.label))
10297 },
10298 color_attachments: if value.colorAttachments.is_null() {
10299 None
10300 } else {
10301 Some(
10302 unsafe {
10303 std::slice::from_raw_parts(
10304 value.colorAttachments,
10305 value.colorAttachmentCount as usize,
10306 )
10307 }
10308 .iter()
10309 .map(|raw| RenderPassColorAttachment::from_ffi(*raw))
10310 .collect(),
10311 )
10312 },
10313 depth_stencil_attachment: if value.depthStencilAttachment.is_null() {
10314 None
10315 } else {
10316 Some(
10317 RenderPassDepthStencilAttachment::from_ffi(unsafe {
10318 *value.depthStencilAttachment
10319 }),
10320 )
10321 },
10322 occlusion_query_set: if value.occlusionQuerySet.is_null() {
10323 None
10324 } else {
10325 Some(unsafe { QuerySet::from_raw(value.occlusionQuerySet) })
10326 },
10327 timestamp_writes: if value.timestampWrites.is_null() {
10328 None
10329 } else {
10330 Some(
10331 PassTimestampWrites::from_ffi(unsafe { *value.timestampWrites }),
10332 )
10333 },
10334 }
10335 }
10336 }
10337 pub struct RenderPassDescriptorExpandResolveRect {
10338 pub x: Option<u32>,
10339 pub y: Option<u32>,
10340 pub width: Option<u32>,
10341 pub height: Option<u32>,
10342 }
10343 impl Default for RenderPassDescriptorExpandResolveRect {
10344 fn default() -> Self {
10345 Self {
10346 x: None,
10347 y: None,
10348 width: None,
10349 height: None,
10350 }
10351 }
10352 }
10353 impl RenderPassDescriptorExpandResolveRect {
10354 pub fn new() -> Self {
10355 Self::default()
10356 }
10357 pub(crate) fn to_ffi(
10358 &self,
10359 ) -> (ffi::WGPURenderPassDescriptorExpandResolveRect, ChainedStructStorage) {
10360 let mut storage = ChainedStructStorage::new();
10361 let mut raw: ffi::WGPURenderPassDescriptorExpandResolveRect = unsafe {
10362 std::mem::zeroed()
10363 };
10364 if let Some(value) = self.x {
10365 raw.x = value;
10366 }
10367 if let Some(value) = self.y {
10368 raw.y = value;
10369 }
10370 if let Some(value) = self.width {
10371 raw.width = value;
10372 }
10373 if let Some(value) = self.height {
10374 raw.height = value;
10375 }
10376 (raw, storage)
10377 }
10378 pub(crate) fn from_ffi(
10379 value: ffi::WGPURenderPassDescriptorExpandResolveRect,
10380 ) -> Self {
10381 Self {
10382 x: Some(value.x),
10383 y: Some(value.y),
10384 width: Some(value.width),
10385 height: Some(value.height),
10386 }
10387 }
10388 }
10389 pub struct RenderPassDescriptorResolveRect {
10390 pub color_offset_x: Option<u32>,
10391 pub color_offset_y: Option<u32>,
10392 pub resolve_offset_x: Option<u32>,
10393 pub resolve_offset_y: Option<u32>,
10394 pub width: Option<u32>,
10395 pub height: Option<u32>,
10396 }
10397 impl Default for RenderPassDescriptorResolveRect {
10398 fn default() -> Self {
10399 Self {
10400 color_offset_x: None,
10401 color_offset_y: None,
10402 resolve_offset_x: None,
10403 resolve_offset_y: None,
10404 width: None,
10405 height: None,
10406 }
10407 }
10408 }
10409 impl RenderPassDescriptorResolveRect {
10410 pub fn new() -> Self {
10411 Self::default()
10412 }
10413 pub(crate) fn to_ffi(
10414 &self,
10415 ) -> (ffi::WGPURenderPassDescriptorResolveRect, ChainedStructStorage) {
10416 let mut storage = ChainedStructStorage::new();
10417 let mut raw: ffi::WGPURenderPassDescriptorResolveRect = unsafe {
10418 std::mem::zeroed()
10419 };
10420 if let Some(value) = self.color_offset_x {
10421 raw.colorOffsetX = value;
10422 }
10423 if let Some(value) = self.color_offset_y {
10424 raw.colorOffsetY = value;
10425 }
10426 if let Some(value) = self.resolve_offset_x {
10427 raw.resolveOffsetX = value;
10428 }
10429 if let Some(value) = self.resolve_offset_y {
10430 raw.resolveOffsetY = value;
10431 }
10432 if let Some(value) = self.width {
10433 raw.width = value;
10434 }
10435 if let Some(value) = self.height {
10436 raw.height = value;
10437 }
10438 (raw, storage)
10439 }
10440 pub(crate) fn from_ffi(value: ffi::WGPURenderPassDescriptorResolveRect) -> Self {
10441 Self {
10442 color_offset_x: Some(value.colorOffsetX),
10443 color_offset_y: Some(value.colorOffsetY),
10444 resolve_offset_x: Some(value.resolveOffsetX),
10445 resolve_offset_y: Some(value.resolveOffsetY),
10446 width: Some(value.width),
10447 height: Some(value.height),
10448 }
10449 }
10450 }
10451 pub struct RenderPassMaxDrawCount {
10452 pub max_draw_count: Option<u64>,
10453 }
10454 impl Default for RenderPassMaxDrawCount {
10455 fn default() -> Self {
10456 Self {
10457 max_draw_count: Some(50000000),
10458 }
10459 }
10460 }
10461 impl RenderPassMaxDrawCount {
10462 pub fn new() -> Self {
10463 Self::default()
10464 }
10465 pub(crate) fn to_ffi(
10466 &self,
10467 ) -> (ffi::WGPURenderPassMaxDrawCount, ChainedStructStorage) {
10468 let mut storage = ChainedStructStorage::new();
10469 let mut raw: ffi::WGPURenderPassMaxDrawCount = unsafe { std::mem::zeroed() };
10470 if let Some(value) = self.max_draw_count {
10471 raw.maxDrawCount = value;
10472 }
10473 (raw, storage)
10474 }
10475 pub(crate) fn from_ffi(value: ffi::WGPURenderPassMaxDrawCount) -> Self {
10476 Self {
10477 max_draw_count: Some(value.maxDrawCount),
10478 }
10479 }
10480 }
10481 pub struct RenderPassPixelLocalStorage {
10482 pub total_pixel_local_storage_size: Option<u64>,
10483 pub storage_attachments: Option<Vec<RenderPassStorageAttachment>>,
10484 }
10485 impl Default for RenderPassPixelLocalStorage {
10486 fn default() -> Self {
10487 Self {
10488 total_pixel_local_storage_size: None,
10489 storage_attachments: None,
10490 }
10491 }
10492 }
10493 impl RenderPassPixelLocalStorage {
10494 pub fn new() -> Self {
10495 Self::default()
10496 }
10497 pub(crate) fn to_ffi(
10498 &self,
10499 ) -> (ffi::WGPURenderPassPixelLocalStorage, ChainedStructStorage) {
10500 let mut storage = ChainedStructStorage::new();
10501 let mut raw: ffi::WGPURenderPassPixelLocalStorage = unsafe {
10502 std::mem::zeroed()
10503 };
10504 if let Some(value) = self.total_pixel_local_storage_size {
10505 raw.totalPixelLocalStorageSize = value;
10506 }
10507 raw.storageAttachmentCount = self
10508 .storage_attachments
10509 .as_ref()
10510 .map(|v| v.len())
10511 .unwrap_or(0);
10512 if let Some(values) = &self.storage_attachments {
10513 let len_value = values.len();
10514 let mut raw_vec: Vec<ffi::WGPURenderPassStorageAttachment> = Vec::with_capacity(
10515 values.len(),
10516 );
10517 for item in values.iter() {
10518 let (raw_item, storage_item) = item.to_ffi();
10519 raw_vec.push(raw_item);
10520 storage.push_storage(storage_item);
10521 }
10522 let ptr = storage.push_vec(raw_vec);
10523 raw.storageAttachments = ptr;
10524 raw.storageAttachmentCount = len_value;
10525 } else {
10526 raw.storageAttachments = std::ptr::null();
10527 raw.storageAttachmentCount = 0;
10528 }
10529 (raw, storage)
10530 }
10531 pub(crate) fn from_ffi(value: ffi::WGPURenderPassPixelLocalStorage) -> Self {
10532 Self {
10533 total_pixel_local_storage_size: Some(value.totalPixelLocalStorageSize),
10534 storage_attachments: if value.storageAttachments.is_null() {
10535 None
10536 } else {
10537 Some(
10538 unsafe {
10539 std::slice::from_raw_parts(
10540 value.storageAttachments,
10541 value.storageAttachmentCount as usize,
10542 )
10543 }
10544 .iter()
10545 .map(|raw| RenderPassStorageAttachment::from_ffi(*raw))
10546 .collect(),
10547 )
10548 },
10549 }
10550 }
10551 }
10552 pub struct RenderPassStorageAttachment {
10553 pub(crate) extensions: Vec<RenderPassStorageAttachmentExtension>,
10554 pub offset: Option<u64>,
10555 pub storage: Option<TextureView>,
10556 pub load_op: Option<LoadOp>,
10557 pub store_op: Option<StoreOp>,
10558 pub clear_value: Option<Color>,
10559 }
10560 impl Default for RenderPassStorageAttachment {
10561 fn default() -> Self {
10562 Self {
10563 extensions: Vec::new(),
10564 offset: Some(0),
10565 storage: None,
10566 load_op: None,
10567 store_op: None,
10568 clear_value: None,
10569 }
10570 }
10571 }
10572 impl RenderPassStorageAttachment {
10573 pub fn new() -> Self {
10574 Self::default()
10575 }
10576 pub(crate) fn to_ffi(
10577 &self,
10578 ) -> (ffi::WGPURenderPassStorageAttachment, ChainedStructStorage) {
10579 let mut storage = ChainedStructStorage::new();
10580 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10581 for ext in self.extensions.iter().rev() {
10582 next = ext.push_chain(&mut storage, next);
10583 }
10584 let mut raw: ffi::WGPURenderPassStorageAttachment = unsafe {
10585 std::mem::zeroed()
10586 };
10587 raw.nextInChain = next;
10588 if let Some(value) = self.offset {
10589 raw.offset = value;
10590 }
10591 raw.storage = self
10592 .storage
10593 .as_ref()
10594 .map(|v| v.as_raw())
10595 .unwrap_or(std::ptr::null_mut());
10596 if let Some(value) = self.load_op {
10597 raw.loadOp = value.into();
10598 } else {
10599 raw.loadOp = 0 as ffi::WGPULoadOp;
10600 }
10601 if let Some(value) = self.store_op {
10602 raw.storeOp = value.into();
10603 } else {
10604 raw.storeOp = 0 as ffi::WGPUStoreOp;
10605 }
10606 if let Some(value) = &self.clear_value {
10607 let (raw_value, storage_value) = value.to_ffi();
10608 raw.clearValue = raw_value;
10609 storage.push_storage(storage_value);
10610 }
10611 (raw, storage)
10612 }
10613 pub fn with_extension(
10614 mut self,
10615 extension: RenderPassStorageAttachmentExtension,
10616 ) -> Self {
10617 self.extensions.push(extension);
10618 self
10619 }
10620 pub(crate) fn from_ffi(value: ffi::WGPURenderPassStorageAttachment) -> Self {
10621 Self {
10622 extensions: Vec::new(),
10623 offset: Some(value.offset),
10624 storage: Some(unsafe { TextureView::from_raw(value.storage) }),
10625 load_op: Some(value.loadOp.into()),
10626 store_op: Some(value.storeOp.into()),
10627 clear_value: Some(Color::from_ffi(value.clearValue)),
10628 }
10629 }
10630 }
10631 pub struct RenderPipelineDescriptor {
10632 pub(crate) extensions: Vec<RenderPipelineDescriptorExtension>,
10633 pub label: Option<String>,
10634 pub layout: Option<PipelineLayout>,
10635 pub vertex: Option<VertexState>,
10636 pub primitive: Option<PrimitiveState>,
10637 pub depth_stencil: Option<DepthStencilState>,
10638 pub multisample: Option<MultisampleState>,
10639 pub fragment: Option<FragmentState>,
10640 }
10641 impl Default for RenderPipelineDescriptor {
10642 fn default() -> Self {
10643 Self {
10644 extensions: Vec::new(),
10645 label: None,
10646 layout: None,
10647 vertex: None,
10648 primitive: None,
10649 depth_stencil: None,
10650 multisample: None,
10651 fragment: None,
10652 }
10653 }
10654 }
10655 impl RenderPipelineDescriptor {
10656 pub fn new() -> Self {
10657 Self::default()
10658 }
10659 pub(crate) fn to_ffi(
10660 &self,
10661 ) -> (ffi::WGPURenderPipelineDescriptor, ChainedStructStorage) {
10662 let mut storage = ChainedStructStorage::new();
10663 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10664 for ext in self.extensions.iter().rev() {
10665 next = ext.push_chain(&mut storage, next);
10666 }
10667 let mut raw: ffi::WGPURenderPipelineDescriptor = unsafe {
10668 std::mem::zeroed()
10669 };
10670 raw.nextInChain = next;
10671 if let Some(value) = &self.label {
10672 raw.label = ffi::WGPUStringView {
10673 data: value.as_ptr().cast(),
10674 length: value.len(),
10675 };
10676 } else {
10677 raw.label = ffi::WGPUStringView {
10678 data: std::ptr::null(),
10679 length: 0,
10680 };
10681 }
10682 raw.layout = self
10683 .layout
10684 .as_ref()
10685 .map(|v| v.as_raw())
10686 .unwrap_or(std::ptr::null_mut());
10687 if let Some(value) = &self.vertex {
10688 let (raw_value, storage_value) = value.to_ffi();
10689 raw.vertex = raw_value;
10690 storage.push_storage(storage_value);
10691 }
10692 if let Some(value) = &self.primitive {
10693 let (raw_value, storage_value) = value.to_ffi();
10694 raw.primitive = raw_value;
10695 storage.push_storage(storage_value);
10696 }
10697 if let Some(value) = &self.depth_stencil {
10698 let (raw_value, storage_value) = value.to_ffi();
10699 let ptr = storage.push_value(raw_value);
10700 raw.depthStencil = ptr;
10701 storage.push_storage(storage_value);
10702 } else {
10703 raw.depthStencil = std::ptr::null();
10704 }
10705 if let Some(value) = &self.multisample {
10706 let (raw_value, storage_value) = value.to_ffi();
10707 raw.multisample = raw_value;
10708 storage.push_storage(storage_value);
10709 }
10710 if let Some(value) = &self.fragment {
10711 let (raw_value, storage_value) = value.to_ffi();
10712 let ptr = storage.push_value(raw_value);
10713 raw.fragment = ptr;
10714 storage.push_storage(storage_value);
10715 } else {
10716 raw.fragment = std::ptr::null();
10717 }
10718 (raw, storage)
10719 }
10720 pub fn with_extension(
10721 mut self,
10722 extension: RenderPipelineDescriptorExtension,
10723 ) -> Self {
10724 self.extensions.push(extension);
10725 self
10726 }
10727 pub(crate) fn from_ffi(value: ffi::WGPURenderPipelineDescriptor) -> Self {
10728 Self {
10729 extensions: Vec::new(),
10730 label: if value.label.data.is_null() || value.label.length == 0 {
10731 None
10732 } else {
10733 Some(string_view_to_string(value.label))
10734 },
10735 layout: if value.layout.is_null() {
10736 None
10737 } else {
10738 Some(unsafe { PipelineLayout::from_raw(value.layout) })
10739 },
10740 vertex: Some(VertexState::from_ffi(value.vertex)),
10741 primitive: Some(PrimitiveState::from_ffi(value.primitive)),
10742 depth_stencil: if value.depthStencil.is_null() {
10743 None
10744 } else {
10745 Some(DepthStencilState::from_ffi(unsafe { *value.depthStencil }))
10746 },
10747 multisample: Some(MultisampleState::from_ffi(value.multisample)),
10748 fragment: if value.fragment.is_null() {
10749 None
10750 } else {
10751 Some(FragmentState::from_ffi(unsafe { *value.fragment }))
10752 },
10753 }
10754 }
10755 }
10756 pub struct RequestAdapterWebGPUBackendOptions {}
10757 impl Default for RequestAdapterWebGPUBackendOptions {
10758 fn default() -> Self {
10759 Self {}
10760 }
10761 }
10762 impl RequestAdapterWebGPUBackendOptions {
10763 pub fn new() -> Self {
10764 Self::default()
10765 }
10766 pub(crate) fn to_ffi(
10767 &self,
10768 ) -> (ffi::WGPURequestAdapterWebGPUBackendOptions, ChainedStructStorage) {
10769 let mut storage = ChainedStructStorage::new();
10770 let mut raw: ffi::WGPURequestAdapterWebGPUBackendOptions = unsafe {
10771 std::mem::zeroed()
10772 };
10773 (raw, storage)
10774 }
10775 pub(crate) fn from_ffi(
10776 value: ffi::WGPURequestAdapterWebGPUBackendOptions,
10777 ) -> Self {
10778 let _ = value;
10779 Self::default()
10780 }
10781 }
10782 pub struct RequestAdapterWebXROptions {
10783 pub xr_compatible: Option<bool>,
10784 }
10785 impl Default for RequestAdapterWebXROptions {
10786 fn default() -> Self {
10787 Self { xr_compatible: None }
10788 }
10789 }
10790 impl RequestAdapterWebXROptions {
10791 pub fn new() -> Self {
10792 Self::default()
10793 }
10794 pub(crate) fn to_ffi(
10795 &self,
10796 ) -> (ffi::WGPURequestAdapterWebXROptions, ChainedStructStorage) {
10797 let mut storage = ChainedStructStorage::new();
10798 let mut raw: ffi::WGPURequestAdapterWebXROptions = unsafe {
10799 std::mem::zeroed()
10800 };
10801 raw.xrCompatible = if self.xr_compatible.unwrap_or(false) { 1 } else { 0 };
10802 (raw, storage)
10803 }
10804 pub(crate) fn from_ffi(value: ffi::WGPURequestAdapterWebXROptions) -> Self {
10805 Self {
10806 xr_compatible: Some(value.xrCompatible != 0),
10807 }
10808 }
10809 }
10810 pub struct RequestAdapterOptions {
10811 pub(crate) extensions: Vec<RequestAdapterOptionsExtension>,
10812 pub feature_level: Option<FeatureLevel>,
10813 pub power_preference: Option<PowerPreference>,
10814 pub force_fallback_adapter: Option<bool>,
10815 pub backend_type: Option<BackendType>,
10816 pub compatible_surface: Option<Surface>,
10817 }
10818 impl Default for RequestAdapterOptions {
10819 fn default() -> Self {
10820 Self {
10821 extensions: Vec::new(),
10822 feature_level: Some(FeatureLevel::Core),
10823 power_preference: None,
10824 force_fallback_adapter: None,
10825 backend_type: None,
10826 compatible_surface: None,
10827 }
10828 }
10829 }
10830 impl RequestAdapterOptions {
10831 pub fn new() -> Self {
10832 Self::default()
10833 }
10834 pub(crate) fn to_ffi(
10835 &self,
10836 ) -> (ffi::WGPURequestAdapterOptions, ChainedStructStorage) {
10837 let mut storage = ChainedStructStorage::new();
10838 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10839 for ext in self.extensions.iter().rev() {
10840 next = ext.push_chain(&mut storage, next);
10841 }
10842 let mut raw: ffi::WGPURequestAdapterOptions = unsafe { std::mem::zeroed() };
10843 raw.nextInChain = next;
10844 if let Some(value) = self.feature_level {
10845 raw.featureLevel = value.into();
10846 } else {
10847 raw.featureLevel = 0 as ffi::WGPUFeatureLevel;
10848 }
10849 if let Some(value) = self.power_preference {
10850 raw.powerPreference = value.into();
10851 } else {
10852 raw.powerPreference = 0 as ffi::WGPUPowerPreference;
10853 }
10854 raw.forceFallbackAdapter = if self.force_fallback_adapter.unwrap_or(false) {
10855 1
10856 } else {
10857 0
10858 };
10859 if let Some(value) = self.backend_type {
10860 raw.backendType = value.into();
10861 } else {
10862 raw.backendType = 0 as ffi::WGPUBackendType;
10863 }
10864 raw.compatibleSurface = self
10865 .compatible_surface
10866 .as_ref()
10867 .map(|v| v.as_raw())
10868 .unwrap_or(std::ptr::null_mut());
10869 (raw, storage)
10870 }
10871 pub fn with_extension(
10872 mut self,
10873 extension: RequestAdapterOptionsExtension,
10874 ) -> Self {
10875 self.extensions.push(extension);
10876 self
10877 }
10878 pub(crate) fn from_ffi(value: ffi::WGPURequestAdapterOptions) -> Self {
10879 Self {
10880 extensions: Vec::new(),
10881 feature_level: Some(value.featureLevel.into()),
10882 power_preference: Some(value.powerPreference.into()),
10883 force_fallback_adapter: Some(value.forceFallbackAdapter != 0),
10884 backend_type: Some(value.backendType.into()),
10885 compatible_surface: if value.compatibleSurface.is_null() {
10886 None
10887 } else {
10888 Some(unsafe { Surface::from_raw(value.compatibleSurface) })
10889 },
10890 }
10891 }
10892 }
10893 pub struct ResourceTableDescriptor {
10894 pub(crate) extensions: Vec<ResourceTableDescriptorExtension>,
10895 pub label: Option<String>,
10896 pub size: Option<u32>,
10897 }
10898 impl Default for ResourceTableDescriptor {
10899 fn default() -> Self {
10900 Self {
10901 extensions: Vec::new(),
10902 label: None,
10903 size: None,
10904 }
10905 }
10906 }
10907 impl ResourceTableDescriptor {
10908 pub fn new() -> Self {
10909 Self::default()
10910 }
10911 pub(crate) fn to_ffi(
10912 &self,
10913 ) -> (ffi::WGPUResourceTableDescriptor, ChainedStructStorage) {
10914 let mut storage = ChainedStructStorage::new();
10915 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10916 for ext in self.extensions.iter().rev() {
10917 next = ext.push_chain(&mut storage, next);
10918 }
10919 let mut raw: ffi::WGPUResourceTableDescriptor = unsafe {
10920 std::mem::zeroed()
10921 };
10922 raw.nextInChain = next;
10923 if let Some(value) = &self.label {
10924 raw.label = ffi::WGPUStringView {
10925 data: value.as_ptr().cast(),
10926 length: value.len(),
10927 };
10928 } else {
10929 raw.label = ffi::WGPUStringView {
10930 data: std::ptr::null(),
10931 length: 0,
10932 };
10933 }
10934 if let Some(value) = self.size {
10935 raw.size = value;
10936 }
10937 (raw, storage)
10938 }
10939 pub fn with_extension(
10940 mut self,
10941 extension: ResourceTableDescriptorExtension,
10942 ) -> Self {
10943 self.extensions.push(extension);
10944 self
10945 }
10946 pub(crate) fn from_ffi(value: ffi::WGPUResourceTableDescriptor) -> Self {
10947 Self {
10948 extensions: Vec::new(),
10949 label: if value.label.data.is_null() || value.label.length == 0 {
10950 None
10951 } else {
10952 Some(string_view_to_string(value.label))
10953 },
10954 size: Some(value.size),
10955 }
10956 }
10957 }
10958 pub struct SamplerBindingLayout {
10959 pub(crate) extensions: Vec<SamplerBindingLayoutExtension>,
10960 pub r#type: Option<SamplerBindingType>,
10961 }
10962 impl Default for SamplerBindingLayout {
10963 fn default() -> Self {
10964 Self {
10965 extensions: Vec::new(),
10966 r#type: Some(SamplerBindingType::Filtering),
10967 }
10968 }
10969 }
10970 impl SamplerBindingLayout {
10971 pub fn new() -> Self {
10972 Self::default()
10973 }
10974 pub(crate) fn to_ffi(
10975 &self,
10976 ) -> (ffi::WGPUSamplerBindingLayout, ChainedStructStorage) {
10977 let mut storage = ChainedStructStorage::new();
10978 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10979 for ext in self.extensions.iter().rev() {
10980 next = ext.push_chain(&mut storage, next);
10981 }
10982 let mut raw: ffi::WGPUSamplerBindingLayout = unsafe { std::mem::zeroed() };
10983 raw.nextInChain = next;
10984 if let Some(value) = self.r#type {
10985 raw.type_ = value.into();
10986 } else {
10987 raw.type_ = 0 as ffi::WGPUSamplerBindingType;
10988 }
10989 (raw, storage)
10990 }
10991 pub fn with_extension(
10992 mut self,
10993 extension: SamplerBindingLayoutExtension,
10994 ) -> Self {
10995 self.extensions.push(extension);
10996 self
10997 }
10998 pub(crate) fn from_ffi(value: ffi::WGPUSamplerBindingLayout) -> Self {
10999 Self {
11000 extensions: Vec::new(),
11001 r#type: Some(value.type_.into()),
11002 }
11003 }
11004 }
11005 pub struct SamplerDescriptor {
11006 pub(crate) extensions: Vec<SamplerDescriptorExtension>,
11007 pub label: Option<String>,
11008 pub address_mode_u: Option<AddressMode>,
11009 pub address_mode_v: Option<AddressMode>,
11010 pub address_mode_w: Option<AddressMode>,
11011 pub mag_filter: Option<FilterMode>,
11012 pub min_filter: Option<FilterMode>,
11013 pub mipmap_filter: Option<MipmapFilterMode>,
11014 pub lod_min_clamp: Option<f32>,
11015 pub lod_max_clamp: Option<f32>,
11016 pub compare: Option<CompareFunction>,
11017 pub max_anisotropy: Option<u16>,
11018 }
11019 impl Default for SamplerDescriptor {
11020 fn default() -> Self {
11021 Self {
11022 extensions: Vec::new(),
11023 label: None,
11024 address_mode_u: Some(AddressMode::ClampToEdge),
11025 address_mode_v: Some(AddressMode::ClampToEdge),
11026 address_mode_w: Some(AddressMode::ClampToEdge),
11027 mag_filter: Some(FilterMode::Nearest),
11028 min_filter: Some(FilterMode::Nearest),
11029 mipmap_filter: Some(MipmapFilterMode::Nearest),
11030 lod_min_clamp: None,
11031 lod_max_clamp: None,
11032 compare: None,
11033 max_anisotropy: Some(1),
11034 }
11035 }
11036 }
11037 impl SamplerDescriptor {
11038 pub fn new() -> Self {
11039 Self::default()
11040 }
11041 pub(crate) fn to_ffi(
11042 &self,
11043 ) -> (ffi::WGPUSamplerDescriptor, ChainedStructStorage) {
11044 let mut storage = ChainedStructStorage::new();
11045 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11046 for ext in self.extensions.iter().rev() {
11047 next = ext.push_chain(&mut storage, next);
11048 }
11049 let mut raw: ffi::WGPUSamplerDescriptor = unsafe { std::mem::zeroed() };
11050 raw.nextInChain = next;
11051 if let Some(value) = &self.label {
11052 raw.label = ffi::WGPUStringView {
11053 data: value.as_ptr().cast(),
11054 length: value.len(),
11055 };
11056 } else {
11057 raw.label = ffi::WGPUStringView {
11058 data: std::ptr::null(),
11059 length: 0,
11060 };
11061 }
11062 if let Some(value) = self.address_mode_u {
11063 raw.addressModeU = value.into();
11064 } else {
11065 raw.addressModeU = 0 as ffi::WGPUAddressMode;
11066 }
11067 if let Some(value) = self.address_mode_v {
11068 raw.addressModeV = value.into();
11069 } else {
11070 raw.addressModeV = 0 as ffi::WGPUAddressMode;
11071 }
11072 if let Some(value) = self.address_mode_w {
11073 raw.addressModeW = value.into();
11074 } else {
11075 raw.addressModeW = 0 as ffi::WGPUAddressMode;
11076 }
11077 if let Some(value) = self.mag_filter {
11078 raw.magFilter = value.into();
11079 } else {
11080 raw.magFilter = 0 as ffi::WGPUFilterMode;
11081 }
11082 if let Some(value) = self.min_filter {
11083 raw.minFilter = value.into();
11084 } else {
11085 raw.minFilter = 0 as ffi::WGPUFilterMode;
11086 }
11087 if let Some(value) = self.mipmap_filter {
11088 raw.mipmapFilter = value.into();
11089 } else {
11090 raw.mipmapFilter = 0 as ffi::WGPUMipmapFilterMode;
11091 }
11092 if let Some(value) = self.lod_min_clamp {
11093 raw.lodMinClamp = value;
11094 }
11095 if let Some(value) = self.lod_max_clamp {
11096 raw.lodMaxClamp = value;
11097 }
11098 if let Some(value) = self.compare {
11099 raw.compare = value.into();
11100 } else {
11101 raw.compare = 0 as ffi::WGPUCompareFunction;
11102 }
11103 if let Some(value) = self.max_anisotropy {
11104 raw.maxAnisotropy = value;
11105 }
11106 (raw, storage)
11107 }
11108 pub fn with_extension(mut self, extension: SamplerDescriptorExtension) -> Self {
11109 self.extensions.push(extension);
11110 self
11111 }
11112 pub(crate) fn from_ffi(value: ffi::WGPUSamplerDescriptor) -> Self {
11113 Self {
11114 extensions: Vec::new(),
11115 label: if value.label.data.is_null() || value.label.length == 0 {
11116 None
11117 } else {
11118 Some(string_view_to_string(value.label))
11119 },
11120 address_mode_u: Some(value.addressModeU.into()),
11121 address_mode_v: Some(value.addressModeV.into()),
11122 address_mode_w: Some(value.addressModeW.into()),
11123 mag_filter: Some(value.magFilter.into()),
11124 min_filter: Some(value.minFilter.into()),
11125 mipmap_filter: Some(value.mipmapFilter.into()),
11126 lod_min_clamp: Some(value.lodMinClamp),
11127 lod_max_clamp: Some(value.lodMaxClamp),
11128 compare: Some(value.compare.into()),
11129 max_anisotropy: Some(value.maxAnisotropy),
11130 }
11131 }
11132 }
11133 pub struct ShaderModuleCompilationOptions {
11134 pub strict_math: Option<bool>,
11135 }
11136 impl Default for ShaderModuleCompilationOptions {
11137 fn default() -> Self {
11138 Self { strict_math: None }
11139 }
11140 }
11141 impl ShaderModuleCompilationOptions {
11142 pub fn new() -> Self {
11143 Self::default()
11144 }
11145 pub(crate) fn to_ffi(
11146 &self,
11147 ) -> (ffi::WGPUShaderModuleCompilationOptions, ChainedStructStorage) {
11148 let mut storage = ChainedStructStorage::new();
11149 let mut raw: ffi::WGPUShaderModuleCompilationOptions = unsafe {
11150 std::mem::zeroed()
11151 };
11152 raw.strictMath = if self.strict_math.unwrap_or(false) { 1 } else { 0 };
11153 (raw, storage)
11154 }
11155 pub(crate) fn from_ffi(value: ffi::WGPUShaderModuleCompilationOptions) -> Self {
11156 Self {
11157 strict_math: Some(value.strictMath != 0),
11158 }
11159 }
11160 }
11161 pub struct ShaderModuleDescriptor {
11162 pub(crate) extensions: Vec<ShaderModuleDescriptorExtension>,
11163 pub label: Option<String>,
11164 }
11165 impl Default for ShaderModuleDescriptor {
11166 fn default() -> Self {
11167 Self {
11168 extensions: Vec::new(),
11169 label: None,
11170 }
11171 }
11172 }
11173 impl ShaderModuleDescriptor {
11174 pub fn new() -> Self {
11175 Self::default()
11176 }
11177 pub(crate) fn to_ffi(
11178 &self,
11179 ) -> (ffi::WGPUShaderModuleDescriptor, ChainedStructStorage) {
11180 let mut storage = ChainedStructStorage::new();
11181 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11182 for ext in self.extensions.iter().rev() {
11183 next = ext.push_chain(&mut storage, next);
11184 }
11185 let mut raw: ffi::WGPUShaderModuleDescriptor = unsafe { std::mem::zeroed() };
11186 raw.nextInChain = next;
11187 if let Some(value) = &self.label {
11188 raw.label = ffi::WGPUStringView {
11189 data: value.as_ptr().cast(),
11190 length: value.len(),
11191 };
11192 } else {
11193 raw.label = ffi::WGPUStringView {
11194 data: std::ptr::null(),
11195 length: 0,
11196 };
11197 }
11198 (raw, storage)
11199 }
11200 pub fn with_extension(
11201 mut self,
11202 extension: ShaderModuleDescriptorExtension,
11203 ) -> Self {
11204 self.extensions.push(extension);
11205 self
11206 }
11207 pub(crate) fn from_ffi(value: ffi::WGPUShaderModuleDescriptor) -> Self {
11208 Self {
11209 extensions: Vec::new(),
11210 label: if value.label.data.is_null() || value.label.length == 0 {
11211 None
11212 } else {
11213 Some(string_view_to_string(value.label))
11214 },
11215 }
11216 }
11217 }
11218 pub struct ShaderSourceSPIRV {
11219 pub code: Option<Vec<u32>>,
11220 }
11221 impl Default for ShaderSourceSPIRV {
11222 fn default() -> Self {
11223 Self { code: None }
11224 }
11225 }
11226 impl ShaderSourceSPIRV {
11227 pub fn new() -> Self {
11228 Self::default()
11229 }
11230 pub(crate) fn to_ffi(
11231 &self,
11232 ) -> (ffi::WGPUShaderSourceSPIRV, ChainedStructStorage) {
11233 let mut storage = ChainedStructStorage::new();
11234 let mut raw: ffi::WGPUShaderSourceSPIRV = unsafe { std::mem::zeroed() };
11235 raw.codeSize = (self.code.as_ref().map(|v| v.len()).unwrap_or(0)) as u32;
11236 if let Some(values) = &self.code {
11237 let len_value = values.len();
11238 let raw_vec = values.to_vec();
11239 let ptr = storage.push_vec(raw_vec);
11240 raw.code = ptr;
11241 raw.codeSize = len_value as u32;
11242 } else {
11243 raw.code = std::ptr::null();
11244 raw.codeSize = 0;
11245 }
11246 (raw, storage)
11247 }
11248 pub(crate) fn from_ffi(value: ffi::WGPUShaderSourceSPIRV) -> Self {
11249 Self {
11250 code: if value.code.is_null() {
11251 None
11252 } else {
11253 Some(
11254 unsafe {
11255 std::slice::from_raw_parts(
11256 value.code,
11257 value.codeSize as usize,
11258 )
11259 }
11260 .to_vec(),
11261 )
11262 },
11263 }
11264 }
11265 }
11266 pub struct ShaderSourceWGSL {
11267 pub code: Option<String>,
11268 }
11269 impl Default for ShaderSourceWGSL {
11270 fn default() -> Self {
11271 Self { code: None }
11272 }
11273 }
11274 impl ShaderSourceWGSL {
11275 pub fn new() -> Self {
11276 Self::default()
11277 }
11278 pub(crate) fn to_ffi(
11279 &self,
11280 ) -> (ffi::WGPUShaderSourceWGSL, ChainedStructStorage) {
11281 let mut storage = ChainedStructStorage::new();
11282 let mut raw: ffi::WGPUShaderSourceWGSL = unsafe { std::mem::zeroed() };
11283 if let Some(value) = &self.code {
11284 raw.code = ffi::WGPUStringView {
11285 data: value.as_ptr().cast(),
11286 length: value.len(),
11287 };
11288 } else {
11289 raw.code = ffi::WGPUStringView {
11290 data: std::ptr::null(),
11291 length: 0,
11292 };
11293 }
11294 (raw, storage)
11295 }
11296 pub(crate) fn from_ffi(value: ffi::WGPUShaderSourceWGSL) -> Self {
11297 Self {
11298 code: Some(string_view_to_string(value.code)),
11299 }
11300 }
11301 }
11302 pub struct SharedBufferMemoryBeginAccessDescriptor {
11303 pub(crate) extensions: Vec<SharedBufferMemoryBeginAccessDescriptorExtension>,
11304 pub initialized: Option<bool>,
11305 pub fences: Option<Vec<SharedFence>>,
11306 pub signaled_values: Option<Vec<u64>>,
11307 }
11308 impl Default for SharedBufferMemoryBeginAccessDescriptor {
11309 fn default() -> Self {
11310 Self {
11311 extensions: Vec::new(),
11312 initialized: None,
11313 fences: None,
11314 signaled_values: None,
11315 }
11316 }
11317 }
11318 impl SharedBufferMemoryBeginAccessDescriptor {
11319 pub fn new() -> Self {
11320 Self::default()
11321 }
11322 pub(crate) fn to_ffi(
11323 &self,
11324 ) -> (ffi::WGPUSharedBufferMemoryBeginAccessDescriptor, ChainedStructStorage) {
11325 let mut storage = ChainedStructStorage::new();
11326 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11327 for ext in self.extensions.iter().rev() {
11328 next = ext.push_chain(&mut storage, next);
11329 }
11330 let mut raw: ffi::WGPUSharedBufferMemoryBeginAccessDescriptor = unsafe {
11331 std::mem::zeroed()
11332 };
11333 raw.nextInChain = next;
11334 raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
11335 raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
11336 if let Some(values) = &self.fences {
11337 let len_value = values.len();
11338 let raw_vec: Vec<ffi::WGPUSharedFence> = values
11339 .iter()
11340 .map(|v| v.as_raw())
11341 .collect();
11342 let ptr = storage.push_vec(raw_vec);
11343 raw.fences = ptr;
11344 raw.fenceCount = len_value;
11345 } else {
11346 raw.fences = std::ptr::null();
11347 raw.fenceCount = 0;
11348 }
11349 if let Some(values) = &self.signaled_values {
11350 let len_value = values.len();
11351 let raw_vec = values.to_vec();
11352 let ptr = storage.push_vec(raw_vec);
11353 raw.signaledValues = ptr;
11354 raw.fenceCount = len_value;
11355 } else {
11356 raw.signaledValues = std::ptr::null();
11357 raw.fenceCount = 0;
11358 }
11359 (raw, storage)
11360 }
11361 pub fn with_extension(
11362 mut self,
11363 extension: SharedBufferMemoryBeginAccessDescriptorExtension,
11364 ) -> Self {
11365 self.extensions.push(extension);
11366 self
11367 }
11368 pub(crate) fn from_ffi(
11369 value: ffi::WGPUSharedBufferMemoryBeginAccessDescriptor,
11370 ) -> Self {
11371 Self {
11372 extensions: Vec::new(),
11373 initialized: Some(value.initialized != 0),
11374 fences: if value.fences.is_null() {
11375 None
11376 } else {
11377 Some(
11378 unsafe {
11379 std::slice::from_raw_parts(
11380 value.fences,
11381 value.fenceCount as usize,
11382 )
11383 }
11384 .iter()
11385 .map(|raw| unsafe { SharedFence::from_raw(*raw) })
11386 .collect(),
11387 )
11388 },
11389 signaled_values: if value.signaledValues.is_null() {
11390 None
11391 } else {
11392 Some(
11393 unsafe {
11394 std::slice::from_raw_parts(
11395 value.signaledValues,
11396 value.fenceCount as usize,
11397 )
11398 }
11399 .to_vec(),
11400 )
11401 },
11402 }
11403 }
11404 }
11405 pub struct SharedBufferMemoryDescriptor {
11406 pub(crate) extensions: Vec<SharedBufferMemoryDescriptorExtension>,
11407 pub label: Option<String>,
11408 }
11409 impl Default for SharedBufferMemoryDescriptor {
11410 fn default() -> Self {
11411 Self {
11412 extensions: Vec::new(),
11413 label: None,
11414 }
11415 }
11416 }
11417 impl SharedBufferMemoryDescriptor {
11418 pub fn new() -> Self {
11419 Self::default()
11420 }
11421 pub(crate) fn to_ffi(
11422 &self,
11423 ) -> (ffi::WGPUSharedBufferMemoryDescriptor, ChainedStructStorage) {
11424 let mut storage = ChainedStructStorage::new();
11425 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11426 for ext in self.extensions.iter().rev() {
11427 next = ext.push_chain(&mut storage, next);
11428 }
11429 let mut raw: ffi::WGPUSharedBufferMemoryDescriptor = unsafe {
11430 std::mem::zeroed()
11431 };
11432 raw.nextInChain = next;
11433 if let Some(value) = &self.label {
11434 raw.label = ffi::WGPUStringView {
11435 data: value.as_ptr().cast(),
11436 length: value.len(),
11437 };
11438 } else {
11439 raw.label = ffi::WGPUStringView {
11440 data: std::ptr::null(),
11441 length: 0,
11442 };
11443 }
11444 (raw, storage)
11445 }
11446 pub fn with_extension(
11447 mut self,
11448 extension: SharedBufferMemoryDescriptorExtension,
11449 ) -> Self {
11450 self.extensions.push(extension);
11451 self
11452 }
11453 pub(crate) fn from_ffi(value: ffi::WGPUSharedBufferMemoryDescriptor) -> Self {
11454 Self {
11455 extensions: Vec::new(),
11456 label: if value.label.data.is_null() || value.label.length == 0 {
11457 None
11458 } else {
11459 Some(string_view_to_string(value.label))
11460 },
11461 }
11462 }
11463 }
11464 pub struct SharedBufferMemoryEndAccessState {
11465 pub(crate) extensions: Vec<SharedBufferMemoryEndAccessStateExtension>,
11466 pub initialized: Option<bool>,
11467 pub fences: Option<Vec<SharedFence>>,
11468 pub signaled_values: Option<Vec<u64>>,
11469 #[doc(hidden)]
11470 pub(crate) _free_members: Option<ffi::WGPUSharedBufferMemoryEndAccessState>,
11471 }
11472 impl Default for SharedBufferMemoryEndAccessState {
11473 fn default() -> Self {
11474 Self {
11475 extensions: Vec::new(),
11476 initialized: None,
11477 fences: None,
11478 signaled_values: None,
11479 _free_members: None,
11480 }
11481 }
11482 }
11483 impl SharedBufferMemoryEndAccessState {
11484 pub fn new() -> Self {
11485 Self::default()
11486 }
11487 pub(crate) fn to_ffi(
11488 &self,
11489 ) -> (ffi::WGPUSharedBufferMemoryEndAccessState, ChainedStructStorage) {
11490 let mut storage = ChainedStructStorage::new();
11491 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11492 for ext in self.extensions.iter().rev() {
11493 next = ext.push_chain(&mut storage, next);
11494 }
11495 let mut raw: ffi::WGPUSharedBufferMemoryEndAccessState = unsafe {
11496 std::mem::zeroed()
11497 };
11498 raw.nextInChain = next;
11499 raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
11500 raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
11501 if let Some(values) = &self.fences {
11502 let len_value = values.len();
11503 let raw_vec: Vec<ffi::WGPUSharedFence> = values
11504 .iter()
11505 .map(|v| v.as_raw())
11506 .collect();
11507 let ptr = storage.push_vec(raw_vec);
11508 raw.fences = ptr;
11509 raw.fenceCount = len_value;
11510 } else {
11511 raw.fences = std::ptr::null();
11512 raw.fenceCount = 0;
11513 }
11514 if let Some(values) = &self.signaled_values {
11515 let len_value = values.len();
11516 let raw_vec = values.to_vec();
11517 let ptr = storage.push_vec(raw_vec);
11518 raw.signaledValues = ptr;
11519 raw.fenceCount = len_value;
11520 } else {
11521 raw.signaledValues = std::ptr::null();
11522 raw.fenceCount = 0;
11523 }
11524 (raw, storage)
11525 }
11526 pub fn with_extension(
11527 mut self,
11528 extension: SharedBufferMemoryEndAccessStateExtension,
11529 ) -> Self {
11530 self.extensions.push(extension);
11531 self
11532 }
11533 pub(crate) fn from_ffi(
11534 value: ffi::WGPUSharedBufferMemoryEndAccessState,
11535 ) -> Self {
11536 Self {
11537 extensions: Vec::new(),
11538 initialized: Some(value.initialized != 0),
11539 fences: if value.fences.is_null() {
11540 None
11541 } else {
11542 Some(
11543 unsafe {
11544 std::slice::from_raw_parts(
11545 value.fences,
11546 value.fenceCount as usize,
11547 )
11548 }
11549 .iter()
11550 .map(|raw| unsafe { SharedFence::from_raw(*raw) })
11551 .collect(),
11552 )
11553 },
11554 signaled_values: if value.signaledValues.is_null() {
11555 None
11556 } else {
11557 Some(
11558 unsafe {
11559 std::slice::from_raw_parts(
11560 value.signaledValues,
11561 value.fenceCount as usize,
11562 )
11563 }
11564 .to_vec(),
11565 )
11566 },
11567 _free_members: Some(value),
11568 }
11569 }
11570 pub(crate) fn free_members(value: ffi::WGPUSharedBufferMemoryEndAccessState) {
11571 unsafe { ffi::wgpuSharedBufferMemoryEndAccessStateFreeMembers(value) };
11572 }
11573 }
11574 impl Drop for SharedBufferMemoryEndAccessState {
11575 fn drop(&mut self) {
11576 if let Some(value) = self._free_members.take() {
11577 unsafe { ffi::wgpuSharedBufferMemoryEndAccessStateFreeMembers(value) };
11578 }
11579 }
11580 }
11581 pub struct SharedBufferMemoryProperties {
11582 pub(crate) extensions: Vec<SharedBufferMemoryPropertiesExtension>,
11583 pub usage: Option<BufferUsage>,
11584 pub size: Option<u64>,
11585 }
11586 impl Default for SharedBufferMemoryProperties {
11587 fn default() -> Self {
11588 Self {
11589 extensions: Vec::new(),
11590 usage: None,
11591 size: None,
11592 }
11593 }
11594 }
11595 impl SharedBufferMemoryProperties {
11596 pub fn new() -> Self {
11597 Self::default()
11598 }
11599 pub(crate) fn to_ffi(
11600 &self,
11601 ) -> (ffi::WGPUSharedBufferMemoryProperties, ChainedStructStorage) {
11602 let mut storage = ChainedStructStorage::new();
11603 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11604 for ext in self.extensions.iter().rev() {
11605 next = ext.push_chain(&mut storage, next);
11606 }
11607 let mut raw: ffi::WGPUSharedBufferMemoryProperties = unsafe {
11608 std::mem::zeroed()
11609 };
11610 raw.nextInChain = next;
11611 if let Some(value) = self.usage {
11612 raw.usage = value.into();
11613 } else {
11614 raw.usage = 0 as ffi::WGPUBufferUsage;
11615 }
11616 if let Some(value) = self.size {
11617 raw.size = value;
11618 }
11619 (raw, storage)
11620 }
11621 pub fn with_extension(
11622 mut self,
11623 extension: SharedBufferMemoryPropertiesExtension,
11624 ) -> Self {
11625 self.extensions.push(extension);
11626 self
11627 }
11628 pub(crate) fn from_ffi(value: ffi::WGPUSharedBufferMemoryProperties) -> Self {
11629 Self {
11630 extensions: Vec::new(),
11631 usage: Some(value.usage.into()),
11632 size: Some(value.size),
11633 }
11634 }
11635 }
11636 pub struct SharedFenceDXGISharedHandleDescriptor {
11637 pub handle: Option<*mut std::ffi::c_void>,
11638 }
11639 impl Default for SharedFenceDXGISharedHandleDescriptor {
11640 fn default() -> Self {
11641 Self { handle: None }
11642 }
11643 }
11644 impl SharedFenceDXGISharedHandleDescriptor {
11645 pub fn new() -> Self {
11646 Self::default()
11647 }
11648 pub(crate) fn to_ffi(
11649 &self,
11650 ) -> (ffi::WGPUSharedFenceDXGISharedHandleDescriptor, ChainedStructStorage) {
11651 let mut storage = ChainedStructStorage::new();
11652 let mut raw: ffi::WGPUSharedFenceDXGISharedHandleDescriptor = unsafe {
11653 std::mem::zeroed()
11654 };
11655 if let Some(value) = self.handle {
11656 raw.handle = value;
11657 }
11658 (raw, storage)
11659 }
11660 pub(crate) fn from_ffi(
11661 value: ffi::WGPUSharedFenceDXGISharedHandleDescriptor,
11662 ) -> Self {
11663 Self { handle: Some(value.handle) }
11664 }
11665 }
11666 pub struct SharedFenceDXGISharedHandleExportInfo {
11667 pub handle: Option<*mut std::ffi::c_void>,
11668 }
11669 impl Default for SharedFenceDXGISharedHandleExportInfo {
11670 fn default() -> Self {
11671 Self { handle: None }
11672 }
11673 }
11674 impl SharedFenceDXGISharedHandleExportInfo {
11675 pub fn new() -> Self {
11676 Self::default()
11677 }
11678 pub(crate) fn to_ffi(
11679 &self,
11680 ) -> (ffi::WGPUSharedFenceDXGISharedHandleExportInfo, ChainedStructStorage) {
11681 let mut storage = ChainedStructStorage::new();
11682 let mut raw: ffi::WGPUSharedFenceDXGISharedHandleExportInfo = unsafe {
11683 std::mem::zeroed()
11684 };
11685 if let Some(value) = self.handle {
11686 raw.handle = value;
11687 }
11688 (raw, storage)
11689 }
11690 pub(crate) fn from_ffi(
11691 value: ffi::WGPUSharedFenceDXGISharedHandleExportInfo,
11692 ) -> Self {
11693 Self { handle: Some(value.handle) }
11694 }
11695 }
11696 pub struct SharedFenceEGLSyncDescriptor {
11697 pub sync: Option<*mut std::ffi::c_void>,
11698 }
11699 impl Default for SharedFenceEGLSyncDescriptor {
11700 fn default() -> Self {
11701 Self { sync: None }
11702 }
11703 }
11704 impl SharedFenceEGLSyncDescriptor {
11705 pub fn new() -> Self {
11706 Self::default()
11707 }
11708 pub(crate) fn to_ffi(
11709 &self,
11710 ) -> (ffi::WGPUSharedFenceEGLSyncDescriptor, ChainedStructStorage) {
11711 let mut storage = ChainedStructStorage::new();
11712 let mut raw: ffi::WGPUSharedFenceEGLSyncDescriptor = unsafe {
11713 std::mem::zeroed()
11714 };
11715 if let Some(value) = self.sync {
11716 raw.sync = value;
11717 }
11718 (raw, storage)
11719 }
11720 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceEGLSyncDescriptor) -> Self {
11721 Self { sync: Some(value.sync) }
11722 }
11723 }
11724 pub struct SharedFenceEGLSyncExportInfo {
11725 pub sync: Option<*mut std::ffi::c_void>,
11726 }
11727 impl Default for SharedFenceEGLSyncExportInfo {
11728 fn default() -> Self {
11729 Self { sync: None }
11730 }
11731 }
11732 impl SharedFenceEGLSyncExportInfo {
11733 pub fn new() -> Self {
11734 Self::default()
11735 }
11736 pub(crate) fn to_ffi(
11737 &self,
11738 ) -> (ffi::WGPUSharedFenceEGLSyncExportInfo, ChainedStructStorage) {
11739 let mut storage = ChainedStructStorage::new();
11740 let mut raw: ffi::WGPUSharedFenceEGLSyncExportInfo = unsafe {
11741 std::mem::zeroed()
11742 };
11743 if let Some(value) = self.sync {
11744 raw.sync = value;
11745 }
11746 (raw, storage)
11747 }
11748 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceEGLSyncExportInfo) -> Self {
11749 Self { sync: Some(value.sync) }
11750 }
11751 }
11752 pub struct SharedFenceMTLSharedEventDescriptor {
11753 pub shared_event: Option<*mut std::ffi::c_void>,
11754 }
11755 impl Default for SharedFenceMTLSharedEventDescriptor {
11756 fn default() -> Self {
11757 Self { shared_event: None }
11758 }
11759 }
11760 impl SharedFenceMTLSharedEventDescriptor {
11761 pub fn new() -> Self {
11762 Self::default()
11763 }
11764 pub(crate) fn to_ffi(
11765 &self,
11766 ) -> (ffi::WGPUSharedFenceMTLSharedEventDescriptor, ChainedStructStorage) {
11767 let mut storage = ChainedStructStorage::new();
11768 let mut raw: ffi::WGPUSharedFenceMTLSharedEventDescriptor = unsafe {
11769 std::mem::zeroed()
11770 };
11771 if let Some(value) = self.shared_event {
11772 raw.sharedEvent = value;
11773 }
11774 (raw, storage)
11775 }
11776 pub(crate) fn from_ffi(
11777 value: ffi::WGPUSharedFenceMTLSharedEventDescriptor,
11778 ) -> Self {
11779 Self {
11780 shared_event: Some(value.sharedEvent),
11781 }
11782 }
11783 }
11784 pub struct SharedFenceMTLSharedEventExportInfo {
11785 pub shared_event: Option<*mut std::ffi::c_void>,
11786 }
11787 impl Default for SharedFenceMTLSharedEventExportInfo {
11788 fn default() -> Self {
11789 Self { shared_event: None }
11790 }
11791 }
11792 impl SharedFenceMTLSharedEventExportInfo {
11793 pub fn new() -> Self {
11794 Self::default()
11795 }
11796 pub(crate) fn to_ffi(
11797 &self,
11798 ) -> (ffi::WGPUSharedFenceMTLSharedEventExportInfo, ChainedStructStorage) {
11799 let mut storage = ChainedStructStorage::new();
11800 let mut raw: ffi::WGPUSharedFenceMTLSharedEventExportInfo = unsafe {
11801 std::mem::zeroed()
11802 };
11803 if let Some(value) = self.shared_event {
11804 raw.sharedEvent = value;
11805 }
11806 (raw, storage)
11807 }
11808 pub(crate) fn from_ffi(
11809 value: ffi::WGPUSharedFenceMTLSharedEventExportInfo,
11810 ) -> Self {
11811 Self {
11812 shared_event: Some(value.sharedEvent),
11813 }
11814 }
11815 }
11816 pub struct SharedFenceDescriptor {
11817 pub(crate) extensions: Vec<SharedFenceDescriptorExtension>,
11818 pub label: Option<String>,
11819 }
11820 impl Default for SharedFenceDescriptor {
11821 fn default() -> Self {
11822 Self {
11823 extensions: Vec::new(),
11824 label: None,
11825 }
11826 }
11827 }
11828 impl SharedFenceDescriptor {
11829 pub fn new() -> Self {
11830 Self::default()
11831 }
11832 pub(crate) fn to_ffi(
11833 &self,
11834 ) -> (ffi::WGPUSharedFenceDescriptor, ChainedStructStorage) {
11835 let mut storage = ChainedStructStorage::new();
11836 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11837 for ext in self.extensions.iter().rev() {
11838 next = ext.push_chain(&mut storage, next);
11839 }
11840 let mut raw: ffi::WGPUSharedFenceDescriptor = unsafe { std::mem::zeroed() };
11841 raw.nextInChain = next;
11842 if let Some(value) = &self.label {
11843 raw.label = ffi::WGPUStringView {
11844 data: value.as_ptr().cast(),
11845 length: value.len(),
11846 };
11847 } else {
11848 raw.label = ffi::WGPUStringView {
11849 data: std::ptr::null(),
11850 length: 0,
11851 };
11852 }
11853 (raw, storage)
11854 }
11855 pub fn with_extension(
11856 mut self,
11857 extension: SharedFenceDescriptorExtension,
11858 ) -> Self {
11859 self.extensions.push(extension);
11860 self
11861 }
11862 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceDescriptor) -> Self {
11863 Self {
11864 extensions: Vec::new(),
11865 label: if value.label.data.is_null() || value.label.length == 0 {
11866 None
11867 } else {
11868 Some(string_view_to_string(value.label))
11869 },
11870 }
11871 }
11872 }
11873 pub struct SharedFenceExportInfo {
11874 pub(crate) extensions: Vec<SharedFenceExportInfoExtension>,
11875 pub r#type: Option<SharedFenceType>,
11876 }
11877 impl Default for SharedFenceExportInfo {
11878 fn default() -> Self {
11879 Self {
11880 extensions: Vec::new(),
11881 r#type: None,
11882 }
11883 }
11884 }
11885 impl SharedFenceExportInfo {
11886 pub fn new() -> Self {
11887 Self::default()
11888 }
11889 pub(crate) fn to_ffi(
11890 &self,
11891 ) -> (ffi::WGPUSharedFenceExportInfo, ChainedStructStorage) {
11892 let mut storage = ChainedStructStorage::new();
11893 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11894 for ext in self.extensions.iter().rev() {
11895 next = ext.push_chain(&mut storage, next);
11896 }
11897 let mut raw: ffi::WGPUSharedFenceExportInfo = unsafe { std::mem::zeroed() };
11898 raw.nextInChain = next;
11899 if let Some(value) = self.r#type {
11900 raw.type_ = value.into();
11901 } else {
11902 raw.type_ = 0 as ffi::WGPUSharedFenceType;
11903 }
11904 (raw, storage)
11905 }
11906 pub fn with_extension(
11907 mut self,
11908 extension: SharedFenceExportInfoExtension,
11909 ) -> Self {
11910 self.extensions.push(extension);
11911 self
11912 }
11913 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceExportInfo) -> Self {
11914 Self {
11915 extensions: Vec::new(),
11916 r#type: Some(value.type_.into()),
11917 }
11918 }
11919 }
11920 pub struct SharedFenceSyncFDDescriptor {
11921 pub handle: Option<i32>,
11922 }
11923 impl Default for SharedFenceSyncFDDescriptor {
11924 fn default() -> Self {
11925 Self { handle: None }
11926 }
11927 }
11928 impl SharedFenceSyncFDDescriptor {
11929 pub fn new() -> Self {
11930 Self::default()
11931 }
11932 pub(crate) fn to_ffi(
11933 &self,
11934 ) -> (ffi::WGPUSharedFenceSyncFDDescriptor, ChainedStructStorage) {
11935 let mut storage = ChainedStructStorage::new();
11936 let mut raw: ffi::WGPUSharedFenceSyncFDDescriptor = unsafe {
11937 std::mem::zeroed()
11938 };
11939 if let Some(value) = self.handle {
11940 raw.handle = value;
11941 }
11942 (raw, storage)
11943 }
11944 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceSyncFDDescriptor) -> Self {
11945 Self { handle: Some(value.handle) }
11946 }
11947 }
11948 pub struct SharedFenceSyncFDExportInfo {
11949 pub handle: Option<i32>,
11950 }
11951 impl Default for SharedFenceSyncFDExportInfo {
11952 fn default() -> Self {
11953 Self { handle: None }
11954 }
11955 }
11956 impl SharedFenceSyncFDExportInfo {
11957 pub fn new() -> Self {
11958 Self::default()
11959 }
11960 pub(crate) fn to_ffi(
11961 &self,
11962 ) -> (ffi::WGPUSharedFenceSyncFDExportInfo, ChainedStructStorage) {
11963 let mut storage = ChainedStructStorage::new();
11964 let mut raw: ffi::WGPUSharedFenceSyncFDExportInfo = unsafe {
11965 std::mem::zeroed()
11966 };
11967 if let Some(value) = self.handle {
11968 raw.handle = value;
11969 }
11970 (raw, storage)
11971 }
11972 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceSyncFDExportInfo) -> Self {
11973 Self { handle: Some(value.handle) }
11974 }
11975 }
11976 pub struct SharedFenceVkSemaphoreOpaqueFDDescriptor {
11977 pub handle: Option<i32>,
11978 }
11979 impl Default for SharedFenceVkSemaphoreOpaqueFDDescriptor {
11980 fn default() -> Self {
11981 Self { handle: None }
11982 }
11983 }
11984 impl SharedFenceVkSemaphoreOpaqueFDDescriptor {
11985 pub fn new() -> Self {
11986 Self::default()
11987 }
11988 pub(crate) fn to_ffi(
11989 &self,
11990 ) -> (ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor, ChainedStructStorage) {
11991 let mut storage = ChainedStructStorage::new();
11992 let mut raw: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor = unsafe {
11993 std::mem::zeroed()
11994 };
11995 if let Some(value) = self.handle {
11996 raw.handle = value;
11997 }
11998 (raw, storage)
11999 }
12000 pub(crate) fn from_ffi(
12001 value: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor,
12002 ) -> Self {
12003 Self { handle: Some(value.handle) }
12004 }
12005 }
12006 pub struct SharedFenceVkSemaphoreOpaqueFDExportInfo {
12007 pub handle: Option<i32>,
12008 }
12009 impl Default for SharedFenceVkSemaphoreOpaqueFDExportInfo {
12010 fn default() -> Self {
12011 Self { handle: None }
12012 }
12013 }
12014 impl SharedFenceVkSemaphoreOpaqueFDExportInfo {
12015 pub fn new() -> Self {
12016 Self::default()
12017 }
12018 pub(crate) fn to_ffi(
12019 &self,
12020 ) -> (ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo, ChainedStructStorage) {
12021 let mut storage = ChainedStructStorage::new();
12022 let mut raw: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo = unsafe {
12023 std::mem::zeroed()
12024 };
12025 if let Some(value) = self.handle {
12026 raw.handle = value;
12027 }
12028 (raw, storage)
12029 }
12030 pub(crate) fn from_ffi(
12031 value: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo,
12032 ) -> Self {
12033 Self { handle: Some(value.handle) }
12034 }
12035 }
12036 pub struct SharedFenceVkSemaphoreZirconHandleDescriptor {
12037 pub handle: Option<u32>,
12038 }
12039 impl Default for SharedFenceVkSemaphoreZirconHandleDescriptor {
12040 fn default() -> Self {
12041 Self { handle: None }
12042 }
12043 }
12044 impl SharedFenceVkSemaphoreZirconHandleDescriptor {
12045 pub fn new() -> Self {
12046 Self::default()
12047 }
12048 pub(crate) fn to_ffi(
12049 &self,
12050 ) -> (
12051 ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor,
12052 ChainedStructStorage,
12053 ) {
12054 let mut storage = ChainedStructStorage::new();
12055 let mut raw: ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor = unsafe {
12056 std::mem::zeroed()
12057 };
12058 if let Some(value) = self.handle {
12059 raw.handle = value;
12060 }
12061 (raw, storage)
12062 }
12063 pub(crate) fn from_ffi(
12064 value: ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor,
12065 ) -> Self {
12066 Self { handle: Some(value.handle) }
12067 }
12068 }
12069 pub struct SharedFenceVkSemaphoreZirconHandleExportInfo {
12070 pub handle: Option<u32>,
12071 }
12072 impl Default for SharedFenceVkSemaphoreZirconHandleExportInfo {
12073 fn default() -> Self {
12074 Self { handle: None }
12075 }
12076 }
12077 impl SharedFenceVkSemaphoreZirconHandleExportInfo {
12078 pub fn new() -> Self {
12079 Self::default()
12080 }
12081 pub(crate) fn to_ffi(
12082 &self,
12083 ) -> (
12084 ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo,
12085 ChainedStructStorage,
12086 ) {
12087 let mut storage = ChainedStructStorage::new();
12088 let mut raw: ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo = unsafe {
12089 std::mem::zeroed()
12090 };
12091 if let Some(value) = self.handle {
12092 raw.handle = value;
12093 }
12094 (raw, storage)
12095 }
12096 pub(crate) fn from_ffi(
12097 value: ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo,
12098 ) -> Self {
12099 Self { handle: Some(value.handle) }
12100 }
12101 }
12102 pub struct SharedTextureMemoryD3DSwapchainBeginState {
12103 pub is_swapchain: Option<bool>,
12104 }
12105 impl Default for SharedTextureMemoryD3DSwapchainBeginState {
12106 fn default() -> Self {
12107 Self { is_swapchain: None }
12108 }
12109 }
12110 impl SharedTextureMemoryD3DSwapchainBeginState {
12111 pub fn new() -> Self {
12112 Self::default()
12113 }
12114 pub(crate) fn to_ffi(
12115 &self,
12116 ) -> (ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState, ChainedStructStorage) {
12117 let mut storage = ChainedStructStorage::new();
12118 let mut raw: ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState = unsafe {
12119 std::mem::zeroed()
12120 };
12121 raw.isSwapchain = if self.is_swapchain.unwrap_or(false) { 1 } else { 0 };
12122 (raw, storage)
12123 }
12124 pub(crate) fn from_ffi(
12125 value: ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState,
12126 ) -> Self {
12127 Self {
12128 is_swapchain: Some(value.isSwapchain != 0),
12129 }
12130 }
12131 }
12132 pub struct SharedTextureMemoryD3D11BeginState {
12133 pub requires_end_access_fence: Option<bool>,
12134 }
12135 impl Default for SharedTextureMemoryD3D11BeginState {
12136 fn default() -> Self {
12137 Self {
12138 requires_end_access_fence: None,
12139 }
12140 }
12141 }
12142 impl SharedTextureMemoryD3D11BeginState {
12143 pub fn new() -> Self {
12144 Self::default()
12145 }
12146 pub(crate) fn to_ffi(
12147 &self,
12148 ) -> (ffi::WGPUSharedTextureMemoryD3D11BeginState, ChainedStructStorage) {
12149 let mut storage = ChainedStructStorage::new();
12150 let mut raw: ffi::WGPUSharedTextureMemoryD3D11BeginState = unsafe {
12151 std::mem::zeroed()
12152 };
12153 raw.requiresEndAccessFence = if self
12154 .requires_end_access_fence
12155 .unwrap_or(false)
12156 {
12157 1
12158 } else {
12159 0
12160 };
12161 (raw, storage)
12162 }
12163 pub(crate) fn from_ffi(
12164 value: ffi::WGPUSharedTextureMemoryD3D11BeginState,
12165 ) -> Self {
12166 Self {
12167 requires_end_access_fence: Some(value.requiresEndAccessFence != 0),
12168 }
12169 }
12170 }
12171 pub struct SharedTextureMemoryDXGISharedHandleDescriptor {
12172 pub handle: Option<*mut std::ffi::c_void>,
12173 pub use_keyed_mutex: Option<bool>,
12174 }
12175 impl Default for SharedTextureMemoryDXGISharedHandleDescriptor {
12176 fn default() -> Self {
12177 Self {
12178 handle: None,
12179 use_keyed_mutex: None,
12180 }
12181 }
12182 }
12183 impl SharedTextureMemoryDXGISharedHandleDescriptor {
12184 pub fn new() -> Self {
12185 Self::default()
12186 }
12187 pub(crate) fn to_ffi(
12188 &self,
12189 ) -> (
12190 ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor,
12191 ChainedStructStorage,
12192 ) {
12193 let mut storage = ChainedStructStorage::new();
12194 let mut raw: ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor = unsafe {
12195 std::mem::zeroed()
12196 };
12197 if let Some(value) = self.handle {
12198 raw.handle = value;
12199 }
12200 raw.useKeyedMutex = if self.use_keyed_mutex.unwrap_or(false) {
12201 1
12202 } else {
12203 0
12204 };
12205 (raw, storage)
12206 }
12207 pub(crate) fn from_ffi(
12208 value: ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor,
12209 ) -> Self {
12210 Self {
12211 handle: Some(value.handle),
12212 use_keyed_mutex: Some(value.useKeyedMutex != 0),
12213 }
12214 }
12215 }
12216 pub struct SharedTextureMemoryEGLImageDescriptor {
12217 pub image: Option<*mut std::ffi::c_void>,
12218 }
12219 impl Default for SharedTextureMemoryEGLImageDescriptor {
12220 fn default() -> Self {
12221 Self { image: None }
12222 }
12223 }
12224 impl SharedTextureMemoryEGLImageDescriptor {
12225 pub fn new() -> Self {
12226 Self::default()
12227 }
12228 pub(crate) fn to_ffi(
12229 &self,
12230 ) -> (ffi::WGPUSharedTextureMemoryEGLImageDescriptor, ChainedStructStorage) {
12231 let mut storage = ChainedStructStorage::new();
12232 let mut raw: ffi::WGPUSharedTextureMemoryEGLImageDescriptor = unsafe {
12233 std::mem::zeroed()
12234 };
12235 if let Some(value) = self.image {
12236 raw.image = value;
12237 }
12238 (raw, storage)
12239 }
12240 pub(crate) fn from_ffi(
12241 value: ffi::WGPUSharedTextureMemoryEGLImageDescriptor,
12242 ) -> Self {
12243 Self { image: Some(value.image) }
12244 }
12245 }
12246 pub struct SharedTextureMemoryIOSurfaceDescriptor {
12247 pub io_surface: Option<*mut std::ffi::c_void>,
12248 pub allow_storage_binding: Option<bool>,
12249 }
12250 impl Default for SharedTextureMemoryIOSurfaceDescriptor {
12251 fn default() -> Self {
12252 Self {
12253 io_surface: None,
12254 allow_storage_binding: None,
12255 }
12256 }
12257 }
12258 impl SharedTextureMemoryIOSurfaceDescriptor {
12259 pub fn new() -> Self {
12260 Self::default()
12261 }
12262 pub(crate) fn to_ffi(
12263 &self,
12264 ) -> (ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor, ChainedStructStorage) {
12265 let mut storage = ChainedStructStorage::new();
12266 let mut raw: ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor = unsafe {
12267 std::mem::zeroed()
12268 };
12269 if let Some(value) = self.io_surface {
12270 raw.ioSurface = value;
12271 }
12272 raw.allowStorageBinding = if self.allow_storage_binding.unwrap_or(false) {
12273 1
12274 } else {
12275 0
12276 };
12277 (raw, storage)
12278 }
12279 pub(crate) fn from_ffi(
12280 value: ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor,
12281 ) -> Self {
12282 Self {
12283 io_surface: Some(value.ioSurface),
12284 allow_storage_binding: Some(value.allowStorageBinding != 0),
12285 }
12286 }
12287 }
12288 pub struct SharedTextureMemoryAHardwareBufferDescriptor {
12289 pub handle: Option<*mut std::ffi::c_void>,
12290 }
12291 impl Default for SharedTextureMemoryAHardwareBufferDescriptor {
12292 fn default() -> Self {
12293 Self { handle: None }
12294 }
12295 }
12296 impl SharedTextureMemoryAHardwareBufferDescriptor {
12297 pub fn new() -> Self {
12298 Self::default()
12299 }
12300 pub(crate) fn to_ffi(
12301 &self,
12302 ) -> (
12303 ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor,
12304 ChainedStructStorage,
12305 ) {
12306 let mut storage = ChainedStructStorage::new();
12307 let mut raw: ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor = unsafe {
12308 std::mem::zeroed()
12309 };
12310 if let Some(value) = self.handle {
12311 raw.handle = value;
12312 }
12313 (raw, storage)
12314 }
12315 pub(crate) fn from_ffi(
12316 value: ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor,
12317 ) -> Self {
12318 Self { handle: Some(value.handle) }
12319 }
12320 }
12321 pub struct SharedTextureMemoryAHardwareBufferProperties {
12322 pub y_cb_cr_info: Option<YCbCrVkDescriptor>,
12323 }
12324 impl Default for SharedTextureMemoryAHardwareBufferProperties {
12325 fn default() -> Self {
12326 Self { y_cb_cr_info: None }
12327 }
12328 }
12329 impl SharedTextureMemoryAHardwareBufferProperties {
12330 pub fn new() -> Self {
12331 Self::default()
12332 }
12333 pub(crate) fn to_ffi(
12334 &self,
12335 ) -> (
12336 ffi::WGPUSharedTextureMemoryAHardwareBufferProperties,
12337 ChainedStructStorage,
12338 ) {
12339 let mut storage = ChainedStructStorage::new();
12340 let mut raw: ffi::WGPUSharedTextureMemoryAHardwareBufferProperties = unsafe {
12341 std::mem::zeroed()
12342 };
12343 if let Some(value) = &self.y_cb_cr_info {
12344 let (raw_value, storage_value) = value.to_ffi();
12345 raw.yCbCrInfo = raw_value;
12346 storage.push_storage(storage_value);
12347 }
12348 (raw, storage)
12349 }
12350 pub(crate) fn from_ffi(
12351 value: ffi::WGPUSharedTextureMemoryAHardwareBufferProperties,
12352 ) -> Self {
12353 Self {
12354 y_cb_cr_info: Some(YCbCrVkDescriptor::from_ffi(value.yCbCrInfo)),
12355 }
12356 }
12357 }
12358 pub struct SharedTextureMemoryBeginAccessDescriptor {
12359 pub(crate) extensions: Vec<SharedTextureMemoryBeginAccessDescriptorExtension>,
12360 pub concurrent_read: Option<bool>,
12361 pub initialized: Option<bool>,
12362 pub fences: Option<Vec<SharedFence>>,
12363 pub signaled_values: Option<Vec<u64>>,
12364 }
12365 impl Default for SharedTextureMemoryBeginAccessDescriptor {
12366 fn default() -> Self {
12367 Self {
12368 extensions: Vec::new(),
12369 concurrent_read: None,
12370 initialized: None,
12371 fences: None,
12372 signaled_values: None,
12373 }
12374 }
12375 }
12376 impl SharedTextureMemoryBeginAccessDescriptor {
12377 pub fn new() -> Self {
12378 Self::default()
12379 }
12380 pub(crate) fn to_ffi(
12381 &self,
12382 ) -> (ffi::WGPUSharedTextureMemoryBeginAccessDescriptor, ChainedStructStorage) {
12383 let mut storage = ChainedStructStorage::new();
12384 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12385 for ext in self.extensions.iter().rev() {
12386 next = ext.push_chain(&mut storage, next);
12387 }
12388 let mut raw: ffi::WGPUSharedTextureMemoryBeginAccessDescriptor = unsafe {
12389 std::mem::zeroed()
12390 };
12391 raw.nextInChain = next;
12392 raw.concurrentRead = if self.concurrent_read.unwrap_or(false) {
12393 1
12394 } else {
12395 0
12396 };
12397 raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
12398 raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
12399 if let Some(values) = &self.fences {
12400 let len_value = values.len();
12401 let raw_vec: Vec<ffi::WGPUSharedFence> = values
12402 .iter()
12403 .map(|v| v.as_raw())
12404 .collect();
12405 let ptr = storage.push_vec(raw_vec);
12406 raw.fences = ptr;
12407 raw.fenceCount = len_value;
12408 } else {
12409 raw.fences = std::ptr::null();
12410 raw.fenceCount = 0;
12411 }
12412 if let Some(values) = &self.signaled_values {
12413 let len_value = values.len();
12414 let raw_vec = values.to_vec();
12415 let ptr = storage.push_vec(raw_vec);
12416 raw.signaledValues = ptr;
12417 raw.fenceCount = len_value;
12418 } else {
12419 raw.signaledValues = std::ptr::null();
12420 raw.fenceCount = 0;
12421 }
12422 (raw, storage)
12423 }
12424 pub fn with_extension(
12425 mut self,
12426 extension: SharedTextureMemoryBeginAccessDescriptorExtension,
12427 ) -> Self {
12428 self.extensions.push(extension);
12429 self
12430 }
12431 pub(crate) fn from_ffi(
12432 value: ffi::WGPUSharedTextureMemoryBeginAccessDescriptor,
12433 ) -> Self {
12434 Self {
12435 extensions: Vec::new(),
12436 concurrent_read: Some(value.concurrentRead != 0),
12437 initialized: Some(value.initialized != 0),
12438 fences: if value.fences.is_null() {
12439 None
12440 } else {
12441 Some(
12442 unsafe {
12443 std::slice::from_raw_parts(
12444 value.fences,
12445 value.fenceCount as usize,
12446 )
12447 }
12448 .iter()
12449 .map(|raw| unsafe { SharedFence::from_raw(*raw) })
12450 .collect(),
12451 )
12452 },
12453 signaled_values: if value.signaledValues.is_null() {
12454 None
12455 } else {
12456 Some(
12457 unsafe {
12458 std::slice::from_raw_parts(
12459 value.signaledValues,
12460 value.fenceCount as usize,
12461 )
12462 }
12463 .to_vec(),
12464 )
12465 },
12466 }
12467 }
12468 }
12469 pub struct SharedTextureMemoryDescriptor {
12470 pub(crate) extensions: Vec<SharedTextureMemoryDescriptorExtension>,
12471 pub label: Option<String>,
12472 }
12473 impl Default for SharedTextureMemoryDescriptor {
12474 fn default() -> Self {
12475 Self {
12476 extensions: Vec::new(),
12477 label: None,
12478 }
12479 }
12480 }
12481 impl SharedTextureMemoryDescriptor {
12482 pub fn new() -> Self {
12483 Self::default()
12484 }
12485 pub(crate) fn to_ffi(
12486 &self,
12487 ) -> (ffi::WGPUSharedTextureMemoryDescriptor, ChainedStructStorage) {
12488 let mut storage = ChainedStructStorage::new();
12489 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12490 for ext in self.extensions.iter().rev() {
12491 next = ext.push_chain(&mut storage, next);
12492 }
12493 let mut raw: ffi::WGPUSharedTextureMemoryDescriptor = unsafe {
12494 std::mem::zeroed()
12495 };
12496 raw.nextInChain = next;
12497 if let Some(value) = &self.label {
12498 raw.label = ffi::WGPUStringView {
12499 data: value.as_ptr().cast(),
12500 length: value.len(),
12501 };
12502 } else {
12503 raw.label = ffi::WGPUStringView {
12504 data: std::ptr::null(),
12505 length: 0,
12506 };
12507 }
12508 (raw, storage)
12509 }
12510 pub fn with_extension(
12511 mut self,
12512 extension: SharedTextureMemoryDescriptorExtension,
12513 ) -> Self {
12514 self.extensions.push(extension);
12515 self
12516 }
12517 pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryDescriptor) -> Self {
12518 Self {
12519 extensions: Vec::new(),
12520 label: if value.label.data.is_null() || value.label.length == 0 {
12521 None
12522 } else {
12523 Some(string_view_to_string(value.label))
12524 },
12525 }
12526 }
12527 }
12528 pub struct SharedTextureMemoryDmaBufDescriptor {
12529 pub size: Option<Extent3D>,
12530 pub drm_format: Option<u32>,
12531 pub drm_modifier: Option<u64>,
12532 pub planes: Option<Vec<SharedTextureMemoryDmaBufPlane>>,
12533 }
12534 impl Default for SharedTextureMemoryDmaBufDescriptor {
12535 fn default() -> Self {
12536 Self {
12537 size: None,
12538 drm_format: None,
12539 drm_modifier: None,
12540 planes: None,
12541 }
12542 }
12543 }
12544 impl SharedTextureMemoryDmaBufDescriptor {
12545 pub fn new() -> Self {
12546 Self::default()
12547 }
12548 pub(crate) fn to_ffi(
12549 &self,
12550 ) -> (ffi::WGPUSharedTextureMemoryDmaBufDescriptor, ChainedStructStorage) {
12551 let mut storage = ChainedStructStorage::new();
12552 let mut raw: ffi::WGPUSharedTextureMemoryDmaBufDescriptor = unsafe {
12553 std::mem::zeroed()
12554 };
12555 if let Some(value) = &self.size {
12556 let (raw_value, storage_value) = value.to_ffi();
12557 raw.size = raw_value;
12558 storage.push_storage(storage_value);
12559 }
12560 if let Some(value) = self.drm_format {
12561 raw.drmFormat = value;
12562 }
12563 if let Some(value) = self.drm_modifier {
12564 raw.drmModifier = value;
12565 }
12566 raw.planeCount = self.planes.as_ref().map(|v| v.len()).unwrap_or(0);
12567 if let Some(values) = &self.planes {
12568 let len_value = values.len();
12569 let mut raw_vec: Vec<ffi::WGPUSharedTextureMemoryDmaBufPlane> = Vec::with_capacity(
12570 values.len(),
12571 );
12572 for item in values.iter() {
12573 let (raw_item, storage_item) = item.to_ffi();
12574 raw_vec.push(raw_item);
12575 storage.push_storage(storage_item);
12576 }
12577 let ptr = storage.push_vec(raw_vec);
12578 raw.planes = ptr;
12579 raw.planeCount = len_value;
12580 } else {
12581 raw.planes = std::ptr::null();
12582 raw.planeCount = 0;
12583 }
12584 (raw, storage)
12585 }
12586 pub(crate) fn from_ffi(
12587 value: ffi::WGPUSharedTextureMemoryDmaBufDescriptor,
12588 ) -> Self {
12589 Self {
12590 size: Some(Extent3D::from_ffi(value.size)),
12591 drm_format: Some(value.drmFormat),
12592 drm_modifier: Some(value.drmModifier),
12593 planes: if value.planes.is_null() {
12594 None
12595 } else {
12596 Some(
12597 unsafe {
12598 std::slice::from_raw_parts(
12599 value.planes,
12600 value.planeCount as usize,
12601 )
12602 }
12603 .iter()
12604 .map(|raw| SharedTextureMemoryDmaBufPlane::from_ffi(*raw))
12605 .collect(),
12606 )
12607 },
12608 }
12609 }
12610 }
12611 pub struct SharedTextureMemoryDmaBufPlane {
12612 pub fd: Option<i32>,
12613 pub offset: Option<u64>,
12614 pub stride: Option<u32>,
12615 }
12616 impl Default for SharedTextureMemoryDmaBufPlane {
12617 fn default() -> Self {
12618 Self {
12619 fd: None,
12620 offset: None,
12621 stride: None,
12622 }
12623 }
12624 }
12625 impl SharedTextureMemoryDmaBufPlane {
12626 pub fn new() -> Self {
12627 Self::default()
12628 }
12629 pub(crate) fn to_ffi(
12630 &self,
12631 ) -> (ffi::WGPUSharedTextureMemoryDmaBufPlane, ChainedStructStorage) {
12632 let mut storage = ChainedStructStorage::new();
12633 let mut raw: ffi::WGPUSharedTextureMemoryDmaBufPlane = unsafe {
12634 std::mem::zeroed()
12635 };
12636 if let Some(value) = self.fd {
12637 raw.fd = value;
12638 }
12639 if let Some(value) = self.offset {
12640 raw.offset = value;
12641 }
12642 if let Some(value) = self.stride {
12643 raw.stride = value;
12644 }
12645 (raw, storage)
12646 }
12647 pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryDmaBufPlane) -> Self {
12648 Self {
12649 fd: Some(value.fd),
12650 offset: Some(value.offset),
12651 stride: Some(value.stride),
12652 }
12653 }
12654 }
12655 pub struct SharedTextureMemoryEndAccessState {
12656 pub(crate) extensions: Vec<SharedTextureMemoryEndAccessStateExtension>,
12657 pub initialized: Option<bool>,
12658 pub fences: Option<Vec<SharedFence>>,
12659 pub signaled_values: Option<Vec<u64>>,
12660 #[doc(hidden)]
12661 pub(crate) _free_members: Option<ffi::WGPUSharedTextureMemoryEndAccessState>,
12662 }
12663 impl Default for SharedTextureMemoryEndAccessState {
12664 fn default() -> Self {
12665 Self {
12666 extensions: Vec::new(),
12667 initialized: None,
12668 fences: None,
12669 signaled_values: None,
12670 _free_members: None,
12671 }
12672 }
12673 }
12674 impl SharedTextureMemoryEndAccessState {
12675 pub fn new() -> Self {
12676 Self::default()
12677 }
12678 pub(crate) fn to_ffi(
12679 &self,
12680 ) -> (ffi::WGPUSharedTextureMemoryEndAccessState, ChainedStructStorage) {
12681 let mut storage = ChainedStructStorage::new();
12682 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12683 for ext in self.extensions.iter().rev() {
12684 next = ext.push_chain(&mut storage, next);
12685 }
12686 let mut raw: ffi::WGPUSharedTextureMemoryEndAccessState = unsafe {
12687 std::mem::zeroed()
12688 };
12689 raw.nextInChain = next;
12690 raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
12691 raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
12692 if let Some(values) = &self.fences {
12693 let len_value = values.len();
12694 let raw_vec: Vec<ffi::WGPUSharedFence> = values
12695 .iter()
12696 .map(|v| v.as_raw())
12697 .collect();
12698 let ptr = storage.push_vec(raw_vec);
12699 raw.fences = ptr;
12700 raw.fenceCount = len_value;
12701 } else {
12702 raw.fences = std::ptr::null();
12703 raw.fenceCount = 0;
12704 }
12705 if let Some(values) = &self.signaled_values {
12706 let len_value = values.len();
12707 let raw_vec = values.to_vec();
12708 let ptr = storage.push_vec(raw_vec);
12709 raw.signaledValues = ptr;
12710 raw.fenceCount = len_value;
12711 } else {
12712 raw.signaledValues = std::ptr::null();
12713 raw.fenceCount = 0;
12714 }
12715 (raw, storage)
12716 }
12717 pub fn with_extension(
12718 mut self,
12719 extension: SharedTextureMemoryEndAccessStateExtension,
12720 ) -> Self {
12721 self.extensions.push(extension);
12722 self
12723 }
12724 pub(crate) fn from_ffi(
12725 value: ffi::WGPUSharedTextureMemoryEndAccessState,
12726 ) -> Self {
12727 Self {
12728 extensions: Vec::new(),
12729 initialized: Some(value.initialized != 0),
12730 fences: if value.fences.is_null() {
12731 None
12732 } else {
12733 Some(
12734 unsafe {
12735 std::slice::from_raw_parts(
12736 value.fences,
12737 value.fenceCount as usize,
12738 )
12739 }
12740 .iter()
12741 .map(|raw| unsafe { SharedFence::from_raw(*raw) })
12742 .collect(),
12743 )
12744 },
12745 signaled_values: if value.signaledValues.is_null() {
12746 None
12747 } else {
12748 Some(
12749 unsafe {
12750 std::slice::from_raw_parts(
12751 value.signaledValues,
12752 value.fenceCount as usize,
12753 )
12754 }
12755 .to_vec(),
12756 )
12757 },
12758 _free_members: Some(value),
12759 }
12760 }
12761 pub(crate) fn free_members(value: ffi::WGPUSharedTextureMemoryEndAccessState) {
12762 unsafe { ffi::wgpuSharedTextureMemoryEndAccessStateFreeMembers(value) };
12763 }
12764 }
12765 impl Drop for SharedTextureMemoryEndAccessState {
12766 fn drop(&mut self) {
12767 if let Some(value) = self._free_members.take() {
12768 unsafe { ffi::wgpuSharedTextureMemoryEndAccessStateFreeMembers(value) };
12769 }
12770 }
12771 }
12772 pub struct SharedTextureMemoryMetalEndAccessState {
12773 pub commands_scheduled_future: Option<Future>,
12774 }
12775 impl Default for SharedTextureMemoryMetalEndAccessState {
12776 fn default() -> Self {
12777 Self {
12778 commands_scheduled_future: None,
12779 }
12780 }
12781 }
12782 impl SharedTextureMemoryMetalEndAccessState {
12783 pub fn new() -> Self {
12784 Self::default()
12785 }
12786 pub(crate) fn to_ffi(
12787 &self,
12788 ) -> (ffi::WGPUSharedTextureMemoryMetalEndAccessState, ChainedStructStorage) {
12789 let mut storage = ChainedStructStorage::new();
12790 let mut raw: ffi::WGPUSharedTextureMemoryMetalEndAccessState = unsafe {
12791 std::mem::zeroed()
12792 };
12793 if let Some(value) = &self.commands_scheduled_future {
12794 let (raw_value, storage_value) = value.to_ffi();
12795 raw.commandsScheduledFuture = raw_value;
12796 storage.push_storage(storage_value);
12797 }
12798 (raw, storage)
12799 }
12800 pub(crate) fn from_ffi(
12801 value: ffi::WGPUSharedTextureMemoryMetalEndAccessState,
12802 ) -> Self {
12803 Self {
12804 commands_scheduled_future: Some(
12805 Future::from_ffi(value.commandsScheduledFuture),
12806 ),
12807 }
12808 }
12809 }
12810 pub struct SharedTextureMemoryOpaqueFDDescriptor {
12811 pub vk_image_create_info: Option<*const std::ffi::c_void>,
12812 pub memory_fd: Option<i32>,
12813 pub memory_type_index: Option<u32>,
12814 pub allocation_size: Option<u64>,
12815 pub dedicated_allocation: Option<bool>,
12816 }
12817 impl Default for SharedTextureMemoryOpaqueFDDescriptor {
12818 fn default() -> Self {
12819 Self {
12820 vk_image_create_info: None,
12821 memory_fd: None,
12822 memory_type_index: None,
12823 allocation_size: None,
12824 dedicated_allocation: None,
12825 }
12826 }
12827 }
12828 impl SharedTextureMemoryOpaqueFDDescriptor {
12829 pub fn new() -> Self {
12830 Self::default()
12831 }
12832 pub(crate) fn to_ffi(
12833 &self,
12834 ) -> (ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor, ChainedStructStorage) {
12835 let mut storage = ChainedStructStorage::new();
12836 let mut raw: ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor = unsafe {
12837 std::mem::zeroed()
12838 };
12839 if let Some(value) = self.vk_image_create_info {
12840 raw.vkImageCreateInfo = value;
12841 }
12842 if let Some(value) = self.memory_fd {
12843 raw.memoryFD = value;
12844 }
12845 if let Some(value) = self.memory_type_index {
12846 raw.memoryTypeIndex = value;
12847 }
12848 if let Some(value) = self.allocation_size {
12849 raw.allocationSize = value;
12850 }
12851 raw.dedicatedAllocation = if self.dedicated_allocation.unwrap_or(false) {
12852 1
12853 } else {
12854 0
12855 };
12856 (raw, storage)
12857 }
12858 pub(crate) fn from_ffi(
12859 value: ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor,
12860 ) -> Self {
12861 Self {
12862 vk_image_create_info: Some(value.vkImageCreateInfo),
12863 memory_fd: Some(value.memoryFD),
12864 memory_type_index: Some(value.memoryTypeIndex),
12865 allocation_size: Some(value.allocationSize),
12866 dedicated_allocation: Some(value.dedicatedAllocation != 0),
12867 }
12868 }
12869 }
12870 pub struct SharedTextureMemoryProperties {
12871 pub(crate) extensions: Vec<SharedTextureMemoryPropertiesExtension>,
12872 pub usage: Option<TextureUsage>,
12873 pub size: Option<Extent3D>,
12874 pub format: Option<TextureFormat>,
12875 }
12876 impl Default for SharedTextureMemoryProperties {
12877 fn default() -> Self {
12878 Self {
12879 extensions: Vec::new(),
12880 usage: None,
12881 size: None,
12882 format: None,
12883 }
12884 }
12885 }
12886 impl SharedTextureMemoryProperties {
12887 pub fn new() -> Self {
12888 Self::default()
12889 }
12890 pub(crate) fn to_ffi(
12891 &self,
12892 ) -> (ffi::WGPUSharedTextureMemoryProperties, ChainedStructStorage) {
12893 let mut storage = ChainedStructStorage::new();
12894 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12895 for ext in self.extensions.iter().rev() {
12896 next = ext.push_chain(&mut storage, next);
12897 }
12898 let mut raw: ffi::WGPUSharedTextureMemoryProperties = unsafe {
12899 std::mem::zeroed()
12900 };
12901 raw.nextInChain = next;
12902 if let Some(value) = self.usage {
12903 raw.usage = value.into();
12904 } else {
12905 raw.usage = 0 as ffi::WGPUTextureUsage;
12906 }
12907 if let Some(value) = &self.size {
12908 let (raw_value, storage_value) = value.to_ffi();
12909 raw.size = raw_value;
12910 storage.push_storage(storage_value);
12911 }
12912 if let Some(value) = self.format {
12913 raw.format = value.into();
12914 } else {
12915 raw.format = 0 as ffi::WGPUTextureFormat;
12916 }
12917 (raw, storage)
12918 }
12919 pub fn with_extension(
12920 mut self,
12921 extension: SharedTextureMemoryPropertiesExtension,
12922 ) -> Self {
12923 self.extensions.push(extension);
12924 self
12925 }
12926 pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryProperties) -> Self {
12927 Self {
12928 extensions: Vec::new(),
12929 usage: Some(value.usage.into()),
12930 size: Some(Extent3D::from_ffi(value.size)),
12931 format: Some(value.format.into()),
12932 }
12933 }
12934 }
12935 pub struct SharedTextureMemoryVkDedicatedAllocationDescriptor {
12936 pub dedicated_allocation: Option<bool>,
12937 }
12938 impl Default for SharedTextureMemoryVkDedicatedAllocationDescriptor {
12939 fn default() -> Self {
12940 Self { dedicated_allocation: None }
12941 }
12942 }
12943 impl SharedTextureMemoryVkDedicatedAllocationDescriptor {
12944 pub fn new() -> Self {
12945 Self::default()
12946 }
12947 pub(crate) fn to_ffi(
12948 &self,
12949 ) -> (
12950 ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor,
12951 ChainedStructStorage,
12952 ) {
12953 let mut storage = ChainedStructStorage::new();
12954 let mut raw: ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor = unsafe {
12955 std::mem::zeroed()
12956 };
12957 raw.dedicatedAllocation = if self.dedicated_allocation.unwrap_or(false) {
12958 1
12959 } else {
12960 0
12961 };
12962 (raw, storage)
12963 }
12964 pub(crate) fn from_ffi(
12965 value: ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor,
12966 ) -> Self {
12967 Self {
12968 dedicated_allocation: Some(value.dedicatedAllocation != 0),
12969 }
12970 }
12971 }
12972 pub struct SharedTextureMemoryVkImageLayoutBeginState {
12973 pub old_layout: Option<i32>,
12974 pub new_layout: Option<i32>,
12975 }
12976 impl Default for SharedTextureMemoryVkImageLayoutBeginState {
12977 fn default() -> Self {
12978 Self {
12979 old_layout: None,
12980 new_layout: None,
12981 }
12982 }
12983 }
12984 impl SharedTextureMemoryVkImageLayoutBeginState {
12985 pub fn new() -> Self {
12986 Self::default()
12987 }
12988 pub(crate) fn to_ffi(
12989 &self,
12990 ) -> (
12991 ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState,
12992 ChainedStructStorage,
12993 ) {
12994 let mut storage = ChainedStructStorage::new();
12995 let mut raw: ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState = unsafe {
12996 std::mem::zeroed()
12997 };
12998 if let Some(value) = self.old_layout {
12999 raw.oldLayout = value;
13000 }
13001 if let Some(value) = self.new_layout {
13002 raw.newLayout = value;
13003 }
13004 (raw, storage)
13005 }
13006 pub(crate) fn from_ffi(
13007 value: ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState,
13008 ) -> Self {
13009 Self {
13010 old_layout: Some(value.oldLayout),
13011 new_layout: Some(value.newLayout),
13012 }
13013 }
13014 }
13015 pub struct SharedTextureMemoryVkImageLayoutEndState {
13016 pub old_layout: Option<i32>,
13017 pub new_layout: Option<i32>,
13018 }
13019 impl Default for SharedTextureMemoryVkImageLayoutEndState {
13020 fn default() -> Self {
13021 Self {
13022 old_layout: None,
13023 new_layout: None,
13024 }
13025 }
13026 }
13027 impl SharedTextureMemoryVkImageLayoutEndState {
13028 pub fn new() -> Self {
13029 Self::default()
13030 }
13031 pub(crate) fn to_ffi(
13032 &self,
13033 ) -> (ffi::WGPUSharedTextureMemoryVkImageLayoutEndState, ChainedStructStorage) {
13034 let mut storage = ChainedStructStorage::new();
13035 let mut raw: ffi::WGPUSharedTextureMemoryVkImageLayoutEndState = unsafe {
13036 std::mem::zeroed()
13037 };
13038 if let Some(value) = self.old_layout {
13039 raw.oldLayout = value;
13040 }
13041 if let Some(value) = self.new_layout {
13042 raw.newLayout = value;
13043 }
13044 (raw, storage)
13045 }
13046 pub(crate) fn from_ffi(
13047 value: ffi::WGPUSharedTextureMemoryVkImageLayoutEndState,
13048 ) -> Self {
13049 Self {
13050 old_layout: Some(value.oldLayout),
13051 new_layout: Some(value.newLayout),
13052 }
13053 }
13054 }
13055 pub struct SharedTextureMemoryZirconHandleDescriptor {
13056 pub memory_fd: Option<u32>,
13057 pub allocation_size: Option<u64>,
13058 }
13059 impl Default for SharedTextureMemoryZirconHandleDescriptor {
13060 fn default() -> Self {
13061 Self {
13062 memory_fd: None,
13063 allocation_size: None,
13064 }
13065 }
13066 }
13067 impl SharedTextureMemoryZirconHandleDescriptor {
13068 pub fn new() -> Self {
13069 Self::default()
13070 }
13071 pub(crate) fn to_ffi(
13072 &self,
13073 ) -> (ffi::WGPUSharedTextureMemoryZirconHandleDescriptor, ChainedStructStorage) {
13074 let mut storage = ChainedStructStorage::new();
13075 let mut raw: ffi::WGPUSharedTextureMemoryZirconHandleDescriptor = unsafe {
13076 std::mem::zeroed()
13077 };
13078 if let Some(value) = self.memory_fd {
13079 raw.memoryFD = value;
13080 }
13081 if let Some(value) = self.allocation_size {
13082 raw.allocationSize = value;
13083 }
13084 (raw, storage)
13085 }
13086 pub(crate) fn from_ffi(
13087 value: ffi::WGPUSharedTextureMemoryZirconHandleDescriptor,
13088 ) -> Self {
13089 Self {
13090 memory_fd: Some(value.memoryFD),
13091 allocation_size: Some(value.allocationSize),
13092 }
13093 }
13094 }
13095 pub struct StaticSamplerBindingLayout {
13096 pub sampler: Option<Sampler>,
13097 pub sampled_texture_binding: Option<u32>,
13098 }
13099 impl Default for StaticSamplerBindingLayout {
13100 fn default() -> Self {
13101 Self {
13102 sampler: None,
13103 sampled_texture_binding: Some(LIMIT_U32_UNDEFINED),
13104 }
13105 }
13106 }
13107 impl StaticSamplerBindingLayout {
13108 pub fn new() -> Self {
13109 Self::default()
13110 }
13111 pub(crate) fn to_ffi(
13112 &self,
13113 ) -> (ffi::WGPUStaticSamplerBindingLayout, ChainedStructStorage) {
13114 let mut storage = ChainedStructStorage::new();
13115 let mut raw: ffi::WGPUStaticSamplerBindingLayout = unsafe {
13116 std::mem::zeroed()
13117 };
13118 raw.sampler = self
13119 .sampler
13120 .as_ref()
13121 .map(|v| v.as_raw())
13122 .unwrap_or(std::ptr::null_mut());
13123 if let Some(value) = self.sampled_texture_binding {
13124 raw.sampledTextureBinding = value;
13125 }
13126 (raw, storage)
13127 }
13128 pub(crate) fn from_ffi(value: ffi::WGPUStaticSamplerBindingLayout) -> Self {
13129 Self {
13130 sampler: Some(unsafe { Sampler::from_raw(value.sampler) }),
13131 sampled_texture_binding: Some(value.sampledTextureBinding),
13132 }
13133 }
13134 }
13135 pub struct StencilFaceState {
13136 pub compare: Option<CompareFunction>,
13137 pub fail_op: Option<StencilOperation>,
13138 pub depth_fail_op: Option<StencilOperation>,
13139 pub pass_op: Option<StencilOperation>,
13140 }
13141 impl Default for StencilFaceState {
13142 fn default() -> Self {
13143 Self {
13144 compare: Some(CompareFunction::Always),
13145 fail_op: Some(StencilOperation::Keep),
13146 depth_fail_op: Some(StencilOperation::Keep),
13147 pass_op: Some(StencilOperation::Keep),
13148 }
13149 }
13150 }
13151 impl StencilFaceState {
13152 pub fn new() -> Self {
13153 Self::default()
13154 }
13155 pub(crate) fn to_ffi(
13156 &self,
13157 ) -> (ffi::WGPUStencilFaceState, ChainedStructStorage) {
13158 let mut storage = ChainedStructStorage::new();
13159 let mut raw: ffi::WGPUStencilFaceState = unsafe { std::mem::zeroed() };
13160 if let Some(value) = self.compare {
13161 raw.compare = value.into();
13162 } else {
13163 raw.compare = 0 as ffi::WGPUCompareFunction;
13164 }
13165 if let Some(value) = self.fail_op {
13166 raw.failOp = value.into();
13167 } else {
13168 raw.failOp = 0 as ffi::WGPUStencilOperation;
13169 }
13170 if let Some(value) = self.depth_fail_op {
13171 raw.depthFailOp = value.into();
13172 } else {
13173 raw.depthFailOp = 0 as ffi::WGPUStencilOperation;
13174 }
13175 if let Some(value) = self.pass_op {
13176 raw.passOp = value.into();
13177 } else {
13178 raw.passOp = 0 as ffi::WGPUStencilOperation;
13179 }
13180 (raw, storage)
13181 }
13182 pub(crate) fn from_ffi(value: ffi::WGPUStencilFaceState) -> Self {
13183 Self {
13184 compare: Some(value.compare.into()),
13185 fail_op: Some(value.failOp.into()),
13186 depth_fail_op: Some(value.depthFailOp.into()),
13187 pass_op: Some(value.passOp.into()),
13188 }
13189 }
13190 }
13191 pub struct StorageTextureBindingLayout {
13192 pub(crate) extensions: Vec<StorageTextureBindingLayoutExtension>,
13193 pub access: Option<StorageTextureAccess>,
13194 pub format: Option<TextureFormat>,
13195 pub view_dimension: Option<TextureViewDimension>,
13196 }
13197 impl Default for StorageTextureBindingLayout {
13198 fn default() -> Self {
13199 Self {
13200 extensions: Vec::new(),
13201 access: Some(StorageTextureAccess::WriteOnly),
13202 format: None,
13203 view_dimension: Some(TextureViewDimension::D2),
13204 }
13205 }
13206 }
13207 impl StorageTextureBindingLayout {
13208 pub fn new() -> Self {
13209 Self::default()
13210 }
13211 pub(crate) fn to_ffi(
13212 &self,
13213 ) -> (ffi::WGPUStorageTextureBindingLayout, ChainedStructStorage) {
13214 let mut storage = ChainedStructStorage::new();
13215 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13216 for ext in self.extensions.iter().rev() {
13217 next = ext.push_chain(&mut storage, next);
13218 }
13219 let mut raw: ffi::WGPUStorageTextureBindingLayout = unsafe {
13220 std::mem::zeroed()
13221 };
13222 raw.nextInChain = next;
13223 if let Some(value) = self.access {
13224 raw.access = value.into();
13225 } else {
13226 raw.access = 0 as ffi::WGPUStorageTextureAccess;
13227 }
13228 if let Some(value) = self.format {
13229 raw.format = value.into();
13230 } else {
13231 raw.format = 0 as ffi::WGPUTextureFormat;
13232 }
13233 if let Some(value) = self.view_dimension {
13234 raw.viewDimension = value.into();
13235 } else {
13236 raw.viewDimension = 0 as ffi::WGPUTextureViewDimension;
13237 }
13238 (raw, storage)
13239 }
13240 pub fn with_extension(
13241 mut self,
13242 extension: StorageTextureBindingLayoutExtension,
13243 ) -> Self {
13244 self.extensions.push(extension);
13245 self
13246 }
13247 pub(crate) fn from_ffi(value: ffi::WGPUStorageTextureBindingLayout) -> Self {
13248 Self {
13249 extensions: Vec::new(),
13250 access: Some(value.access.into()),
13251 format: Some(value.format.into()),
13252 view_dimension: Some(value.viewDimension.into()),
13253 }
13254 }
13255 }
13256 pub struct StringView {
13257 pub data: Option<*const std::os::raw::c_char>,
13258 pub length: Option<usize>,
13259 }
13260 impl Default for StringView {
13261 fn default() -> Self {
13262 Self {
13263 data: None,
13264 length: Some(STRLEN),
13265 }
13266 }
13267 }
13268 impl StringView {
13269 pub fn new() -> Self {
13270 Self::default()
13271 }
13272 pub(crate) fn to_ffi(&self) -> (ffi::WGPUStringView, ChainedStructStorage) {
13273 let mut storage = ChainedStructStorage::new();
13274 let mut raw: ffi::WGPUStringView = unsafe { std::mem::zeroed() };
13275 if let Some(value) = self.data {
13276 raw.data = value;
13277 }
13278 if let Some(value) = self.length {
13279 raw.length = value;
13280 }
13281 (raw, storage)
13282 }
13283 pub(crate) fn from_ffi(value: ffi::WGPUStringView) -> Self {
13284 Self {
13285 data: Some(value.data),
13286 length: Some(value.length),
13287 }
13288 }
13289 }
13290 pub struct SubgroupMatrixConfig {
13291 pub component_type: Option<SubgroupMatrixComponentType>,
13292 pub result_component_type: Option<SubgroupMatrixComponentType>,
13293 pub m: Option<u32>,
13294 pub n: Option<u32>,
13295 pub k: Option<u32>,
13296 }
13297 impl Default for SubgroupMatrixConfig {
13298 fn default() -> Self {
13299 Self {
13300 component_type: None,
13301 result_component_type: None,
13302 m: None,
13303 n: None,
13304 k: None,
13305 }
13306 }
13307 }
13308 impl SubgroupMatrixConfig {
13309 pub fn new() -> Self {
13310 Self::default()
13311 }
13312 pub(crate) fn to_ffi(
13313 &self,
13314 ) -> (ffi::WGPUSubgroupMatrixConfig, ChainedStructStorage) {
13315 let mut storage = ChainedStructStorage::new();
13316 let mut raw: ffi::WGPUSubgroupMatrixConfig = unsafe { std::mem::zeroed() };
13317 if let Some(value) = self.component_type {
13318 raw.componentType = value.into();
13319 } else {
13320 raw.componentType = 0 as ffi::WGPUSubgroupMatrixComponentType;
13321 }
13322 if let Some(value) = self.result_component_type {
13323 raw.resultComponentType = value.into();
13324 } else {
13325 raw.resultComponentType = 0 as ffi::WGPUSubgroupMatrixComponentType;
13326 }
13327 if let Some(value) = self.m {
13328 raw.M = value;
13329 }
13330 if let Some(value) = self.n {
13331 raw.N = value;
13332 }
13333 if let Some(value) = self.k {
13334 raw.K = value;
13335 }
13336 (raw, storage)
13337 }
13338 pub(crate) fn from_ffi(value: ffi::WGPUSubgroupMatrixConfig) -> Self {
13339 Self {
13340 component_type: Some(value.componentType.into()),
13341 result_component_type: Some(value.resultComponentType.into()),
13342 m: Some(value.M),
13343 n: Some(value.N),
13344 k: Some(value.K),
13345 }
13346 }
13347 }
13348 pub struct SupportedWGSLLanguageFeatures {
13349 pub features: Option<Vec<WGSLLanguageFeatureName>>,
13350 #[doc(hidden)]
13351 pub(crate) _free_members: Option<ffi::WGPUSupportedWGSLLanguageFeatures>,
13352 }
13353 impl Default for SupportedWGSLLanguageFeatures {
13354 fn default() -> Self {
13355 Self {
13356 features: None,
13357 _free_members: None,
13358 }
13359 }
13360 }
13361 impl SupportedWGSLLanguageFeatures {
13362 pub fn new() -> Self {
13363 Self::default()
13364 }
13365 pub(crate) fn to_ffi(
13366 &self,
13367 ) -> (ffi::WGPUSupportedWGSLLanguageFeatures, ChainedStructStorage) {
13368 let mut storage = ChainedStructStorage::new();
13369 let mut raw: ffi::WGPUSupportedWGSLLanguageFeatures = unsafe {
13370 std::mem::zeroed()
13371 };
13372 raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13373 if let Some(values) = &self.features {
13374 let len_value = values.len();
13375 let raw_vec: Vec<ffi::WGPUWGSLLanguageFeatureName> = values
13376 .iter()
13377 .map(|v| (*v).into())
13378 .collect();
13379 let ptr = storage.push_vec(raw_vec);
13380 raw.features = ptr;
13381 raw.featureCount = len_value;
13382 } else {
13383 raw.features = std::ptr::null();
13384 raw.featureCount = 0;
13385 }
13386 (raw, storage)
13387 }
13388 pub(crate) fn from_ffi(value: ffi::WGPUSupportedWGSLLanguageFeatures) -> Self {
13389 Self {
13390 features: if value.features.is_null() {
13391 None
13392 } else {
13393 Some(
13394 unsafe {
13395 std::slice::from_raw_parts(
13396 value.features,
13397 value.featureCount as usize,
13398 )
13399 }
13400 .iter()
13401 .map(|raw| WGSLLanguageFeatureName::from(*raw))
13402 .collect(),
13403 )
13404 },
13405 _free_members: Some(value),
13406 }
13407 }
13408 pub(crate) fn free_members(value: ffi::WGPUSupportedWGSLLanguageFeatures) {
13409 unsafe { ffi::wgpuSupportedWGSLLanguageFeaturesFreeMembers(value) };
13410 }
13411 }
13412 impl Drop for SupportedWGSLLanguageFeatures {
13413 fn drop(&mut self) {
13414 if let Some(value) = self._free_members.take() {
13415 unsafe { ffi::wgpuSupportedWGSLLanguageFeaturesFreeMembers(value) };
13416 }
13417 }
13418 }
13419 pub struct SupportedFeatures {
13420 pub features: Option<Vec<FeatureName>>,
13421 #[doc(hidden)]
13422 pub(crate) _free_members: Option<ffi::WGPUSupportedFeatures>,
13423 }
13424 impl Default for SupportedFeatures {
13425 fn default() -> Self {
13426 Self {
13427 features: None,
13428 _free_members: None,
13429 }
13430 }
13431 }
13432 impl SupportedFeatures {
13433 pub fn new() -> Self {
13434 Self::default()
13435 }
13436 pub(crate) fn to_ffi(
13437 &self,
13438 ) -> (ffi::WGPUSupportedFeatures, ChainedStructStorage) {
13439 let mut storage = ChainedStructStorage::new();
13440 let mut raw: ffi::WGPUSupportedFeatures = unsafe { std::mem::zeroed() };
13441 raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13442 if let Some(values) = &self.features {
13443 let len_value = values.len();
13444 let raw_vec: Vec<ffi::WGPUFeatureName> = values
13445 .iter()
13446 .map(|v| (*v).into())
13447 .collect();
13448 let ptr = storage.push_vec(raw_vec);
13449 raw.features = ptr;
13450 raw.featureCount = len_value;
13451 } else {
13452 raw.features = std::ptr::null();
13453 raw.featureCount = 0;
13454 }
13455 (raw, storage)
13456 }
13457 pub(crate) fn from_ffi(value: ffi::WGPUSupportedFeatures) -> Self {
13458 Self {
13459 features: if value.features.is_null() {
13460 None
13461 } else {
13462 Some(
13463 unsafe {
13464 std::slice::from_raw_parts(
13465 value.features,
13466 value.featureCount as usize,
13467 )
13468 }
13469 .iter()
13470 .map(|raw| FeatureName::from(*raw))
13471 .collect(),
13472 )
13473 },
13474 _free_members: Some(value),
13475 }
13476 }
13477 pub(crate) fn free_members(value: ffi::WGPUSupportedFeatures) {
13478 unsafe { ffi::wgpuSupportedFeaturesFreeMembers(value) };
13479 }
13480 }
13481 impl Drop for SupportedFeatures {
13482 fn drop(&mut self) {
13483 if let Some(value) = self._free_members.take() {
13484 unsafe { ffi::wgpuSupportedFeaturesFreeMembers(value) };
13485 }
13486 }
13487 }
13488 pub struct SupportedInstanceFeatures {
13489 pub features: Option<Vec<InstanceFeatureName>>,
13490 #[doc(hidden)]
13491 pub(crate) _free_members: Option<ffi::WGPUSupportedInstanceFeatures>,
13492 }
13493 impl Default for SupportedInstanceFeatures {
13494 fn default() -> Self {
13495 Self {
13496 features: None,
13497 _free_members: None,
13498 }
13499 }
13500 }
13501 impl SupportedInstanceFeatures {
13502 pub fn new() -> Self {
13503 Self::default()
13504 }
13505 pub(crate) fn to_ffi(
13506 &self,
13507 ) -> (ffi::WGPUSupportedInstanceFeatures, ChainedStructStorage) {
13508 let mut storage = ChainedStructStorage::new();
13509 let mut raw: ffi::WGPUSupportedInstanceFeatures = unsafe {
13510 std::mem::zeroed()
13511 };
13512 raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13513 if let Some(values) = &self.features {
13514 let len_value = values.len();
13515 let raw_vec: Vec<ffi::WGPUInstanceFeatureName> = values
13516 .iter()
13517 .map(|v| (*v).into())
13518 .collect();
13519 let ptr = storage.push_vec(raw_vec);
13520 raw.features = ptr;
13521 raw.featureCount = len_value;
13522 } else {
13523 raw.features = std::ptr::null();
13524 raw.featureCount = 0;
13525 }
13526 (raw, storage)
13527 }
13528 pub(crate) fn from_ffi(value: ffi::WGPUSupportedInstanceFeatures) -> Self {
13529 Self {
13530 features: if value.features.is_null() {
13531 None
13532 } else {
13533 Some(
13534 unsafe {
13535 std::slice::from_raw_parts(
13536 value.features,
13537 value.featureCount as usize,
13538 )
13539 }
13540 .iter()
13541 .map(|raw| InstanceFeatureName::from(*raw))
13542 .collect(),
13543 )
13544 },
13545 _free_members: Some(value),
13546 }
13547 }
13548 pub(crate) fn free_members(value: ffi::WGPUSupportedInstanceFeatures) {
13549 unsafe { ffi::wgpuSupportedInstanceFeaturesFreeMembers(value) };
13550 }
13551 }
13552 impl Drop for SupportedInstanceFeatures {
13553 fn drop(&mut self) {
13554 if let Some(value) = self._free_members.take() {
13555 unsafe { ffi::wgpuSupportedInstanceFeaturesFreeMembers(value) };
13556 }
13557 }
13558 }
13559 pub struct SurfaceCapabilities {
13560 pub(crate) extensions: Vec<SurfaceCapabilitiesExtension>,
13561 pub usages: Option<TextureUsage>,
13562 pub formats: Option<Vec<TextureFormat>>,
13563 pub present_modes: Option<Vec<PresentMode>>,
13564 pub alpha_modes: Option<Vec<CompositeAlphaMode>>,
13565 #[doc(hidden)]
13566 pub(crate) _free_members: Option<ffi::WGPUSurfaceCapabilities>,
13567 }
13568 impl Default for SurfaceCapabilities {
13569 fn default() -> Self {
13570 Self {
13571 extensions: Vec::new(),
13572 usages: None,
13573 formats: None,
13574 present_modes: None,
13575 alpha_modes: None,
13576 _free_members: None,
13577 }
13578 }
13579 }
13580 impl SurfaceCapabilities {
13581 pub fn new() -> Self {
13582 Self::default()
13583 }
13584 pub(crate) fn to_ffi(
13585 &self,
13586 ) -> (ffi::WGPUSurfaceCapabilities, ChainedStructStorage) {
13587 let mut storage = ChainedStructStorage::new();
13588 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13589 for ext in self.extensions.iter().rev() {
13590 next = ext.push_chain(&mut storage, next);
13591 }
13592 let mut raw: ffi::WGPUSurfaceCapabilities = unsafe { std::mem::zeroed() };
13593 raw.nextInChain = next;
13594 if let Some(value) = self.usages {
13595 raw.usages = value.into();
13596 } else {
13597 raw.usages = 0 as ffi::WGPUTextureUsage;
13598 }
13599 raw.formatCount = self.formats.as_ref().map(|v| v.len()).unwrap_or(0);
13600 if let Some(values) = &self.formats {
13601 let len_value = values.len();
13602 let raw_vec: Vec<ffi::WGPUTextureFormat> = values
13603 .iter()
13604 .map(|v| (*v).into())
13605 .collect();
13606 let ptr = storage.push_vec(raw_vec);
13607 raw.formats = ptr;
13608 raw.formatCount = len_value;
13609 } else {
13610 raw.formats = std::ptr::null();
13611 raw.formatCount = 0;
13612 }
13613 raw.presentModeCount = self
13614 .present_modes
13615 .as_ref()
13616 .map(|v| v.len())
13617 .unwrap_or(0);
13618 if let Some(values) = &self.present_modes {
13619 let len_value = values.len();
13620 let raw_vec: Vec<ffi::WGPUPresentMode> = values
13621 .iter()
13622 .map(|v| (*v).into())
13623 .collect();
13624 let ptr = storage.push_vec(raw_vec);
13625 raw.presentModes = ptr;
13626 raw.presentModeCount = len_value;
13627 } else {
13628 raw.presentModes = std::ptr::null();
13629 raw.presentModeCount = 0;
13630 }
13631 raw.alphaModeCount = self.alpha_modes.as_ref().map(|v| v.len()).unwrap_or(0);
13632 if let Some(values) = &self.alpha_modes {
13633 let len_value = values.len();
13634 let raw_vec: Vec<ffi::WGPUCompositeAlphaMode> = values
13635 .iter()
13636 .map(|v| (*v).into())
13637 .collect();
13638 let ptr = storage.push_vec(raw_vec);
13639 raw.alphaModes = ptr;
13640 raw.alphaModeCount = len_value;
13641 } else {
13642 raw.alphaModes = std::ptr::null();
13643 raw.alphaModeCount = 0;
13644 }
13645 (raw, storage)
13646 }
13647 pub fn with_extension(
13648 mut self,
13649 extension: SurfaceCapabilitiesExtension,
13650 ) -> Self {
13651 self.extensions.push(extension);
13652 self
13653 }
13654 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceCapabilities) -> Self {
13655 Self {
13656 extensions: Vec::new(),
13657 usages: Some(value.usages.into()),
13658 formats: if value.formats.is_null() {
13659 None
13660 } else {
13661 Some(
13662 unsafe {
13663 std::slice::from_raw_parts(
13664 value.formats,
13665 value.formatCount as usize,
13666 )
13667 }
13668 .iter()
13669 .map(|raw| TextureFormat::from(*raw))
13670 .collect(),
13671 )
13672 },
13673 present_modes: if value.presentModes.is_null() {
13674 None
13675 } else {
13676 Some(
13677 unsafe {
13678 std::slice::from_raw_parts(
13679 value.presentModes,
13680 value.presentModeCount as usize,
13681 )
13682 }
13683 .iter()
13684 .map(|raw| PresentMode::from(*raw))
13685 .collect(),
13686 )
13687 },
13688 alpha_modes: if value.alphaModes.is_null() {
13689 None
13690 } else {
13691 Some(
13692 unsafe {
13693 std::slice::from_raw_parts(
13694 value.alphaModes,
13695 value.alphaModeCount as usize,
13696 )
13697 }
13698 .iter()
13699 .map(|raw| CompositeAlphaMode::from(*raw))
13700 .collect(),
13701 )
13702 },
13703 _free_members: Some(value),
13704 }
13705 }
13706 pub(crate) fn free_members(value: ffi::WGPUSurfaceCapabilities) {
13707 unsafe { ffi::wgpuSurfaceCapabilitiesFreeMembers(value) };
13708 }
13709 }
13710 impl Drop for SurfaceCapabilities {
13711 fn drop(&mut self) {
13712 if let Some(value) = self._free_members.take() {
13713 unsafe { ffi::wgpuSurfaceCapabilitiesFreeMembers(value) };
13714 }
13715 }
13716 }
13717 pub struct SurfaceColorManagement {
13718 pub color_space: Option<PredefinedColorSpace>,
13719 pub tone_mapping_mode: Option<ToneMappingMode>,
13720 }
13721 impl Default for SurfaceColorManagement {
13722 fn default() -> Self {
13723 Self {
13724 color_space: None,
13725 tone_mapping_mode: None,
13726 }
13727 }
13728 }
13729 impl SurfaceColorManagement {
13730 pub fn new() -> Self {
13731 Self::default()
13732 }
13733 pub(crate) fn to_ffi(
13734 &self,
13735 ) -> (ffi::WGPUSurfaceColorManagement, ChainedStructStorage) {
13736 let mut storage = ChainedStructStorage::new();
13737 let mut raw: ffi::WGPUSurfaceColorManagement = unsafe { std::mem::zeroed() };
13738 if let Some(value) = self.color_space {
13739 raw.colorSpace = value.into();
13740 } else {
13741 raw.colorSpace = 0 as ffi::WGPUPredefinedColorSpace;
13742 }
13743 if let Some(value) = self.tone_mapping_mode {
13744 raw.toneMappingMode = value.into();
13745 } else {
13746 raw.toneMappingMode = 0 as ffi::WGPUToneMappingMode;
13747 }
13748 (raw, storage)
13749 }
13750 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceColorManagement) -> Self {
13751 Self {
13752 color_space: Some(value.colorSpace.into()),
13753 tone_mapping_mode: Some(value.toneMappingMode.into()),
13754 }
13755 }
13756 }
13757 pub struct SurfaceConfiguration {
13758 pub(crate) extensions: Vec<SurfaceConfigurationExtension>,
13759 pub device: Option<Device>,
13760 pub format: Option<TextureFormat>,
13761 pub usage: Option<TextureUsage>,
13762 pub width: Option<u32>,
13763 pub height: Option<u32>,
13764 pub view_formats: Option<Vec<TextureFormat>>,
13765 pub alpha_mode: Option<CompositeAlphaMode>,
13766 pub present_mode: Option<PresentMode>,
13767 }
13768 impl Default for SurfaceConfiguration {
13769 fn default() -> Self {
13770 Self {
13771 extensions: Vec::new(),
13772 device: None,
13773 format: None,
13774 usage: Some(TextureUsage::RENDER_ATTACHMENT),
13775 width: None,
13776 height: None,
13777 view_formats: None,
13778 alpha_mode: Some(CompositeAlphaMode::Auto),
13779 present_mode: Some(PresentMode::Fifo),
13780 }
13781 }
13782 }
13783 impl SurfaceConfiguration {
13784 pub fn new() -> Self {
13785 Self::default()
13786 }
13787 pub(crate) fn to_ffi(
13788 &self,
13789 ) -> (ffi::WGPUSurfaceConfiguration, ChainedStructStorage) {
13790 let mut storage = ChainedStructStorage::new();
13791 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13792 for ext in self.extensions.iter().rev() {
13793 next = ext.push_chain(&mut storage, next);
13794 }
13795 let mut raw: ffi::WGPUSurfaceConfiguration = unsafe { std::mem::zeroed() };
13796 raw.nextInChain = next;
13797 raw.device = self
13798 .device
13799 .as_ref()
13800 .map(|v| v.as_raw())
13801 .unwrap_or(std::ptr::null_mut());
13802 if let Some(value) = self.format {
13803 raw.format = value.into();
13804 } else {
13805 raw.format = 0 as ffi::WGPUTextureFormat;
13806 }
13807 if let Some(value) = self.usage {
13808 raw.usage = value.into();
13809 } else {
13810 raw.usage = 0 as ffi::WGPUTextureUsage;
13811 }
13812 if let Some(value) = self.width {
13813 raw.width = value;
13814 }
13815 if let Some(value) = self.height {
13816 raw.height = value;
13817 }
13818 raw.viewFormatCount = self
13819 .view_formats
13820 .as_ref()
13821 .map(|v| v.len())
13822 .unwrap_or(0);
13823 if let Some(values) = &self.view_formats {
13824 let len_value = values.len();
13825 let raw_vec: Vec<ffi::WGPUTextureFormat> = values
13826 .iter()
13827 .map(|v| (*v).into())
13828 .collect();
13829 let ptr = storage.push_vec(raw_vec);
13830 raw.viewFormats = ptr;
13831 raw.viewFormatCount = len_value;
13832 } else {
13833 raw.viewFormats = std::ptr::null();
13834 raw.viewFormatCount = 0;
13835 }
13836 if let Some(value) = self.alpha_mode {
13837 raw.alphaMode = value.into();
13838 } else {
13839 raw.alphaMode = 0 as ffi::WGPUCompositeAlphaMode;
13840 }
13841 if let Some(value) = self.present_mode {
13842 raw.presentMode = value.into();
13843 } else {
13844 raw.presentMode = 0 as ffi::WGPUPresentMode;
13845 }
13846 (raw, storage)
13847 }
13848 pub fn with_extension(
13849 mut self,
13850 extension: SurfaceConfigurationExtension,
13851 ) -> Self {
13852 self.extensions.push(extension);
13853 self
13854 }
13855 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceConfiguration) -> Self {
13856 Self {
13857 extensions: Vec::new(),
13858 device: Some(unsafe { Device::from_raw(value.device) }),
13859 format: Some(value.format.into()),
13860 usage: Some(value.usage.into()),
13861 width: Some(value.width),
13862 height: Some(value.height),
13863 view_formats: if value.viewFormats.is_null() {
13864 None
13865 } else {
13866 Some(
13867 unsafe {
13868 std::slice::from_raw_parts(
13869 value.viewFormats,
13870 value.viewFormatCount as usize,
13871 )
13872 }
13873 .iter()
13874 .map(|raw| TextureFormat::from(*raw))
13875 .collect(),
13876 )
13877 },
13878 alpha_mode: Some(value.alphaMode.into()),
13879 present_mode: Some(value.presentMode.into()),
13880 }
13881 }
13882 }
13883 pub struct SurfaceDescriptor {
13884 pub(crate) extensions: Vec<SurfaceDescriptorExtension>,
13885 pub label: Option<String>,
13886 }
13887 impl Default for SurfaceDescriptor {
13888 fn default() -> Self {
13889 Self {
13890 extensions: Vec::new(),
13891 label: None,
13892 }
13893 }
13894 }
13895 impl SurfaceDescriptor {
13896 pub fn new() -> Self {
13897 Self::default()
13898 }
13899 pub(crate) fn to_ffi(
13900 &self,
13901 ) -> (ffi::WGPUSurfaceDescriptor, ChainedStructStorage) {
13902 let mut storage = ChainedStructStorage::new();
13903 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13904 for ext in self.extensions.iter().rev() {
13905 next = ext.push_chain(&mut storage, next);
13906 }
13907 let mut raw: ffi::WGPUSurfaceDescriptor = unsafe { std::mem::zeroed() };
13908 raw.nextInChain = next;
13909 if let Some(value) = &self.label {
13910 raw.label = ffi::WGPUStringView {
13911 data: value.as_ptr().cast(),
13912 length: value.len(),
13913 };
13914 } else {
13915 raw.label = ffi::WGPUStringView {
13916 data: std::ptr::null(),
13917 length: 0,
13918 };
13919 }
13920 (raw, storage)
13921 }
13922 pub fn with_extension(mut self, extension: SurfaceDescriptorExtension) -> Self {
13923 self.extensions.push(extension);
13924 self
13925 }
13926 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceDescriptor) -> Self {
13927 Self {
13928 extensions: Vec::new(),
13929 label: if value.label.data.is_null() || value.label.length == 0 {
13930 None
13931 } else {
13932 Some(string_view_to_string(value.label))
13933 },
13934 }
13935 }
13936 }
13937 pub struct SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13938 pub swap_chain_panel: Option<*mut std::ffi::c_void>,
13939 }
13940 impl Default for SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13941 fn default() -> Self {
13942 Self { swap_chain_panel: None }
13943 }
13944 }
13945 impl SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13946 pub fn new() -> Self {
13947 Self::default()
13948 }
13949 pub(crate) fn to_ffi(
13950 &self,
13951 ) -> (
13952 ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel,
13953 ChainedStructStorage,
13954 ) {
13955 let mut storage = ChainedStructStorage::new();
13956 let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel = unsafe {
13957 std::mem::zeroed()
13958 };
13959 if let Some(value) = self.swap_chain_panel {
13960 raw.swapChainPanel = value;
13961 }
13962 (raw, storage)
13963 }
13964 pub(crate) fn from_ffi(
13965 value: ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel,
13966 ) -> Self {
13967 Self {
13968 swap_chain_panel: Some(value.swapChainPanel),
13969 }
13970 }
13971 }
13972 pub struct SurfaceDescriptorFromWindowsWinUISwapChainPanel {
13973 pub swap_chain_panel: Option<*mut std::ffi::c_void>,
13974 }
13975 impl Default for SurfaceDescriptorFromWindowsWinUISwapChainPanel {
13976 fn default() -> Self {
13977 Self { swap_chain_panel: None }
13978 }
13979 }
13980 impl SurfaceDescriptorFromWindowsWinUISwapChainPanel {
13981 pub fn new() -> Self {
13982 Self::default()
13983 }
13984 pub(crate) fn to_ffi(
13985 &self,
13986 ) -> (
13987 ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel,
13988 ChainedStructStorage,
13989 ) {
13990 let mut storage = ChainedStructStorage::new();
13991 let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel = unsafe {
13992 std::mem::zeroed()
13993 };
13994 if let Some(value) = self.swap_chain_panel {
13995 raw.swapChainPanel = value;
13996 }
13997 (raw, storage)
13998 }
13999 pub(crate) fn from_ffi(
14000 value: ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel,
14001 ) -> Self {
14002 Self {
14003 swap_chain_panel: Some(value.swapChainPanel),
14004 }
14005 }
14006 }
14007 pub struct SurfaceDescriptorFromWindowsCoreWindow {
14008 pub core_window: Option<*mut std::ffi::c_void>,
14009 }
14010 impl Default for SurfaceDescriptorFromWindowsCoreWindow {
14011 fn default() -> Self {
14012 Self { core_window: None }
14013 }
14014 }
14015 impl SurfaceDescriptorFromWindowsCoreWindow {
14016 pub fn new() -> Self {
14017 Self::default()
14018 }
14019 pub(crate) fn to_ffi(
14020 &self,
14021 ) -> (ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow, ChainedStructStorage) {
14022 let mut storage = ChainedStructStorage::new();
14023 let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow = unsafe {
14024 std::mem::zeroed()
14025 };
14026 if let Some(value) = self.core_window {
14027 raw.coreWindow = value;
14028 }
14029 (raw, storage)
14030 }
14031 pub(crate) fn from_ffi(
14032 value: ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow,
14033 ) -> Self {
14034 Self {
14035 core_window: Some(value.coreWindow),
14036 }
14037 }
14038 }
14039 pub struct SurfaceSourceXCBWindow {
14040 pub connection: Option<*mut std::ffi::c_void>,
14041 pub window: Option<u32>,
14042 }
14043 impl Default for SurfaceSourceXCBWindow {
14044 fn default() -> Self {
14045 Self {
14046 connection: None,
14047 window: None,
14048 }
14049 }
14050 }
14051 impl SurfaceSourceXCBWindow {
14052 pub fn new() -> Self {
14053 Self::default()
14054 }
14055 pub(crate) fn to_ffi(
14056 &self,
14057 ) -> (ffi::WGPUSurfaceSourceXCBWindow, ChainedStructStorage) {
14058 let mut storage = ChainedStructStorage::new();
14059 let mut raw: ffi::WGPUSurfaceSourceXCBWindow = unsafe { std::mem::zeroed() };
14060 if let Some(value) = self.connection {
14061 raw.connection = value;
14062 }
14063 if let Some(value) = self.window {
14064 raw.window = value;
14065 }
14066 (raw, storage)
14067 }
14068 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceXCBWindow) -> Self {
14069 Self {
14070 connection: Some(value.connection),
14071 window: Some(value.window),
14072 }
14073 }
14074 }
14075 pub struct SurfaceSourceAndroidNativeWindow {
14076 pub window: Option<*mut std::ffi::c_void>,
14077 }
14078 impl Default for SurfaceSourceAndroidNativeWindow {
14079 fn default() -> Self {
14080 Self { window: None }
14081 }
14082 }
14083 impl SurfaceSourceAndroidNativeWindow {
14084 pub fn new() -> Self {
14085 Self::default()
14086 }
14087 pub(crate) fn to_ffi(
14088 &self,
14089 ) -> (ffi::WGPUSurfaceSourceAndroidNativeWindow, ChainedStructStorage) {
14090 let mut storage = ChainedStructStorage::new();
14091 let mut raw: ffi::WGPUSurfaceSourceAndroidNativeWindow = unsafe {
14092 std::mem::zeroed()
14093 };
14094 if let Some(value) = self.window {
14095 raw.window = value;
14096 }
14097 (raw, storage)
14098 }
14099 pub(crate) fn from_ffi(
14100 value: ffi::WGPUSurfaceSourceAndroidNativeWindow,
14101 ) -> Self {
14102 Self { window: Some(value.window) }
14103 }
14104 }
14105 pub struct SurfaceSourceMetalLayer {
14106 pub layer: Option<*mut std::ffi::c_void>,
14107 }
14108 impl Default for SurfaceSourceMetalLayer {
14109 fn default() -> Self {
14110 Self { layer: None }
14111 }
14112 }
14113 impl SurfaceSourceMetalLayer {
14114 pub fn new() -> Self {
14115 Self::default()
14116 }
14117 pub(crate) fn to_ffi(
14118 &self,
14119 ) -> (ffi::WGPUSurfaceSourceMetalLayer, ChainedStructStorage) {
14120 let mut storage = ChainedStructStorage::new();
14121 let mut raw: ffi::WGPUSurfaceSourceMetalLayer = unsafe {
14122 std::mem::zeroed()
14123 };
14124 if let Some(value) = self.layer {
14125 raw.layer = value;
14126 }
14127 (raw, storage)
14128 }
14129 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceMetalLayer) -> Self {
14130 Self { layer: Some(value.layer) }
14131 }
14132 }
14133 pub struct SurfaceSourceWaylandSurface {
14134 pub display: Option<*mut std::ffi::c_void>,
14135 pub surface: Option<*mut std::ffi::c_void>,
14136 }
14137 impl Default for SurfaceSourceWaylandSurface {
14138 fn default() -> Self {
14139 Self {
14140 display: None,
14141 surface: None,
14142 }
14143 }
14144 }
14145 impl SurfaceSourceWaylandSurface {
14146 pub fn new() -> Self {
14147 Self::default()
14148 }
14149 pub(crate) fn to_ffi(
14150 &self,
14151 ) -> (ffi::WGPUSurfaceSourceWaylandSurface, ChainedStructStorage) {
14152 let mut storage = ChainedStructStorage::new();
14153 let mut raw: ffi::WGPUSurfaceSourceWaylandSurface = unsafe {
14154 std::mem::zeroed()
14155 };
14156 if let Some(value) = self.display {
14157 raw.display = value;
14158 }
14159 if let Some(value) = self.surface {
14160 raw.surface = value;
14161 }
14162 (raw, storage)
14163 }
14164 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceWaylandSurface) -> Self {
14165 Self {
14166 display: Some(value.display),
14167 surface: Some(value.surface),
14168 }
14169 }
14170 }
14171 pub struct SurfaceSourceWindowsHWND {
14172 pub hinstance: Option<*mut std::ffi::c_void>,
14173 pub hwnd: Option<*mut std::ffi::c_void>,
14174 }
14175 impl Default for SurfaceSourceWindowsHWND {
14176 fn default() -> Self {
14177 Self {
14178 hinstance: None,
14179 hwnd: None,
14180 }
14181 }
14182 }
14183 impl SurfaceSourceWindowsHWND {
14184 pub fn new() -> Self {
14185 Self::default()
14186 }
14187 pub(crate) fn to_ffi(
14188 &self,
14189 ) -> (ffi::WGPUSurfaceSourceWindowsHWND, ChainedStructStorage) {
14190 let mut storage = ChainedStructStorage::new();
14191 let mut raw: ffi::WGPUSurfaceSourceWindowsHWND = unsafe {
14192 std::mem::zeroed()
14193 };
14194 if let Some(value) = self.hinstance {
14195 raw.hinstance = value;
14196 }
14197 if let Some(value) = self.hwnd {
14198 raw.hwnd = value;
14199 }
14200 (raw, storage)
14201 }
14202 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceWindowsHWND) -> Self {
14203 Self {
14204 hinstance: Some(value.hinstance),
14205 hwnd: Some(value.hwnd),
14206 }
14207 }
14208 }
14209 pub struct SurfaceSourceXlibWindow {
14210 pub display: Option<*mut std::ffi::c_void>,
14211 pub window: Option<u64>,
14212 }
14213 impl Default for SurfaceSourceXlibWindow {
14214 fn default() -> Self {
14215 Self {
14216 display: None,
14217 window: None,
14218 }
14219 }
14220 }
14221 impl SurfaceSourceXlibWindow {
14222 pub fn new() -> Self {
14223 Self::default()
14224 }
14225 pub(crate) fn to_ffi(
14226 &self,
14227 ) -> (ffi::WGPUSurfaceSourceXlibWindow, ChainedStructStorage) {
14228 let mut storage = ChainedStructStorage::new();
14229 let mut raw: ffi::WGPUSurfaceSourceXlibWindow = unsafe {
14230 std::mem::zeroed()
14231 };
14232 if let Some(value) = self.display {
14233 raw.display = value;
14234 }
14235 if let Some(value) = self.window {
14236 raw.window = value;
14237 }
14238 (raw, storage)
14239 }
14240 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceXlibWindow) -> Self {
14241 Self {
14242 display: Some(value.display),
14243 window: Some(value.window),
14244 }
14245 }
14246 }
14247 pub struct SurfaceTexture {
14248 pub(crate) extensions: Vec<SurfaceTextureExtension>,
14249 pub texture: Option<Texture>,
14250 pub status: Option<SurfaceGetCurrentTextureStatus>,
14251 }
14252 impl Default for SurfaceTexture {
14253 fn default() -> Self {
14254 Self {
14255 extensions: Vec::new(),
14256 texture: None,
14257 status: None,
14258 }
14259 }
14260 }
14261 impl SurfaceTexture {
14262 pub fn new() -> Self {
14263 Self::default()
14264 }
14265 pub(crate) fn to_ffi(&self) -> (ffi::WGPUSurfaceTexture, ChainedStructStorage) {
14266 let mut storage = ChainedStructStorage::new();
14267 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14268 for ext in self.extensions.iter().rev() {
14269 next = ext.push_chain(&mut storage, next);
14270 }
14271 let mut raw: ffi::WGPUSurfaceTexture = unsafe { std::mem::zeroed() };
14272 raw.nextInChain = next;
14273 raw.texture = self
14274 .texture
14275 .as_ref()
14276 .map(|v| v.as_raw())
14277 .unwrap_or(std::ptr::null_mut());
14278 if let Some(value) = self.status {
14279 raw.status = value.into();
14280 } else {
14281 raw.status = 0 as ffi::WGPUSurfaceGetCurrentTextureStatus;
14282 }
14283 (raw, storage)
14284 }
14285 pub fn with_extension(mut self, extension: SurfaceTextureExtension) -> Self {
14286 self.extensions.push(extension);
14287 self
14288 }
14289 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceTexture) -> Self {
14290 Self {
14291 extensions: Vec::new(),
14292 texture: Some(unsafe { Texture::from_raw(value.texture) }),
14293 status: Some(value.status.into()),
14294 }
14295 }
14296 }
14297 pub struct TexelBufferBindingEntry {
14298 pub texel_buffer_view: Option<TexelBufferView>,
14299 }
14300 impl Default for TexelBufferBindingEntry {
14301 fn default() -> Self {
14302 Self { texel_buffer_view: None }
14303 }
14304 }
14305 impl TexelBufferBindingEntry {
14306 pub fn new() -> Self {
14307 Self::default()
14308 }
14309 pub(crate) fn to_ffi(
14310 &self,
14311 ) -> (ffi::WGPUTexelBufferBindingEntry, ChainedStructStorage) {
14312 let mut storage = ChainedStructStorage::new();
14313 let mut raw: ffi::WGPUTexelBufferBindingEntry = unsafe {
14314 std::mem::zeroed()
14315 };
14316 raw.texelBufferView = self
14317 .texel_buffer_view
14318 .as_ref()
14319 .map(|v| v.as_raw())
14320 .unwrap_or(std::ptr::null_mut());
14321 (raw, storage)
14322 }
14323 pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferBindingEntry) -> Self {
14324 Self {
14325 texel_buffer_view: Some(unsafe {
14326 TexelBufferView::from_raw(value.texelBufferView)
14327 }),
14328 }
14329 }
14330 }
14331 pub struct TexelBufferBindingLayout {
14332 pub access: Option<TexelBufferAccess>,
14333 pub format: Option<TextureFormat>,
14334 }
14335 impl Default for TexelBufferBindingLayout {
14336 fn default() -> Self {
14337 Self {
14338 access: Some(TexelBufferAccess::ReadWrite),
14339 format: None,
14340 }
14341 }
14342 }
14343 impl TexelBufferBindingLayout {
14344 pub fn new() -> Self {
14345 Self::default()
14346 }
14347 pub(crate) fn to_ffi(
14348 &self,
14349 ) -> (ffi::WGPUTexelBufferBindingLayout, ChainedStructStorage) {
14350 let mut storage = ChainedStructStorage::new();
14351 let mut raw: ffi::WGPUTexelBufferBindingLayout = unsafe {
14352 std::mem::zeroed()
14353 };
14354 if let Some(value) = self.access {
14355 raw.access = value.into();
14356 } else {
14357 raw.access = 0 as ffi::WGPUTexelBufferAccess;
14358 }
14359 if let Some(value) = self.format {
14360 raw.format = value.into();
14361 } else {
14362 raw.format = 0 as ffi::WGPUTextureFormat;
14363 }
14364 (raw, storage)
14365 }
14366 pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferBindingLayout) -> Self {
14367 Self {
14368 access: Some(value.access.into()),
14369 format: Some(value.format.into()),
14370 }
14371 }
14372 }
14373 pub struct TexelBufferViewDescriptor {
14374 pub(crate) extensions: Vec<TexelBufferViewDescriptorExtension>,
14375 pub label: Option<String>,
14376 pub format: Option<TextureFormat>,
14377 pub offset: Option<u64>,
14378 pub size: Option<u64>,
14379 }
14380 impl Default for TexelBufferViewDescriptor {
14381 fn default() -> Self {
14382 Self {
14383 extensions: Vec::new(),
14384 label: None,
14385 format: None,
14386 offset: Some(0),
14387 size: Some(WHOLE_SIZE),
14388 }
14389 }
14390 }
14391 impl TexelBufferViewDescriptor {
14392 pub fn new() -> Self {
14393 Self::default()
14394 }
14395 pub(crate) fn to_ffi(
14396 &self,
14397 ) -> (ffi::WGPUTexelBufferViewDescriptor, ChainedStructStorage) {
14398 let mut storage = ChainedStructStorage::new();
14399 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14400 for ext in self.extensions.iter().rev() {
14401 next = ext.push_chain(&mut storage, next);
14402 }
14403 let mut raw: ffi::WGPUTexelBufferViewDescriptor = unsafe {
14404 std::mem::zeroed()
14405 };
14406 raw.nextInChain = next;
14407 if let Some(value) = &self.label {
14408 raw.label = ffi::WGPUStringView {
14409 data: value.as_ptr().cast(),
14410 length: value.len(),
14411 };
14412 } else {
14413 raw.label = ffi::WGPUStringView {
14414 data: std::ptr::null(),
14415 length: 0,
14416 };
14417 }
14418 if let Some(value) = self.format {
14419 raw.format = value.into();
14420 } else {
14421 raw.format = 0 as ffi::WGPUTextureFormat;
14422 }
14423 if let Some(value) = self.offset {
14424 raw.offset = value;
14425 }
14426 if let Some(value) = self.size {
14427 raw.size = value;
14428 }
14429 (raw, storage)
14430 }
14431 pub fn with_extension(
14432 mut self,
14433 extension: TexelBufferViewDescriptorExtension,
14434 ) -> Self {
14435 self.extensions.push(extension);
14436 self
14437 }
14438 pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferViewDescriptor) -> Self {
14439 Self {
14440 extensions: Vec::new(),
14441 label: if value.label.data.is_null() || value.label.length == 0 {
14442 None
14443 } else {
14444 Some(string_view_to_string(value.label))
14445 },
14446 format: Some(value.format.into()),
14447 offset: Some(value.offset),
14448 size: Some(value.size),
14449 }
14450 }
14451 }
14452 pub struct TexelCopyBufferInfo {
14453 pub layout: Option<TexelCopyBufferLayout>,
14454 pub buffer: Option<Buffer>,
14455 }
14456 impl Default for TexelCopyBufferInfo {
14457 fn default() -> Self {
14458 Self { layout: None, buffer: None }
14459 }
14460 }
14461 impl TexelCopyBufferInfo {
14462 pub fn new() -> Self {
14463 Self::default()
14464 }
14465 pub(crate) fn to_ffi(
14466 &self,
14467 ) -> (ffi::WGPUTexelCopyBufferInfo, ChainedStructStorage) {
14468 let mut storage = ChainedStructStorage::new();
14469 let mut raw: ffi::WGPUTexelCopyBufferInfo = unsafe { std::mem::zeroed() };
14470 if let Some(value) = &self.layout {
14471 let (raw_value, storage_value) = value.to_ffi();
14472 raw.layout = raw_value;
14473 storage.push_storage(storage_value);
14474 }
14475 raw.buffer = self
14476 .buffer
14477 .as_ref()
14478 .map(|v| v.as_raw())
14479 .unwrap_or(std::ptr::null_mut());
14480 (raw, storage)
14481 }
14482 pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyBufferInfo) -> Self {
14483 Self {
14484 layout: Some(TexelCopyBufferLayout::from_ffi(value.layout)),
14485 buffer: Some(unsafe { Buffer::from_raw(value.buffer) }),
14486 }
14487 }
14488 }
14489 pub struct TexelCopyBufferLayout {
14490 pub offset: Option<u64>,
14491 pub bytes_per_row: Option<u32>,
14492 pub rows_per_image: Option<u32>,
14493 }
14494 impl Default for TexelCopyBufferLayout {
14495 fn default() -> Self {
14496 Self {
14497 offset: Some(0),
14498 bytes_per_row: Some(COPY_STRIDE_UNDEFINED),
14499 rows_per_image: Some(COPY_STRIDE_UNDEFINED),
14500 }
14501 }
14502 }
14503 impl TexelCopyBufferLayout {
14504 pub fn new() -> Self {
14505 Self::default()
14506 }
14507 pub(crate) fn to_ffi(
14508 &self,
14509 ) -> (ffi::WGPUTexelCopyBufferLayout, ChainedStructStorage) {
14510 let mut storage = ChainedStructStorage::new();
14511 let mut raw: ffi::WGPUTexelCopyBufferLayout = unsafe { std::mem::zeroed() };
14512 if let Some(value) = self.offset {
14513 raw.offset = value;
14514 }
14515 if let Some(value) = self.bytes_per_row {
14516 raw.bytesPerRow = value;
14517 }
14518 if let Some(value) = self.rows_per_image {
14519 raw.rowsPerImage = value;
14520 }
14521 (raw, storage)
14522 }
14523 pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyBufferLayout) -> Self {
14524 Self {
14525 offset: Some(value.offset),
14526 bytes_per_row: Some(value.bytesPerRow),
14527 rows_per_image: Some(value.rowsPerImage),
14528 }
14529 }
14530 }
14531 pub struct TexelCopyTextureInfo {
14532 pub texture: Option<Texture>,
14533 pub mip_level: Option<u32>,
14534 pub origin: Option<Origin3D>,
14535 pub aspect: Option<TextureAspect>,
14536 }
14537 impl Default for TexelCopyTextureInfo {
14538 fn default() -> Self {
14539 Self {
14540 texture: None,
14541 mip_level: Some(0),
14542 origin: None,
14543 aspect: Some(TextureAspect::All),
14544 }
14545 }
14546 }
14547 impl TexelCopyTextureInfo {
14548 pub fn new() -> Self {
14549 Self::default()
14550 }
14551 pub(crate) fn to_ffi(
14552 &self,
14553 ) -> (ffi::WGPUTexelCopyTextureInfo, ChainedStructStorage) {
14554 let mut storage = ChainedStructStorage::new();
14555 let mut raw: ffi::WGPUTexelCopyTextureInfo = unsafe { std::mem::zeroed() };
14556 raw.texture = self
14557 .texture
14558 .as_ref()
14559 .map(|v| v.as_raw())
14560 .unwrap_or(std::ptr::null_mut());
14561 if let Some(value) = self.mip_level {
14562 raw.mipLevel = value;
14563 }
14564 if let Some(value) = &self.origin {
14565 let (raw_value, storage_value) = value.to_ffi();
14566 raw.origin = raw_value;
14567 storage.push_storage(storage_value);
14568 }
14569 if let Some(value) = self.aspect {
14570 raw.aspect = value.into();
14571 } else {
14572 raw.aspect = 0 as ffi::WGPUTextureAspect;
14573 }
14574 (raw, storage)
14575 }
14576 pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyTextureInfo) -> Self {
14577 Self {
14578 texture: Some(unsafe { Texture::from_raw(value.texture) }),
14579 mip_level: Some(value.mipLevel),
14580 origin: Some(Origin3D::from_ffi(value.origin)),
14581 aspect: Some(value.aspect.into()),
14582 }
14583 }
14584 }
14585 pub struct TextureBindingLayout {
14586 pub(crate) extensions: Vec<TextureBindingLayoutExtension>,
14587 pub sample_type: Option<TextureSampleType>,
14588 pub view_dimension: Option<TextureViewDimension>,
14589 pub multisampled: Option<bool>,
14590 }
14591 impl Default for TextureBindingLayout {
14592 fn default() -> Self {
14593 Self {
14594 extensions: Vec::new(),
14595 sample_type: Some(TextureSampleType::Float),
14596 view_dimension: Some(TextureViewDimension::D2),
14597 multisampled: None,
14598 }
14599 }
14600 }
14601 impl TextureBindingLayout {
14602 pub fn new() -> Self {
14603 Self::default()
14604 }
14605 pub(crate) fn to_ffi(
14606 &self,
14607 ) -> (ffi::WGPUTextureBindingLayout, ChainedStructStorage) {
14608 let mut storage = ChainedStructStorage::new();
14609 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14610 for ext in self.extensions.iter().rev() {
14611 next = ext.push_chain(&mut storage, next);
14612 }
14613 let mut raw: ffi::WGPUTextureBindingLayout = unsafe { std::mem::zeroed() };
14614 raw.nextInChain = next;
14615 if let Some(value) = self.sample_type {
14616 raw.sampleType = value.into();
14617 } else {
14618 raw.sampleType = 0 as ffi::WGPUTextureSampleType;
14619 }
14620 if let Some(value) = self.view_dimension {
14621 raw.viewDimension = value.into();
14622 } else {
14623 raw.viewDimension = 0 as ffi::WGPUTextureViewDimension;
14624 }
14625 raw.multisampled = if self.multisampled.unwrap_or(false) { 1 } else { 0 };
14626 (raw, storage)
14627 }
14628 pub fn with_extension(
14629 mut self,
14630 extension: TextureBindingLayoutExtension,
14631 ) -> Self {
14632 self.extensions.push(extension);
14633 self
14634 }
14635 pub(crate) fn from_ffi(value: ffi::WGPUTextureBindingLayout) -> Self {
14636 Self {
14637 extensions: Vec::new(),
14638 sample_type: Some(value.sampleType.into()),
14639 view_dimension: Some(value.viewDimension.into()),
14640 multisampled: Some(value.multisampled != 0),
14641 }
14642 }
14643 }
14644 pub struct TextureComponentSwizzle {
14645 pub r: Option<ComponentSwizzle>,
14646 pub g: Option<ComponentSwizzle>,
14647 pub b: Option<ComponentSwizzle>,
14648 pub a: Option<ComponentSwizzle>,
14649 }
14650 impl Default for TextureComponentSwizzle {
14651 fn default() -> Self {
14652 Self {
14653 r: Some(ComponentSwizzle::R),
14654 g: Some(ComponentSwizzle::G),
14655 b: Some(ComponentSwizzle::B),
14656 a: Some(ComponentSwizzle::A),
14657 }
14658 }
14659 }
14660 impl TextureComponentSwizzle {
14661 pub fn new() -> Self {
14662 Self::default()
14663 }
14664 pub(crate) fn to_ffi(
14665 &self,
14666 ) -> (ffi::WGPUTextureComponentSwizzle, ChainedStructStorage) {
14667 let mut storage = ChainedStructStorage::new();
14668 let mut raw: ffi::WGPUTextureComponentSwizzle = unsafe {
14669 std::mem::zeroed()
14670 };
14671 if let Some(value) = self.r {
14672 raw.r = value.into();
14673 } else {
14674 raw.r = 0 as ffi::WGPUComponentSwizzle;
14675 }
14676 if let Some(value) = self.g {
14677 raw.g = value.into();
14678 } else {
14679 raw.g = 0 as ffi::WGPUComponentSwizzle;
14680 }
14681 if let Some(value) = self.b {
14682 raw.b = value.into();
14683 } else {
14684 raw.b = 0 as ffi::WGPUComponentSwizzle;
14685 }
14686 if let Some(value) = self.a {
14687 raw.a = value.into();
14688 } else {
14689 raw.a = 0 as ffi::WGPUComponentSwizzle;
14690 }
14691 (raw, storage)
14692 }
14693 pub(crate) fn from_ffi(value: ffi::WGPUTextureComponentSwizzle) -> Self {
14694 Self {
14695 r: Some(value.r.into()),
14696 g: Some(value.g.into()),
14697 b: Some(value.b.into()),
14698 a: Some(value.a.into()),
14699 }
14700 }
14701 }
14702 pub struct TextureComponentSwizzleDescriptor {
14703 pub swizzle: Option<TextureComponentSwizzle>,
14704 }
14705 impl Default for TextureComponentSwizzleDescriptor {
14706 fn default() -> Self {
14707 Self { swizzle: None }
14708 }
14709 }
14710 impl TextureComponentSwizzleDescriptor {
14711 pub fn new() -> Self {
14712 Self::default()
14713 }
14714 pub(crate) fn to_ffi(
14715 &self,
14716 ) -> (ffi::WGPUTextureComponentSwizzleDescriptor, ChainedStructStorage) {
14717 let mut storage = ChainedStructStorage::new();
14718 let mut raw: ffi::WGPUTextureComponentSwizzleDescriptor = unsafe {
14719 std::mem::zeroed()
14720 };
14721 if let Some(value) = &self.swizzle {
14722 let (raw_value, storage_value) = value.to_ffi();
14723 raw.swizzle = raw_value;
14724 storage.push_storage(storage_value);
14725 }
14726 (raw, storage)
14727 }
14728 pub(crate) fn from_ffi(
14729 value: ffi::WGPUTextureComponentSwizzleDescriptor,
14730 ) -> Self {
14731 Self {
14732 swizzle: Some(TextureComponentSwizzle::from_ffi(value.swizzle)),
14733 }
14734 }
14735 }
14736 pub struct TextureDescriptor {
14737 pub(crate) extensions: Vec<TextureDescriptorExtension>,
14738 pub label: Option<String>,
14739 pub usage: Option<TextureUsage>,
14740 pub dimension: Option<TextureDimension>,
14741 pub size: Option<Extent3D>,
14742 pub format: Option<TextureFormat>,
14743 pub mip_level_count: Option<u32>,
14744 pub sample_count: Option<u32>,
14745 pub view_formats: Option<Vec<TextureFormat>>,
14746 }
14747 impl Default for TextureDescriptor {
14748 fn default() -> Self {
14749 Self {
14750 extensions: Vec::new(),
14751 label: None,
14752 usage: None,
14753 dimension: Some(TextureDimension::D2),
14754 size: None,
14755 format: None,
14756 mip_level_count: Some(1),
14757 sample_count: Some(1),
14758 view_formats: None,
14759 }
14760 }
14761 }
14762 impl TextureDescriptor {
14763 pub fn new() -> Self {
14764 Self::default()
14765 }
14766 pub(crate) fn to_ffi(
14767 &self,
14768 ) -> (ffi::WGPUTextureDescriptor, ChainedStructStorage) {
14769 let mut storage = ChainedStructStorage::new();
14770 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14771 for ext in self.extensions.iter().rev() {
14772 next = ext.push_chain(&mut storage, next);
14773 }
14774 let mut raw: ffi::WGPUTextureDescriptor = unsafe { std::mem::zeroed() };
14775 raw.nextInChain = next;
14776 if let Some(value) = &self.label {
14777 raw.label = ffi::WGPUStringView {
14778 data: value.as_ptr().cast(),
14779 length: value.len(),
14780 };
14781 } else {
14782 raw.label = ffi::WGPUStringView {
14783 data: std::ptr::null(),
14784 length: 0,
14785 };
14786 }
14787 if let Some(value) = self.usage {
14788 raw.usage = value.into();
14789 } else {
14790 raw.usage = 0 as ffi::WGPUTextureUsage;
14791 }
14792 if let Some(value) = self.dimension {
14793 raw.dimension = value.into();
14794 } else {
14795 raw.dimension = 0 as ffi::WGPUTextureDimension;
14796 }
14797 if let Some(value) = &self.size {
14798 let (raw_value, storage_value) = value.to_ffi();
14799 raw.size = raw_value;
14800 storage.push_storage(storage_value);
14801 }
14802 if let Some(value) = self.format {
14803 raw.format = value.into();
14804 } else {
14805 raw.format = 0 as ffi::WGPUTextureFormat;
14806 }
14807 if let Some(value) = self.mip_level_count {
14808 raw.mipLevelCount = value;
14809 }
14810 if let Some(value) = self.sample_count {
14811 raw.sampleCount = value;
14812 }
14813 raw.viewFormatCount = self
14814 .view_formats
14815 .as_ref()
14816 .map(|v| v.len())
14817 .unwrap_or(0);
14818 if let Some(values) = &self.view_formats {
14819 let len_value = values.len();
14820 let raw_vec: Vec<ffi::WGPUTextureFormat> = values
14821 .iter()
14822 .map(|v| (*v).into())
14823 .collect();
14824 let ptr = storage.push_vec(raw_vec);
14825 raw.viewFormats = ptr;
14826 raw.viewFormatCount = len_value;
14827 } else {
14828 raw.viewFormats = std::ptr::null();
14829 raw.viewFormatCount = 0;
14830 }
14831 (raw, storage)
14832 }
14833 pub fn with_extension(mut self, extension: TextureDescriptorExtension) -> Self {
14834 self.extensions.push(extension);
14835 self
14836 }
14837 pub(crate) fn from_ffi(value: ffi::WGPUTextureDescriptor) -> Self {
14838 Self {
14839 extensions: Vec::new(),
14840 label: if value.label.data.is_null() || value.label.length == 0 {
14841 None
14842 } else {
14843 Some(string_view_to_string(value.label))
14844 },
14845 usage: Some(value.usage.into()),
14846 dimension: Some(value.dimension.into()),
14847 size: Some(Extent3D::from_ffi(value.size)),
14848 format: Some(value.format.into()),
14849 mip_level_count: Some(value.mipLevelCount),
14850 sample_count: Some(value.sampleCount),
14851 view_formats: if value.viewFormats.is_null() {
14852 None
14853 } else {
14854 Some(
14855 unsafe {
14856 std::slice::from_raw_parts(
14857 value.viewFormats,
14858 value.viewFormatCount as usize,
14859 )
14860 }
14861 .iter()
14862 .map(|raw| TextureFormat::from(*raw))
14863 .collect(),
14864 )
14865 },
14866 }
14867 }
14868 }
14869 pub struct TextureViewDescriptor {
14870 pub(crate) extensions: Vec<TextureViewDescriptorExtension>,
14871 pub label: Option<String>,
14872 pub format: Option<TextureFormat>,
14873 pub dimension: Option<TextureViewDimension>,
14874 pub base_mip_level: Option<u32>,
14875 pub mip_level_count: Option<u32>,
14876 pub base_array_layer: Option<u32>,
14877 pub array_layer_count: Option<u32>,
14878 pub aspect: Option<TextureAspect>,
14879 pub usage: Option<TextureUsage>,
14880 }
14881 impl Default for TextureViewDescriptor {
14882 fn default() -> Self {
14883 Self {
14884 extensions: Vec::new(),
14885 label: None,
14886 format: None,
14887 dimension: None,
14888 base_mip_level: Some(0),
14889 mip_level_count: Some(MIP_LEVEL_COUNT_UNDEFINED),
14890 base_array_layer: Some(0),
14891 array_layer_count: Some(ARRAY_LAYER_COUNT_UNDEFINED),
14892 aspect: Some(TextureAspect::All),
14893 usage: Some(TextureUsage::NONE),
14894 }
14895 }
14896 }
14897 impl TextureViewDescriptor {
14898 pub fn new() -> Self {
14899 Self::default()
14900 }
14901 pub(crate) fn to_ffi(
14902 &self,
14903 ) -> (ffi::WGPUTextureViewDescriptor, ChainedStructStorage) {
14904 let mut storage = ChainedStructStorage::new();
14905 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14906 for ext in self.extensions.iter().rev() {
14907 next = ext.push_chain(&mut storage, next);
14908 }
14909 let mut raw: ffi::WGPUTextureViewDescriptor = unsafe { std::mem::zeroed() };
14910 raw.nextInChain = next;
14911 if let Some(value) = &self.label {
14912 raw.label = ffi::WGPUStringView {
14913 data: value.as_ptr().cast(),
14914 length: value.len(),
14915 };
14916 } else {
14917 raw.label = ffi::WGPUStringView {
14918 data: std::ptr::null(),
14919 length: 0,
14920 };
14921 }
14922 if let Some(value) = self.format {
14923 raw.format = value.into();
14924 } else {
14925 raw.format = 0 as ffi::WGPUTextureFormat;
14926 }
14927 if let Some(value) = self.dimension {
14928 raw.dimension = value.into();
14929 } else {
14930 raw.dimension = 0 as ffi::WGPUTextureViewDimension;
14931 }
14932 if let Some(value) = self.base_mip_level {
14933 raw.baseMipLevel = value;
14934 }
14935 if let Some(value) = self.mip_level_count {
14936 raw.mipLevelCount = value;
14937 }
14938 if let Some(value) = self.base_array_layer {
14939 raw.baseArrayLayer = value;
14940 }
14941 if let Some(value) = self.array_layer_count {
14942 raw.arrayLayerCount = value;
14943 }
14944 if let Some(value) = self.aspect {
14945 raw.aspect = value.into();
14946 } else {
14947 raw.aspect = 0 as ffi::WGPUTextureAspect;
14948 }
14949 if let Some(value) = self.usage {
14950 raw.usage = value.into();
14951 } else {
14952 raw.usage = 0 as ffi::WGPUTextureUsage;
14953 }
14954 (raw, storage)
14955 }
14956 pub fn with_extension(
14957 mut self,
14958 extension: TextureViewDescriptorExtension,
14959 ) -> Self {
14960 self.extensions.push(extension);
14961 self
14962 }
14963 pub(crate) fn from_ffi(value: ffi::WGPUTextureViewDescriptor) -> Self {
14964 Self {
14965 extensions: Vec::new(),
14966 label: if value.label.data.is_null() || value.label.length == 0 {
14967 None
14968 } else {
14969 Some(string_view_to_string(value.label))
14970 },
14971 format: Some(value.format.into()),
14972 dimension: Some(value.dimension.into()),
14973 base_mip_level: Some(value.baseMipLevel),
14974 mip_level_count: Some(value.mipLevelCount),
14975 base_array_layer: Some(value.baseArrayLayer),
14976 array_layer_count: Some(value.arrayLayerCount),
14977 aspect: Some(value.aspect.into()),
14978 usage: Some(value.usage.into()),
14979 }
14980 }
14981 }
14982 pub struct VertexAttribute {
14983 pub(crate) extensions: Vec<VertexAttributeExtension>,
14984 pub format: Option<VertexFormat>,
14985 pub offset: Option<u64>,
14986 pub shader_location: Option<u32>,
14987 }
14988 impl Default for VertexAttribute {
14989 fn default() -> Self {
14990 Self {
14991 extensions: Vec::new(),
14992 format: None,
14993 offset: None,
14994 shader_location: None,
14995 }
14996 }
14997 }
14998 impl VertexAttribute {
14999 pub fn new() -> Self {
15000 Self::default()
15001 }
15002 pub(crate) fn to_ffi(&self) -> (ffi::WGPUVertexAttribute, ChainedStructStorage) {
15003 let mut storage = ChainedStructStorage::new();
15004 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15005 for ext in self.extensions.iter().rev() {
15006 next = ext.push_chain(&mut storage, next);
15007 }
15008 let mut raw: ffi::WGPUVertexAttribute = unsafe { std::mem::zeroed() };
15009 raw.nextInChain = next;
15010 if let Some(value) = self.format {
15011 raw.format = value.into();
15012 } else {
15013 raw.format = 0 as ffi::WGPUVertexFormat;
15014 }
15015 if let Some(value) = self.offset {
15016 raw.offset = value;
15017 }
15018 if let Some(value) = self.shader_location {
15019 raw.shaderLocation = value;
15020 }
15021 (raw, storage)
15022 }
15023 pub fn with_extension(mut self, extension: VertexAttributeExtension) -> Self {
15024 self.extensions.push(extension);
15025 self
15026 }
15027 pub(crate) fn from_ffi(value: ffi::WGPUVertexAttribute) -> Self {
15028 Self {
15029 extensions: Vec::new(),
15030 format: Some(value.format.into()),
15031 offset: Some(value.offset),
15032 shader_location: Some(value.shaderLocation),
15033 }
15034 }
15035 }
15036 pub struct VertexBufferLayout {
15037 pub(crate) extensions: Vec<VertexBufferLayoutExtension>,
15038 pub step_mode: Option<VertexStepMode>,
15039 pub array_stride: Option<u64>,
15040 pub attributes: Option<Vec<VertexAttribute>>,
15041 }
15042 impl Default for VertexBufferLayout {
15043 fn default() -> Self {
15044 Self {
15045 extensions: Vec::new(),
15046 step_mode: None,
15047 array_stride: None,
15048 attributes: None,
15049 }
15050 }
15051 }
15052 impl VertexBufferLayout {
15053 pub fn new() -> Self {
15054 Self::default()
15055 }
15056 pub(crate) fn to_ffi(
15057 &self,
15058 ) -> (ffi::WGPUVertexBufferLayout, ChainedStructStorage) {
15059 let mut storage = ChainedStructStorage::new();
15060 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15061 for ext in self.extensions.iter().rev() {
15062 next = ext.push_chain(&mut storage, next);
15063 }
15064 let mut raw: ffi::WGPUVertexBufferLayout = unsafe { std::mem::zeroed() };
15065 raw.nextInChain = next;
15066 if let Some(value) = self.step_mode {
15067 raw.stepMode = value.into();
15068 } else {
15069 raw.stepMode = 0 as ffi::WGPUVertexStepMode;
15070 }
15071 if let Some(value) = self.array_stride {
15072 raw.arrayStride = value;
15073 }
15074 raw.attributeCount = self.attributes.as_ref().map(|v| v.len()).unwrap_or(0);
15075 if let Some(values) = &self.attributes {
15076 let len_value = values.len();
15077 let mut raw_vec: Vec<ffi::WGPUVertexAttribute> = Vec::with_capacity(
15078 values.len(),
15079 );
15080 for item in values.iter() {
15081 let (raw_item, storage_item) = item.to_ffi();
15082 raw_vec.push(raw_item);
15083 storage.push_storage(storage_item);
15084 }
15085 let ptr = storage.push_vec(raw_vec);
15086 raw.attributes = ptr;
15087 raw.attributeCount = len_value;
15088 } else {
15089 raw.attributes = std::ptr::null();
15090 raw.attributeCount = 0;
15091 }
15092 (raw, storage)
15093 }
15094 pub fn with_extension(mut self, extension: VertexBufferLayoutExtension) -> Self {
15095 self.extensions.push(extension);
15096 self
15097 }
15098 pub(crate) fn from_ffi(value: ffi::WGPUVertexBufferLayout) -> Self {
15099 Self {
15100 extensions: Vec::new(),
15101 step_mode: Some(value.stepMode.into()),
15102 array_stride: Some(value.arrayStride),
15103 attributes: if value.attributes.is_null() {
15104 None
15105 } else {
15106 Some(
15107 unsafe {
15108 std::slice::from_raw_parts(
15109 value.attributes,
15110 value.attributeCount as usize,
15111 )
15112 }
15113 .iter()
15114 .map(|raw| VertexAttribute::from_ffi(*raw))
15115 .collect(),
15116 )
15117 },
15118 }
15119 }
15120 }
15121 pub struct VertexState {
15122 pub(crate) extensions: Vec<VertexStateExtension>,
15123 pub module: Option<ShaderModule>,
15124 pub entry_point: Option<String>,
15125 pub constants: Option<Vec<ConstantEntry>>,
15126 pub buffers: Option<Vec<VertexBufferLayout>>,
15127 }
15128 impl Default for VertexState {
15129 fn default() -> Self {
15130 Self {
15131 extensions: Vec::new(),
15132 module: None,
15133 entry_point: None,
15134 constants: None,
15135 buffers: None,
15136 }
15137 }
15138 }
15139 impl VertexState {
15140 pub fn new() -> Self {
15141 Self::default()
15142 }
15143 pub(crate) fn to_ffi(&self) -> (ffi::WGPUVertexState, ChainedStructStorage) {
15144 let mut storage = ChainedStructStorage::new();
15145 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15146 for ext in self.extensions.iter().rev() {
15147 next = ext.push_chain(&mut storage, next);
15148 }
15149 let mut raw: ffi::WGPUVertexState = unsafe { std::mem::zeroed() };
15150 raw.nextInChain = next;
15151 raw.module = self
15152 .module
15153 .as_ref()
15154 .map(|v| v.as_raw())
15155 .unwrap_or(std::ptr::null_mut());
15156 if let Some(value) = &self.entry_point {
15157 raw.entryPoint = ffi::WGPUStringView {
15158 data: value.as_ptr().cast(),
15159 length: value.len(),
15160 };
15161 } else {
15162 raw.entryPoint = ffi::WGPUStringView {
15163 data: std::ptr::null(),
15164 length: 0,
15165 };
15166 }
15167 raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
15168 if let Some(values) = &self.constants {
15169 let len_value = values.len();
15170 let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
15171 values.len(),
15172 );
15173 for item in values.iter() {
15174 let (raw_item, storage_item) = item.to_ffi();
15175 raw_vec.push(raw_item);
15176 storage.push_storage(storage_item);
15177 }
15178 let ptr = storage.push_vec(raw_vec);
15179 raw.constants = ptr;
15180 raw.constantCount = len_value;
15181 } else {
15182 raw.constants = std::ptr::null();
15183 raw.constantCount = 0;
15184 }
15185 raw.bufferCount = self.buffers.as_ref().map(|v| v.len()).unwrap_or(0);
15186 if let Some(values) = &self.buffers {
15187 let len_value = values.len();
15188 let mut raw_vec: Vec<ffi::WGPUVertexBufferLayout> = Vec::with_capacity(
15189 values.len(),
15190 );
15191 for item in values.iter() {
15192 let (raw_item, storage_item) = item.to_ffi();
15193 raw_vec.push(raw_item);
15194 storage.push_storage(storage_item);
15195 }
15196 let ptr = storage.push_vec(raw_vec);
15197 raw.buffers = ptr;
15198 raw.bufferCount = len_value;
15199 } else {
15200 raw.buffers = std::ptr::null();
15201 raw.bufferCount = 0;
15202 }
15203 (raw, storage)
15204 }
15205 pub fn with_extension(mut self, extension: VertexStateExtension) -> Self {
15206 self.extensions.push(extension);
15207 self
15208 }
15209 pub(crate) fn from_ffi(value: ffi::WGPUVertexState) -> Self {
15210 Self {
15211 extensions: Vec::new(),
15212 module: Some(unsafe { ShaderModule::from_raw(value.module) }),
15213 entry_point: if value.entryPoint.data.is_null()
15214 || value.entryPoint.length == 0
15215 {
15216 None
15217 } else {
15218 Some(string_view_to_string(value.entryPoint))
15219 },
15220 constants: if value.constants.is_null() {
15221 None
15222 } else {
15223 Some(
15224 unsafe {
15225 std::slice::from_raw_parts(
15226 value.constants,
15227 value.constantCount as usize,
15228 )
15229 }
15230 .iter()
15231 .map(|raw| ConstantEntry::from_ffi(*raw))
15232 .collect(),
15233 )
15234 },
15235 buffers: if value.buffers.is_null() {
15236 None
15237 } else {
15238 Some(
15239 unsafe {
15240 std::slice::from_raw_parts(
15241 value.buffers,
15242 value.bufferCount as usize,
15243 )
15244 }
15245 .iter()
15246 .map(|raw| VertexBufferLayout::from_ffi(*raw))
15247 .collect(),
15248 )
15249 },
15250 }
15251 }
15252 }
15253 pub struct YCbCrVkDescriptor {
15254 pub vk_format: Option<u32>,
15255 pub vk_y_cb_cr_model: Option<u32>,
15256 pub vk_y_cb_cr_range: Option<u32>,
15257 pub vk_component_swizzle_red: Option<u32>,
15258 pub vk_component_swizzle_green: Option<u32>,
15259 pub vk_component_swizzle_blue: Option<u32>,
15260 pub vk_component_swizzle_alpha: Option<u32>,
15261 pub vk_x_chroma_offset: Option<u32>,
15262 pub vk_y_chroma_offset: Option<u32>,
15263 pub vk_chroma_filter: Option<FilterMode>,
15264 pub force_explicit_reconstruction: Option<bool>,
15265 pub external_format: Option<u64>,
15266 }
15267 impl Default for YCbCrVkDescriptor {
15268 fn default() -> Self {
15269 Self {
15270 vk_format: Some(0),
15271 vk_y_cb_cr_model: Some(0),
15272 vk_y_cb_cr_range: Some(0),
15273 vk_component_swizzle_red: Some(0),
15274 vk_component_swizzle_green: Some(0),
15275 vk_component_swizzle_blue: Some(0),
15276 vk_component_swizzle_alpha: Some(0),
15277 vk_x_chroma_offset: Some(0),
15278 vk_y_chroma_offset: Some(0),
15279 vk_chroma_filter: Some(FilterMode::Nearest),
15280 force_explicit_reconstruction: None,
15281 external_format: Some(0),
15282 }
15283 }
15284 }
15285 impl YCbCrVkDescriptor {
15286 pub fn new() -> Self {
15287 Self::default()
15288 }
15289 pub(crate) fn to_ffi(
15290 &self,
15291 ) -> (ffi::WGPUYCbCrVkDescriptor, ChainedStructStorage) {
15292 let mut storage = ChainedStructStorage::new();
15293 let mut raw: ffi::WGPUYCbCrVkDescriptor = unsafe { std::mem::zeroed() };
15294 if let Some(value) = self.vk_format {
15295 raw.vkFormat = value;
15296 }
15297 if let Some(value) = self.vk_y_cb_cr_model {
15298 raw.vkYCbCrModel = value;
15299 }
15300 if let Some(value) = self.vk_y_cb_cr_range {
15301 raw.vkYCbCrRange = value;
15302 }
15303 if let Some(value) = self.vk_component_swizzle_red {
15304 raw.vkComponentSwizzleRed = value;
15305 }
15306 if let Some(value) = self.vk_component_swizzle_green {
15307 raw.vkComponentSwizzleGreen = value;
15308 }
15309 if let Some(value) = self.vk_component_swizzle_blue {
15310 raw.vkComponentSwizzleBlue = value;
15311 }
15312 if let Some(value) = self.vk_component_swizzle_alpha {
15313 raw.vkComponentSwizzleAlpha = value;
15314 }
15315 if let Some(value) = self.vk_x_chroma_offset {
15316 raw.vkXChromaOffset = value;
15317 }
15318 if let Some(value) = self.vk_y_chroma_offset {
15319 raw.vkYChromaOffset = value;
15320 }
15321 if let Some(value) = self.vk_chroma_filter {
15322 raw.vkChromaFilter = value.into();
15323 } else {
15324 raw.vkChromaFilter = 0 as ffi::WGPUFilterMode;
15325 }
15326 raw.forceExplicitReconstruction = if self
15327 .force_explicit_reconstruction
15328 .unwrap_or(false)
15329 {
15330 1
15331 } else {
15332 0
15333 };
15334 if let Some(value) = self.external_format {
15335 raw.externalFormat = value;
15336 }
15337 (raw, storage)
15338 }
15339 pub(crate) fn from_ffi(value: ffi::WGPUYCbCrVkDescriptor) -> Self {
15340 Self {
15341 vk_format: Some(value.vkFormat),
15342 vk_y_cb_cr_model: Some(value.vkYCbCrModel),
15343 vk_y_cb_cr_range: Some(value.vkYCbCrRange),
15344 vk_component_swizzle_red: Some(value.vkComponentSwizzleRed),
15345 vk_component_swizzle_green: Some(value.vkComponentSwizzleGreen),
15346 vk_component_swizzle_blue: Some(value.vkComponentSwizzleBlue),
15347 vk_component_swizzle_alpha: Some(value.vkComponentSwizzleAlpha),
15348 vk_x_chroma_offset: Some(value.vkXChromaOffset),
15349 vk_y_chroma_offset: Some(value.vkYChromaOffset),
15350 vk_chroma_filter: Some(value.vkChromaFilter.into()),
15351 force_explicit_reconstruction: Some(
15352 value.forceExplicitReconstruction != 0,
15353 ),
15354 external_format: Some(value.externalFormat),
15355 }
15356 }
15357 }
15358}
15359mod extensions {
15360 #![allow(dead_code, unused_imports)]
15361 use crate::ffi;
15362 use crate::generated::*;
15363 use std::any::Any;
15364 pub(crate) struct ChainedStructStorage {
15365 entries: Vec<Box<ffi::WGPUChainedStruct>>,
15366 buffers: Vec<Box<dyn Any>>,
15367 nested: Vec<ChainedStructStorage>,
15368 }
15369 impl ChainedStructStorage {
15370 pub(crate) fn new() -> Self {
15371 Self {
15372 entries: Vec::new(),
15373 buffers: Vec::new(),
15374 nested: Vec::new(),
15375 }
15376 }
15377 pub(crate) fn push(
15378 &mut self,
15379 s_type: ffi::WGPUSType,
15380 next: *mut ffi::WGPUChainedStruct,
15381 ) -> *mut ffi::WGPUChainedStruct {
15382 let mut node = Box::new(ffi::WGPUChainedStruct {
15383 next,
15384 sType: s_type,
15385 });
15386 let ptr = std::ptr::from_mut(node.as_mut());
15387 self.entries.push(node);
15388 ptr
15389 }
15390 pub(crate) fn push_value<T: 'static>(&mut self, value: T) -> *const T {
15391 let boxed = Box::new(value);
15392 let ptr = std::ptr::from_ref(boxed.as_ref());
15393 self.buffers.push(boxed);
15394 ptr
15395 }
15396 pub(crate) fn push_value_mut<T: 'static>(&mut self, value: T) -> *mut T {
15397 let mut boxed = Box::new(value);
15398 let ptr = std::ptr::from_mut(boxed.as_mut());
15399 self.buffers.push(boxed);
15400 ptr
15401 }
15402 pub(crate) fn push_vec<T: 'static>(&mut self, value: Vec<T>) -> *const T {
15403 let ptr = value.as_ptr();
15404 self.buffers.push(Box::new(value));
15405 ptr
15406 }
15407 pub(crate) fn push_vec_mut<T: 'static>(&mut self, value: Vec<T>) -> *mut T {
15408 let mut value = value;
15409 let ptr = value.as_mut_ptr();
15410 self.buffers.push(Box::new(value));
15411 ptr
15412 }
15413 pub(crate) fn push_any<T: 'static>(&mut self, value: T) {
15414 self.buffers.push(Box::new(value));
15415 }
15416 pub(crate) fn push_storage(&mut self, storage: ChainedStructStorage) {
15417 self.nested.push(storage);
15418 }
15419 }
15420 #[allow(dead_code)]
15421 pub enum AdapterInfoExtension {
15422 AdapterPropertiesD3D(AdapterPropertiesD3D),
15423 AdapterPropertiesWGPU(AdapterPropertiesWGPU),
15424 AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15425 AdapterPropertiesExplicitComputeSubgroupSizeConfigs,
15426 ),
15427 AdapterPropertiesMemoryHeaps(AdapterPropertiesMemoryHeaps),
15428 AdapterPropertiesSubgroupMatrixConfigs(AdapterPropertiesSubgroupMatrixConfigs),
15429 AdapterPropertiesVk(AdapterPropertiesVk),
15430 DawnAdapterPropertiesPowerPreference(DawnAdapterPropertiesPowerPreference),
15431 }
15432 impl std::convert::From<AdapterPropertiesD3D> for AdapterInfoExtension {
15433 fn from(ext: AdapterPropertiesD3D) -> Self {
15434 AdapterInfoExtension::AdapterPropertiesD3D(ext)
15435 }
15436 }
15437 impl std::convert::From<AdapterPropertiesWGPU> for AdapterInfoExtension {
15438 fn from(ext: AdapterPropertiesWGPU) -> Self {
15439 AdapterInfoExtension::AdapterPropertiesWGPU(ext)
15440 }
15441 }
15442 impl std::convert::From<AdapterPropertiesExplicitComputeSubgroupSizeConfigs>
15443 for AdapterInfoExtension {
15444 fn from(ext: AdapterPropertiesExplicitComputeSubgroupSizeConfigs) -> Self {
15445 AdapterInfoExtension::AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15446 ext,
15447 )
15448 }
15449 }
15450 impl std::convert::From<AdapterPropertiesMemoryHeaps> for AdapterInfoExtension {
15451 fn from(ext: AdapterPropertiesMemoryHeaps) -> Self {
15452 AdapterInfoExtension::AdapterPropertiesMemoryHeaps(ext)
15453 }
15454 }
15455 impl std::convert::From<AdapterPropertiesSubgroupMatrixConfigs>
15456 for AdapterInfoExtension {
15457 fn from(ext: AdapterPropertiesSubgroupMatrixConfigs) -> Self {
15458 AdapterInfoExtension::AdapterPropertiesSubgroupMatrixConfigs(ext)
15459 }
15460 }
15461 impl std::convert::From<AdapterPropertiesVk> for AdapterInfoExtension {
15462 fn from(ext: AdapterPropertiesVk) -> Self {
15463 AdapterInfoExtension::AdapterPropertiesVk(ext)
15464 }
15465 }
15466 impl std::convert::From<DawnAdapterPropertiesPowerPreference>
15467 for AdapterInfoExtension {
15468 fn from(ext: DawnAdapterPropertiesPowerPreference) -> Self {
15469 AdapterInfoExtension::DawnAdapterPropertiesPowerPreference(ext)
15470 }
15471 }
15472 impl AdapterInfoExtension {
15473 pub(crate) fn push_chain(
15474 &self,
15475 storage: &mut ChainedStructStorage,
15476 next: *mut ffi::WGPUChainedStruct,
15477 ) -> *mut ffi::WGPUChainedStruct {
15478 match self {
15479 AdapterInfoExtension::AdapterPropertiesD3D(value) => {
15480 let (mut raw, storage_value) = value.to_ffi();
15481 raw.chain.sType = SType::AdapterPropertiesD3D.into();
15482 raw.chain.next = next;
15483 storage.push_storage(storage_value);
15484 let raw_ptr = storage.push_value_mut(raw);
15485 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15486 }
15487 AdapterInfoExtension::AdapterPropertiesWGPU(value) => {
15488 let (mut raw, storage_value) = value.to_ffi();
15489 raw.chain.sType = SType::AdapterPropertiesWGPU.into();
15490 raw.chain.next = next;
15491 storage.push_storage(storage_value);
15492 let raw_ptr = storage.push_value_mut(raw);
15493 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15494 }
15495 AdapterInfoExtension::AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15496 value,
15497 ) => {
15498 let (mut raw, storage_value) = value.to_ffi();
15499 raw.chain.sType = SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs
15500 .into();
15501 raw.chain.next = next;
15502 storage.push_storage(storage_value);
15503 let raw_ptr = storage.push_value_mut(raw);
15504 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15505 }
15506 AdapterInfoExtension::AdapterPropertiesMemoryHeaps(value) => {
15507 let (mut raw, storage_value) = value.to_ffi();
15508 raw.chain.sType = SType::AdapterPropertiesMemoryHeaps.into();
15509 raw.chain.next = next;
15510 storage.push_storage(storage_value);
15511 let raw_ptr = storage.push_value_mut(raw);
15512 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15513 }
15514 AdapterInfoExtension::AdapterPropertiesSubgroupMatrixConfigs(value) => {
15515 let (mut raw, storage_value) = value.to_ffi();
15516 raw.chain.sType = SType::AdapterPropertiesSubgroupMatrixConfigs
15517 .into();
15518 raw.chain.next = next;
15519 storage.push_storage(storage_value);
15520 let raw_ptr = storage.push_value_mut(raw);
15521 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15522 }
15523 AdapterInfoExtension::AdapterPropertiesVk(value) => {
15524 let (mut raw, storage_value) = value.to_ffi();
15525 raw.chain.sType = SType::AdapterPropertiesVk.into();
15526 raw.chain.next = next;
15527 storage.push_storage(storage_value);
15528 let raw_ptr = storage.push_value_mut(raw);
15529 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15530 }
15531 AdapterInfoExtension::DawnAdapterPropertiesPowerPreference(value) => {
15532 let (mut raw, storage_value) = value.to_ffi();
15533 raw.chain.sType = SType::DawnAdapterPropertiesPowerPreference.into();
15534 raw.chain.next = next;
15535 storage.push_storage(storage_value);
15536 let raw_ptr = storage.push_value_mut(raw);
15537 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15538 }
15539 }
15540 }
15541 }
15542 #[allow(dead_code)]
15543 pub enum BindGroupDescriptorExtension {}
15544 impl BindGroupDescriptorExtension {
15545 pub(crate) fn push_chain(
15546 &self,
15547 storage: &mut ChainedStructStorage,
15548 next: *mut ffi::WGPUChainedStruct,
15549 ) -> *mut ffi::WGPUChainedStruct {
15550 let _ = self;
15551 let _ = storage;
15552 next
15553 }
15554 }
15555 #[allow(dead_code)]
15556 pub enum BindGroupEntryExtension {
15557 ExternalTextureBindingEntry(ExternalTextureBindingEntry),
15558 TexelBufferBindingEntry(TexelBufferBindingEntry),
15559 }
15560 impl std::convert::From<ExternalTextureBindingEntry> for BindGroupEntryExtension {
15561 fn from(ext: ExternalTextureBindingEntry) -> Self {
15562 BindGroupEntryExtension::ExternalTextureBindingEntry(ext)
15563 }
15564 }
15565 impl std::convert::From<TexelBufferBindingEntry> for BindGroupEntryExtension {
15566 fn from(ext: TexelBufferBindingEntry) -> Self {
15567 BindGroupEntryExtension::TexelBufferBindingEntry(ext)
15568 }
15569 }
15570 impl BindGroupEntryExtension {
15571 pub(crate) fn push_chain(
15572 &self,
15573 storage: &mut ChainedStructStorage,
15574 next: *mut ffi::WGPUChainedStruct,
15575 ) -> *mut ffi::WGPUChainedStruct {
15576 match self {
15577 BindGroupEntryExtension::ExternalTextureBindingEntry(value) => {
15578 let (mut raw, storage_value) = value.to_ffi();
15579 raw.chain.sType = SType::ExternalTextureBindingEntry.into();
15580 raw.chain.next = next;
15581 storage.push_storage(storage_value);
15582 let raw_ptr = storage.push_value_mut(raw);
15583 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15584 }
15585 BindGroupEntryExtension::TexelBufferBindingEntry(value) => {
15586 let (mut raw, storage_value) = value.to_ffi();
15587 raw.chain.sType = SType::TexelBufferBindingEntry.into();
15588 raw.chain.next = next;
15589 storage.push_storage(storage_value);
15590 let raw_ptr = storage.push_value_mut(raw);
15591 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15592 }
15593 }
15594 }
15595 }
15596 #[allow(dead_code)]
15597 pub enum BindGroupLayoutDescriptorExtension {}
15598 impl BindGroupLayoutDescriptorExtension {
15599 pub(crate) fn push_chain(
15600 &self,
15601 storage: &mut ChainedStructStorage,
15602 next: *mut ffi::WGPUChainedStruct,
15603 ) -> *mut ffi::WGPUChainedStruct {
15604 let _ = self;
15605 let _ = storage;
15606 next
15607 }
15608 }
15609 #[allow(dead_code)]
15610 pub enum BindGroupLayoutEntryExtension {
15611 ExternalTextureBindingLayout(ExternalTextureBindingLayout),
15612 StaticSamplerBindingLayout(StaticSamplerBindingLayout),
15613 TexelBufferBindingLayout(TexelBufferBindingLayout),
15614 }
15615 impl std::convert::From<ExternalTextureBindingLayout>
15616 for BindGroupLayoutEntryExtension {
15617 fn from(ext: ExternalTextureBindingLayout) -> Self {
15618 BindGroupLayoutEntryExtension::ExternalTextureBindingLayout(ext)
15619 }
15620 }
15621 impl std::convert::From<StaticSamplerBindingLayout>
15622 for BindGroupLayoutEntryExtension {
15623 fn from(ext: StaticSamplerBindingLayout) -> Self {
15624 BindGroupLayoutEntryExtension::StaticSamplerBindingLayout(ext)
15625 }
15626 }
15627 impl std::convert::From<TexelBufferBindingLayout> for BindGroupLayoutEntryExtension {
15628 fn from(ext: TexelBufferBindingLayout) -> Self {
15629 BindGroupLayoutEntryExtension::TexelBufferBindingLayout(ext)
15630 }
15631 }
15632 impl BindGroupLayoutEntryExtension {
15633 pub(crate) fn push_chain(
15634 &self,
15635 storage: &mut ChainedStructStorage,
15636 next: *mut ffi::WGPUChainedStruct,
15637 ) -> *mut ffi::WGPUChainedStruct {
15638 match self {
15639 BindGroupLayoutEntryExtension::ExternalTextureBindingLayout(value) => {
15640 let (mut raw, storage_value) = value.to_ffi();
15641 raw.chain.sType = SType::ExternalTextureBindingLayout.into();
15642 raw.chain.next = next;
15643 storage.push_storage(storage_value);
15644 let raw_ptr = storage.push_value_mut(raw);
15645 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15646 }
15647 BindGroupLayoutEntryExtension::StaticSamplerBindingLayout(value) => {
15648 let (mut raw, storage_value) = value.to_ffi();
15649 raw.chain.sType = SType::StaticSamplerBindingLayout.into();
15650 raw.chain.next = next;
15651 storage.push_storage(storage_value);
15652 let raw_ptr = storage.push_value_mut(raw);
15653 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15654 }
15655 BindGroupLayoutEntryExtension::TexelBufferBindingLayout(value) => {
15656 let (mut raw, storage_value) = value.to_ffi();
15657 raw.chain.sType = SType::TexelBufferBindingLayout.into();
15658 raw.chain.next = next;
15659 storage.push_storage(storage_value);
15660 let raw_ptr = storage.push_value_mut(raw);
15661 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15662 }
15663 }
15664 }
15665 }
15666 #[allow(dead_code)]
15667 pub enum BindingResourceExtension {}
15668 impl BindingResourceExtension {
15669 pub(crate) fn push_chain(
15670 &self,
15671 storage: &mut ChainedStructStorage,
15672 next: *mut ffi::WGPUChainedStruct,
15673 ) -> *mut ffi::WGPUChainedStruct {
15674 let _ = self;
15675 let _ = storage;
15676 next
15677 }
15678 }
15679 #[allow(dead_code)]
15680 pub enum BufferBindingLayoutExtension {}
15681 impl BufferBindingLayoutExtension {
15682 pub(crate) fn push_chain(
15683 &self,
15684 storage: &mut ChainedStructStorage,
15685 next: *mut ffi::WGPUChainedStruct,
15686 ) -> *mut ffi::WGPUChainedStruct {
15687 let _ = self;
15688 let _ = storage;
15689 next
15690 }
15691 }
15692 #[allow(dead_code)]
15693 pub enum BufferDescriptorExtension {
15694 BufferHostMappedPointer(BufferHostMappedPointer),
15695 DawnBufferDescriptorErrorInfoFromWireClient(
15696 DawnBufferDescriptorErrorInfoFromWireClient,
15697 ),
15698 DawnFakeBufferOOMForTesting(DawnFakeBufferOOMForTesting),
15699 }
15700 impl std::convert::From<BufferHostMappedPointer> for BufferDescriptorExtension {
15701 fn from(ext: BufferHostMappedPointer) -> Self {
15702 BufferDescriptorExtension::BufferHostMappedPointer(ext)
15703 }
15704 }
15705 impl std::convert::From<DawnBufferDescriptorErrorInfoFromWireClient>
15706 for BufferDescriptorExtension {
15707 fn from(ext: DawnBufferDescriptorErrorInfoFromWireClient) -> Self {
15708 BufferDescriptorExtension::DawnBufferDescriptorErrorInfoFromWireClient(ext)
15709 }
15710 }
15711 impl std::convert::From<DawnFakeBufferOOMForTesting> for BufferDescriptorExtension {
15712 fn from(ext: DawnFakeBufferOOMForTesting) -> Self {
15713 BufferDescriptorExtension::DawnFakeBufferOOMForTesting(ext)
15714 }
15715 }
15716 impl BufferDescriptorExtension {
15717 pub(crate) fn push_chain(
15718 &self,
15719 storage: &mut ChainedStructStorage,
15720 next: *mut ffi::WGPUChainedStruct,
15721 ) -> *mut ffi::WGPUChainedStruct {
15722 match self {
15723 BufferDescriptorExtension::BufferHostMappedPointer(value) => {
15724 let (mut raw, storage_value) = value.to_ffi();
15725 raw.chain.sType = SType::BufferHostMappedPointer.into();
15726 raw.chain.next = next;
15727 storage.push_storage(storage_value);
15728 let raw_ptr = storage.push_value_mut(raw);
15729 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15730 }
15731 BufferDescriptorExtension::DawnBufferDescriptorErrorInfoFromWireClient(
15732 value,
15733 ) => {
15734 let (mut raw, storage_value) = value.to_ffi();
15735 raw.chain.sType = SType::DawnBufferDescriptorErrorInfoFromWireClient
15736 .into();
15737 raw.chain.next = next;
15738 storage.push_storage(storage_value);
15739 let raw_ptr = storage.push_value_mut(raw);
15740 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15741 }
15742 BufferDescriptorExtension::DawnFakeBufferOOMForTesting(value) => {
15743 let (mut raw, storage_value) = value.to_ffi();
15744 raw.chain.sType = SType::DawnFakeBufferOOMForTesting.into();
15745 raw.chain.next = next;
15746 storage.push_storage(storage_value);
15747 let raw_ptr = storage.push_value_mut(raw);
15748 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15749 }
15750 }
15751 }
15752 }
15753 #[allow(dead_code)]
15754 pub enum ColorTargetStateExtension {
15755 ColorTargetStateExpandResolveTextureDawn(
15756 ColorTargetStateExpandResolveTextureDawn,
15757 ),
15758 }
15759 impl std::convert::From<ColorTargetStateExpandResolveTextureDawn>
15760 for ColorTargetStateExtension {
15761 fn from(ext: ColorTargetStateExpandResolveTextureDawn) -> Self {
15762 ColorTargetStateExtension::ColorTargetStateExpandResolveTextureDawn(ext)
15763 }
15764 }
15765 impl ColorTargetStateExtension {
15766 pub(crate) fn push_chain(
15767 &self,
15768 storage: &mut ChainedStructStorage,
15769 next: *mut ffi::WGPUChainedStruct,
15770 ) -> *mut ffi::WGPUChainedStruct {
15771 match self {
15772 ColorTargetStateExtension::ColorTargetStateExpandResolveTextureDawn(
15773 value,
15774 ) => {
15775 let (mut raw, storage_value) = value.to_ffi();
15776 raw.chain.sType = SType::ColorTargetStateExpandResolveTextureDawn
15777 .into();
15778 raw.chain.next = next;
15779 storage.push_storage(storage_value);
15780 let raw_ptr = storage.push_value_mut(raw);
15781 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15782 }
15783 }
15784 }
15785 }
15786 #[allow(dead_code)]
15787 pub enum CommandBufferDescriptorExtension {}
15788 impl CommandBufferDescriptorExtension {
15789 pub(crate) fn push_chain(
15790 &self,
15791 storage: &mut ChainedStructStorage,
15792 next: *mut ffi::WGPUChainedStruct,
15793 ) -> *mut ffi::WGPUChainedStruct {
15794 let _ = self;
15795 let _ = storage;
15796 next
15797 }
15798 }
15799 #[allow(dead_code)]
15800 pub enum CommandEncoderDescriptorExtension {
15801 DawnEncoderInternalUsageDescriptor(DawnEncoderInternalUsageDescriptor),
15802 }
15803 impl std::convert::From<DawnEncoderInternalUsageDescriptor>
15804 for CommandEncoderDescriptorExtension {
15805 fn from(ext: DawnEncoderInternalUsageDescriptor) -> Self {
15806 CommandEncoderDescriptorExtension::DawnEncoderInternalUsageDescriptor(ext)
15807 }
15808 }
15809 impl CommandEncoderDescriptorExtension {
15810 pub(crate) fn push_chain(
15811 &self,
15812 storage: &mut ChainedStructStorage,
15813 next: *mut ffi::WGPUChainedStruct,
15814 ) -> *mut ffi::WGPUChainedStruct {
15815 match self {
15816 CommandEncoderDescriptorExtension::DawnEncoderInternalUsageDescriptor(
15817 value,
15818 ) => {
15819 let (mut raw, storage_value) = value.to_ffi();
15820 raw.chain.sType = SType::DawnEncoderInternalUsageDescriptor.into();
15821 raw.chain.next = next;
15822 storage.push_storage(storage_value);
15823 let raw_ptr = storage.push_value_mut(raw);
15824 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15825 }
15826 }
15827 }
15828 }
15829 #[allow(dead_code)]
15830 pub enum CompilationInfoExtension {}
15831 impl CompilationInfoExtension {
15832 pub(crate) fn push_chain(
15833 &self,
15834 storage: &mut ChainedStructStorage,
15835 next: *mut ffi::WGPUChainedStruct,
15836 ) -> *mut ffi::WGPUChainedStruct {
15837 let _ = self;
15838 let _ = storage;
15839 next
15840 }
15841 }
15842 #[allow(dead_code)]
15843 pub enum CompilationMessageExtension {
15844 DawnCompilationMessageUtf16(DawnCompilationMessageUtf16),
15845 }
15846 impl std::convert::From<DawnCompilationMessageUtf16>
15847 for CompilationMessageExtension {
15848 fn from(ext: DawnCompilationMessageUtf16) -> Self {
15849 CompilationMessageExtension::DawnCompilationMessageUtf16(ext)
15850 }
15851 }
15852 impl CompilationMessageExtension {
15853 pub(crate) fn push_chain(
15854 &self,
15855 storage: &mut ChainedStructStorage,
15856 next: *mut ffi::WGPUChainedStruct,
15857 ) -> *mut ffi::WGPUChainedStruct {
15858 match self {
15859 CompilationMessageExtension::DawnCompilationMessageUtf16(value) => {
15860 let (mut raw, storage_value) = value.to_ffi();
15861 raw.chain.sType = SType::DawnCompilationMessageUtf16.into();
15862 raw.chain.next = next;
15863 storage.push_storage(storage_value);
15864 let raw_ptr = storage.push_value_mut(raw);
15865 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15866 }
15867 }
15868 }
15869 }
15870 #[allow(dead_code)]
15871 pub enum ComputePassDescriptorExtension {}
15872 impl ComputePassDescriptorExtension {
15873 pub(crate) fn push_chain(
15874 &self,
15875 storage: &mut ChainedStructStorage,
15876 next: *mut ffi::WGPUChainedStruct,
15877 ) -> *mut ffi::WGPUChainedStruct {
15878 let _ = self;
15879 let _ = storage;
15880 next
15881 }
15882 }
15883 #[allow(dead_code)]
15884 pub enum ComputePipelineDescriptorExtension {}
15885 impl ComputePipelineDescriptorExtension {
15886 pub(crate) fn push_chain(
15887 &self,
15888 storage: &mut ChainedStructStorage,
15889 next: *mut ffi::WGPUChainedStruct,
15890 ) -> *mut ffi::WGPUChainedStruct {
15891 let _ = self;
15892 let _ = storage;
15893 next
15894 }
15895 }
15896 #[allow(dead_code)]
15897 pub enum ComputeStateExtension {}
15898 impl ComputeStateExtension {
15899 pub(crate) fn push_chain(
15900 &self,
15901 storage: &mut ChainedStructStorage,
15902 next: *mut ffi::WGPUChainedStruct,
15903 ) -> *mut ffi::WGPUChainedStruct {
15904 let _ = self;
15905 let _ = storage;
15906 next
15907 }
15908 }
15909 #[allow(dead_code)]
15910 pub enum ConstantEntryExtension {}
15911 impl ConstantEntryExtension {
15912 pub(crate) fn push_chain(
15913 &self,
15914 storage: &mut ChainedStructStorage,
15915 next: *mut ffi::WGPUChainedStruct,
15916 ) -> *mut ffi::WGPUChainedStruct {
15917 let _ = self;
15918 let _ = storage;
15919 next
15920 }
15921 }
15922 #[allow(dead_code)]
15923 pub enum CopyTextureForBrowserOptionsExtension {}
15924 impl CopyTextureForBrowserOptionsExtension {
15925 pub(crate) fn push_chain(
15926 &self,
15927 storage: &mut ChainedStructStorage,
15928 next: *mut ffi::WGPUChainedStruct,
15929 ) -> *mut ffi::WGPUChainedStruct {
15930 let _ = self;
15931 let _ = storage;
15932 next
15933 }
15934 }
15935 #[allow(dead_code)]
15936 pub enum DawnFormatCapabilitiesExtension {
15937 DawnDrmFormatCapabilities(DawnDrmFormatCapabilities),
15938 }
15939 impl std::convert::From<DawnDrmFormatCapabilities>
15940 for DawnFormatCapabilitiesExtension {
15941 fn from(ext: DawnDrmFormatCapabilities) -> Self {
15942 DawnFormatCapabilitiesExtension::DawnDrmFormatCapabilities(ext)
15943 }
15944 }
15945 impl DawnFormatCapabilitiesExtension {
15946 pub(crate) fn push_chain(
15947 &self,
15948 storage: &mut ChainedStructStorage,
15949 next: *mut ffi::WGPUChainedStruct,
15950 ) -> *mut ffi::WGPUChainedStruct {
15951 match self {
15952 DawnFormatCapabilitiesExtension::DawnDrmFormatCapabilities(value) => {
15953 let (mut raw, storage_value) = value.to_ffi();
15954 raw.chain.sType = SType::DawnDrmFormatCapabilities.into();
15955 raw.chain.next = next;
15956 storage.push_storage(storage_value);
15957 let raw_ptr = storage.push_value_mut(raw);
15958 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15959 }
15960 }
15961 }
15962 }
15963 #[allow(dead_code)]
15964 pub enum DepthStencilStateExtension {}
15965 impl DepthStencilStateExtension {
15966 pub(crate) fn push_chain(
15967 &self,
15968 storage: &mut ChainedStructStorage,
15969 next: *mut ffi::WGPUChainedStruct,
15970 ) -> *mut ffi::WGPUChainedStruct {
15971 let _ = self;
15972 let _ = storage;
15973 next
15974 }
15975 }
15976 #[allow(dead_code)]
15977 pub enum DeviceDescriptorExtension {
15978 DawnCacheDeviceDescriptor(DawnCacheDeviceDescriptor),
15979 DawnConsumeAdapterDescriptor(DawnConsumeAdapterDescriptor),
15980 DawnDeviceAllocatorControl(DawnDeviceAllocatorControl),
15981 DawnFakeDeviceInitializeErrorForTesting(DawnFakeDeviceInitializeErrorForTesting),
15982 DawnTogglesDescriptor(DawnTogglesDescriptor),
15983 }
15984 impl std::convert::From<DawnCacheDeviceDescriptor> for DeviceDescriptorExtension {
15985 fn from(ext: DawnCacheDeviceDescriptor) -> Self {
15986 DeviceDescriptorExtension::DawnCacheDeviceDescriptor(ext)
15987 }
15988 }
15989 impl std::convert::From<DawnConsumeAdapterDescriptor> for DeviceDescriptorExtension {
15990 fn from(ext: DawnConsumeAdapterDescriptor) -> Self {
15991 DeviceDescriptorExtension::DawnConsumeAdapterDescriptor(ext)
15992 }
15993 }
15994 impl std::convert::From<DawnDeviceAllocatorControl> for DeviceDescriptorExtension {
15995 fn from(ext: DawnDeviceAllocatorControl) -> Self {
15996 DeviceDescriptorExtension::DawnDeviceAllocatorControl(ext)
15997 }
15998 }
15999 impl std::convert::From<DawnFakeDeviceInitializeErrorForTesting>
16000 for DeviceDescriptorExtension {
16001 fn from(ext: DawnFakeDeviceInitializeErrorForTesting) -> Self {
16002 DeviceDescriptorExtension::DawnFakeDeviceInitializeErrorForTesting(ext)
16003 }
16004 }
16005 impl std::convert::From<DawnTogglesDescriptor> for DeviceDescriptorExtension {
16006 fn from(ext: DawnTogglesDescriptor) -> Self {
16007 DeviceDescriptorExtension::DawnTogglesDescriptor(ext)
16008 }
16009 }
16010 impl DeviceDescriptorExtension {
16011 pub(crate) fn push_chain(
16012 &self,
16013 storage: &mut ChainedStructStorage,
16014 next: *mut ffi::WGPUChainedStruct,
16015 ) -> *mut ffi::WGPUChainedStruct {
16016 match self {
16017 DeviceDescriptorExtension::DawnCacheDeviceDescriptor(value) => {
16018 let (mut raw, storage_value) = value.to_ffi();
16019 raw.chain.sType = SType::DawnCacheDeviceDescriptor.into();
16020 raw.chain.next = next;
16021 storage.push_storage(storage_value);
16022 let raw_ptr = storage.push_value_mut(raw);
16023 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16024 }
16025 DeviceDescriptorExtension::DawnConsumeAdapterDescriptor(value) => {
16026 let (mut raw, storage_value) = value.to_ffi();
16027 raw.chain.sType = SType::DawnConsumeAdapterDescriptor.into();
16028 raw.chain.next = next;
16029 storage.push_storage(storage_value);
16030 let raw_ptr = storage.push_value_mut(raw);
16031 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16032 }
16033 DeviceDescriptorExtension::DawnDeviceAllocatorControl(value) => {
16034 let (mut raw, storage_value) = value.to_ffi();
16035 raw.chain.sType = SType::DawnDeviceAllocatorControl.into();
16036 raw.chain.next = next;
16037 storage.push_storage(storage_value);
16038 let raw_ptr = storage.push_value_mut(raw);
16039 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16040 }
16041 DeviceDescriptorExtension::DawnFakeDeviceInitializeErrorForTesting(
16042 value,
16043 ) => {
16044 let (mut raw, storage_value) = value.to_ffi();
16045 raw.chain.sType = SType::DawnFakeDeviceInitializeErrorForTesting
16046 .into();
16047 raw.chain.next = next;
16048 storage.push_storage(storage_value);
16049 let raw_ptr = storage.push_value_mut(raw);
16050 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16051 }
16052 DeviceDescriptorExtension::DawnTogglesDescriptor(value) => {
16053 let (mut raw, storage_value) = value.to_ffi();
16054 raw.chain.sType = SType::DawnTogglesDescriptor.into();
16055 raw.chain.next = next;
16056 storage.push_storage(storage_value);
16057 let raw_ptr = storage.push_value_mut(raw);
16058 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16059 }
16060 }
16061 }
16062 }
16063 #[allow(dead_code)]
16064 pub enum ExternalTextureDescriptorExtension {}
16065 impl ExternalTextureDescriptorExtension {
16066 pub(crate) fn push_chain(
16067 &self,
16068 storage: &mut ChainedStructStorage,
16069 next: *mut ffi::WGPUChainedStruct,
16070 ) -> *mut ffi::WGPUChainedStruct {
16071 let _ = self;
16072 let _ = storage;
16073 next
16074 }
16075 }
16076 #[allow(dead_code)]
16077 pub enum FragmentStateExtension {}
16078 impl FragmentStateExtension {
16079 pub(crate) fn push_chain(
16080 &self,
16081 storage: &mut ChainedStructStorage,
16082 next: *mut ffi::WGPUChainedStruct,
16083 ) -> *mut ffi::WGPUChainedStruct {
16084 let _ = self;
16085 let _ = storage;
16086 next
16087 }
16088 }
16089 #[allow(dead_code)]
16090 pub enum ImageCopyExternalTextureExtension {}
16091 impl ImageCopyExternalTextureExtension {
16092 pub(crate) fn push_chain(
16093 &self,
16094 storage: &mut ChainedStructStorage,
16095 next: *mut ffi::WGPUChainedStruct,
16096 ) -> *mut ffi::WGPUChainedStruct {
16097 let _ = self;
16098 let _ = storage;
16099 next
16100 }
16101 }
16102 #[allow(dead_code)]
16103 pub enum InstanceDescriptorExtension {
16104 DawnWGSLBlocklist(DawnWGSLBlocklist),
16105 DawnTogglesDescriptor(DawnTogglesDescriptor),
16106 DawnWireWGSLControl(DawnWireWGSLControl),
16107 }
16108 impl std::convert::From<DawnWGSLBlocklist> for InstanceDescriptorExtension {
16109 fn from(ext: DawnWGSLBlocklist) -> Self {
16110 InstanceDescriptorExtension::DawnWGSLBlocklist(ext)
16111 }
16112 }
16113 impl std::convert::From<DawnTogglesDescriptor> for InstanceDescriptorExtension {
16114 fn from(ext: DawnTogglesDescriptor) -> Self {
16115 InstanceDescriptorExtension::DawnTogglesDescriptor(ext)
16116 }
16117 }
16118 impl std::convert::From<DawnWireWGSLControl> for InstanceDescriptorExtension {
16119 fn from(ext: DawnWireWGSLControl) -> Self {
16120 InstanceDescriptorExtension::DawnWireWGSLControl(ext)
16121 }
16122 }
16123 impl InstanceDescriptorExtension {
16124 pub(crate) fn push_chain(
16125 &self,
16126 storage: &mut ChainedStructStorage,
16127 next: *mut ffi::WGPUChainedStruct,
16128 ) -> *mut ffi::WGPUChainedStruct {
16129 match self {
16130 InstanceDescriptorExtension::DawnWGSLBlocklist(value) => {
16131 let (mut raw, storage_value) = value.to_ffi();
16132 raw.chain.sType = SType::DawnWGSLBlocklist.into();
16133 raw.chain.next = next;
16134 storage.push_storage(storage_value);
16135 let raw_ptr = storage.push_value_mut(raw);
16136 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16137 }
16138 InstanceDescriptorExtension::DawnTogglesDescriptor(value) => {
16139 let (mut raw, storage_value) = value.to_ffi();
16140 raw.chain.sType = SType::DawnTogglesDescriptor.into();
16141 raw.chain.next = next;
16142 storage.push_storage(storage_value);
16143 let raw_ptr = storage.push_value_mut(raw);
16144 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16145 }
16146 InstanceDescriptorExtension::DawnWireWGSLControl(value) => {
16147 let (mut raw, storage_value) = value.to_ffi();
16148 raw.chain.sType = SType::DawnWireWGSLControl.into();
16149 raw.chain.next = next;
16150 storage.push_storage(storage_value);
16151 let raw_ptr = storage.push_value_mut(raw);
16152 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16153 }
16154 }
16155 }
16156 }
16157 #[allow(dead_code)]
16158 pub enum InstanceLimitsExtension {}
16159 impl InstanceLimitsExtension {
16160 pub(crate) fn push_chain(
16161 &self,
16162 storage: &mut ChainedStructStorage,
16163 next: *mut ffi::WGPUChainedStruct,
16164 ) -> *mut ffi::WGPUChainedStruct {
16165 let _ = self;
16166 let _ = storage;
16167 next
16168 }
16169 }
16170 #[allow(dead_code)]
16171 pub enum LimitsExtension {
16172 DawnHostMappedPointerLimits(DawnHostMappedPointerLimits),
16173 DawnTexelCopyBufferRowAlignmentLimits(DawnTexelCopyBufferRowAlignmentLimits),
16174 }
16175 impl std::convert::From<DawnHostMappedPointerLimits> for LimitsExtension {
16176 fn from(ext: DawnHostMappedPointerLimits) -> Self {
16177 LimitsExtension::DawnHostMappedPointerLimits(ext)
16178 }
16179 }
16180 impl std::convert::From<DawnTexelCopyBufferRowAlignmentLimits> for LimitsExtension {
16181 fn from(ext: DawnTexelCopyBufferRowAlignmentLimits) -> Self {
16182 LimitsExtension::DawnTexelCopyBufferRowAlignmentLimits(ext)
16183 }
16184 }
16185 impl LimitsExtension {
16186 pub(crate) fn push_chain(
16187 &self,
16188 storage: &mut ChainedStructStorage,
16189 next: *mut ffi::WGPUChainedStruct,
16190 ) -> *mut ffi::WGPUChainedStruct {
16191 match self {
16192 LimitsExtension::DawnHostMappedPointerLimits(value) => {
16193 let (mut raw, storage_value) = value.to_ffi();
16194 raw.chain.sType = SType::DawnHostMappedPointerLimits.into();
16195 raw.chain.next = next;
16196 storage.push_storage(storage_value);
16197 let raw_ptr = storage.push_value_mut(raw);
16198 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16199 }
16200 LimitsExtension::DawnTexelCopyBufferRowAlignmentLimits(value) => {
16201 let (mut raw, storage_value) = value.to_ffi();
16202 raw.chain.sType = SType::DawnTexelCopyBufferRowAlignmentLimits
16203 .into();
16204 raw.chain.next = next;
16205 storage.push_storage(storage_value);
16206 let raw_ptr = storage.push_value_mut(raw);
16207 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16208 }
16209 }
16210 }
16211 }
16212 #[allow(dead_code)]
16213 pub enum MultisampleStateExtension {}
16214 impl MultisampleStateExtension {
16215 pub(crate) fn push_chain(
16216 &self,
16217 storage: &mut ChainedStructStorage,
16218 next: *mut ffi::WGPUChainedStruct,
16219 ) -> *mut ffi::WGPUChainedStruct {
16220 let _ = self;
16221 let _ = storage;
16222 next
16223 }
16224 }
16225 #[allow(dead_code)]
16226 pub enum PassTimestampWritesExtension {}
16227 impl PassTimestampWritesExtension {
16228 pub(crate) fn push_chain(
16229 &self,
16230 storage: &mut ChainedStructStorage,
16231 next: *mut ffi::WGPUChainedStruct,
16232 ) -> *mut ffi::WGPUChainedStruct {
16233 let _ = self;
16234 let _ = storage;
16235 next
16236 }
16237 }
16238 #[allow(dead_code)]
16239 pub enum PipelineLayoutDescriptorExtension {
16240 PipelineLayoutPixelLocalStorage(PipelineLayoutPixelLocalStorage),
16241 PipelineLayoutResourceTable(PipelineLayoutResourceTable),
16242 }
16243 impl std::convert::From<PipelineLayoutPixelLocalStorage>
16244 for PipelineLayoutDescriptorExtension {
16245 fn from(ext: PipelineLayoutPixelLocalStorage) -> Self {
16246 PipelineLayoutDescriptorExtension::PipelineLayoutPixelLocalStorage(ext)
16247 }
16248 }
16249 impl std::convert::From<PipelineLayoutResourceTable>
16250 for PipelineLayoutDescriptorExtension {
16251 fn from(ext: PipelineLayoutResourceTable) -> Self {
16252 PipelineLayoutDescriptorExtension::PipelineLayoutResourceTable(ext)
16253 }
16254 }
16255 impl PipelineLayoutDescriptorExtension {
16256 pub(crate) fn push_chain(
16257 &self,
16258 storage: &mut ChainedStructStorage,
16259 next: *mut ffi::WGPUChainedStruct,
16260 ) -> *mut ffi::WGPUChainedStruct {
16261 match self {
16262 PipelineLayoutDescriptorExtension::PipelineLayoutPixelLocalStorage(
16263 value,
16264 ) => {
16265 let (mut raw, storage_value) = value.to_ffi();
16266 raw.chain.sType = SType::PipelineLayoutPixelLocalStorage.into();
16267 raw.chain.next = next;
16268 storage.push_storage(storage_value);
16269 let raw_ptr = storage.push_value_mut(raw);
16270 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16271 }
16272 PipelineLayoutDescriptorExtension::PipelineLayoutResourceTable(
16273 value,
16274 ) => {
16275 let (mut raw, storage_value) = value.to_ffi();
16276 raw.chain.sType = SType::PipelineLayoutResourceTable.into();
16277 raw.chain.next = next;
16278 storage.push_storage(storage_value);
16279 let raw_ptr = storage.push_value_mut(raw);
16280 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16281 }
16282 }
16283 }
16284 }
16285 #[allow(dead_code)]
16286 pub enum PipelineLayoutStorageAttachmentExtension {}
16287 impl PipelineLayoutStorageAttachmentExtension {
16288 pub(crate) fn push_chain(
16289 &self,
16290 storage: &mut ChainedStructStorage,
16291 next: *mut ffi::WGPUChainedStruct,
16292 ) -> *mut ffi::WGPUChainedStruct {
16293 let _ = self;
16294 let _ = storage;
16295 next
16296 }
16297 }
16298 #[allow(dead_code)]
16299 pub enum PrimitiveStateExtension {}
16300 impl PrimitiveStateExtension {
16301 pub(crate) fn push_chain(
16302 &self,
16303 storage: &mut ChainedStructStorage,
16304 next: *mut ffi::WGPUChainedStruct,
16305 ) -> *mut ffi::WGPUChainedStruct {
16306 let _ = self;
16307 let _ = storage;
16308 next
16309 }
16310 }
16311 #[allow(dead_code)]
16312 pub enum QuerySetDescriptorExtension {}
16313 impl QuerySetDescriptorExtension {
16314 pub(crate) fn push_chain(
16315 &self,
16316 storage: &mut ChainedStructStorage,
16317 next: *mut ffi::WGPUChainedStruct,
16318 ) -> *mut ffi::WGPUChainedStruct {
16319 let _ = self;
16320 let _ = storage;
16321 next
16322 }
16323 }
16324 #[allow(dead_code)]
16325 pub enum QueueDescriptorExtension {}
16326 impl QueueDescriptorExtension {
16327 pub(crate) fn push_chain(
16328 &self,
16329 storage: &mut ChainedStructStorage,
16330 next: *mut ffi::WGPUChainedStruct,
16331 ) -> *mut ffi::WGPUChainedStruct {
16332 let _ = self;
16333 let _ = storage;
16334 next
16335 }
16336 }
16337 #[allow(dead_code)]
16338 pub enum RenderBundleDescriptorExtension {}
16339 impl RenderBundleDescriptorExtension {
16340 pub(crate) fn push_chain(
16341 &self,
16342 storage: &mut ChainedStructStorage,
16343 next: *mut ffi::WGPUChainedStruct,
16344 ) -> *mut ffi::WGPUChainedStruct {
16345 let _ = self;
16346 let _ = storage;
16347 next
16348 }
16349 }
16350 #[allow(dead_code)]
16351 pub enum RenderBundleEncoderDescriptorExtension {}
16352 impl RenderBundleEncoderDescriptorExtension {
16353 pub(crate) fn push_chain(
16354 &self,
16355 storage: &mut ChainedStructStorage,
16356 next: *mut ffi::WGPUChainedStruct,
16357 ) -> *mut ffi::WGPUChainedStruct {
16358 let _ = self;
16359 let _ = storage;
16360 next
16361 }
16362 }
16363 #[allow(dead_code)]
16364 pub enum RenderPassColorAttachmentExtension {}
16365 impl RenderPassColorAttachmentExtension {
16366 pub(crate) fn push_chain(
16367 &self,
16368 storage: &mut ChainedStructStorage,
16369 next: *mut ffi::WGPUChainedStruct,
16370 ) -> *mut ffi::WGPUChainedStruct {
16371 let _ = self;
16372 let _ = storage;
16373 next
16374 }
16375 }
16376 #[allow(dead_code)]
16377 pub enum RenderPassDepthStencilAttachmentExtension {}
16378 impl RenderPassDepthStencilAttachmentExtension {
16379 pub(crate) fn push_chain(
16380 &self,
16381 storage: &mut ChainedStructStorage,
16382 next: *mut ffi::WGPUChainedStruct,
16383 ) -> *mut ffi::WGPUChainedStruct {
16384 let _ = self;
16385 let _ = storage;
16386 next
16387 }
16388 }
16389 #[allow(dead_code)]
16390 pub enum RenderPassDescriptorExtension {
16391 DawnRenderPassSampleCount(DawnRenderPassSampleCount),
16392 RenderPassDescriptorExpandResolveRect(RenderPassDescriptorExpandResolveRect),
16393 RenderPassDescriptorResolveRect(RenderPassDescriptorResolveRect),
16394 RenderPassMaxDrawCount(RenderPassMaxDrawCount),
16395 RenderPassPixelLocalStorage(RenderPassPixelLocalStorage),
16396 }
16397 impl std::convert::From<DawnRenderPassSampleCount>
16398 for RenderPassDescriptorExtension {
16399 fn from(ext: DawnRenderPassSampleCount) -> Self {
16400 RenderPassDescriptorExtension::DawnRenderPassSampleCount(ext)
16401 }
16402 }
16403 impl std::convert::From<RenderPassDescriptorExpandResolveRect>
16404 for RenderPassDescriptorExtension {
16405 fn from(ext: RenderPassDescriptorExpandResolveRect) -> Self {
16406 RenderPassDescriptorExtension::RenderPassDescriptorExpandResolveRect(ext)
16407 }
16408 }
16409 impl std::convert::From<RenderPassDescriptorResolveRect>
16410 for RenderPassDescriptorExtension {
16411 fn from(ext: RenderPassDescriptorResolveRect) -> Self {
16412 RenderPassDescriptorExtension::RenderPassDescriptorResolveRect(ext)
16413 }
16414 }
16415 impl std::convert::From<RenderPassMaxDrawCount> for RenderPassDescriptorExtension {
16416 fn from(ext: RenderPassMaxDrawCount) -> Self {
16417 RenderPassDescriptorExtension::RenderPassMaxDrawCount(ext)
16418 }
16419 }
16420 impl std::convert::From<RenderPassPixelLocalStorage>
16421 for RenderPassDescriptorExtension {
16422 fn from(ext: RenderPassPixelLocalStorage) -> Self {
16423 RenderPassDescriptorExtension::RenderPassPixelLocalStorage(ext)
16424 }
16425 }
16426 impl RenderPassDescriptorExtension {
16427 pub(crate) fn push_chain(
16428 &self,
16429 storage: &mut ChainedStructStorage,
16430 next: *mut ffi::WGPUChainedStruct,
16431 ) -> *mut ffi::WGPUChainedStruct {
16432 match self {
16433 RenderPassDescriptorExtension::DawnRenderPassSampleCount(value) => {
16434 let (mut raw, storage_value) = value.to_ffi();
16435 raw.chain.sType = SType::DawnRenderPassSampleCount.into();
16436 raw.chain.next = next;
16437 storage.push_storage(storage_value);
16438 let raw_ptr = storage.push_value_mut(raw);
16439 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16440 }
16441 RenderPassDescriptorExtension::RenderPassDescriptorExpandResolveRect(
16442 value,
16443 ) => {
16444 let (mut raw, storage_value) = value.to_ffi();
16445 raw.chain.sType = SType::RenderPassDescriptorExpandResolveRect
16446 .into();
16447 raw.chain.next = next;
16448 storage.push_storage(storage_value);
16449 let raw_ptr = storage.push_value_mut(raw);
16450 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16451 }
16452 RenderPassDescriptorExtension::RenderPassDescriptorResolveRect(
16453 value,
16454 ) => {
16455 let (mut raw, storage_value) = value.to_ffi();
16456 raw.chain.sType = SType::RenderPassDescriptorResolveRect.into();
16457 raw.chain.next = next;
16458 storage.push_storage(storage_value);
16459 let raw_ptr = storage.push_value_mut(raw);
16460 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16461 }
16462 RenderPassDescriptorExtension::RenderPassMaxDrawCount(value) => {
16463 let (mut raw, storage_value) = value.to_ffi();
16464 raw.chain.sType = SType::RenderPassMaxDrawCount.into();
16465 raw.chain.next = next;
16466 storage.push_storage(storage_value);
16467 let raw_ptr = storage.push_value_mut(raw);
16468 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16469 }
16470 RenderPassDescriptorExtension::RenderPassPixelLocalStorage(value) => {
16471 let (mut raw, storage_value) = value.to_ffi();
16472 raw.chain.sType = SType::RenderPassPixelLocalStorage.into();
16473 raw.chain.next = next;
16474 storage.push_storage(storage_value);
16475 let raw_ptr = storage.push_value_mut(raw);
16476 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16477 }
16478 }
16479 }
16480 }
16481 #[allow(dead_code)]
16482 pub enum RenderPassStorageAttachmentExtension {}
16483 impl RenderPassStorageAttachmentExtension {
16484 pub(crate) fn push_chain(
16485 &self,
16486 storage: &mut ChainedStructStorage,
16487 next: *mut ffi::WGPUChainedStruct,
16488 ) -> *mut ffi::WGPUChainedStruct {
16489 let _ = self;
16490 let _ = storage;
16491 next
16492 }
16493 }
16494 #[allow(dead_code)]
16495 pub enum RenderPipelineDescriptorExtension {}
16496 impl RenderPipelineDescriptorExtension {
16497 pub(crate) fn push_chain(
16498 &self,
16499 storage: &mut ChainedStructStorage,
16500 next: *mut ffi::WGPUChainedStruct,
16501 ) -> *mut ffi::WGPUChainedStruct {
16502 let _ = self;
16503 let _ = storage;
16504 next
16505 }
16506 }
16507 #[allow(dead_code)]
16508 pub enum RequestAdapterOptionsExtension {
16509 DawnTogglesDescriptor(DawnTogglesDescriptor),
16510 RequestAdapterWebGPUBackendOptions(RequestAdapterWebGPUBackendOptions),
16511 RequestAdapterWebXROptions(RequestAdapterWebXROptions),
16512 }
16513 impl std::convert::From<DawnTogglesDescriptor> for RequestAdapterOptionsExtension {
16514 fn from(ext: DawnTogglesDescriptor) -> Self {
16515 RequestAdapterOptionsExtension::DawnTogglesDescriptor(ext)
16516 }
16517 }
16518 impl std::convert::From<RequestAdapterWebGPUBackendOptions>
16519 for RequestAdapterOptionsExtension {
16520 fn from(ext: RequestAdapterWebGPUBackendOptions) -> Self {
16521 RequestAdapterOptionsExtension::RequestAdapterWebGPUBackendOptions(ext)
16522 }
16523 }
16524 impl std::convert::From<RequestAdapterWebXROptions>
16525 for RequestAdapterOptionsExtension {
16526 fn from(ext: RequestAdapterWebXROptions) -> Self {
16527 RequestAdapterOptionsExtension::RequestAdapterWebXROptions(ext)
16528 }
16529 }
16530 impl RequestAdapterOptionsExtension {
16531 pub(crate) fn push_chain(
16532 &self,
16533 storage: &mut ChainedStructStorage,
16534 next: *mut ffi::WGPUChainedStruct,
16535 ) -> *mut ffi::WGPUChainedStruct {
16536 match self {
16537 RequestAdapterOptionsExtension::DawnTogglesDescriptor(value) => {
16538 let (mut raw, storage_value) = value.to_ffi();
16539 raw.chain.sType = SType::DawnTogglesDescriptor.into();
16540 raw.chain.next = next;
16541 storage.push_storage(storage_value);
16542 let raw_ptr = storage.push_value_mut(raw);
16543 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16544 }
16545 RequestAdapterOptionsExtension::RequestAdapterWebGPUBackendOptions(
16546 value,
16547 ) => {
16548 let (mut raw, storage_value) = value.to_ffi();
16549 raw.chain.sType = SType::RequestAdapterWebGPUBackendOptions.into();
16550 raw.chain.next = next;
16551 storage.push_storage(storage_value);
16552 let raw_ptr = storage.push_value_mut(raw);
16553 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16554 }
16555 RequestAdapterOptionsExtension::RequestAdapterWebXROptions(value) => {
16556 let (mut raw, storage_value) = value.to_ffi();
16557 raw.chain.sType = SType::RequestAdapterWebXROptions.into();
16558 raw.chain.next = next;
16559 storage.push_storage(storage_value);
16560 let raw_ptr = storage.push_value_mut(raw);
16561 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16562 }
16563 }
16564 }
16565 }
16566 #[allow(dead_code)]
16567 pub enum ResourceTableDescriptorExtension {}
16568 impl ResourceTableDescriptorExtension {
16569 pub(crate) fn push_chain(
16570 &self,
16571 storage: &mut ChainedStructStorage,
16572 next: *mut ffi::WGPUChainedStruct,
16573 ) -> *mut ffi::WGPUChainedStruct {
16574 let _ = self;
16575 let _ = storage;
16576 next
16577 }
16578 }
16579 #[allow(dead_code)]
16580 pub enum SamplerBindingLayoutExtension {}
16581 impl SamplerBindingLayoutExtension {
16582 pub(crate) fn push_chain(
16583 &self,
16584 storage: &mut ChainedStructStorage,
16585 next: *mut ffi::WGPUChainedStruct,
16586 ) -> *mut ffi::WGPUChainedStruct {
16587 let _ = self;
16588 let _ = storage;
16589 next
16590 }
16591 }
16592 #[allow(dead_code)]
16593 pub enum SamplerDescriptorExtension {
16594 YCbCrVkDescriptor(YCbCrVkDescriptor),
16595 }
16596 impl std::convert::From<YCbCrVkDescriptor> for SamplerDescriptorExtension {
16597 fn from(ext: YCbCrVkDescriptor) -> Self {
16598 SamplerDescriptorExtension::YCbCrVkDescriptor(ext)
16599 }
16600 }
16601 impl SamplerDescriptorExtension {
16602 pub(crate) fn push_chain(
16603 &self,
16604 storage: &mut ChainedStructStorage,
16605 next: *mut ffi::WGPUChainedStruct,
16606 ) -> *mut ffi::WGPUChainedStruct {
16607 match self {
16608 SamplerDescriptorExtension::YCbCrVkDescriptor(value) => {
16609 let (mut raw, storage_value) = value.to_ffi();
16610 raw.chain.sType = SType::YCbCrVkDescriptor.into();
16611 raw.chain.next = next;
16612 storage.push_storage(storage_value);
16613 let raw_ptr = storage.push_value_mut(raw);
16614 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16615 }
16616 }
16617 }
16618 }
16619 #[allow(dead_code)]
16620 pub enum ShaderModuleDescriptorExtension {
16621 DawnShaderModuleSPIRVOptionsDescriptor(DawnShaderModuleSPIRVOptionsDescriptor),
16622 ShaderModuleCompilationOptions(ShaderModuleCompilationOptions),
16623 ShaderSourceSPIRV(ShaderSourceSPIRV),
16624 ShaderSourceWGSL(ShaderSourceWGSL),
16625 }
16626 impl std::convert::From<DawnShaderModuleSPIRVOptionsDescriptor>
16627 for ShaderModuleDescriptorExtension {
16628 fn from(ext: DawnShaderModuleSPIRVOptionsDescriptor) -> Self {
16629 ShaderModuleDescriptorExtension::DawnShaderModuleSPIRVOptionsDescriptor(ext)
16630 }
16631 }
16632 impl std::convert::From<ShaderModuleCompilationOptions>
16633 for ShaderModuleDescriptorExtension {
16634 fn from(ext: ShaderModuleCompilationOptions) -> Self {
16635 ShaderModuleDescriptorExtension::ShaderModuleCompilationOptions(ext)
16636 }
16637 }
16638 impl std::convert::From<ShaderSourceSPIRV> for ShaderModuleDescriptorExtension {
16639 fn from(ext: ShaderSourceSPIRV) -> Self {
16640 ShaderModuleDescriptorExtension::ShaderSourceSPIRV(ext)
16641 }
16642 }
16643 impl std::convert::From<ShaderSourceWGSL> for ShaderModuleDescriptorExtension {
16644 fn from(ext: ShaderSourceWGSL) -> Self {
16645 ShaderModuleDescriptorExtension::ShaderSourceWGSL(ext)
16646 }
16647 }
16648 impl ShaderModuleDescriptorExtension {
16649 pub(crate) fn push_chain(
16650 &self,
16651 storage: &mut ChainedStructStorage,
16652 next: *mut ffi::WGPUChainedStruct,
16653 ) -> *mut ffi::WGPUChainedStruct {
16654 match self {
16655 ShaderModuleDescriptorExtension::DawnShaderModuleSPIRVOptionsDescriptor(
16656 value,
16657 ) => {
16658 let (mut raw, storage_value) = value.to_ffi();
16659 raw.chain.sType = SType::DawnShaderModuleSPIRVOptionsDescriptor
16660 .into();
16661 raw.chain.next = next;
16662 storage.push_storage(storage_value);
16663 let raw_ptr = storage.push_value_mut(raw);
16664 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16665 }
16666 ShaderModuleDescriptorExtension::ShaderModuleCompilationOptions(
16667 value,
16668 ) => {
16669 let (mut raw, storage_value) = value.to_ffi();
16670 raw.chain.sType = SType::ShaderModuleCompilationOptions.into();
16671 raw.chain.next = next;
16672 storage.push_storage(storage_value);
16673 let raw_ptr = storage.push_value_mut(raw);
16674 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16675 }
16676 ShaderModuleDescriptorExtension::ShaderSourceSPIRV(value) => {
16677 let (mut raw, storage_value) = value.to_ffi();
16678 raw.chain.sType = SType::ShaderSourceSPIRV.into();
16679 raw.chain.next = next;
16680 storage.push_storage(storage_value);
16681 let raw_ptr = storage.push_value_mut(raw);
16682 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16683 }
16684 ShaderModuleDescriptorExtension::ShaderSourceWGSL(value) => {
16685 let (mut raw, storage_value) = value.to_ffi();
16686 raw.chain.sType = SType::ShaderSourceWGSL.into();
16687 raw.chain.next = next;
16688 storage.push_storage(storage_value);
16689 let raw_ptr = storage.push_value_mut(raw);
16690 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16691 }
16692 }
16693 }
16694 }
16695 #[allow(dead_code)]
16696 pub enum SharedBufferMemoryBeginAccessDescriptorExtension {}
16697 impl SharedBufferMemoryBeginAccessDescriptorExtension {
16698 pub(crate) fn push_chain(
16699 &self,
16700 storage: &mut ChainedStructStorage,
16701 next: *mut ffi::WGPUChainedStruct,
16702 ) -> *mut ffi::WGPUChainedStruct {
16703 let _ = self;
16704 let _ = storage;
16705 next
16706 }
16707 }
16708 #[allow(dead_code)]
16709 pub enum SharedBufferMemoryDescriptorExtension {}
16710 impl SharedBufferMemoryDescriptorExtension {
16711 pub(crate) fn push_chain(
16712 &self,
16713 storage: &mut ChainedStructStorage,
16714 next: *mut ffi::WGPUChainedStruct,
16715 ) -> *mut ffi::WGPUChainedStruct {
16716 let _ = self;
16717 let _ = storage;
16718 next
16719 }
16720 }
16721 #[allow(dead_code)]
16722 pub enum SharedBufferMemoryEndAccessStateExtension {}
16723 impl SharedBufferMemoryEndAccessStateExtension {
16724 pub(crate) fn push_chain(
16725 &self,
16726 storage: &mut ChainedStructStorage,
16727 next: *mut ffi::WGPUChainedStruct,
16728 ) -> *mut ffi::WGPUChainedStruct {
16729 let _ = self;
16730 let _ = storage;
16731 next
16732 }
16733 }
16734 #[allow(dead_code)]
16735 pub enum SharedBufferMemoryPropertiesExtension {}
16736 impl SharedBufferMemoryPropertiesExtension {
16737 pub(crate) fn push_chain(
16738 &self,
16739 storage: &mut ChainedStructStorage,
16740 next: *mut ffi::WGPUChainedStruct,
16741 ) -> *mut ffi::WGPUChainedStruct {
16742 let _ = self;
16743 let _ = storage;
16744 next
16745 }
16746 }
16747 #[allow(dead_code)]
16748 pub enum SharedFenceDescriptorExtension {
16749 SharedFenceDXGISharedHandleDescriptor(SharedFenceDXGISharedHandleDescriptor),
16750 SharedFenceEGLSyncDescriptor(SharedFenceEGLSyncDescriptor),
16751 SharedFenceMTLSharedEventDescriptor(SharedFenceMTLSharedEventDescriptor),
16752 SharedFenceSyncFDDescriptor(SharedFenceSyncFDDescriptor),
16753 SharedFenceVkSemaphoreOpaqueFDDescriptor(
16754 SharedFenceVkSemaphoreOpaqueFDDescriptor,
16755 ),
16756 SharedFenceVkSemaphoreZirconHandleDescriptor(
16757 SharedFenceVkSemaphoreZirconHandleDescriptor,
16758 ),
16759 }
16760 impl std::convert::From<SharedFenceDXGISharedHandleDescriptor>
16761 for SharedFenceDescriptorExtension {
16762 fn from(ext: SharedFenceDXGISharedHandleDescriptor) -> Self {
16763 SharedFenceDescriptorExtension::SharedFenceDXGISharedHandleDescriptor(ext)
16764 }
16765 }
16766 impl std::convert::From<SharedFenceEGLSyncDescriptor>
16767 for SharedFenceDescriptorExtension {
16768 fn from(ext: SharedFenceEGLSyncDescriptor) -> Self {
16769 SharedFenceDescriptorExtension::SharedFenceEGLSyncDescriptor(ext)
16770 }
16771 }
16772 impl std::convert::From<SharedFenceMTLSharedEventDescriptor>
16773 for SharedFenceDescriptorExtension {
16774 fn from(ext: SharedFenceMTLSharedEventDescriptor) -> Self {
16775 SharedFenceDescriptorExtension::SharedFenceMTLSharedEventDescriptor(ext)
16776 }
16777 }
16778 impl std::convert::From<SharedFenceSyncFDDescriptor>
16779 for SharedFenceDescriptorExtension {
16780 fn from(ext: SharedFenceSyncFDDescriptor) -> Self {
16781 SharedFenceDescriptorExtension::SharedFenceSyncFDDescriptor(ext)
16782 }
16783 }
16784 impl std::convert::From<SharedFenceVkSemaphoreOpaqueFDDescriptor>
16785 for SharedFenceDescriptorExtension {
16786 fn from(ext: SharedFenceVkSemaphoreOpaqueFDDescriptor) -> Self {
16787 SharedFenceDescriptorExtension::SharedFenceVkSemaphoreOpaqueFDDescriptor(ext)
16788 }
16789 }
16790 impl std::convert::From<SharedFenceVkSemaphoreZirconHandleDescriptor>
16791 for SharedFenceDescriptorExtension {
16792 fn from(ext: SharedFenceVkSemaphoreZirconHandleDescriptor) -> Self {
16793 SharedFenceDescriptorExtension::SharedFenceVkSemaphoreZirconHandleDescriptor(
16794 ext,
16795 )
16796 }
16797 }
16798 impl SharedFenceDescriptorExtension {
16799 pub(crate) fn push_chain(
16800 &self,
16801 storage: &mut ChainedStructStorage,
16802 next: *mut ffi::WGPUChainedStruct,
16803 ) -> *mut ffi::WGPUChainedStruct {
16804 match self {
16805 SharedFenceDescriptorExtension::SharedFenceDXGISharedHandleDescriptor(
16806 value,
16807 ) => {
16808 let (mut raw, storage_value) = value.to_ffi();
16809 raw.chain.sType = SType::SharedFenceDXGISharedHandleDescriptor
16810 .into();
16811 raw.chain.next = next;
16812 storage.push_storage(storage_value);
16813 let raw_ptr = storage.push_value_mut(raw);
16814 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16815 }
16816 SharedFenceDescriptorExtension::SharedFenceEGLSyncDescriptor(value) => {
16817 let (mut raw, storage_value) = value.to_ffi();
16818 raw.chain.sType = SType::SharedFenceEGLSyncDescriptor.into();
16819 raw.chain.next = next;
16820 storage.push_storage(storage_value);
16821 let raw_ptr = storage.push_value_mut(raw);
16822 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16823 }
16824 SharedFenceDescriptorExtension::SharedFenceMTLSharedEventDescriptor(
16825 value,
16826 ) => {
16827 let (mut raw, storage_value) = value.to_ffi();
16828 raw.chain.sType = SType::SharedFenceMTLSharedEventDescriptor.into();
16829 raw.chain.next = next;
16830 storage.push_storage(storage_value);
16831 let raw_ptr = storage.push_value_mut(raw);
16832 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16833 }
16834 SharedFenceDescriptorExtension::SharedFenceSyncFDDescriptor(value) => {
16835 let (mut raw, storage_value) = value.to_ffi();
16836 raw.chain.sType = SType::SharedFenceSyncFDDescriptor.into();
16837 raw.chain.next = next;
16838 storage.push_storage(storage_value);
16839 let raw_ptr = storage.push_value_mut(raw);
16840 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16841 }
16842 SharedFenceDescriptorExtension::SharedFenceVkSemaphoreOpaqueFDDescriptor(
16843 value,
16844 ) => {
16845 let (mut raw, storage_value) = value.to_ffi();
16846 raw.chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDDescriptor
16847 .into();
16848 raw.chain.next = next;
16849 storage.push_storage(storage_value);
16850 let raw_ptr = storage.push_value_mut(raw);
16851 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16852 }
16853 SharedFenceDescriptorExtension::SharedFenceVkSemaphoreZirconHandleDescriptor(
16854 value,
16855 ) => {
16856 let (mut raw, storage_value) = value.to_ffi();
16857 raw.chain.sType = SType::SharedFenceVkSemaphoreZirconHandleDescriptor
16858 .into();
16859 raw.chain.next = next;
16860 storage.push_storage(storage_value);
16861 let raw_ptr = storage.push_value_mut(raw);
16862 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16863 }
16864 }
16865 }
16866 }
16867 #[allow(dead_code)]
16868 pub enum SharedFenceExportInfoExtension {
16869 SharedFenceDXGISharedHandleExportInfo(SharedFenceDXGISharedHandleExportInfo),
16870 SharedFenceEGLSyncExportInfo(SharedFenceEGLSyncExportInfo),
16871 SharedFenceMTLSharedEventExportInfo(SharedFenceMTLSharedEventExportInfo),
16872 SharedFenceSyncFDExportInfo(SharedFenceSyncFDExportInfo),
16873 SharedFenceVkSemaphoreOpaqueFDExportInfo(
16874 SharedFenceVkSemaphoreOpaqueFDExportInfo,
16875 ),
16876 SharedFenceVkSemaphoreZirconHandleExportInfo(
16877 SharedFenceVkSemaphoreZirconHandleExportInfo,
16878 ),
16879 }
16880 impl std::convert::From<SharedFenceDXGISharedHandleExportInfo>
16881 for SharedFenceExportInfoExtension {
16882 fn from(ext: SharedFenceDXGISharedHandleExportInfo) -> Self {
16883 SharedFenceExportInfoExtension::SharedFenceDXGISharedHandleExportInfo(ext)
16884 }
16885 }
16886 impl std::convert::From<SharedFenceEGLSyncExportInfo>
16887 for SharedFenceExportInfoExtension {
16888 fn from(ext: SharedFenceEGLSyncExportInfo) -> Self {
16889 SharedFenceExportInfoExtension::SharedFenceEGLSyncExportInfo(ext)
16890 }
16891 }
16892 impl std::convert::From<SharedFenceMTLSharedEventExportInfo>
16893 for SharedFenceExportInfoExtension {
16894 fn from(ext: SharedFenceMTLSharedEventExportInfo) -> Self {
16895 SharedFenceExportInfoExtension::SharedFenceMTLSharedEventExportInfo(ext)
16896 }
16897 }
16898 impl std::convert::From<SharedFenceSyncFDExportInfo>
16899 for SharedFenceExportInfoExtension {
16900 fn from(ext: SharedFenceSyncFDExportInfo) -> Self {
16901 SharedFenceExportInfoExtension::SharedFenceSyncFDExportInfo(ext)
16902 }
16903 }
16904 impl std::convert::From<SharedFenceVkSemaphoreOpaqueFDExportInfo>
16905 for SharedFenceExportInfoExtension {
16906 fn from(ext: SharedFenceVkSemaphoreOpaqueFDExportInfo) -> Self {
16907 SharedFenceExportInfoExtension::SharedFenceVkSemaphoreOpaqueFDExportInfo(ext)
16908 }
16909 }
16910 impl std::convert::From<SharedFenceVkSemaphoreZirconHandleExportInfo>
16911 for SharedFenceExportInfoExtension {
16912 fn from(ext: SharedFenceVkSemaphoreZirconHandleExportInfo) -> Self {
16913 SharedFenceExportInfoExtension::SharedFenceVkSemaphoreZirconHandleExportInfo(
16914 ext,
16915 )
16916 }
16917 }
16918 impl SharedFenceExportInfoExtension {
16919 pub(crate) fn push_chain(
16920 &self,
16921 storage: &mut ChainedStructStorage,
16922 next: *mut ffi::WGPUChainedStruct,
16923 ) -> *mut ffi::WGPUChainedStruct {
16924 match self {
16925 SharedFenceExportInfoExtension::SharedFenceDXGISharedHandleExportInfo(
16926 value,
16927 ) => {
16928 let (mut raw, storage_value) = value.to_ffi();
16929 raw.chain.sType = SType::SharedFenceDXGISharedHandleExportInfo
16930 .into();
16931 raw.chain.next = next;
16932 storage.push_storage(storage_value);
16933 let raw_ptr = storage.push_value_mut(raw);
16934 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16935 }
16936 SharedFenceExportInfoExtension::SharedFenceEGLSyncExportInfo(value) => {
16937 let (mut raw, storage_value) = value.to_ffi();
16938 raw.chain.sType = SType::SharedFenceEGLSyncExportInfo.into();
16939 raw.chain.next = next;
16940 storage.push_storage(storage_value);
16941 let raw_ptr = storage.push_value_mut(raw);
16942 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16943 }
16944 SharedFenceExportInfoExtension::SharedFenceMTLSharedEventExportInfo(
16945 value,
16946 ) => {
16947 let (mut raw, storage_value) = value.to_ffi();
16948 raw.chain.sType = SType::SharedFenceMTLSharedEventExportInfo.into();
16949 raw.chain.next = next;
16950 storage.push_storage(storage_value);
16951 let raw_ptr = storage.push_value_mut(raw);
16952 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16953 }
16954 SharedFenceExportInfoExtension::SharedFenceSyncFDExportInfo(value) => {
16955 let (mut raw, storage_value) = value.to_ffi();
16956 raw.chain.sType = SType::SharedFenceSyncFDExportInfo.into();
16957 raw.chain.next = next;
16958 storage.push_storage(storage_value);
16959 let raw_ptr = storage.push_value_mut(raw);
16960 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16961 }
16962 SharedFenceExportInfoExtension::SharedFenceVkSemaphoreOpaqueFDExportInfo(
16963 value,
16964 ) => {
16965 let (mut raw, storage_value) = value.to_ffi();
16966 raw.chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDExportInfo
16967 .into();
16968 raw.chain.next = next;
16969 storage.push_storage(storage_value);
16970 let raw_ptr = storage.push_value_mut(raw);
16971 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16972 }
16973 SharedFenceExportInfoExtension::SharedFenceVkSemaphoreZirconHandleExportInfo(
16974 value,
16975 ) => {
16976 let (mut raw, storage_value) = value.to_ffi();
16977 raw.chain.sType = SType::SharedFenceVkSemaphoreZirconHandleExportInfo
16978 .into();
16979 raw.chain.next = next;
16980 storage.push_storage(storage_value);
16981 let raw_ptr = storage.push_value_mut(raw);
16982 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16983 }
16984 }
16985 }
16986 }
16987 #[allow(dead_code)]
16988 pub enum SharedTextureMemoryBeginAccessDescriptorExtension {
16989 SharedTextureMemoryD3DSwapchainBeginState(
16990 SharedTextureMemoryD3DSwapchainBeginState,
16991 ),
16992 SharedTextureMemoryD3D11BeginState(SharedTextureMemoryD3D11BeginState),
16993 SharedTextureMemoryVkImageLayoutBeginState(
16994 SharedTextureMemoryVkImageLayoutBeginState,
16995 ),
16996 }
16997 impl std::convert::From<SharedTextureMemoryD3DSwapchainBeginState>
16998 for SharedTextureMemoryBeginAccessDescriptorExtension {
16999 fn from(ext: SharedTextureMemoryD3DSwapchainBeginState) -> Self {
17000 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3DSwapchainBeginState(
17001 ext,
17002 )
17003 }
17004 }
17005 impl std::convert::From<SharedTextureMemoryD3D11BeginState>
17006 for SharedTextureMemoryBeginAccessDescriptorExtension {
17007 fn from(ext: SharedTextureMemoryD3D11BeginState) -> Self {
17008 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3D11BeginState(
17009 ext,
17010 )
17011 }
17012 }
17013 impl std::convert::From<SharedTextureMemoryVkImageLayoutBeginState>
17014 for SharedTextureMemoryBeginAccessDescriptorExtension {
17015 fn from(ext: SharedTextureMemoryVkImageLayoutBeginState) -> Self {
17016 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryVkImageLayoutBeginState(
17017 ext,
17018 )
17019 }
17020 }
17021 impl SharedTextureMemoryBeginAccessDescriptorExtension {
17022 pub(crate) fn push_chain(
17023 &self,
17024 storage: &mut ChainedStructStorage,
17025 next: *mut ffi::WGPUChainedStruct,
17026 ) -> *mut ffi::WGPUChainedStruct {
17027 match self {
17028 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3DSwapchainBeginState(
17029 value,
17030 ) => {
17031 let (mut raw, storage_value) = value.to_ffi();
17032 raw.chain.sType = SType::SharedTextureMemoryD3DSwapchainBeginState
17033 .into();
17034 raw.chain.next = next;
17035 storage.push_storage(storage_value);
17036 let raw_ptr = storage.push_value_mut(raw);
17037 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17038 }
17039 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3D11BeginState(
17040 value,
17041 ) => {
17042 let (mut raw, storage_value) = value.to_ffi();
17043 raw.chain.sType = SType::SharedTextureMemoryD3D11BeginState.into();
17044 raw.chain.next = next;
17045 storage.push_storage(storage_value);
17046 let raw_ptr = storage.push_value_mut(raw);
17047 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17048 }
17049 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryVkImageLayoutBeginState(
17050 value,
17051 ) => {
17052 let (mut raw, storage_value) = value.to_ffi();
17053 raw.chain.sType = SType::SharedTextureMemoryVkImageLayoutBeginState
17054 .into();
17055 raw.chain.next = next;
17056 storage.push_storage(storage_value);
17057 let raw_ptr = storage.push_value_mut(raw);
17058 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17059 }
17060 }
17061 }
17062 }
17063 #[allow(dead_code)]
17064 pub enum SharedTextureMemoryDescriptorExtension {
17065 SharedTextureMemoryDXGISharedHandleDescriptor(
17066 SharedTextureMemoryDXGISharedHandleDescriptor,
17067 ),
17068 SharedTextureMemoryEGLImageDescriptor(SharedTextureMemoryEGLImageDescriptor),
17069 SharedTextureMemoryIOSurfaceDescriptor(SharedTextureMemoryIOSurfaceDescriptor),
17070 SharedTextureMemoryAHardwareBufferDescriptor(
17071 SharedTextureMemoryAHardwareBufferDescriptor,
17072 ),
17073 SharedTextureMemoryDmaBufDescriptor(SharedTextureMemoryDmaBufDescriptor),
17074 SharedTextureMemoryOpaqueFDDescriptor(SharedTextureMemoryOpaqueFDDescriptor),
17075 SharedTextureMemoryVkDedicatedAllocationDescriptor(
17076 SharedTextureMemoryVkDedicatedAllocationDescriptor,
17077 ),
17078 SharedTextureMemoryZirconHandleDescriptor(
17079 SharedTextureMemoryZirconHandleDescriptor,
17080 ),
17081 }
17082 impl std::convert::From<SharedTextureMemoryDXGISharedHandleDescriptor>
17083 for SharedTextureMemoryDescriptorExtension {
17084 fn from(ext: SharedTextureMemoryDXGISharedHandleDescriptor) -> Self {
17085 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDXGISharedHandleDescriptor(
17086 ext,
17087 )
17088 }
17089 }
17090 impl std::convert::From<SharedTextureMemoryEGLImageDescriptor>
17091 for SharedTextureMemoryDescriptorExtension {
17092 fn from(ext: SharedTextureMemoryEGLImageDescriptor) -> Self {
17093 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryEGLImageDescriptor(
17094 ext,
17095 )
17096 }
17097 }
17098 impl std::convert::From<SharedTextureMemoryIOSurfaceDescriptor>
17099 for SharedTextureMemoryDescriptorExtension {
17100 fn from(ext: SharedTextureMemoryIOSurfaceDescriptor) -> Self {
17101 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryIOSurfaceDescriptor(
17102 ext,
17103 )
17104 }
17105 }
17106 impl std::convert::From<SharedTextureMemoryAHardwareBufferDescriptor>
17107 for SharedTextureMemoryDescriptorExtension {
17108 fn from(ext: SharedTextureMemoryAHardwareBufferDescriptor) -> Self {
17109 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryAHardwareBufferDescriptor(
17110 ext,
17111 )
17112 }
17113 }
17114 impl std::convert::From<SharedTextureMemoryDmaBufDescriptor>
17115 for SharedTextureMemoryDescriptorExtension {
17116 fn from(ext: SharedTextureMemoryDmaBufDescriptor) -> Self {
17117 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDmaBufDescriptor(
17118 ext,
17119 )
17120 }
17121 }
17122 impl std::convert::From<SharedTextureMemoryOpaqueFDDescriptor>
17123 for SharedTextureMemoryDescriptorExtension {
17124 fn from(ext: SharedTextureMemoryOpaqueFDDescriptor) -> Self {
17125 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryOpaqueFDDescriptor(
17126 ext,
17127 )
17128 }
17129 }
17130 impl std::convert::From<SharedTextureMemoryVkDedicatedAllocationDescriptor>
17131 for SharedTextureMemoryDescriptorExtension {
17132 fn from(ext: SharedTextureMemoryVkDedicatedAllocationDescriptor) -> Self {
17133 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryVkDedicatedAllocationDescriptor(
17134 ext,
17135 )
17136 }
17137 }
17138 impl std::convert::From<SharedTextureMemoryZirconHandleDescriptor>
17139 for SharedTextureMemoryDescriptorExtension {
17140 fn from(ext: SharedTextureMemoryZirconHandleDescriptor) -> Self {
17141 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryZirconHandleDescriptor(
17142 ext,
17143 )
17144 }
17145 }
17146 impl SharedTextureMemoryDescriptorExtension {
17147 pub(crate) fn push_chain(
17148 &self,
17149 storage: &mut ChainedStructStorage,
17150 next: *mut ffi::WGPUChainedStruct,
17151 ) -> *mut ffi::WGPUChainedStruct {
17152 match self {
17153 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDXGISharedHandleDescriptor(
17154 value,
17155 ) => {
17156 let (mut raw, storage_value) = value.to_ffi();
17157 raw.chain.sType = SType::SharedTextureMemoryDXGISharedHandleDescriptor
17158 .into();
17159 raw.chain.next = next;
17160 storage.push_storage(storage_value);
17161 let raw_ptr = storage.push_value_mut(raw);
17162 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17163 }
17164 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryEGLImageDescriptor(
17165 value,
17166 ) => {
17167 let (mut raw, storage_value) = value.to_ffi();
17168 raw.chain.sType = SType::SharedTextureMemoryEGLImageDescriptor
17169 .into();
17170 raw.chain.next = next;
17171 storage.push_storage(storage_value);
17172 let raw_ptr = storage.push_value_mut(raw);
17173 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17174 }
17175 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryIOSurfaceDescriptor(
17176 value,
17177 ) => {
17178 let (mut raw, storage_value) = value.to_ffi();
17179 raw.chain.sType = SType::SharedTextureMemoryIOSurfaceDescriptor
17180 .into();
17181 raw.chain.next = next;
17182 storage.push_storage(storage_value);
17183 let raw_ptr = storage.push_value_mut(raw);
17184 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17185 }
17186 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryAHardwareBufferDescriptor(
17187 value,
17188 ) => {
17189 let (mut raw, storage_value) = value.to_ffi();
17190 raw.chain.sType = SType::SharedTextureMemoryAHardwareBufferDescriptor
17191 .into();
17192 raw.chain.next = next;
17193 storage.push_storage(storage_value);
17194 let raw_ptr = storage.push_value_mut(raw);
17195 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17196 }
17197 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDmaBufDescriptor(
17198 value,
17199 ) => {
17200 let (mut raw, storage_value) = value.to_ffi();
17201 raw.chain.sType = SType::SharedTextureMemoryDmaBufDescriptor.into();
17202 raw.chain.next = next;
17203 storage.push_storage(storage_value);
17204 let raw_ptr = storage.push_value_mut(raw);
17205 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17206 }
17207 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryOpaqueFDDescriptor(
17208 value,
17209 ) => {
17210 let (mut raw, storage_value) = value.to_ffi();
17211 raw.chain.sType = SType::SharedTextureMemoryOpaqueFDDescriptor
17212 .into();
17213 raw.chain.next = next;
17214 storage.push_storage(storage_value);
17215 let raw_ptr = storage.push_value_mut(raw);
17216 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17217 }
17218 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryVkDedicatedAllocationDescriptor(
17219 value,
17220 ) => {
17221 let (mut raw, storage_value) = value.to_ffi();
17222 raw.chain.sType = SType::SharedTextureMemoryVkDedicatedAllocationDescriptor
17223 .into();
17224 raw.chain.next = next;
17225 storage.push_storage(storage_value);
17226 let raw_ptr = storage.push_value_mut(raw);
17227 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17228 }
17229 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryZirconHandleDescriptor(
17230 value,
17231 ) => {
17232 let (mut raw, storage_value) = value.to_ffi();
17233 raw.chain.sType = SType::SharedTextureMemoryZirconHandleDescriptor
17234 .into();
17235 raw.chain.next = next;
17236 storage.push_storage(storage_value);
17237 let raw_ptr = storage.push_value_mut(raw);
17238 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17239 }
17240 }
17241 }
17242 }
17243 #[allow(dead_code)]
17244 pub enum SharedTextureMemoryEndAccessStateExtension {
17245 SharedTextureMemoryMetalEndAccessState(SharedTextureMemoryMetalEndAccessState),
17246 SharedTextureMemoryVkImageLayoutEndState(
17247 SharedTextureMemoryVkImageLayoutEndState,
17248 ),
17249 }
17250 impl std::convert::From<SharedTextureMemoryMetalEndAccessState>
17251 for SharedTextureMemoryEndAccessStateExtension {
17252 fn from(ext: SharedTextureMemoryMetalEndAccessState) -> Self {
17253 SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryMetalEndAccessState(
17254 ext,
17255 )
17256 }
17257 }
17258 impl std::convert::From<SharedTextureMemoryVkImageLayoutEndState>
17259 for SharedTextureMemoryEndAccessStateExtension {
17260 fn from(ext: SharedTextureMemoryVkImageLayoutEndState) -> Self {
17261 SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryVkImageLayoutEndState(
17262 ext,
17263 )
17264 }
17265 }
17266 impl SharedTextureMemoryEndAccessStateExtension {
17267 pub(crate) fn push_chain(
17268 &self,
17269 storage: &mut ChainedStructStorage,
17270 next: *mut ffi::WGPUChainedStruct,
17271 ) -> *mut ffi::WGPUChainedStruct {
17272 match self {
17273 SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryMetalEndAccessState(
17274 value,
17275 ) => {
17276 let (mut raw, storage_value) = value.to_ffi();
17277 raw.chain.sType = SType::SharedTextureMemoryMetalEndAccessState
17278 .into();
17279 raw.chain.next = next;
17280 storage.push_storage(storage_value);
17281 let raw_ptr = storage.push_value_mut(raw);
17282 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17283 }
17284 SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryVkImageLayoutEndState(
17285 value,
17286 ) => {
17287 let (mut raw, storage_value) = value.to_ffi();
17288 raw.chain.sType = SType::SharedTextureMemoryVkImageLayoutEndState
17289 .into();
17290 raw.chain.next = next;
17291 storage.push_storage(storage_value);
17292 let raw_ptr = storage.push_value_mut(raw);
17293 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17294 }
17295 }
17296 }
17297 }
17298 #[allow(dead_code)]
17299 pub enum SharedTextureMemoryPropertiesExtension {
17300 SharedTextureMemoryAHardwareBufferProperties(
17301 SharedTextureMemoryAHardwareBufferProperties,
17302 ),
17303 }
17304 impl std::convert::From<SharedTextureMemoryAHardwareBufferProperties>
17305 for SharedTextureMemoryPropertiesExtension {
17306 fn from(ext: SharedTextureMemoryAHardwareBufferProperties) -> Self {
17307 SharedTextureMemoryPropertiesExtension::SharedTextureMemoryAHardwareBufferProperties(
17308 ext,
17309 )
17310 }
17311 }
17312 impl SharedTextureMemoryPropertiesExtension {
17313 pub(crate) fn push_chain(
17314 &self,
17315 storage: &mut ChainedStructStorage,
17316 next: *mut ffi::WGPUChainedStruct,
17317 ) -> *mut ffi::WGPUChainedStruct {
17318 match self {
17319 SharedTextureMemoryPropertiesExtension::SharedTextureMemoryAHardwareBufferProperties(
17320 value,
17321 ) => {
17322 let (mut raw, storage_value) = value.to_ffi();
17323 raw.chain.sType = SType::SharedTextureMemoryAHardwareBufferProperties
17324 .into();
17325 raw.chain.next = next;
17326 storage.push_storage(storage_value);
17327 let raw_ptr = storage.push_value_mut(raw);
17328 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17329 }
17330 }
17331 }
17332 }
17333 #[allow(dead_code)]
17334 pub enum StorageTextureBindingLayoutExtension {}
17335 impl StorageTextureBindingLayoutExtension {
17336 pub(crate) fn push_chain(
17337 &self,
17338 storage: &mut ChainedStructStorage,
17339 next: *mut ffi::WGPUChainedStruct,
17340 ) -> *mut ffi::WGPUChainedStruct {
17341 let _ = self;
17342 let _ = storage;
17343 next
17344 }
17345 }
17346 #[allow(dead_code)]
17347 pub enum SurfaceCapabilitiesExtension {}
17348 impl SurfaceCapabilitiesExtension {
17349 pub(crate) fn push_chain(
17350 &self,
17351 storage: &mut ChainedStructStorage,
17352 next: *mut ffi::WGPUChainedStruct,
17353 ) -> *mut ffi::WGPUChainedStruct {
17354 let _ = self;
17355 let _ = storage;
17356 next
17357 }
17358 }
17359 #[allow(dead_code)]
17360 pub enum SurfaceConfigurationExtension {}
17361 impl SurfaceConfigurationExtension {
17362 pub(crate) fn push_chain(
17363 &self,
17364 storage: &mut ChainedStructStorage,
17365 next: *mut ffi::WGPUChainedStruct,
17366 ) -> *mut ffi::WGPUChainedStruct {
17367 let _ = self;
17368 let _ = storage;
17369 next
17370 }
17371 }
17372 #[allow(dead_code)]
17373 pub enum SurfaceDescriptorExtension {
17374 SurfaceColorManagement(SurfaceColorManagement),
17375 SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17376 SurfaceDescriptorFromWindowsUWPSwapChainPanel,
17377 ),
17378 SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17379 SurfaceDescriptorFromWindowsWinUISwapChainPanel,
17380 ),
17381 SurfaceDescriptorFromWindowsCoreWindow(SurfaceDescriptorFromWindowsCoreWindow),
17382 SurfaceSourceXCBWindow(SurfaceSourceXCBWindow),
17383 SurfaceSourceAndroidNativeWindow(SurfaceSourceAndroidNativeWindow),
17384 SurfaceSourceMetalLayer(SurfaceSourceMetalLayer),
17385 SurfaceSourceWaylandSurface(SurfaceSourceWaylandSurface),
17386 SurfaceSourceWindowsHWND(SurfaceSourceWindowsHWND),
17387 SurfaceSourceXlibWindow(SurfaceSourceXlibWindow),
17388 }
17389 impl std::convert::From<SurfaceColorManagement> for SurfaceDescriptorExtension {
17390 fn from(ext: SurfaceColorManagement) -> Self {
17391 SurfaceDescriptorExtension::SurfaceColorManagement(ext)
17392 }
17393 }
17394 impl std::convert::From<SurfaceDescriptorFromWindowsUWPSwapChainPanel>
17395 for SurfaceDescriptorExtension {
17396 fn from(ext: SurfaceDescriptorFromWindowsUWPSwapChainPanel) -> Self {
17397 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17398 ext,
17399 )
17400 }
17401 }
17402 impl std::convert::From<SurfaceDescriptorFromWindowsWinUISwapChainPanel>
17403 for SurfaceDescriptorExtension {
17404 fn from(ext: SurfaceDescriptorFromWindowsWinUISwapChainPanel) -> Self {
17405 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17406 ext,
17407 )
17408 }
17409 }
17410 impl std::convert::From<SurfaceDescriptorFromWindowsCoreWindow>
17411 for SurfaceDescriptorExtension {
17412 fn from(ext: SurfaceDescriptorFromWindowsCoreWindow) -> Self {
17413 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsCoreWindow(ext)
17414 }
17415 }
17416 impl std::convert::From<SurfaceSourceXCBWindow> for SurfaceDescriptorExtension {
17417 fn from(ext: SurfaceSourceXCBWindow) -> Self {
17418 SurfaceDescriptorExtension::SurfaceSourceXCBWindow(ext)
17419 }
17420 }
17421 impl std::convert::From<SurfaceSourceAndroidNativeWindow>
17422 for SurfaceDescriptorExtension {
17423 fn from(ext: SurfaceSourceAndroidNativeWindow) -> Self {
17424 SurfaceDescriptorExtension::SurfaceSourceAndroidNativeWindow(ext)
17425 }
17426 }
17427 impl std::convert::From<SurfaceSourceMetalLayer> for SurfaceDescriptorExtension {
17428 fn from(ext: SurfaceSourceMetalLayer) -> Self {
17429 SurfaceDescriptorExtension::SurfaceSourceMetalLayer(ext)
17430 }
17431 }
17432 impl std::convert::From<SurfaceSourceWaylandSurface> for SurfaceDescriptorExtension {
17433 fn from(ext: SurfaceSourceWaylandSurface) -> Self {
17434 SurfaceDescriptorExtension::SurfaceSourceWaylandSurface(ext)
17435 }
17436 }
17437 impl std::convert::From<SurfaceSourceWindowsHWND> for SurfaceDescriptorExtension {
17438 fn from(ext: SurfaceSourceWindowsHWND) -> Self {
17439 SurfaceDescriptorExtension::SurfaceSourceWindowsHWND(ext)
17440 }
17441 }
17442 impl std::convert::From<SurfaceSourceXlibWindow> for SurfaceDescriptorExtension {
17443 fn from(ext: SurfaceSourceXlibWindow) -> Self {
17444 SurfaceDescriptorExtension::SurfaceSourceXlibWindow(ext)
17445 }
17446 }
17447 impl SurfaceDescriptorExtension {
17448 pub(crate) fn push_chain(
17449 &self,
17450 storage: &mut ChainedStructStorage,
17451 next: *mut ffi::WGPUChainedStruct,
17452 ) -> *mut ffi::WGPUChainedStruct {
17453 match self {
17454 SurfaceDescriptorExtension::SurfaceColorManagement(value) => {
17455 let (mut raw, storage_value) = value.to_ffi();
17456 raw.chain.sType = SType::SurfaceColorManagement.into();
17457 raw.chain.next = next;
17458 storage.push_storage(storage_value);
17459 let raw_ptr = storage.push_value_mut(raw);
17460 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17461 }
17462 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17463 value,
17464 ) => {
17465 let (mut raw, storage_value) = value.to_ffi();
17466 raw.chain.sType = SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel
17467 .into();
17468 raw.chain.next = next;
17469 storage.push_storage(storage_value);
17470 let raw_ptr = storage.push_value_mut(raw);
17471 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17472 }
17473 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17474 value,
17475 ) => {
17476 let (mut raw, storage_value) = value.to_ffi();
17477 raw.chain.sType = SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel
17478 .into();
17479 raw.chain.next = next;
17480 storage.push_storage(storage_value);
17481 let raw_ptr = storage.push_value_mut(raw);
17482 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17483 }
17484 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsCoreWindow(
17485 value,
17486 ) => {
17487 let (mut raw, storage_value) = value.to_ffi();
17488 raw.chain.sType = SType::SurfaceDescriptorFromWindowsCoreWindow
17489 .into();
17490 raw.chain.next = next;
17491 storage.push_storage(storage_value);
17492 let raw_ptr = storage.push_value_mut(raw);
17493 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17494 }
17495 SurfaceDescriptorExtension::SurfaceSourceXCBWindow(value) => {
17496 let (mut raw, storage_value) = value.to_ffi();
17497 raw.chain.sType = SType::SurfaceSourceXCBWindow.into();
17498 raw.chain.next = next;
17499 storage.push_storage(storage_value);
17500 let raw_ptr = storage.push_value_mut(raw);
17501 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17502 }
17503 SurfaceDescriptorExtension::SurfaceSourceAndroidNativeWindow(value) => {
17504 let (mut raw, storage_value) = value.to_ffi();
17505 raw.chain.sType = SType::SurfaceSourceAndroidNativeWindow.into();
17506 raw.chain.next = next;
17507 storage.push_storage(storage_value);
17508 let raw_ptr = storage.push_value_mut(raw);
17509 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17510 }
17511 SurfaceDescriptorExtension::SurfaceSourceMetalLayer(value) => {
17512 let (mut raw, storage_value) = value.to_ffi();
17513 raw.chain.sType = SType::SurfaceSourceMetalLayer.into();
17514 raw.chain.next = next;
17515 storage.push_storage(storage_value);
17516 let raw_ptr = storage.push_value_mut(raw);
17517 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17518 }
17519 SurfaceDescriptorExtension::SurfaceSourceWaylandSurface(value) => {
17520 let (mut raw, storage_value) = value.to_ffi();
17521 raw.chain.sType = SType::SurfaceSourceWaylandSurface.into();
17522 raw.chain.next = next;
17523 storage.push_storage(storage_value);
17524 let raw_ptr = storage.push_value_mut(raw);
17525 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17526 }
17527 SurfaceDescriptorExtension::SurfaceSourceWindowsHWND(value) => {
17528 let (mut raw, storage_value) = value.to_ffi();
17529 raw.chain.sType = SType::SurfaceSourceWindowsHWND.into();
17530 raw.chain.next = next;
17531 storage.push_storage(storage_value);
17532 let raw_ptr = storage.push_value_mut(raw);
17533 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17534 }
17535 SurfaceDescriptorExtension::SurfaceSourceXlibWindow(value) => {
17536 let (mut raw, storage_value) = value.to_ffi();
17537 raw.chain.sType = SType::SurfaceSourceXlibWindow.into();
17538 raw.chain.next = next;
17539 storage.push_storage(storage_value);
17540 let raw_ptr = storage.push_value_mut(raw);
17541 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17542 }
17543 }
17544 }
17545 }
17546 #[allow(dead_code)]
17547 pub enum SurfaceTextureExtension {}
17548 impl SurfaceTextureExtension {
17549 pub(crate) fn push_chain(
17550 &self,
17551 storage: &mut ChainedStructStorage,
17552 next: *mut ffi::WGPUChainedStruct,
17553 ) -> *mut ffi::WGPUChainedStruct {
17554 let _ = self;
17555 let _ = storage;
17556 next
17557 }
17558 }
17559 #[allow(dead_code)]
17560 pub enum TexelBufferViewDescriptorExtension {}
17561 impl TexelBufferViewDescriptorExtension {
17562 pub(crate) fn push_chain(
17563 &self,
17564 storage: &mut ChainedStructStorage,
17565 next: *mut ffi::WGPUChainedStruct,
17566 ) -> *mut ffi::WGPUChainedStruct {
17567 let _ = self;
17568 let _ = storage;
17569 next
17570 }
17571 }
17572 #[allow(dead_code)]
17573 pub enum TextureBindingLayoutExtension {}
17574 impl TextureBindingLayoutExtension {
17575 pub(crate) fn push_chain(
17576 &self,
17577 storage: &mut ChainedStructStorage,
17578 next: *mut ffi::WGPUChainedStruct,
17579 ) -> *mut ffi::WGPUChainedStruct {
17580 let _ = self;
17581 let _ = storage;
17582 next
17583 }
17584 }
17585 #[allow(dead_code)]
17586 pub enum TextureDescriptorExtension {
17587 DawnTextureInternalUsageDescriptor(DawnTextureInternalUsageDescriptor),
17588 }
17589 impl std::convert::From<DawnTextureInternalUsageDescriptor>
17590 for TextureDescriptorExtension {
17591 fn from(ext: DawnTextureInternalUsageDescriptor) -> Self {
17592 TextureDescriptorExtension::DawnTextureInternalUsageDescriptor(ext)
17593 }
17594 }
17595 impl TextureDescriptorExtension {
17596 pub(crate) fn push_chain(
17597 &self,
17598 storage: &mut ChainedStructStorage,
17599 next: *mut ffi::WGPUChainedStruct,
17600 ) -> *mut ffi::WGPUChainedStruct {
17601 match self {
17602 TextureDescriptorExtension::DawnTextureInternalUsageDescriptor(
17603 value,
17604 ) => {
17605 let (mut raw, storage_value) = value.to_ffi();
17606 raw.chain.sType = SType::DawnTextureInternalUsageDescriptor.into();
17607 raw.chain.next = next;
17608 storage.push_storage(storage_value);
17609 let raw_ptr = storage.push_value_mut(raw);
17610 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17611 }
17612 }
17613 }
17614 }
17615 #[allow(dead_code)]
17616 pub enum TextureViewDescriptorExtension {
17617 TextureComponentSwizzleDescriptor(TextureComponentSwizzleDescriptor),
17618 YCbCrVkDescriptor(YCbCrVkDescriptor),
17619 }
17620 impl std::convert::From<TextureComponentSwizzleDescriptor>
17621 for TextureViewDescriptorExtension {
17622 fn from(ext: TextureComponentSwizzleDescriptor) -> Self {
17623 TextureViewDescriptorExtension::TextureComponentSwizzleDescriptor(ext)
17624 }
17625 }
17626 impl std::convert::From<YCbCrVkDescriptor> for TextureViewDescriptorExtension {
17627 fn from(ext: YCbCrVkDescriptor) -> Self {
17628 TextureViewDescriptorExtension::YCbCrVkDescriptor(ext)
17629 }
17630 }
17631 impl TextureViewDescriptorExtension {
17632 pub(crate) fn push_chain(
17633 &self,
17634 storage: &mut ChainedStructStorage,
17635 next: *mut ffi::WGPUChainedStruct,
17636 ) -> *mut ffi::WGPUChainedStruct {
17637 match self {
17638 TextureViewDescriptorExtension::TextureComponentSwizzleDescriptor(
17639 value,
17640 ) => {
17641 let (mut raw, storage_value) = value.to_ffi();
17642 raw.chain.sType = SType::TextureComponentSwizzleDescriptor.into();
17643 raw.chain.next = next;
17644 storage.push_storage(storage_value);
17645 let raw_ptr = storage.push_value_mut(raw);
17646 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17647 }
17648 TextureViewDescriptorExtension::YCbCrVkDescriptor(value) => {
17649 let (mut raw, storage_value) = value.to_ffi();
17650 raw.chain.sType = SType::YCbCrVkDescriptor.into();
17651 raw.chain.next = next;
17652 storage.push_storage(storage_value);
17653 let raw_ptr = storage.push_value_mut(raw);
17654 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17655 }
17656 }
17657 }
17658 }
17659 #[allow(dead_code)]
17660 pub enum VertexAttributeExtension {}
17661 impl VertexAttributeExtension {
17662 pub(crate) fn push_chain(
17663 &self,
17664 storage: &mut ChainedStructStorage,
17665 next: *mut ffi::WGPUChainedStruct,
17666 ) -> *mut ffi::WGPUChainedStruct {
17667 let _ = self;
17668 let _ = storage;
17669 next
17670 }
17671 }
17672 #[allow(dead_code)]
17673 pub enum VertexBufferLayoutExtension {}
17674 impl VertexBufferLayoutExtension {
17675 pub(crate) fn push_chain(
17676 &self,
17677 storage: &mut ChainedStructStorage,
17678 next: *mut ffi::WGPUChainedStruct,
17679 ) -> *mut ffi::WGPUChainedStruct {
17680 let _ = self;
17681 let _ = storage;
17682 next
17683 }
17684 }
17685 #[allow(dead_code)]
17686 pub enum VertexStateExtension {}
17687 impl VertexStateExtension {
17688 pub(crate) fn push_chain(
17689 &self,
17690 storage: &mut ChainedStructStorage,
17691 next: *mut ffi::WGPUChainedStruct,
17692 ) -> *mut ffi::WGPUChainedStruct {
17693 let _ = self;
17694 let _ = storage;
17695 next
17696 }
17697 }
17698}
17699mod objects {
17700 #![allow(dead_code, unused_imports)]
17701 use crate::generated::*;
17702 use crate::ffi;
17703 #[derive(Debug)]
17704 pub struct Adapter {
17705 raw: ffi::WGPUAdapter,
17706 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
17707 }
17708 impl Adapter {
17709 pub(crate) unsafe fn from_raw(raw: ffi::WGPUAdapter) -> Self {
17710 Self {
17711 raw,
17712 _not_sync: std::marker::PhantomData,
17713 }
17714 }
17715 pub fn as_raw(&self) -> ffi::WGPUAdapter {
17716 self.raw
17717 }
17718 pub fn get_instance(&self) -> Instance {
17719 let result = unsafe { ffi::wgpuAdapterGetInstance(self.raw) };
17720 unsafe { Instance::from_raw(result) }
17721 }
17722 pub fn get_limits(&self, limits: &mut Limits) -> Status {
17723 let (mut limits_ffi, _limits_storage) = limits.to_ffi();
17724 let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
17725 let result = unsafe { ffi::wgpuAdapterGetLimits(self.raw, limits_ptr) };
17726 *limits = Limits::from_ffi(limits_ffi);
17727 result.into()
17728 }
17729 pub fn get_info(&self, info: &mut AdapterInfo) -> Status {
17730 let (mut info_ffi, _info_storage) = info.to_ffi();
17731 let info_ptr = std::ptr::addr_of_mut!(info_ffi);
17732 let result = unsafe { ffi::wgpuAdapterGetInfo(self.raw, info_ptr) };
17733 *info = AdapterInfo::from_ffi(info_ffi);
17734 result.into()
17735 }
17736 pub fn has_feature(&self, feature: FeatureName) -> bool {
17737 let feature_ffi: ffi::WGPUFeatureName = feature.into();
17738 let result = unsafe { ffi::wgpuAdapterHasFeature(self.raw, feature_ffi) };
17739 result != 0
17740 }
17741 pub fn get_features(&self, features: &mut SupportedFeatures) -> () {
17742 let (mut features_ffi, _features_storage) = features.to_ffi();
17743 let features_ptr = std::ptr::addr_of_mut!(features_ffi);
17744 unsafe { ffi::wgpuAdapterGetFeatures(self.raw, features_ptr) };
17745 *features = SupportedFeatures::from_ffi(features_ffi);
17746 ()
17747 }
17748 pub fn request_device(
17749 &self,
17750 descriptor: Option<&DeviceDescriptor>,
17751 callback: impl FnMut(
17752 RequestDeviceStatus,
17753 Option<Device>,
17754 String,
17755 ) + Send + 'static,
17756 ) -> Future {
17757 let mut descriptor_storage = ChainedStructStorage::new();
17758 let descriptor_ptr = if let Some(value) = &descriptor {
17759 let (descriptor_ffi, storage) = value.to_ffi();
17760 descriptor_storage = storage;
17761 std::ptr::addr_of!(descriptor_ffi)
17762 } else {
17763 std::ptr::null()
17764 };
17765 let callback_box: RequestDeviceCallback = Box::new(callback);
17766 let callback_box = Box::new(Some(callback_box));
17767 let callback_userdata = Box::into_raw(callback_box)
17768 .cast::<std::ffi::c_void>();
17769 let callback_info_ffi = ffi::WGPURequestDeviceCallbackInfo {
17770 nextInChain: std::ptr::null_mut(),
17771 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
17772 callback: Some(request_device_callback_trampoline),
17773 userdata1: callback_userdata,
17774 userdata2: std::ptr::null_mut(),
17775 };
17776 let result = unsafe {
17777 ffi::wgpuAdapterRequestDevice(
17778 self.raw,
17779 descriptor_ptr,
17780 callback_info_ffi,
17781 )
17782 };
17783 Future::from_ffi(result)
17784 }
17785 pub fn create_device(&self, descriptor: Option<&DeviceDescriptor>) -> Device {
17786 let mut descriptor_storage = ChainedStructStorage::new();
17787 let descriptor_ptr = if let Some(value) = &descriptor {
17788 let (descriptor_ffi, storage) = value.to_ffi();
17789 descriptor_storage = storage;
17790 std::ptr::addr_of!(descriptor_ffi)
17791 } else {
17792 std::ptr::null()
17793 };
17794 let result = unsafe {
17795 ffi::wgpuAdapterCreateDevice(self.raw, descriptor_ptr)
17796 };
17797 unsafe { Device::from_raw(result) }
17798 }
17799 pub fn get_format_capabilities(
17800 &self,
17801 format: TextureFormat,
17802 capabilities: &mut DawnFormatCapabilities,
17803 ) -> Status {
17804 let format_ffi: ffi::WGPUTextureFormat = format.into();
17805 let (mut capabilities_ffi, _capabilities_storage) = capabilities.to_ffi();
17806 let capabilities_ptr = std::ptr::addr_of_mut!(capabilities_ffi);
17807 let result = unsafe {
17808 ffi::wgpuAdapterGetFormatCapabilities(
17809 self.raw,
17810 format_ffi,
17811 capabilities_ptr,
17812 )
17813 };
17814 *capabilities = DawnFormatCapabilities::from_ffi(capabilities_ffi);
17815 result.into()
17816 }
17817 }
17818 impl Drop for Adapter {
17819 fn drop(&mut self) {
17820 if self.as_raw().is_null() {
17821 return;
17822 }
17823 unsafe { ffi::wgpuAdapterRelease(self.raw) };
17824 }
17825 }
17826 impl Clone for Adapter {
17827 fn clone(&self) -> Self {
17828 unsafe { ffi::wgpuAdapterAddRef(self.raw) };
17829 Self {
17830 raw: self.raw,
17831 _not_sync: std::marker::PhantomData,
17832 }
17833 }
17834 }
17835 unsafe impl Send for Adapter {}
17836 #[derive(Debug)]
17837 pub struct BindGroup {
17838 raw: ffi::WGPUBindGroup,
17839 }
17840 impl BindGroup {
17841 pub(crate) unsafe fn from_raw(raw: ffi::WGPUBindGroup) -> Self {
17842 Self { raw }
17843 }
17844 pub fn as_raw(&self) -> ffi::WGPUBindGroup {
17845 self.raw
17846 }
17847 pub fn set_label(&self, label: String) -> () {
17848 let label_ffi = ffi::WGPUStringView {
17849 data: label.as_ptr().cast(),
17850 length: label.len(),
17851 };
17852 unsafe { ffi::wgpuBindGroupSetLabel(self.raw, label_ffi) };
17853 ()
17854 }
17855 }
17856 impl Drop for BindGroup {
17857 fn drop(&mut self) {
17858 if self.as_raw().is_null() {
17859 return;
17860 }
17861 unsafe { ffi::wgpuBindGroupRelease(self.raw) };
17862 }
17863 }
17864 impl Clone for BindGroup {
17865 fn clone(&self) -> Self {
17866 unsafe { ffi::wgpuBindGroupAddRef(self.raw) };
17867 Self { raw: self.raw }
17868 }
17869 }
17870 unsafe impl Send for BindGroup {}
17871 unsafe impl Sync for BindGroup {}
17872 #[derive(Debug)]
17873 pub struct BindGroupLayout {
17874 raw: ffi::WGPUBindGroupLayout,
17875 }
17876 impl BindGroupLayout {
17877 pub(crate) unsafe fn from_raw(raw: ffi::WGPUBindGroupLayout) -> Self {
17878 Self { raw }
17879 }
17880 pub fn as_raw(&self) -> ffi::WGPUBindGroupLayout {
17881 self.raw
17882 }
17883 pub fn set_label(&self, label: String) -> () {
17884 let label_ffi = ffi::WGPUStringView {
17885 data: label.as_ptr().cast(),
17886 length: label.len(),
17887 };
17888 unsafe { ffi::wgpuBindGroupLayoutSetLabel(self.raw, label_ffi) };
17889 ()
17890 }
17891 }
17892 impl Drop for BindGroupLayout {
17893 fn drop(&mut self) {
17894 if self.as_raw().is_null() {
17895 return;
17896 }
17897 unsafe { ffi::wgpuBindGroupLayoutRelease(self.raw) };
17898 }
17899 }
17900 impl Clone for BindGroupLayout {
17901 fn clone(&self) -> Self {
17902 unsafe { ffi::wgpuBindGroupLayoutAddRef(self.raw) };
17903 Self { raw: self.raw }
17904 }
17905 }
17906 unsafe impl Send for BindGroupLayout {}
17907 unsafe impl Sync for BindGroupLayout {}
17908 #[derive(Debug)]
17909 pub struct Buffer {
17910 raw: ffi::WGPUBuffer,
17911 }
17912 impl Buffer {
17913 pub(crate) unsafe fn from_raw(raw: ffi::WGPUBuffer) -> Self {
17914 Self { raw }
17915 }
17916 pub fn as_raw(&self) -> ffi::WGPUBuffer {
17917 self.raw
17918 }
17919 pub fn map_async(
17920 &self,
17921 mode: MapMode,
17922 offset: usize,
17923 size: usize,
17924 callback: impl FnMut(MapAsyncStatus, String) + Send + 'static,
17925 ) -> Future {
17926 let mode_ffi: ffi::WGPUMapMode = mode.into();
17927 let callback_box: BufferMapCallback = Box::new(callback);
17928 let callback_box = Box::new(Some(callback_box));
17929 let callback_userdata = Box::into_raw(callback_box)
17930 .cast::<std::ffi::c_void>();
17931 let callback_info_ffi = ffi::WGPUBufferMapCallbackInfo {
17932 nextInChain: std::ptr::null_mut(),
17933 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
17934 callback: Some(buffer_map_callback_trampoline),
17935 userdata1: callback_userdata,
17936 userdata2: std::ptr::null_mut(),
17937 };
17938 let result = unsafe {
17939 ffi::wgpuBufferMapAsync(
17940 self.raw,
17941 mode_ffi,
17942 offset,
17943 size,
17944 callback_info_ffi,
17945 )
17946 };
17947 Future::from_ffi(result)
17948 }
17949 pub fn get_mapped_range(
17950 &self,
17951 offset: usize,
17952 size: usize,
17953 ) -> *mut std::ffi::c_void {
17954 let result = unsafe {
17955 ffi::wgpuBufferGetMappedRange(self.raw, offset, size)
17956 };
17957 result
17958 }
17959 pub fn get_const_mapped_range(
17960 &self,
17961 offset: usize,
17962 size: usize,
17963 ) -> *const std::ffi::c_void {
17964 let result = unsafe {
17965 ffi::wgpuBufferGetConstMappedRange(self.raw, offset, size)
17966 };
17967 result
17968 }
17969 pub fn write_mapped_range(
17970 &self,
17971 offset: usize,
17972 data: &[std::ffi::c_void],
17973 ) -> Status {
17974 let data_ptr = data.as_ptr();
17975 let result = unsafe {
17976 ffi::wgpuBufferWriteMappedRange(self.raw, offset, data_ptr, data.len())
17977 };
17978 result.into()
17979 }
17980 pub fn read_mapped_range(
17981 &self,
17982 offset: usize,
17983 mut data: &mut [std::ffi::c_void],
17984 ) -> Status {
17985 let data_ptr = data.as_mut_ptr();
17986 let result = unsafe {
17987 ffi::wgpuBufferReadMappedRange(self.raw, offset, data_ptr, data.len())
17988 };
17989 result.into()
17990 }
17991 pub fn create_texel_view(
17992 &self,
17993 descriptor: &TexelBufferViewDescriptor,
17994 ) -> TexelBufferView {
17995 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
17996 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
17997 let result = unsafe {
17998 ffi::wgpuBufferCreateTexelView(self.raw, descriptor_ptr)
17999 };
18000 unsafe { TexelBufferView::from_raw(result) }
18001 }
18002 pub fn set_label(&self, label: String) -> () {
18003 let label_ffi = ffi::WGPUStringView {
18004 data: label.as_ptr().cast(),
18005 length: label.len(),
18006 };
18007 unsafe { ffi::wgpuBufferSetLabel(self.raw, label_ffi) };
18008 ()
18009 }
18010 pub fn get_usage(&self) -> BufferUsage {
18011 let result = unsafe { ffi::wgpuBufferGetUsage(self.raw) };
18012 result.into()
18013 }
18014 pub fn get_size(&self) -> u64 {
18015 let result = unsafe { ffi::wgpuBufferGetSize(self.raw) };
18016 result
18017 }
18018 pub fn get_map_state(&self) -> BufferMapState {
18019 let result = unsafe { ffi::wgpuBufferGetMapState(self.raw) };
18020 result.into()
18021 }
18022 pub fn unmap(&self) -> () {
18023 unsafe { ffi::wgpuBufferUnmap(self.raw) };
18024 ()
18025 }
18026 pub fn destroy(&self) -> () {
18027 unsafe { ffi::wgpuBufferDestroy(self.raw) };
18028 ()
18029 }
18030 }
18031 impl Drop for Buffer {
18032 fn drop(&mut self) {
18033 if self.as_raw().is_null() {
18034 return;
18035 }
18036 unsafe { ffi::wgpuBufferRelease(self.raw) };
18037 }
18038 }
18039 impl Clone for Buffer {
18040 fn clone(&self) -> Self {
18041 unsafe { ffi::wgpuBufferAddRef(self.raw) };
18042 Self { raw: self.raw }
18043 }
18044 }
18045 unsafe impl Send for Buffer {}
18046 unsafe impl Sync for Buffer {}
18047 #[derive(Debug)]
18048 pub struct CommandBuffer {
18049 raw: ffi::WGPUCommandBuffer,
18050 }
18051 impl CommandBuffer {
18052 pub(crate) unsafe fn from_raw(raw: ffi::WGPUCommandBuffer) -> Self {
18053 Self { raw }
18054 }
18055 pub fn as_raw(&self) -> ffi::WGPUCommandBuffer {
18056 self.raw
18057 }
18058 pub fn set_label(&self, label: String) -> () {
18059 let label_ffi = ffi::WGPUStringView {
18060 data: label.as_ptr().cast(),
18061 length: label.len(),
18062 };
18063 unsafe { ffi::wgpuCommandBufferSetLabel(self.raw, label_ffi) };
18064 ()
18065 }
18066 }
18067 impl Drop for CommandBuffer {
18068 fn drop(&mut self) {
18069 if self.as_raw().is_null() {
18070 return;
18071 }
18072 unsafe { ffi::wgpuCommandBufferRelease(self.raw) };
18073 }
18074 }
18075 impl Clone for CommandBuffer {
18076 fn clone(&self) -> Self {
18077 unsafe { ffi::wgpuCommandBufferAddRef(self.raw) };
18078 Self { raw: self.raw }
18079 }
18080 }
18081 unsafe impl Send for CommandBuffer {}
18082 unsafe impl Sync for CommandBuffer {}
18083 #[derive(Debug)]
18084 pub struct CommandEncoder {
18085 raw: ffi::WGPUCommandEncoder,
18086 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
18087 }
18088 impl CommandEncoder {
18089 pub(crate) unsafe fn from_raw(raw: ffi::WGPUCommandEncoder) -> Self {
18090 Self {
18091 raw,
18092 _not_sync: std::marker::PhantomData,
18093 }
18094 }
18095 pub fn as_raw(&self) -> ffi::WGPUCommandEncoder {
18096 self.raw
18097 }
18098 pub fn finish(
18099 &self,
18100 descriptor: Option<&CommandBufferDescriptor>,
18101 ) -> CommandBuffer {
18102 let mut descriptor_storage = ChainedStructStorage::new();
18103 let descriptor_ptr = if let Some(value) = &descriptor {
18104 let (descriptor_ffi, storage) = value.to_ffi();
18105 descriptor_storage = storage;
18106 std::ptr::addr_of!(descriptor_ffi)
18107 } else {
18108 std::ptr::null()
18109 };
18110 let result = unsafe {
18111 ffi::wgpuCommandEncoderFinish(self.raw, descriptor_ptr)
18112 };
18113 unsafe { CommandBuffer::from_raw(result) }
18114 }
18115 pub fn begin_compute_pass(
18116 &self,
18117 descriptor: Option<&ComputePassDescriptor>,
18118 ) -> ComputePassEncoder {
18119 let mut descriptor_storage = ChainedStructStorage::new();
18120 let descriptor_ptr = if let Some(value) = &descriptor {
18121 let (descriptor_ffi, storage) = value.to_ffi();
18122 descriptor_storage = storage;
18123 std::ptr::addr_of!(descriptor_ffi)
18124 } else {
18125 std::ptr::null()
18126 };
18127 let result = unsafe {
18128 ffi::wgpuCommandEncoderBeginComputePass(self.raw, descriptor_ptr)
18129 };
18130 unsafe { ComputePassEncoder::from_raw(result) }
18131 }
18132 pub fn begin_render_pass(
18133 &self,
18134 descriptor: &RenderPassDescriptor,
18135 ) -> RenderPassEncoder {
18136 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18137 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18138 let result = unsafe {
18139 ffi::wgpuCommandEncoderBeginRenderPass(self.raw, descriptor_ptr)
18140 };
18141 unsafe { RenderPassEncoder::from_raw(result) }
18142 }
18143 pub fn copy_buffer_to_buffer(
18144 &self,
18145 source: Buffer,
18146 source_offset: u64,
18147 destination: Buffer,
18148 destination_offset: u64,
18149 size: u64,
18150 ) -> () {
18151 unsafe {
18152 ffi::wgpuCommandEncoderCopyBufferToBuffer(
18153 self.raw,
18154 source.as_raw(),
18155 source_offset,
18156 destination.as_raw(),
18157 destination_offset,
18158 size,
18159 )
18160 };
18161 ()
18162 }
18163 pub fn copy_buffer_to_texture(
18164 &self,
18165 source: &TexelCopyBufferInfo,
18166 destination: &TexelCopyTextureInfo,
18167 copy_size: &Extent3D,
18168 ) -> () {
18169 let (source_ffi, _source_storage) = source.to_ffi();
18170 let source_ptr = std::ptr::addr_of!(source_ffi);
18171 let (destination_ffi, _destination_storage) = destination.to_ffi();
18172 let destination_ptr = std::ptr::addr_of!(destination_ffi);
18173 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18174 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18175 unsafe {
18176 ffi::wgpuCommandEncoderCopyBufferToTexture(
18177 self.raw,
18178 source_ptr,
18179 destination_ptr,
18180 copy_size_ptr,
18181 )
18182 };
18183 ()
18184 }
18185 pub fn copy_texture_to_buffer(
18186 &self,
18187 source: &TexelCopyTextureInfo,
18188 destination: &TexelCopyBufferInfo,
18189 copy_size: &Extent3D,
18190 ) -> () {
18191 let (source_ffi, _source_storage) = source.to_ffi();
18192 let source_ptr = std::ptr::addr_of!(source_ffi);
18193 let (destination_ffi, _destination_storage) = destination.to_ffi();
18194 let destination_ptr = std::ptr::addr_of!(destination_ffi);
18195 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18196 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18197 unsafe {
18198 ffi::wgpuCommandEncoderCopyTextureToBuffer(
18199 self.raw,
18200 source_ptr,
18201 destination_ptr,
18202 copy_size_ptr,
18203 )
18204 };
18205 ()
18206 }
18207 pub fn copy_texture_to_texture(
18208 &self,
18209 source: &TexelCopyTextureInfo,
18210 destination: &TexelCopyTextureInfo,
18211 copy_size: &Extent3D,
18212 ) -> () {
18213 let (source_ffi, _source_storage) = source.to_ffi();
18214 let source_ptr = std::ptr::addr_of!(source_ffi);
18215 let (destination_ffi, _destination_storage) = destination.to_ffi();
18216 let destination_ptr = std::ptr::addr_of!(destination_ffi);
18217 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18218 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18219 unsafe {
18220 ffi::wgpuCommandEncoderCopyTextureToTexture(
18221 self.raw,
18222 source_ptr,
18223 destination_ptr,
18224 copy_size_ptr,
18225 )
18226 };
18227 ()
18228 }
18229 pub fn clear_buffer(&self, buffer: Buffer, offset: u64, size: u64) -> () {
18230 unsafe {
18231 ffi::wgpuCommandEncoderClearBuffer(
18232 self.raw,
18233 buffer.as_raw(),
18234 offset,
18235 size,
18236 )
18237 };
18238 ()
18239 }
18240 pub fn inject_validation_error(&self, message: String) -> () {
18241 let message_ffi = ffi::WGPUStringView {
18242 data: message.as_ptr().cast(),
18243 length: message.len(),
18244 };
18245 unsafe {
18246 ffi::wgpuCommandEncoderInjectValidationError(self.raw, message_ffi)
18247 };
18248 ()
18249 }
18250 pub fn insert_debug_marker(&self, marker_label: String) -> () {
18251 let marker_label_ffi = ffi::WGPUStringView {
18252 data: marker_label.as_ptr().cast(),
18253 length: marker_label.len(),
18254 };
18255 unsafe {
18256 ffi::wgpuCommandEncoderInsertDebugMarker(self.raw, marker_label_ffi)
18257 };
18258 ()
18259 }
18260 pub fn pop_debug_group(&self) -> () {
18261 unsafe { ffi::wgpuCommandEncoderPopDebugGroup(self.raw) };
18262 ()
18263 }
18264 pub fn push_debug_group(&self, group_label: String) -> () {
18265 let group_label_ffi = ffi::WGPUStringView {
18266 data: group_label.as_ptr().cast(),
18267 length: group_label.len(),
18268 };
18269 unsafe { ffi::wgpuCommandEncoderPushDebugGroup(self.raw, group_label_ffi) };
18270 ()
18271 }
18272 pub fn resolve_query_set(
18273 &self,
18274 query_set: QuerySet,
18275 first_query: u32,
18276 query_count: u32,
18277 destination: Buffer,
18278 destination_offset: u64,
18279 ) -> () {
18280 unsafe {
18281 ffi::wgpuCommandEncoderResolveQuerySet(
18282 self.raw,
18283 query_set.as_raw(),
18284 first_query,
18285 query_count,
18286 destination.as_raw(),
18287 destination_offset,
18288 )
18289 };
18290 ()
18291 }
18292 pub fn write_buffer(
18293 &self,
18294 buffer: Buffer,
18295 buffer_offset: u64,
18296 data: &[u8],
18297 ) -> () {
18298 let data_ptr = data.as_ptr();
18299 unsafe {
18300 ffi::wgpuCommandEncoderWriteBuffer(
18301 self.raw,
18302 buffer.as_raw(),
18303 buffer_offset,
18304 data_ptr,
18305 (data.len()) as u64,
18306 )
18307 };
18308 ()
18309 }
18310 pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
18311 unsafe {
18312 ffi::wgpuCommandEncoderWriteTimestamp(
18313 self.raw,
18314 query_set.as_raw(),
18315 query_index,
18316 )
18317 };
18318 ()
18319 }
18320 pub fn set_label(&self, label: String) -> () {
18321 let label_ffi = ffi::WGPUStringView {
18322 data: label.as_ptr().cast(),
18323 length: label.len(),
18324 };
18325 unsafe { ffi::wgpuCommandEncoderSetLabel(self.raw, label_ffi) };
18326 ()
18327 }
18328 }
18329 impl Drop for CommandEncoder {
18330 fn drop(&mut self) {
18331 if self.as_raw().is_null() {
18332 return;
18333 }
18334 unsafe { ffi::wgpuCommandEncoderRelease(self.raw) };
18335 }
18336 }
18337 impl Clone for CommandEncoder {
18338 fn clone(&self) -> Self {
18339 unsafe { ffi::wgpuCommandEncoderAddRef(self.raw) };
18340 Self {
18341 raw: self.raw,
18342 _not_sync: std::marker::PhantomData,
18343 }
18344 }
18345 }
18346 unsafe impl Send for CommandEncoder {}
18347 #[derive(Debug)]
18348 pub struct ComputePassEncoder {
18349 raw: ffi::WGPUComputePassEncoder,
18350 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
18351 }
18352 impl ComputePassEncoder {
18353 pub(crate) unsafe fn from_raw(raw: ffi::WGPUComputePassEncoder) -> Self {
18354 Self {
18355 raw,
18356 _not_sync: std::marker::PhantomData,
18357 }
18358 }
18359 pub fn as_raw(&self) -> ffi::WGPUComputePassEncoder {
18360 self.raw
18361 }
18362 pub fn insert_debug_marker(&self, marker_label: String) -> () {
18363 let marker_label_ffi = ffi::WGPUStringView {
18364 data: marker_label.as_ptr().cast(),
18365 length: marker_label.len(),
18366 };
18367 unsafe {
18368 ffi::wgpuComputePassEncoderInsertDebugMarker(self.raw, marker_label_ffi)
18369 };
18370 ()
18371 }
18372 pub fn pop_debug_group(&self) -> () {
18373 unsafe { ffi::wgpuComputePassEncoderPopDebugGroup(self.raw) };
18374 ()
18375 }
18376 pub fn push_debug_group(&self, group_label: String) -> () {
18377 let group_label_ffi = ffi::WGPUStringView {
18378 data: group_label.as_ptr().cast(),
18379 length: group_label.len(),
18380 };
18381 unsafe {
18382 ffi::wgpuComputePassEncoderPushDebugGroup(self.raw, group_label_ffi)
18383 };
18384 ()
18385 }
18386 pub fn set_pipeline(&self, pipeline: ComputePipeline) -> () {
18387 unsafe {
18388 ffi::wgpuComputePassEncoderSetPipeline(self.raw, pipeline.as_raw())
18389 };
18390 ()
18391 }
18392 pub fn set_bind_group(
18393 &self,
18394 group_index: u32,
18395 group: Option<BindGroup>,
18396 dynamic_offsets: &[u32],
18397 ) -> () {
18398 let group_raw = group
18399 .as_ref()
18400 .map(|v| v.as_raw())
18401 .unwrap_or(std::ptr::null_mut());
18402 let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
18403 unsafe {
18404 ffi::wgpuComputePassEncoderSetBindGroup(
18405 self.raw,
18406 group_index,
18407 group_raw,
18408 dynamic_offsets.len(),
18409 dynamic_offsets_ptr,
18410 )
18411 };
18412 ()
18413 }
18414 pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
18415 unsafe {
18416 ffi::wgpuComputePassEncoderWriteTimestamp(
18417 self.raw,
18418 query_set.as_raw(),
18419 query_index,
18420 )
18421 };
18422 ()
18423 }
18424 pub fn dispatch_workgroups(
18425 &self,
18426 workgroup_count_x: u32,
18427 workgroup_count_y: u32,
18428 workgroup_count_z: u32,
18429 ) -> () {
18430 unsafe {
18431 ffi::wgpuComputePassEncoderDispatchWorkgroups(
18432 self.raw,
18433 workgroup_count_x,
18434 workgroup_count_y,
18435 workgroup_count_z,
18436 )
18437 };
18438 ()
18439 }
18440 pub fn dispatch_workgroups_indirect(
18441 &self,
18442 indirect_buffer: Buffer,
18443 indirect_offset: u64,
18444 ) -> () {
18445 unsafe {
18446 ffi::wgpuComputePassEncoderDispatchWorkgroupsIndirect(
18447 self.raw,
18448 indirect_buffer.as_raw(),
18449 indirect_offset,
18450 )
18451 };
18452 ()
18453 }
18454 pub fn end(&self) -> () {
18455 unsafe { ffi::wgpuComputePassEncoderEnd(self.raw) };
18456 ()
18457 }
18458 pub fn set_label(&self, label: String) -> () {
18459 let label_ffi = ffi::WGPUStringView {
18460 data: label.as_ptr().cast(),
18461 length: label.len(),
18462 };
18463 unsafe { ffi::wgpuComputePassEncoderSetLabel(self.raw, label_ffi) };
18464 ()
18465 }
18466 pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
18467 let data_ptr = data.as_ptr();
18468 unsafe {
18469 ffi::wgpuComputePassEncoderSetImmediates(
18470 self.raw,
18471 offset,
18472 data_ptr,
18473 data.len(),
18474 )
18475 };
18476 ()
18477 }
18478 pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
18479 let table_raw = table
18480 .as_ref()
18481 .map(|v| v.as_raw())
18482 .unwrap_or(std::ptr::null_mut());
18483 unsafe { ffi::wgpuComputePassEncoderSetResourceTable(self.raw, table_raw) };
18484 ()
18485 }
18486 }
18487 impl Drop for ComputePassEncoder {
18488 fn drop(&mut self) {
18489 if self.as_raw().is_null() {
18490 return;
18491 }
18492 unsafe { ffi::wgpuComputePassEncoderRelease(self.raw) };
18493 }
18494 }
18495 impl Clone for ComputePassEncoder {
18496 fn clone(&self) -> Self {
18497 unsafe { ffi::wgpuComputePassEncoderAddRef(self.raw) };
18498 Self {
18499 raw: self.raw,
18500 _not_sync: std::marker::PhantomData,
18501 }
18502 }
18503 }
18504 unsafe impl Send for ComputePassEncoder {}
18505 #[derive(Debug)]
18506 pub struct ComputePipeline {
18507 raw: ffi::WGPUComputePipeline,
18508 }
18509 impl ComputePipeline {
18510 pub(crate) unsafe fn from_raw(raw: ffi::WGPUComputePipeline) -> Self {
18511 Self { raw }
18512 }
18513 pub fn as_raw(&self) -> ffi::WGPUComputePipeline {
18514 self.raw
18515 }
18516 pub fn get_bind_group_layout(&self, group_index: u32) -> BindGroupLayout {
18517 let result = unsafe {
18518 ffi::wgpuComputePipelineGetBindGroupLayout(self.raw, group_index)
18519 };
18520 unsafe { BindGroupLayout::from_raw(result) }
18521 }
18522 pub fn set_label(&self, label: String) -> () {
18523 let label_ffi = ffi::WGPUStringView {
18524 data: label.as_ptr().cast(),
18525 length: label.len(),
18526 };
18527 unsafe { ffi::wgpuComputePipelineSetLabel(self.raw, label_ffi) };
18528 ()
18529 }
18530 }
18531 impl Drop for ComputePipeline {
18532 fn drop(&mut self) {
18533 if self.as_raw().is_null() {
18534 return;
18535 }
18536 unsafe { ffi::wgpuComputePipelineRelease(self.raw) };
18537 }
18538 }
18539 impl Clone for ComputePipeline {
18540 fn clone(&self) -> Self {
18541 unsafe { ffi::wgpuComputePipelineAddRef(self.raw) };
18542 Self { raw: self.raw }
18543 }
18544 }
18545 unsafe impl Send for ComputePipeline {}
18546 unsafe impl Sync for ComputePipeline {}
18547 #[derive(Debug)]
18548 pub struct Device {
18549 raw: ffi::WGPUDevice,
18550 }
18551 impl Device {
18552 pub(crate) unsafe fn from_raw(raw: ffi::WGPUDevice) -> Self {
18553 Self { raw }
18554 }
18555 pub fn as_raw(&self) -> ffi::WGPUDevice {
18556 self.raw
18557 }
18558 pub fn create_bind_group(&self, descriptor: &BindGroupDescriptor) -> BindGroup {
18559 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18560 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18561 let result = unsafe {
18562 ffi::wgpuDeviceCreateBindGroup(self.raw, descriptor_ptr)
18563 };
18564 unsafe { BindGroup::from_raw(result) }
18565 }
18566 pub fn create_bind_group_layout(
18567 &self,
18568 descriptor: &BindGroupLayoutDescriptor,
18569 ) -> BindGroupLayout {
18570 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18571 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18572 let result = unsafe {
18573 ffi::wgpuDeviceCreateBindGroupLayout(self.raw, descriptor_ptr)
18574 };
18575 unsafe { BindGroupLayout::from_raw(result) }
18576 }
18577 pub fn create_buffer(&self, descriptor: &BufferDescriptor) -> Option<Buffer> {
18578 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18579 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18580 let result = unsafe {
18581 ffi::wgpuDeviceCreateBuffer(self.raw, descriptor_ptr)
18582 };
18583 if result.is_null() {
18584 None
18585 } else {
18586 Some(unsafe { Buffer::from_raw(result) })
18587 }
18588 }
18589 pub fn create_error_buffer(&self, descriptor: &BufferDescriptor) -> Buffer {
18590 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18591 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18592 let result = unsafe {
18593 ffi::wgpuDeviceCreateErrorBuffer(self.raw, descriptor_ptr)
18594 };
18595 unsafe { Buffer::from_raw(result) }
18596 }
18597 pub fn create_command_encoder(
18598 &self,
18599 descriptor: Option<&CommandEncoderDescriptor>,
18600 ) -> CommandEncoder {
18601 let mut descriptor_storage = ChainedStructStorage::new();
18602 let descriptor_ptr = if let Some(value) = &descriptor {
18603 let (descriptor_ffi, storage) = value.to_ffi();
18604 descriptor_storage = storage;
18605 std::ptr::addr_of!(descriptor_ffi)
18606 } else {
18607 std::ptr::null()
18608 };
18609 let result = unsafe {
18610 ffi::wgpuDeviceCreateCommandEncoder(self.raw, descriptor_ptr)
18611 };
18612 unsafe { CommandEncoder::from_raw(result) }
18613 }
18614 pub fn create_compute_pipeline(
18615 &self,
18616 descriptor: &ComputePipelineDescriptor,
18617 ) -> ComputePipeline {
18618 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18619 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18620 let result = unsafe {
18621 ffi::wgpuDeviceCreateComputePipeline(self.raw, descriptor_ptr)
18622 };
18623 unsafe { ComputePipeline::from_raw(result) }
18624 }
18625 pub fn create_compute_pipeline_async(
18626 &self,
18627 descriptor: &ComputePipelineDescriptor,
18628 callback: impl FnMut(
18629 CreatePipelineAsyncStatus,
18630 Option<ComputePipeline>,
18631 String,
18632 ) + Send + 'static,
18633 ) -> Future {
18634 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18635 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18636 let callback_box: CreateComputePipelineAsyncCallback = Box::new(callback);
18637 let callback_box = Box::new(Some(callback_box));
18638 let callback_userdata = Box::into_raw(callback_box)
18639 .cast::<std::ffi::c_void>();
18640 let callback_info_ffi = ffi::WGPUCreateComputePipelineAsyncCallbackInfo {
18641 nextInChain: std::ptr::null_mut(),
18642 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18643 callback: Some(create_compute_pipeline_async_callback_trampoline),
18644 userdata1: callback_userdata,
18645 userdata2: std::ptr::null_mut(),
18646 };
18647 let result = unsafe {
18648 ffi::wgpuDeviceCreateComputePipelineAsync(
18649 self.raw,
18650 descriptor_ptr,
18651 callback_info_ffi,
18652 )
18653 };
18654 Future::from_ffi(result)
18655 }
18656 pub fn create_external_texture(
18657 &self,
18658 external_texture_descriptor: &ExternalTextureDescriptor,
18659 ) -> ExternalTexture {
18660 let (
18661 external_texture_descriptor_ffi,
18662 _external_texture_descriptor_storage,
18663 ) = external_texture_descriptor.to_ffi();
18664 let external_texture_descriptor_ptr = std::ptr::addr_of!(
18665 external_texture_descriptor_ffi
18666 );
18667 let result = unsafe {
18668 ffi::wgpuDeviceCreateExternalTexture(
18669 self.raw,
18670 external_texture_descriptor_ptr,
18671 )
18672 };
18673 unsafe { ExternalTexture::from_raw(result) }
18674 }
18675 pub fn create_error_external_texture(&self) -> ExternalTexture {
18676 let result = unsafe { ffi::wgpuDeviceCreateErrorExternalTexture(self.raw) };
18677 unsafe { ExternalTexture::from_raw(result) }
18678 }
18679 pub fn create_pipeline_layout(
18680 &self,
18681 descriptor: &PipelineLayoutDescriptor,
18682 ) -> PipelineLayout {
18683 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18684 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18685 let result = unsafe {
18686 ffi::wgpuDeviceCreatePipelineLayout(self.raw, descriptor_ptr)
18687 };
18688 unsafe { PipelineLayout::from_raw(result) }
18689 }
18690 pub fn create_query_set(&self, descriptor: &QuerySetDescriptor) -> QuerySet {
18691 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18692 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18693 let result = unsafe {
18694 ffi::wgpuDeviceCreateQuerySet(self.raw, descriptor_ptr)
18695 };
18696 unsafe { QuerySet::from_raw(result) }
18697 }
18698 pub fn create_render_pipeline_async(
18699 &self,
18700 descriptor: &RenderPipelineDescriptor,
18701 callback: impl FnMut(
18702 CreatePipelineAsyncStatus,
18703 Option<RenderPipeline>,
18704 String,
18705 ) + Send + 'static,
18706 ) -> Future {
18707 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18708 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18709 let callback_box: CreateRenderPipelineAsyncCallback = Box::new(callback);
18710 let callback_box = Box::new(Some(callback_box));
18711 let callback_userdata = Box::into_raw(callback_box)
18712 .cast::<std::ffi::c_void>();
18713 let callback_info_ffi = ffi::WGPUCreateRenderPipelineAsyncCallbackInfo {
18714 nextInChain: std::ptr::null_mut(),
18715 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18716 callback: Some(create_render_pipeline_async_callback_trampoline),
18717 userdata1: callback_userdata,
18718 userdata2: std::ptr::null_mut(),
18719 };
18720 let result = unsafe {
18721 ffi::wgpuDeviceCreateRenderPipelineAsync(
18722 self.raw,
18723 descriptor_ptr,
18724 callback_info_ffi,
18725 )
18726 };
18727 Future::from_ffi(result)
18728 }
18729 pub fn create_render_bundle_encoder(
18730 &self,
18731 descriptor: &RenderBundleEncoderDescriptor,
18732 ) -> RenderBundleEncoder {
18733 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18734 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18735 let result = unsafe {
18736 ffi::wgpuDeviceCreateRenderBundleEncoder(self.raw, descriptor_ptr)
18737 };
18738 unsafe { RenderBundleEncoder::from_raw(result) }
18739 }
18740 pub fn create_render_pipeline(
18741 &self,
18742 descriptor: &RenderPipelineDescriptor,
18743 ) -> RenderPipeline {
18744 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18745 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18746 let result = unsafe {
18747 ffi::wgpuDeviceCreateRenderPipeline(self.raw, descriptor_ptr)
18748 };
18749 unsafe { RenderPipeline::from_raw(result) }
18750 }
18751 pub fn create_sampler(&self, descriptor: Option<&SamplerDescriptor>) -> Sampler {
18752 let mut descriptor_storage = ChainedStructStorage::new();
18753 let descriptor_ptr = if let Some(value) = &descriptor {
18754 let (descriptor_ffi, storage) = value.to_ffi();
18755 descriptor_storage = storage;
18756 std::ptr::addr_of!(descriptor_ffi)
18757 } else {
18758 std::ptr::null()
18759 };
18760 let result = unsafe {
18761 ffi::wgpuDeviceCreateSampler(self.raw, descriptor_ptr)
18762 };
18763 unsafe { Sampler::from_raw(result) }
18764 }
18765 pub fn create_shader_module(
18766 &self,
18767 descriptor: &ShaderModuleDescriptor,
18768 ) -> ShaderModule {
18769 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18770 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18771 let result = unsafe {
18772 ffi::wgpuDeviceCreateShaderModule(self.raw, descriptor_ptr)
18773 };
18774 unsafe { ShaderModule::from_raw(result) }
18775 }
18776 pub fn create_error_shader_module(
18777 &self,
18778 descriptor: &ShaderModuleDescriptor,
18779 error_message: String,
18780 ) -> ShaderModule {
18781 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18782 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18783 let error_message_ffi = ffi::WGPUStringView {
18784 data: error_message.as_ptr().cast(),
18785 length: error_message.len(),
18786 };
18787 let result = unsafe {
18788 ffi::wgpuDeviceCreateErrorShaderModule(
18789 self.raw,
18790 descriptor_ptr,
18791 error_message_ffi,
18792 )
18793 };
18794 unsafe { ShaderModule::from_raw(result) }
18795 }
18796 pub fn create_texture(&self, descriptor: &TextureDescriptor) -> Texture {
18797 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18798 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18799 let result = unsafe {
18800 ffi::wgpuDeviceCreateTexture(self.raw, descriptor_ptr)
18801 };
18802 unsafe { Texture::from_raw(result) }
18803 }
18804 pub fn create_resource_table(
18805 &self,
18806 descriptor: &ResourceTableDescriptor,
18807 ) -> ResourceTable {
18808 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18809 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18810 let result = unsafe {
18811 ffi::wgpuDeviceCreateResourceTable(self.raw, descriptor_ptr)
18812 };
18813 unsafe { ResourceTable::from_raw(result) }
18814 }
18815 pub fn import_shared_buffer_memory(
18816 &self,
18817 descriptor: &SharedBufferMemoryDescriptor,
18818 ) -> SharedBufferMemory {
18819 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18820 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18821 let result = unsafe {
18822 ffi::wgpuDeviceImportSharedBufferMemory(self.raw, descriptor_ptr)
18823 };
18824 unsafe { SharedBufferMemory::from_raw(result) }
18825 }
18826 pub fn import_shared_texture_memory(
18827 &self,
18828 descriptor: &SharedTextureMemoryDescriptor,
18829 ) -> SharedTextureMemory {
18830 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18831 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18832 let result = unsafe {
18833 ffi::wgpuDeviceImportSharedTextureMemory(self.raw, descriptor_ptr)
18834 };
18835 unsafe { SharedTextureMemory::from_raw(result) }
18836 }
18837 pub fn import_shared_fence(
18838 &self,
18839 descriptor: &SharedFenceDescriptor,
18840 ) -> SharedFence {
18841 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18842 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18843 let result = unsafe {
18844 ffi::wgpuDeviceImportSharedFence(self.raw, descriptor_ptr)
18845 };
18846 unsafe { SharedFence::from_raw(result) }
18847 }
18848 pub fn create_error_texture(&self, descriptor: &TextureDescriptor) -> Texture {
18849 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18850 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18851 let result = unsafe {
18852 ffi::wgpuDeviceCreateErrorTexture(self.raw, descriptor_ptr)
18853 };
18854 unsafe { Texture::from_raw(result) }
18855 }
18856 pub fn destroy(&self) -> () {
18857 unsafe { ffi::wgpuDeviceDestroy(self.raw) };
18858 ()
18859 }
18860 pub fn get_a_hardware_buffer_properties(
18861 &self,
18862 handle: *mut std::ffi::c_void,
18863 properties: &mut AHardwareBufferProperties,
18864 ) -> Status {
18865 let (mut properties_ffi, _properties_storage) = properties.to_ffi();
18866 let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
18867 let result = unsafe {
18868 ffi::wgpuDeviceGetAHardwareBufferProperties(
18869 self.raw,
18870 handle,
18871 properties_ptr,
18872 )
18873 };
18874 *properties = AHardwareBufferProperties::from_ffi(properties_ffi);
18875 result.into()
18876 }
18877 pub fn get_limits(&self, limits: &mut Limits) -> Status {
18878 let (mut limits_ffi, _limits_storage) = limits.to_ffi();
18879 let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
18880 let result = unsafe { ffi::wgpuDeviceGetLimits(self.raw, limits_ptr) };
18881 *limits = Limits::from_ffi(limits_ffi);
18882 result.into()
18883 }
18884 pub fn get_lost_future(&self) -> Future {
18885 let result = unsafe { ffi::wgpuDeviceGetLostFuture(self.raw) };
18886 Future::from_ffi(result)
18887 }
18888 pub fn has_feature(&self, feature: FeatureName) -> bool {
18889 let feature_ffi: ffi::WGPUFeatureName = feature.into();
18890 let result = unsafe { ffi::wgpuDeviceHasFeature(self.raw, feature_ffi) };
18891 result != 0
18892 }
18893 pub fn get_features(&self, features: &mut SupportedFeatures) -> () {
18894 let (mut features_ffi, _features_storage) = features.to_ffi();
18895 let features_ptr = std::ptr::addr_of_mut!(features_ffi);
18896 unsafe { ffi::wgpuDeviceGetFeatures(self.raw, features_ptr) };
18897 *features = SupportedFeatures::from_ffi(features_ffi);
18898 ()
18899 }
18900 pub fn get_adapter_info(&self, adapter_info: &mut AdapterInfo) -> Status {
18901 let (mut adapter_info_ffi, _adapter_info_storage) = adapter_info.to_ffi();
18902 let adapter_info_ptr = std::ptr::addr_of_mut!(adapter_info_ffi);
18903 let result = unsafe {
18904 ffi::wgpuDeviceGetAdapterInfo(self.raw, adapter_info_ptr)
18905 };
18906 *adapter_info = AdapterInfo::from_ffi(adapter_info_ffi);
18907 result.into()
18908 }
18909 pub fn get_adapter(&self) -> Adapter {
18910 let result = unsafe { ffi::wgpuDeviceGetAdapter(self.raw) };
18911 unsafe { Adapter::from_raw(result) }
18912 }
18913 pub fn get_queue(&self) -> Queue {
18914 let result = unsafe { ffi::wgpuDeviceGetQueue(self.raw) };
18915 unsafe { Queue::from_raw(result) }
18916 }
18917 pub fn inject_error(&self, r#type: ErrorType, message: String) -> () {
18918 let r#type_ffi: ffi::WGPUErrorType = r#type.into();
18919 let message_ffi = ffi::WGPUStringView {
18920 data: message.as_ptr().cast(),
18921 length: message.len(),
18922 };
18923 unsafe { ffi::wgpuDeviceInjectError(self.raw, r#type_ffi, message_ffi) };
18924 ()
18925 }
18926 pub fn force_loss(&self, r#type: DeviceLostReason, message: String) -> () {
18927 let r#type_ffi: ffi::WGPUDeviceLostReason = r#type.into();
18928 let message_ffi = ffi::WGPUStringView {
18929 data: message.as_ptr().cast(),
18930 length: message.len(),
18931 };
18932 unsafe { ffi::wgpuDeviceForceLoss(self.raw, r#type_ffi, message_ffi) };
18933 ()
18934 }
18935 pub fn tick(&self) -> () {
18936 unsafe { ffi::wgpuDeviceTick(self.raw) };
18937 ()
18938 }
18939 pub fn set_logging_callback(
18940 &self,
18941 callback: impl FnMut(LoggingType, String) + Send + 'static,
18942 ) -> () {
18943 let callback_box: LoggingCallback = Box::new(callback);
18944 let callback_box = Box::new(Some(callback_box));
18945 let callback_userdata = Box::into_raw(callback_box)
18946 .cast::<std::ffi::c_void>();
18947 let callback_info_ffi = ffi::WGPULoggingCallbackInfo {
18948 nextInChain: std::ptr::null_mut(),
18949 callback: Some(logging_callback_trampoline),
18950 userdata1: callback_userdata,
18951 userdata2: std::ptr::null_mut(),
18952 };
18953 unsafe { ffi::wgpuDeviceSetLoggingCallback(self.raw, callback_info_ffi) };
18954 ()
18955 }
18956 pub fn push_error_scope(&self, filter: ErrorFilter) -> () {
18957 let filter_ffi: ffi::WGPUErrorFilter = filter.into();
18958 unsafe { ffi::wgpuDevicePushErrorScope(self.raw, filter_ffi) };
18959 ()
18960 }
18961 pub fn pop_error_scope(
18962 &self,
18963 callback: impl FnMut(PopErrorScopeStatus, ErrorType, String) + Send + 'static,
18964 ) -> Future {
18965 let callback_box: PopErrorScopeCallback = Box::new(callback);
18966 let callback_box = Box::new(Some(callback_box));
18967 let callback_userdata = Box::into_raw(callback_box)
18968 .cast::<std::ffi::c_void>();
18969 let callback_info_ffi = ffi::WGPUPopErrorScopeCallbackInfo {
18970 nextInChain: std::ptr::null_mut(),
18971 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18972 callback: Some(pop_error_scope_callback_trampoline),
18973 userdata1: callback_userdata,
18974 userdata2: std::ptr::null_mut(),
18975 };
18976 let result = unsafe {
18977 ffi::wgpuDevicePopErrorScope(self.raw, callback_info_ffi)
18978 };
18979 Future::from_ffi(result)
18980 }
18981 pub fn set_label(&self, label: String) -> () {
18982 let label_ffi = ffi::WGPUStringView {
18983 data: label.as_ptr().cast(),
18984 length: label.len(),
18985 };
18986 unsafe { ffi::wgpuDeviceSetLabel(self.raw, label_ffi) };
18987 ()
18988 }
18989 pub fn validate_texture_descriptor(&self, descriptor: &TextureDescriptor) -> () {
18990 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18991 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18992 unsafe {
18993 ffi::wgpuDeviceValidateTextureDescriptor(self.raw, descriptor_ptr)
18994 };
18995 ()
18996 }
18997 }
18998 impl Drop for Device {
18999 fn drop(&mut self) {
19000 if self.as_raw().is_null() {
19001 return;
19002 }
19003 unsafe { ffi::wgpuDeviceRelease(self.raw) };
19004 }
19005 }
19006 impl Clone for Device {
19007 fn clone(&self) -> Self {
19008 unsafe { ffi::wgpuDeviceAddRef(self.raw) };
19009 Self { raw: self.raw }
19010 }
19011 }
19012 unsafe impl Send for Device {}
19013 unsafe impl Sync for Device {}
19014 #[derive(Debug)]
19015 pub struct ExternalTexture {
19016 raw: ffi::WGPUExternalTexture,
19017 }
19018 impl ExternalTexture {
19019 pub(crate) unsafe fn from_raw(raw: ffi::WGPUExternalTexture) -> Self {
19020 Self { raw }
19021 }
19022 pub fn as_raw(&self) -> ffi::WGPUExternalTexture {
19023 self.raw
19024 }
19025 pub fn set_label(&self, label: String) -> () {
19026 let label_ffi = ffi::WGPUStringView {
19027 data: label.as_ptr().cast(),
19028 length: label.len(),
19029 };
19030 unsafe { ffi::wgpuExternalTextureSetLabel(self.raw, label_ffi) };
19031 ()
19032 }
19033 pub fn destroy(&self) -> () {
19034 unsafe { ffi::wgpuExternalTextureDestroy(self.raw) };
19035 ()
19036 }
19037 pub fn expire(&self) -> () {
19038 unsafe { ffi::wgpuExternalTextureExpire(self.raw) };
19039 ()
19040 }
19041 pub fn refresh(&self) -> () {
19042 unsafe { ffi::wgpuExternalTextureRefresh(self.raw) };
19043 ()
19044 }
19045 }
19046 impl Drop for ExternalTexture {
19047 fn drop(&mut self) {
19048 if self.as_raw().is_null() {
19049 return;
19050 }
19051 unsafe { ffi::wgpuExternalTextureRelease(self.raw) };
19052 }
19053 }
19054 impl Clone for ExternalTexture {
19055 fn clone(&self) -> Self {
19056 unsafe { ffi::wgpuExternalTextureAddRef(self.raw) };
19057 Self { raw: self.raw }
19058 }
19059 }
19060 unsafe impl Send for ExternalTexture {}
19061 unsafe impl Sync for ExternalTexture {}
19062 #[derive(Debug)]
19063 pub struct Instance {
19064 raw: ffi::WGPUInstance,
19065 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
19066 }
19067 impl Instance {
19068 pub(crate) unsafe fn from_raw(raw: ffi::WGPUInstance) -> Self {
19069 Self {
19070 raw,
19071 _not_sync: std::marker::PhantomData,
19072 }
19073 }
19074 pub fn as_raw(&self) -> ffi::WGPUInstance {
19075 self.raw
19076 }
19077 pub fn new(descriptor: Option<&InstanceDescriptor>) -> Self {
19078 let mut descriptor_storage = ChainedStructStorage::new();
19079 let descriptor_ptr = if let Some(value) = &descriptor {
19080 let (descriptor_ffi, storage) = value.to_ffi();
19081 descriptor_storage = storage;
19082 std::ptr::addr_of!(descriptor_ffi)
19083 } else {
19084 std::ptr::null()
19085 };
19086 let result = unsafe { ffi::wgpuCreateInstance(descriptor_ptr) };
19087 unsafe { Instance::from_raw(result) }
19088 }
19089 pub fn create_surface(&self, descriptor: &SurfaceDescriptor) -> Surface {
19090 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19091 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19092 let result = unsafe {
19093 ffi::wgpuInstanceCreateSurface(self.raw, descriptor_ptr)
19094 };
19095 unsafe { Surface::from_raw(result) }
19096 }
19097 pub fn process_events(&self) -> () {
19098 unsafe { ffi::wgpuInstanceProcessEvents(self.raw) };
19099 ()
19100 }
19101 pub fn wait_any(
19102 &self,
19103 mut futures: Option<&mut [FutureWaitInfo]>,
19104 timeout_ns: u64,
19105 ) -> WaitStatus {
19106 let mut futures_raw: Vec<ffi::WGPUFutureWaitInfo> = Vec::new();
19107 let mut futures_storage: Vec<ChainedStructStorage> = Vec::new();
19108 let futures_ptr = if let Some(value) = futures.as_deref() {
19109 for item in value {
19110 let (raw, storage) = item.to_ffi();
19111 futures_raw.push(raw);
19112 futures_storage.push(storage);
19113 }
19114 futures_raw.as_mut_ptr()
19115 } else {
19116 std::ptr::null_mut()
19117 };
19118 let result = unsafe {
19119 ffi::wgpuInstanceWaitAny(
19120 self.raw,
19121 futures.as_deref().map(|v| v.len()).unwrap_or(0),
19122 futures_ptr,
19123 timeout_ns,
19124 )
19125 };
19126 result.into()
19127 }
19128 pub fn request_adapter(
19129 &self,
19130 options: Option<&RequestAdapterOptions>,
19131 callback: impl FnMut(
19132 RequestAdapterStatus,
19133 Option<Adapter>,
19134 String,
19135 ) + Send + 'static,
19136 ) -> Future {
19137 let mut options_storage = ChainedStructStorage::new();
19138 let options_ptr = if let Some(value) = &options {
19139 let (options_ffi, storage) = value.to_ffi();
19140 options_storage = storage;
19141 std::ptr::addr_of!(options_ffi)
19142 } else {
19143 std::ptr::null()
19144 };
19145 let callback_box: RequestAdapterCallback = Box::new(callback);
19146 let callback_box = Box::new(Some(callback_box));
19147 let callback_userdata = Box::into_raw(callback_box)
19148 .cast::<std::ffi::c_void>();
19149 let callback_info_ffi = ffi::WGPURequestAdapterCallbackInfo {
19150 nextInChain: std::ptr::null_mut(),
19151 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19152 callback: Some(request_adapter_callback_trampoline),
19153 userdata1: callback_userdata,
19154 userdata2: std::ptr::null_mut(),
19155 };
19156 let result = unsafe {
19157 ffi::wgpuInstanceRequestAdapter(self.raw, options_ptr, callback_info_ffi)
19158 };
19159 Future::from_ffi(result)
19160 }
19161 pub fn has_wgsl_language_feature(
19162 &self,
19163 feature: WGSLLanguageFeatureName,
19164 ) -> bool {
19165 let feature_ffi: ffi::WGPUWGSLLanguageFeatureName = feature.into();
19166 let result = unsafe {
19167 ffi::wgpuInstanceHasWGSLLanguageFeature(self.raw, feature_ffi)
19168 };
19169 result != 0
19170 }
19171 pub fn get_wgsl_language_features(
19172 &self,
19173 features: &mut SupportedWGSLLanguageFeatures,
19174 ) -> () {
19175 let (mut features_ffi, _features_storage) = features.to_ffi();
19176 let features_ptr = std::ptr::addr_of_mut!(features_ffi);
19177 unsafe { ffi::wgpuInstanceGetWGSLLanguageFeatures(self.raw, features_ptr) };
19178 *features = SupportedWGSLLanguageFeatures::from_ffi(features_ffi);
19179 ()
19180 }
19181 }
19182 impl Drop for Instance {
19183 fn drop(&mut self) {
19184 if self.as_raw().is_null() {
19185 return;
19186 }
19187 unsafe { ffi::wgpuInstanceRelease(self.raw) };
19188 }
19189 }
19190 impl Clone for Instance {
19191 fn clone(&self) -> Self {
19192 unsafe { ffi::wgpuInstanceAddRef(self.raw) };
19193 Self {
19194 raw: self.raw,
19195 _not_sync: std::marker::PhantomData,
19196 }
19197 }
19198 }
19199 unsafe impl Send for Instance {}
19200 #[derive(Debug)]
19201 pub struct PipelineLayout {
19202 raw: ffi::WGPUPipelineLayout,
19203 }
19204 impl PipelineLayout {
19205 pub(crate) unsafe fn from_raw(raw: ffi::WGPUPipelineLayout) -> Self {
19206 Self { raw }
19207 }
19208 pub fn as_raw(&self) -> ffi::WGPUPipelineLayout {
19209 self.raw
19210 }
19211 pub fn set_label(&self, label: String) -> () {
19212 let label_ffi = ffi::WGPUStringView {
19213 data: label.as_ptr().cast(),
19214 length: label.len(),
19215 };
19216 unsafe { ffi::wgpuPipelineLayoutSetLabel(self.raw, label_ffi) };
19217 ()
19218 }
19219 }
19220 impl Drop for PipelineLayout {
19221 fn drop(&mut self) {
19222 if self.as_raw().is_null() {
19223 return;
19224 }
19225 unsafe { ffi::wgpuPipelineLayoutRelease(self.raw) };
19226 }
19227 }
19228 impl Clone for PipelineLayout {
19229 fn clone(&self) -> Self {
19230 unsafe { ffi::wgpuPipelineLayoutAddRef(self.raw) };
19231 Self { raw: self.raw }
19232 }
19233 }
19234 unsafe impl Send for PipelineLayout {}
19235 unsafe impl Sync for PipelineLayout {}
19236 #[derive(Debug)]
19237 pub struct QuerySet {
19238 raw: ffi::WGPUQuerySet,
19239 }
19240 impl QuerySet {
19241 pub(crate) unsafe fn from_raw(raw: ffi::WGPUQuerySet) -> Self {
19242 Self { raw }
19243 }
19244 pub fn as_raw(&self) -> ffi::WGPUQuerySet {
19245 self.raw
19246 }
19247 pub fn set_label(&self, label: String) -> () {
19248 let label_ffi = ffi::WGPUStringView {
19249 data: label.as_ptr().cast(),
19250 length: label.len(),
19251 };
19252 unsafe { ffi::wgpuQuerySetSetLabel(self.raw, label_ffi) };
19253 ()
19254 }
19255 pub fn get_type(&self) -> QueryType {
19256 let result = unsafe { ffi::wgpuQuerySetGetType(self.raw) };
19257 result.into()
19258 }
19259 pub fn get_count(&self) -> u32 {
19260 let result = unsafe { ffi::wgpuQuerySetGetCount(self.raw) };
19261 result
19262 }
19263 pub fn destroy(&self) -> () {
19264 unsafe { ffi::wgpuQuerySetDestroy(self.raw) };
19265 ()
19266 }
19267 }
19268 impl Drop for QuerySet {
19269 fn drop(&mut self) {
19270 if self.as_raw().is_null() {
19271 return;
19272 }
19273 unsafe { ffi::wgpuQuerySetRelease(self.raw) };
19274 }
19275 }
19276 impl Clone for QuerySet {
19277 fn clone(&self) -> Self {
19278 unsafe { ffi::wgpuQuerySetAddRef(self.raw) };
19279 Self { raw: self.raw }
19280 }
19281 }
19282 unsafe impl Send for QuerySet {}
19283 unsafe impl Sync for QuerySet {}
19284 #[derive(Debug)]
19285 pub struct Queue {
19286 raw: ffi::WGPUQueue,
19287 }
19288 impl Queue {
19289 pub(crate) unsafe fn from_raw(raw: ffi::WGPUQueue) -> Self {
19290 Self { raw }
19291 }
19292 pub fn as_raw(&self) -> ffi::WGPUQueue {
19293 self.raw
19294 }
19295 pub fn submit(&self, commands: &[CommandBuffer]) -> () {
19296 let mut commands_raw: Vec<ffi::WGPUCommandBuffer> = commands
19297 .iter()
19298 .map(|v| v.as_raw())
19299 .collect();
19300 let commands_ptr = commands_raw.as_ptr();
19301 unsafe { ffi::wgpuQueueSubmit(self.raw, commands.len(), commands_ptr) };
19302 ()
19303 }
19304 pub fn on_submitted_work_done(
19305 &self,
19306 callback: impl FnMut(QueueWorkDoneStatus, String) + Send + 'static,
19307 ) -> Future {
19308 let callback_box: QueueWorkDoneCallback = Box::new(callback);
19309 let callback_box = Box::new(Some(callback_box));
19310 let callback_userdata = Box::into_raw(callback_box)
19311 .cast::<std::ffi::c_void>();
19312 let callback_info_ffi = ffi::WGPUQueueWorkDoneCallbackInfo {
19313 nextInChain: std::ptr::null_mut(),
19314 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19315 callback: Some(queue_work_done_callback_trampoline),
19316 userdata1: callback_userdata,
19317 userdata2: std::ptr::null_mut(),
19318 };
19319 let result = unsafe {
19320 ffi::wgpuQueueOnSubmittedWorkDone(self.raw, callback_info_ffi)
19321 };
19322 Future::from_ffi(result)
19323 }
19324 pub fn write_buffer(
19325 &self,
19326 buffer: Buffer,
19327 buffer_offset: u64,
19328 data: &[std::ffi::c_void],
19329 ) -> () {
19330 let data_ptr = data.as_ptr();
19331 unsafe {
19332 ffi::wgpuQueueWriteBuffer(
19333 self.raw,
19334 buffer.as_raw(),
19335 buffer_offset,
19336 data_ptr,
19337 data.len(),
19338 )
19339 };
19340 ()
19341 }
19342 pub fn write_texture(
19343 &self,
19344 destination: &TexelCopyTextureInfo,
19345 data: &[std::ffi::c_void],
19346 data_layout: &TexelCopyBufferLayout,
19347 write_size: &Extent3D,
19348 ) -> () {
19349 let (destination_ffi, _destination_storage) = destination.to_ffi();
19350 let destination_ptr = std::ptr::addr_of!(destination_ffi);
19351 let data_ptr = data.as_ptr();
19352 let (data_layout_ffi, _data_layout_storage) = data_layout.to_ffi();
19353 let data_layout_ptr = std::ptr::addr_of!(data_layout_ffi);
19354 let (write_size_ffi, _write_size_storage) = write_size.to_ffi();
19355 let write_size_ptr = std::ptr::addr_of!(write_size_ffi);
19356 unsafe {
19357 ffi::wgpuQueueWriteTexture(
19358 self.raw,
19359 destination_ptr,
19360 data_ptr,
19361 data.len(),
19362 data_layout_ptr,
19363 write_size_ptr,
19364 )
19365 };
19366 ()
19367 }
19368 pub fn copy_texture_for_browser(
19369 &self,
19370 source: &TexelCopyTextureInfo,
19371 destination: &TexelCopyTextureInfo,
19372 copy_size: &Extent3D,
19373 options: &CopyTextureForBrowserOptions,
19374 ) -> () {
19375 let (source_ffi, _source_storage) = source.to_ffi();
19376 let source_ptr = std::ptr::addr_of!(source_ffi);
19377 let (destination_ffi, _destination_storage) = destination.to_ffi();
19378 let destination_ptr = std::ptr::addr_of!(destination_ffi);
19379 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
19380 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
19381 let (options_ffi, _options_storage) = options.to_ffi();
19382 let options_ptr = std::ptr::addr_of!(options_ffi);
19383 unsafe {
19384 ffi::wgpuQueueCopyTextureForBrowser(
19385 self.raw,
19386 source_ptr,
19387 destination_ptr,
19388 copy_size_ptr,
19389 options_ptr,
19390 )
19391 };
19392 ()
19393 }
19394 pub fn copy_external_texture_for_browser(
19395 &self,
19396 source: &ImageCopyExternalTexture,
19397 destination: &TexelCopyTextureInfo,
19398 copy_size: &Extent3D,
19399 options: &CopyTextureForBrowserOptions,
19400 ) -> () {
19401 let (source_ffi, _source_storage) = source.to_ffi();
19402 let source_ptr = std::ptr::addr_of!(source_ffi);
19403 let (destination_ffi, _destination_storage) = destination.to_ffi();
19404 let destination_ptr = std::ptr::addr_of!(destination_ffi);
19405 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
19406 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
19407 let (options_ffi, _options_storage) = options.to_ffi();
19408 let options_ptr = std::ptr::addr_of!(options_ffi);
19409 unsafe {
19410 ffi::wgpuQueueCopyExternalTextureForBrowser(
19411 self.raw,
19412 source_ptr,
19413 destination_ptr,
19414 copy_size_ptr,
19415 options_ptr,
19416 )
19417 };
19418 ()
19419 }
19420 pub fn set_label(&self, label: String) -> () {
19421 let label_ffi = ffi::WGPUStringView {
19422 data: label.as_ptr().cast(),
19423 length: label.len(),
19424 };
19425 unsafe { ffi::wgpuQueueSetLabel(self.raw, label_ffi) };
19426 ()
19427 }
19428 }
19429 impl Drop for Queue {
19430 fn drop(&mut self) {
19431 if self.as_raw().is_null() {
19432 return;
19433 }
19434 unsafe { ffi::wgpuQueueRelease(self.raw) };
19435 }
19436 }
19437 impl Clone for Queue {
19438 fn clone(&self) -> Self {
19439 unsafe { ffi::wgpuQueueAddRef(self.raw) };
19440 Self { raw: self.raw }
19441 }
19442 }
19443 unsafe impl Send for Queue {}
19444 unsafe impl Sync for Queue {}
19445 #[derive(Debug)]
19446 pub struct RenderBundle {
19447 raw: ffi::WGPURenderBundle,
19448 }
19449 impl RenderBundle {
19450 pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderBundle) -> Self {
19451 Self { raw }
19452 }
19453 pub fn as_raw(&self) -> ffi::WGPURenderBundle {
19454 self.raw
19455 }
19456 pub fn set_label(&self, label: String) -> () {
19457 let label_ffi = ffi::WGPUStringView {
19458 data: label.as_ptr().cast(),
19459 length: label.len(),
19460 };
19461 unsafe { ffi::wgpuRenderBundleSetLabel(self.raw, label_ffi) };
19462 ()
19463 }
19464 }
19465 impl Drop for RenderBundle {
19466 fn drop(&mut self) {
19467 if self.as_raw().is_null() {
19468 return;
19469 }
19470 unsafe { ffi::wgpuRenderBundleRelease(self.raw) };
19471 }
19472 }
19473 impl Clone for RenderBundle {
19474 fn clone(&self) -> Self {
19475 unsafe { ffi::wgpuRenderBundleAddRef(self.raw) };
19476 Self { raw: self.raw }
19477 }
19478 }
19479 unsafe impl Send for RenderBundle {}
19480 unsafe impl Sync for RenderBundle {}
19481 #[derive(Debug)]
19482 pub struct RenderBundleEncoder {
19483 raw: ffi::WGPURenderBundleEncoder,
19484 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
19485 }
19486 impl RenderBundleEncoder {
19487 pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderBundleEncoder) -> Self {
19488 Self {
19489 raw,
19490 _not_sync: std::marker::PhantomData,
19491 }
19492 }
19493 pub fn as_raw(&self) -> ffi::WGPURenderBundleEncoder {
19494 self.raw
19495 }
19496 pub fn set_pipeline(&self, pipeline: RenderPipeline) -> () {
19497 unsafe {
19498 ffi::wgpuRenderBundleEncoderSetPipeline(self.raw, pipeline.as_raw())
19499 };
19500 ()
19501 }
19502 pub fn set_bind_group(
19503 &self,
19504 group_index: u32,
19505 group: Option<BindGroup>,
19506 dynamic_offsets: &[u32],
19507 ) -> () {
19508 let group_raw = group
19509 .as_ref()
19510 .map(|v| v.as_raw())
19511 .unwrap_or(std::ptr::null_mut());
19512 let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
19513 unsafe {
19514 ffi::wgpuRenderBundleEncoderSetBindGroup(
19515 self.raw,
19516 group_index,
19517 group_raw,
19518 dynamic_offsets.len(),
19519 dynamic_offsets_ptr,
19520 )
19521 };
19522 ()
19523 }
19524 pub fn draw(
19525 &self,
19526 vertex_count: u32,
19527 instance_count: u32,
19528 first_vertex: u32,
19529 first_instance: u32,
19530 ) -> () {
19531 unsafe {
19532 ffi::wgpuRenderBundleEncoderDraw(
19533 self.raw,
19534 vertex_count,
19535 instance_count,
19536 first_vertex,
19537 first_instance,
19538 )
19539 };
19540 ()
19541 }
19542 pub fn draw_indexed(
19543 &self,
19544 index_count: u32,
19545 instance_count: u32,
19546 first_index: u32,
19547 base_vertex: i32,
19548 first_instance: u32,
19549 ) -> () {
19550 unsafe {
19551 ffi::wgpuRenderBundleEncoderDrawIndexed(
19552 self.raw,
19553 index_count,
19554 instance_count,
19555 first_index,
19556 base_vertex,
19557 first_instance,
19558 )
19559 };
19560 ()
19561 }
19562 pub fn draw_indirect(
19563 &self,
19564 indirect_buffer: Buffer,
19565 indirect_offset: u64,
19566 ) -> () {
19567 unsafe {
19568 ffi::wgpuRenderBundleEncoderDrawIndirect(
19569 self.raw,
19570 indirect_buffer.as_raw(),
19571 indirect_offset,
19572 )
19573 };
19574 ()
19575 }
19576 pub fn draw_indexed_indirect(
19577 &self,
19578 indirect_buffer: Buffer,
19579 indirect_offset: u64,
19580 ) -> () {
19581 unsafe {
19582 ffi::wgpuRenderBundleEncoderDrawIndexedIndirect(
19583 self.raw,
19584 indirect_buffer.as_raw(),
19585 indirect_offset,
19586 )
19587 };
19588 ()
19589 }
19590 pub fn insert_debug_marker(&self, marker_label: String) -> () {
19591 let marker_label_ffi = ffi::WGPUStringView {
19592 data: marker_label.as_ptr().cast(),
19593 length: marker_label.len(),
19594 };
19595 unsafe {
19596 ffi::wgpuRenderBundleEncoderInsertDebugMarker(self.raw, marker_label_ffi)
19597 };
19598 ()
19599 }
19600 pub fn pop_debug_group(&self) -> () {
19601 unsafe { ffi::wgpuRenderBundleEncoderPopDebugGroup(self.raw) };
19602 ()
19603 }
19604 pub fn push_debug_group(&self, group_label: String) -> () {
19605 let group_label_ffi = ffi::WGPUStringView {
19606 data: group_label.as_ptr().cast(),
19607 length: group_label.len(),
19608 };
19609 unsafe {
19610 ffi::wgpuRenderBundleEncoderPushDebugGroup(self.raw, group_label_ffi)
19611 };
19612 ()
19613 }
19614 pub fn set_vertex_buffer(
19615 &self,
19616 slot: u32,
19617 buffer: Option<Buffer>,
19618 offset: u64,
19619 size: u64,
19620 ) -> () {
19621 let buffer_raw = buffer
19622 .as_ref()
19623 .map(|v| v.as_raw())
19624 .unwrap_or(std::ptr::null_mut());
19625 unsafe {
19626 ffi::wgpuRenderBundleEncoderSetVertexBuffer(
19627 self.raw,
19628 slot,
19629 buffer_raw,
19630 offset,
19631 size,
19632 )
19633 };
19634 ()
19635 }
19636 pub fn set_index_buffer(
19637 &self,
19638 buffer: Buffer,
19639 format: IndexFormat,
19640 offset: u64,
19641 size: u64,
19642 ) -> () {
19643 let format_ffi: ffi::WGPUIndexFormat = format.into();
19644 unsafe {
19645 ffi::wgpuRenderBundleEncoderSetIndexBuffer(
19646 self.raw,
19647 buffer.as_raw(),
19648 format_ffi,
19649 offset,
19650 size,
19651 )
19652 };
19653 ()
19654 }
19655 pub fn finish(
19656 &self,
19657 descriptor: Option<&RenderBundleDescriptor>,
19658 ) -> RenderBundle {
19659 let mut descriptor_storage = ChainedStructStorage::new();
19660 let descriptor_ptr = if let Some(value) = &descriptor {
19661 let (descriptor_ffi, storage) = value.to_ffi();
19662 descriptor_storage = storage;
19663 std::ptr::addr_of!(descriptor_ffi)
19664 } else {
19665 std::ptr::null()
19666 };
19667 let result = unsafe {
19668 ffi::wgpuRenderBundleEncoderFinish(self.raw, descriptor_ptr)
19669 };
19670 unsafe { RenderBundle::from_raw(result) }
19671 }
19672 pub fn set_label(&self, label: String) -> () {
19673 let label_ffi = ffi::WGPUStringView {
19674 data: label.as_ptr().cast(),
19675 length: label.len(),
19676 };
19677 unsafe { ffi::wgpuRenderBundleEncoderSetLabel(self.raw, label_ffi) };
19678 ()
19679 }
19680 pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
19681 let data_ptr = data.as_ptr();
19682 unsafe {
19683 ffi::wgpuRenderBundleEncoderSetImmediates(
19684 self.raw,
19685 offset,
19686 data_ptr,
19687 data.len(),
19688 )
19689 };
19690 ()
19691 }
19692 pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
19693 let table_raw = table
19694 .as_ref()
19695 .map(|v| v.as_raw())
19696 .unwrap_or(std::ptr::null_mut());
19697 unsafe { ffi::wgpuRenderBundleEncoderSetResourceTable(self.raw, table_raw) };
19698 ()
19699 }
19700 }
19701 impl Drop for RenderBundleEncoder {
19702 fn drop(&mut self) {
19703 if self.as_raw().is_null() {
19704 return;
19705 }
19706 unsafe { ffi::wgpuRenderBundleEncoderRelease(self.raw) };
19707 }
19708 }
19709 impl Clone for RenderBundleEncoder {
19710 fn clone(&self) -> Self {
19711 unsafe { ffi::wgpuRenderBundleEncoderAddRef(self.raw) };
19712 Self {
19713 raw: self.raw,
19714 _not_sync: std::marker::PhantomData,
19715 }
19716 }
19717 }
19718 unsafe impl Send for RenderBundleEncoder {}
19719 #[derive(Debug)]
19720 pub struct RenderPassEncoder {
19721 raw: ffi::WGPURenderPassEncoder,
19722 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
19723 }
19724 impl RenderPassEncoder {
19725 pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderPassEncoder) -> Self {
19726 Self {
19727 raw,
19728 _not_sync: std::marker::PhantomData,
19729 }
19730 }
19731 pub fn as_raw(&self) -> ffi::WGPURenderPassEncoder {
19732 self.raw
19733 }
19734 pub fn set_pipeline(&self, pipeline: RenderPipeline) -> () {
19735 unsafe {
19736 ffi::wgpuRenderPassEncoderSetPipeline(self.raw, pipeline.as_raw())
19737 };
19738 ()
19739 }
19740 pub fn set_bind_group(
19741 &self,
19742 group_index: u32,
19743 group: Option<BindGroup>,
19744 dynamic_offsets: &[u32],
19745 ) -> () {
19746 let group_raw = group
19747 .as_ref()
19748 .map(|v| v.as_raw())
19749 .unwrap_or(std::ptr::null_mut());
19750 let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
19751 unsafe {
19752 ffi::wgpuRenderPassEncoderSetBindGroup(
19753 self.raw,
19754 group_index,
19755 group_raw,
19756 dynamic_offsets.len(),
19757 dynamic_offsets_ptr,
19758 )
19759 };
19760 ()
19761 }
19762 pub fn draw(
19763 &self,
19764 vertex_count: u32,
19765 instance_count: u32,
19766 first_vertex: u32,
19767 first_instance: u32,
19768 ) -> () {
19769 unsafe {
19770 ffi::wgpuRenderPassEncoderDraw(
19771 self.raw,
19772 vertex_count,
19773 instance_count,
19774 first_vertex,
19775 first_instance,
19776 )
19777 };
19778 ()
19779 }
19780 pub fn draw_indexed(
19781 &self,
19782 index_count: u32,
19783 instance_count: u32,
19784 first_index: u32,
19785 base_vertex: i32,
19786 first_instance: u32,
19787 ) -> () {
19788 unsafe {
19789 ffi::wgpuRenderPassEncoderDrawIndexed(
19790 self.raw,
19791 index_count,
19792 instance_count,
19793 first_index,
19794 base_vertex,
19795 first_instance,
19796 )
19797 };
19798 ()
19799 }
19800 pub fn draw_indirect(
19801 &self,
19802 indirect_buffer: Buffer,
19803 indirect_offset: u64,
19804 ) -> () {
19805 unsafe {
19806 ffi::wgpuRenderPassEncoderDrawIndirect(
19807 self.raw,
19808 indirect_buffer.as_raw(),
19809 indirect_offset,
19810 )
19811 };
19812 ()
19813 }
19814 pub fn draw_indexed_indirect(
19815 &self,
19816 indirect_buffer: Buffer,
19817 indirect_offset: u64,
19818 ) -> () {
19819 unsafe {
19820 ffi::wgpuRenderPassEncoderDrawIndexedIndirect(
19821 self.raw,
19822 indirect_buffer.as_raw(),
19823 indirect_offset,
19824 )
19825 };
19826 ()
19827 }
19828 pub fn multi_draw_indirect(
19829 &self,
19830 indirect_buffer: Buffer,
19831 indirect_offset: u64,
19832 max_draw_count: u32,
19833 draw_count_buffer: Option<Buffer>,
19834 draw_count_buffer_offset: u64,
19835 ) -> () {
19836 let draw_count_buffer_raw = draw_count_buffer
19837 .as_ref()
19838 .map(|v| v.as_raw())
19839 .unwrap_or(std::ptr::null_mut());
19840 unsafe {
19841 ffi::wgpuRenderPassEncoderMultiDrawIndirect(
19842 self.raw,
19843 indirect_buffer.as_raw(),
19844 indirect_offset,
19845 max_draw_count,
19846 draw_count_buffer_raw,
19847 draw_count_buffer_offset,
19848 )
19849 };
19850 ()
19851 }
19852 pub fn multi_draw_indexed_indirect(
19853 &self,
19854 indirect_buffer: Buffer,
19855 indirect_offset: u64,
19856 max_draw_count: u32,
19857 draw_count_buffer: Option<Buffer>,
19858 draw_count_buffer_offset: u64,
19859 ) -> () {
19860 let draw_count_buffer_raw = draw_count_buffer
19861 .as_ref()
19862 .map(|v| v.as_raw())
19863 .unwrap_or(std::ptr::null_mut());
19864 unsafe {
19865 ffi::wgpuRenderPassEncoderMultiDrawIndexedIndirect(
19866 self.raw,
19867 indirect_buffer.as_raw(),
19868 indirect_offset,
19869 max_draw_count,
19870 draw_count_buffer_raw,
19871 draw_count_buffer_offset,
19872 )
19873 };
19874 ()
19875 }
19876 pub fn execute_bundles(&self, bundles: &[RenderBundle]) -> () {
19877 let mut bundles_raw: Vec<ffi::WGPURenderBundle> = bundles
19878 .iter()
19879 .map(|v| v.as_raw())
19880 .collect();
19881 let bundles_ptr = bundles_raw.as_ptr();
19882 unsafe {
19883 ffi::wgpuRenderPassEncoderExecuteBundles(
19884 self.raw,
19885 bundles.len(),
19886 bundles_ptr,
19887 )
19888 };
19889 ()
19890 }
19891 pub fn insert_debug_marker(&self, marker_label: String) -> () {
19892 let marker_label_ffi = ffi::WGPUStringView {
19893 data: marker_label.as_ptr().cast(),
19894 length: marker_label.len(),
19895 };
19896 unsafe {
19897 ffi::wgpuRenderPassEncoderInsertDebugMarker(self.raw, marker_label_ffi)
19898 };
19899 ()
19900 }
19901 pub fn pop_debug_group(&self) -> () {
19902 unsafe { ffi::wgpuRenderPassEncoderPopDebugGroup(self.raw) };
19903 ()
19904 }
19905 pub fn push_debug_group(&self, group_label: String) -> () {
19906 let group_label_ffi = ffi::WGPUStringView {
19907 data: group_label.as_ptr().cast(),
19908 length: group_label.len(),
19909 };
19910 unsafe {
19911 ffi::wgpuRenderPassEncoderPushDebugGroup(self.raw, group_label_ffi)
19912 };
19913 ()
19914 }
19915 pub fn set_stencil_reference(&self, reference: u32) -> () {
19916 unsafe {
19917 ffi::wgpuRenderPassEncoderSetStencilReference(self.raw, reference)
19918 };
19919 ()
19920 }
19921 pub fn set_blend_constant(&self, color: &Color) -> () {
19922 let (color_ffi, _color_storage) = color.to_ffi();
19923 let color_ptr = std::ptr::addr_of!(color_ffi);
19924 unsafe { ffi::wgpuRenderPassEncoderSetBlendConstant(self.raw, color_ptr) };
19925 ()
19926 }
19927 pub fn set_viewport(
19928 &self,
19929 x: f32,
19930 y: f32,
19931 width: f32,
19932 height: f32,
19933 min_depth: f32,
19934 max_depth: f32,
19935 ) -> () {
19936 unsafe {
19937 ffi::wgpuRenderPassEncoderSetViewport(
19938 self.raw,
19939 x,
19940 y,
19941 width,
19942 height,
19943 min_depth,
19944 max_depth,
19945 )
19946 };
19947 ()
19948 }
19949 pub fn set_scissor_rect(&self, x: u32, y: u32, width: u32, height: u32) -> () {
19950 unsafe {
19951 ffi::wgpuRenderPassEncoderSetScissorRect(self.raw, x, y, width, height)
19952 };
19953 ()
19954 }
19955 pub fn set_vertex_buffer(
19956 &self,
19957 slot: u32,
19958 buffer: Option<Buffer>,
19959 offset: u64,
19960 size: u64,
19961 ) -> () {
19962 let buffer_raw = buffer
19963 .as_ref()
19964 .map(|v| v.as_raw())
19965 .unwrap_or(std::ptr::null_mut());
19966 unsafe {
19967 ffi::wgpuRenderPassEncoderSetVertexBuffer(
19968 self.raw,
19969 slot,
19970 buffer_raw,
19971 offset,
19972 size,
19973 )
19974 };
19975 ()
19976 }
19977 pub fn set_index_buffer(
19978 &self,
19979 buffer: Buffer,
19980 format: IndexFormat,
19981 offset: u64,
19982 size: u64,
19983 ) -> () {
19984 let format_ffi: ffi::WGPUIndexFormat = format.into();
19985 unsafe {
19986 ffi::wgpuRenderPassEncoderSetIndexBuffer(
19987 self.raw,
19988 buffer.as_raw(),
19989 format_ffi,
19990 offset,
19991 size,
19992 )
19993 };
19994 ()
19995 }
19996 pub fn begin_occlusion_query(&self, query_index: u32) -> () {
19997 unsafe {
19998 ffi::wgpuRenderPassEncoderBeginOcclusionQuery(self.raw, query_index)
19999 };
20000 ()
20001 }
20002 pub fn end_occlusion_query(&self) -> () {
20003 unsafe { ffi::wgpuRenderPassEncoderEndOcclusionQuery(self.raw) };
20004 ()
20005 }
20006 pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
20007 unsafe {
20008 ffi::wgpuRenderPassEncoderWriteTimestamp(
20009 self.raw,
20010 query_set.as_raw(),
20011 query_index,
20012 )
20013 };
20014 ()
20015 }
20016 pub fn pixel_local_storage_barrier(&self) -> () {
20017 unsafe { ffi::wgpuRenderPassEncoderPixelLocalStorageBarrier(self.raw) };
20018 ()
20019 }
20020 pub fn end(&self) -> () {
20021 unsafe { ffi::wgpuRenderPassEncoderEnd(self.raw) };
20022 ()
20023 }
20024 pub fn set_label(&self, label: String) -> () {
20025 let label_ffi = ffi::WGPUStringView {
20026 data: label.as_ptr().cast(),
20027 length: label.len(),
20028 };
20029 unsafe { ffi::wgpuRenderPassEncoderSetLabel(self.raw, label_ffi) };
20030 ()
20031 }
20032 pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
20033 let data_ptr = data.as_ptr();
20034 unsafe {
20035 ffi::wgpuRenderPassEncoderSetImmediates(
20036 self.raw,
20037 offset,
20038 data_ptr,
20039 data.len(),
20040 )
20041 };
20042 ()
20043 }
20044 pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
20045 let table_raw = table
20046 .as_ref()
20047 .map(|v| v.as_raw())
20048 .unwrap_or(std::ptr::null_mut());
20049 unsafe { ffi::wgpuRenderPassEncoderSetResourceTable(self.raw, table_raw) };
20050 ()
20051 }
20052 }
20053 impl Drop for RenderPassEncoder {
20054 fn drop(&mut self) {
20055 if self.as_raw().is_null() {
20056 return;
20057 }
20058 unsafe { ffi::wgpuRenderPassEncoderRelease(self.raw) };
20059 }
20060 }
20061 impl Clone for RenderPassEncoder {
20062 fn clone(&self) -> Self {
20063 unsafe { ffi::wgpuRenderPassEncoderAddRef(self.raw) };
20064 Self {
20065 raw: self.raw,
20066 _not_sync: std::marker::PhantomData,
20067 }
20068 }
20069 }
20070 unsafe impl Send for RenderPassEncoder {}
20071 #[derive(Debug)]
20072 pub struct RenderPipeline {
20073 raw: ffi::WGPURenderPipeline,
20074 }
20075 impl RenderPipeline {
20076 pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderPipeline) -> Self {
20077 Self { raw }
20078 }
20079 pub fn as_raw(&self) -> ffi::WGPURenderPipeline {
20080 self.raw
20081 }
20082 pub fn get_bind_group_layout(&self, group_index: u32) -> BindGroupLayout {
20083 let result = unsafe {
20084 ffi::wgpuRenderPipelineGetBindGroupLayout(self.raw, group_index)
20085 };
20086 unsafe { BindGroupLayout::from_raw(result) }
20087 }
20088 pub fn set_label(&self, label: String) -> () {
20089 let label_ffi = ffi::WGPUStringView {
20090 data: label.as_ptr().cast(),
20091 length: label.len(),
20092 };
20093 unsafe { ffi::wgpuRenderPipelineSetLabel(self.raw, label_ffi) };
20094 ()
20095 }
20096 }
20097 impl Drop for RenderPipeline {
20098 fn drop(&mut self) {
20099 if self.as_raw().is_null() {
20100 return;
20101 }
20102 unsafe { ffi::wgpuRenderPipelineRelease(self.raw) };
20103 }
20104 }
20105 impl Clone for RenderPipeline {
20106 fn clone(&self) -> Self {
20107 unsafe { ffi::wgpuRenderPipelineAddRef(self.raw) };
20108 Self { raw: self.raw }
20109 }
20110 }
20111 unsafe impl Send for RenderPipeline {}
20112 unsafe impl Sync for RenderPipeline {}
20113 #[derive(Debug)]
20114 pub struct ResourceTable {
20115 raw: ffi::WGPUResourceTable,
20116 }
20117 impl ResourceTable {
20118 pub(crate) unsafe fn from_raw(raw: ffi::WGPUResourceTable) -> Self {
20119 Self { raw }
20120 }
20121 pub fn as_raw(&self) -> ffi::WGPUResourceTable {
20122 self.raw
20123 }
20124 pub fn get_size(&self) -> u32 {
20125 let result = unsafe { ffi::wgpuResourceTableGetSize(self.raw) };
20126 result
20127 }
20128 pub fn destroy(&self) -> () {
20129 unsafe { ffi::wgpuResourceTableDestroy(self.raw) };
20130 ()
20131 }
20132 pub fn update(&self, slot: u32, resource: &BindingResource) -> Status {
20133 let (resource_ffi, _resource_storage) = resource.to_ffi();
20134 let resource_ptr = std::ptr::addr_of!(resource_ffi);
20135 let result = unsafe {
20136 ffi::wgpuResourceTableUpdate(self.raw, slot, resource_ptr)
20137 };
20138 result.into()
20139 }
20140 pub fn insert_binding(&self, resource: &BindingResource) -> u32 {
20141 let (resource_ffi, _resource_storage) = resource.to_ffi();
20142 let resource_ptr = std::ptr::addr_of!(resource_ffi);
20143 let result = unsafe {
20144 ffi::wgpuResourceTableInsertBinding(self.raw, resource_ptr)
20145 };
20146 result
20147 }
20148 pub fn remove_binding(&self, slot: u32) -> Status {
20149 let result = unsafe { ffi::wgpuResourceTableRemoveBinding(self.raw, slot) };
20150 result.into()
20151 }
20152 }
20153 impl Drop for ResourceTable {
20154 fn drop(&mut self) {
20155 if self.as_raw().is_null() {
20156 return;
20157 }
20158 unsafe { ffi::wgpuResourceTableRelease(self.raw) };
20159 }
20160 }
20161 impl Clone for ResourceTable {
20162 fn clone(&self) -> Self {
20163 unsafe { ffi::wgpuResourceTableAddRef(self.raw) };
20164 Self { raw: self.raw }
20165 }
20166 }
20167 unsafe impl Send for ResourceTable {}
20168 unsafe impl Sync for ResourceTable {}
20169 #[derive(Debug)]
20170 pub struct Sampler {
20171 raw: ffi::WGPUSampler,
20172 }
20173 impl Sampler {
20174 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSampler) -> Self {
20175 Self { raw }
20176 }
20177 pub fn as_raw(&self) -> ffi::WGPUSampler {
20178 self.raw
20179 }
20180 pub fn set_label(&self, label: String) -> () {
20181 let label_ffi = ffi::WGPUStringView {
20182 data: label.as_ptr().cast(),
20183 length: label.len(),
20184 };
20185 unsafe { ffi::wgpuSamplerSetLabel(self.raw, label_ffi) };
20186 ()
20187 }
20188 }
20189 impl Drop for Sampler {
20190 fn drop(&mut self) {
20191 if self.as_raw().is_null() {
20192 return;
20193 }
20194 unsafe { ffi::wgpuSamplerRelease(self.raw) };
20195 }
20196 }
20197 impl Clone for Sampler {
20198 fn clone(&self) -> Self {
20199 unsafe { ffi::wgpuSamplerAddRef(self.raw) };
20200 Self { raw: self.raw }
20201 }
20202 }
20203 unsafe impl Send for Sampler {}
20204 unsafe impl Sync for Sampler {}
20205 #[derive(Debug)]
20206 pub struct ShaderModule {
20207 raw: ffi::WGPUShaderModule,
20208 }
20209 impl ShaderModule {
20210 pub(crate) unsafe fn from_raw(raw: ffi::WGPUShaderModule) -> Self {
20211 Self { raw }
20212 }
20213 pub fn as_raw(&self) -> ffi::WGPUShaderModule {
20214 self.raw
20215 }
20216 pub fn get_compilation_info(
20217 &self,
20218 callback: impl FnMut(
20219 CompilationInfoRequestStatus,
20220 &CompilationInfo,
20221 ) + Send + 'static,
20222 ) -> Future {
20223 let callback_box: CompilationInfoCallback = Box::new(callback);
20224 let callback_box = Box::new(Some(callback_box));
20225 let callback_userdata = Box::into_raw(callback_box)
20226 .cast::<std::ffi::c_void>();
20227 let callback_info_ffi = ffi::WGPUCompilationInfoCallbackInfo {
20228 nextInChain: std::ptr::null_mut(),
20229 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
20230 callback: Some(compilation_info_callback_trampoline),
20231 userdata1: callback_userdata,
20232 userdata2: std::ptr::null_mut(),
20233 };
20234 let result = unsafe {
20235 ffi::wgpuShaderModuleGetCompilationInfo(self.raw, callback_info_ffi)
20236 };
20237 Future::from_ffi(result)
20238 }
20239 pub fn set_label(&self, label: String) -> () {
20240 let label_ffi = ffi::WGPUStringView {
20241 data: label.as_ptr().cast(),
20242 length: label.len(),
20243 };
20244 unsafe { ffi::wgpuShaderModuleSetLabel(self.raw, label_ffi) };
20245 ()
20246 }
20247 }
20248 impl Drop for ShaderModule {
20249 fn drop(&mut self) {
20250 if self.as_raw().is_null() {
20251 return;
20252 }
20253 unsafe { ffi::wgpuShaderModuleRelease(self.raw) };
20254 }
20255 }
20256 impl Clone for ShaderModule {
20257 fn clone(&self) -> Self {
20258 unsafe { ffi::wgpuShaderModuleAddRef(self.raw) };
20259 Self { raw: self.raw }
20260 }
20261 }
20262 unsafe impl Send for ShaderModule {}
20263 unsafe impl Sync for ShaderModule {}
20264 #[derive(Debug)]
20265 pub struct SharedBufferMemory {
20266 raw: ffi::WGPUSharedBufferMemory,
20267 }
20268 impl SharedBufferMemory {
20269 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedBufferMemory) -> Self {
20270 Self { raw }
20271 }
20272 pub fn as_raw(&self) -> ffi::WGPUSharedBufferMemory {
20273 self.raw
20274 }
20275 pub fn set_label(&self, label: String) -> () {
20276 let label_ffi = ffi::WGPUStringView {
20277 data: label.as_ptr().cast(),
20278 length: label.len(),
20279 };
20280 unsafe { ffi::wgpuSharedBufferMemorySetLabel(self.raw, label_ffi) };
20281 ()
20282 }
20283 pub fn get_properties(
20284 &self,
20285 properties: &mut SharedBufferMemoryProperties,
20286 ) -> Status {
20287 let (mut properties_ffi, _properties_storage) = properties.to_ffi();
20288 let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
20289 let result = unsafe {
20290 ffi::wgpuSharedBufferMemoryGetProperties(self.raw, properties_ptr)
20291 };
20292 *properties = SharedBufferMemoryProperties::from_ffi(properties_ffi);
20293 result.into()
20294 }
20295 pub fn create_buffer(&self, descriptor: Option<&BufferDescriptor>) -> Buffer {
20296 let mut descriptor_storage = ChainedStructStorage::new();
20297 let descriptor_ptr = if let Some(value) = &descriptor {
20298 let (descriptor_ffi, storage) = value.to_ffi();
20299 descriptor_storage = storage;
20300 std::ptr::addr_of!(descriptor_ffi)
20301 } else {
20302 std::ptr::null()
20303 };
20304 let result = unsafe {
20305 ffi::wgpuSharedBufferMemoryCreateBuffer(self.raw, descriptor_ptr)
20306 };
20307 unsafe { Buffer::from_raw(result) }
20308 }
20309 pub fn begin_access(
20310 &self,
20311 buffer: Buffer,
20312 descriptor: &SharedBufferMemoryBeginAccessDescriptor,
20313 ) -> Status {
20314 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20315 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
20316 let result = unsafe {
20317 ffi::wgpuSharedBufferMemoryBeginAccess(
20318 self.raw,
20319 buffer.as_raw(),
20320 descriptor_ptr,
20321 )
20322 };
20323 result.into()
20324 }
20325 pub fn end_access(
20326 &self,
20327 buffer: Buffer,
20328 descriptor: &mut SharedBufferMemoryEndAccessState,
20329 ) -> Status {
20330 let (mut descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20331 let descriptor_ptr = std::ptr::addr_of_mut!(descriptor_ffi);
20332 let result = unsafe {
20333 ffi::wgpuSharedBufferMemoryEndAccess(
20334 self.raw,
20335 buffer.as_raw(),
20336 descriptor_ptr,
20337 )
20338 };
20339 *descriptor = SharedBufferMemoryEndAccessState::from_ffi(descriptor_ffi);
20340 result.into()
20341 }
20342 pub fn is_device_lost(&self) -> bool {
20343 let result = unsafe { ffi::wgpuSharedBufferMemoryIsDeviceLost(self.raw) };
20344 result != 0
20345 }
20346 }
20347 impl Drop for SharedBufferMemory {
20348 fn drop(&mut self) {
20349 if self.as_raw().is_null() {
20350 return;
20351 }
20352 unsafe { ffi::wgpuSharedBufferMemoryRelease(self.raw) };
20353 }
20354 }
20355 impl Clone for SharedBufferMemory {
20356 fn clone(&self) -> Self {
20357 unsafe { ffi::wgpuSharedBufferMemoryAddRef(self.raw) };
20358 Self { raw: self.raw }
20359 }
20360 }
20361 unsafe impl Send for SharedBufferMemory {}
20362 unsafe impl Sync for SharedBufferMemory {}
20363 #[derive(Debug)]
20364 pub struct SharedFence {
20365 raw: ffi::WGPUSharedFence,
20366 }
20367 impl SharedFence {
20368 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedFence) -> Self {
20369 Self { raw }
20370 }
20371 pub fn as_raw(&self) -> ffi::WGPUSharedFence {
20372 self.raw
20373 }
20374 pub fn export_info(&self, info: &mut SharedFenceExportInfo) -> () {
20375 let (mut info_ffi, _info_storage) = info.to_ffi();
20376 let info_ptr = std::ptr::addr_of_mut!(info_ffi);
20377 unsafe { ffi::wgpuSharedFenceExportInfo(self.raw, info_ptr) };
20378 *info = SharedFenceExportInfo::from_ffi(info_ffi);
20379 ()
20380 }
20381 }
20382 impl Drop for SharedFence {
20383 fn drop(&mut self) {
20384 if self.as_raw().is_null() {
20385 return;
20386 }
20387 unsafe { ffi::wgpuSharedFenceRelease(self.raw) };
20388 }
20389 }
20390 impl Clone for SharedFence {
20391 fn clone(&self) -> Self {
20392 unsafe { ffi::wgpuSharedFenceAddRef(self.raw) };
20393 Self { raw: self.raw }
20394 }
20395 }
20396 unsafe impl Send for SharedFence {}
20397 unsafe impl Sync for SharedFence {}
20398 #[derive(Debug)]
20399 pub struct SharedTextureMemory {
20400 raw: ffi::WGPUSharedTextureMemory,
20401 }
20402 impl SharedTextureMemory {
20403 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedTextureMemory) -> Self {
20404 Self { raw }
20405 }
20406 pub fn as_raw(&self) -> ffi::WGPUSharedTextureMemory {
20407 self.raw
20408 }
20409 pub fn set_label(&self, label: String) -> () {
20410 let label_ffi = ffi::WGPUStringView {
20411 data: label.as_ptr().cast(),
20412 length: label.len(),
20413 };
20414 unsafe { ffi::wgpuSharedTextureMemorySetLabel(self.raw, label_ffi) };
20415 ()
20416 }
20417 pub fn get_properties(
20418 &self,
20419 properties: &mut SharedTextureMemoryProperties,
20420 ) -> Status {
20421 let (mut properties_ffi, _properties_storage) = properties.to_ffi();
20422 let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
20423 let result = unsafe {
20424 ffi::wgpuSharedTextureMemoryGetProperties(self.raw, properties_ptr)
20425 };
20426 *properties = SharedTextureMemoryProperties::from_ffi(properties_ffi);
20427 result.into()
20428 }
20429 pub fn create_texture(&self, descriptor: Option<&TextureDescriptor>) -> Texture {
20430 let mut descriptor_storage = ChainedStructStorage::new();
20431 let descriptor_ptr = if let Some(value) = &descriptor {
20432 let (descriptor_ffi, storage) = value.to_ffi();
20433 descriptor_storage = storage;
20434 std::ptr::addr_of!(descriptor_ffi)
20435 } else {
20436 std::ptr::null()
20437 };
20438 let result = unsafe {
20439 ffi::wgpuSharedTextureMemoryCreateTexture(self.raw, descriptor_ptr)
20440 };
20441 unsafe { Texture::from_raw(result) }
20442 }
20443 pub fn begin_access(
20444 &self,
20445 texture: Texture,
20446 descriptor: &SharedTextureMemoryBeginAccessDescriptor,
20447 ) -> Status {
20448 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20449 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
20450 let result = unsafe {
20451 ffi::wgpuSharedTextureMemoryBeginAccess(
20452 self.raw,
20453 texture.as_raw(),
20454 descriptor_ptr,
20455 )
20456 };
20457 result.into()
20458 }
20459 pub fn end_access(
20460 &self,
20461 texture: Texture,
20462 descriptor: &mut SharedTextureMemoryEndAccessState,
20463 ) -> Status {
20464 let (mut descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20465 let descriptor_ptr = std::ptr::addr_of_mut!(descriptor_ffi);
20466 let result = unsafe {
20467 ffi::wgpuSharedTextureMemoryEndAccess(
20468 self.raw,
20469 texture.as_raw(),
20470 descriptor_ptr,
20471 )
20472 };
20473 *descriptor = SharedTextureMemoryEndAccessState::from_ffi(descriptor_ffi);
20474 result.into()
20475 }
20476 pub fn is_device_lost(&self) -> bool {
20477 let result = unsafe { ffi::wgpuSharedTextureMemoryIsDeviceLost(self.raw) };
20478 result != 0
20479 }
20480 }
20481 impl Drop for SharedTextureMemory {
20482 fn drop(&mut self) {
20483 if self.as_raw().is_null() {
20484 return;
20485 }
20486 unsafe { ffi::wgpuSharedTextureMemoryRelease(self.raw) };
20487 }
20488 }
20489 impl Clone for SharedTextureMemory {
20490 fn clone(&self) -> Self {
20491 unsafe { ffi::wgpuSharedTextureMemoryAddRef(self.raw) };
20492 Self { raw: self.raw }
20493 }
20494 }
20495 unsafe impl Send for SharedTextureMemory {}
20496 unsafe impl Sync for SharedTextureMemory {}
20497 #[derive(Debug)]
20498 pub struct Surface {
20499 raw: ffi::WGPUSurface,
20500 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
20501 }
20502 impl Surface {
20503 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSurface) -> Self {
20504 Self {
20505 raw,
20506 _not_sync: std::marker::PhantomData,
20507 }
20508 }
20509 pub fn as_raw(&self) -> ffi::WGPUSurface {
20510 self.raw
20511 }
20512 pub fn configure(&self, config: &SurfaceConfiguration) -> () {
20513 let (config_ffi, _config_storage) = config.to_ffi();
20514 let config_ptr = std::ptr::addr_of!(config_ffi);
20515 unsafe { ffi::wgpuSurfaceConfigure(self.raw, config_ptr) };
20516 ()
20517 }
20518 pub fn get_capabilities(
20519 &self,
20520 adapter: Adapter,
20521 capabilities: &mut SurfaceCapabilities,
20522 ) -> Status {
20523 let (mut capabilities_ffi, _capabilities_storage) = capabilities.to_ffi();
20524 let capabilities_ptr = std::ptr::addr_of_mut!(capabilities_ffi);
20525 let result = unsafe {
20526 ffi::wgpuSurfaceGetCapabilities(
20527 self.raw,
20528 adapter.as_raw(),
20529 capabilities_ptr,
20530 )
20531 };
20532 *capabilities = SurfaceCapabilities::from_ffi(capabilities_ffi);
20533 result.into()
20534 }
20535 pub fn get_current_texture(&self, surface_texture: &mut SurfaceTexture) -> () {
20536 let (mut surface_texture_ffi, _surface_texture_storage) = surface_texture
20537 .to_ffi();
20538 let surface_texture_ptr = std::ptr::addr_of_mut!(surface_texture_ffi);
20539 unsafe { ffi::wgpuSurfaceGetCurrentTexture(self.raw, surface_texture_ptr) };
20540 *surface_texture = SurfaceTexture::from_ffi(surface_texture_ffi);
20541 ()
20542 }
20543 pub fn present(&self) -> Status {
20544 let result = unsafe { ffi::wgpuSurfacePresent(self.raw) };
20545 result.into()
20546 }
20547 pub fn unconfigure(&self) -> () {
20548 unsafe { ffi::wgpuSurfaceUnconfigure(self.raw) };
20549 ()
20550 }
20551 pub fn set_label(&self, label: String) -> () {
20552 let label_ffi = ffi::WGPUStringView {
20553 data: label.as_ptr().cast(),
20554 length: label.len(),
20555 };
20556 unsafe { ffi::wgpuSurfaceSetLabel(self.raw, label_ffi) };
20557 ()
20558 }
20559 }
20560 impl Drop for Surface {
20561 fn drop(&mut self) {
20562 if self.as_raw().is_null() {
20563 return;
20564 }
20565 unsafe { ffi::wgpuSurfaceRelease(self.raw) };
20566 }
20567 }
20568 impl Clone for Surface {
20569 fn clone(&self) -> Self {
20570 unsafe { ffi::wgpuSurfaceAddRef(self.raw) };
20571 Self {
20572 raw: self.raw,
20573 _not_sync: std::marker::PhantomData,
20574 }
20575 }
20576 }
20577 unsafe impl Send for Surface {}
20578 #[derive(Debug)]
20579 pub struct TexelBufferView {
20580 raw: ffi::WGPUTexelBufferView,
20581 }
20582 impl TexelBufferView {
20583 pub(crate) unsafe fn from_raw(raw: ffi::WGPUTexelBufferView) -> Self {
20584 Self { raw }
20585 }
20586 pub fn as_raw(&self) -> ffi::WGPUTexelBufferView {
20587 self.raw
20588 }
20589 pub fn set_label(&self, label: String) -> () {
20590 let label_ffi = ffi::WGPUStringView {
20591 data: label.as_ptr().cast(),
20592 length: label.len(),
20593 };
20594 unsafe { ffi::wgpuTexelBufferViewSetLabel(self.raw, label_ffi) };
20595 ()
20596 }
20597 }
20598 impl Drop for TexelBufferView {
20599 fn drop(&mut self) {
20600 if self.as_raw().is_null() {
20601 return;
20602 }
20603 unsafe { ffi::wgpuTexelBufferViewRelease(self.raw) };
20604 }
20605 }
20606 impl Clone for TexelBufferView {
20607 fn clone(&self) -> Self {
20608 unsafe { ffi::wgpuTexelBufferViewAddRef(self.raw) };
20609 Self { raw: self.raw }
20610 }
20611 }
20612 unsafe impl Send for TexelBufferView {}
20613 unsafe impl Sync for TexelBufferView {}
20614 #[derive(Debug)]
20615 pub struct Texture {
20616 raw: ffi::WGPUTexture,
20617 }
20618 impl Texture {
20619 pub(crate) unsafe fn from_raw(raw: ffi::WGPUTexture) -> Self {
20620 Self { raw }
20621 }
20622 pub fn as_raw(&self) -> ffi::WGPUTexture {
20623 self.raw
20624 }
20625 pub fn create_view(
20626 &self,
20627 descriptor: Option<&TextureViewDescriptor>,
20628 ) -> TextureView {
20629 let mut descriptor_storage = ChainedStructStorage::new();
20630 let descriptor_ptr = if let Some(value) = &descriptor {
20631 let (descriptor_ffi, storage) = value.to_ffi();
20632 descriptor_storage = storage;
20633 std::ptr::addr_of!(descriptor_ffi)
20634 } else {
20635 std::ptr::null()
20636 };
20637 let result = unsafe { ffi::wgpuTextureCreateView(self.raw, descriptor_ptr) };
20638 unsafe { TextureView::from_raw(result) }
20639 }
20640 pub fn create_error_view(
20641 &self,
20642 descriptor: Option<&TextureViewDescriptor>,
20643 ) -> TextureView {
20644 let mut descriptor_storage = ChainedStructStorage::new();
20645 let descriptor_ptr = if let Some(value) = &descriptor {
20646 let (descriptor_ffi, storage) = value.to_ffi();
20647 descriptor_storage = storage;
20648 std::ptr::addr_of!(descriptor_ffi)
20649 } else {
20650 std::ptr::null()
20651 };
20652 let result = unsafe {
20653 ffi::wgpuTextureCreateErrorView(self.raw, descriptor_ptr)
20654 };
20655 unsafe { TextureView::from_raw(result) }
20656 }
20657 pub fn set_label(&self, label: String) -> () {
20658 let label_ffi = ffi::WGPUStringView {
20659 data: label.as_ptr().cast(),
20660 length: label.len(),
20661 };
20662 unsafe { ffi::wgpuTextureSetLabel(self.raw, label_ffi) };
20663 ()
20664 }
20665 pub fn get_width(&self) -> u32 {
20666 let result = unsafe { ffi::wgpuTextureGetWidth(self.raw) };
20667 result
20668 }
20669 pub fn get_height(&self) -> u32 {
20670 let result = unsafe { ffi::wgpuTextureGetHeight(self.raw) };
20671 result
20672 }
20673 pub fn get_depth_or_array_layers(&self) -> u32 {
20674 let result = unsafe { ffi::wgpuTextureGetDepthOrArrayLayers(self.raw) };
20675 result
20676 }
20677 pub fn get_mip_level_count(&self) -> u32 {
20678 let result = unsafe { ffi::wgpuTextureGetMipLevelCount(self.raw) };
20679 result
20680 }
20681 pub fn get_sample_count(&self) -> u32 {
20682 let result = unsafe { ffi::wgpuTextureGetSampleCount(self.raw) };
20683 result
20684 }
20685 pub fn get_dimension(&self) -> TextureDimension {
20686 let result = unsafe { ffi::wgpuTextureGetDimension(self.raw) };
20687 result.into()
20688 }
20689 pub fn get_format(&self) -> TextureFormat {
20690 let result = unsafe { ffi::wgpuTextureGetFormat(self.raw) };
20691 result.into()
20692 }
20693 pub fn get_usage(&self) -> TextureUsage {
20694 let result = unsafe { ffi::wgpuTextureGetUsage(self.raw) };
20695 result.into()
20696 }
20697 pub fn get_texture_binding_view_dimension(&self) -> TextureViewDimension {
20698 let result = unsafe {
20699 ffi::wgpuTextureGetTextureBindingViewDimension(self.raw)
20700 };
20701 result.into()
20702 }
20703 pub fn destroy(&self) -> () {
20704 unsafe { ffi::wgpuTextureDestroy(self.raw) };
20705 ()
20706 }
20707 pub fn pin(&self, usage: TextureUsage) -> () {
20708 let usage_ffi: ffi::WGPUTextureUsage = usage.into();
20709 unsafe { ffi::wgpuTexturePin(self.raw, usage_ffi) };
20710 ()
20711 }
20712 pub fn unpin(&self) -> () {
20713 unsafe { ffi::wgpuTextureUnpin(self.raw) };
20714 ()
20715 }
20716 pub fn set_ownership_for_memory_dump(&self, owner_guid: u64) -> () {
20717 unsafe { ffi::wgpuTextureSetOwnershipForMemoryDump(self.raw, owner_guid) };
20718 ()
20719 }
20720 }
20721 impl Drop for Texture {
20722 fn drop(&mut self) {
20723 if self.as_raw().is_null() {
20724 return;
20725 }
20726 unsafe { ffi::wgpuTextureRelease(self.raw) };
20727 }
20728 }
20729 impl Clone for Texture {
20730 fn clone(&self) -> Self {
20731 unsafe { ffi::wgpuTextureAddRef(self.raw) };
20732 Self { raw: self.raw }
20733 }
20734 }
20735 unsafe impl Send for Texture {}
20736 unsafe impl Sync for Texture {}
20737 #[derive(Debug)]
20738 pub struct TextureView {
20739 raw: ffi::WGPUTextureView,
20740 }
20741 impl TextureView {
20742 pub(crate) unsafe fn from_raw(raw: ffi::WGPUTextureView) -> Self {
20743 Self { raw }
20744 }
20745 pub fn as_raw(&self) -> ffi::WGPUTextureView {
20746 self.raw
20747 }
20748 pub fn set_label(&self, label: String) -> () {
20749 let label_ffi = ffi::WGPUStringView {
20750 data: label.as_ptr().cast(),
20751 length: label.len(),
20752 };
20753 unsafe { ffi::wgpuTextureViewSetLabel(self.raw, label_ffi) };
20754 ()
20755 }
20756 }
20757 impl Drop for TextureView {
20758 fn drop(&mut self) {
20759 if self.as_raw().is_null() {
20760 return;
20761 }
20762 unsafe { ffi::wgpuTextureViewRelease(self.raw) };
20763 }
20764 }
20765 impl Clone for TextureView {
20766 fn clone(&self) -> Self {
20767 unsafe { ffi::wgpuTextureViewAddRef(self.raw) };
20768 Self { raw: self.raw }
20769 }
20770 }
20771 unsafe impl Send for TextureView {}
20772 unsafe impl Sync for TextureView {}
20773}
20774mod callbacks {
20775 #![allow(dead_code, unused_imports)]
20776 use crate::ffi;
20777 use crate::generated::*;
20778 pub type Callback = Option<unsafe extern "C" fn(*mut std::ffi::c_void) -> ()>;
20779 pub type DawnLoadCacheDataFunction = Option<
20780 unsafe extern "C" fn(
20781 *const std::ffi::c_void,
20782 usize,
20783 *mut std::ffi::c_void,
20784 usize,
20785 *mut std::ffi::c_void,
20786 ) -> usize,
20787 >;
20788 pub type DawnStoreCacheDataFunction = Option<
20789 unsafe extern "C" fn(
20790 *const std::ffi::c_void,
20791 usize,
20792 *const std::ffi::c_void,
20793 usize,
20794 *mut std::ffi::c_void,
20795 ) -> (),
20796 >;
20797 pub type Proc = Option<unsafe extern "C" fn() -> ()>;
20798 pub type BufferMapCallback = Box<dyn FnMut(MapAsyncStatus, String) + Send + 'static>;
20799 pub(crate) unsafe extern "C" fn buffer_map_callback_trampoline(
20800 status: ffi::WGPUMapAsyncStatus,
20801 message: ffi::WGPUStringView,
20802 userdata1: *mut std::ffi::c_void,
20803 userdata2: *mut std::ffi::c_void,
20804 ) {
20805 let _ = userdata2;
20806 let status = status.into();
20807 let message = string_view_to_string(message);
20808 let mut callback = unsafe {
20809 Box::from_raw(userdata1.cast::<Option<BufferMapCallback>>())
20810 };
20811 if let Some(mut callback) = callback.take() {
20812 callback(status, message);
20813 }
20814 }
20815 pub type CompilationInfoCallback = Box<
20816 dyn FnMut(CompilationInfoRequestStatus, &CompilationInfo) + Send + 'static,
20817 >;
20818 pub(crate) unsafe extern "C" fn compilation_info_callback_trampoline(
20819 status: ffi::WGPUCompilationInfoRequestStatus,
20820 compilation_info: *const ffi::WGPUCompilationInfo,
20821 userdata1: *mut std::ffi::c_void,
20822 userdata2: *mut std::ffi::c_void,
20823 ) {
20824 let _ = userdata2;
20825 let status = status.into();
20826 let compilation_info = if compilation_info.is_null() {
20827 CompilationInfo::new()
20828 } else {
20829 CompilationInfo::new()
20830 };
20831 let mut callback = unsafe {
20832 Box::from_raw(userdata1.cast::<Option<CompilationInfoCallback>>())
20833 };
20834 if let Some(mut callback) = callback.take() {
20835 callback(status, &compilation_info);
20836 }
20837 }
20838 pub type CreateComputePipelineAsyncCallback = Box<
20839 dyn FnMut(
20840 CreatePipelineAsyncStatus,
20841 Option<ComputePipeline>,
20842 String,
20843 ) + Send + 'static,
20844 >;
20845 pub(crate) unsafe extern "C" fn create_compute_pipeline_async_callback_trampoline(
20846 status: ffi::WGPUCreatePipelineAsyncStatus,
20847 pipeline: ffi::WGPUComputePipeline,
20848 message: ffi::WGPUStringView,
20849 userdata1: *mut std::ffi::c_void,
20850 userdata2: *mut std::ffi::c_void,
20851 ) {
20852 let _ = userdata2;
20853 let status = status.into();
20854 let pipeline = if pipeline.is_null() {
20855 None
20856 } else {
20857 Some(unsafe { ComputePipeline::from_raw(pipeline) })
20858 };
20859 let message = string_view_to_string(message);
20860 let mut callback = unsafe {
20861 Box::from_raw(userdata1.cast::<Option<CreateComputePipelineAsyncCallback>>())
20862 };
20863 if let Some(mut callback) = callback.take() {
20864 callback(status, pipeline, message);
20865 }
20866 }
20867 pub type CreateRenderPipelineAsyncCallback = Box<
20868 dyn FnMut(
20869 CreatePipelineAsyncStatus,
20870 Option<RenderPipeline>,
20871 String,
20872 ) + Send + 'static,
20873 >;
20874 pub(crate) unsafe extern "C" fn create_render_pipeline_async_callback_trampoline(
20875 status: ffi::WGPUCreatePipelineAsyncStatus,
20876 pipeline: ffi::WGPURenderPipeline,
20877 message: ffi::WGPUStringView,
20878 userdata1: *mut std::ffi::c_void,
20879 userdata2: *mut std::ffi::c_void,
20880 ) {
20881 let _ = userdata2;
20882 let status = status.into();
20883 let pipeline = if pipeline.is_null() {
20884 None
20885 } else {
20886 Some(unsafe { RenderPipeline::from_raw(pipeline) })
20887 };
20888 let message = string_view_to_string(message);
20889 let mut callback = unsafe {
20890 Box::from_raw(userdata1.cast::<Option<CreateRenderPipelineAsyncCallback>>())
20891 };
20892 if let Some(mut callback) = callback.take() {
20893 callback(status, pipeline, message);
20894 }
20895 }
20896 pub type DeviceLostCallback = Box<
20897 dyn FnMut(Vec<Device>, DeviceLostReason, String) + Send + 'static,
20898 >;
20899 pub(crate) unsafe extern "C" fn device_lost_callback_trampoline(
20900 device: *const ffi::WGPUDevice,
20901 reason: ffi::WGPUDeviceLostReason,
20902 message: ffi::WGPUStringView,
20903 userdata1: *mut std::ffi::c_void,
20904 userdata2: *mut std::ffi::c_void,
20905 ) {
20906 let _ = userdata2;
20907 let device = if device.is_null() {
20908 Vec::new()
20909 } else {
20910 unsafe { std::slice::from_raw_parts(device, 1) }
20911 .iter()
20912 .map(|raw| unsafe { Device::from_raw(*raw) })
20913 .collect()
20914 };
20915 let reason = reason.into();
20916 let message = string_view_to_string(message);
20917 let mut callback = unsafe {
20918 Box::from_raw(userdata1.cast::<Option<DeviceLostCallback>>())
20919 };
20920 if let Some(mut callback) = callback.take() {
20921 callback(device, reason, message);
20922 }
20923 }
20924 pub type LoggingCallback = Box<dyn FnMut(LoggingType, String) + Send + 'static>;
20925 pub(crate) unsafe extern "C" fn logging_callback_trampoline(
20926 r#type: ffi::WGPULoggingType,
20927 message: ffi::WGPUStringView,
20928 userdata1: *mut std::ffi::c_void,
20929 userdata2: *mut std::ffi::c_void,
20930 ) {
20931 let _ = userdata2;
20932 let r#type = r#type.into();
20933 let message = string_view_to_string(message);
20934 let mut callback = unsafe {
20935 Box::from_raw(userdata1.cast::<Option<LoggingCallback>>())
20936 };
20937 if let Some(mut callback) = callback.take() {
20938 callback(r#type, message);
20939 }
20940 }
20941 pub type PopErrorScopeCallback = Box<
20942 dyn FnMut(PopErrorScopeStatus, ErrorType, String) + Send + 'static,
20943 >;
20944 pub(crate) unsafe extern "C" fn pop_error_scope_callback_trampoline(
20945 status: ffi::WGPUPopErrorScopeStatus,
20946 r#type: ffi::WGPUErrorType,
20947 message: ffi::WGPUStringView,
20948 userdata1: *mut std::ffi::c_void,
20949 userdata2: *mut std::ffi::c_void,
20950 ) {
20951 let _ = userdata2;
20952 let status = status.into();
20953 let r#type = r#type.into();
20954 let message = string_view_to_string(message);
20955 let mut callback = unsafe {
20956 Box::from_raw(userdata1.cast::<Option<PopErrorScopeCallback>>())
20957 };
20958 if let Some(mut callback) = callback.take() {
20959 callback(status, r#type, message);
20960 }
20961 }
20962 pub type QueueWorkDoneCallback = Box<
20963 dyn FnMut(QueueWorkDoneStatus, String) + Send + 'static,
20964 >;
20965 pub(crate) unsafe extern "C" fn queue_work_done_callback_trampoline(
20966 status: ffi::WGPUQueueWorkDoneStatus,
20967 message: ffi::WGPUStringView,
20968 userdata1: *mut std::ffi::c_void,
20969 userdata2: *mut std::ffi::c_void,
20970 ) {
20971 let _ = userdata2;
20972 let status = status.into();
20973 let message = string_view_to_string(message);
20974 let mut callback = unsafe {
20975 Box::from_raw(userdata1.cast::<Option<QueueWorkDoneCallback>>())
20976 };
20977 if let Some(mut callback) = callback.take() {
20978 callback(status, message);
20979 }
20980 }
20981 pub type RequestAdapterCallback = Box<
20982 dyn FnMut(RequestAdapterStatus, Option<Adapter>, String) + Send + 'static,
20983 >;
20984 pub(crate) unsafe extern "C" fn request_adapter_callback_trampoline(
20985 status: ffi::WGPURequestAdapterStatus,
20986 adapter: ffi::WGPUAdapter,
20987 message: ffi::WGPUStringView,
20988 userdata1: *mut std::ffi::c_void,
20989 userdata2: *mut std::ffi::c_void,
20990 ) {
20991 let _ = userdata2;
20992 let status = status.into();
20993 let adapter = if adapter.is_null() {
20994 None
20995 } else {
20996 Some(unsafe { Adapter::from_raw(adapter) })
20997 };
20998 let message = string_view_to_string(message);
20999 let mut callback = unsafe {
21000 Box::from_raw(userdata1.cast::<Option<RequestAdapterCallback>>())
21001 };
21002 if let Some(mut callback) = callback.take() {
21003 callback(status, adapter, message);
21004 }
21005 }
21006 pub type RequestDeviceCallback = Box<
21007 dyn FnMut(RequestDeviceStatus, Option<Device>, String) + Send + 'static,
21008 >;
21009 pub(crate) unsafe extern "C" fn request_device_callback_trampoline(
21010 status: ffi::WGPURequestDeviceStatus,
21011 device: ffi::WGPUDevice,
21012 message: ffi::WGPUStringView,
21013 userdata1: *mut std::ffi::c_void,
21014 userdata2: *mut std::ffi::c_void,
21015 ) {
21016 let _ = userdata2;
21017 let status = status.into();
21018 let device = if device.is_null() {
21019 None
21020 } else {
21021 Some(unsafe { Device::from_raw(device) })
21022 };
21023 let message = string_view_to_string(message);
21024 let mut callback = unsafe {
21025 Box::from_raw(userdata1.cast::<Option<RequestDeviceCallback>>())
21026 };
21027 if let Some(mut callback) = callback.take() {
21028 callback(status, device, message);
21029 }
21030 }
21031 pub type UncapturedErrorCallback = Box<
21032 dyn FnMut(Vec<Device>, ErrorType, String) + Send + 'static,
21033 >;
21034 pub(crate) unsafe extern "C" fn uncaptured_error_callback_trampoline(
21035 device: *const ffi::WGPUDevice,
21036 r#type: ffi::WGPUErrorType,
21037 message: ffi::WGPUStringView,
21038 userdata1: *mut std::ffi::c_void,
21039 userdata2: *mut std::ffi::c_void,
21040 ) {
21041 let _ = userdata2;
21042 let device = if device.is_null() {
21043 Vec::new()
21044 } else {
21045 unsafe { std::slice::from_raw_parts(device, 1) }
21046 .iter()
21047 .map(|raw| unsafe { Device::from_raw(*raw) })
21048 .collect()
21049 };
21050 let r#type = r#type.into();
21051 let message = string_view_to_string(message);
21052 let mut callback = unsafe {
21053 Box::from_raw(userdata1.cast::<Option<UncapturedErrorCallback>>())
21054 };
21055 if let Some(mut callback) = callback.take() {
21056 callback(device, r#type, message);
21057 }
21058 }
21059 pub struct BufferMapCallbackInfo {
21060 pub mode: Option<CallbackMode>,
21061 pub callback: std::cell::RefCell<Option<BufferMapCallback>>,
21062 }
21063 impl Default for BufferMapCallbackInfo {
21064 fn default() -> Self {
21065 Self {
21066 mode: None,
21067 callback: std::cell::RefCell::new(None),
21068 }
21069 }
21070 }
21071 impl BufferMapCallbackInfo {
21072 pub fn new() -> Self {
21073 Self::default()
21074 }
21075 }
21076 pub struct CompilationInfoCallbackInfo {
21077 pub mode: Option<CallbackMode>,
21078 pub callback: std::cell::RefCell<Option<CompilationInfoCallback>>,
21079 }
21080 impl Default for CompilationInfoCallbackInfo {
21081 fn default() -> Self {
21082 Self {
21083 mode: None,
21084 callback: std::cell::RefCell::new(None),
21085 }
21086 }
21087 }
21088 impl CompilationInfoCallbackInfo {
21089 pub fn new() -> Self {
21090 Self::default()
21091 }
21092 }
21093 pub struct CreateComputePipelineAsyncCallbackInfo {
21094 pub mode: Option<CallbackMode>,
21095 pub callback: std::cell::RefCell<Option<CreateComputePipelineAsyncCallback>>,
21096 }
21097 impl Default for CreateComputePipelineAsyncCallbackInfo {
21098 fn default() -> Self {
21099 Self {
21100 mode: None,
21101 callback: std::cell::RefCell::new(None),
21102 }
21103 }
21104 }
21105 impl CreateComputePipelineAsyncCallbackInfo {
21106 pub fn new() -> Self {
21107 Self::default()
21108 }
21109 }
21110 pub struct CreateRenderPipelineAsyncCallbackInfo {
21111 pub mode: Option<CallbackMode>,
21112 pub callback: std::cell::RefCell<Option<CreateRenderPipelineAsyncCallback>>,
21113 }
21114 impl Default for CreateRenderPipelineAsyncCallbackInfo {
21115 fn default() -> Self {
21116 Self {
21117 mode: None,
21118 callback: std::cell::RefCell::new(None),
21119 }
21120 }
21121 }
21122 impl CreateRenderPipelineAsyncCallbackInfo {
21123 pub fn new() -> Self {
21124 Self::default()
21125 }
21126 }
21127 pub struct DeviceLostCallbackInfo {
21128 pub mode: Option<CallbackMode>,
21129 pub callback: std::cell::RefCell<Option<DeviceLostCallback>>,
21130 }
21131 impl Default for DeviceLostCallbackInfo {
21132 fn default() -> Self {
21133 Self {
21134 mode: None,
21135 callback: std::cell::RefCell::new(None),
21136 }
21137 }
21138 }
21139 impl DeviceLostCallbackInfo {
21140 pub fn new() -> Self {
21141 Self::default()
21142 }
21143 }
21144 pub struct LoggingCallbackInfo {
21145 pub callback: std::cell::RefCell<Option<LoggingCallback>>,
21146 }
21147 impl Default for LoggingCallbackInfo {
21148 fn default() -> Self {
21149 Self {
21150 callback: std::cell::RefCell::new(None),
21151 }
21152 }
21153 }
21154 impl LoggingCallbackInfo {
21155 pub fn new() -> Self {
21156 Self::default()
21157 }
21158 }
21159 pub struct PopErrorScopeCallbackInfo {
21160 pub mode: Option<CallbackMode>,
21161 pub callback: std::cell::RefCell<Option<PopErrorScopeCallback>>,
21162 }
21163 impl Default for PopErrorScopeCallbackInfo {
21164 fn default() -> Self {
21165 Self {
21166 mode: None,
21167 callback: std::cell::RefCell::new(None),
21168 }
21169 }
21170 }
21171 impl PopErrorScopeCallbackInfo {
21172 pub fn new() -> Self {
21173 Self::default()
21174 }
21175 }
21176 pub struct QueueWorkDoneCallbackInfo {
21177 pub mode: Option<CallbackMode>,
21178 pub callback: std::cell::RefCell<Option<QueueWorkDoneCallback>>,
21179 }
21180 impl Default for QueueWorkDoneCallbackInfo {
21181 fn default() -> Self {
21182 Self {
21183 mode: None,
21184 callback: std::cell::RefCell::new(None),
21185 }
21186 }
21187 }
21188 impl QueueWorkDoneCallbackInfo {
21189 pub fn new() -> Self {
21190 Self::default()
21191 }
21192 }
21193 pub struct RequestAdapterCallbackInfo {
21194 pub mode: Option<CallbackMode>,
21195 pub callback: std::cell::RefCell<Option<RequestAdapterCallback>>,
21196 }
21197 impl Default for RequestAdapterCallbackInfo {
21198 fn default() -> Self {
21199 Self {
21200 mode: None,
21201 callback: std::cell::RefCell::new(None),
21202 }
21203 }
21204 }
21205 impl RequestAdapterCallbackInfo {
21206 pub fn new() -> Self {
21207 Self::default()
21208 }
21209 }
21210 pub struct RequestDeviceCallbackInfo {
21211 pub mode: Option<CallbackMode>,
21212 pub callback: std::cell::RefCell<Option<RequestDeviceCallback>>,
21213 }
21214 impl Default for RequestDeviceCallbackInfo {
21215 fn default() -> Self {
21216 Self {
21217 mode: None,
21218 callback: std::cell::RefCell::new(None),
21219 }
21220 }
21221 }
21222 impl RequestDeviceCallbackInfo {
21223 pub fn new() -> Self {
21224 Self::default()
21225 }
21226 }
21227 pub struct UncapturedErrorCallbackInfo {
21228 pub callback: std::cell::RefCell<Option<UncapturedErrorCallback>>,
21229 }
21230 impl Default for UncapturedErrorCallbackInfo {
21231 fn default() -> Self {
21232 Self {
21233 callback: std::cell::RefCell::new(None),
21234 }
21235 }
21236 }
21237 impl UncapturedErrorCallbackInfo {
21238 pub fn new() -> Self {
21239 Self::default()
21240 }
21241 }
21242}
21243mod functions {
21244 #![allow(dead_code, unused_imports)]
21245 use crate::generated::*;
21246 use crate::ffi;
21247 pub fn create_instance(descriptor: Option<&InstanceDescriptor>) -> Instance {
21248 let mut descriptor_storage = ChainedStructStorage::new();
21249 let descriptor_ptr = if let Some(value) = &descriptor {
21250 let (descriptor_ffi, storage) = value.to_ffi();
21251 descriptor_storage = storage;
21252 std::ptr::addr_of!(descriptor_ffi)
21253 } else {
21254 std::ptr::null()
21255 };
21256 let result = unsafe { ffi::wgpuCreateInstance(descriptor_ptr) };
21257 unsafe { Instance::from_raw(result) }
21258 }
21259 pub fn get_instance_features(features: &mut SupportedInstanceFeatures) -> () {
21260 let (mut features_ffi, _features_storage) = features.to_ffi();
21261 let features_ptr = std::ptr::addr_of_mut!(features_ffi);
21262 unsafe { ffi::wgpuGetInstanceFeatures(features_ptr) };
21263 *features = SupportedInstanceFeatures::from_ffi(features_ffi);
21264 ()
21265 }
21266 pub fn get_instance_limits(limits: &mut InstanceLimits) -> Status {
21267 let (mut limits_ffi, _limits_storage) = limits.to_ffi();
21268 let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
21269 let result = unsafe { ffi::wgpuGetInstanceLimits(limits_ptr) };
21270 *limits = InstanceLimits::from_ffi(limits_ffi);
21271 result.into()
21272 }
21273 pub fn get_proc_address(proc_name: String) -> Proc {
21274 let proc_name_ffi = ffi::WGPUStringView {
21275 data: proc_name.as_ptr().cast(),
21276 length: proc_name.len(),
21277 };
21278 let result = unsafe { ffi::wgpuGetProcAddress(proc_name_ffi) };
21279 result
21280 }
21281 pub fn has_instance_feature(feature: InstanceFeatureName) -> bool {
21282 let feature_ffi: ffi::WGPUInstanceFeatureName = feature.into();
21283 let result = unsafe { ffi::wgpuHasInstanceFeature(feature_ffi) };
21284 result != 0
21285 }
21286}
21287mod constants {
21288 #![allow(dead_code, unused_imports)]
21289 use crate::generated::*;
21290 use crate::ffi;
21291 pub const ARRAY_LAYER_COUNT_UNDEFINED: u32 = u32::MAX;
21292 pub const COPY_STRIDE_UNDEFINED: u32 = u32::MAX;
21293 pub const DEPTH_CLEAR_VALUE_UNDEFINED: f32 = f32::NAN;
21294 pub const DEPTH_SLICE_UNDEFINED: u32 = u32::MAX;
21295 pub const INVALID_BINDING: u32 = u32::MAX;
21296 pub const LIMIT_U32_UNDEFINED: u32 = u32::MAX;
21297 pub const LIMIT_U64_UNDEFINED: u64 = u64::MAX;
21298 pub const MIP_LEVEL_COUNT_UNDEFINED: u32 = u32::MAX;
21299 pub const QUERY_SET_INDEX_UNDEFINED: u32 = u32::MAX;
21300 pub const STRLEN: usize = usize::MAX;
21301 pub const WHOLE_MAP_SIZE: usize = usize::MAX;
21302 pub const WHOLE_SIZE: u64 = u64::MAX;
21303}
21304pub use enums::*;
21305pub use structs::*;
21306pub use extensions::*;
21307pub use objects::*;
21308pub use callbacks::*;
21309pub use functions::*;
21310pub use constants::*;