Skip to main content

dawn_rs/generated/
linux_x86_64.rs

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        RenderPassRenderArea,
1194    }
1195    impl From<ffi::WGPUFeatureName> for FeatureName {
1196        fn from(value: ffi::WGPUFeatureName) -> Self {
1197            match value {
1198                ffi::WGPUFeatureName_WGPUFeatureName_CoreFeaturesAndLimits => {
1199                    FeatureName::CoreFeaturesAndLimits
1200                }
1201                ffi::WGPUFeatureName_WGPUFeatureName_DepthClipControl => {
1202                    FeatureName::DepthClipControl
1203                }
1204                ffi::WGPUFeatureName_WGPUFeatureName_Depth32FloatStencil8 => {
1205                    FeatureName::Depth32FloatStencil8
1206                }
1207                ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBC => {
1208                    FeatureName::TextureCompressionBc
1209                }
1210                ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBCSliced3D => {
1211                    FeatureName::TextureCompressionBcSliced3D
1212                }
1213                ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionETC2 => {
1214                    FeatureName::TextureCompressionEtc2
1215                }
1216                ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTC => {
1217                    FeatureName::TextureCompressionAstc
1218                }
1219                ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTCSliced3D => {
1220                    FeatureName::TextureCompressionAstcSliced3D
1221                }
1222                ffi::WGPUFeatureName_WGPUFeatureName_TimestampQuery => {
1223                    FeatureName::TimestampQuery
1224                }
1225                ffi::WGPUFeatureName_WGPUFeatureName_IndirectFirstInstance => {
1226                    FeatureName::IndirectFirstInstance
1227                }
1228                ffi::WGPUFeatureName_WGPUFeatureName_ShaderF16 => FeatureName::ShaderF16,
1229                ffi::WGPUFeatureName_WGPUFeatureName_RG11B10UfloatRenderable => {
1230                    FeatureName::Rg11B10UfloatRenderable
1231                }
1232                ffi::WGPUFeatureName_WGPUFeatureName_BGRA8UnormStorage => {
1233                    FeatureName::Bgra8UnormStorage
1234                }
1235                ffi::WGPUFeatureName_WGPUFeatureName_Float32Filterable => {
1236                    FeatureName::Float32Filterable
1237                }
1238                ffi::WGPUFeatureName_WGPUFeatureName_Float32Blendable => {
1239                    FeatureName::Float32Blendable
1240                }
1241                ffi::WGPUFeatureName_WGPUFeatureName_ClipDistances => {
1242                    FeatureName::ClipDistances
1243                }
1244                ffi::WGPUFeatureName_WGPUFeatureName_DualSourceBlending => {
1245                    FeatureName::DualSourceBlending
1246                }
1247                ffi::WGPUFeatureName_WGPUFeatureName_Subgroups => FeatureName::Subgroups,
1248                ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier1 => {
1249                    FeatureName::TextureFormatsTier1
1250                }
1251                ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier2 => {
1252                    FeatureName::TextureFormatsTier2
1253                }
1254                ffi::WGPUFeatureName_WGPUFeatureName_PrimitiveIndex => {
1255                    FeatureName::PrimitiveIndex
1256                }
1257                ffi::WGPUFeatureName_WGPUFeatureName_TextureComponentSwizzle => {
1258                    FeatureName::TextureComponentSwizzle
1259                }
1260                ffi::WGPUFeatureName_WGPUFeatureName_DawnInternalUsages => {
1261                    FeatureName::DawnInternalUsages
1262                }
1263                ffi::WGPUFeatureName_WGPUFeatureName_DawnMultiPlanarFormats => {
1264                    FeatureName::DawnMultiPlanarFormats
1265                }
1266                ffi::WGPUFeatureName_WGPUFeatureName_DawnNative => {
1267                    FeatureName::DawnNative
1268                }
1269                ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalTimestampQueryInsidePasses => {
1270                    FeatureName::ChromiumExperimentalTimestampQueryInsidePasses
1271                }
1272                ffi::WGPUFeatureName_WGPUFeatureName_ImplicitDeviceSynchronization => {
1273                    FeatureName::ImplicitDeviceSynchronization
1274                }
1275                ffi::WGPUFeatureName_WGPUFeatureName_TransientAttachments => {
1276                    FeatureName::TransientAttachments
1277                }
1278                ffi::WGPUFeatureName_WGPUFeatureName_MSAARenderToSingleSampled => {
1279                    FeatureName::MsaaRenderToSingleSampled
1280                }
1281                ffi::WGPUFeatureName_WGPUFeatureName_D3D11MultithreadProtected => {
1282                    FeatureName::D3D11MultithreadProtected
1283                }
1284                ffi::WGPUFeatureName_WGPUFeatureName_ANGLETextureSharing => {
1285                    FeatureName::AngleTextureSharing
1286                }
1287                ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageCoherent => {
1288                    FeatureName::PixelLocalStorageCoherent
1289                }
1290                ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageNonCoherent => {
1291                    FeatureName::PixelLocalStorageNonCoherent
1292                }
1293                ffi::WGPUFeatureName_WGPUFeatureName_Unorm16TextureFormats => {
1294                    FeatureName::Unorm16TextureFormats
1295                }
1296                ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatExtendedUsages => {
1297                    FeatureName::MultiPlanarFormatExtendedUsages
1298                }
1299                ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP010 => {
1300                    FeatureName::MultiPlanarFormatP010
1301                }
1302                ffi::WGPUFeatureName_WGPUFeatureName_HostMappedPointer => {
1303                    FeatureName::HostMappedPointer
1304                }
1305                ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarRenderTargets => {
1306                    FeatureName::MultiPlanarRenderTargets
1307                }
1308                ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv12a => {
1309                    FeatureName::MultiPlanarFormatNv12A
1310                }
1311                ffi::WGPUFeatureName_WGPUFeatureName_FramebufferFetch => {
1312                    FeatureName::FramebufferFetch
1313                }
1314                ffi::WGPUFeatureName_WGPUFeatureName_BufferMapExtendedUsages => {
1315                    FeatureName::BufferMapExtendedUsages
1316                }
1317                ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesMemoryHeaps => {
1318                    FeatureName::AdapterPropertiesMemoryHeaps
1319                }
1320                ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesD3D => {
1321                    FeatureName::AdapterPropertiesD3D
1322                }
1323                ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesVk => {
1324                    FeatureName::AdapterPropertiesVk
1325                }
1326                ffi::WGPUFeatureName_WGPUFeatureName_DawnFormatCapabilities => {
1327                    FeatureName::DawnFormatCapabilities
1328                }
1329                ffi::WGPUFeatureName_WGPUFeatureName_DawnDrmFormatCapabilities => {
1330                    FeatureName::DawnDrmFormatCapabilities
1331                }
1332                ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv16 => {
1333                    FeatureName::MultiPlanarFormatNv16
1334                }
1335                ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv24 => {
1336                    FeatureName::MultiPlanarFormatNv24
1337                }
1338                ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP210 => {
1339                    FeatureName::MultiPlanarFormatP210
1340                }
1341                ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP410 => {
1342                    FeatureName::MultiPlanarFormatP410
1343                }
1344                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryVkDedicatedAllocation => {
1345                    FeatureName::SharedTextureMemoryVkDedicatedAllocation
1346                }
1347                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryAHardwareBuffer => {
1348                    FeatureName::SharedTextureMemoryAHardwareBuffer
1349                }
1350                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDmaBuf => {
1351                    FeatureName::SharedTextureMemoryDmaBuf
1352                }
1353                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryOpaqueFD => {
1354                    FeatureName::SharedTextureMemoryOpaqueFD
1355                }
1356                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryZirconHandle => {
1357                    FeatureName::SharedTextureMemoryZirconHandle
1358                }
1359                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDXGISharedHandle => {
1360                    FeatureName::SharedTextureMemoryDXGISharedHandle
1361                }
1362                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D11Texture2D => {
1363                    FeatureName::SharedTextureMemoryD3D11Texture2D
1364                }
1365                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryIOSurface => {
1366                    FeatureName::SharedTextureMemoryIOSurface
1367                }
1368                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryEGLImage => {
1369                    FeatureName::SharedTextureMemoryEGLImage
1370                }
1371                ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreOpaqueFD => {
1372                    FeatureName::SharedFenceVkSemaphoreOpaqueFD
1373                }
1374                ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceSyncFD => {
1375                    FeatureName::SharedFenceSyncFD
1376                }
1377                ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreZirconHandle => {
1378                    FeatureName::SharedFenceVkSemaphoreZirconHandle
1379                }
1380                ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceDXGISharedHandle => {
1381                    FeatureName::SharedFenceDXGISharedHandle
1382                }
1383                ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceMTLSharedEvent => {
1384                    FeatureName::SharedFenceMTLSharedEvent
1385                }
1386                ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12Resource => {
1387                    FeatureName::SharedBufferMemoryD3D12Resource
1388                }
1389                ffi::WGPUFeatureName_WGPUFeatureName_StaticSamplers => {
1390                    FeatureName::StaticSamplers
1391                }
1392                ffi::WGPUFeatureName_WGPUFeatureName_YCbCrVulkanSamplers => {
1393                    FeatureName::YCbCrVulkanSamplers
1394                }
1395                ffi::WGPUFeatureName_WGPUFeatureName_ShaderModuleCompilationOptions => {
1396                    FeatureName::ShaderModuleCompilationOptions
1397                }
1398                ffi::WGPUFeatureName_WGPUFeatureName_DawnLoadResolveTexture => {
1399                    FeatureName::DawnLoadResolveTexture
1400                }
1401                ffi::WGPUFeatureName_WGPUFeatureName_DawnPartialLoadResolveTexture => {
1402                    FeatureName::DawnPartialLoadResolveTexture
1403                }
1404                ffi::WGPUFeatureName_WGPUFeatureName_MultiDrawIndirect => {
1405                    FeatureName::MultiDrawIndirect
1406                }
1407                ffi::WGPUFeatureName_WGPUFeatureName_DawnTexelCopyBufferRowAlignment => {
1408                    FeatureName::DawnTexelCopyBufferRowAlignment
1409                }
1410                ffi::WGPUFeatureName_WGPUFeatureName_FlexibleTextureViews => {
1411                    FeatureName::FlexibleTextureViews
1412                }
1413                ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupMatrix => {
1414                    FeatureName::ChromiumExperimentalSubgroupMatrix
1415                }
1416                ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceEGLSync => {
1417                    FeatureName::SharedFenceEGLSync
1418                }
1419                ffi::WGPUFeatureName_WGPUFeatureName_DawnDeviceAllocatorControl => {
1420                    FeatureName::DawnDeviceAllocatorControl
1421                }
1422                ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesWGPU => {
1423                    FeatureName::AdapterPropertiesWGPU
1424                }
1425                ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12SharedMemoryFileMappingHandle => {
1426                    FeatureName::SharedBufferMemoryD3D12SharedMemoryFileMappingHandle
1427                }
1428                ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D12Resource => {
1429                    FeatureName::SharedTextureMemoryD3D12Resource
1430                }
1431                ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSamplingResourceTable => {
1432                    FeatureName::ChromiumExperimentalSamplingResourceTable
1433                }
1434                ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupSizeControl => {
1435                    FeatureName::ChromiumExperimentalSubgroupSizeControl
1436                }
1437                ffi::WGPUFeatureName_WGPUFeatureName_AtomicVec2uMinMax => {
1438                    FeatureName::AtomicVec2UMinMax
1439                }
1440                ffi::WGPUFeatureName_WGPUFeatureName_Unorm16FormatsForExternalTexture => {
1441                    FeatureName::Unorm16FormatsForExternalTexture
1442                }
1443                ffi::WGPUFeatureName_WGPUFeatureName_OpaqueYCbCrAndroidForExternalTexture => {
1444                    FeatureName::OpaqueYCbCrAndroidForExternalTexture
1445                }
1446                ffi::WGPUFeatureName_WGPUFeatureName_Unorm16Filterable => {
1447                    FeatureName::Unorm16Filterable
1448                }
1449                ffi::WGPUFeatureName_WGPUFeatureName_RenderPassRenderArea => {
1450                    FeatureName::RenderPassRenderArea
1451                }
1452                _ => FeatureName::CoreFeaturesAndLimits,
1453            }
1454        }
1455    }
1456    impl From<FeatureName> for ffi::WGPUFeatureName {
1457        fn from(value: FeatureName) -> Self {
1458            match value {
1459                FeatureName::CoreFeaturesAndLimits => {
1460                    ffi::WGPUFeatureName_WGPUFeatureName_CoreFeaturesAndLimits
1461                }
1462                FeatureName::DepthClipControl => {
1463                    ffi::WGPUFeatureName_WGPUFeatureName_DepthClipControl
1464                }
1465                FeatureName::Depth32FloatStencil8 => {
1466                    ffi::WGPUFeatureName_WGPUFeatureName_Depth32FloatStencil8
1467                }
1468                FeatureName::TextureCompressionBc => {
1469                    ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBC
1470                }
1471                FeatureName::TextureCompressionBcSliced3D => {
1472                    ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBCSliced3D
1473                }
1474                FeatureName::TextureCompressionEtc2 => {
1475                    ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionETC2
1476                }
1477                FeatureName::TextureCompressionAstc => {
1478                    ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTC
1479                }
1480                FeatureName::TextureCompressionAstcSliced3D => {
1481                    ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTCSliced3D
1482                }
1483                FeatureName::TimestampQuery => {
1484                    ffi::WGPUFeatureName_WGPUFeatureName_TimestampQuery
1485                }
1486                FeatureName::IndirectFirstInstance => {
1487                    ffi::WGPUFeatureName_WGPUFeatureName_IndirectFirstInstance
1488                }
1489                FeatureName::ShaderF16 => ffi::WGPUFeatureName_WGPUFeatureName_ShaderF16,
1490                FeatureName::Rg11B10UfloatRenderable => {
1491                    ffi::WGPUFeatureName_WGPUFeatureName_RG11B10UfloatRenderable
1492                }
1493                FeatureName::Bgra8UnormStorage => {
1494                    ffi::WGPUFeatureName_WGPUFeatureName_BGRA8UnormStorage
1495                }
1496                FeatureName::Float32Filterable => {
1497                    ffi::WGPUFeatureName_WGPUFeatureName_Float32Filterable
1498                }
1499                FeatureName::Float32Blendable => {
1500                    ffi::WGPUFeatureName_WGPUFeatureName_Float32Blendable
1501                }
1502                FeatureName::ClipDistances => {
1503                    ffi::WGPUFeatureName_WGPUFeatureName_ClipDistances
1504                }
1505                FeatureName::DualSourceBlending => {
1506                    ffi::WGPUFeatureName_WGPUFeatureName_DualSourceBlending
1507                }
1508                FeatureName::Subgroups => ffi::WGPUFeatureName_WGPUFeatureName_Subgroups,
1509                FeatureName::TextureFormatsTier1 => {
1510                    ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier1
1511                }
1512                FeatureName::TextureFormatsTier2 => {
1513                    ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier2
1514                }
1515                FeatureName::PrimitiveIndex => {
1516                    ffi::WGPUFeatureName_WGPUFeatureName_PrimitiveIndex
1517                }
1518                FeatureName::TextureComponentSwizzle => {
1519                    ffi::WGPUFeatureName_WGPUFeatureName_TextureComponentSwizzle
1520                }
1521                FeatureName::DawnInternalUsages => {
1522                    ffi::WGPUFeatureName_WGPUFeatureName_DawnInternalUsages
1523                }
1524                FeatureName::DawnMultiPlanarFormats => {
1525                    ffi::WGPUFeatureName_WGPUFeatureName_DawnMultiPlanarFormats
1526                }
1527                FeatureName::DawnNative => {
1528                    ffi::WGPUFeatureName_WGPUFeatureName_DawnNative
1529                }
1530                FeatureName::ChromiumExperimentalTimestampQueryInsidePasses => {
1531                    ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalTimestampQueryInsidePasses
1532                }
1533                FeatureName::ImplicitDeviceSynchronization => {
1534                    ffi::WGPUFeatureName_WGPUFeatureName_ImplicitDeviceSynchronization
1535                }
1536                FeatureName::TransientAttachments => {
1537                    ffi::WGPUFeatureName_WGPUFeatureName_TransientAttachments
1538                }
1539                FeatureName::MsaaRenderToSingleSampled => {
1540                    ffi::WGPUFeatureName_WGPUFeatureName_MSAARenderToSingleSampled
1541                }
1542                FeatureName::D3D11MultithreadProtected => {
1543                    ffi::WGPUFeatureName_WGPUFeatureName_D3D11MultithreadProtected
1544                }
1545                FeatureName::AngleTextureSharing => {
1546                    ffi::WGPUFeatureName_WGPUFeatureName_ANGLETextureSharing
1547                }
1548                FeatureName::PixelLocalStorageCoherent => {
1549                    ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageCoherent
1550                }
1551                FeatureName::PixelLocalStorageNonCoherent => {
1552                    ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageNonCoherent
1553                }
1554                FeatureName::Unorm16TextureFormats => {
1555                    ffi::WGPUFeatureName_WGPUFeatureName_Unorm16TextureFormats
1556                }
1557                FeatureName::MultiPlanarFormatExtendedUsages => {
1558                    ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatExtendedUsages
1559                }
1560                FeatureName::MultiPlanarFormatP010 => {
1561                    ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP010
1562                }
1563                FeatureName::HostMappedPointer => {
1564                    ffi::WGPUFeatureName_WGPUFeatureName_HostMappedPointer
1565                }
1566                FeatureName::MultiPlanarRenderTargets => {
1567                    ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarRenderTargets
1568                }
1569                FeatureName::MultiPlanarFormatNv12A => {
1570                    ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv12a
1571                }
1572                FeatureName::FramebufferFetch => {
1573                    ffi::WGPUFeatureName_WGPUFeatureName_FramebufferFetch
1574                }
1575                FeatureName::BufferMapExtendedUsages => {
1576                    ffi::WGPUFeatureName_WGPUFeatureName_BufferMapExtendedUsages
1577                }
1578                FeatureName::AdapterPropertiesMemoryHeaps => {
1579                    ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesMemoryHeaps
1580                }
1581                FeatureName::AdapterPropertiesD3D => {
1582                    ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesD3D
1583                }
1584                FeatureName::AdapterPropertiesVk => {
1585                    ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesVk
1586                }
1587                FeatureName::DawnFormatCapabilities => {
1588                    ffi::WGPUFeatureName_WGPUFeatureName_DawnFormatCapabilities
1589                }
1590                FeatureName::DawnDrmFormatCapabilities => {
1591                    ffi::WGPUFeatureName_WGPUFeatureName_DawnDrmFormatCapabilities
1592                }
1593                FeatureName::MultiPlanarFormatNv16 => {
1594                    ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv16
1595                }
1596                FeatureName::MultiPlanarFormatNv24 => {
1597                    ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv24
1598                }
1599                FeatureName::MultiPlanarFormatP210 => {
1600                    ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP210
1601                }
1602                FeatureName::MultiPlanarFormatP410 => {
1603                    ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP410
1604                }
1605                FeatureName::SharedTextureMemoryVkDedicatedAllocation => {
1606                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryVkDedicatedAllocation
1607                }
1608                FeatureName::SharedTextureMemoryAHardwareBuffer => {
1609                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryAHardwareBuffer
1610                }
1611                FeatureName::SharedTextureMemoryDmaBuf => {
1612                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDmaBuf
1613                }
1614                FeatureName::SharedTextureMemoryOpaqueFD => {
1615                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryOpaqueFD
1616                }
1617                FeatureName::SharedTextureMemoryZirconHandle => {
1618                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryZirconHandle
1619                }
1620                FeatureName::SharedTextureMemoryDXGISharedHandle => {
1621                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDXGISharedHandle
1622                }
1623                FeatureName::SharedTextureMemoryD3D11Texture2D => {
1624                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D11Texture2D
1625                }
1626                FeatureName::SharedTextureMemoryIOSurface => {
1627                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryIOSurface
1628                }
1629                FeatureName::SharedTextureMemoryEGLImage => {
1630                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryEGLImage
1631                }
1632                FeatureName::SharedFenceVkSemaphoreOpaqueFD => {
1633                    ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreOpaqueFD
1634                }
1635                FeatureName::SharedFenceSyncFD => {
1636                    ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceSyncFD
1637                }
1638                FeatureName::SharedFenceVkSemaphoreZirconHandle => {
1639                    ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreZirconHandle
1640                }
1641                FeatureName::SharedFenceDXGISharedHandle => {
1642                    ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceDXGISharedHandle
1643                }
1644                FeatureName::SharedFenceMTLSharedEvent => {
1645                    ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceMTLSharedEvent
1646                }
1647                FeatureName::SharedBufferMemoryD3D12Resource => {
1648                    ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12Resource
1649                }
1650                FeatureName::StaticSamplers => {
1651                    ffi::WGPUFeatureName_WGPUFeatureName_StaticSamplers
1652                }
1653                FeatureName::YCbCrVulkanSamplers => {
1654                    ffi::WGPUFeatureName_WGPUFeatureName_YCbCrVulkanSamplers
1655                }
1656                FeatureName::ShaderModuleCompilationOptions => {
1657                    ffi::WGPUFeatureName_WGPUFeatureName_ShaderModuleCompilationOptions
1658                }
1659                FeatureName::DawnLoadResolveTexture => {
1660                    ffi::WGPUFeatureName_WGPUFeatureName_DawnLoadResolveTexture
1661                }
1662                FeatureName::DawnPartialLoadResolveTexture => {
1663                    ffi::WGPUFeatureName_WGPUFeatureName_DawnPartialLoadResolveTexture
1664                }
1665                FeatureName::MultiDrawIndirect => {
1666                    ffi::WGPUFeatureName_WGPUFeatureName_MultiDrawIndirect
1667                }
1668                FeatureName::DawnTexelCopyBufferRowAlignment => {
1669                    ffi::WGPUFeatureName_WGPUFeatureName_DawnTexelCopyBufferRowAlignment
1670                }
1671                FeatureName::FlexibleTextureViews => {
1672                    ffi::WGPUFeatureName_WGPUFeatureName_FlexibleTextureViews
1673                }
1674                FeatureName::ChromiumExperimentalSubgroupMatrix => {
1675                    ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupMatrix
1676                }
1677                FeatureName::SharedFenceEGLSync => {
1678                    ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceEGLSync
1679                }
1680                FeatureName::DawnDeviceAllocatorControl => {
1681                    ffi::WGPUFeatureName_WGPUFeatureName_DawnDeviceAllocatorControl
1682                }
1683                FeatureName::AdapterPropertiesWGPU => {
1684                    ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesWGPU
1685                }
1686                FeatureName::SharedBufferMemoryD3D12SharedMemoryFileMappingHandle => {
1687                    ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12SharedMemoryFileMappingHandle
1688                }
1689                FeatureName::SharedTextureMemoryD3D12Resource => {
1690                    ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D12Resource
1691                }
1692                FeatureName::ChromiumExperimentalSamplingResourceTable => {
1693                    ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSamplingResourceTable
1694                }
1695                FeatureName::ChromiumExperimentalSubgroupSizeControl => {
1696                    ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupSizeControl
1697                }
1698                FeatureName::AtomicVec2UMinMax => {
1699                    ffi::WGPUFeatureName_WGPUFeatureName_AtomicVec2uMinMax
1700                }
1701                FeatureName::Unorm16FormatsForExternalTexture => {
1702                    ffi::WGPUFeatureName_WGPUFeatureName_Unorm16FormatsForExternalTexture
1703                }
1704                FeatureName::OpaqueYCbCrAndroidForExternalTexture => {
1705                    ffi::WGPUFeatureName_WGPUFeatureName_OpaqueYCbCrAndroidForExternalTexture
1706                }
1707                FeatureName::Unorm16Filterable => {
1708                    ffi::WGPUFeatureName_WGPUFeatureName_Unorm16Filterable
1709                }
1710                FeatureName::RenderPassRenderArea => {
1711                    ffi::WGPUFeatureName_WGPUFeatureName_RenderPassRenderArea
1712                }
1713            }
1714        }
1715    }
1716    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1717    pub enum FilterMode {
1718        Undefined,
1719        Nearest,
1720        Linear,
1721    }
1722    impl From<ffi::WGPUFilterMode> for FilterMode {
1723        fn from(value: ffi::WGPUFilterMode) -> Self {
1724            match value {
1725                ffi::WGPUFilterMode_WGPUFilterMode_Undefined => FilterMode::Undefined,
1726                ffi::WGPUFilterMode_WGPUFilterMode_Nearest => FilterMode::Nearest,
1727                ffi::WGPUFilterMode_WGPUFilterMode_Linear => FilterMode::Linear,
1728                _ => FilterMode::Undefined,
1729            }
1730        }
1731    }
1732    impl From<FilterMode> for ffi::WGPUFilterMode {
1733        fn from(value: FilterMode) -> Self {
1734            match value {
1735                FilterMode::Undefined => ffi::WGPUFilterMode_WGPUFilterMode_Undefined,
1736                FilterMode::Nearest => ffi::WGPUFilterMode_WGPUFilterMode_Nearest,
1737                FilterMode::Linear => ffi::WGPUFilterMode_WGPUFilterMode_Linear,
1738            }
1739        }
1740    }
1741    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1742    pub enum FrontFace {
1743        Undefined,
1744        Ccw,
1745        Cw,
1746    }
1747    impl From<ffi::WGPUFrontFace> for FrontFace {
1748        fn from(value: ffi::WGPUFrontFace) -> Self {
1749            match value {
1750                ffi::WGPUFrontFace_WGPUFrontFace_Undefined => FrontFace::Undefined,
1751                ffi::WGPUFrontFace_WGPUFrontFace_CCW => FrontFace::Ccw,
1752                ffi::WGPUFrontFace_WGPUFrontFace_CW => FrontFace::Cw,
1753                _ => FrontFace::Undefined,
1754            }
1755        }
1756    }
1757    impl From<FrontFace> for ffi::WGPUFrontFace {
1758        fn from(value: FrontFace) -> Self {
1759            match value {
1760                FrontFace::Undefined => ffi::WGPUFrontFace_WGPUFrontFace_Undefined,
1761                FrontFace::Ccw => ffi::WGPUFrontFace_WGPUFrontFace_CCW,
1762                FrontFace::Cw => ffi::WGPUFrontFace_WGPUFrontFace_CW,
1763            }
1764        }
1765    }
1766    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1767    pub enum IndexFormat {
1768        Undefined,
1769        Uint16,
1770        Uint32,
1771    }
1772    impl From<ffi::WGPUIndexFormat> for IndexFormat {
1773        fn from(value: ffi::WGPUIndexFormat) -> Self {
1774            match value {
1775                ffi::WGPUIndexFormat_WGPUIndexFormat_Undefined => IndexFormat::Undefined,
1776                ffi::WGPUIndexFormat_WGPUIndexFormat_Uint16 => IndexFormat::Uint16,
1777                ffi::WGPUIndexFormat_WGPUIndexFormat_Uint32 => IndexFormat::Uint32,
1778                _ => IndexFormat::Undefined,
1779            }
1780        }
1781    }
1782    impl From<IndexFormat> for ffi::WGPUIndexFormat {
1783        fn from(value: IndexFormat) -> Self {
1784            match value {
1785                IndexFormat::Undefined => ffi::WGPUIndexFormat_WGPUIndexFormat_Undefined,
1786                IndexFormat::Uint16 => ffi::WGPUIndexFormat_WGPUIndexFormat_Uint16,
1787                IndexFormat::Uint32 => ffi::WGPUIndexFormat_WGPUIndexFormat_Uint32,
1788            }
1789        }
1790    }
1791    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1792    pub enum InstanceFeatureName {
1793        TimedWaitAny,
1794        ShaderSourceSPIRV,
1795        MultipleDevicesPerAdapter,
1796    }
1797    impl From<ffi::WGPUInstanceFeatureName> for InstanceFeatureName {
1798        fn from(value: ffi::WGPUInstanceFeatureName) -> Self {
1799            match value {
1800                ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_TimedWaitAny => {
1801                    InstanceFeatureName::TimedWaitAny
1802                }
1803                ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_ShaderSourceSPIRV => {
1804                    InstanceFeatureName::ShaderSourceSPIRV
1805                }
1806                ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_MultipleDevicesPerAdapter => {
1807                    InstanceFeatureName::MultipleDevicesPerAdapter
1808                }
1809                _ => InstanceFeatureName::TimedWaitAny,
1810            }
1811        }
1812    }
1813    impl From<InstanceFeatureName> for ffi::WGPUInstanceFeatureName {
1814        fn from(value: InstanceFeatureName) -> Self {
1815            match value {
1816                InstanceFeatureName::TimedWaitAny => {
1817                    ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_TimedWaitAny
1818                }
1819                InstanceFeatureName::ShaderSourceSPIRV => {
1820                    ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_ShaderSourceSPIRV
1821                }
1822                InstanceFeatureName::MultipleDevicesPerAdapter => {
1823                    ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_MultipleDevicesPerAdapter
1824                }
1825            }
1826        }
1827    }
1828    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1829    pub enum LoadOp {
1830        Undefined,
1831        Load,
1832        Clear,
1833        ExpandResolveTexture,
1834    }
1835    impl From<ffi::WGPULoadOp> for LoadOp {
1836        fn from(value: ffi::WGPULoadOp) -> Self {
1837            match value {
1838                ffi::WGPULoadOp_WGPULoadOp_Undefined => LoadOp::Undefined,
1839                ffi::WGPULoadOp_WGPULoadOp_Load => LoadOp::Load,
1840                ffi::WGPULoadOp_WGPULoadOp_Clear => LoadOp::Clear,
1841                ffi::WGPULoadOp_WGPULoadOp_ExpandResolveTexture => {
1842                    LoadOp::ExpandResolveTexture
1843                }
1844                _ => LoadOp::Undefined,
1845            }
1846        }
1847    }
1848    impl From<LoadOp> for ffi::WGPULoadOp {
1849        fn from(value: LoadOp) -> Self {
1850            match value {
1851                LoadOp::Undefined => ffi::WGPULoadOp_WGPULoadOp_Undefined,
1852                LoadOp::Load => ffi::WGPULoadOp_WGPULoadOp_Load,
1853                LoadOp::Clear => ffi::WGPULoadOp_WGPULoadOp_Clear,
1854                LoadOp::ExpandResolveTexture => {
1855                    ffi::WGPULoadOp_WGPULoadOp_ExpandResolveTexture
1856                }
1857            }
1858        }
1859    }
1860    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1861    pub enum LoggingType {
1862        Verbose,
1863        Info,
1864        Warning,
1865        Error,
1866    }
1867    impl From<ffi::WGPULoggingType> for LoggingType {
1868        fn from(value: ffi::WGPULoggingType) -> Self {
1869            match value {
1870                ffi::WGPULoggingType_WGPULoggingType_Verbose => LoggingType::Verbose,
1871                ffi::WGPULoggingType_WGPULoggingType_Info => LoggingType::Info,
1872                ffi::WGPULoggingType_WGPULoggingType_Warning => LoggingType::Warning,
1873                ffi::WGPULoggingType_WGPULoggingType_Error => LoggingType::Error,
1874                _ => LoggingType::Verbose,
1875            }
1876        }
1877    }
1878    impl From<LoggingType> for ffi::WGPULoggingType {
1879        fn from(value: LoggingType) -> Self {
1880            match value {
1881                LoggingType::Verbose => ffi::WGPULoggingType_WGPULoggingType_Verbose,
1882                LoggingType::Info => ffi::WGPULoggingType_WGPULoggingType_Info,
1883                LoggingType::Warning => ffi::WGPULoggingType_WGPULoggingType_Warning,
1884                LoggingType::Error => ffi::WGPULoggingType_WGPULoggingType_Error,
1885            }
1886        }
1887    }
1888    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1889    pub enum MapAsyncStatus {
1890        Success,
1891        CallbackCancelled,
1892        Error,
1893        Aborted,
1894    }
1895    impl From<ffi::WGPUMapAsyncStatus> for MapAsyncStatus {
1896        fn from(value: ffi::WGPUMapAsyncStatus) -> Self {
1897            match value {
1898                ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Success => {
1899                    MapAsyncStatus::Success
1900                }
1901                ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_CallbackCancelled => {
1902                    MapAsyncStatus::CallbackCancelled
1903                }
1904                ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Error => MapAsyncStatus::Error,
1905                ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Aborted => {
1906                    MapAsyncStatus::Aborted
1907                }
1908                _ => MapAsyncStatus::Success,
1909            }
1910        }
1911    }
1912    impl From<MapAsyncStatus> for ffi::WGPUMapAsyncStatus {
1913        fn from(value: MapAsyncStatus) -> Self {
1914            match value {
1915                MapAsyncStatus::Success => {
1916                    ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Success
1917                }
1918                MapAsyncStatus::CallbackCancelled => {
1919                    ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_CallbackCancelled
1920                }
1921                MapAsyncStatus::Error => ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Error,
1922                MapAsyncStatus::Aborted => {
1923                    ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Aborted
1924                }
1925            }
1926        }
1927    }
1928    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1929    pub enum MipmapFilterMode {
1930        Undefined,
1931        Nearest,
1932        Linear,
1933    }
1934    impl From<ffi::WGPUMipmapFilterMode> for MipmapFilterMode {
1935        fn from(value: ffi::WGPUMipmapFilterMode) -> Self {
1936            match value {
1937                ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Undefined => {
1938                    MipmapFilterMode::Undefined
1939                }
1940                ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Nearest => {
1941                    MipmapFilterMode::Nearest
1942                }
1943                ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Linear => {
1944                    MipmapFilterMode::Linear
1945                }
1946                _ => MipmapFilterMode::Undefined,
1947            }
1948        }
1949    }
1950    impl From<MipmapFilterMode> for ffi::WGPUMipmapFilterMode {
1951        fn from(value: MipmapFilterMode) -> Self {
1952            match value {
1953                MipmapFilterMode::Undefined => {
1954                    ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Undefined
1955                }
1956                MipmapFilterMode::Nearest => {
1957                    ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Nearest
1958                }
1959                MipmapFilterMode::Linear => {
1960                    ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Linear
1961                }
1962            }
1963        }
1964    }
1965    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1966    pub enum OptionalBool {
1967        False,
1968        True,
1969        Undefined,
1970    }
1971    impl From<ffi::WGPUOptionalBool> for OptionalBool {
1972        fn from(value: ffi::WGPUOptionalBool) -> Self {
1973            match value {
1974                ffi::WGPUOptionalBool_WGPUOptionalBool_False => OptionalBool::False,
1975                ffi::WGPUOptionalBool_WGPUOptionalBool_True => OptionalBool::True,
1976                ffi::WGPUOptionalBool_WGPUOptionalBool_Undefined => {
1977                    OptionalBool::Undefined
1978                }
1979                _ => OptionalBool::False,
1980            }
1981        }
1982    }
1983    impl From<OptionalBool> for ffi::WGPUOptionalBool {
1984        fn from(value: OptionalBool) -> Self {
1985            match value {
1986                OptionalBool::False => ffi::WGPUOptionalBool_WGPUOptionalBool_False,
1987                OptionalBool::True => ffi::WGPUOptionalBool_WGPUOptionalBool_True,
1988                OptionalBool::Undefined => {
1989                    ffi::WGPUOptionalBool_WGPUOptionalBool_Undefined
1990                }
1991            }
1992        }
1993    }
1994    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1995    pub enum PopErrorScopeStatus {
1996        Success,
1997        CallbackCancelled,
1998        Error,
1999    }
2000    impl From<ffi::WGPUPopErrorScopeStatus> for PopErrorScopeStatus {
2001        fn from(value: ffi::WGPUPopErrorScopeStatus) -> Self {
2002            match value {
2003                ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Success => {
2004                    PopErrorScopeStatus::Success
2005                }
2006                ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_CallbackCancelled => {
2007                    PopErrorScopeStatus::CallbackCancelled
2008                }
2009                ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Error => {
2010                    PopErrorScopeStatus::Error
2011                }
2012                _ => PopErrorScopeStatus::Success,
2013            }
2014        }
2015    }
2016    impl From<PopErrorScopeStatus> for ffi::WGPUPopErrorScopeStatus {
2017        fn from(value: PopErrorScopeStatus) -> Self {
2018            match value {
2019                PopErrorScopeStatus::Success => {
2020                    ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Success
2021                }
2022                PopErrorScopeStatus::CallbackCancelled => {
2023                    ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_CallbackCancelled
2024                }
2025                PopErrorScopeStatus::Error => {
2026                    ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Error
2027                }
2028            }
2029        }
2030    }
2031    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2032    pub enum PowerPreference {
2033        Undefined,
2034        LowPower,
2035        HighPerformance,
2036    }
2037    impl From<ffi::WGPUPowerPreference> for PowerPreference {
2038        fn from(value: ffi::WGPUPowerPreference) -> Self {
2039            match value {
2040                ffi::WGPUPowerPreference_WGPUPowerPreference_Undefined => {
2041                    PowerPreference::Undefined
2042                }
2043                ffi::WGPUPowerPreference_WGPUPowerPreference_LowPower => {
2044                    PowerPreference::LowPower
2045                }
2046                ffi::WGPUPowerPreference_WGPUPowerPreference_HighPerformance => {
2047                    PowerPreference::HighPerformance
2048                }
2049                _ => PowerPreference::Undefined,
2050            }
2051        }
2052    }
2053    impl From<PowerPreference> for ffi::WGPUPowerPreference {
2054        fn from(value: PowerPreference) -> Self {
2055            match value {
2056                PowerPreference::Undefined => {
2057                    ffi::WGPUPowerPreference_WGPUPowerPreference_Undefined
2058                }
2059                PowerPreference::LowPower => {
2060                    ffi::WGPUPowerPreference_WGPUPowerPreference_LowPower
2061                }
2062                PowerPreference::HighPerformance => {
2063                    ffi::WGPUPowerPreference_WGPUPowerPreference_HighPerformance
2064                }
2065            }
2066        }
2067    }
2068    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2069    pub enum PredefinedColorSpace {
2070        SRgb,
2071        DisplayP3,
2072    }
2073    impl From<ffi::WGPUPredefinedColorSpace> for PredefinedColorSpace {
2074        fn from(value: ffi::WGPUPredefinedColorSpace) -> Self {
2075            match value {
2076                ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_SRGB => {
2077                    PredefinedColorSpace::SRgb
2078                }
2079                ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_DisplayP3 => {
2080                    PredefinedColorSpace::DisplayP3
2081                }
2082                _ => PredefinedColorSpace::SRgb,
2083            }
2084        }
2085    }
2086    impl From<PredefinedColorSpace> for ffi::WGPUPredefinedColorSpace {
2087        fn from(value: PredefinedColorSpace) -> Self {
2088            match value {
2089                PredefinedColorSpace::SRgb => {
2090                    ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_SRGB
2091                }
2092                PredefinedColorSpace::DisplayP3 => {
2093                    ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_DisplayP3
2094                }
2095            }
2096        }
2097    }
2098    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2099    pub enum PresentMode {
2100        Undefined,
2101        Fifo,
2102        FifoRelaxed,
2103        Immediate,
2104        Mailbox,
2105    }
2106    impl From<ffi::WGPUPresentMode> for PresentMode {
2107        fn from(value: ffi::WGPUPresentMode) -> Self {
2108            match value {
2109                ffi::WGPUPresentMode_WGPUPresentMode_Undefined => PresentMode::Undefined,
2110                ffi::WGPUPresentMode_WGPUPresentMode_Fifo => PresentMode::Fifo,
2111                ffi::WGPUPresentMode_WGPUPresentMode_FifoRelaxed => {
2112                    PresentMode::FifoRelaxed
2113                }
2114                ffi::WGPUPresentMode_WGPUPresentMode_Immediate => PresentMode::Immediate,
2115                ffi::WGPUPresentMode_WGPUPresentMode_Mailbox => PresentMode::Mailbox,
2116                _ => PresentMode::Undefined,
2117            }
2118        }
2119    }
2120    impl From<PresentMode> for ffi::WGPUPresentMode {
2121        fn from(value: PresentMode) -> Self {
2122            match value {
2123                PresentMode::Undefined => ffi::WGPUPresentMode_WGPUPresentMode_Undefined,
2124                PresentMode::Fifo => ffi::WGPUPresentMode_WGPUPresentMode_Fifo,
2125                PresentMode::FifoRelaxed => {
2126                    ffi::WGPUPresentMode_WGPUPresentMode_FifoRelaxed
2127                }
2128                PresentMode::Immediate => ffi::WGPUPresentMode_WGPUPresentMode_Immediate,
2129                PresentMode::Mailbox => ffi::WGPUPresentMode_WGPUPresentMode_Mailbox,
2130            }
2131        }
2132    }
2133    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2134    pub enum PrimitiveTopology {
2135        Undefined,
2136        PointList,
2137        LineList,
2138        LineStrip,
2139        TriangleList,
2140        TriangleStrip,
2141    }
2142    impl From<ffi::WGPUPrimitiveTopology> for PrimitiveTopology {
2143        fn from(value: ffi::WGPUPrimitiveTopology) -> Self {
2144            match value {
2145                ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_Undefined => {
2146                    PrimitiveTopology::Undefined
2147                }
2148                ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_PointList => {
2149                    PrimitiveTopology::PointList
2150                }
2151                ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineList => {
2152                    PrimitiveTopology::LineList
2153                }
2154                ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineStrip => {
2155                    PrimitiveTopology::LineStrip
2156                }
2157                ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleList => {
2158                    PrimitiveTopology::TriangleList
2159                }
2160                ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleStrip => {
2161                    PrimitiveTopology::TriangleStrip
2162                }
2163                _ => PrimitiveTopology::Undefined,
2164            }
2165        }
2166    }
2167    impl From<PrimitiveTopology> for ffi::WGPUPrimitiveTopology {
2168        fn from(value: PrimitiveTopology) -> Self {
2169            match value {
2170                PrimitiveTopology::Undefined => {
2171                    ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_Undefined
2172                }
2173                PrimitiveTopology::PointList => {
2174                    ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_PointList
2175                }
2176                PrimitiveTopology::LineList => {
2177                    ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineList
2178                }
2179                PrimitiveTopology::LineStrip => {
2180                    ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineStrip
2181                }
2182                PrimitiveTopology::TriangleList => {
2183                    ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleList
2184                }
2185                PrimitiveTopology::TriangleStrip => {
2186                    ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleStrip
2187                }
2188            }
2189        }
2190    }
2191    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2192    pub enum QueryType {
2193        Occlusion,
2194        Timestamp,
2195    }
2196    impl From<ffi::WGPUQueryType> for QueryType {
2197        fn from(value: ffi::WGPUQueryType) -> Self {
2198            match value {
2199                ffi::WGPUQueryType_WGPUQueryType_Occlusion => QueryType::Occlusion,
2200                ffi::WGPUQueryType_WGPUQueryType_Timestamp => QueryType::Timestamp,
2201                _ => QueryType::Occlusion,
2202            }
2203        }
2204    }
2205    impl From<QueryType> for ffi::WGPUQueryType {
2206        fn from(value: QueryType) -> Self {
2207            match value {
2208                QueryType::Occlusion => ffi::WGPUQueryType_WGPUQueryType_Occlusion,
2209                QueryType::Timestamp => ffi::WGPUQueryType_WGPUQueryType_Timestamp,
2210            }
2211        }
2212    }
2213    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2214    pub enum QueueWorkDoneStatus {
2215        Success,
2216        CallbackCancelled,
2217        Error,
2218    }
2219    impl From<ffi::WGPUQueueWorkDoneStatus> for QueueWorkDoneStatus {
2220        fn from(value: ffi::WGPUQueueWorkDoneStatus) -> Self {
2221            match value {
2222                ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Success => {
2223                    QueueWorkDoneStatus::Success
2224                }
2225                ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_CallbackCancelled => {
2226                    QueueWorkDoneStatus::CallbackCancelled
2227                }
2228                ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Error => {
2229                    QueueWorkDoneStatus::Error
2230                }
2231                _ => QueueWorkDoneStatus::Success,
2232            }
2233        }
2234    }
2235    impl From<QueueWorkDoneStatus> for ffi::WGPUQueueWorkDoneStatus {
2236        fn from(value: QueueWorkDoneStatus) -> Self {
2237            match value {
2238                QueueWorkDoneStatus::Success => {
2239                    ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Success
2240                }
2241                QueueWorkDoneStatus::CallbackCancelled => {
2242                    ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_CallbackCancelled
2243                }
2244                QueueWorkDoneStatus::Error => {
2245                    ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Error
2246                }
2247            }
2248        }
2249    }
2250    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2251    pub enum RequestAdapterStatus {
2252        Success,
2253        CallbackCancelled,
2254        Unavailable,
2255        Error,
2256    }
2257    impl From<ffi::WGPURequestAdapterStatus> for RequestAdapterStatus {
2258        fn from(value: ffi::WGPURequestAdapterStatus) -> Self {
2259            match value {
2260                ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Success => {
2261                    RequestAdapterStatus::Success
2262                }
2263                ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_CallbackCancelled => {
2264                    RequestAdapterStatus::CallbackCancelled
2265                }
2266                ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Unavailable => {
2267                    RequestAdapterStatus::Unavailable
2268                }
2269                ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Error => {
2270                    RequestAdapterStatus::Error
2271                }
2272                _ => RequestAdapterStatus::Success,
2273            }
2274        }
2275    }
2276    impl From<RequestAdapterStatus> for ffi::WGPURequestAdapterStatus {
2277        fn from(value: RequestAdapterStatus) -> Self {
2278            match value {
2279                RequestAdapterStatus::Success => {
2280                    ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Success
2281                }
2282                RequestAdapterStatus::CallbackCancelled => {
2283                    ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_CallbackCancelled
2284                }
2285                RequestAdapterStatus::Unavailable => {
2286                    ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Unavailable
2287                }
2288                RequestAdapterStatus::Error => {
2289                    ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Error
2290                }
2291            }
2292        }
2293    }
2294    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2295    pub enum RequestDeviceStatus {
2296        Success,
2297        CallbackCancelled,
2298        Error,
2299    }
2300    impl From<ffi::WGPURequestDeviceStatus> for RequestDeviceStatus {
2301        fn from(value: ffi::WGPURequestDeviceStatus) -> Self {
2302            match value {
2303                ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Success => {
2304                    RequestDeviceStatus::Success
2305                }
2306                ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_CallbackCancelled => {
2307                    RequestDeviceStatus::CallbackCancelled
2308                }
2309                ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Error => {
2310                    RequestDeviceStatus::Error
2311                }
2312                _ => RequestDeviceStatus::Success,
2313            }
2314        }
2315    }
2316    impl From<RequestDeviceStatus> for ffi::WGPURequestDeviceStatus {
2317        fn from(value: RequestDeviceStatus) -> Self {
2318            match value {
2319                RequestDeviceStatus::Success => {
2320                    ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Success
2321                }
2322                RequestDeviceStatus::CallbackCancelled => {
2323                    ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_CallbackCancelled
2324                }
2325                RequestDeviceStatus::Error => {
2326                    ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Error
2327                }
2328            }
2329        }
2330    }
2331    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2332    pub enum SType {
2333        ShaderSourceSPIRV,
2334        ShaderSourceWGSL,
2335        RenderPassMaxDrawCount,
2336        SurfaceSourceMetalLayer,
2337        SurfaceSourceWindowsHWND,
2338        SurfaceSourceXlibWindow,
2339        SurfaceSourceWaylandSurface,
2340        SurfaceSourceAndroidNativeWindow,
2341        SurfaceSourceXCBWindow,
2342        SurfaceColorManagement,
2343        RequestAdapterWebXROptions,
2344        TextureComponentSwizzleDescriptor,
2345        CompatibilityModeLimits,
2346        TextureBindingViewDimensionDescriptor,
2347        EmscriptenSurfaceSourceCanvasHTMLSelector,
2348        SurfaceDescriptorFromWindowsCoreWindow,
2349        ExternalTextureBindingEntry,
2350        ExternalTextureBindingLayout,
2351        SurfaceDescriptorFromWindowsUWPSwapChainPanel,
2352        DawnTextureInternalUsageDescriptor,
2353        DawnEncoderInternalUsageDescriptor,
2354        DawnInstanceDescriptor,
2355        DawnCacheDeviceDescriptor,
2356        DawnAdapterPropertiesPowerPreference,
2357        DawnBufferDescriptorErrorInfoFromWireClient,
2358        DawnTogglesDescriptor,
2359        DawnShaderModuleSPIRVOptionsDescriptor,
2360        RequestAdapterOptionsLuid,
2361        RequestAdapterOptionsGetGlProc,
2362        RequestAdapterOptionsD3D11Device,
2363        DawnRenderPassSampleCount,
2364        RenderPassPixelLocalStorage,
2365        PipelineLayoutPixelLocalStorage,
2366        BufferHostMappedPointer,
2367        AdapterPropertiesMemoryHeaps,
2368        AdapterPropertiesD3D,
2369        AdapterPropertiesVk,
2370        DawnWireWGSLControl,
2371        DawnWGSLBlocklist,
2372        DawnDrmFormatCapabilities,
2373        ShaderModuleCompilationOptions,
2374        ColorTargetStateExpandResolveTextureDawn,
2375        RenderPassRenderAreaRect,
2376        SharedTextureMemoryVkDedicatedAllocationDescriptor,
2377        SharedTextureMemoryAHardwareBufferDescriptor,
2378        SharedTextureMemoryDmaBufDescriptor,
2379        SharedTextureMemoryOpaqueFDDescriptor,
2380        SharedTextureMemoryZirconHandleDescriptor,
2381        SharedTextureMemoryDXGISharedHandleDescriptor,
2382        SharedTextureMemoryD3D11Texture2DDescriptor,
2383        SharedTextureMemoryIOSurfaceDescriptor,
2384        SharedTextureMemoryEGLImageDescriptor,
2385        SharedTextureMemoryInitializedBeginState,
2386        SharedTextureMemoryInitializedEndState,
2387        SharedTextureMemoryVkImageLayoutBeginState,
2388        SharedTextureMemoryVkImageLayoutEndState,
2389        SharedTextureMemoryD3DSwapchainBeginState,
2390        SharedFenceVkSemaphoreOpaqueFDDescriptor,
2391        SharedFenceVkSemaphoreOpaqueFDExportInfo,
2392        SharedFenceSyncFDDescriptor,
2393        SharedFenceSyncFDExportInfo,
2394        SharedFenceVkSemaphoreZirconHandleDescriptor,
2395        SharedFenceVkSemaphoreZirconHandleExportInfo,
2396        SharedFenceDXGISharedHandleDescriptor,
2397        SharedFenceDXGISharedHandleExportInfo,
2398        SharedFenceMTLSharedEventDescriptor,
2399        SharedFenceMTLSharedEventExportInfo,
2400        SharedBufferMemoryD3D12ResourceDescriptor,
2401        StaticSamplerBindingLayout,
2402        YCbCrVkDescriptor,
2403        SharedTextureMemoryAHardwareBufferProperties,
2404        AHardwareBufferProperties,
2405        DawnTexelCopyBufferRowAlignmentLimits,
2406        AdapterPropertiesSubgroupMatrixConfigs,
2407        SharedFenceEGLSyncDescriptor,
2408        SharedFenceEGLSyncExportInfo,
2409        DawnInjectedInvalidSType,
2410        DawnCompilationMessageUtf16,
2411        DawnFakeBufferOOMForTesting,
2412        SurfaceDescriptorFromWindowsWinUISwapChainPanel,
2413        DawnDeviceAllocatorControl,
2414        DawnHostMappedPointerLimits,
2415        RenderPassDescriptorResolveRect,
2416        RequestAdapterWebGPUBackendOptions,
2417        DawnFakeDeviceInitializeErrorForTesting,
2418        SharedTextureMemoryD3D11BeginState,
2419        DawnConsumeAdapterDescriptor,
2420        TexelBufferBindingEntry,
2421        TexelBufferBindingLayout,
2422        SharedTextureMemoryMetalEndAccessState,
2423        AdapterPropertiesWGPU,
2424        SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
2425        SharedTextureMemoryD3D12ResourceDescriptor,
2426        RequestAdapterOptionsAngleVirtualizationGroup,
2427        PipelineLayoutResourceTable,
2428        AdapterPropertiesExplicitComputeSubgroupSizeConfigs,
2429    }
2430    impl From<ffi::WGPUSType> for SType {
2431        fn from(value: ffi::WGPUSType) -> Self {
2432            match value {
2433                ffi::WGPUSType_WGPUSType_ShaderSourceSPIRV => SType::ShaderSourceSPIRV,
2434                ffi::WGPUSType_WGPUSType_ShaderSourceWGSL => SType::ShaderSourceWGSL,
2435                ffi::WGPUSType_WGPUSType_RenderPassMaxDrawCount => {
2436                    SType::RenderPassMaxDrawCount
2437                }
2438                ffi::WGPUSType_WGPUSType_SurfaceSourceMetalLayer => {
2439                    SType::SurfaceSourceMetalLayer
2440                }
2441                ffi::WGPUSType_WGPUSType_SurfaceSourceWindowsHWND => {
2442                    SType::SurfaceSourceWindowsHWND
2443                }
2444                ffi::WGPUSType_WGPUSType_SurfaceSourceXlibWindow => {
2445                    SType::SurfaceSourceXlibWindow
2446                }
2447                ffi::WGPUSType_WGPUSType_SurfaceSourceWaylandSurface => {
2448                    SType::SurfaceSourceWaylandSurface
2449                }
2450                ffi::WGPUSType_WGPUSType_SurfaceSourceAndroidNativeWindow => {
2451                    SType::SurfaceSourceAndroidNativeWindow
2452                }
2453                ffi::WGPUSType_WGPUSType_SurfaceSourceXCBWindow => {
2454                    SType::SurfaceSourceXCBWindow
2455                }
2456                ffi::WGPUSType_WGPUSType_SurfaceColorManagement => {
2457                    SType::SurfaceColorManagement
2458                }
2459                ffi::WGPUSType_WGPUSType_RequestAdapterWebXROptions => {
2460                    SType::RequestAdapterWebXROptions
2461                }
2462                ffi::WGPUSType_WGPUSType_TextureComponentSwizzleDescriptor => {
2463                    SType::TextureComponentSwizzleDescriptor
2464                }
2465                ffi::WGPUSType_WGPUSType_CompatibilityModeLimits => {
2466                    SType::CompatibilityModeLimits
2467                }
2468                ffi::WGPUSType_WGPUSType_TextureBindingViewDimensionDescriptor => {
2469                    SType::TextureBindingViewDimensionDescriptor
2470                }
2471                ffi::WGPUSType_WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector => {
2472                    SType::EmscriptenSurfaceSourceCanvasHTMLSelector
2473                }
2474                ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsCoreWindow => {
2475                    SType::SurfaceDescriptorFromWindowsCoreWindow
2476                }
2477                ffi::WGPUSType_WGPUSType_ExternalTextureBindingEntry => {
2478                    SType::ExternalTextureBindingEntry
2479                }
2480                ffi::WGPUSType_WGPUSType_ExternalTextureBindingLayout => {
2481                    SType::ExternalTextureBindingLayout
2482                }
2483                ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsUWPSwapChainPanel => {
2484                    SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel
2485                }
2486                ffi::WGPUSType_WGPUSType_DawnTextureInternalUsageDescriptor => {
2487                    SType::DawnTextureInternalUsageDescriptor
2488                }
2489                ffi::WGPUSType_WGPUSType_DawnEncoderInternalUsageDescriptor => {
2490                    SType::DawnEncoderInternalUsageDescriptor
2491                }
2492                ffi::WGPUSType_WGPUSType_DawnInstanceDescriptor => {
2493                    SType::DawnInstanceDescriptor
2494                }
2495                ffi::WGPUSType_WGPUSType_DawnCacheDeviceDescriptor => {
2496                    SType::DawnCacheDeviceDescriptor
2497                }
2498                ffi::WGPUSType_WGPUSType_DawnAdapterPropertiesPowerPreference => {
2499                    SType::DawnAdapterPropertiesPowerPreference
2500                }
2501                ffi::WGPUSType_WGPUSType_DawnBufferDescriptorErrorInfoFromWireClient => {
2502                    SType::DawnBufferDescriptorErrorInfoFromWireClient
2503                }
2504                ffi::WGPUSType_WGPUSType_DawnTogglesDescriptor => {
2505                    SType::DawnTogglesDescriptor
2506                }
2507                ffi::WGPUSType_WGPUSType_DawnShaderModuleSPIRVOptionsDescriptor => {
2508                    SType::DawnShaderModuleSPIRVOptionsDescriptor
2509                }
2510                ffi::WGPUSType_WGPUSType_RequestAdapterOptionsLUID => {
2511                    SType::RequestAdapterOptionsLuid
2512                }
2513                ffi::WGPUSType_WGPUSType_RequestAdapterOptionsGetGLProc => {
2514                    SType::RequestAdapterOptionsGetGlProc
2515                }
2516                ffi::WGPUSType_WGPUSType_RequestAdapterOptionsD3D11Device => {
2517                    SType::RequestAdapterOptionsD3D11Device
2518                }
2519                ffi::WGPUSType_WGPUSType_DawnRenderPassSampleCount => {
2520                    SType::DawnRenderPassSampleCount
2521                }
2522                ffi::WGPUSType_WGPUSType_RenderPassPixelLocalStorage => {
2523                    SType::RenderPassPixelLocalStorage
2524                }
2525                ffi::WGPUSType_WGPUSType_PipelineLayoutPixelLocalStorage => {
2526                    SType::PipelineLayoutPixelLocalStorage
2527                }
2528                ffi::WGPUSType_WGPUSType_BufferHostMappedPointer => {
2529                    SType::BufferHostMappedPointer
2530                }
2531                ffi::WGPUSType_WGPUSType_AdapterPropertiesMemoryHeaps => {
2532                    SType::AdapterPropertiesMemoryHeaps
2533                }
2534                ffi::WGPUSType_WGPUSType_AdapterPropertiesD3D => {
2535                    SType::AdapterPropertiesD3D
2536                }
2537                ffi::WGPUSType_WGPUSType_AdapterPropertiesVk => {
2538                    SType::AdapterPropertiesVk
2539                }
2540                ffi::WGPUSType_WGPUSType_DawnWireWGSLControl => {
2541                    SType::DawnWireWGSLControl
2542                }
2543                ffi::WGPUSType_WGPUSType_DawnWGSLBlocklist => SType::DawnWGSLBlocklist,
2544                ffi::WGPUSType_WGPUSType_DawnDrmFormatCapabilities => {
2545                    SType::DawnDrmFormatCapabilities
2546                }
2547                ffi::WGPUSType_WGPUSType_ShaderModuleCompilationOptions => {
2548                    SType::ShaderModuleCompilationOptions
2549                }
2550                ffi::WGPUSType_WGPUSType_ColorTargetStateExpandResolveTextureDawn => {
2551                    SType::ColorTargetStateExpandResolveTextureDawn
2552                }
2553                ffi::WGPUSType_WGPUSType_RenderPassRenderAreaRect => {
2554                    SType::RenderPassRenderAreaRect
2555                }
2556                ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkDedicatedAllocationDescriptor => {
2557                    SType::SharedTextureMemoryVkDedicatedAllocationDescriptor
2558                }
2559                ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferDescriptor => {
2560                    SType::SharedTextureMemoryAHardwareBufferDescriptor
2561                }
2562                ffi::WGPUSType_WGPUSType_SharedTextureMemoryDmaBufDescriptor => {
2563                    SType::SharedTextureMemoryDmaBufDescriptor
2564                }
2565                ffi::WGPUSType_WGPUSType_SharedTextureMemoryOpaqueFDDescriptor => {
2566                    SType::SharedTextureMemoryOpaqueFDDescriptor
2567                }
2568                ffi::WGPUSType_WGPUSType_SharedTextureMemoryZirconHandleDescriptor => {
2569                    SType::SharedTextureMemoryZirconHandleDescriptor
2570                }
2571                ffi::WGPUSType_WGPUSType_SharedTextureMemoryDXGISharedHandleDescriptor => {
2572                    SType::SharedTextureMemoryDXGISharedHandleDescriptor
2573                }
2574                ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11Texture2DDescriptor => {
2575                    SType::SharedTextureMemoryD3D11Texture2DDescriptor
2576                }
2577                ffi::WGPUSType_WGPUSType_SharedTextureMemoryIOSurfaceDescriptor => {
2578                    SType::SharedTextureMemoryIOSurfaceDescriptor
2579                }
2580                ffi::WGPUSType_WGPUSType_SharedTextureMemoryEGLImageDescriptor => {
2581                    SType::SharedTextureMemoryEGLImageDescriptor
2582                }
2583                ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedBeginState => {
2584                    SType::SharedTextureMemoryInitializedBeginState
2585                }
2586                ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedEndState => {
2587                    SType::SharedTextureMemoryInitializedEndState
2588                }
2589                ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutBeginState => {
2590                    SType::SharedTextureMemoryVkImageLayoutBeginState
2591                }
2592                ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutEndState => {
2593                    SType::SharedTextureMemoryVkImageLayoutEndState
2594                }
2595                ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3DSwapchainBeginState => {
2596                    SType::SharedTextureMemoryD3DSwapchainBeginState
2597                }
2598                ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDDescriptor => {
2599                    SType::SharedFenceVkSemaphoreOpaqueFDDescriptor
2600                }
2601                ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDExportInfo => {
2602                    SType::SharedFenceVkSemaphoreOpaqueFDExportInfo
2603                }
2604                ffi::WGPUSType_WGPUSType_SharedFenceSyncFDDescriptor => {
2605                    SType::SharedFenceSyncFDDescriptor
2606                }
2607                ffi::WGPUSType_WGPUSType_SharedFenceSyncFDExportInfo => {
2608                    SType::SharedFenceSyncFDExportInfo
2609                }
2610                ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleDescriptor => {
2611                    SType::SharedFenceVkSemaphoreZirconHandleDescriptor
2612                }
2613                ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleExportInfo => {
2614                    SType::SharedFenceVkSemaphoreZirconHandleExportInfo
2615                }
2616                ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleDescriptor => {
2617                    SType::SharedFenceDXGISharedHandleDescriptor
2618                }
2619                ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleExportInfo => {
2620                    SType::SharedFenceDXGISharedHandleExportInfo
2621                }
2622                ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventDescriptor => {
2623                    SType::SharedFenceMTLSharedEventDescriptor
2624                }
2625                ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventExportInfo => {
2626                    SType::SharedFenceMTLSharedEventExportInfo
2627                }
2628                ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor => {
2629                    SType::SharedBufferMemoryD3D12ResourceDescriptor
2630                }
2631                ffi::WGPUSType_WGPUSType_StaticSamplerBindingLayout => {
2632                    SType::StaticSamplerBindingLayout
2633                }
2634                ffi::WGPUSType_WGPUSType_YCbCrVkDescriptor => SType::YCbCrVkDescriptor,
2635                ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferProperties => {
2636                    SType::SharedTextureMemoryAHardwareBufferProperties
2637                }
2638                ffi::WGPUSType_WGPUSType_AHardwareBufferProperties => {
2639                    SType::AHardwareBufferProperties
2640                }
2641                ffi::WGPUSType_WGPUSType_DawnTexelCopyBufferRowAlignmentLimits => {
2642                    SType::DawnTexelCopyBufferRowAlignmentLimits
2643                }
2644                ffi::WGPUSType_WGPUSType_AdapterPropertiesSubgroupMatrixConfigs => {
2645                    SType::AdapterPropertiesSubgroupMatrixConfigs
2646                }
2647                ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncDescriptor => {
2648                    SType::SharedFenceEGLSyncDescriptor
2649                }
2650                ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncExportInfo => {
2651                    SType::SharedFenceEGLSyncExportInfo
2652                }
2653                ffi::WGPUSType_WGPUSType_DawnInjectedInvalidSType => {
2654                    SType::DawnInjectedInvalidSType
2655                }
2656                ffi::WGPUSType_WGPUSType_DawnCompilationMessageUtf16 => {
2657                    SType::DawnCompilationMessageUtf16
2658                }
2659                ffi::WGPUSType_WGPUSType_DawnFakeBufferOOMForTesting => {
2660                    SType::DawnFakeBufferOOMForTesting
2661                }
2662                ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsWinUISwapChainPanel => {
2663                    SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel
2664                }
2665                ffi::WGPUSType_WGPUSType_DawnDeviceAllocatorControl => {
2666                    SType::DawnDeviceAllocatorControl
2667                }
2668                ffi::WGPUSType_WGPUSType_DawnHostMappedPointerLimits => {
2669                    SType::DawnHostMappedPointerLimits
2670                }
2671                ffi::WGPUSType_WGPUSType_RenderPassDescriptorResolveRect => {
2672                    SType::RenderPassDescriptorResolveRect
2673                }
2674                ffi::WGPUSType_WGPUSType_RequestAdapterWebGPUBackendOptions => {
2675                    SType::RequestAdapterWebGPUBackendOptions
2676                }
2677                ffi::WGPUSType_WGPUSType_DawnFakeDeviceInitializeErrorForTesting => {
2678                    SType::DawnFakeDeviceInitializeErrorForTesting
2679                }
2680                ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11BeginState => {
2681                    SType::SharedTextureMemoryD3D11BeginState
2682                }
2683                ffi::WGPUSType_WGPUSType_DawnConsumeAdapterDescriptor => {
2684                    SType::DawnConsumeAdapterDescriptor
2685                }
2686                ffi::WGPUSType_WGPUSType_TexelBufferBindingEntry => {
2687                    SType::TexelBufferBindingEntry
2688                }
2689                ffi::WGPUSType_WGPUSType_TexelBufferBindingLayout => {
2690                    SType::TexelBufferBindingLayout
2691                }
2692                ffi::WGPUSType_WGPUSType_SharedTextureMemoryMetalEndAccessState => {
2693                    SType::SharedTextureMemoryMetalEndAccessState
2694                }
2695                ffi::WGPUSType_WGPUSType_AdapterPropertiesWGPU => {
2696                    SType::AdapterPropertiesWGPU
2697                }
2698                ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor => {
2699                    SType::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor
2700                }
2701                ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D12ResourceDescriptor => {
2702                    SType::SharedTextureMemoryD3D12ResourceDescriptor
2703                }
2704                ffi::WGPUSType_WGPUSType_RequestAdapterOptionsAngleVirtualizationGroup => {
2705                    SType::RequestAdapterOptionsAngleVirtualizationGroup
2706                }
2707                ffi::WGPUSType_WGPUSType_PipelineLayoutResourceTable => {
2708                    SType::PipelineLayoutResourceTable
2709                }
2710                ffi::WGPUSType_WGPUSType_AdapterPropertiesExplicitComputeSubgroupSizeConfigs => {
2711                    SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs
2712                }
2713                _ => SType::ShaderSourceSPIRV,
2714            }
2715        }
2716    }
2717    impl From<SType> for ffi::WGPUSType {
2718        fn from(value: SType) -> Self {
2719            match value {
2720                SType::ShaderSourceSPIRV => ffi::WGPUSType_WGPUSType_ShaderSourceSPIRV,
2721                SType::ShaderSourceWGSL => ffi::WGPUSType_WGPUSType_ShaderSourceWGSL,
2722                SType::RenderPassMaxDrawCount => {
2723                    ffi::WGPUSType_WGPUSType_RenderPassMaxDrawCount
2724                }
2725                SType::SurfaceSourceMetalLayer => {
2726                    ffi::WGPUSType_WGPUSType_SurfaceSourceMetalLayer
2727                }
2728                SType::SurfaceSourceWindowsHWND => {
2729                    ffi::WGPUSType_WGPUSType_SurfaceSourceWindowsHWND
2730                }
2731                SType::SurfaceSourceXlibWindow => {
2732                    ffi::WGPUSType_WGPUSType_SurfaceSourceXlibWindow
2733                }
2734                SType::SurfaceSourceWaylandSurface => {
2735                    ffi::WGPUSType_WGPUSType_SurfaceSourceWaylandSurface
2736                }
2737                SType::SurfaceSourceAndroidNativeWindow => {
2738                    ffi::WGPUSType_WGPUSType_SurfaceSourceAndroidNativeWindow
2739                }
2740                SType::SurfaceSourceXCBWindow => {
2741                    ffi::WGPUSType_WGPUSType_SurfaceSourceXCBWindow
2742                }
2743                SType::SurfaceColorManagement => {
2744                    ffi::WGPUSType_WGPUSType_SurfaceColorManagement
2745                }
2746                SType::RequestAdapterWebXROptions => {
2747                    ffi::WGPUSType_WGPUSType_RequestAdapterWebXROptions
2748                }
2749                SType::TextureComponentSwizzleDescriptor => {
2750                    ffi::WGPUSType_WGPUSType_TextureComponentSwizzleDescriptor
2751                }
2752                SType::CompatibilityModeLimits => {
2753                    ffi::WGPUSType_WGPUSType_CompatibilityModeLimits
2754                }
2755                SType::TextureBindingViewDimensionDescriptor => {
2756                    ffi::WGPUSType_WGPUSType_TextureBindingViewDimensionDescriptor
2757                }
2758                SType::EmscriptenSurfaceSourceCanvasHTMLSelector => {
2759                    ffi::WGPUSType_WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector
2760                }
2761                SType::SurfaceDescriptorFromWindowsCoreWindow => {
2762                    ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsCoreWindow
2763                }
2764                SType::ExternalTextureBindingEntry => {
2765                    ffi::WGPUSType_WGPUSType_ExternalTextureBindingEntry
2766                }
2767                SType::ExternalTextureBindingLayout => {
2768                    ffi::WGPUSType_WGPUSType_ExternalTextureBindingLayout
2769                }
2770                SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel => {
2771                    ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsUWPSwapChainPanel
2772                }
2773                SType::DawnTextureInternalUsageDescriptor => {
2774                    ffi::WGPUSType_WGPUSType_DawnTextureInternalUsageDescriptor
2775                }
2776                SType::DawnEncoderInternalUsageDescriptor => {
2777                    ffi::WGPUSType_WGPUSType_DawnEncoderInternalUsageDescriptor
2778                }
2779                SType::DawnInstanceDescriptor => {
2780                    ffi::WGPUSType_WGPUSType_DawnInstanceDescriptor
2781                }
2782                SType::DawnCacheDeviceDescriptor => {
2783                    ffi::WGPUSType_WGPUSType_DawnCacheDeviceDescriptor
2784                }
2785                SType::DawnAdapterPropertiesPowerPreference => {
2786                    ffi::WGPUSType_WGPUSType_DawnAdapterPropertiesPowerPreference
2787                }
2788                SType::DawnBufferDescriptorErrorInfoFromWireClient => {
2789                    ffi::WGPUSType_WGPUSType_DawnBufferDescriptorErrorInfoFromWireClient
2790                }
2791                SType::DawnTogglesDescriptor => {
2792                    ffi::WGPUSType_WGPUSType_DawnTogglesDescriptor
2793                }
2794                SType::DawnShaderModuleSPIRVOptionsDescriptor => {
2795                    ffi::WGPUSType_WGPUSType_DawnShaderModuleSPIRVOptionsDescriptor
2796                }
2797                SType::RequestAdapterOptionsLuid => {
2798                    ffi::WGPUSType_WGPUSType_RequestAdapterOptionsLUID
2799                }
2800                SType::RequestAdapterOptionsGetGlProc => {
2801                    ffi::WGPUSType_WGPUSType_RequestAdapterOptionsGetGLProc
2802                }
2803                SType::RequestAdapterOptionsD3D11Device => {
2804                    ffi::WGPUSType_WGPUSType_RequestAdapterOptionsD3D11Device
2805                }
2806                SType::DawnRenderPassSampleCount => {
2807                    ffi::WGPUSType_WGPUSType_DawnRenderPassSampleCount
2808                }
2809                SType::RenderPassPixelLocalStorage => {
2810                    ffi::WGPUSType_WGPUSType_RenderPassPixelLocalStorage
2811                }
2812                SType::PipelineLayoutPixelLocalStorage => {
2813                    ffi::WGPUSType_WGPUSType_PipelineLayoutPixelLocalStorage
2814                }
2815                SType::BufferHostMappedPointer => {
2816                    ffi::WGPUSType_WGPUSType_BufferHostMappedPointer
2817                }
2818                SType::AdapterPropertiesMemoryHeaps => {
2819                    ffi::WGPUSType_WGPUSType_AdapterPropertiesMemoryHeaps
2820                }
2821                SType::AdapterPropertiesD3D => {
2822                    ffi::WGPUSType_WGPUSType_AdapterPropertiesD3D
2823                }
2824                SType::AdapterPropertiesVk => {
2825                    ffi::WGPUSType_WGPUSType_AdapterPropertiesVk
2826                }
2827                SType::DawnWireWGSLControl => {
2828                    ffi::WGPUSType_WGPUSType_DawnWireWGSLControl
2829                }
2830                SType::DawnWGSLBlocklist => ffi::WGPUSType_WGPUSType_DawnWGSLBlocklist,
2831                SType::DawnDrmFormatCapabilities => {
2832                    ffi::WGPUSType_WGPUSType_DawnDrmFormatCapabilities
2833                }
2834                SType::ShaderModuleCompilationOptions => {
2835                    ffi::WGPUSType_WGPUSType_ShaderModuleCompilationOptions
2836                }
2837                SType::ColorTargetStateExpandResolveTextureDawn => {
2838                    ffi::WGPUSType_WGPUSType_ColorTargetStateExpandResolveTextureDawn
2839                }
2840                SType::RenderPassRenderAreaRect => {
2841                    ffi::WGPUSType_WGPUSType_RenderPassRenderAreaRect
2842                }
2843                SType::SharedTextureMemoryVkDedicatedAllocationDescriptor => {
2844                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkDedicatedAllocationDescriptor
2845                }
2846                SType::SharedTextureMemoryAHardwareBufferDescriptor => {
2847                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferDescriptor
2848                }
2849                SType::SharedTextureMemoryDmaBufDescriptor => {
2850                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryDmaBufDescriptor
2851                }
2852                SType::SharedTextureMemoryOpaqueFDDescriptor => {
2853                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryOpaqueFDDescriptor
2854                }
2855                SType::SharedTextureMemoryZirconHandleDescriptor => {
2856                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryZirconHandleDescriptor
2857                }
2858                SType::SharedTextureMemoryDXGISharedHandleDescriptor => {
2859                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryDXGISharedHandleDescriptor
2860                }
2861                SType::SharedTextureMemoryD3D11Texture2DDescriptor => {
2862                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11Texture2DDescriptor
2863                }
2864                SType::SharedTextureMemoryIOSurfaceDescriptor => {
2865                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryIOSurfaceDescriptor
2866                }
2867                SType::SharedTextureMemoryEGLImageDescriptor => {
2868                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryEGLImageDescriptor
2869                }
2870                SType::SharedTextureMemoryInitializedBeginState => {
2871                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedBeginState
2872                }
2873                SType::SharedTextureMemoryInitializedEndState => {
2874                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedEndState
2875                }
2876                SType::SharedTextureMemoryVkImageLayoutBeginState => {
2877                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutBeginState
2878                }
2879                SType::SharedTextureMemoryVkImageLayoutEndState => {
2880                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutEndState
2881                }
2882                SType::SharedTextureMemoryD3DSwapchainBeginState => {
2883                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3DSwapchainBeginState
2884                }
2885                SType::SharedFenceVkSemaphoreOpaqueFDDescriptor => {
2886                    ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDDescriptor
2887                }
2888                SType::SharedFenceVkSemaphoreOpaqueFDExportInfo => {
2889                    ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDExportInfo
2890                }
2891                SType::SharedFenceSyncFDDescriptor => {
2892                    ffi::WGPUSType_WGPUSType_SharedFenceSyncFDDescriptor
2893                }
2894                SType::SharedFenceSyncFDExportInfo => {
2895                    ffi::WGPUSType_WGPUSType_SharedFenceSyncFDExportInfo
2896                }
2897                SType::SharedFenceVkSemaphoreZirconHandleDescriptor => {
2898                    ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleDescriptor
2899                }
2900                SType::SharedFenceVkSemaphoreZirconHandleExportInfo => {
2901                    ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleExportInfo
2902                }
2903                SType::SharedFenceDXGISharedHandleDescriptor => {
2904                    ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleDescriptor
2905                }
2906                SType::SharedFenceDXGISharedHandleExportInfo => {
2907                    ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleExportInfo
2908                }
2909                SType::SharedFenceMTLSharedEventDescriptor => {
2910                    ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventDescriptor
2911                }
2912                SType::SharedFenceMTLSharedEventExportInfo => {
2913                    ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventExportInfo
2914                }
2915                SType::SharedBufferMemoryD3D12ResourceDescriptor => {
2916                    ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor
2917                }
2918                SType::StaticSamplerBindingLayout => {
2919                    ffi::WGPUSType_WGPUSType_StaticSamplerBindingLayout
2920                }
2921                SType::YCbCrVkDescriptor => ffi::WGPUSType_WGPUSType_YCbCrVkDescriptor,
2922                SType::SharedTextureMemoryAHardwareBufferProperties => {
2923                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferProperties
2924                }
2925                SType::AHardwareBufferProperties => {
2926                    ffi::WGPUSType_WGPUSType_AHardwareBufferProperties
2927                }
2928                SType::DawnTexelCopyBufferRowAlignmentLimits => {
2929                    ffi::WGPUSType_WGPUSType_DawnTexelCopyBufferRowAlignmentLimits
2930                }
2931                SType::AdapterPropertiesSubgroupMatrixConfigs => {
2932                    ffi::WGPUSType_WGPUSType_AdapterPropertiesSubgroupMatrixConfigs
2933                }
2934                SType::SharedFenceEGLSyncDescriptor => {
2935                    ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncDescriptor
2936                }
2937                SType::SharedFenceEGLSyncExportInfo => {
2938                    ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncExportInfo
2939                }
2940                SType::DawnInjectedInvalidSType => {
2941                    ffi::WGPUSType_WGPUSType_DawnInjectedInvalidSType
2942                }
2943                SType::DawnCompilationMessageUtf16 => {
2944                    ffi::WGPUSType_WGPUSType_DawnCompilationMessageUtf16
2945                }
2946                SType::DawnFakeBufferOOMForTesting => {
2947                    ffi::WGPUSType_WGPUSType_DawnFakeBufferOOMForTesting
2948                }
2949                SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel => {
2950                    ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsWinUISwapChainPanel
2951                }
2952                SType::DawnDeviceAllocatorControl => {
2953                    ffi::WGPUSType_WGPUSType_DawnDeviceAllocatorControl
2954                }
2955                SType::DawnHostMappedPointerLimits => {
2956                    ffi::WGPUSType_WGPUSType_DawnHostMappedPointerLimits
2957                }
2958                SType::RenderPassDescriptorResolveRect => {
2959                    ffi::WGPUSType_WGPUSType_RenderPassDescriptorResolveRect
2960                }
2961                SType::RequestAdapterWebGPUBackendOptions => {
2962                    ffi::WGPUSType_WGPUSType_RequestAdapterWebGPUBackendOptions
2963                }
2964                SType::DawnFakeDeviceInitializeErrorForTesting => {
2965                    ffi::WGPUSType_WGPUSType_DawnFakeDeviceInitializeErrorForTesting
2966                }
2967                SType::SharedTextureMemoryD3D11BeginState => {
2968                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11BeginState
2969                }
2970                SType::DawnConsumeAdapterDescriptor => {
2971                    ffi::WGPUSType_WGPUSType_DawnConsumeAdapterDescriptor
2972                }
2973                SType::TexelBufferBindingEntry => {
2974                    ffi::WGPUSType_WGPUSType_TexelBufferBindingEntry
2975                }
2976                SType::TexelBufferBindingLayout => {
2977                    ffi::WGPUSType_WGPUSType_TexelBufferBindingLayout
2978                }
2979                SType::SharedTextureMemoryMetalEndAccessState => {
2980                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryMetalEndAccessState
2981                }
2982                SType::AdapterPropertiesWGPU => {
2983                    ffi::WGPUSType_WGPUSType_AdapterPropertiesWGPU
2984                }
2985                SType::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor => {
2986                    ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor
2987                }
2988                SType::SharedTextureMemoryD3D12ResourceDescriptor => {
2989                    ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D12ResourceDescriptor
2990                }
2991                SType::RequestAdapterOptionsAngleVirtualizationGroup => {
2992                    ffi::WGPUSType_WGPUSType_RequestAdapterOptionsAngleVirtualizationGroup
2993                }
2994                SType::PipelineLayoutResourceTable => {
2995                    ffi::WGPUSType_WGPUSType_PipelineLayoutResourceTable
2996                }
2997                SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs => {
2998                    ffi::WGPUSType_WGPUSType_AdapterPropertiesExplicitComputeSubgroupSizeConfigs
2999                }
3000            }
3001        }
3002    }
3003    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3004    pub enum SamplerBindingType {
3005        BindingNotUsed,
3006        Undefined,
3007        Filtering,
3008        NonFiltering,
3009        Comparison,
3010    }
3011    impl From<ffi::WGPUSamplerBindingType> for SamplerBindingType {
3012        fn from(value: ffi::WGPUSamplerBindingType) -> Self {
3013            match value {
3014                ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_BindingNotUsed => {
3015                    SamplerBindingType::BindingNotUsed
3016                }
3017                ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Undefined => {
3018                    SamplerBindingType::Undefined
3019                }
3020                ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Filtering => {
3021                    SamplerBindingType::Filtering
3022                }
3023                ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_NonFiltering => {
3024                    SamplerBindingType::NonFiltering
3025                }
3026                ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Comparison => {
3027                    SamplerBindingType::Comparison
3028                }
3029                _ => SamplerBindingType::BindingNotUsed,
3030            }
3031        }
3032    }
3033    impl From<SamplerBindingType> for ffi::WGPUSamplerBindingType {
3034        fn from(value: SamplerBindingType) -> Self {
3035            match value {
3036                SamplerBindingType::BindingNotUsed => {
3037                    ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_BindingNotUsed
3038                }
3039                SamplerBindingType::Undefined => {
3040                    ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Undefined
3041                }
3042                SamplerBindingType::Filtering => {
3043                    ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Filtering
3044                }
3045                SamplerBindingType::NonFiltering => {
3046                    ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_NonFiltering
3047                }
3048                SamplerBindingType::Comparison => {
3049                    ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Comparison
3050                }
3051            }
3052        }
3053    }
3054    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3055    pub enum SharedFenceType {
3056        VkSemaphoreOpaqueFD,
3057        SyncFD,
3058        VkSemaphoreZirconHandle,
3059        DXGISharedHandle,
3060        MTLSharedEvent,
3061        EGLSync,
3062    }
3063    impl From<ffi::WGPUSharedFenceType> for SharedFenceType {
3064        fn from(value: ffi::WGPUSharedFenceType) -> Self {
3065            match value {
3066                ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreOpaqueFD => {
3067                    SharedFenceType::VkSemaphoreOpaqueFD
3068                }
3069                ffi::WGPUSharedFenceType_WGPUSharedFenceType_SyncFD => {
3070                    SharedFenceType::SyncFD
3071                }
3072                ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreZirconHandle => {
3073                    SharedFenceType::VkSemaphoreZirconHandle
3074                }
3075                ffi::WGPUSharedFenceType_WGPUSharedFenceType_DXGISharedHandle => {
3076                    SharedFenceType::DXGISharedHandle
3077                }
3078                ffi::WGPUSharedFenceType_WGPUSharedFenceType_MTLSharedEvent => {
3079                    SharedFenceType::MTLSharedEvent
3080                }
3081                ffi::WGPUSharedFenceType_WGPUSharedFenceType_EGLSync => {
3082                    SharedFenceType::EGLSync
3083                }
3084                _ => SharedFenceType::VkSemaphoreOpaqueFD,
3085            }
3086        }
3087    }
3088    impl From<SharedFenceType> for ffi::WGPUSharedFenceType {
3089        fn from(value: SharedFenceType) -> Self {
3090            match value {
3091                SharedFenceType::VkSemaphoreOpaqueFD => {
3092                    ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreOpaqueFD
3093                }
3094                SharedFenceType::SyncFD => {
3095                    ffi::WGPUSharedFenceType_WGPUSharedFenceType_SyncFD
3096                }
3097                SharedFenceType::VkSemaphoreZirconHandle => {
3098                    ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreZirconHandle
3099                }
3100                SharedFenceType::DXGISharedHandle => {
3101                    ffi::WGPUSharedFenceType_WGPUSharedFenceType_DXGISharedHandle
3102                }
3103                SharedFenceType::MTLSharedEvent => {
3104                    ffi::WGPUSharedFenceType_WGPUSharedFenceType_MTLSharedEvent
3105                }
3106                SharedFenceType::EGLSync => {
3107                    ffi::WGPUSharedFenceType_WGPUSharedFenceType_EGLSync
3108                }
3109            }
3110        }
3111    }
3112    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3113    pub enum Status {
3114        Success,
3115        Error,
3116    }
3117    impl From<ffi::WGPUStatus> for Status {
3118        fn from(value: ffi::WGPUStatus) -> Self {
3119            match value {
3120                ffi::WGPUStatus_WGPUStatus_Success => Status::Success,
3121                ffi::WGPUStatus_WGPUStatus_Error => Status::Error,
3122                _ => Status::Success,
3123            }
3124        }
3125    }
3126    impl From<Status> for ffi::WGPUStatus {
3127        fn from(value: Status) -> Self {
3128            match value {
3129                Status::Success => ffi::WGPUStatus_WGPUStatus_Success,
3130                Status::Error => ffi::WGPUStatus_WGPUStatus_Error,
3131            }
3132        }
3133    }
3134    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3135    pub enum StencilOperation {
3136        Undefined,
3137        Keep,
3138        Zero,
3139        Replace,
3140        Invert,
3141        IncrementClamp,
3142        DecrementClamp,
3143        IncrementWrap,
3144        DecrementWrap,
3145    }
3146    impl From<ffi::WGPUStencilOperation> for StencilOperation {
3147        fn from(value: ffi::WGPUStencilOperation) -> Self {
3148            match value {
3149                ffi::WGPUStencilOperation_WGPUStencilOperation_Undefined => {
3150                    StencilOperation::Undefined
3151                }
3152                ffi::WGPUStencilOperation_WGPUStencilOperation_Keep => {
3153                    StencilOperation::Keep
3154                }
3155                ffi::WGPUStencilOperation_WGPUStencilOperation_Zero => {
3156                    StencilOperation::Zero
3157                }
3158                ffi::WGPUStencilOperation_WGPUStencilOperation_Replace => {
3159                    StencilOperation::Replace
3160                }
3161                ffi::WGPUStencilOperation_WGPUStencilOperation_Invert => {
3162                    StencilOperation::Invert
3163                }
3164                ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementClamp => {
3165                    StencilOperation::IncrementClamp
3166                }
3167                ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementClamp => {
3168                    StencilOperation::DecrementClamp
3169                }
3170                ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementWrap => {
3171                    StencilOperation::IncrementWrap
3172                }
3173                ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementWrap => {
3174                    StencilOperation::DecrementWrap
3175                }
3176                _ => StencilOperation::Undefined,
3177            }
3178        }
3179    }
3180    impl From<StencilOperation> for ffi::WGPUStencilOperation {
3181        fn from(value: StencilOperation) -> Self {
3182            match value {
3183                StencilOperation::Undefined => {
3184                    ffi::WGPUStencilOperation_WGPUStencilOperation_Undefined
3185                }
3186                StencilOperation::Keep => {
3187                    ffi::WGPUStencilOperation_WGPUStencilOperation_Keep
3188                }
3189                StencilOperation::Zero => {
3190                    ffi::WGPUStencilOperation_WGPUStencilOperation_Zero
3191                }
3192                StencilOperation::Replace => {
3193                    ffi::WGPUStencilOperation_WGPUStencilOperation_Replace
3194                }
3195                StencilOperation::Invert => {
3196                    ffi::WGPUStencilOperation_WGPUStencilOperation_Invert
3197                }
3198                StencilOperation::IncrementClamp => {
3199                    ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementClamp
3200                }
3201                StencilOperation::DecrementClamp => {
3202                    ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementClamp
3203                }
3204                StencilOperation::IncrementWrap => {
3205                    ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementWrap
3206                }
3207                StencilOperation::DecrementWrap => {
3208                    ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementWrap
3209                }
3210            }
3211        }
3212    }
3213    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3214    pub enum StorageTextureAccess {
3215        BindingNotUsed,
3216        Undefined,
3217        WriteOnly,
3218        ReadOnly,
3219        ReadWrite,
3220    }
3221    impl From<ffi::WGPUStorageTextureAccess> for StorageTextureAccess {
3222        fn from(value: ffi::WGPUStorageTextureAccess) -> Self {
3223            match value {
3224                ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_BindingNotUsed => {
3225                    StorageTextureAccess::BindingNotUsed
3226                }
3227                ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_Undefined => {
3228                    StorageTextureAccess::Undefined
3229                }
3230                ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_WriteOnly => {
3231                    StorageTextureAccess::WriteOnly
3232                }
3233                ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadOnly => {
3234                    StorageTextureAccess::ReadOnly
3235                }
3236                ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadWrite => {
3237                    StorageTextureAccess::ReadWrite
3238                }
3239                _ => StorageTextureAccess::BindingNotUsed,
3240            }
3241        }
3242    }
3243    impl From<StorageTextureAccess> for ffi::WGPUStorageTextureAccess {
3244        fn from(value: StorageTextureAccess) -> Self {
3245            match value {
3246                StorageTextureAccess::BindingNotUsed => {
3247                    ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_BindingNotUsed
3248                }
3249                StorageTextureAccess::Undefined => {
3250                    ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_Undefined
3251                }
3252                StorageTextureAccess::WriteOnly => {
3253                    ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_WriteOnly
3254                }
3255                StorageTextureAccess::ReadOnly => {
3256                    ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadOnly
3257                }
3258                StorageTextureAccess::ReadWrite => {
3259                    ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadWrite
3260                }
3261            }
3262        }
3263    }
3264    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3265    pub enum StoreOp {
3266        Undefined,
3267        Store,
3268        Discard,
3269    }
3270    impl From<ffi::WGPUStoreOp> for StoreOp {
3271        fn from(value: ffi::WGPUStoreOp) -> Self {
3272            match value {
3273                ffi::WGPUStoreOp_WGPUStoreOp_Undefined => StoreOp::Undefined,
3274                ffi::WGPUStoreOp_WGPUStoreOp_Store => StoreOp::Store,
3275                ffi::WGPUStoreOp_WGPUStoreOp_Discard => StoreOp::Discard,
3276                _ => StoreOp::Undefined,
3277            }
3278        }
3279    }
3280    impl From<StoreOp> for ffi::WGPUStoreOp {
3281        fn from(value: StoreOp) -> Self {
3282            match value {
3283                StoreOp::Undefined => ffi::WGPUStoreOp_WGPUStoreOp_Undefined,
3284                StoreOp::Store => ffi::WGPUStoreOp_WGPUStoreOp_Store,
3285                StoreOp::Discard => ffi::WGPUStoreOp_WGPUStoreOp_Discard,
3286            }
3287        }
3288    }
3289    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3290    pub enum SubgroupMatrixComponentType {
3291        F32,
3292        F16,
3293        U32,
3294        I32,
3295        U8,
3296        I8,
3297    }
3298    impl From<ffi::WGPUSubgroupMatrixComponentType> for SubgroupMatrixComponentType {
3299        fn from(value: ffi::WGPUSubgroupMatrixComponentType) -> Self {
3300            match value {
3301                ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F32 => {
3302                    SubgroupMatrixComponentType::F32
3303                }
3304                ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F16 => {
3305                    SubgroupMatrixComponentType::F16
3306                }
3307                ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U32 => {
3308                    SubgroupMatrixComponentType::U32
3309                }
3310                ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I32 => {
3311                    SubgroupMatrixComponentType::I32
3312                }
3313                ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U8 => {
3314                    SubgroupMatrixComponentType::U8
3315                }
3316                ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I8 => {
3317                    SubgroupMatrixComponentType::I8
3318                }
3319                _ => SubgroupMatrixComponentType::F32,
3320            }
3321        }
3322    }
3323    impl From<SubgroupMatrixComponentType> for ffi::WGPUSubgroupMatrixComponentType {
3324        fn from(value: SubgroupMatrixComponentType) -> Self {
3325            match value {
3326                SubgroupMatrixComponentType::F32 => {
3327                    ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F32
3328                }
3329                SubgroupMatrixComponentType::F16 => {
3330                    ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F16
3331                }
3332                SubgroupMatrixComponentType::U32 => {
3333                    ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U32
3334                }
3335                SubgroupMatrixComponentType::I32 => {
3336                    ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I32
3337                }
3338                SubgroupMatrixComponentType::U8 => {
3339                    ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U8
3340                }
3341                SubgroupMatrixComponentType::I8 => {
3342                    ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I8
3343                }
3344            }
3345        }
3346    }
3347    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3348    pub enum SurfaceGetCurrentTextureStatus {
3349        SuccessOptimal,
3350        SuccessSuboptimal,
3351        Timeout,
3352        Outdated,
3353        Lost,
3354        Error,
3355    }
3356    impl From<ffi::WGPUSurfaceGetCurrentTextureStatus>
3357    for SurfaceGetCurrentTextureStatus {
3358        fn from(value: ffi::WGPUSurfaceGetCurrentTextureStatus) -> Self {
3359            match value {
3360                ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal => {
3361                    SurfaceGetCurrentTextureStatus::SuccessOptimal
3362                }
3363                ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal => {
3364                    SurfaceGetCurrentTextureStatus::SuccessSuboptimal
3365                }
3366                ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Timeout => {
3367                    SurfaceGetCurrentTextureStatus::Timeout
3368                }
3369                ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Outdated => {
3370                    SurfaceGetCurrentTextureStatus::Outdated
3371                }
3372                ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Lost => {
3373                    SurfaceGetCurrentTextureStatus::Lost
3374                }
3375                ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Error => {
3376                    SurfaceGetCurrentTextureStatus::Error
3377                }
3378                _ => SurfaceGetCurrentTextureStatus::SuccessOptimal,
3379            }
3380        }
3381    }
3382    impl From<SurfaceGetCurrentTextureStatus>
3383    for ffi::WGPUSurfaceGetCurrentTextureStatus {
3384        fn from(value: SurfaceGetCurrentTextureStatus) -> Self {
3385            match value {
3386                SurfaceGetCurrentTextureStatus::SuccessOptimal => {
3387                    ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal
3388                }
3389                SurfaceGetCurrentTextureStatus::SuccessSuboptimal => {
3390                    ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal
3391                }
3392                SurfaceGetCurrentTextureStatus::Timeout => {
3393                    ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Timeout
3394                }
3395                SurfaceGetCurrentTextureStatus::Outdated => {
3396                    ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Outdated
3397                }
3398                SurfaceGetCurrentTextureStatus::Lost => {
3399                    ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Lost
3400                }
3401                SurfaceGetCurrentTextureStatus::Error => {
3402                    ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Error
3403                }
3404            }
3405        }
3406    }
3407    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3408    pub enum TexelBufferAccess {
3409        Undefined,
3410        ReadOnly,
3411        ReadWrite,
3412    }
3413    impl From<ffi::WGPUTexelBufferAccess> for TexelBufferAccess {
3414        fn from(value: ffi::WGPUTexelBufferAccess) -> Self {
3415            match value {
3416                ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_Undefined => {
3417                    TexelBufferAccess::Undefined
3418                }
3419                ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadOnly => {
3420                    TexelBufferAccess::ReadOnly
3421                }
3422                ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadWrite => {
3423                    TexelBufferAccess::ReadWrite
3424                }
3425                _ => TexelBufferAccess::Undefined,
3426            }
3427        }
3428    }
3429    impl From<TexelBufferAccess> for ffi::WGPUTexelBufferAccess {
3430        fn from(value: TexelBufferAccess) -> Self {
3431            match value {
3432                TexelBufferAccess::Undefined => {
3433                    ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_Undefined
3434                }
3435                TexelBufferAccess::ReadOnly => {
3436                    ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadOnly
3437                }
3438                TexelBufferAccess::ReadWrite => {
3439                    ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadWrite
3440                }
3441            }
3442        }
3443    }
3444    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3445    pub enum TextureAspect {
3446        Undefined,
3447        All,
3448        StencilOnly,
3449        DepthOnly,
3450        Plane0Only,
3451        Plane1Only,
3452        Plane2Only,
3453    }
3454    impl From<ffi::WGPUTextureAspect> for TextureAspect {
3455        fn from(value: ffi::WGPUTextureAspect) -> Self {
3456            match value {
3457                ffi::WGPUTextureAspect_WGPUTextureAspect_Undefined => {
3458                    TextureAspect::Undefined
3459                }
3460                ffi::WGPUTextureAspect_WGPUTextureAspect_All => TextureAspect::All,
3461                ffi::WGPUTextureAspect_WGPUTextureAspect_StencilOnly => {
3462                    TextureAspect::StencilOnly
3463                }
3464                ffi::WGPUTextureAspect_WGPUTextureAspect_DepthOnly => {
3465                    TextureAspect::DepthOnly
3466                }
3467                ffi::WGPUTextureAspect_WGPUTextureAspect_Plane0Only => {
3468                    TextureAspect::Plane0Only
3469                }
3470                ffi::WGPUTextureAspect_WGPUTextureAspect_Plane1Only => {
3471                    TextureAspect::Plane1Only
3472                }
3473                ffi::WGPUTextureAspect_WGPUTextureAspect_Plane2Only => {
3474                    TextureAspect::Plane2Only
3475                }
3476                _ => TextureAspect::Undefined,
3477            }
3478        }
3479    }
3480    impl From<TextureAspect> for ffi::WGPUTextureAspect {
3481        fn from(value: TextureAspect) -> Self {
3482            match value {
3483                TextureAspect::Undefined => {
3484                    ffi::WGPUTextureAspect_WGPUTextureAspect_Undefined
3485                }
3486                TextureAspect::All => ffi::WGPUTextureAspect_WGPUTextureAspect_All,
3487                TextureAspect::StencilOnly => {
3488                    ffi::WGPUTextureAspect_WGPUTextureAspect_StencilOnly
3489                }
3490                TextureAspect::DepthOnly => {
3491                    ffi::WGPUTextureAspect_WGPUTextureAspect_DepthOnly
3492                }
3493                TextureAspect::Plane0Only => {
3494                    ffi::WGPUTextureAspect_WGPUTextureAspect_Plane0Only
3495                }
3496                TextureAspect::Plane1Only => {
3497                    ffi::WGPUTextureAspect_WGPUTextureAspect_Plane1Only
3498                }
3499                TextureAspect::Plane2Only => {
3500                    ffi::WGPUTextureAspect_WGPUTextureAspect_Plane2Only
3501                }
3502            }
3503        }
3504    }
3505    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3506    pub enum TextureDimension {
3507        Undefined,
3508        D1,
3509        D2,
3510        D3,
3511    }
3512    impl From<ffi::WGPUTextureDimension> for TextureDimension {
3513        fn from(value: ffi::WGPUTextureDimension) -> Self {
3514            match value {
3515                ffi::WGPUTextureDimension_WGPUTextureDimension_Undefined => {
3516                    TextureDimension::Undefined
3517                }
3518                ffi::WGPUTextureDimension_WGPUTextureDimension_1D => TextureDimension::D1,
3519                ffi::WGPUTextureDimension_WGPUTextureDimension_2D => TextureDimension::D2,
3520                ffi::WGPUTextureDimension_WGPUTextureDimension_3D => TextureDimension::D3,
3521                _ => TextureDimension::Undefined,
3522            }
3523        }
3524    }
3525    impl From<TextureDimension> for ffi::WGPUTextureDimension {
3526        fn from(value: TextureDimension) -> Self {
3527            match value {
3528                TextureDimension::Undefined => {
3529                    ffi::WGPUTextureDimension_WGPUTextureDimension_Undefined
3530                }
3531                TextureDimension::D1 => ffi::WGPUTextureDimension_WGPUTextureDimension_1D,
3532                TextureDimension::D2 => ffi::WGPUTextureDimension_WGPUTextureDimension_2D,
3533                TextureDimension::D3 => ffi::WGPUTextureDimension_WGPUTextureDimension_3D,
3534            }
3535        }
3536    }
3537    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3538    pub enum TextureFormat {
3539        Undefined,
3540        R8Unorm,
3541        R8Snorm,
3542        R8Uint,
3543        R8Sint,
3544        R16Unorm,
3545        R16Snorm,
3546        R16Uint,
3547        R16Sint,
3548        R16Float,
3549        Rg8Unorm,
3550        Rg8Snorm,
3551        Rg8Uint,
3552        Rg8Sint,
3553        R32Float,
3554        R32Uint,
3555        R32Sint,
3556        Rg16Unorm,
3557        Rg16Snorm,
3558        Rg16Uint,
3559        Rg16Sint,
3560        Rg16Float,
3561        Rgba8Unorm,
3562        Rgba8UnormSrgb,
3563        Rgba8Snorm,
3564        Rgba8Uint,
3565        Rgba8Sint,
3566        Bgra8Unorm,
3567        Bgra8UnormSrgb,
3568        Rgb10A2Uint,
3569        Rgb10A2Unorm,
3570        Rg11B10Ufloat,
3571        Rgb9E5Ufloat,
3572        Rg32Float,
3573        Rg32Uint,
3574        Rg32Sint,
3575        Rgba16Unorm,
3576        Rgba16Snorm,
3577        Rgba16Uint,
3578        Rgba16Sint,
3579        Rgba16Float,
3580        Rgba32Float,
3581        Rgba32Uint,
3582        Rgba32Sint,
3583        Stencil8,
3584        Depth16Unorm,
3585        Depth24Plus,
3586        Depth24PlusStencil8,
3587        Depth32Float,
3588        Depth32FloatStencil8,
3589        Bc1RgbaUnorm,
3590        Bc1RgbaUnormSrgb,
3591        Bc2RgbaUnorm,
3592        Bc2RgbaUnormSrgb,
3593        Bc3RgbaUnorm,
3594        Bc3RgbaUnormSrgb,
3595        Bc4RUnorm,
3596        Bc4RSnorm,
3597        Bc5RgUnorm,
3598        Bc5RgSnorm,
3599        Bc6HRgbUfloat,
3600        Bc6HRgbFloat,
3601        Bc7RgbaUnorm,
3602        Bc7RgbaUnormSrgb,
3603        Etc2Rgb8Unorm,
3604        Etc2Rgb8UnormSrgb,
3605        Etc2Rgb8A1Unorm,
3606        Etc2Rgb8A1UnormSrgb,
3607        Etc2Rgba8Unorm,
3608        Etc2Rgba8UnormSrgb,
3609        EacR11Unorm,
3610        EacR11Snorm,
3611        EacRg11Unorm,
3612        EacRg11Snorm,
3613        Astc4X4Unorm,
3614        Astc4X4UnormSrgb,
3615        Astc5X4Unorm,
3616        Astc5X4UnormSrgb,
3617        Astc5X5Unorm,
3618        Astc5X5UnormSrgb,
3619        Astc6X5Unorm,
3620        Astc6X5UnormSrgb,
3621        Astc6X6Unorm,
3622        Astc6X6UnormSrgb,
3623        Astc8X5Unorm,
3624        Astc8X5UnormSrgb,
3625        Astc8X6Unorm,
3626        Astc8X6UnormSrgb,
3627        Astc8X8Unorm,
3628        Astc8X8UnormSrgb,
3629        Astc10X5Unorm,
3630        Astc10X5UnormSrgb,
3631        Astc10X6Unorm,
3632        Astc10X6UnormSrgb,
3633        Astc10X8Unorm,
3634        Astc10X8UnormSrgb,
3635        Astc10X10Unorm,
3636        Astc10X10UnormSrgb,
3637        Astc12X10Unorm,
3638        Astc12X10UnormSrgb,
3639        Astc12X12Unorm,
3640        Astc12X12UnormSrgb,
3641        R8Bg8Biplanar420Unorm,
3642        R10X6Bg10X6Biplanar420Unorm,
3643        R8Bg8A8Triplanar420Unorm,
3644        R8Bg8Biplanar422Unorm,
3645        R8Bg8Biplanar444Unorm,
3646        R10X6Bg10X6Biplanar422Unorm,
3647        R10X6Bg10X6Biplanar444Unorm,
3648        OpaqueYCbCrAndroid,
3649    }
3650    impl From<ffi::WGPUTextureFormat> for TextureFormat {
3651        fn from(value: ffi::WGPUTextureFormat) -> Self {
3652            match value {
3653                ffi::WGPUTextureFormat_WGPUTextureFormat_Undefined => {
3654                    TextureFormat::Undefined
3655                }
3656                ffi::WGPUTextureFormat_WGPUTextureFormat_R8Unorm => {
3657                    TextureFormat::R8Unorm
3658                }
3659                ffi::WGPUTextureFormat_WGPUTextureFormat_R8Snorm => {
3660                    TextureFormat::R8Snorm
3661                }
3662                ffi::WGPUTextureFormat_WGPUTextureFormat_R8Uint => TextureFormat::R8Uint,
3663                ffi::WGPUTextureFormat_WGPUTextureFormat_R8Sint => TextureFormat::R8Sint,
3664                ffi::WGPUTextureFormat_WGPUTextureFormat_R16Unorm => {
3665                    TextureFormat::R16Unorm
3666                }
3667                ffi::WGPUTextureFormat_WGPUTextureFormat_R16Snorm => {
3668                    TextureFormat::R16Snorm
3669                }
3670                ffi::WGPUTextureFormat_WGPUTextureFormat_R16Uint => {
3671                    TextureFormat::R16Uint
3672                }
3673                ffi::WGPUTextureFormat_WGPUTextureFormat_R16Sint => {
3674                    TextureFormat::R16Sint
3675                }
3676                ffi::WGPUTextureFormat_WGPUTextureFormat_R16Float => {
3677                    TextureFormat::R16Float
3678                }
3679                ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Unorm => {
3680                    TextureFormat::Rg8Unorm
3681                }
3682                ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Snorm => {
3683                    TextureFormat::Rg8Snorm
3684                }
3685                ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Uint => {
3686                    TextureFormat::Rg8Uint
3687                }
3688                ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Sint => {
3689                    TextureFormat::Rg8Sint
3690                }
3691                ffi::WGPUTextureFormat_WGPUTextureFormat_R32Float => {
3692                    TextureFormat::R32Float
3693                }
3694                ffi::WGPUTextureFormat_WGPUTextureFormat_R32Uint => {
3695                    TextureFormat::R32Uint
3696                }
3697                ffi::WGPUTextureFormat_WGPUTextureFormat_R32Sint => {
3698                    TextureFormat::R32Sint
3699                }
3700                ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Unorm => {
3701                    TextureFormat::Rg16Unorm
3702                }
3703                ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Snorm => {
3704                    TextureFormat::Rg16Snorm
3705                }
3706                ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Uint => {
3707                    TextureFormat::Rg16Uint
3708                }
3709                ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Sint => {
3710                    TextureFormat::Rg16Sint
3711                }
3712                ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Float => {
3713                    TextureFormat::Rg16Float
3714                }
3715                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Unorm => {
3716                    TextureFormat::Rgba8Unorm
3717                }
3718                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8UnormSrgb => {
3719                    TextureFormat::Rgba8UnormSrgb
3720                }
3721                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Snorm => {
3722                    TextureFormat::Rgba8Snorm
3723                }
3724                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Uint => {
3725                    TextureFormat::Rgba8Uint
3726                }
3727                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Sint => {
3728                    TextureFormat::Rgba8Sint
3729                }
3730                ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8Unorm => {
3731                    TextureFormat::Bgra8Unorm
3732                }
3733                ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8UnormSrgb => {
3734                    TextureFormat::Bgra8UnormSrgb
3735                }
3736                ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Uint => {
3737                    TextureFormat::Rgb10A2Uint
3738                }
3739                ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Unorm => {
3740                    TextureFormat::Rgb10A2Unorm
3741                }
3742                ffi::WGPUTextureFormat_WGPUTextureFormat_RG11B10Ufloat => {
3743                    TextureFormat::Rg11B10Ufloat
3744                }
3745                ffi::WGPUTextureFormat_WGPUTextureFormat_RGB9E5Ufloat => {
3746                    TextureFormat::Rgb9E5Ufloat
3747                }
3748                ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Float => {
3749                    TextureFormat::Rg32Float
3750                }
3751                ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Uint => {
3752                    TextureFormat::Rg32Uint
3753                }
3754                ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Sint => {
3755                    TextureFormat::Rg32Sint
3756                }
3757                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Unorm => {
3758                    TextureFormat::Rgba16Unorm
3759                }
3760                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Snorm => {
3761                    TextureFormat::Rgba16Snorm
3762                }
3763                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Uint => {
3764                    TextureFormat::Rgba16Uint
3765                }
3766                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Sint => {
3767                    TextureFormat::Rgba16Sint
3768                }
3769                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Float => {
3770                    TextureFormat::Rgba16Float
3771                }
3772                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Float => {
3773                    TextureFormat::Rgba32Float
3774                }
3775                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Uint => {
3776                    TextureFormat::Rgba32Uint
3777                }
3778                ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Sint => {
3779                    TextureFormat::Rgba32Sint
3780                }
3781                ffi::WGPUTextureFormat_WGPUTextureFormat_Stencil8 => {
3782                    TextureFormat::Stencil8
3783                }
3784                ffi::WGPUTextureFormat_WGPUTextureFormat_Depth16Unorm => {
3785                    TextureFormat::Depth16Unorm
3786                }
3787                ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24Plus => {
3788                    TextureFormat::Depth24Plus
3789                }
3790                ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24PlusStencil8 => {
3791                    TextureFormat::Depth24PlusStencil8
3792                }
3793                ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32Float => {
3794                    TextureFormat::Depth32Float
3795                }
3796                ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32FloatStencil8 => {
3797                    TextureFormat::Depth32FloatStencil8
3798                }
3799                ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnorm => {
3800                    TextureFormat::Bc1RgbaUnorm
3801                }
3802                ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnormSrgb => {
3803                    TextureFormat::Bc1RgbaUnormSrgb
3804                }
3805                ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnorm => {
3806                    TextureFormat::Bc2RgbaUnorm
3807                }
3808                ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnormSrgb => {
3809                    TextureFormat::Bc2RgbaUnormSrgb
3810                }
3811                ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnorm => {
3812                    TextureFormat::Bc3RgbaUnorm
3813                }
3814                ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnormSrgb => {
3815                    TextureFormat::Bc3RgbaUnormSrgb
3816                }
3817                ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RUnorm => {
3818                    TextureFormat::Bc4RUnorm
3819                }
3820                ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RSnorm => {
3821                    TextureFormat::Bc4RSnorm
3822                }
3823                ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGUnorm => {
3824                    TextureFormat::Bc5RgUnorm
3825                }
3826                ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGSnorm => {
3827                    TextureFormat::Bc5RgSnorm
3828                }
3829                ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBUfloat => {
3830                    TextureFormat::Bc6HRgbUfloat
3831                }
3832                ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBFloat => {
3833                    TextureFormat::Bc6HRgbFloat
3834                }
3835                ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnorm => {
3836                    TextureFormat::Bc7RgbaUnorm
3837                }
3838                ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnormSrgb => {
3839                    TextureFormat::Bc7RgbaUnormSrgb
3840                }
3841                ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8Unorm => {
3842                    TextureFormat::Etc2Rgb8Unorm
3843                }
3844                ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8UnormSrgb => {
3845                    TextureFormat::Etc2Rgb8UnormSrgb
3846                }
3847                ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1Unorm => {
3848                    TextureFormat::Etc2Rgb8A1Unorm
3849                }
3850                ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1UnormSrgb => {
3851                    TextureFormat::Etc2Rgb8A1UnormSrgb
3852                }
3853                ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8Unorm => {
3854                    TextureFormat::Etc2Rgba8Unorm
3855                }
3856                ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8UnormSrgb => {
3857                    TextureFormat::Etc2Rgba8UnormSrgb
3858                }
3859                ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Unorm => {
3860                    TextureFormat::EacR11Unorm
3861                }
3862                ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Snorm => {
3863                    TextureFormat::EacR11Snorm
3864                }
3865                ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Unorm => {
3866                    TextureFormat::EacRg11Unorm
3867                }
3868                ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Snorm => {
3869                    TextureFormat::EacRg11Snorm
3870                }
3871                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4Unorm => {
3872                    TextureFormat::Astc4X4Unorm
3873                }
3874                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4UnormSrgb => {
3875                    TextureFormat::Astc4X4UnormSrgb
3876                }
3877                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4Unorm => {
3878                    TextureFormat::Astc5X4Unorm
3879                }
3880                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4UnormSrgb => {
3881                    TextureFormat::Astc5X4UnormSrgb
3882                }
3883                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5Unorm => {
3884                    TextureFormat::Astc5X5Unorm
3885                }
3886                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5UnormSrgb => {
3887                    TextureFormat::Astc5X5UnormSrgb
3888                }
3889                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5Unorm => {
3890                    TextureFormat::Astc6X5Unorm
3891                }
3892                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5UnormSrgb => {
3893                    TextureFormat::Astc6X5UnormSrgb
3894                }
3895                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6Unorm => {
3896                    TextureFormat::Astc6X6Unorm
3897                }
3898                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6UnormSrgb => {
3899                    TextureFormat::Astc6X6UnormSrgb
3900                }
3901                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5Unorm => {
3902                    TextureFormat::Astc8X5Unorm
3903                }
3904                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5UnormSrgb => {
3905                    TextureFormat::Astc8X5UnormSrgb
3906                }
3907                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6Unorm => {
3908                    TextureFormat::Astc8X6Unorm
3909                }
3910                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6UnormSrgb => {
3911                    TextureFormat::Astc8X6UnormSrgb
3912                }
3913                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8Unorm => {
3914                    TextureFormat::Astc8X8Unorm
3915                }
3916                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8UnormSrgb => {
3917                    TextureFormat::Astc8X8UnormSrgb
3918                }
3919                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5Unorm => {
3920                    TextureFormat::Astc10X5Unorm
3921                }
3922                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5UnormSrgb => {
3923                    TextureFormat::Astc10X5UnormSrgb
3924                }
3925                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6Unorm => {
3926                    TextureFormat::Astc10X6Unorm
3927                }
3928                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6UnormSrgb => {
3929                    TextureFormat::Astc10X6UnormSrgb
3930                }
3931                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8Unorm => {
3932                    TextureFormat::Astc10X8Unorm
3933                }
3934                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8UnormSrgb => {
3935                    TextureFormat::Astc10X8UnormSrgb
3936                }
3937                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10Unorm => {
3938                    TextureFormat::Astc10X10Unorm
3939                }
3940                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10UnormSrgb => {
3941                    TextureFormat::Astc10X10UnormSrgb
3942                }
3943                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10Unorm => {
3944                    TextureFormat::Astc12X10Unorm
3945                }
3946                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10UnormSrgb => {
3947                    TextureFormat::Astc12X10UnormSrgb
3948                }
3949                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12Unorm => {
3950                    TextureFormat::Astc12X12Unorm
3951                }
3952                ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12UnormSrgb => {
3953                    TextureFormat::Astc12X12UnormSrgb
3954                }
3955                ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar420Unorm => {
3956                    TextureFormat::R8Bg8Biplanar420Unorm
3957                }
3958                ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar420Unorm => {
3959                    TextureFormat::R10X6Bg10X6Biplanar420Unorm
3960                }
3961                ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8A8Triplanar420Unorm => {
3962                    TextureFormat::R8Bg8A8Triplanar420Unorm
3963                }
3964                ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar422Unorm => {
3965                    TextureFormat::R8Bg8Biplanar422Unorm
3966                }
3967                ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar444Unorm => {
3968                    TextureFormat::R8Bg8Biplanar444Unorm
3969                }
3970                ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar422Unorm => {
3971                    TextureFormat::R10X6Bg10X6Biplanar422Unorm
3972                }
3973                ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar444Unorm => {
3974                    TextureFormat::R10X6Bg10X6Biplanar444Unorm
3975                }
3976                ffi::WGPUTextureFormat_WGPUTextureFormat_OpaqueYCbCrAndroid => {
3977                    TextureFormat::OpaqueYCbCrAndroid
3978                }
3979                _ => TextureFormat::Undefined,
3980            }
3981        }
3982    }
3983    impl From<TextureFormat> for ffi::WGPUTextureFormat {
3984        fn from(value: TextureFormat) -> Self {
3985            match value {
3986                TextureFormat::Undefined => {
3987                    ffi::WGPUTextureFormat_WGPUTextureFormat_Undefined
3988                }
3989                TextureFormat::R8Unorm => {
3990                    ffi::WGPUTextureFormat_WGPUTextureFormat_R8Unorm
3991                }
3992                TextureFormat::R8Snorm => {
3993                    ffi::WGPUTextureFormat_WGPUTextureFormat_R8Snorm
3994                }
3995                TextureFormat::R8Uint => ffi::WGPUTextureFormat_WGPUTextureFormat_R8Uint,
3996                TextureFormat::R8Sint => ffi::WGPUTextureFormat_WGPUTextureFormat_R8Sint,
3997                TextureFormat::R16Unorm => {
3998                    ffi::WGPUTextureFormat_WGPUTextureFormat_R16Unorm
3999                }
4000                TextureFormat::R16Snorm => {
4001                    ffi::WGPUTextureFormat_WGPUTextureFormat_R16Snorm
4002                }
4003                TextureFormat::R16Uint => {
4004                    ffi::WGPUTextureFormat_WGPUTextureFormat_R16Uint
4005                }
4006                TextureFormat::R16Sint => {
4007                    ffi::WGPUTextureFormat_WGPUTextureFormat_R16Sint
4008                }
4009                TextureFormat::R16Float => {
4010                    ffi::WGPUTextureFormat_WGPUTextureFormat_R16Float
4011                }
4012                TextureFormat::Rg8Unorm => {
4013                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Unorm
4014                }
4015                TextureFormat::Rg8Snorm => {
4016                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Snorm
4017                }
4018                TextureFormat::Rg8Uint => {
4019                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Uint
4020                }
4021                TextureFormat::Rg8Sint => {
4022                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Sint
4023                }
4024                TextureFormat::R32Float => {
4025                    ffi::WGPUTextureFormat_WGPUTextureFormat_R32Float
4026                }
4027                TextureFormat::R32Uint => {
4028                    ffi::WGPUTextureFormat_WGPUTextureFormat_R32Uint
4029                }
4030                TextureFormat::R32Sint => {
4031                    ffi::WGPUTextureFormat_WGPUTextureFormat_R32Sint
4032                }
4033                TextureFormat::Rg16Unorm => {
4034                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Unorm
4035                }
4036                TextureFormat::Rg16Snorm => {
4037                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Snorm
4038                }
4039                TextureFormat::Rg16Uint => {
4040                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Uint
4041                }
4042                TextureFormat::Rg16Sint => {
4043                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Sint
4044                }
4045                TextureFormat::Rg16Float => {
4046                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Float
4047                }
4048                TextureFormat::Rgba8Unorm => {
4049                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Unorm
4050                }
4051                TextureFormat::Rgba8UnormSrgb => {
4052                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8UnormSrgb
4053                }
4054                TextureFormat::Rgba8Snorm => {
4055                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Snorm
4056                }
4057                TextureFormat::Rgba8Uint => {
4058                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Uint
4059                }
4060                TextureFormat::Rgba8Sint => {
4061                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Sint
4062                }
4063                TextureFormat::Bgra8Unorm => {
4064                    ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8Unorm
4065                }
4066                TextureFormat::Bgra8UnormSrgb => {
4067                    ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8UnormSrgb
4068                }
4069                TextureFormat::Rgb10A2Uint => {
4070                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Uint
4071                }
4072                TextureFormat::Rgb10A2Unorm => {
4073                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Unorm
4074                }
4075                TextureFormat::Rg11B10Ufloat => {
4076                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG11B10Ufloat
4077                }
4078                TextureFormat::Rgb9E5Ufloat => {
4079                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGB9E5Ufloat
4080                }
4081                TextureFormat::Rg32Float => {
4082                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Float
4083                }
4084                TextureFormat::Rg32Uint => {
4085                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Uint
4086                }
4087                TextureFormat::Rg32Sint => {
4088                    ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Sint
4089                }
4090                TextureFormat::Rgba16Unorm => {
4091                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Unorm
4092                }
4093                TextureFormat::Rgba16Snorm => {
4094                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Snorm
4095                }
4096                TextureFormat::Rgba16Uint => {
4097                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Uint
4098                }
4099                TextureFormat::Rgba16Sint => {
4100                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Sint
4101                }
4102                TextureFormat::Rgba16Float => {
4103                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Float
4104                }
4105                TextureFormat::Rgba32Float => {
4106                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Float
4107                }
4108                TextureFormat::Rgba32Uint => {
4109                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Uint
4110                }
4111                TextureFormat::Rgba32Sint => {
4112                    ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Sint
4113                }
4114                TextureFormat::Stencil8 => {
4115                    ffi::WGPUTextureFormat_WGPUTextureFormat_Stencil8
4116                }
4117                TextureFormat::Depth16Unorm => {
4118                    ffi::WGPUTextureFormat_WGPUTextureFormat_Depth16Unorm
4119                }
4120                TextureFormat::Depth24Plus => {
4121                    ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24Plus
4122                }
4123                TextureFormat::Depth24PlusStencil8 => {
4124                    ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24PlusStencil8
4125                }
4126                TextureFormat::Depth32Float => {
4127                    ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32Float
4128                }
4129                TextureFormat::Depth32FloatStencil8 => {
4130                    ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32FloatStencil8
4131                }
4132                TextureFormat::Bc1RgbaUnorm => {
4133                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnorm
4134                }
4135                TextureFormat::Bc1RgbaUnormSrgb => {
4136                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnormSrgb
4137                }
4138                TextureFormat::Bc2RgbaUnorm => {
4139                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnorm
4140                }
4141                TextureFormat::Bc2RgbaUnormSrgb => {
4142                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnormSrgb
4143                }
4144                TextureFormat::Bc3RgbaUnorm => {
4145                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnorm
4146                }
4147                TextureFormat::Bc3RgbaUnormSrgb => {
4148                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnormSrgb
4149                }
4150                TextureFormat::Bc4RUnorm => {
4151                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RUnorm
4152                }
4153                TextureFormat::Bc4RSnorm => {
4154                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RSnorm
4155                }
4156                TextureFormat::Bc5RgUnorm => {
4157                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGUnorm
4158                }
4159                TextureFormat::Bc5RgSnorm => {
4160                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGSnorm
4161                }
4162                TextureFormat::Bc6HRgbUfloat => {
4163                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBUfloat
4164                }
4165                TextureFormat::Bc6HRgbFloat => {
4166                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBFloat
4167                }
4168                TextureFormat::Bc7RgbaUnorm => {
4169                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnorm
4170                }
4171                TextureFormat::Bc7RgbaUnormSrgb => {
4172                    ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnormSrgb
4173                }
4174                TextureFormat::Etc2Rgb8Unorm => {
4175                    ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8Unorm
4176                }
4177                TextureFormat::Etc2Rgb8UnormSrgb => {
4178                    ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8UnormSrgb
4179                }
4180                TextureFormat::Etc2Rgb8A1Unorm => {
4181                    ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1Unorm
4182                }
4183                TextureFormat::Etc2Rgb8A1UnormSrgb => {
4184                    ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1UnormSrgb
4185                }
4186                TextureFormat::Etc2Rgba8Unorm => {
4187                    ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8Unorm
4188                }
4189                TextureFormat::Etc2Rgba8UnormSrgb => {
4190                    ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8UnormSrgb
4191                }
4192                TextureFormat::EacR11Unorm => {
4193                    ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Unorm
4194                }
4195                TextureFormat::EacR11Snorm => {
4196                    ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Snorm
4197                }
4198                TextureFormat::EacRg11Unorm => {
4199                    ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Unorm
4200                }
4201                TextureFormat::EacRg11Snorm => {
4202                    ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Snorm
4203                }
4204                TextureFormat::Astc4X4Unorm => {
4205                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4Unorm
4206                }
4207                TextureFormat::Astc4X4UnormSrgb => {
4208                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4UnormSrgb
4209                }
4210                TextureFormat::Astc5X4Unorm => {
4211                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4Unorm
4212                }
4213                TextureFormat::Astc5X4UnormSrgb => {
4214                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4UnormSrgb
4215                }
4216                TextureFormat::Astc5X5Unorm => {
4217                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5Unorm
4218                }
4219                TextureFormat::Astc5X5UnormSrgb => {
4220                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5UnormSrgb
4221                }
4222                TextureFormat::Astc6X5Unorm => {
4223                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5Unorm
4224                }
4225                TextureFormat::Astc6X5UnormSrgb => {
4226                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5UnormSrgb
4227                }
4228                TextureFormat::Astc6X6Unorm => {
4229                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6Unorm
4230                }
4231                TextureFormat::Astc6X6UnormSrgb => {
4232                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6UnormSrgb
4233                }
4234                TextureFormat::Astc8X5Unorm => {
4235                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5Unorm
4236                }
4237                TextureFormat::Astc8X5UnormSrgb => {
4238                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5UnormSrgb
4239                }
4240                TextureFormat::Astc8X6Unorm => {
4241                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6Unorm
4242                }
4243                TextureFormat::Astc8X6UnormSrgb => {
4244                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6UnormSrgb
4245                }
4246                TextureFormat::Astc8X8Unorm => {
4247                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8Unorm
4248                }
4249                TextureFormat::Astc8X8UnormSrgb => {
4250                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8UnormSrgb
4251                }
4252                TextureFormat::Astc10X5Unorm => {
4253                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5Unorm
4254                }
4255                TextureFormat::Astc10X5UnormSrgb => {
4256                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5UnormSrgb
4257                }
4258                TextureFormat::Astc10X6Unorm => {
4259                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6Unorm
4260                }
4261                TextureFormat::Astc10X6UnormSrgb => {
4262                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6UnormSrgb
4263                }
4264                TextureFormat::Astc10X8Unorm => {
4265                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8Unorm
4266                }
4267                TextureFormat::Astc10X8UnormSrgb => {
4268                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8UnormSrgb
4269                }
4270                TextureFormat::Astc10X10Unorm => {
4271                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10Unorm
4272                }
4273                TextureFormat::Astc10X10UnormSrgb => {
4274                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10UnormSrgb
4275                }
4276                TextureFormat::Astc12X10Unorm => {
4277                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10Unorm
4278                }
4279                TextureFormat::Astc12X10UnormSrgb => {
4280                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10UnormSrgb
4281                }
4282                TextureFormat::Astc12X12Unorm => {
4283                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12Unorm
4284                }
4285                TextureFormat::Astc12X12UnormSrgb => {
4286                    ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12UnormSrgb
4287                }
4288                TextureFormat::R8Bg8Biplanar420Unorm => {
4289                    ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar420Unorm
4290                }
4291                TextureFormat::R10X6Bg10X6Biplanar420Unorm => {
4292                    ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar420Unorm
4293                }
4294                TextureFormat::R8Bg8A8Triplanar420Unorm => {
4295                    ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8A8Triplanar420Unorm
4296                }
4297                TextureFormat::R8Bg8Biplanar422Unorm => {
4298                    ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar422Unorm
4299                }
4300                TextureFormat::R8Bg8Biplanar444Unorm => {
4301                    ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar444Unorm
4302                }
4303                TextureFormat::R10X6Bg10X6Biplanar422Unorm => {
4304                    ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar422Unorm
4305                }
4306                TextureFormat::R10X6Bg10X6Biplanar444Unorm => {
4307                    ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar444Unorm
4308                }
4309                TextureFormat::OpaqueYCbCrAndroid => {
4310                    ffi::WGPUTextureFormat_WGPUTextureFormat_OpaqueYCbCrAndroid
4311                }
4312            }
4313        }
4314    }
4315    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4316    pub enum TextureSampleType {
4317        BindingNotUsed,
4318        Undefined,
4319        Float,
4320        UnfilterableFloat,
4321        Depth,
4322        Sint,
4323        Uint,
4324    }
4325    impl From<ffi::WGPUTextureSampleType> for TextureSampleType {
4326        fn from(value: ffi::WGPUTextureSampleType) -> Self {
4327            match value {
4328                ffi::WGPUTextureSampleType_WGPUTextureSampleType_BindingNotUsed => {
4329                    TextureSampleType::BindingNotUsed
4330                }
4331                ffi::WGPUTextureSampleType_WGPUTextureSampleType_Undefined => {
4332                    TextureSampleType::Undefined
4333                }
4334                ffi::WGPUTextureSampleType_WGPUTextureSampleType_Float => {
4335                    TextureSampleType::Float
4336                }
4337                ffi::WGPUTextureSampleType_WGPUTextureSampleType_UnfilterableFloat => {
4338                    TextureSampleType::UnfilterableFloat
4339                }
4340                ffi::WGPUTextureSampleType_WGPUTextureSampleType_Depth => {
4341                    TextureSampleType::Depth
4342                }
4343                ffi::WGPUTextureSampleType_WGPUTextureSampleType_Sint => {
4344                    TextureSampleType::Sint
4345                }
4346                ffi::WGPUTextureSampleType_WGPUTextureSampleType_Uint => {
4347                    TextureSampleType::Uint
4348                }
4349                _ => TextureSampleType::BindingNotUsed,
4350            }
4351        }
4352    }
4353    impl From<TextureSampleType> for ffi::WGPUTextureSampleType {
4354        fn from(value: TextureSampleType) -> Self {
4355            match value {
4356                TextureSampleType::BindingNotUsed => {
4357                    ffi::WGPUTextureSampleType_WGPUTextureSampleType_BindingNotUsed
4358                }
4359                TextureSampleType::Undefined => {
4360                    ffi::WGPUTextureSampleType_WGPUTextureSampleType_Undefined
4361                }
4362                TextureSampleType::Float => {
4363                    ffi::WGPUTextureSampleType_WGPUTextureSampleType_Float
4364                }
4365                TextureSampleType::UnfilterableFloat => {
4366                    ffi::WGPUTextureSampleType_WGPUTextureSampleType_UnfilterableFloat
4367                }
4368                TextureSampleType::Depth => {
4369                    ffi::WGPUTextureSampleType_WGPUTextureSampleType_Depth
4370                }
4371                TextureSampleType::Sint => {
4372                    ffi::WGPUTextureSampleType_WGPUTextureSampleType_Sint
4373                }
4374                TextureSampleType::Uint => {
4375                    ffi::WGPUTextureSampleType_WGPUTextureSampleType_Uint
4376                }
4377            }
4378        }
4379    }
4380    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4381    pub enum TextureViewDimension {
4382        Undefined,
4383        D1,
4384        D2,
4385        D2Array,
4386        Cube,
4387        CubeArray,
4388        D3,
4389    }
4390    impl From<ffi::WGPUTextureViewDimension> for TextureViewDimension {
4391        fn from(value: ffi::WGPUTextureViewDimension) -> Self {
4392            match value {
4393                ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Undefined => {
4394                    TextureViewDimension::Undefined
4395                }
4396                ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_1D => {
4397                    TextureViewDimension::D1
4398                }
4399                ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2D => {
4400                    TextureViewDimension::D2
4401                }
4402                ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2DArray => {
4403                    TextureViewDimension::D2Array
4404                }
4405                ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Cube => {
4406                    TextureViewDimension::Cube
4407                }
4408                ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_CubeArray => {
4409                    TextureViewDimension::CubeArray
4410                }
4411                ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_3D => {
4412                    TextureViewDimension::D3
4413                }
4414                _ => TextureViewDimension::Undefined,
4415            }
4416        }
4417    }
4418    impl From<TextureViewDimension> for ffi::WGPUTextureViewDimension {
4419        fn from(value: TextureViewDimension) -> Self {
4420            match value {
4421                TextureViewDimension::Undefined => {
4422                    ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Undefined
4423                }
4424                TextureViewDimension::D1 => {
4425                    ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_1D
4426                }
4427                TextureViewDimension::D2 => {
4428                    ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2D
4429                }
4430                TextureViewDimension::D2Array => {
4431                    ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2DArray
4432                }
4433                TextureViewDimension::Cube => {
4434                    ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Cube
4435                }
4436                TextureViewDimension::CubeArray => {
4437                    ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_CubeArray
4438                }
4439                TextureViewDimension::D3 => {
4440                    ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_3D
4441                }
4442            }
4443        }
4444    }
4445    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4446    pub enum ToneMappingMode {
4447        Standard,
4448        Extended,
4449    }
4450    impl From<ffi::WGPUToneMappingMode> for ToneMappingMode {
4451        fn from(value: ffi::WGPUToneMappingMode) -> Self {
4452            match value {
4453                ffi::WGPUToneMappingMode_WGPUToneMappingMode_Standard => {
4454                    ToneMappingMode::Standard
4455                }
4456                ffi::WGPUToneMappingMode_WGPUToneMappingMode_Extended => {
4457                    ToneMappingMode::Extended
4458                }
4459                _ => ToneMappingMode::Standard,
4460            }
4461        }
4462    }
4463    impl From<ToneMappingMode> for ffi::WGPUToneMappingMode {
4464        fn from(value: ToneMappingMode) -> Self {
4465            match value {
4466                ToneMappingMode::Standard => {
4467                    ffi::WGPUToneMappingMode_WGPUToneMappingMode_Standard
4468                }
4469                ToneMappingMode::Extended => {
4470                    ffi::WGPUToneMappingMode_WGPUToneMappingMode_Extended
4471                }
4472            }
4473        }
4474    }
4475    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4476    pub enum VertexFormat {
4477        Uint8,
4478        Uint8X2,
4479        Uint8X4,
4480        Sint8,
4481        Sint8X2,
4482        Sint8X4,
4483        Unorm8,
4484        Unorm8X2,
4485        Unorm8X4,
4486        Snorm8,
4487        Snorm8X2,
4488        Snorm8X4,
4489        Uint16,
4490        Uint16X2,
4491        Uint16X4,
4492        Sint16,
4493        Sint16X2,
4494        Sint16X4,
4495        Unorm16,
4496        Unorm16X2,
4497        Unorm16X4,
4498        Snorm16,
4499        Snorm16X2,
4500        Snorm16X4,
4501        Float16,
4502        Float16X2,
4503        Float16X4,
4504        Float32,
4505        Float32X2,
4506        Float32X3,
4507        Float32X4,
4508        Uint32,
4509        Uint32X2,
4510        Uint32X3,
4511        Uint32X4,
4512        Sint32,
4513        Sint32X2,
4514        Sint32X3,
4515        Sint32X4,
4516        Unorm1010102,
4517        Unorm8X4Bgra,
4518    }
4519    impl From<ffi::WGPUVertexFormat> for VertexFormat {
4520        fn from(value: ffi::WGPUVertexFormat) -> Self {
4521            match value {
4522                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8 => VertexFormat::Uint8,
4523                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x2 => VertexFormat::Uint8X2,
4524                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x4 => VertexFormat::Uint8X4,
4525                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8 => VertexFormat::Sint8,
4526                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x2 => VertexFormat::Sint8X2,
4527                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x4 => VertexFormat::Sint8X4,
4528                ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8 => VertexFormat::Unorm8,
4529                ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x2 => VertexFormat::Unorm8X2,
4530                ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4 => VertexFormat::Unorm8X4,
4531                ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8 => VertexFormat::Snorm8,
4532                ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x2 => VertexFormat::Snorm8X2,
4533                ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x4 => VertexFormat::Snorm8X4,
4534                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16 => VertexFormat::Uint16,
4535                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x2 => VertexFormat::Uint16X2,
4536                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x4 => VertexFormat::Uint16X4,
4537                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16 => VertexFormat::Sint16,
4538                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x2 => VertexFormat::Sint16X2,
4539                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x4 => VertexFormat::Sint16X4,
4540                ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16 => VertexFormat::Unorm16,
4541                ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x2 => {
4542                    VertexFormat::Unorm16X2
4543                }
4544                ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x4 => {
4545                    VertexFormat::Unorm16X4
4546                }
4547                ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16 => VertexFormat::Snorm16,
4548                ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x2 => {
4549                    VertexFormat::Snorm16X2
4550                }
4551                ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x4 => {
4552                    VertexFormat::Snorm16X4
4553                }
4554                ffi::WGPUVertexFormat_WGPUVertexFormat_Float16 => VertexFormat::Float16,
4555                ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x2 => {
4556                    VertexFormat::Float16X2
4557                }
4558                ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x4 => {
4559                    VertexFormat::Float16X4
4560                }
4561                ffi::WGPUVertexFormat_WGPUVertexFormat_Float32 => VertexFormat::Float32,
4562                ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x2 => {
4563                    VertexFormat::Float32X2
4564                }
4565                ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x3 => {
4566                    VertexFormat::Float32X3
4567                }
4568                ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x4 => {
4569                    VertexFormat::Float32X4
4570                }
4571                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32 => VertexFormat::Uint32,
4572                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x2 => VertexFormat::Uint32X2,
4573                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x3 => VertexFormat::Uint32X3,
4574                ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x4 => VertexFormat::Uint32X4,
4575                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32 => VertexFormat::Sint32,
4576                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x2 => VertexFormat::Sint32X2,
4577                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x3 => VertexFormat::Sint32X3,
4578                ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x4 => VertexFormat::Sint32X4,
4579                ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm10_10_10_2 => {
4580                    VertexFormat::Unorm1010102
4581                }
4582                ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4BGRA => {
4583                    VertexFormat::Unorm8X4Bgra
4584                }
4585                _ => VertexFormat::Uint8,
4586            }
4587        }
4588    }
4589    impl From<VertexFormat> for ffi::WGPUVertexFormat {
4590        fn from(value: VertexFormat) -> Self {
4591            match value {
4592                VertexFormat::Uint8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8,
4593                VertexFormat::Uint8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x2,
4594                VertexFormat::Uint8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x4,
4595                VertexFormat::Sint8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8,
4596                VertexFormat::Sint8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x2,
4597                VertexFormat::Sint8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x4,
4598                VertexFormat::Unorm8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8,
4599                VertexFormat::Unorm8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x2,
4600                VertexFormat::Unorm8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4,
4601                VertexFormat::Snorm8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8,
4602                VertexFormat::Snorm8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x2,
4603                VertexFormat::Snorm8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x4,
4604                VertexFormat::Uint16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16,
4605                VertexFormat::Uint16X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x2,
4606                VertexFormat::Uint16X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x4,
4607                VertexFormat::Sint16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16,
4608                VertexFormat::Sint16X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x2,
4609                VertexFormat::Sint16X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x4,
4610                VertexFormat::Unorm16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16,
4611                VertexFormat::Unorm16X2 => {
4612                    ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x2
4613                }
4614                VertexFormat::Unorm16X4 => {
4615                    ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x4
4616                }
4617                VertexFormat::Snorm16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16,
4618                VertexFormat::Snorm16X2 => {
4619                    ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x2
4620                }
4621                VertexFormat::Snorm16X4 => {
4622                    ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x4
4623                }
4624                VertexFormat::Float16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Float16,
4625                VertexFormat::Float16X2 => {
4626                    ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x2
4627                }
4628                VertexFormat::Float16X4 => {
4629                    ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x4
4630                }
4631                VertexFormat::Float32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Float32,
4632                VertexFormat::Float32X2 => {
4633                    ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x2
4634                }
4635                VertexFormat::Float32X3 => {
4636                    ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x3
4637                }
4638                VertexFormat::Float32X4 => {
4639                    ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x4
4640                }
4641                VertexFormat::Uint32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32,
4642                VertexFormat::Uint32X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x2,
4643                VertexFormat::Uint32X3 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x3,
4644                VertexFormat::Uint32X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x4,
4645                VertexFormat::Sint32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32,
4646                VertexFormat::Sint32X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x2,
4647                VertexFormat::Sint32X3 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x3,
4648                VertexFormat::Sint32X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x4,
4649                VertexFormat::Unorm1010102 => {
4650                    ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm10_10_10_2
4651                }
4652                VertexFormat::Unorm8X4Bgra => {
4653                    ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4BGRA
4654                }
4655            }
4656        }
4657    }
4658    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4659    pub enum VertexStepMode {
4660        Undefined,
4661        Vertex,
4662        Instance,
4663    }
4664    impl From<ffi::WGPUVertexStepMode> for VertexStepMode {
4665        fn from(value: ffi::WGPUVertexStepMode) -> Self {
4666            match value {
4667                ffi::WGPUVertexStepMode_WGPUVertexStepMode_Undefined => {
4668                    VertexStepMode::Undefined
4669                }
4670                ffi::WGPUVertexStepMode_WGPUVertexStepMode_Vertex => {
4671                    VertexStepMode::Vertex
4672                }
4673                ffi::WGPUVertexStepMode_WGPUVertexStepMode_Instance => {
4674                    VertexStepMode::Instance
4675                }
4676                _ => VertexStepMode::Undefined,
4677            }
4678        }
4679    }
4680    impl From<VertexStepMode> for ffi::WGPUVertexStepMode {
4681        fn from(value: VertexStepMode) -> Self {
4682            match value {
4683                VertexStepMode::Undefined => {
4684                    ffi::WGPUVertexStepMode_WGPUVertexStepMode_Undefined
4685                }
4686                VertexStepMode::Vertex => {
4687                    ffi::WGPUVertexStepMode_WGPUVertexStepMode_Vertex
4688                }
4689                VertexStepMode::Instance => {
4690                    ffi::WGPUVertexStepMode_WGPUVertexStepMode_Instance
4691                }
4692            }
4693        }
4694    }
4695    #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4696    pub enum WaitStatus {
4697        Success,
4698        TimedOut,
4699        Error,
4700    }
4701    impl From<ffi::WGPUWaitStatus> for WaitStatus {
4702        fn from(value: ffi::WGPUWaitStatus) -> Self {
4703            match value {
4704                ffi::WGPUWaitStatus_WGPUWaitStatus_Success => WaitStatus::Success,
4705                ffi::WGPUWaitStatus_WGPUWaitStatus_TimedOut => WaitStatus::TimedOut,
4706                ffi::WGPUWaitStatus_WGPUWaitStatus_Error => WaitStatus::Error,
4707                _ => WaitStatus::Success,
4708            }
4709        }
4710    }
4711    impl From<WaitStatus> for ffi::WGPUWaitStatus {
4712        fn from(value: WaitStatus) -> Self {
4713            match value {
4714                WaitStatus::Success => ffi::WGPUWaitStatus_WGPUWaitStatus_Success,
4715                WaitStatus::TimedOut => ffi::WGPUWaitStatus_WGPUWaitStatus_TimedOut,
4716                WaitStatus::Error => ffi::WGPUWaitStatus_WGPUWaitStatus_Error,
4717            }
4718        }
4719    }
4720    bitflags! {
4721        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct BufferUsage : u64 {
4722        const NONE = ffi::WGPUBufferUsage_None as u64; const MAP_READ =
4723        ffi::WGPUBufferUsage_MapRead as u64; const MAP_WRITE =
4724        ffi::WGPUBufferUsage_MapWrite as u64; const COPY_SRC =
4725        ffi::WGPUBufferUsage_CopySrc as u64; const COPY_DST =
4726        ffi::WGPUBufferUsage_CopyDst as u64; const INDEX = ffi::WGPUBufferUsage_Index as
4727        u64; const VERTEX = ffi::WGPUBufferUsage_Vertex as u64; const UNIFORM =
4728        ffi::WGPUBufferUsage_Uniform as u64; const STORAGE = ffi::WGPUBufferUsage_Storage
4729        as u64; const INDIRECT = ffi::WGPUBufferUsage_Indirect as u64; const
4730        QUERY_RESOLVE = ffi::WGPUBufferUsage_QueryResolve as u64; const TEXEL_BUFFER =
4731        ffi::WGPUBufferUsage_TexelBuffer as u64; }
4732    }
4733    impl From<ffi::WGPUBufferUsage> for BufferUsage {
4734        fn from(value: ffi::WGPUBufferUsage) -> Self {
4735            BufferUsage::from_bits_truncate(value as u64)
4736        }
4737    }
4738    impl From<BufferUsage> for ffi::WGPUBufferUsage {
4739        fn from(value: BufferUsage) -> Self {
4740            value.bits() as ffi::WGPUBufferUsage
4741        }
4742    }
4743    bitflags! {
4744        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ColorWriteMask :
4745        u64 { const NONE = ffi::WGPUColorWriteMask_None as u64; const RED =
4746        ffi::WGPUColorWriteMask_Red as u64; const GREEN = ffi::WGPUColorWriteMask_Green
4747        as u64; const BLUE = ffi::WGPUColorWriteMask_Blue as u64; const ALPHA =
4748        ffi::WGPUColorWriteMask_Alpha as u64; const ALL = ffi::WGPUColorWriteMask_All as
4749        u64; }
4750    }
4751    impl From<ffi::WGPUColorWriteMask> for ColorWriteMask {
4752        fn from(value: ffi::WGPUColorWriteMask) -> Self {
4753            ColorWriteMask::from_bits_truncate(value as u64)
4754        }
4755    }
4756    impl From<ColorWriteMask> for ffi::WGPUColorWriteMask {
4757        fn from(value: ColorWriteMask) -> Self {
4758            value.bits() as ffi::WGPUColorWriteMask
4759        }
4760    }
4761    bitflags! {
4762        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct HeapProperty : u64
4763        { const NONE = ffi::WGPUHeapProperty_None as u64; const DEVICE_LOCAL =
4764        ffi::WGPUHeapProperty_DeviceLocal as u64; const HOST_VISIBLE =
4765        ffi::WGPUHeapProperty_HostVisible as u64; const HOST_COHERENT =
4766        ffi::WGPUHeapProperty_HostCoherent as u64; const HOST_UNCACHED =
4767        ffi::WGPUHeapProperty_HostUncached as u64; const HOST_CACHED =
4768        ffi::WGPUHeapProperty_HostCached as u64; }
4769    }
4770    impl From<ffi::WGPUHeapProperty> for HeapProperty {
4771        fn from(value: ffi::WGPUHeapProperty) -> Self {
4772            HeapProperty::from_bits_truncate(value as u64)
4773        }
4774    }
4775    impl From<HeapProperty> for ffi::WGPUHeapProperty {
4776        fn from(value: HeapProperty) -> Self {
4777            value.bits() as ffi::WGPUHeapProperty
4778        }
4779    }
4780    bitflags! {
4781        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct MapMode : u64 {
4782        const NONE = ffi::WGPUMapMode_None as u64; const READ = ffi::WGPUMapMode_Read as
4783        u64; const WRITE = ffi::WGPUMapMode_Write as u64; }
4784    }
4785    impl From<ffi::WGPUMapMode> for MapMode {
4786        fn from(value: ffi::WGPUMapMode) -> Self {
4787            MapMode::from_bits_truncate(value as u64)
4788        }
4789    }
4790    impl From<MapMode> for ffi::WGPUMapMode {
4791        fn from(value: MapMode) -> Self {
4792            value.bits() as ffi::WGPUMapMode
4793        }
4794    }
4795    bitflags! {
4796        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ShaderStage : u64 {
4797        const NONE = ffi::WGPUShaderStage_None as u64; const VERTEX =
4798        ffi::WGPUShaderStage_Vertex as u64; const FRAGMENT =
4799        ffi::WGPUShaderStage_Fragment as u64; const COMPUTE =
4800        ffi::WGPUShaderStage_Compute as u64; }
4801    }
4802    impl From<ffi::WGPUShaderStage> for ShaderStage {
4803        fn from(value: ffi::WGPUShaderStage) -> Self {
4804            ShaderStage::from_bits_truncate(value as u64)
4805        }
4806    }
4807    impl From<ShaderStage> for ffi::WGPUShaderStage {
4808        fn from(value: ShaderStage) -> Self {
4809            value.bits() as ffi::WGPUShaderStage
4810        }
4811    }
4812    bitflags! {
4813        #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct TextureUsage : u64
4814        { const NONE = ffi::WGPUTextureUsage_None as u64; const COPY_SRC =
4815        ffi::WGPUTextureUsage_CopySrc as u64; const COPY_DST =
4816        ffi::WGPUTextureUsage_CopyDst as u64; const TEXTURE_BINDING =
4817        ffi::WGPUTextureUsage_TextureBinding as u64; const STORAGE_BINDING =
4818        ffi::WGPUTextureUsage_StorageBinding as u64; const RENDER_ATTACHMENT =
4819        ffi::WGPUTextureUsage_RenderAttachment as u64; const TRANSIENT_ATTACHMENT =
4820        ffi::WGPUTextureUsage_TransientAttachment as u64; const STORAGE_ATTACHMENT =
4821        ffi::WGPUTextureUsage_StorageAttachment as u64; }
4822    }
4823    impl From<ffi::WGPUTextureUsage> for TextureUsage {
4824        fn from(value: ffi::WGPUTextureUsage) -> Self {
4825            TextureUsage::from_bits_truncate(value as u64)
4826        }
4827    }
4828    impl From<TextureUsage> for ffi::WGPUTextureUsage {
4829        fn from(value: TextureUsage) -> Self {
4830            value.bits() as ffi::WGPUTextureUsage
4831        }
4832    }
4833}
4834mod structs {
4835    #![allow(dead_code, unused_imports)]
4836    use crate::ffi;
4837    use crate::generated::*;
4838    use std::any::Any;
4839    use std::ffi::CStr;
4840    pub(crate) fn string_view_to_string(view: ffi::WGPUStringView) -> String {
4841        if view.data.is_null() || view.length == 0 {
4842            return String::new();
4843        }
4844        let data = view.data.cast::<u8>();
4845        let slice = unsafe { std::slice::from_raw_parts(data, view.length) };
4846        String::from_utf8_lossy(slice).into_owned()
4847    }
4848    pub struct AHardwareBufferProperties {
4849        pub y_cb_cr_info: Option<YCbCrVkDescriptor>,
4850    }
4851    impl Default for AHardwareBufferProperties {
4852        fn default() -> Self {
4853            Self { y_cb_cr_info: None }
4854        }
4855    }
4856    impl AHardwareBufferProperties {
4857        pub fn new() -> Self {
4858            Self::default()
4859        }
4860        pub(crate) fn to_ffi(
4861            &self,
4862        ) -> (ffi::WGPUAHardwareBufferProperties, ChainedStructStorage) {
4863            let mut storage = ChainedStructStorage::new();
4864            let mut raw: ffi::WGPUAHardwareBufferProperties = unsafe {
4865                std::mem::zeroed()
4866            };
4867            if let Some(value) = &self.y_cb_cr_info {
4868                let (raw_value, storage_value) = value.to_ffi();
4869                raw.yCbCrInfo = raw_value;
4870                storage.push_storage(storage_value);
4871            }
4872            (raw, storage)
4873        }
4874        pub(crate) fn from_ffi(value: ffi::WGPUAHardwareBufferProperties) -> Self {
4875            Self {
4876                y_cb_cr_info: Some(YCbCrVkDescriptor::from_ffi(value.yCbCrInfo)),
4877            }
4878        }
4879    }
4880    pub struct AdapterInfo {
4881        pub(crate) extensions: Vec<AdapterInfoExtension>,
4882        pub vendor: Option<String>,
4883        pub architecture: Option<String>,
4884        pub device: Option<String>,
4885        pub description: Option<String>,
4886        pub backend_type: Option<BackendType>,
4887        pub adapter_type: Option<AdapterType>,
4888        pub vendor_id: Option<u32>,
4889        pub device_id: Option<u32>,
4890        pub subgroup_min_size: Option<u32>,
4891        pub subgroup_max_size: Option<u32>,
4892        #[doc(hidden)]
4893        pub(crate) _free_members: Option<ffi::WGPUAdapterInfo>,
4894    }
4895    impl Default for AdapterInfo {
4896        fn default() -> Self {
4897            Self {
4898                extensions: Vec::new(),
4899                vendor: None,
4900                architecture: None,
4901                device: None,
4902                description: None,
4903                backend_type: None,
4904                adapter_type: None,
4905                vendor_id: None,
4906                device_id: None,
4907                subgroup_min_size: None,
4908                subgroup_max_size: None,
4909                _free_members: None,
4910            }
4911        }
4912    }
4913    impl AdapterInfo {
4914        pub fn new() -> Self {
4915            Self::default()
4916        }
4917        pub(crate) fn to_ffi(&self) -> (ffi::WGPUAdapterInfo, ChainedStructStorage) {
4918            let mut storage = ChainedStructStorage::new();
4919            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
4920            for ext in self.extensions.iter().rev() {
4921                next = ext.push_chain(&mut storage, next);
4922            }
4923            let mut raw: ffi::WGPUAdapterInfo = unsafe { std::mem::zeroed() };
4924            raw.nextInChain = next;
4925            if let Some(value) = &self.vendor {
4926                raw.vendor = ffi::WGPUStringView {
4927                    data: value.as_ptr().cast(),
4928                    length: value.len(),
4929                };
4930            } else {
4931                raw.vendor = ffi::WGPUStringView {
4932                    data: std::ptr::null(),
4933                    length: 0,
4934                };
4935            }
4936            if let Some(value) = &self.architecture {
4937                raw.architecture = ffi::WGPUStringView {
4938                    data: value.as_ptr().cast(),
4939                    length: value.len(),
4940                };
4941            } else {
4942                raw.architecture = ffi::WGPUStringView {
4943                    data: std::ptr::null(),
4944                    length: 0,
4945                };
4946            }
4947            if let Some(value) = &self.device {
4948                raw.device = ffi::WGPUStringView {
4949                    data: value.as_ptr().cast(),
4950                    length: value.len(),
4951                };
4952            } else {
4953                raw.device = ffi::WGPUStringView {
4954                    data: std::ptr::null(),
4955                    length: 0,
4956                };
4957            }
4958            if let Some(value) = &self.description {
4959                raw.description = ffi::WGPUStringView {
4960                    data: value.as_ptr().cast(),
4961                    length: value.len(),
4962                };
4963            } else {
4964                raw.description = ffi::WGPUStringView {
4965                    data: std::ptr::null(),
4966                    length: 0,
4967                };
4968            }
4969            if let Some(value) = self.backend_type {
4970                raw.backendType = value.into();
4971            } else {
4972                raw.backendType = 0 as ffi::WGPUBackendType;
4973            }
4974            if let Some(value) = self.adapter_type {
4975                raw.adapterType = value.into();
4976            } else {
4977                raw.adapterType = 0 as ffi::WGPUAdapterType;
4978            }
4979            if let Some(value) = self.vendor_id {
4980                raw.vendorID = value;
4981            }
4982            if let Some(value) = self.device_id {
4983                raw.deviceID = value;
4984            }
4985            if let Some(value) = self.subgroup_min_size {
4986                raw.subgroupMinSize = value;
4987            }
4988            if let Some(value) = self.subgroup_max_size {
4989                raw.subgroupMaxSize = value;
4990            }
4991            (raw, storage)
4992        }
4993        pub fn with_extension(mut self, extension: AdapterInfoExtension) -> Self {
4994            self.extensions.push(extension);
4995            self
4996        }
4997        pub(crate) fn from_ffi(value: ffi::WGPUAdapterInfo) -> Self {
4998            Self {
4999                extensions: Vec::new(),
5000                vendor: Some(string_view_to_string(value.vendor)),
5001                architecture: Some(string_view_to_string(value.architecture)),
5002                device: Some(string_view_to_string(value.device)),
5003                description: Some(string_view_to_string(value.description)),
5004                backend_type: Some(value.backendType.into()),
5005                adapter_type: Some(value.adapterType.into()),
5006                vendor_id: Some(value.vendorID),
5007                device_id: Some(value.deviceID),
5008                subgroup_min_size: Some(value.subgroupMinSize),
5009                subgroup_max_size: Some(value.subgroupMaxSize),
5010                _free_members: Some(value),
5011            }
5012        }
5013        pub(crate) fn free_members(value: ffi::WGPUAdapterInfo) {
5014            unsafe { ffi::wgpuAdapterInfoFreeMembers(value) };
5015        }
5016    }
5017    impl Drop for AdapterInfo {
5018        fn drop(&mut self) {
5019            if let Some(value) = self._free_members.take() {
5020                unsafe { ffi::wgpuAdapterInfoFreeMembers(value) };
5021            }
5022        }
5023    }
5024    pub struct AdapterPropertiesD3D {
5025        pub shader_model: Option<u32>,
5026    }
5027    impl Default for AdapterPropertiesD3D {
5028        fn default() -> Self {
5029            Self { shader_model: None }
5030        }
5031    }
5032    impl AdapterPropertiesD3D {
5033        pub fn new() -> Self {
5034            Self::default()
5035        }
5036        pub(crate) fn to_ffi(
5037            &self,
5038        ) -> (ffi::WGPUAdapterPropertiesD3D, ChainedStructStorage) {
5039            let mut storage = ChainedStructStorage::new();
5040            let mut raw: ffi::WGPUAdapterPropertiesD3D = unsafe { std::mem::zeroed() };
5041            if let Some(value) = self.shader_model {
5042                raw.shaderModel = value;
5043            }
5044            (raw, storage)
5045        }
5046        pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesD3D) -> Self {
5047            Self {
5048                shader_model: Some(value.shaderModel),
5049            }
5050        }
5051    }
5052    pub struct AdapterPropertiesWGPU {
5053        pub backend_type: Option<BackendType>,
5054    }
5055    impl Default for AdapterPropertiesWGPU {
5056        fn default() -> Self {
5057            Self { backend_type: None }
5058        }
5059    }
5060    impl AdapterPropertiesWGPU {
5061        pub fn new() -> Self {
5062            Self::default()
5063        }
5064        pub(crate) fn to_ffi(
5065            &self,
5066        ) -> (ffi::WGPUAdapterPropertiesWGPU, ChainedStructStorage) {
5067            let mut storage = ChainedStructStorage::new();
5068            let mut raw: ffi::WGPUAdapterPropertiesWGPU = unsafe { std::mem::zeroed() };
5069            if let Some(value) = self.backend_type {
5070                raw.backendType = value.into();
5071            } else {
5072                raw.backendType = 0 as ffi::WGPUBackendType;
5073            }
5074            (raw, storage)
5075        }
5076        pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesWGPU) -> Self {
5077            Self {
5078                backend_type: Some(value.backendType.into()),
5079            }
5080        }
5081    }
5082    pub struct AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5083        pub min_explicit_compute_subgroup_size: Option<u32>,
5084        pub max_explicit_compute_subgroup_size: Option<u32>,
5085        pub max_compute_workgroup_subgroups: Option<u32>,
5086    }
5087    impl Default for AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5088        fn default() -> Self {
5089            Self {
5090                min_explicit_compute_subgroup_size: None,
5091                max_explicit_compute_subgroup_size: None,
5092                max_compute_workgroup_subgroups: None,
5093            }
5094        }
5095    }
5096    impl AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5097        pub fn new() -> Self {
5098            Self::default()
5099        }
5100        pub(crate) fn to_ffi(
5101            &self,
5102        ) -> (
5103            ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs,
5104            ChainedStructStorage,
5105        ) {
5106            let mut storage = ChainedStructStorage::new();
5107            let mut raw: ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs = unsafe {
5108                std::mem::zeroed()
5109            };
5110            if let Some(value) = self.min_explicit_compute_subgroup_size {
5111                raw.minExplicitComputeSubgroupSize = value;
5112            }
5113            if let Some(value) = self.max_explicit_compute_subgroup_size {
5114                raw.maxExplicitComputeSubgroupSize = value;
5115            }
5116            if let Some(value) = self.max_compute_workgroup_subgroups {
5117                raw.maxComputeWorkgroupSubgroups = value;
5118            }
5119            (raw, storage)
5120        }
5121        pub(crate) fn from_ffi(
5122            value: ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs,
5123        ) -> Self {
5124            Self {
5125                min_explicit_compute_subgroup_size: Some(
5126                    value.minExplicitComputeSubgroupSize,
5127                ),
5128                max_explicit_compute_subgroup_size: Some(
5129                    value.maxExplicitComputeSubgroupSize,
5130                ),
5131                max_compute_workgroup_subgroups: Some(value.maxComputeWorkgroupSubgroups),
5132            }
5133        }
5134    }
5135    pub struct AdapterPropertiesMemoryHeaps {
5136        pub heap_info: Option<Vec<MemoryHeapInfo>>,
5137        #[doc(hidden)]
5138        pub(crate) _free_members: Option<ffi::WGPUAdapterPropertiesMemoryHeaps>,
5139    }
5140    impl Default for AdapterPropertiesMemoryHeaps {
5141        fn default() -> Self {
5142            Self {
5143                heap_info: None,
5144                _free_members: None,
5145            }
5146        }
5147    }
5148    impl AdapterPropertiesMemoryHeaps {
5149        pub fn new() -> Self {
5150            Self::default()
5151        }
5152        pub(crate) fn to_ffi(
5153            &self,
5154        ) -> (ffi::WGPUAdapterPropertiesMemoryHeaps, ChainedStructStorage) {
5155            let mut storage = ChainedStructStorage::new();
5156            let mut raw: ffi::WGPUAdapterPropertiesMemoryHeaps = unsafe {
5157                std::mem::zeroed()
5158            };
5159            raw.heapCount = self.heap_info.as_ref().map(|v| v.len()).unwrap_or(0);
5160            if let Some(values) = &self.heap_info {
5161                let len_value = values.len();
5162                let mut raw_vec: Vec<ffi::WGPUMemoryHeapInfo> = Vec::with_capacity(
5163                    values.len(),
5164                );
5165                for item in values.iter() {
5166                    let (raw_item, storage_item) = item.to_ffi();
5167                    raw_vec.push(raw_item);
5168                    storage.push_storage(storage_item);
5169                }
5170                let ptr = storage.push_vec(raw_vec);
5171                raw.heapInfo = ptr;
5172                raw.heapCount = len_value;
5173            } else {
5174                raw.heapInfo = std::ptr::null();
5175                raw.heapCount = 0;
5176            }
5177            (raw, storage)
5178        }
5179        pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesMemoryHeaps) -> Self {
5180            Self {
5181                heap_info: if value.heapInfo.is_null() {
5182                    None
5183                } else {
5184                    Some(
5185                        unsafe {
5186                            std::slice::from_raw_parts(
5187                                value.heapInfo,
5188                                value.heapCount as usize,
5189                            )
5190                        }
5191                            .iter()
5192                            .map(|raw| MemoryHeapInfo::from_ffi(*raw))
5193                            .collect(),
5194                    )
5195                },
5196                _free_members: Some(value),
5197            }
5198        }
5199        pub(crate) fn free_members(value: ffi::WGPUAdapterPropertiesMemoryHeaps) {
5200            unsafe { ffi::wgpuAdapterPropertiesMemoryHeapsFreeMembers(value) };
5201        }
5202    }
5203    impl Drop for AdapterPropertiesMemoryHeaps {
5204        fn drop(&mut self) {
5205            if let Some(value) = self._free_members.take() {
5206                unsafe { ffi::wgpuAdapterPropertiesMemoryHeapsFreeMembers(value) };
5207            }
5208        }
5209    }
5210    pub struct AdapterPropertiesSubgroupMatrixConfigs {
5211        pub configs: Option<Vec<SubgroupMatrixConfig>>,
5212        #[doc(hidden)]
5213        pub(crate) _free_members: Option<
5214            ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5215        >,
5216    }
5217    impl Default for AdapterPropertiesSubgroupMatrixConfigs {
5218        fn default() -> Self {
5219            Self {
5220                configs: None,
5221                _free_members: None,
5222            }
5223        }
5224    }
5225    impl AdapterPropertiesSubgroupMatrixConfigs {
5226        pub fn new() -> Self {
5227            Self::default()
5228        }
5229        pub(crate) fn to_ffi(
5230            &self,
5231        ) -> (ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs, ChainedStructStorage) {
5232            let mut storage = ChainedStructStorage::new();
5233            let mut raw: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs = unsafe {
5234                std::mem::zeroed()
5235            };
5236            raw.configCount = self.configs.as_ref().map(|v| v.len()).unwrap_or(0);
5237            if let Some(values) = &self.configs {
5238                let len_value = values.len();
5239                let mut raw_vec: Vec<ffi::WGPUSubgroupMatrixConfig> = Vec::with_capacity(
5240                    values.len(),
5241                );
5242                for item in values.iter() {
5243                    let (raw_item, storage_item) = item.to_ffi();
5244                    raw_vec.push(raw_item);
5245                    storage.push_storage(storage_item);
5246                }
5247                let ptr = storage.push_vec(raw_vec);
5248                raw.configs = ptr;
5249                raw.configCount = len_value;
5250            } else {
5251                raw.configs = std::ptr::null();
5252                raw.configCount = 0;
5253            }
5254            (raw, storage)
5255        }
5256        pub(crate) fn from_ffi(
5257            value: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5258        ) -> Self {
5259            Self {
5260                configs: if value.configs.is_null() {
5261                    None
5262                } else {
5263                    Some(
5264                        unsafe {
5265                            std::slice::from_raw_parts(
5266                                value.configs,
5267                                value.configCount as usize,
5268                            )
5269                        }
5270                            .iter()
5271                            .map(|raw| SubgroupMatrixConfig::from_ffi(*raw))
5272                            .collect(),
5273                    )
5274                },
5275                _free_members: Some(value),
5276            }
5277        }
5278        pub(crate) fn free_members(
5279            value: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5280        ) {
5281            unsafe { ffi::wgpuAdapterPropertiesSubgroupMatrixConfigsFreeMembers(value) };
5282        }
5283    }
5284    impl Drop for AdapterPropertiesSubgroupMatrixConfigs {
5285        fn drop(&mut self) {
5286            if let Some(value) = self._free_members.take() {
5287                unsafe {
5288                    ffi::wgpuAdapterPropertiesSubgroupMatrixConfigsFreeMembers(value)
5289                };
5290            }
5291        }
5292    }
5293    pub struct AdapterPropertiesVk {
5294        pub driver_version: Option<u32>,
5295    }
5296    impl Default for AdapterPropertiesVk {
5297        fn default() -> Self {
5298            Self { driver_version: None }
5299        }
5300    }
5301    impl AdapterPropertiesVk {
5302        pub fn new() -> Self {
5303            Self::default()
5304        }
5305        pub(crate) fn to_ffi(
5306            &self,
5307        ) -> (ffi::WGPUAdapterPropertiesVk, ChainedStructStorage) {
5308            let mut storage = ChainedStructStorage::new();
5309            let mut raw: ffi::WGPUAdapterPropertiesVk = unsafe { std::mem::zeroed() };
5310            if let Some(value) = self.driver_version {
5311                raw.driverVersion = value;
5312            }
5313            (raw, storage)
5314        }
5315        pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesVk) -> Self {
5316            Self {
5317                driver_version: Some(value.driverVersion),
5318            }
5319        }
5320    }
5321    pub struct BindGroupDescriptor {
5322        pub(crate) extensions: Vec<BindGroupDescriptorExtension>,
5323        pub label: Option<String>,
5324        pub layout: Option<BindGroupLayout>,
5325        pub entries: Option<Vec<BindGroupEntry>>,
5326    }
5327    impl Default for BindGroupDescriptor {
5328        fn default() -> Self {
5329            Self {
5330                extensions: Vec::new(),
5331                label: None,
5332                layout: None,
5333                entries: None,
5334            }
5335        }
5336    }
5337    impl BindGroupDescriptor {
5338        pub fn new() -> Self {
5339            Self::default()
5340        }
5341        pub(crate) fn to_ffi(
5342            &self,
5343        ) -> (ffi::WGPUBindGroupDescriptor, ChainedStructStorage) {
5344            let mut storage = ChainedStructStorage::new();
5345            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5346            for ext in self.extensions.iter().rev() {
5347                next = ext.push_chain(&mut storage, next);
5348            }
5349            let mut raw: ffi::WGPUBindGroupDescriptor = unsafe { std::mem::zeroed() };
5350            raw.nextInChain = next;
5351            if let Some(value) = &self.label {
5352                raw.label = ffi::WGPUStringView {
5353                    data: value.as_ptr().cast(),
5354                    length: value.len(),
5355                };
5356            } else {
5357                raw.label = ffi::WGPUStringView {
5358                    data: std::ptr::null(),
5359                    length: 0,
5360                };
5361            }
5362            raw.layout = self
5363                .layout
5364                .as_ref()
5365                .map(|v| v.as_raw())
5366                .unwrap_or(std::ptr::null_mut());
5367            raw.entryCount = self.entries.as_ref().map(|v| v.len()).unwrap_or(0);
5368            if let Some(values) = &self.entries {
5369                let len_value = values.len();
5370                let mut raw_vec: Vec<ffi::WGPUBindGroupEntry> = Vec::with_capacity(
5371                    values.len(),
5372                );
5373                for item in values.iter() {
5374                    let (raw_item, storage_item) = item.to_ffi();
5375                    raw_vec.push(raw_item);
5376                    storage.push_storage(storage_item);
5377                }
5378                let ptr = storage.push_vec(raw_vec);
5379                raw.entries = ptr;
5380                raw.entryCount = len_value;
5381            } else {
5382                raw.entries = std::ptr::null();
5383                raw.entryCount = 0;
5384            }
5385            (raw, storage)
5386        }
5387        pub fn with_extension(
5388            mut self,
5389            extension: BindGroupDescriptorExtension,
5390        ) -> Self {
5391            self.extensions.push(extension);
5392            self
5393        }
5394        pub(crate) fn from_ffi(value: ffi::WGPUBindGroupDescriptor) -> Self {
5395            Self {
5396                extensions: Vec::new(),
5397                label: if value.label.data.is_null() || value.label.length == 0 {
5398                    None
5399                } else {
5400                    Some(string_view_to_string(value.label))
5401                },
5402                layout: Some(unsafe { BindGroupLayout::from_raw(value.layout) }),
5403                entries: if value.entries.is_null() {
5404                    None
5405                } else {
5406                    Some(
5407                        unsafe {
5408                            std::slice::from_raw_parts(
5409                                value.entries,
5410                                value.entryCount as usize,
5411                            )
5412                        }
5413                            .iter()
5414                            .map(|raw| BindGroupEntry::from_ffi(*raw))
5415                            .collect(),
5416                    )
5417                },
5418            }
5419        }
5420    }
5421    pub struct BindGroupEntry {
5422        pub(crate) extensions: Vec<BindGroupEntryExtension>,
5423        pub binding: Option<u32>,
5424        pub buffer: Option<Buffer>,
5425        pub offset: Option<u64>,
5426        pub size: Option<u64>,
5427        pub sampler: Option<Sampler>,
5428        pub texture_view: Option<TextureView>,
5429    }
5430    impl Default for BindGroupEntry {
5431        fn default() -> Self {
5432            Self {
5433                extensions: Vec::new(),
5434                binding: None,
5435                buffer: None,
5436                offset: Some(0),
5437                size: Some(WHOLE_SIZE),
5438                sampler: None,
5439                texture_view: None,
5440            }
5441        }
5442    }
5443    impl BindGroupEntry {
5444        pub fn new() -> Self {
5445            Self::default()
5446        }
5447        pub(crate) fn to_ffi(&self) -> (ffi::WGPUBindGroupEntry, ChainedStructStorage) {
5448            let mut storage = ChainedStructStorage::new();
5449            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5450            for ext in self.extensions.iter().rev() {
5451                next = ext.push_chain(&mut storage, next);
5452            }
5453            let mut raw: ffi::WGPUBindGroupEntry = unsafe { std::mem::zeroed() };
5454            raw.nextInChain = next;
5455            if let Some(value) = self.binding {
5456                raw.binding = value;
5457            }
5458            raw.buffer = self
5459                .buffer
5460                .as_ref()
5461                .map(|v| v.as_raw())
5462                .unwrap_or(std::ptr::null_mut());
5463            if let Some(value) = self.offset {
5464                raw.offset = value;
5465            }
5466            if let Some(value) = self.size {
5467                raw.size = value;
5468            }
5469            raw.sampler = self
5470                .sampler
5471                .as_ref()
5472                .map(|v| v.as_raw())
5473                .unwrap_or(std::ptr::null_mut());
5474            raw.textureView = self
5475                .texture_view
5476                .as_ref()
5477                .map(|v| v.as_raw())
5478                .unwrap_or(std::ptr::null_mut());
5479            (raw, storage)
5480        }
5481        pub fn with_extension(mut self, extension: BindGroupEntryExtension) -> Self {
5482            self.extensions.push(extension);
5483            self
5484        }
5485        pub(crate) fn from_ffi(value: ffi::WGPUBindGroupEntry) -> Self {
5486            Self {
5487                extensions: Vec::new(),
5488                binding: Some(value.binding),
5489                buffer: if value.buffer.is_null() {
5490                    None
5491                } else {
5492                    Some(unsafe { Buffer::from_raw(value.buffer) })
5493                },
5494                offset: Some(value.offset),
5495                size: Some(value.size),
5496                sampler: if value.sampler.is_null() {
5497                    None
5498                } else {
5499                    Some(unsafe { Sampler::from_raw(value.sampler) })
5500                },
5501                texture_view: if value.textureView.is_null() {
5502                    None
5503                } else {
5504                    Some(unsafe { TextureView::from_raw(value.textureView) })
5505                },
5506            }
5507        }
5508    }
5509    pub struct BindGroupLayoutDescriptor {
5510        pub(crate) extensions: Vec<BindGroupLayoutDescriptorExtension>,
5511        pub label: Option<String>,
5512        pub entries: Option<Vec<BindGroupLayoutEntry>>,
5513    }
5514    impl Default for BindGroupLayoutDescriptor {
5515        fn default() -> Self {
5516            Self {
5517                extensions: Vec::new(),
5518                label: None,
5519                entries: None,
5520            }
5521        }
5522    }
5523    impl BindGroupLayoutDescriptor {
5524        pub fn new() -> Self {
5525            Self::default()
5526        }
5527        pub(crate) fn to_ffi(
5528            &self,
5529        ) -> (ffi::WGPUBindGroupLayoutDescriptor, ChainedStructStorage) {
5530            let mut storage = ChainedStructStorage::new();
5531            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5532            for ext in self.extensions.iter().rev() {
5533                next = ext.push_chain(&mut storage, next);
5534            }
5535            let mut raw: ffi::WGPUBindGroupLayoutDescriptor = unsafe {
5536                std::mem::zeroed()
5537            };
5538            raw.nextInChain = next;
5539            if let Some(value) = &self.label {
5540                raw.label = ffi::WGPUStringView {
5541                    data: value.as_ptr().cast(),
5542                    length: value.len(),
5543                };
5544            } else {
5545                raw.label = ffi::WGPUStringView {
5546                    data: std::ptr::null(),
5547                    length: 0,
5548                };
5549            }
5550            raw.entryCount = self.entries.as_ref().map(|v| v.len()).unwrap_or(0);
5551            if let Some(values) = &self.entries {
5552                let len_value = values.len();
5553                let mut raw_vec: Vec<ffi::WGPUBindGroupLayoutEntry> = Vec::with_capacity(
5554                    values.len(),
5555                );
5556                for item in values.iter() {
5557                    let (raw_item, storage_item) = item.to_ffi();
5558                    raw_vec.push(raw_item);
5559                    storage.push_storage(storage_item);
5560                }
5561                let ptr = storage.push_vec(raw_vec);
5562                raw.entries = ptr;
5563                raw.entryCount = len_value;
5564            } else {
5565                raw.entries = std::ptr::null();
5566                raw.entryCount = 0;
5567            }
5568            (raw, storage)
5569        }
5570        pub fn with_extension(
5571            mut self,
5572            extension: BindGroupLayoutDescriptorExtension,
5573        ) -> Self {
5574            self.extensions.push(extension);
5575            self
5576        }
5577        pub(crate) fn from_ffi(value: ffi::WGPUBindGroupLayoutDescriptor) -> Self {
5578            Self {
5579                extensions: Vec::new(),
5580                label: if value.label.data.is_null() || value.label.length == 0 {
5581                    None
5582                } else {
5583                    Some(string_view_to_string(value.label))
5584                },
5585                entries: if value.entries.is_null() {
5586                    None
5587                } else {
5588                    Some(
5589                        unsafe {
5590                            std::slice::from_raw_parts(
5591                                value.entries,
5592                                value.entryCount as usize,
5593                            )
5594                        }
5595                            .iter()
5596                            .map(|raw| BindGroupLayoutEntry::from_ffi(*raw))
5597                            .collect(),
5598                    )
5599                },
5600            }
5601        }
5602    }
5603    pub struct BindGroupLayoutEntry {
5604        pub(crate) extensions: Vec<BindGroupLayoutEntryExtension>,
5605        pub binding: Option<u32>,
5606        pub visibility: Option<ShaderStage>,
5607        pub binding_array_size: Option<u32>,
5608        pub buffer: Option<BufferBindingLayout>,
5609        pub sampler: Option<SamplerBindingLayout>,
5610        pub texture: Option<TextureBindingLayout>,
5611        pub storage_texture: Option<StorageTextureBindingLayout>,
5612    }
5613    impl Default for BindGroupLayoutEntry {
5614        fn default() -> Self {
5615            Self {
5616                extensions: Vec::new(),
5617                binding: None,
5618                visibility: None,
5619                binding_array_size: Some(0),
5620                buffer: None,
5621                sampler: None,
5622                texture: None,
5623                storage_texture: None,
5624            }
5625        }
5626    }
5627    impl BindGroupLayoutEntry {
5628        pub fn new() -> Self {
5629            Self::default()
5630        }
5631        pub(crate) fn to_ffi(
5632            &self,
5633        ) -> (ffi::WGPUBindGroupLayoutEntry, ChainedStructStorage) {
5634            let mut storage = ChainedStructStorage::new();
5635            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5636            for ext in self.extensions.iter().rev() {
5637                next = ext.push_chain(&mut storage, next);
5638            }
5639            let mut raw: ffi::WGPUBindGroupLayoutEntry = unsafe { std::mem::zeroed() };
5640            raw.nextInChain = next;
5641            if let Some(value) = self.binding {
5642                raw.binding = value;
5643            }
5644            if let Some(value) = self.visibility {
5645                raw.visibility = value.into();
5646            } else {
5647                raw.visibility = 0 as ffi::WGPUShaderStage;
5648            }
5649            if let Some(value) = self.binding_array_size {
5650                raw.bindingArraySize = value;
5651            }
5652            if let Some(value) = &self.buffer {
5653                let (raw_value, storage_value) = value.to_ffi();
5654                raw.buffer = raw_value;
5655                storage.push_storage(storage_value);
5656            }
5657            if let Some(value) = &self.sampler {
5658                let (raw_value, storage_value) = value.to_ffi();
5659                raw.sampler = raw_value;
5660                storage.push_storage(storage_value);
5661            }
5662            if let Some(value) = &self.texture {
5663                let (raw_value, storage_value) = value.to_ffi();
5664                raw.texture = raw_value;
5665                storage.push_storage(storage_value);
5666            }
5667            if let Some(value) = &self.storage_texture {
5668                let (raw_value, storage_value) = value.to_ffi();
5669                raw.storageTexture = raw_value;
5670                storage.push_storage(storage_value);
5671            }
5672            (raw, storage)
5673        }
5674        pub fn with_extension(
5675            mut self,
5676            extension: BindGroupLayoutEntryExtension,
5677        ) -> Self {
5678            self.extensions.push(extension);
5679            self
5680        }
5681        pub(crate) fn from_ffi(value: ffi::WGPUBindGroupLayoutEntry) -> Self {
5682            Self {
5683                extensions: Vec::new(),
5684                binding: Some(value.binding),
5685                visibility: Some(value.visibility.into()),
5686                binding_array_size: Some(value.bindingArraySize),
5687                buffer: Some(BufferBindingLayout::from_ffi(value.buffer)),
5688                sampler: Some(SamplerBindingLayout::from_ffi(value.sampler)),
5689                texture: Some(TextureBindingLayout::from_ffi(value.texture)),
5690                storage_texture: Some(
5691                    StorageTextureBindingLayout::from_ffi(value.storageTexture),
5692                ),
5693            }
5694        }
5695    }
5696    pub struct BindingResource {
5697        pub(crate) extensions: Vec<BindingResourceExtension>,
5698        pub buffer: Option<Buffer>,
5699        pub offset: Option<u64>,
5700        pub size: Option<u64>,
5701        pub sampler: Option<Sampler>,
5702        pub texture_view: Option<TextureView>,
5703    }
5704    impl Default for BindingResource {
5705        fn default() -> Self {
5706            Self {
5707                extensions: Vec::new(),
5708                buffer: None,
5709                offset: Some(0),
5710                size: Some(WHOLE_SIZE),
5711                sampler: None,
5712                texture_view: None,
5713            }
5714        }
5715    }
5716    impl BindingResource {
5717        pub fn new() -> Self {
5718            Self::default()
5719        }
5720        pub(crate) fn to_ffi(&self) -> (ffi::WGPUBindingResource, ChainedStructStorage) {
5721            let mut storage = ChainedStructStorage::new();
5722            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5723            for ext in self.extensions.iter().rev() {
5724                next = ext.push_chain(&mut storage, next);
5725            }
5726            let mut raw: ffi::WGPUBindingResource = unsafe { std::mem::zeroed() };
5727            raw.nextInChain = next;
5728            raw.buffer = self
5729                .buffer
5730                .as_ref()
5731                .map(|v| v.as_raw())
5732                .unwrap_or(std::ptr::null_mut());
5733            if let Some(value) = self.offset {
5734                raw.offset = value;
5735            }
5736            if let Some(value) = self.size {
5737                raw.size = value;
5738            }
5739            raw.sampler = self
5740                .sampler
5741                .as_ref()
5742                .map(|v| v.as_raw())
5743                .unwrap_or(std::ptr::null_mut());
5744            raw.textureView = self
5745                .texture_view
5746                .as_ref()
5747                .map(|v| v.as_raw())
5748                .unwrap_or(std::ptr::null_mut());
5749            (raw, storage)
5750        }
5751        pub fn with_extension(mut self, extension: BindingResourceExtension) -> Self {
5752            self.extensions.push(extension);
5753            self
5754        }
5755        pub(crate) fn from_ffi(value: ffi::WGPUBindingResource) -> Self {
5756            Self {
5757                extensions: Vec::new(),
5758                buffer: if value.buffer.is_null() {
5759                    None
5760                } else {
5761                    Some(unsafe { Buffer::from_raw(value.buffer) })
5762                },
5763                offset: Some(value.offset),
5764                size: Some(value.size),
5765                sampler: if value.sampler.is_null() {
5766                    None
5767                } else {
5768                    Some(unsafe { Sampler::from_raw(value.sampler) })
5769                },
5770                texture_view: if value.textureView.is_null() {
5771                    None
5772                } else {
5773                    Some(unsafe { TextureView::from_raw(value.textureView) })
5774                },
5775            }
5776        }
5777    }
5778    pub struct BlendComponent {
5779        pub operation: Option<BlendOperation>,
5780        pub src_factor: Option<BlendFactor>,
5781        pub dst_factor: Option<BlendFactor>,
5782    }
5783    impl Default for BlendComponent {
5784        fn default() -> Self {
5785            Self {
5786                operation: Some(BlendOperation::Add),
5787                src_factor: Some(BlendFactor::One),
5788                dst_factor: Some(BlendFactor::Zero),
5789            }
5790        }
5791    }
5792    impl BlendComponent {
5793        pub fn new() -> Self {
5794            Self::default()
5795        }
5796        pub(crate) fn to_ffi(&self) -> (ffi::WGPUBlendComponent, ChainedStructStorage) {
5797            let mut storage = ChainedStructStorage::new();
5798            let mut raw: ffi::WGPUBlendComponent = unsafe { std::mem::zeroed() };
5799            if let Some(value) = self.operation {
5800                raw.operation = value.into();
5801            } else {
5802                raw.operation = 0 as ffi::WGPUBlendOperation;
5803            }
5804            if let Some(value) = self.src_factor {
5805                raw.srcFactor = value.into();
5806            } else {
5807                raw.srcFactor = 0 as ffi::WGPUBlendFactor;
5808            }
5809            if let Some(value) = self.dst_factor {
5810                raw.dstFactor = value.into();
5811            } else {
5812                raw.dstFactor = 0 as ffi::WGPUBlendFactor;
5813            }
5814            (raw, storage)
5815        }
5816        pub(crate) fn from_ffi(value: ffi::WGPUBlendComponent) -> Self {
5817            Self {
5818                operation: Some(value.operation.into()),
5819                src_factor: Some(value.srcFactor.into()),
5820                dst_factor: Some(value.dstFactor.into()),
5821            }
5822        }
5823    }
5824    pub struct BlendState {
5825        pub color: Option<BlendComponent>,
5826        pub alpha: Option<BlendComponent>,
5827    }
5828    impl Default for BlendState {
5829        fn default() -> Self {
5830            Self { color: None, alpha: None }
5831        }
5832    }
5833    impl BlendState {
5834        pub fn new() -> Self {
5835            Self::default()
5836        }
5837        pub(crate) fn to_ffi(&self) -> (ffi::WGPUBlendState, ChainedStructStorage) {
5838            let mut storage = ChainedStructStorage::new();
5839            let mut raw: ffi::WGPUBlendState = unsafe { std::mem::zeroed() };
5840            if let Some(value) = &self.color {
5841                let (raw_value, storage_value) = value.to_ffi();
5842                raw.color = raw_value;
5843                storage.push_storage(storage_value);
5844            }
5845            if let Some(value) = &self.alpha {
5846                let (raw_value, storage_value) = value.to_ffi();
5847                raw.alpha = raw_value;
5848                storage.push_storage(storage_value);
5849            }
5850            (raw, storage)
5851        }
5852        pub(crate) fn from_ffi(value: ffi::WGPUBlendState) -> Self {
5853            Self {
5854                color: Some(BlendComponent::from_ffi(value.color)),
5855                alpha: Some(BlendComponent::from_ffi(value.alpha)),
5856            }
5857        }
5858    }
5859    pub struct BufferBindingLayout {
5860        pub(crate) extensions: Vec<BufferBindingLayoutExtension>,
5861        pub r#type: Option<BufferBindingType>,
5862        pub has_dynamic_offset: Option<bool>,
5863        pub min_binding_size: Option<u64>,
5864    }
5865    impl Default for BufferBindingLayout {
5866        fn default() -> Self {
5867            Self {
5868                extensions: Vec::new(),
5869                r#type: Some(BufferBindingType::Uniform),
5870                has_dynamic_offset: None,
5871                min_binding_size: Some(0),
5872            }
5873        }
5874    }
5875    impl BufferBindingLayout {
5876        pub fn new() -> Self {
5877            Self::default()
5878        }
5879        pub(crate) fn to_ffi(
5880            &self,
5881        ) -> (ffi::WGPUBufferBindingLayout, ChainedStructStorage) {
5882            let mut storage = ChainedStructStorage::new();
5883            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5884            for ext in self.extensions.iter().rev() {
5885                next = ext.push_chain(&mut storage, next);
5886            }
5887            let mut raw: ffi::WGPUBufferBindingLayout = unsafe { std::mem::zeroed() };
5888            raw.nextInChain = next;
5889            if let Some(value) = self.r#type {
5890                raw.type_ = value.into();
5891            } else {
5892                raw.type_ = 0 as ffi::WGPUBufferBindingType;
5893            }
5894            raw.hasDynamicOffset = if self.has_dynamic_offset.unwrap_or(false) {
5895                1
5896            } else {
5897                0
5898            };
5899            if let Some(value) = self.min_binding_size {
5900                raw.minBindingSize = value;
5901            }
5902            (raw, storage)
5903        }
5904        pub fn with_extension(
5905            mut self,
5906            extension: BufferBindingLayoutExtension,
5907        ) -> Self {
5908            self.extensions.push(extension);
5909            self
5910        }
5911        pub(crate) fn from_ffi(value: ffi::WGPUBufferBindingLayout) -> Self {
5912            Self {
5913                extensions: Vec::new(),
5914                r#type: Some(value.type_.into()),
5915                has_dynamic_offset: Some(value.hasDynamicOffset != 0),
5916                min_binding_size: Some(value.minBindingSize),
5917            }
5918        }
5919    }
5920    pub struct BufferDescriptor {
5921        pub(crate) extensions: Vec<BufferDescriptorExtension>,
5922        pub label: Option<String>,
5923        pub usage: Option<BufferUsage>,
5924        pub size: Option<u64>,
5925        pub mapped_at_creation: Option<bool>,
5926    }
5927    impl Default for BufferDescriptor {
5928        fn default() -> Self {
5929            Self {
5930                extensions: Vec::new(),
5931                label: None,
5932                usage: None,
5933                size: None,
5934                mapped_at_creation: None,
5935            }
5936        }
5937    }
5938    impl BufferDescriptor {
5939        pub fn new() -> Self {
5940            Self::default()
5941        }
5942        pub(crate) fn to_ffi(
5943            &self,
5944        ) -> (ffi::WGPUBufferDescriptor, ChainedStructStorage) {
5945            let mut storage = ChainedStructStorage::new();
5946            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5947            for ext in self.extensions.iter().rev() {
5948                next = ext.push_chain(&mut storage, next);
5949            }
5950            let mut raw: ffi::WGPUBufferDescriptor = unsafe { std::mem::zeroed() };
5951            raw.nextInChain = next;
5952            if let Some(value) = &self.label {
5953                raw.label = ffi::WGPUStringView {
5954                    data: value.as_ptr().cast(),
5955                    length: value.len(),
5956                };
5957            } else {
5958                raw.label = ffi::WGPUStringView {
5959                    data: std::ptr::null(),
5960                    length: 0,
5961                };
5962            }
5963            if let Some(value) = self.usage {
5964                raw.usage = value.into();
5965            } else {
5966                raw.usage = 0 as ffi::WGPUBufferUsage;
5967            }
5968            if let Some(value) = self.size {
5969                raw.size = value;
5970            }
5971            raw.mappedAtCreation = if self.mapped_at_creation.unwrap_or(false) {
5972                1
5973            } else {
5974                0
5975            };
5976            (raw, storage)
5977        }
5978        pub fn with_extension(mut self, extension: BufferDescriptorExtension) -> Self {
5979            self.extensions.push(extension);
5980            self
5981        }
5982        pub(crate) fn from_ffi(value: ffi::WGPUBufferDescriptor) -> Self {
5983            Self {
5984                extensions: Vec::new(),
5985                label: if value.label.data.is_null() || value.label.length == 0 {
5986                    None
5987                } else {
5988                    Some(string_view_to_string(value.label))
5989                },
5990                usage: Some(value.usage.into()),
5991                size: Some(value.size),
5992                mapped_at_creation: Some(value.mappedAtCreation != 0),
5993            }
5994        }
5995    }
5996    pub struct BufferHostMappedPointer {
5997        pub pointer: Option<*mut std::ffi::c_void>,
5998        pub dispose_callback: Option<Callback>,
5999        pub userdata: Option<*mut std::ffi::c_void>,
6000    }
6001    impl Default for BufferHostMappedPointer {
6002        fn default() -> Self {
6003            Self {
6004                pointer: None,
6005                dispose_callback: None,
6006                userdata: None,
6007            }
6008        }
6009    }
6010    impl BufferHostMappedPointer {
6011        pub fn new() -> Self {
6012            Self::default()
6013        }
6014        pub(crate) fn to_ffi(
6015            &self,
6016        ) -> (ffi::WGPUBufferHostMappedPointer, ChainedStructStorage) {
6017            let mut storage = ChainedStructStorage::new();
6018            let mut raw: ffi::WGPUBufferHostMappedPointer = unsafe {
6019                std::mem::zeroed()
6020            };
6021            if let Some(value) = self.pointer {
6022                raw.pointer = value;
6023            }
6024            if let Some(value) = self.dispose_callback {
6025                raw.disposeCallback = value;
6026            }
6027            if let Some(value) = self.userdata {
6028                raw.userdata = value;
6029            }
6030            (raw, storage)
6031        }
6032        pub(crate) fn from_ffi(value: ffi::WGPUBufferHostMappedPointer) -> Self {
6033            Self {
6034                pointer: Some(value.pointer),
6035                dispose_callback: Some(value.disposeCallback),
6036                userdata: Some(value.userdata),
6037            }
6038        }
6039    }
6040    pub struct Color {
6041        pub r: Option<f64>,
6042        pub g: Option<f64>,
6043        pub b: Option<f64>,
6044        pub a: Option<f64>,
6045    }
6046    impl Default for Color {
6047        fn default() -> Self {
6048            Self {
6049                r: None,
6050                g: None,
6051                b: None,
6052                a: None,
6053            }
6054        }
6055    }
6056    impl Color {
6057        pub fn new() -> Self {
6058            Self::default()
6059        }
6060        pub(crate) fn to_ffi(&self) -> (ffi::WGPUColor, ChainedStructStorage) {
6061            let mut storage = ChainedStructStorage::new();
6062            let mut raw: ffi::WGPUColor = unsafe { std::mem::zeroed() };
6063            if let Some(value) = self.r {
6064                raw.r = value;
6065            }
6066            if let Some(value) = self.g {
6067                raw.g = value;
6068            }
6069            if let Some(value) = self.b {
6070                raw.b = value;
6071            }
6072            if let Some(value) = self.a {
6073                raw.a = value;
6074            }
6075            (raw, storage)
6076        }
6077        pub(crate) fn from_ffi(value: ffi::WGPUColor) -> Self {
6078            Self {
6079                r: Some(value.r),
6080                g: Some(value.g),
6081                b: Some(value.b),
6082                a: Some(value.a),
6083            }
6084        }
6085    }
6086    pub struct ColorTargetState {
6087        pub(crate) extensions: Vec<ColorTargetStateExtension>,
6088        pub format: Option<TextureFormat>,
6089        pub blend: Option<BlendState>,
6090        pub write_mask: Option<ColorWriteMask>,
6091    }
6092    impl Default for ColorTargetState {
6093        fn default() -> Self {
6094            Self {
6095                extensions: Vec::new(),
6096                format: None,
6097                blend: None,
6098                write_mask: Some(ColorWriteMask::ALL),
6099            }
6100        }
6101    }
6102    impl ColorTargetState {
6103        pub fn new() -> Self {
6104            Self::default()
6105        }
6106        pub(crate) fn to_ffi(
6107            &self,
6108        ) -> (ffi::WGPUColorTargetState, ChainedStructStorage) {
6109            let mut storage = ChainedStructStorage::new();
6110            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6111            for ext in self.extensions.iter().rev() {
6112                next = ext.push_chain(&mut storage, next);
6113            }
6114            let mut raw: ffi::WGPUColorTargetState = unsafe { std::mem::zeroed() };
6115            raw.nextInChain = next;
6116            if let Some(value) = self.format {
6117                raw.format = value.into();
6118            } else {
6119                raw.format = 0 as ffi::WGPUTextureFormat;
6120            }
6121            if let Some(value) = &self.blend {
6122                let (raw_value, storage_value) = value.to_ffi();
6123                let ptr = storage.push_value(raw_value);
6124                raw.blend = ptr;
6125                storage.push_storage(storage_value);
6126            } else {
6127                raw.blend = std::ptr::null();
6128            }
6129            if let Some(value) = self.write_mask {
6130                raw.writeMask = value.into();
6131            } else {
6132                raw.writeMask = 0 as ffi::WGPUColorWriteMask;
6133            }
6134            (raw, storage)
6135        }
6136        pub fn with_extension(mut self, extension: ColorTargetStateExtension) -> Self {
6137            self.extensions.push(extension);
6138            self
6139        }
6140        pub(crate) fn from_ffi(value: ffi::WGPUColorTargetState) -> Self {
6141            Self {
6142                extensions: Vec::new(),
6143                format: Some(value.format.into()),
6144                blend: if value.blend.is_null() {
6145                    None
6146                } else {
6147                    Some(BlendState::from_ffi(unsafe { *value.blend }))
6148                },
6149                write_mask: Some(value.writeMask.into()),
6150            }
6151        }
6152    }
6153    pub struct ColorTargetStateExpandResolveTextureDawn {
6154        pub enabled: Option<bool>,
6155    }
6156    impl Default for ColorTargetStateExpandResolveTextureDawn {
6157        fn default() -> Self {
6158            Self { enabled: None }
6159        }
6160    }
6161    impl ColorTargetStateExpandResolveTextureDawn {
6162        pub fn new() -> Self {
6163            Self::default()
6164        }
6165        pub(crate) fn to_ffi(
6166            &self,
6167        ) -> (ffi::WGPUColorTargetStateExpandResolveTextureDawn, ChainedStructStorage) {
6168            let mut storage = ChainedStructStorage::new();
6169            let mut raw: ffi::WGPUColorTargetStateExpandResolveTextureDawn = unsafe {
6170                std::mem::zeroed()
6171            };
6172            raw.enabled = if self.enabled.unwrap_or(false) { 1 } else { 0 };
6173            (raw, storage)
6174        }
6175        pub(crate) fn from_ffi(
6176            value: ffi::WGPUColorTargetStateExpandResolveTextureDawn,
6177        ) -> Self {
6178            Self {
6179                enabled: Some(value.enabled != 0),
6180            }
6181        }
6182    }
6183    pub struct CommandBufferDescriptor {
6184        pub(crate) extensions: Vec<CommandBufferDescriptorExtension>,
6185        pub label: Option<String>,
6186    }
6187    impl Default for CommandBufferDescriptor {
6188        fn default() -> Self {
6189            Self {
6190                extensions: Vec::new(),
6191                label: None,
6192            }
6193        }
6194    }
6195    impl CommandBufferDescriptor {
6196        pub fn new() -> Self {
6197            Self::default()
6198        }
6199        pub(crate) fn to_ffi(
6200            &self,
6201        ) -> (ffi::WGPUCommandBufferDescriptor, ChainedStructStorage) {
6202            let mut storage = ChainedStructStorage::new();
6203            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6204            for ext in self.extensions.iter().rev() {
6205                next = ext.push_chain(&mut storage, next);
6206            }
6207            let mut raw: ffi::WGPUCommandBufferDescriptor = unsafe {
6208                std::mem::zeroed()
6209            };
6210            raw.nextInChain = next;
6211            if let Some(value) = &self.label {
6212                raw.label = ffi::WGPUStringView {
6213                    data: value.as_ptr().cast(),
6214                    length: value.len(),
6215                };
6216            } else {
6217                raw.label = ffi::WGPUStringView {
6218                    data: std::ptr::null(),
6219                    length: 0,
6220                };
6221            }
6222            (raw, storage)
6223        }
6224        pub fn with_extension(
6225            mut self,
6226            extension: CommandBufferDescriptorExtension,
6227        ) -> Self {
6228            self.extensions.push(extension);
6229            self
6230        }
6231        pub(crate) fn from_ffi(value: ffi::WGPUCommandBufferDescriptor) -> Self {
6232            Self {
6233                extensions: Vec::new(),
6234                label: if value.label.data.is_null() || value.label.length == 0 {
6235                    None
6236                } else {
6237                    Some(string_view_to_string(value.label))
6238                },
6239            }
6240        }
6241    }
6242    pub struct CommandEncoderDescriptor {
6243        pub(crate) extensions: Vec<CommandEncoderDescriptorExtension>,
6244        pub label: Option<String>,
6245    }
6246    impl Default for CommandEncoderDescriptor {
6247        fn default() -> Self {
6248            Self {
6249                extensions: Vec::new(),
6250                label: None,
6251            }
6252        }
6253    }
6254    impl CommandEncoderDescriptor {
6255        pub fn new() -> Self {
6256            Self::default()
6257        }
6258        pub(crate) fn to_ffi(
6259            &self,
6260        ) -> (ffi::WGPUCommandEncoderDescriptor, ChainedStructStorage) {
6261            let mut storage = ChainedStructStorage::new();
6262            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6263            for ext in self.extensions.iter().rev() {
6264                next = ext.push_chain(&mut storage, next);
6265            }
6266            let mut raw: ffi::WGPUCommandEncoderDescriptor = unsafe {
6267                std::mem::zeroed()
6268            };
6269            raw.nextInChain = next;
6270            if let Some(value) = &self.label {
6271                raw.label = ffi::WGPUStringView {
6272                    data: value.as_ptr().cast(),
6273                    length: value.len(),
6274                };
6275            } else {
6276                raw.label = ffi::WGPUStringView {
6277                    data: std::ptr::null(),
6278                    length: 0,
6279                };
6280            }
6281            (raw, storage)
6282        }
6283        pub fn with_extension(
6284            mut self,
6285            extension: CommandEncoderDescriptorExtension,
6286        ) -> Self {
6287            self.extensions.push(extension);
6288            self
6289        }
6290        pub(crate) fn from_ffi(value: ffi::WGPUCommandEncoderDescriptor) -> Self {
6291            Self {
6292                extensions: Vec::new(),
6293                label: if value.label.data.is_null() || value.label.length == 0 {
6294                    None
6295                } else {
6296                    Some(string_view_to_string(value.label))
6297                },
6298            }
6299        }
6300    }
6301    pub struct CompilationInfo {
6302        pub(crate) extensions: Vec<CompilationInfoExtension>,
6303        pub messages: Option<Vec<CompilationMessage>>,
6304    }
6305    impl Default for CompilationInfo {
6306        fn default() -> Self {
6307            Self {
6308                extensions: Vec::new(),
6309                messages: None,
6310            }
6311        }
6312    }
6313    impl CompilationInfo {
6314        pub fn new() -> Self {
6315            Self::default()
6316        }
6317        pub(crate) fn to_ffi(&self) -> (ffi::WGPUCompilationInfo, ChainedStructStorage) {
6318            let mut storage = ChainedStructStorage::new();
6319            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6320            for ext in self.extensions.iter().rev() {
6321                next = ext.push_chain(&mut storage, next);
6322            }
6323            let mut raw: ffi::WGPUCompilationInfo = unsafe { std::mem::zeroed() };
6324            raw.nextInChain = next;
6325            raw.messageCount = self.messages.as_ref().map(|v| v.len()).unwrap_or(0);
6326            if let Some(values) = &self.messages {
6327                let len_value = values.len();
6328                let mut raw_vec: Vec<ffi::WGPUCompilationMessage> = Vec::with_capacity(
6329                    values.len(),
6330                );
6331                for item in values.iter() {
6332                    let (raw_item, storage_item) = item.to_ffi();
6333                    raw_vec.push(raw_item);
6334                    storage.push_storage(storage_item);
6335                }
6336                let ptr = storage.push_vec(raw_vec);
6337                raw.messages = ptr;
6338                raw.messageCount = len_value;
6339            } else {
6340                raw.messages = std::ptr::null();
6341                raw.messageCount = 0;
6342            }
6343            (raw, storage)
6344        }
6345        pub fn with_extension(mut self, extension: CompilationInfoExtension) -> Self {
6346            self.extensions.push(extension);
6347            self
6348        }
6349        pub(crate) fn from_ffi(value: ffi::WGPUCompilationInfo) -> Self {
6350            Self {
6351                extensions: Vec::new(),
6352                messages: if value.messages.is_null() {
6353                    None
6354                } else {
6355                    Some(
6356                        unsafe {
6357                            std::slice::from_raw_parts(
6358                                value.messages,
6359                                value.messageCount as usize,
6360                            )
6361                        }
6362                            .iter()
6363                            .map(|raw| CompilationMessage::from_ffi(*raw))
6364                            .collect(),
6365                    )
6366                },
6367            }
6368        }
6369    }
6370    pub struct CompilationMessage {
6371        pub(crate) extensions: Vec<CompilationMessageExtension>,
6372        pub message: Option<String>,
6373        pub r#type: Option<CompilationMessageType>,
6374        pub line_num: Option<u64>,
6375        pub line_pos: Option<u64>,
6376        pub offset: Option<u64>,
6377        pub length: Option<u64>,
6378    }
6379    impl Default for CompilationMessage {
6380        fn default() -> Self {
6381            Self {
6382                extensions: Vec::new(),
6383                message: None,
6384                r#type: None,
6385                line_num: None,
6386                line_pos: None,
6387                offset: None,
6388                length: None,
6389            }
6390        }
6391    }
6392    impl CompilationMessage {
6393        pub fn new() -> Self {
6394            Self::default()
6395        }
6396        pub(crate) fn to_ffi(
6397            &self,
6398        ) -> (ffi::WGPUCompilationMessage, ChainedStructStorage) {
6399            let mut storage = ChainedStructStorage::new();
6400            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6401            for ext in self.extensions.iter().rev() {
6402                next = ext.push_chain(&mut storage, next);
6403            }
6404            let mut raw: ffi::WGPUCompilationMessage = unsafe { std::mem::zeroed() };
6405            raw.nextInChain = next;
6406            if let Some(value) = &self.message {
6407                raw.message = ffi::WGPUStringView {
6408                    data: value.as_ptr().cast(),
6409                    length: value.len(),
6410                };
6411            } else {
6412                raw.message = ffi::WGPUStringView {
6413                    data: std::ptr::null(),
6414                    length: 0,
6415                };
6416            }
6417            if let Some(value) = self.r#type {
6418                raw.type_ = value.into();
6419            } else {
6420                raw.type_ = 0 as ffi::WGPUCompilationMessageType;
6421            }
6422            if let Some(value) = self.line_num {
6423                raw.lineNum = value;
6424            }
6425            if let Some(value) = self.line_pos {
6426                raw.linePos = value;
6427            }
6428            if let Some(value) = self.offset {
6429                raw.offset = value;
6430            }
6431            if let Some(value) = self.length {
6432                raw.length = value;
6433            }
6434            (raw, storage)
6435        }
6436        pub fn with_extension(mut self, extension: CompilationMessageExtension) -> Self {
6437            self.extensions.push(extension);
6438            self
6439        }
6440        pub(crate) fn from_ffi(value: ffi::WGPUCompilationMessage) -> Self {
6441            Self {
6442                extensions: Vec::new(),
6443                message: Some(string_view_to_string(value.message)),
6444                r#type: Some(value.type_.into()),
6445                line_num: Some(value.lineNum),
6446                line_pos: Some(value.linePos),
6447                offset: Some(value.offset),
6448                length: Some(value.length),
6449            }
6450        }
6451    }
6452    pub struct ComputePassDescriptor {
6453        pub(crate) extensions: Vec<ComputePassDescriptorExtension>,
6454        pub label: Option<String>,
6455        pub timestamp_writes: Option<PassTimestampWrites>,
6456    }
6457    impl Default for ComputePassDescriptor {
6458        fn default() -> Self {
6459            Self {
6460                extensions: Vec::new(),
6461                label: None,
6462                timestamp_writes: None,
6463            }
6464        }
6465    }
6466    impl ComputePassDescriptor {
6467        pub fn new() -> Self {
6468            Self::default()
6469        }
6470        pub(crate) fn to_ffi(
6471            &self,
6472        ) -> (ffi::WGPUComputePassDescriptor, ChainedStructStorage) {
6473            let mut storage = ChainedStructStorage::new();
6474            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6475            for ext in self.extensions.iter().rev() {
6476                next = ext.push_chain(&mut storage, next);
6477            }
6478            let mut raw: ffi::WGPUComputePassDescriptor = unsafe { std::mem::zeroed() };
6479            raw.nextInChain = next;
6480            if let Some(value) = &self.label {
6481                raw.label = ffi::WGPUStringView {
6482                    data: value.as_ptr().cast(),
6483                    length: value.len(),
6484                };
6485            } else {
6486                raw.label = ffi::WGPUStringView {
6487                    data: std::ptr::null(),
6488                    length: 0,
6489                };
6490            }
6491            if let Some(value) = &self.timestamp_writes {
6492                let (raw_value, storage_value) = value.to_ffi();
6493                let ptr = storage.push_value(raw_value);
6494                raw.timestampWrites = ptr;
6495                storage.push_storage(storage_value);
6496            } else {
6497                raw.timestampWrites = std::ptr::null();
6498            }
6499            (raw, storage)
6500        }
6501        pub fn with_extension(
6502            mut self,
6503            extension: ComputePassDescriptorExtension,
6504        ) -> Self {
6505            self.extensions.push(extension);
6506            self
6507        }
6508        pub(crate) fn from_ffi(value: ffi::WGPUComputePassDescriptor) -> Self {
6509            Self {
6510                extensions: Vec::new(),
6511                label: if value.label.data.is_null() || value.label.length == 0 {
6512                    None
6513                } else {
6514                    Some(string_view_to_string(value.label))
6515                },
6516                timestamp_writes: if value.timestampWrites.is_null() {
6517                    None
6518                } else {
6519                    Some(
6520                        PassTimestampWrites::from_ffi(unsafe { *value.timestampWrites }),
6521                    )
6522                },
6523            }
6524        }
6525    }
6526    pub struct ComputePipelineDescriptor {
6527        pub(crate) extensions: Vec<ComputePipelineDescriptorExtension>,
6528        pub label: Option<String>,
6529        pub layout: Option<PipelineLayout>,
6530        pub compute: Option<ComputeState>,
6531    }
6532    impl Default for ComputePipelineDescriptor {
6533        fn default() -> Self {
6534            Self {
6535                extensions: Vec::new(),
6536                label: None,
6537                layout: None,
6538                compute: None,
6539            }
6540        }
6541    }
6542    impl ComputePipelineDescriptor {
6543        pub fn new() -> Self {
6544            Self::default()
6545        }
6546        pub(crate) fn to_ffi(
6547            &self,
6548        ) -> (ffi::WGPUComputePipelineDescriptor, ChainedStructStorage) {
6549            let mut storage = ChainedStructStorage::new();
6550            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6551            for ext in self.extensions.iter().rev() {
6552                next = ext.push_chain(&mut storage, next);
6553            }
6554            let mut raw: ffi::WGPUComputePipelineDescriptor = unsafe {
6555                std::mem::zeroed()
6556            };
6557            raw.nextInChain = next;
6558            if let Some(value) = &self.label {
6559                raw.label = ffi::WGPUStringView {
6560                    data: value.as_ptr().cast(),
6561                    length: value.len(),
6562                };
6563            } else {
6564                raw.label = ffi::WGPUStringView {
6565                    data: std::ptr::null(),
6566                    length: 0,
6567                };
6568            }
6569            raw.layout = self
6570                .layout
6571                .as_ref()
6572                .map(|v| v.as_raw())
6573                .unwrap_or(std::ptr::null_mut());
6574            if let Some(value) = &self.compute {
6575                let (raw_value, storage_value) = value.to_ffi();
6576                raw.compute = raw_value;
6577                storage.push_storage(storage_value);
6578            }
6579            (raw, storage)
6580        }
6581        pub fn with_extension(
6582            mut self,
6583            extension: ComputePipelineDescriptorExtension,
6584        ) -> Self {
6585            self.extensions.push(extension);
6586            self
6587        }
6588        pub(crate) fn from_ffi(value: ffi::WGPUComputePipelineDescriptor) -> Self {
6589            Self {
6590                extensions: Vec::new(),
6591                label: if value.label.data.is_null() || value.label.length == 0 {
6592                    None
6593                } else {
6594                    Some(string_view_to_string(value.label))
6595                },
6596                layout: if value.layout.is_null() {
6597                    None
6598                } else {
6599                    Some(unsafe { PipelineLayout::from_raw(value.layout) })
6600                },
6601                compute: Some(ComputeState::from_ffi(value.compute)),
6602            }
6603        }
6604    }
6605    pub struct ComputeState {
6606        pub(crate) extensions: Vec<ComputeStateExtension>,
6607        pub module: Option<ShaderModule>,
6608        pub entry_point: Option<String>,
6609        pub constants: Option<Vec<ConstantEntry>>,
6610    }
6611    impl Default for ComputeState {
6612        fn default() -> Self {
6613            Self {
6614                extensions: Vec::new(),
6615                module: None,
6616                entry_point: None,
6617                constants: None,
6618            }
6619        }
6620    }
6621    impl ComputeState {
6622        pub fn new() -> Self {
6623            Self::default()
6624        }
6625        pub(crate) fn to_ffi(&self) -> (ffi::WGPUComputeState, ChainedStructStorage) {
6626            let mut storage = ChainedStructStorage::new();
6627            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6628            for ext in self.extensions.iter().rev() {
6629                next = ext.push_chain(&mut storage, next);
6630            }
6631            let mut raw: ffi::WGPUComputeState = unsafe { std::mem::zeroed() };
6632            raw.nextInChain = next;
6633            raw.module = self
6634                .module
6635                .as_ref()
6636                .map(|v| v.as_raw())
6637                .unwrap_or(std::ptr::null_mut());
6638            if let Some(value) = &self.entry_point {
6639                raw.entryPoint = ffi::WGPUStringView {
6640                    data: value.as_ptr().cast(),
6641                    length: value.len(),
6642                };
6643            } else {
6644                raw.entryPoint = ffi::WGPUStringView {
6645                    data: std::ptr::null(),
6646                    length: 0,
6647                };
6648            }
6649            raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
6650            if let Some(values) = &self.constants {
6651                let len_value = values.len();
6652                let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
6653                    values.len(),
6654                );
6655                for item in values.iter() {
6656                    let (raw_item, storage_item) = item.to_ffi();
6657                    raw_vec.push(raw_item);
6658                    storage.push_storage(storage_item);
6659                }
6660                let ptr = storage.push_vec(raw_vec);
6661                raw.constants = ptr;
6662                raw.constantCount = len_value;
6663            } else {
6664                raw.constants = std::ptr::null();
6665                raw.constantCount = 0;
6666            }
6667            (raw, storage)
6668        }
6669        pub fn with_extension(mut self, extension: ComputeStateExtension) -> Self {
6670            self.extensions.push(extension);
6671            self
6672        }
6673        pub(crate) fn from_ffi(value: ffi::WGPUComputeState) -> Self {
6674            Self {
6675                extensions: Vec::new(),
6676                module: Some(unsafe { ShaderModule::from_raw(value.module) }),
6677                entry_point: if value.entryPoint.data.is_null()
6678                    || value.entryPoint.length == 0
6679                {
6680                    None
6681                } else {
6682                    Some(string_view_to_string(value.entryPoint))
6683                },
6684                constants: if value.constants.is_null() {
6685                    None
6686                } else {
6687                    Some(
6688                        unsafe {
6689                            std::slice::from_raw_parts(
6690                                value.constants,
6691                                value.constantCount as usize,
6692                            )
6693                        }
6694                            .iter()
6695                            .map(|raw| ConstantEntry::from_ffi(*raw))
6696                            .collect(),
6697                    )
6698                },
6699            }
6700        }
6701    }
6702    pub struct ConstantEntry {
6703        pub(crate) extensions: Vec<ConstantEntryExtension>,
6704        pub key: Option<String>,
6705        pub value: Option<f64>,
6706    }
6707    impl Default for ConstantEntry {
6708        fn default() -> Self {
6709            Self {
6710                extensions: Vec::new(),
6711                key: None,
6712                value: None,
6713            }
6714        }
6715    }
6716    impl ConstantEntry {
6717        pub fn new() -> Self {
6718            Self::default()
6719        }
6720        pub(crate) fn to_ffi(&self) -> (ffi::WGPUConstantEntry, ChainedStructStorage) {
6721            let mut storage = ChainedStructStorage::new();
6722            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6723            for ext in self.extensions.iter().rev() {
6724                next = ext.push_chain(&mut storage, next);
6725            }
6726            let mut raw: ffi::WGPUConstantEntry = unsafe { std::mem::zeroed() };
6727            raw.nextInChain = next;
6728            if let Some(value) = &self.key {
6729                raw.key = ffi::WGPUStringView {
6730                    data: value.as_ptr().cast(),
6731                    length: value.len(),
6732                };
6733            } else {
6734                raw.key = ffi::WGPUStringView {
6735                    data: std::ptr::null(),
6736                    length: 0,
6737                };
6738            }
6739            if let Some(value) = self.value {
6740                raw.value = value;
6741            }
6742            (raw, storage)
6743        }
6744        pub fn with_extension(mut self, extension: ConstantEntryExtension) -> Self {
6745            self.extensions.push(extension);
6746            self
6747        }
6748        pub(crate) fn from_ffi(value: ffi::WGPUConstantEntry) -> Self {
6749            Self {
6750                extensions: Vec::new(),
6751                key: Some(string_view_to_string(value.key)),
6752                value: Some(value.value),
6753            }
6754        }
6755    }
6756    pub struct CopyTextureForBrowserOptions {
6757        pub(crate) extensions: Vec<CopyTextureForBrowserOptionsExtension>,
6758        pub flip_y: Option<bool>,
6759        pub needs_color_space_conversion: Option<bool>,
6760        pub src_alpha_mode: Option<AlphaMode>,
6761        pub src_transfer_function_parameters: Option<Vec<f32>>,
6762        pub conversion_matrix: Option<Vec<f32>>,
6763        pub dst_transfer_function_parameters: Option<Vec<f32>>,
6764        pub dst_alpha_mode: Option<AlphaMode>,
6765        pub internal_usage: Option<bool>,
6766    }
6767    impl Default for CopyTextureForBrowserOptions {
6768        fn default() -> Self {
6769            Self {
6770                extensions: Vec::new(),
6771                flip_y: None,
6772                needs_color_space_conversion: None,
6773                src_alpha_mode: Some(AlphaMode::Unpremultiplied),
6774                src_transfer_function_parameters: None,
6775                conversion_matrix: None,
6776                dst_transfer_function_parameters: None,
6777                dst_alpha_mode: Some(AlphaMode::Unpremultiplied),
6778                internal_usage: None,
6779            }
6780        }
6781    }
6782    impl CopyTextureForBrowserOptions {
6783        pub fn new() -> Self {
6784            Self::default()
6785        }
6786        pub(crate) fn to_ffi(
6787            &self,
6788        ) -> (ffi::WGPUCopyTextureForBrowserOptions, ChainedStructStorage) {
6789            let mut storage = ChainedStructStorage::new();
6790            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6791            for ext in self.extensions.iter().rev() {
6792                next = ext.push_chain(&mut storage, next);
6793            }
6794            let mut raw: ffi::WGPUCopyTextureForBrowserOptions = unsafe {
6795                std::mem::zeroed()
6796            };
6797            raw.nextInChain = next;
6798            raw.flipY = if self.flip_y.unwrap_or(false) { 1 } else { 0 };
6799            raw.needsColorSpaceConversion = if self
6800                .needs_color_space_conversion
6801                .unwrap_or(false)
6802            {
6803                1
6804            } else {
6805                0
6806            };
6807            if let Some(value) = self.src_alpha_mode {
6808                raw.srcAlphaMode = value.into();
6809            } else {
6810                raw.srcAlphaMode = 0 as ffi::WGPUAlphaMode;
6811            }
6812            if let Some(values) = &self.src_transfer_function_parameters {
6813                let len_value = values.len();
6814                let raw_vec = values.to_vec();
6815                let ptr = storage.push_vec(raw_vec);
6816                raw.srcTransferFunctionParameters = ptr;
6817            } else {
6818                raw.srcTransferFunctionParameters = std::ptr::null();
6819                let _ = 0;
6820            }
6821            if let Some(values) = &self.conversion_matrix {
6822                let len_value = values.len();
6823                let raw_vec = values.to_vec();
6824                let ptr = storage.push_vec(raw_vec);
6825                raw.conversionMatrix = ptr;
6826            } else {
6827                raw.conversionMatrix = std::ptr::null();
6828                let _ = 0;
6829            }
6830            if let Some(values) = &self.dst_transfer_function_parameters {
6831                let len_value = values.len();
6832                let raw_vec = values.to_vec();
6833                let ptr = storage.push_vec(raw_vec);
6834                raw.dstTransferFunctionParameters = ptr;
6835            } else {
6836                raw.dstTransferFunctionParameters = std::ptr::null();
6837                let _ = 0;
6838            }
6839            if let Some(value) = self.dst_alpha_mode {
6840                raw.dstAlphaMode = value.into();
6841            } else {
6842                raw.dstAlphaMode = 0 as ffi::WGPUAlphaMode;
6843            }
6844            raw.internalUsage = if self.internal_usage.unwrap_or(false) { 1 } else { 0 };
6845            (raw, storage)
6846        }
6847        pub fn with_extension(
6848            mut self,
6849            extension: CopyTextureForBrowserOptionsExtension,
6850        ) -> Self {
6851            self.extensions.push(extension);
6852            self
6853        }
6854        pub(crate) fn from_ffi(value: ffi::WGPUCopyTextureForBrowserOptions) -> Self {
6855            Self {
6856                extensions: Vec::new(),
6857                flip_y: Some(value.flipY != 0),
6858                needs_color_space_conversion: Some(value.needsColorSpaceConversion != 0),
6859                src_alpha_mode: Some(value.srcAlphaMode.into()),
6860                src_transfer_function_parameters: if value
6861                    .srcTransferFunctionParameters
6862                    .is_null()
6863                {
6864                    None
6865                } else {
6866                    Some(
6867                        unsafe {
6868                            std::slice::from_raw_parts(
6869                                value.srcTransferFunctionParameters,
6870                                7usize,
6871                            )
6872                        }
6873                            .to_vec(),
6874                    )
6875                },
6876                conversion_matrix: if value.conversionMatrix.is_null() {
6877                    None
6878                } else {
6879                    Some(
6880                        unsafe {
6881                            std::slice::from_raw_parts(value.conversionMatrix, 9usize)
6882                        }
6883                            .to_vec(),
6884                    )
6885                },
6886                dst_transfer_function_parameters: if value
6887                    .dstTransferFunctionParameters
6888                    .is_null()
6889                {
6890                    None
6891                } else {
6892                    Some(
6893                        unsafe {
6894                            std::slice::from_raw_parts(
6895                                value.dstTransferFunctionParameters,
6896                                7usize,
6897                            )
6898                        }
6899                            .to_vec(),
6900                    )
6901                },
6902                dst_alpha_mode: Some(value.dstAlphaMode.into()),
6903                internal_usage: Some(value.internalUsage != 0),
6904            }
6905        }
6906    }
6907    pub struct DawnWGSLBlocklist {
6908        pub blocklisted_features: Option<Vec<String>>,
6909    }
6910    impl Default for DawnWGSLBlocklist {
6911        fn default() -> Self {
6912            Self { blocklisted_features: None }
6913        }
6914    }
6915    impl DawnWGSLBlocklist {
6916        pub fn new() -> Self {
6917            Self::default()
6918        }
6919        pub(crate) fn to_ffi(
6920            &self,
6921        ) -> (ffi::WGPUDawnWGSLBlocklist, ChainedStructStorage) {
6922            let mut storage = ChainedStructStorage::new();
6923            let mut raw: ffi::WGPUDawnWGSLBlocklist = unsafe { std::mem::zeroed() };
6924            raw.blocklistedFeatureCount = self
6925                .blocklisted_features
6926                .as_ref()
6927                .map(|v| v.len())
6928                .unwrap_or(0);
6929            if let Some(values) = &self.blocklisted_features {
6930                let len_value = values.len();
6931                let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
6932                    values.len(),
6933                );
6934                let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
6935                    values.len(),
6936                );
6937                for item in values.iter() {
6938                    let c_string = std::ffi::CString::new(item.as_str())
6939                        .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
6940                    ptrs.push(c_string.as_ptr());
6941                    c_strings.push(c_string);
6942                }
6943                let ptr = storage.push_vec(ptrs);
6944                storage.push_any(c_strings);
6945                raw.blocklistedFeatures = ptr;
6946                raw.blocklistedFeatureCount = len_value;
6947            } else {
6948                raw.blocklistedFeatures = std::ptr::null();
6949                raw.blocklistedFeatureCount = 0;
6950            }
6951            (raw, storage)
6952        }
6953        pub(crate) fn from_ffi(value: ffi::WGPUDawnWGSLBlocklist) -> Self {
6954            Self {
6955                blocklisted_features: if value.blocklistedFeatures.is_null() {
6956                    None
6957                } else {
6958                    Some(
6959                        unsafe {
6960                            std::slice::from_raw_parts(
6961                                value.blocklistedFeatures,
6962                                value.blocklistedFeatureCount as usize,
6963                            )
6964                        }
6965                            .iter()
6966                            .map(|raw| {
6967                                if raw.is_null() {
6968                                    String::new()
6969                                } else {
6970                                    unsafe { CStr::from_ptr(*raw) }
6971                                        .to_string_lossy()
6972                                        .into_owned()
6973                                }
6974                            })
6975                            .collect(),
6976                    )
6977                },
6978            }
6979        }
6980    }
6981    pub struct DawnAdapterPropertiesPowerPreference {
6982        pub power_preference: Option<PowerPreference>,
6983    }
6984    impl Default for DawnAdapterPropertiesPowerPreference {
6985        fn default() -> Self {
6986            Self { power_preference: None }
6987        }
6988    }
6989    impl DawnAdapterPropertiesPowerPreference {
6990        pub fn new() -> Self {
6991            Self::default()
6992        }
6993        pub(crate) fn to_ffi(
6994            &self,
6995        ) -> (ffi::WGPUDawnAdapterPropertiesPowerPreference, ChainedStructStorage) {
6996            let mut storage = ChainedStructStorage::new();
6997            let mut raw: ffi::WGPUDawnAdapterPropertiesPowerPreference = unsafe {
6998                std::mem::zeroed()
6999            };
7000            if let Some(value) = self.power_preference {
7001                raw.powerPreference = value.into();
7002            } else {
7003                raw.powerPreference = 0 as ffi::WGPUPowerPreference;
7004            }
7005            (raw, storage)
7006        }
7007        pub(crate) fn from_ffi(
7008            value: ffi::WGPUDawnAdapterPropertiesPowerPreference,
7009        ) -> Self {
7010            Self {
7011                power_preference: Some(value.powerPreference.into()),
7012            }
7013        }
7014    }
7015    pub struct DawnBufferDescriptorErrorInfoFromWireClient {
7016        pub out_of_memory: Option<bool>,
7017    }
7018    impl Default for DawnBufferDescriptorErrorInfoFromWireClient {
7019        fn default() -> Self {
7020            Self { out_of_memory: None }
7021        }
7022    }
7023    impl DawnBufferDescriptorErrorInfoFromWireClient {
7024        pub fn new() -> Self {
7025            Self::default()
7026        }
7027        pub(crate) fn to_ffi(
7028            &self,
7029        ) -> (
7030            ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient,
7031            ChainedStructStorage,
7032        ) {
7033            let mut storage = ChainedStructStorage::new();
7034            let mut raw: ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient = unsafe {
7035                std::mem::zeroed()
7036            };
7037            raw.outOfMemory = if self.out_of_memory.unwrap_or(false) { 1 } else { 0 };
7038            (raw, storage)
7039        }
7040        pub(crate) fn from_ffi(
7041            value: ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient,
7042        ) -> Self {
7043            Self {
7044                out_of_memory: Some(value.outOfMemory != 0),
7045            }
7046        }
7047    }
7048    pub struct DawnCacheDeviceDescriptor {
7049        pub isolation_key: Option<String>,
7050        pub load_data_function: Option<DawnLoadCacheDataFunction>,
7051        pub store_data_function: Option<DawnStoreCacheDataFunction>,
7052        pub function_userdata: Option<*mut std::ffi::c_void>,
7053    }
7054    impl Default for DawnCacheDeviceDescriptor {
7055        fn default() -> Self {
7056            Self {
7057                isolation_key: None,
7058                load_data_function: None,
7059                store_data_function: None,
7060                function_userdata: None,
7061            }
7062        }
7063    }
7064    impl DawnCacheDeviceDescriptor {
7065        pub fn new() -> Self {
7066            Self::default()
7067        }
7068        pub(crate) fn to_ffi(
7069            &self,
7070        ) -> (ffi::WGPUDawnCacheDeviceDescriptor, ChainedStructStorage) {
7071            let mut storage = ChainedStructStorage::new();
7072            let mut raw: ffi::WGPUDawnCacheDeviceDescriptor = unsafe {
7073                std::mem::zeroed()
7074            };
7075            if let Some(value) = &self.isolation_key {
7076                raw.isolationKey = ffi::WGPUStringView {
7077                    data: value.as_ptr().cast(),
7078                    length: value.len(),
7079                };
7080            } else {
7081                raw.isolationKey = ffi::WGPUStringView {
7082                    data: std::ptr::null(),
7083                    length: 0,
7084                };
7085            }
7086            if let Some(value) = self.load_data_function {
7087                raw.loadDataFunction = value;
7088            }
7089            if let Some(value) = self.store_data_function {
7090                raw.storeDataFunction = value;
7091            }
7092            if let Some(value) = self.function_userdata {
7093                raw.functionUserdata = value;
7094            }
7095            (raw, storage)
7096        }
7097        pub(crate) fn from_ffi(value: ffi::WGPUDawnCacheDeviceDescriptor) -> Self {
7098            Self {
7099                isolation_key: Some(string_view_to_string(value.isolationKey)),
7100                load_data_function: Some(value.loadDataFunction),
7101                store_data_function: Some(value.storeDataFunction),
7102                function_userdata: Some(value.functionUserdata),
7103            }
7104        }
7105    }
7106    pub struct DawnCompilationMessageUtf16 {
7107        pub line_pos: Option<u64>,
7108        pub offset: Option<u64>,
7109        pub length: Option<u64>,
7110    }
7111    impl Default for DawnCompilationMessageUtf16 {
7112        fn default() -> Self {
7113            Self {
7114                line_pos: None,
7115                offset: None,
7116                length: None,
7117            }
7118        }
7119    }
7120    impl DawnCompilationMessageUtf16 {
7121        pub fn new() -> Self {
7122            Self::default()
7123        }
7124        pub(crate) fn to_ffi(
7125            &self,
7126        ) -> (ffi::WGPUDawnCompilationMessageUtf16, ChainedStructStorage) {
7127            let mut storage = ChainedStructStorage::new();
7128            let mut raw: ffi::WGPUDawnCompilationMessageUtf16 = unsafe {
7129                std::mem::zeroed()
7130            };
7131            if let Some(value) = self.line_pos {
7132                raw.linePos = value;
7133            }
7134            if let Some(value) = self.offset {
7135                raw.offset = value;
7136            }
7137            if let Some(value) = self.length {
7138                raw.length = value;
7139            }
7140            (raw, storage)
7141        }
7142        pub(crate) fn from_ffi(value: ffi::WGPUDawnCompilationMessageUtf16) -> Self {
7143            Self {
7144                line_pos: Some(value.linePos),
7145                offset: Some(value.offset),
7146                length: Some(value.length),
7147            }
7148        }
7149    }
7150    pub struct DawnConsumeAdapterDescriptor {
7151        pub consume_adapter: Option<bool>,
7152    }
7153    impl Default for DawnConsumeAdapterDescriptor {
7154        fn default() -> Self {
7155            Self { consume_adapter: None }
7156        }
7157    }
7158    impl DawnConsumeAdapterDescriptor {
7159        pub fn new() -> Self {
7160            Self::default()
7161        }
7162        pub(crate) fn to_ffi(
7163            &self,
7164        ) -> (ffi::WGPUDawnConsumeAdapterDescriptor, ChainedStructStorage) {
7165            let mut storage = ChainedStructStorage::new();
7166            let mut raw: ffi::WGPUDawnConsumeAdapterDescriptor = unsafe {
7167                std::mem::zeroed()
7168            };
7169            raw.consumeAdapter = if self.consume_adapter.unwrap_or(false) {
7170                1
7171            } else {
7172                0
7173            };
7174            (raw, storage)
7175        }
7176        pub(crate) fn from_ffi(value: ffi::WGPUDawnConsumeAdapterDescriptor) -> Self {
7177            Self {
7178                consume_adapter: Some(value.consumeAdapter != 0),
7179            }
7180        }
7181    }
7182    pub struct DawnDeviceAllocatorControl {
7183        pub allocator_heap_block_size: Option<usize>,
7184    }
7185    impl Default for DawnDeviceAllocatorControl {
7186        fn default() -> Self {
7187            Self {
7188                allocator_heap_block_size: Some(0),
7189            }
7190        }
7191    }
7192    impl DawnDeviceAllocatorControl {
7193        pub fn new() -> Self {
7194            Self::default()
7195        }
7196        pub(crate) fn to_ffi(
7197            &self,
7198        ) -> (ffi::WGPUDawnDeviceAllocatorControl, ChainedStructStorage) {
7199            let mut storage = ChainedStructStorage::new();
7200            let mut raw: ffi::WGPUDawnDeviceAllocatorControl = unsafe {
7201                std::mem::zeroed()
7202            };
7203            if let Some(value) = self.allocator_heap_block_size {
7204                raw.allocatorHeapBlockSize = value;
7205            }
7206            (raw, storage)
7207        }
7208        pub(crate) fn from_ffi(value: ffi::WGPUDawnDeviceAllocatorControl) -> Self {
7209            Self {
7210                allocator_heap_block_size: Some(value.allocatorHeapBlockSize),
7211            }
7212        }
7213    }
7214    pub struct DawnDrmFormatCapabilities {
7215        pub properties: Option<Vec<DawnDrmFormatProperties>>,
7216        #[doc(hidden)]
7217        pub(crate) _free_members: Option<ffi::WGPUDawnDrmFormatCapabilities>,
7218    }
7219    impl Default for DawnDrmFormatCapabilities {
7220        fn default() -> Self {
7221            Self {
7222                properties: None,
7223                _free_members: None,
7224            }
7225        }
7226    }
7227    impl DawnDrmFormatCapabilities {
7228        pub fn new() -> Self {
7229            Self::default()
7230        }
7231        pub(crate) fn to_ffi(
7232            &self,
7233        ) -> (ffi::WGPUDawnDrmFormatCapabilities, ChainedStructStorage) {
7234            let mut storage = ChainedStructStorage::new();
7235            let mut raw: ffi::WGPUDawnDrmFormatCapabilities = unsafe {
7236                std::mem::zeroed()
7237            };
7238            raw.propertiesCount = self.properties.as_ref().map(|v| v.len()).unwrap_or(0);
7239            if let Some(values) = &self.properties {
7240                let len_value = values.len();
7241                let mut raw_vec: Vec<ffi::WGPUDawnDrmFormatProperties> = Vec::with_capacity(
7242                    values.len(),
7243                );
7244                for item in values.iter() {
7245                    let (raw_item, storage_item) = item.to_ffi();
7246                    raw_vec.push(raw_item);
7247                    storage.push_storage(storage_item);
7248                }
7249                let ptr = storage.push_vec(raw_vec);
7250                raw.properties = ptr;
7251                raw.propertiesCount = len_value;
7252            } else {
7253                raw.properties = std::ptr::null();
7254                raw.propertiesCount = 0;
7255            }
7256            (raw, storage)
7257        }
7258        pub(crate) fn from_ffi(value: ffi::WGPUDawnDrmFormatCapabilities) -> Self {
7259            Self {
7260                properties: if value.properties.is_null() {
7261                    None
7262                } else {
7263                    Some(
7264                        unsafe {
7265                            std::slice::from_raw_parts(
7266                                value.properties,
7267                                value.propertiesCount as usize,
7268                            )
7269                        }
7270                            .iter()
7271                            .map(|raw| DawnDrmFormatProperties::from_ffi(*raw))
7272                            .collect(),
7273                    )
7274                },
7275                _free_members: Some(value),
7276            }
7277        }
7278        pub(crate) fn free_members(value: ffi::WGPUDawnDrmFormatCapabilities) {
7279            unsafe { ffi::wgpuDawnDrmFormatCapabilitiesFreeMembers(value) };
7280        }
7281    }
7282    impl Drop for DawnDrmFormatCapabilities {
7283        fn drop(&mut self) {
7284            if let Some(value) = self._free_members.take() {
7285                unsafe { ffi::wgpuDawnDrmFormatCapabilitiesFreeMembers(value) };
7286            }
7287        }
7288    }
7289    pub struct DawnDrmFormatProperties {
7290        pub modifier: Option<u64>,
7291        pub modifier_plane_count: Option<u32>,
7292    }
7293    impl Default for DawnDrmFormatProperties {
7294        fn default() -> Self {
7295            Self {
7296                modifier: None,
7297                modifier_plane_count: None,
7298            }
7299        }
7300    }
7301    impl DawnDrmFormatProperties {
7302        pub fn new() -> Self {
7303            Self::default()
7304        }
7305        pub(crate) fn to_ffi(
7306            &self,
7307        ) -> (ffi::WGPUDawnDrmFormatProperties, ChainedStructStorage) {
7308            let mut storage = ChainedStructStorage::new();
7309            let mut raw: ffi::WGPUDawnDrmFormatProperties = unsafe {
7310                std::mem::zeroed()
7311            };
7312            if let Some(value) = self.modifier {
7313                raw.modifier = value;
7314            }
7315            if let Some(value) = self.modifier_plane_count {
7316                raw.modifierPlaneCount = value;
7317            }
7318            (raw, storage)
7319        }
7320        pub(crate) fn from_ffi(value: ffi::WGPUDawnDrmFormatProperties) -> Self {
7321            Self {
7322                modifier: Some(value.modifier),
7323                modifier_plane_count: Some(value.modifierPlaneCount),
7324            }
7325        }
7326    }
7327    pub struct DawnEncoderInternalUsageDescriptor {
7328        pub use_internal_usages: Option<bool>,
7329    }
7330    impl Default for DawnEncoderInternalUsageDescriptor {
7331        fn default() -> Self {
7332            Self { use_internal_usages: None }
7333        }
7334    }
7335    impl DawnEncoderInternalUsageDescriptor {
7336        pub fn new() -> Self {
7337            Self::default()
7338        }
7339        pub(crate) fn to_ffi(
7340            &self,
7341        ) -> (ffi::WGPUDawnEncoderInternalUsageDescriptor, ChainedStructStorage) {
7342            let mut storage = ChainedStructStorage::new();
7343            let mut raw: ffi::WGPUDawnEncoderInternalUsageDescriptor = unsafe {
7344                std::mem::zeroed()
7345            };
7346            raw.useInternalUsages = if self.use_internal_usages.unwrap_or(false) {
7347                1
7348            } else {
7349                0
7350            };
7351            (raw, storage)
7352        }
7353        pub(crate) fn from_ffi(
7354            value: ffi::WGPUDawnEncoderInternalUsageDescriptor,
7355        ) -> Self {
7356            Self {
7357                use_internal_usages: Some(value.useInternalUsages != 0),
7358            }
7359        }
7360    }
7361    pub struct DawnFakeBufferOOMForTesting {
7362        pub fake_oom_at_wire_client_map: Option<bool>,
7363        pub fake_oom_at_native_map: Option<bool>,
7364        pub fake_oom_at_device: Option<bool>,
7365    }
7366    impl Default for DawnFakeBufferOOMForTesting {
7367        fn default() -> Self {
7368            Self {
7369                fake_oom_at_wire_client_map: None,
7370                fake_oom_at_native_map: None,
7371                fake_oom_at_device: None,
7372            }
7373        }
7374    }
7375    impl DawnFakeBufferOOMForTesting {
7376        pub fn new() -> Self {
7377            Self::default()
7378        }
7379        pub(crate) fn to_ffi(
7380            &self,
7381        ) -> (ffi::WGPUDawnFakeBufferOOMForTesting, ChainedStructStorage) {
7382            let mut storage = ChainedStructStorage::new();
7383            let mut raw: ffi::WGPUDawnFakeBufferOOMForTesting = unsafe {
7384                std::mem::zeroed()
7385            };
7386            raw.fakeOOMAtWireClientMap = if self
7387                .fake_oom_at_wire_client_map
7388                .unwrap_or(false)
7389            {
7390                1
7391            } else {
7392                0
7393            };
7394            raw.fakeOOMAtNativeMap = if self.fake_oom_at_native_map.unwrap_or(false) {
7395                1
7396            } else {
7397                0
7398            };
7399            raw.fakeOOMAtDevice = if self.fake_oom_at_device.unwrap_or(false) {
7400                1
7401            } else {
7402                0
7403            };
7404            (raw, storage)
7405        }
7406        pub(crate) fn from_ffi(value: ffi::WGPUDawnFakeBufferOOMForTesting) -> Self {
7407            Self {
7408                fake_oom_at_wire_client_map: Some(value.fakeOOMAtWireClientMap != 0),
7409                fake_oom_at_native_map: Some(value.fakeOOMAtNativeMap != 0),
7410                fake_oom_at_device: Some(value.fakeOOMAtDevice != 0),
7411            }
7412        }
7413    }
7414    pub struct DawnFakeDeviceInitializeErrorForTesting {}
7415    impl Default for DawnFakeDeviceInitializeErrorForTesting {
7416        fn default() -> Self {
7417            Self {}
7418        }
7419    }
7420    impl DawnFakeDeviceInitializeErrorForTesting {
7421        pub fn new() -> Self {
7422            Self::default()
7423        }
7424        pub(crate) fn to_ffi(
7425            &self,
7426        ) -> (ffi::WGPUDawnFakeDeviceInitializeErrorForTesting, ChainedStructStorage) {
7427            let mut storage = ChainedStructStorage::new();
7428            let mut raw: ffi::WGPUDawnFakeDeviceInitializeErrorForTesting = unsafe {
7429                std::mem::zeroed()
7430            };
7431            (raw, storage)
7432        }
7433        pub(crate) fn from_ffi(
7434            value: ffi::WGPUDawnFakeDeviceInitializeErrorForTesting,
7435        ) -> Self {
7436            let _ = value;
7437            Self::default()
7438        }
7439    }
7440    pub struct DawnFormatCapabilities {
7441        pub(crate) extensions: Vec<DawnFormatCapabilitiesExtension>,
7442    }
7443    impl Default for DawnFormatCapabilities {
7444        fn default() -> Self {
7445            Self { extensions: Vec::new() }
7446        }
7447    }
7448    impl DawnFormatCapabilities {
7449        pub fn new() -> Self {
7450            Self::default()
7451        }
7452        pub(crate) fn to_ffi(
7453            &self,
7454        ) -> (ffi::WGPUDawnFormatCapabilities, ChainedStructStorage) {
7455            let mut storage = ChainedStructStorage::new();
7456            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7457            for ext in self.extensions.iter().rev() {
7458                next = ext.push_chain(&mut storage, next);
7459            }
7460            let mut raw: ffi::WGPUDawnFormatCapabilities = unsafe { std::mem::zeroed() };
7461            raw.nextInChain = next;
7462            (raw, storage)
7463        }
7464        pub fn with_extension(
7465            mut self,
7466            extension: DawnFormatCapabilitiesExtension,
7467        ) -> Self {
7468            self.extensions.push(extension);
7469            self
7470        }
7471        pub(crate) fn from_ffi(value: ffi::WGPUDawnFormatCapabilities) -> Self {
7472            Self { extensions: Vec::new() }
7473        }
7474    }
7475    pub struct DawnHostMappedPointerLimits {
7476        pub host_mapped_pointer_alignment: Option<u32>,
7477    }
7478    impl Default for DawnHostMappedPointerLimits {
7479        fn default() -> Self {
7480            Self {
7481                host_mapped_pointer_alignment: Some(LIMIT_U32_UNDEFINED),
7482            }
7483        }
7484    }
7485    impl DawnHostMappedPointerLimits {
7486        pub fn new() -> Self {
7487            Self::default()
7488        }
7489        pub(crate) fn to_ffi(
7490            &self,
7491        ) -> (ffi::WGPUDawnHostMappedPointerLimits, ChainedStructStorage) {
7492            let mut storage = ChainedStructStorage::new();
7493            let mut raw: ffi::WGPUDawnHostMappedPointerLimits = unsafe {
7494                std::mem::zeroed()
7495            };
7496            if let Some(value) = self.host_mapped_pointer_alignment {
7497                raw.hostMappedPointerAlignment = value;
7498            }
7499            (raw, storage)
7500        }
7501        pub(crate) fn from_ffi(value: ffi::WGPUDawnHostMappedPointerLimits) -> Self {
7502            Self {
7503                host_mapped_pointer_alignment: Some(value.hostMappedPointerAlignment),
7504            }
7505        }
7506    }
7507    pub struct DawnInjectedInvalidSType {
7508        pub invalid_s_type: Option<SType>,
7509    }
7510    impl Default for DawnInjectedInvalidSType {
7511        fn default() -> Self {
7512            Self { invalid_s_type: None }
7513        }
7514    }
7515    impl DawnInjectedInvalidSType {
7516        pub fn new() -> Self {
7517            Self::default()
7518        }
7519        pub(crate) fn to_ffi(
7520            &self,
7521        ) -> (ffi::WGPUDawnInjectedInvalidSType, ChainedStructStorage) {
7522            let mut storage = ChainedStructStorage::new();
7523            let mut raw: ffi::WGPUDawnInjectedInvalidSType = unsafe {
7524                std::mem::zeroed()
7525            };
7526            if let Some(value) = self.invalid_s_type {
7527                raw.invalidSType = value.into();
7528            } else {
7529                raw.invalidSType = 0 as ffi::WGPUSType;
7530            }
7531            (raw, storage)
7532        }
7533        pub(crate) fn from_ffi(value: ffi::WGPUDawnInjectedInvalidSType) -> Self {
7534            Self {
7535                invalid_s_type: Some(value.invalidSType.into()),
7536            }
7537        }
7538    }
7539    pub struct DawnRenderPassSampleCount {
7540        pub sample_count: Option<u32>,
7541    }
7542    impl Default for DawnRenderPassSampleCount {
7543        fn default() -> Self {
7544            Self { sample_count: Some(1) }
7545        }
7546    }
7547    impl DawnRenderPassSampleCount {
7548        pub fn new() -> Self {
7549            Self::default()
7550        }
7551        pub(crate) fn to_ffi(
7552            &self,
7553        ) -> (ffi::WGPUDawnRenderPassSampleCount, ChainedStructStorage) {
7554            let mut storage = ChainedStructStorage::new();
7555            let mut raw: ffi::WGPUDawnRenderPassSampleCount = unsafe {
7556                std::mem::zeroed()
7557            };
7558            if let Some(value) = self.sample_count {
7559                raw.sampleCount = value;
7560            }
7561            (raw, storage)
7562        }
7563        pub(crate) fn from_ffi(value: ffi::WGPUDawnRenderPassSampleCount) -> Self {
7564            Self {
7565                sample_count: Some(value.sampleCount),
7566            }
7567        }
7568    }
7569    pub struct DawnShaderModuleSPIRVOptionsDescriptor {
7570        pub allow_non_uniform_derivatives: Option<bool>,
7571    }
7572    impl Default for DawnShaderModuleSPIRVOptionsDescriptor {
7573        fn default() -> Self {
7574            Self {
7575                allow_non_uniform_derivatives: None,
7576            }
7577        }
7578    }
7579    impl DawnShaderModuleSPIRVOptionsDescriptor {
7580        pub fn new() -> Self {
7581            Self::default()
7582        }
7583        pub(crate) fn to_ffi(
7584            &self,
7585        ) -> (ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor, ChainedStructStorage) {
7586            let mut storage = ChainedStructStorage::new();
7587            let mut raw: ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor = unsafe {
7588                std::mem::zeroed()
7589            };
7590            raw.allowNonUniformDerivatives = if self
7591                .allow_non_uniform_derivatives
7592                .unwrap_or(false)
7593            {
7594                1
7595            } else {
7596                0
7597            };
7598            (raw, storage)
7599        }
7600        pub(crate) fn from_ffi(
7601            value: ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor,
7602        ) -> Self {
7603            Self {
7604                allow_non_uniform_derivatives: Some(
7605                    value.allowNonUniformDerivatives != 0,
7606                ),
7607            }
7608        }
7609    }
7610    pub struct DawnTexelCopyBufferRowAlignmentLimits {
7611        pub min_texel_copy_buffer_row_alignment: Option<u32>,
7612    }
7613    impl Default for DawnTexelCopyBufferRowAlignmentLimits {
7614        fn default() -> Self {
7615            Self {
7616                min_texel_copy_buffer_row_alignment: Some(LIMIT_U32_UNDEFINED),
7617            }
7618        }
7619    }
7620    impl DawnTexelCopyBufferRowAlignmentLimits {
7621        pub fn new() -> Self {
7622            Self::default()
7623        }
7624        pub(crate) fn to_ffi(
7625            &self,
7626        ) -> (ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits, ChainedStructStorage) {
7627            let mut storage = ChainedStructStorage::new();
7628            let mut raw: ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits = unsafe {
7629                std::mem::zeroed()
7630            };
7631            if let Some(value) = self.min_texel_copy_buffer_row_alignment {
7632                raw.minTexelCopyBufferRowAlignment = value;
7633            }
7634            (raw, storage)
7635        }
7636        pub(crate) fn from_ffi(
7637            value: ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits,
7638        ) -> Self {
7639            Self {
7640                min_texel_copy_buffer_row_alignment: Some(
7641                    value.minTexelCopyBufferRowAlignment,
7642                ),
7643            }
7644        }
7645    }
7646    pub struct DawnTextureInternalUsageDescriptor {
7647        pub internal_usage: Option<TextureUsage>,
7648    }
7649    impl Default for DawnTextureInternalUsageDescriptor {
7650        fn default() -> Self {
7651            Self { internal_usage: None }
7652        }
7653    }
7654    impl DawnTextureInternalUsageDescriptor {
7655        pub fn new() -> Self {
7656            Self::default()
7657        }
7658        pub(crate) fn to_ffi(
7659            &self,
7660        ) -> (ffi::WGPUDawnTextureInternalUsageDescriptor, ChainedStructStorage) {
7661            let mut storage = ChainedStructStorage::new();
7662            let mut raw: ffi::WGPUDawnTextureInternalUsageDescriptor = unsafe {
7663                std::mem::zeroed()
7664            };
7665            if let Some(value) = self.internal_usage {
7666                raw.internalUsage = value.into();
7667            } else {
7668                raw.internalUsage = 0 as ffi::WGPUTextureUsage;
7669            }
7670            (raw, storage)
7671        }
7672        pub(crate) fn from_ffi(
7673            value: ffi::WGPUDawnTextureInternalUsageDescriptor,
7674        ) -> Self {
7675            Self {
7676                internal_usage: Some(value.internalUsage.into()),
7677            }
7678        }
7679    }
7680    pub struct DawnTogglesDescriptor {
7681        pub enabled_toggles: Option<Vec<String>>,
7682        pub disabled_toggles: Option<Vec<String>>,
7683    }
7684    impl Default for DawnTogglesDescriptor {
7685        fn default() -> Self {
7686            Self {
7687                enabled_toggles: None,
7688                disabled_toggles: None,
7689            }
7690        }
7691    }
7692    impl DawnTogglesDescriptor {
7693        pub fn new() -> Self {
7694            Self::default()
7695        }
7696        pub(crate) fn to_ffi(
7697            &self,
7698        ) -> (ffi::WGPUDawnTogglesDescriptor, ChainedStructStorage) {
7699            let mut storage = ChainedStructStorage::new();
7700            let mut raw: ffi::WGPUDawnTogglesDescriptor = unsafe { std::mem::zeroed() };
7701            raw.enabledToggleCount = self
7702                .enabled_toggles
7703                .as_ref()
7704                .map(|v| v.len())
7705                .unwrap_or(0);
7706            if let Some(values) = &self.enabled_toggles {
7707                let len_value = values.len();
7708                let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
7709                    values.len(),
7710                );
7711                let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
7712                    values.len(),
7713                );
7714                for item in values.iter() {
7715                    let c_string = std::ffi::CString::new(item.as_str())
7716                        .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
7717                    ptrs.push(c_string.as_ptr());
7718                    c_strings.push(c_string);
7719                }
7720                let ptr = storage.push_vec(ptrs);
7721                storage.push_any(c_strings);
7722                raw.enabledToggles = ptr;
7723                raw.enabledToggleCount = len_value;
7724            } else {
7725                raw.enabledToggles = std::ptr::null();
7726                raw.enabledToggleCount = 0;
7727            }
7728            raw.disabledToggleCount = self
7729                .disabled_toggles
7730                .as_ref()
7731                .map(|v| v.len())
7732                .unwrap_or(0);
7733            if let Some(values) = &self.disabled_toggles {
7734                let len_value = values.len();
7735                let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
7736                    values.len(),
7737                );
7738                let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
7739                    values.len(),
7740                );
7741                for item in values.iter() {
7742                    let c_string = std::ffi::CString::new(item.as_str())
7743                        .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
7744                    ptrs.push(c_string.as_ptr());
7745                    c_strings.push(c_string);
7746                }
7747                let ptr = storage.push_vec(ptrs);
7748                storage.push_any(c_strings);
7749                raw.disabledToggles = ptr;
7750                raw.disabledToggleCount = len_value;
7751            } else {
7752                raw.disabledToggles = std::ptr::null();
7753                raw.disabledToggleCount = 0;
7754            }
7755            (raw, storage)
7756        }
7757        pub(crate) fn from_ffi(value: ffi::WGPUDawnTogglesDescriptor) -> Self {
7758            Self {
7759                enabled_toggles: if value.enabledToggles.is_null() {
7760                    None
7761                } else {
7762                    Some(
7763                        unsafe {
7764                            std::slice::from_raw_parts(
7765                                value.enabledToggles,
7766                                value.enabledToggleCount as usize,
7767                            )
7768                        }
7769                            .iter()
7770                            .map(|raw| {
7771                                if raw.is_null() {
7772                                    String::new()
7773                                } else {
7774                                    unsafe { CStr::from_ptr(*raw) }
7775                                        .to_string_lossy()
7776                                        .into_owned()
7777                                }
7778                            })
7779                            .collect(),
7780                    )
7781                },
7782                disabled_toggles: if value.disabledToggles.is_null() {
7783                    None
7784                } else {
7785                    Some(
7786                        unsafe {
7787                            std::slice::from_raw_parts(
7788                                value.disabledToggles,
7789                                value.disabledToggleCount as usize,
7790                            )
7791                        }
7792                            .iter()
7793                            .map(|raw| {
7794                                if raw.is_null() {
7795                                    String::new()
7796                                } else {
7797                                    unsafe { CStr::from_ptr(*raw) }
7798                                        .to_string_lossy()
7799                                        .into_owned()
7800                                }
7801                            })
7802                            .collect(),
7803                    )
7804                },
7805            }
7806        }
7807    }
7808    pub struct DawnWireWGSLControl {
7809        pub enable_experimental: Option<bool>,
7810        pub enable_unsafe: Option<bool>,
7811        pub enable_testing: Option<bool>,
7812    }
7813    impl Default for DawnWireWGSLControl {
7814        fn default() -> Self {
7815            Self {
7816                enable_experimental: None,
7817                enable_unsafe: None,
7818                enable_testing: None,
7819            }
7820        }
7821    }
7822    impl DawnWireWGSLControl {
7823        pub fn new() -> Self {
7824            Self::default()
7825        }
7826        pub(crate) fn to_ffi(
7827            &self,
7828        ) -> (ffi::WGPUDawnWireWGSLControl, ChainedStructStorage) {
7829            let mut storage = ChainedStructStorage::new();
7830            let mut raw: ffi::WGPUDawnWireWGSLControl = unsafe { std::mem::zeroed() };
7831            raw.enableExperimental = if self.enable_experimental.unwrap_or(false) {
7832                1
7833            } else {
7834                0
7835            };
7836            raw.enableUnsafe = if self.enable_unsafe.unwrap_or(false) { 1 } else { 0 };
7837            raw.enableTesting = if self.enable_testing.unwrap_or(false) { 1 } else { 0 };
7838            (raw, storage)
7839        }
7840        pub(crate) fn from_ffi(value: ffi::WGPUDawnWireWGSLControl) -> Self {
7841            Self {
7842                enable_experimental: Some(value.enableExperimental != 0),
7843                enable_unsafe: Some(value.enableUnsafe != 0),
7844                enable_testing: Some(value.enableTesting != 0),
7845            }
7846        }
7847    }
7848    pub struct DepthStencilState {
7849        pub(crate) extensions: Vec<DepthStencilStateExtension>,
7850        pub format: Option<TextureFormat>,
7851        pub depth_write_enabled: Option<OptionalBool>,
7852        pub depth_compare: Option<CompareFunction>,
7853        pub stencil_front: Option<StencilFaceState>,
7854        pub stencil_back: Option<StencilFaceState>,
7855        pub stencil_read_mask: Option<u32>,
7856        pub stencil_write_mask: Option<u32>,
7857        pub depth_bias: Option<i32>,
7858        pub depth_bias_slope_scale: Option<f32>,
7859        pub depth_bias_clamp: Option<f32>,
7860    }
7861    impl Default for DepthStencilState {
7862        fn default() -> Self {
7863            Self {
7864                extensions: Vec::new(),
7865                format: None,
7866                depth_write_enabled: None,
7867                depth_compare: None,
7868                stencil_front: None,
7869                stencil_back: None,
7870                stencil_read_mask: Some(4294967295),
7871                stencil_write_mask: Some(4294967295),
7872                depth_bias: Some(0),
7873                depth_bias_slope_scale: None,
7874                depth_bias_clamp: None,
7875            }
7876        }
7877    }
7878    impl DepthStencilState {
7879        pub fn new() -> Self {
7880            Self::default()
7881        }
7882        pub(crate) fn to_ffi(
7883            &self,
7884        ) -> (ffi::WGPUDepthStencilState, ChainedStructStorage) {
7885            let mut storage = ChainedStructStorage::new();
7886            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7887            for ext in self.extensions.iter().rev() {
7888                next = ext.push_chain(&mut storage, next);
7889            }
7890            let mut raw: ffi::WGPUDepthStencilState = unsafe { std::mem::zeroed() };
7891            raw.nextInChain = next;
7892            if let Some(value) = self.format {
7893                raw.format = value.into();
7894            } else {
7895                raw.format = 0 as ffi::WGPUTextureFormat;
7896            }
7897            if let Some(value) = self.depth_write_enabled {
7898                raw.depthWriteEnabled = value.into();
7899            } else {
7900                raw.depthWriteEnabled = 0 as ffi::WGPUOptionalBool;
7901            }
7902            if let Some(value) = self.depth_compare {
7903                raw.depthCompare = value.into();
7904            } else {
7905                raw.depthCompare = 0 as ffi::WGPUCompareFunction;
7906            }
7907            if let Some(value) = &self.stencil_front {
7908                let (raw_value, storage_value) = value.to_ffi();
7909                raw.stencilFront = raw_value;
7910                storage.push_storage(storage_value);
7911            }
7912            if let Some(value) = &self.stencil_back {
7913                let (raw_value, storage_value) = value.to_ffi();
7914                raw.stencilBack = raw_value;
7915                storage.push_storage(storage_value);
7916            }
7917            if let Some(value) = self.stencil_read_mask {
7918                raw.stencilReadMask = value;
7919            }
7920            if let Some(value) = self.stencil_write_mask {
7921                raw.stencilWriteMask = value;
7922            }
7923            if let Some(value) = self.depth_bias {
7924                raw.depthBias = value;
7925            }
7926            if let Some(value) = self.depth_bias_slope_scale {
7927                raw.depthBiasSlopeScale = value;
7928            }
7929            if let Some(value) = self.depth_bias_clamp {
7930                raw.depthBiasClamp = value;
7931            }
7932            (raw, storage)
7933        }
7934        pub fn with_extension(mut self, extension: DepthStencilStateExtension) -> Self {
7935            self.extensions.push(extension);
7936            self
7937        }
7938        pub(crate) fn from_ffi(value: ffi::WGPUDepthStencilState) -> Self {
7939            Self {
7940                extensions: Vec::new(),
7941                format: Some(value.format.into()),
7942                depth_write_enabled: Some(value.depthWriteEnabled.into()),
7943                depth_compare: Some(value.depthCompare.into()),
7944                stencil_front: Some(StencilFaceState::from_ffi(value.stencilFront)),
7945                stencil_back: Some(StencilFaceState::from_ffi(value.stencilBack)),
7946                stencil_read_mask: Some(value.stencilReadMask),
7947                stencil_write_mask: Some(value.stencilWriteMask),
7948                depth_bias: Some(value.depthBias),
7949                depth_bias_slope_scale: Some(value.depthBiasSlopeScale),
7950                depth_bias_clamp: Some(value.depthBiasClamp),
7951            }
7952        }
7953    }
7954    pub struct DeviceDescriptor {
7955        pub(crate) extensions: Vec<DeviceDescriptorExtension>,
7956        pub label: Option<String>,
7957        pub required_features: Option<Vec<FeatureName>>,
7958        pub required_limits: Option<Limits>,
7959        pub default_queue: Option<QueueDescriptor>,
7960        pub device_lost_callback_info: Option<DeviceLostCallbackInfo>,
7961        pub uncaptured_error_callback_info: Option<UncapturedErrorCallbackInfo>,
7962    }
7963    impl Default for DeviceDescriptor {
7964        fn default() -> Self {
7965            Self {
7966                extensions: Vec::new(),
7967                label: None,
7968                required_features: None,
7969                required_limits: None,
7970                default_queue: None,
7971                device_lost_callback_info: None,
7972                uncaptured_error_callback_info: None,
7973            }
7974        }
7975    }
7976    impl DeviceDescriptor {
7977        pub fn new() -> Self {
7978            Self::default()
7979        }
7980        pub(crate) fn to_ffi(
7981            &self,
7982        ) -> (ffi::WGPUDeviceDescriptor, ChainedStructStorage) {
7983            let mut storage = ChainedStructStorage::new();
7984            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7985            for ext in self.extensions.iter().rev() {
7986                next = ext.push_chain(&mut storage, next);
7987            }
7988            let mut raw: ffi::WGPUDeviceDescriptor = unsafe { std::mem::zeroed() };
7989            raw.nextInChain = next;
7990            if let Some(value) = &self.label {
7991                raw.label = ffi::WGPUStringView {
7992                    data: value.as_ptr().cast(),
7993                    length: value.len(),
7994                };
7995            } else {
7996                raw.label = ffi::WGPUStringView {
7997                    data: std::ptr::null(),
7998                    length: 0,
7999                };
8000            }
8001            raw.requiredFeatureCount = self
8002                .required_features
8003                .as_ref()
8004                .map(|v| v.len())
8005                .unwrap_or(0);
8006            if let Some(values) = &self.required_features {
8007                let len_value = values.len();
8008                let raw_vec: Vec<ffi::WGPUFeatureName> = values
8009                    .iter()
8010                    .map(|v| (*v).into())
8011                    .collect();
8012                let ptr = storage.push_vec(raw_vec);
8013                raw.requiredFeatures = ptr;
8014                raw.requiredFeatureCount = len_value;
8015            } else {
8016                raw.requiredFeatures = std::ptr::null();
8017                raw.requiredFeatureCount = 0;
8018            }
8019            if let Some(value) = &self.required_limits {
8020                let (raw_value, storage_value) = value.to_ffi();
8021                let ptr = storage.push_value(raw_value);
8022                raw.requiredLimits = ptr;
8023                storage.push_storage(storage_value);
8024            } else {
8025                raw.requiredLimits = std::ptr::null();
8026            }
8027            if let Some(value) = &self.default_queue {
8028                let (raw_value, storage_value) = value.to_ffi();
8029                raw.defaultQueue = raw_value;
8030                storage.push_storage(storage_value);
8031            }
8032            if let Some(info) = &self.device_lost_callback_info {
8033                let mut callback_slot = info.callback.borrow_mut();
8034                let callback = callback_slot.take();
8035                let (
8036                    callback_ptr,
8037                    userdata1,
8038                ): (ffi::WGPUDeviceLostCallback, *mut std::ffi::c_void) = if let Some(
8039                    callback,
8040                ) = callback {
8041                    let callback_box: DeviceLostCallback = callback;
8042                    let callback_box = Box::new(Some(callback_box));
8043                    let userdata = Box::into_raw(callback_box)
8044                        .cast::<std::ffi::c_void>();
8045                    (Some(device_lost_callback_trampoline), userdata)
8046                } else {
8047                    (None, std::ptr::null_mut())
8048                };
8049                let mode = info.mode.unwrap_or(CallbackMode::AllowSpontaneous);
8050                raw.deviceLostCallbackInfo = ffi::WGPUDeviceLostCallbackInfo {
8051                    nextInChain: std::ptr::null_mut(),
8052                    mode: mode.into(),
8053                    callback: callback_ptr,
8054                    userdata1,
8055                    userdata2: std::ptr::null_mut(),
8056                };
8057            } else {
8058                raw.deviceLostCallbackInfo = ffi::WGPUDeviceLostCallbackInfo {
8059                    nextInChain: std::ptr::null_mut(),
8060                    mode: CallbackMode::AllowSpontaneous.into(),
8061                    callback: None,
8062                    userdata1: std::ptr::null_mut(),
8063                    userdata2: std::ptr::null_mut(),
8064                };
8065            }
8066            if let Some(info) = &self.uncaptured_error_callback_info {
8067                let mut callback_slot = info.callback.borrow_mut();
8068                let callback = callback_slot.take();
8069                let (
8070                    callback_ptr,
8071                    userdata1,
8072                ): (ffi::WGPUUncapturedErrorCallback, *mut std::ffi::c_void) = if let Some(
8073                    callback,
8074                ) = callback {
8075                    let callback_box: UncapturedErrorCallback = callback;
8076                    let callback_box = Box::new(Some(callback_box));
8077                    let userdata = Box::into_raw(callback_box)
8078                        .cast::<std::ffi::c_void>();
8079                    (Some(uncaptured_error_callback_trampoline), userdata)
8080                } else {
8081                    (None, std::ptr::null_mut())
8082                };
8083                raw.uncapturedErrorCallbackInfo = ffi::WGPUUncapturedErrorCallbackInfo {
8084                    nextInChain: std::ptr::null_mut(),
8085                    callback: callback_ptr,
8086                    userdata1,
8087                    userdata2: std::ptr::null_mut(),
8088                };
8089            } else {
8090                raw.uncapturedErrorCallbackInfo = ffi::WGPUUncapturedErrorCallbackInfo {
8091                    nextInChain: std::ptr::null_mut(),
8092                    callback: None,
8093                    userdata1: std::ptr::null_mut(),
8094                    userdata2: std::ptr::null_mut(),
8095                };
8096            }
8097            (raw, storage)
8098        }
8099        pub fn with_extension(mut self, extension: DeviceDescriptorExtension) -> Self {
8100            self.extensions.push(extension);
8101            self
8102        }
8103        pub(crate) fn from_ffi(value: ffi::WGPUDeviceDescriptor) -> Self {
8104            Self {
8105                extensions: Vec::new(),
8106                label: if value.label.data.is_null() || value.label.length == 0 {
8107                    None
8108                } else {
8109                    Some(string_view_to_string(value.label))
8110                },
8111                required_features: if value.requiredFeatures.is_null() {
8112                    None
8113                } else {
8114                    Some(
8115                        unsafe {
8116                            std::slice::from_raw_parts(
8117                                value.requiredFeatures,
8118                                value.requiredFeatureCount as usize,
8119                            )
8120                        }
8121                            .iter()
8122                            .map(|raw| FeatureName::from(*raw))
8123                            .collect(),
8124                    )
8125                },
8126                required_limits: if value.requiredLimits.is_null() {
8127                    None
8128                } else {
8129                    Some(Limits::from_ffi(unsafe { *value.requiredLimits }))
8130                },
8131                default_queue: Some(QueueDescriptor::from_ffi(value.defaultQueue)),
8132                device_lost_callback_info: None,
8133                uncaptured_error_callback_info: None,
8134            }
8135        }
8136    }
8137    pub struct Extent2D {
8138        pub width: Option<u32>,
8139        pub height: Option<u32>,
8140    }
8141    impl Default for Extent2D {
8142        fn default() -> Self {
8143            Self { width: None, height: None }
8144        }
8145    }
8146    impl Extent2D {
8147        pub fn new() -> Self {
8148            Self::default()
8149        }
8150        pub(crate) fn to_ffi(&self) -> (ffi::WGPUExtent2D, ChainedStructStorage) {
8151            let mut storage = ChainedStructStorage::new();
8152            let mut raw: ffi::WGPUExtent2D = unsafe { std::mem::zeroed() };
8153            if let Some(value) = self.width {
8154                raw.width = value;
8155            }
8156            if let Some(value) = self.height {
8157                raw.height = value;
8158            }
8159            (raw, storage)
8160        }
8161        pub(crate) fn from_ffi(value: ffi::WGPUExtent2D) -> Self {
8162            Self {
8163                width: Some(value.width),
8164                height: Some(value.height),
8165            }
8166        }
8167    }
8168    pub struct Extent3D {
8169        pub width: Option<u32>,
8170        pub height: Option<u32>,
8171        pub depth_or_array_layers: Option<u32>,
8172    }
8173    impl Default for Extent3D {
8174        fn default() -> Self {
8175            Self {
8176                width: None,
8177                height: Some(1),
8178                depth_or_array_layers: Some(1),
8179            }
8180        }
8181    }
8182    impl Extent3D {
8183        pub fn new() -> Self {
8184            Self::default()
8185        }
8186        pub(crate) fn to_ffi(&self) -> (ffi::WGPUExtent3D, ChainedStructStorage) {
8187            let mut storage = ChainedStructStorage::new();
8188            let mut raw: ffi::WGPUExtent3D = unsafe { std::mem::zeroed() };
8189            if let Some(value) = self.width {
8190                raw.width = value;
8191            }
8192            if let Some(value) = self.height {
8193                raw.height = value;
8194            }
8195            if let Some(value) = self.depth_or_array_layers {
8196                raw.depthOrArrayLayers = value;
8197            }
8198            (raw, storage)
8199        }
8200        pub(crate) fn from_ffi(value: ffi::WGPUExtent3D) -> Self {
8201            Self {
8202                width: Some(value.width),
8203                height: Some(value.height),
8204                depth_or_array_layers: Some(value.depthOrArrayLayers),
8205            }
8206        }
8207    }
8208    pub struct ExternalTextureBindingEntry {
8209        pub external_texture: Option<ExternalTexture>,
8210    }
8211    impl Default for ExternalTextureBindingEntry {
8212        fn default() -> Self {
8213            Self { external_texture: None }
8214        }
8215    }
8216    impl ExternalTextureBindingEntry {
8217        pub fn new() -> Self {
8218            Self::default()
8219        }
8220        pub(crate) fn to_ffi(
8221            &self,
8222        ) -> (ffi::WGPUExternalTextureBindingEntry, ChainedStructStorage) {
8223            let mut storage = ChainedStructStorage::new();
8224            let mut raw: ffi::WGPUExternalTextureBindingEntry = unsafe {
8225                std::mem::zeroed()
8226            };
8227            raw.externalTexture = self
8228                .external_texture
8229                .as_ref()
8230                .map(|v| v.as_raw())
8231                .unwrap_or(std::ptr::null_mut());
8232            (raw, storage)
8233        }
8234        pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureBindingEntry) -> Self {
8235            Self {
8236                external_texture: Some(unsafe {
8237                    ExternalTexture::from_raw(value.externalTexture)
8238                }),
8239            }
8240        }
8241    }
8242    pub struct ExternalTextureBindingLayout {}
8243    impl Default for ExternalTextureBindingLayout {
8244        fn default() -> Self {
8245            Self {}
8246        }
8247    }
8248    impl ExternalTextureBindingLayout {
8249        pub fn new() -> Self {
8250            Self::default()
8251        }
8252        pub(crate) fn to_ffi(
8253            &self,
8254        ) -> (ffi::WGPUExternalTextureBindingLayout, ChainedStructStorage) {
8255            let mut storage = ChainedStructStorage::new();
8256            let mut raw: ffi::WGPUExternalTextureBindingLayout = unsafe {
8257                std::mem::zeroed()
8258            };
8259            (raw, storage)
8260        }
8261        pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureBindingLayout) -> Self {
8262            let _ = value;
8263            Self::default()
8264        }
8265    }
8266    pub struct ExternalTextureDescriptor {
8267        pub(crate) extensions: Vec<ExternalTextureDescriptorExtension>,
8268        pub label: Option<String>,
8269        pub plane_0: Option<TextureView>,
8270        pub plane_1: Option<TextureView>,
8271        pub crop_origin: Option<Origin2D>,
8272        pub crop_size: Option<Extent2D>,
8273        pub apparent_size: Option<Extent2D>,
8274        pub do_yuv_to_rgb_conversion_only: Option<bool>,
8275        pub yuv_to_rgb_conversion_matrix: Option<Vec<f32>>,
8276        pub src_transfer_function_parameters: Option<Vec<f32>>,
8277        pub dst_transfer_function_parameters: Option<Vec<f32>>,
8278        pub gamut_conversion_matrix: Option<Vec<f32>>,
8279        pub mirrored: Option<bool>,
8280        pub rotation: Option<ExternalTextureRotation>,
8281    }
8282    impl Default for ExternalTextureDescriptor {
8283        fn default() -> Self {
8284            Self {
8285                extensions: Vec::new(),
8286                label: None,
8287                plane_0: None,
8288                plane_1: None,
8289                crop_origin: None,
8290                crop_size: None,
8291                apparent_size: None,
8292                do_yuv_to_rgb_conversion_only: None,
8293                yuv_to_rgb_conversion_matrix: None,
8294                src_transfer_function_parameters: None,
8295                dst_transfer_function_parameters: None,
8296                gamut_conversion_matrix: None,
8297                mirrored: None,
8298                rotation: Some(ExternalTextureRotation::Rotate0Degrees),
8299            }
8300        }
8301    }
8302    impl ExternalTextureDescriptor {
8303        pub fn new() -> Self {
8304            Self::default()
8305        }
8306        pub(crate) fn to_ffi(
8307            &self,
8308        ) -> (ffi::WGPUExternalTextureDescriptor, ChainedStructStorage) {
8309            let mut storage = ChainedStructStorage::new();
8310            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8311            for ext in self.extensions.iter().rev() {
8312                next = ext.push_chain(&mut storage, next);
8313            }
8314            let mut raw: ffi::WGPUExternalTextureDescriptor = unsafe {
8315                std::mem::zeroed()
8316            };
8317            raw.nextInChain = next;
8318            if let Some(value) = &self.label {
8319                raw.label = ffi::WGPUStringView {
8320                    data: value.as_ptr().cast(),
8321                    length: value.len(),
8322                };
8323            } else {
8324                raw.label = ffi::WGPUStringView {
8325                    data: std::ptr::null(),
8326                    length: 0,
8327                };
8328            }
8329            raw.plane0 = self
8330                .plane_0
8331                .as_ref()
8332                .map(|v| v.as_raw())
8333                .unwrap_or(std::ptr::null_mut());
8334            raw.plane1 = self
8335                .plane_1
8336                .as_ref()
8337                .map(|v| v.as_raw())
8338                .unwrap_or(std::ptr::null_mut());
8339            if let Some(value) = &self.crop_origin {
8340                let (raw_value, storage_value) = value.to_ffi();
8341                raw.cropOrigin = raw_value;
8342                storage.push_storage(storage_value);
8343            }
8344            if let Some(value) = &self.crop_size {
8345                let (raw_value, storage_value) = value.to_ffi();
8346                raw.cropSize = raw_value;
8347                storage.push_storage(storage_value);
8348            }
8349            if let Some(value) = &self.apparent_size {
8350                let (raw_value, storage_value) = value.to_ffi();
8351                raw.apparentSize = raw_value;
8352                storage.push_storage(storage_value);
8353            }
8354            raw.doYuvToRgbConversionOnly = if self
8355                .do_yuv_to_rgb_conversion_only
8356                .unwrap_or(false)
8357            {
8358                1
8359            } else {
8360                0
8361            };
8362            if let Some(values) = &self.yuv_to_rgb_conversion_matrix {
8363                let len_value = values.len();
8364                let raw_vec = values.to_vec();
8365                let ptr = storage.push_vec(raw_vec);
8366                raw.yuvToRgbConversionMatrix = ptr;
8367            } else {
8368                raw.yuvToRgbConversionMatrix = std::ptr::null();
8369                let _ = 0;
8370            }
8371            if let Some(values) = &self.src_transfer_function_parameters {
8372                let len_value = values.len();
8373                let raw_vec = values.to_vec();
8374                let ptr = storage.push_vec(raw_vec);
8375                raw.srcTransferFunctionParameters = ptr;
8376            } else {
8377                raw.srcTransferFunctionParameters = std::ptr::null();
8378                let _ = 0;
8379            }
8380            if let Some(values) = &self.dst_transfer_function_parameters {
8381                let len_value = values.len();
8382                let raw_vec = values.to_vec();
8383                let ptr = storage.push_vec(raw_vec);
8384                raw.dstTransferFunctionParameters = ptr;
8385            } else {
8386                raw.dstTransferFunctionParameters = std::ptr::null();
8387                let _ = 0;
8388            }
8389            if let Some(values) = &self.gamut_conversion_matrix {
8390                let len_value = values.len();
8391                let raw_vec = values.to_vec();
8392                let ptr = storage.push_vec(raw_vec);
8393                raw.gamutConversionMatrix = ptr;
8394            } else {
8395                raw.gamutConversionMatrix = std::ptr::null();
8396                let _ = 0;
8397            }
8398            raw.mirrored = if self.mirrored.unwrap_or(false) { 1 } else { 0 };
8399            if let Some(value) = self.rotation {
8400                raw.rotation = value.into();
8401            } else {
8402                raw.rotation = 0 as ffi::WGPUExternalTextureRotation;
8403            }
8404            (raw, storage)
8405        }
8406        pub fn with_extension(
8407            mut self,
8408            extension: ExternalTextureDescriptorExtension,
8409        ) -> Self {
8410            self.extensions.push(extension);
8411            self
8412        }
8413        pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureDescriptor) -> Self {
8414            Self {
8415                extensions: Vec::new(),
8416                label: if value.label.data.is_null() || value.label.length == 0 {
8417                    None
8418                } else {
8419                    Some(string_view_to_string(value.label))
8420                },
8421                plane_0: Some(unsafe { TextureView::from_raw(value.plane0) }),
8422                plane_1: if value.plane1.is_null() {
8423                    None
8424                } else {
8425                    Some(unsafe { TextureView::from_raw(value.plane1) })
8426                },
8427                crop_origin: Some(Origin2D::from_ffi(value.cropOrigin)),
8428                crop_size: Some(Extent2D::from_ffi(value.cropSize)),
8429                apparent_size: Some(Extent2D::from_ffi(value.apparentSize)),
8430                do_yuv_to_rgb_conversion_only: Some(value.doYuvToRgbConversionOnly != 0),
8431                yuv_to_rgb_conversion_matrix: if value.yuvToRgbConversionMatrix.is_null()
8432                {
8433                    None
8434                } else {
8435                    Some(
8436                        unsafe {
8437                            std::slice::from_raw_parts(
8438                                value.yuvToRgbConversionMatrix,
8439                                12usize,
8440                            )
8441                        }
8442                            .to_vec(),
8443                    )
8444                },
8445                src_transfer_function_parameters: if value
8446                    .srcTransferFunctionParameters
8447                    .is_null()
8448                {
8449                    None
8450                } else {
8451                    Some(
8452                        unsafe {
8453                            std::slice::from_raw_parts(
8454                                value.srcTransferFunctionParameters,
8455                                7usize,
8456                            )
8457                        }
8458                            .to_vec(),
8459                    )
8460                },
8461                dst_transfer_function_parameters: if value
8462                    .dstTransferFunctionParameters
8463                    .is_null()
8464                {
8465                    None
8466                } else {
8467                    Some(
8468                        unsafe {
8469                            std::slice::from_raw_parts(
8470                                value.dstTransferFunctionParameters,
8471                                7usize,
8472                            )
8473                        }
8474                            .to_vec(),
8475                    )
8476                },
8477                gamut_conversion_matrix: if value.gamutConversionMatrix.is_null() {
8478                    None
8479                } else {
8480                    Some(
8481                        unsafe {
8482                            std::slice::from_raw_parts(
8483                                value.gamutConversionMatrix,
8484                                9usize,
8485                            )
8486                        }
8487                            .to_vec(),
8488                    )
8489                },
8490                mirrored: Some(value.mirrored != 0),
8491                rotation: Some(value.rotation.into()),
8492            }
8493        }
8494    }
8495    pub struct FragmentState {
8496        pub(crate) extensions: Vec<FragmentStateExtension>,
8497        pub module: Option<ShaderModule>,
8498        pub entry_point: Option<String>,
8499        pub constants: Option<Vec<ConstantEntry>>,
8500        pub targets: Option<Vec<ColorTargetState>>,
8501    }
8502    impl Default for FragmentState {
8503        fn default() -> Self {
8504            Self {
8505                extensions: Vec::new(),
8506                module: None,
8507                entry_point: None,
8508                constants: None,
8509                targets: None,
8510            }
8511        }
8512    }
8513    impl FragmentState {
8514        pub fn new() -> Self {
8515            Self::default()
8516        }
8517        pub(crate) fn to_ffi(&self) -> (ffi::WGPUFragmentState, ChainedStructStorage) {
8518            let mut storage = ChainedStructStorage::new();
8519            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8520            for ext in self.extensions.iter().rev() {
8521                next = ext.push_chain(&mut storage, next);
8522            }
8523            let mut raw: ffi::WGPUFragmentState = unsafe { std::mem::zeroed() };
8524            raw.nextInChain = next;
8525            raw.module = self
8526                .module
8527                .as_ref()
8528                .map(|v| v.as_raw())
8529                .unwrap_or(std::ptr::null_mut());
8530            if let Some(value) = &self.entry_point {
8531                raw.entryPoint = ffi::WGPUStringView {
8532                    data: value.as_ptr().cast(),
8533                    length: value.len(),
8534                };
8535            } else {
8536                raw.entryPoint = ffi::WGPUStringView {
8537                    data: std::ptr::null(),
8538                    length: 0,
8539                };
8540            }
8541            raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
8542            if let Some(values) = &self.constants {
8543                let len_value = values.len();
8544                let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
8545                    values.len(),
8546                );
8547                for item in values.iter() {
8548                    let (raw_item, storage_item) = item.to_ffi();
8549                    raw_vec.push(raw_item);
8550                    storage.push_storage(storage_item);
8551                }
8552                let ptr = storage.push_vec(raw_vec);
8553                raw.constants = ptr;
8554                raw.constantCount = len_value;
8555            } else {
8556                raw.constants = std::ptr::null();
8557                raw.constantCount = 0;
8558            }
8559            raw.targetCount = self.targets.as_ref().map(|v| v.len()).unwrap_or(0);
8560            if let Some(values) = &self.targets {
8561                let len_value = values.len();
8562                let mut raw_vec: Vec<ffi::WGPUColorTargetState> = Vec::with_capacity(
8563                    values.len(),
8564                );
8565                for item in values.iter() {
8566                    let (raw_item, storage_item) = item.to_ffi();
8567                    raw_vec.push(raw_item);
8568                    storage.push_storage(storage_item);
8569                }
8570                let ptr = storage.push_vec(raw_vec);
8571                raw.targets = ptr;
8572                raw.targetCount = len_value;
8573            } else {
8574                raw.targets = std::ptr::null();
8575                raw.targetCount = 0;
8576            }
8577            (raw, storage)
8578        }
8579        pub fn with_extension(mut self, extension: FragmentStateExtension) -> Self {
8580            self.extensions.push(extension);
8581            self
8582        }
8583        pub(crate) fn from_ffi(value: ffi::WGPUFragmentState) -> Self {
8584            Self {
8585                extensions: Vec::new(),
8586                module: Some(unsafe { ShaderModule::from_raw(value.module) }),
8587                entry_point: if value.entryPoint.data.is_null()
8588                    || value.entryPoint.length == 0
8589                {
8590                    None
8591                } else {
8592                    Some(string_view_to_string(value.entryPoint))
8593                },
8594                constants: if value.constants.is_null() {
8595                    None
8596                } else {
8597                    Some(
8598                        unsafe {
8599                            std::slice::from_raw_parts(
8600                                value.constants,
8601                                value.constantCount as usize,
8602                            )
8603                        }
8604                            .iter()
8605                            .map(|raw| ConstantEntry::from_ffi(*raw))
8606                            .collect(),
8607                    )
8608                },
8609                targets: if value.targets.is_null() {
8610                    None
8611                } else {
8612                    Some(
8613                        unsafe {
8614                            std::slice::from_raw_parts(
8615                                value.targets,
8616                                value.targetCount as usize,
8617                            )
8618                        }
8619                            .iter()
8620                            .map(|raw| ColorTargetState::from_ffi(*raw))
8621                            .collect(),
8622                    )
8623                },
8624            }
8625        }
8626    }
8627    pub struct Future {
8628        pub id: Option<u64>,
8629    }
8630    impl Default for Future {
8631        fn default() -> Self {
8632            Self { id: None }
8633        }
8634    }
8635    impl Future {
8636        pub fn new() -> Self {
8637            Self::default()
8638        }
8639        pub(crate) fn to_ffi(&self) -> (ffi::WGPUFuture, ChainedStructStorage) {
8640            let mut storage = ChainedStructStorage::new();
8641            let mut raw: ffi::WGPUFuture = unsafe { std::mem::zeroed() };
8642            if let Some(value) = self.id {
8643                raw.id = value;
8644            }
8645            (raw, storage)
8646        }
8647        pub(crate) fn from_ffi(value: ffi::WGPUFuture) -> Self {
8648            Self { id: Some(value.id) }
8649        }
8650    }
8651    pub struct FutureWaitInfo {
8652        pub future: Option<Future>,
8653        pub completed: Option<bool>,
8654    }
8655    impl Default for FutureWaitInfo {
8656        fn default() -> Self {
8657            Self {
8658                future: None,
8659                completed: None,
8660            }
8661        }
8662    }
8663    impl FutureWaitInfo {
8664        pub fn new() -> Self {
8665            Self::default()
8666        }
8667        pub(crate) fn to_ffi(&self) -> (ffi::WGPUFutureWaitInfo, ChainedStructStorage) {
8668            let mut storage = ChainedStructStorage::new();
8669            let mut raw: ffi::WGPUFutureWaitInfo = unsafe { std::mem::zeroed() };
8670            if let Some(value) = &self.future {
8671                let (raw_value, storage_value) = value.to_ffi();
8672                raw.future = raw_value;
8673                storage.push_storage(storage_value);
8674            }
8675            raw.completed = if self.completed.unwrap_or(false) { 1 } else { 0 };
8676            (raw, storage)
8677        }
8678        pub(crate) fn from_ffi(value: ffi::WGPUFutureWaitInfo) -> Self {
8679            Self {
8680                future: Some(Future::from_ffi(value.future)),
8681                completed: Some(value.completed != 0),
8682            }
8683        }
8684    }
8685    pub struct ImageCopyExternalTexture {
8686        pub(crate) extensions: Vec<ImageCopyExternalTextureExtension>,
8687        pub external_texture: Option<ExternalTexture>,
8688        pub origin: Option<Origin3D>,
8689        pub natural_size: Option<Extent2D>,
8690    }
8691    impl Default for ImageCopyExternalTexture {
8692        fn default() -> Self {
8693            Self {
8694                extensions: Vec::new(),
8695                external_texture: None,
8696                origin: None,
8697                natural_size: None,
8698            }
8699        }
8700    }
8701    impl ImageCopyExternalTexture {
8702        pub fn new() -> Self {
8703            Self::default()
8704        }
8705        pub(crate) fn to_ffi(
8706            &self,
8707        ) -> (ffi::WGPUImageCopyExternalTexture, ChainedStructStorage) {
8708            let mut storage = ChainedStructStorage::new();
8709            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8710            for ext in self.extensions.iter().rev() {
8711                next = ext.push_chain(&mut storage, next);
8712            }
8713            let mut raw: ffi::WGPUImageCopyExternalTexture = unsafe {
8714                std::mem::zeroed()
8715            };
8716            raw.nextInChain = next;
8717            raw.externalTexture = self
8718                .external_texture
8719                .as_ref()
8720                .map(|v| v.as_raw())
8721                .unwrap_or(std::ptr::null_mut());
8722            if let Some(value) = &self.origin {
8723                let (raw_value, storage_value) = value.to_ffi();
8724                raw.origin = raw_value;
8725                storage.push_storage(storage_value);
8726            }
8727            if let Some(value) = &self.natural_size {
8728                let (raw_value, storage_value) = value.to_ffi();
8729                raw.naturalSize = raw_value;
8730                storage.push_storage(storage_value);
8731            }
8732            (raw, storage)
8733        }
8734        pub fn with_extension(
8735            mut self,
8736            extension: ImageCopyExternalTextureExtension,
8737        ) -> Self {
8738            self.extensions.push(extension);
8739            self
8740        }
8741        pub(crate) fn from_ffi(value: ffi::WGPUImageCopyExternalTexture) -> Self {
8742            Self {
8743                extensions: Vec::new(),
8744                external_texture: Some(unsafe {
8745                    ExternalTexture::from_raw(value.externalTexture)
8746                }),
8747                origin: Some(Origin3D::from_ffi(value.origin)),
8748                natural_size: Some(Extent2D::from_ffi(value.naturalSize)),
8749            }
8750        }
8751    }
8752    pub struct InstanceDescriptor {
8753        pub(crate) extensions: Vec<InstanceDescriptorExtension>,
8754        pub required_features: Option<Vec<InstanceFeatureName>>,
8755        pub required_limits: Option<InstanceLimits>,
8756    }
8757    impl Default for InstanceDescriptor {
8758        fn default() -> Self {
8759            Self {
8760                extensions: Vec::new(),
8761                required_features: None,
8762                required_limits: None,
8763            }
8764        }
8765    }
8766    impl InstanceDescriptor {
8767        pub fn new() -> Self {
8768            Self::default()
8769        }
8770        pub(crate) fn to_ffi(
8771            &self,
8772        ) -> (ffi::WGPUInstanceDescriptor, ChainedStructStorage) {
8773            let mut storage = ChainedStructStorage::new();
8774            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8775            for ext in self.extensions.iter().rev() {
8776                next = ext.push_chain(&mut storage, next);
8777            }
8778            let mut raw: ffi::WGPUInstanceDescriptor = unsafe { std::mem::zeroed() };
8779            raw.nextInChain = next;
8780            raw.requiredFeatureCount = self
8781                .required_features
8782                .as_ref()
8783                .map(|v| v.len())
8784                .unwrap_or(0);
8785            if let Some(values) = &self.required_features {
8786                let len_value = values.len();
8787                let raw_vec: Vec<ffi::WGPUInstanceFeatureName> = values
8788                    .iter()
8789                    .map(|v| (*v).into())
8790                    .collect();
8791                let ptr = storage.push_vec(raw_vec);
8792                raw.requiredFeatures = ptr;
8793                raw.requiredFeatureCount = len_value;
8794            } else {
8795                raw.requiredFeatures = std::ptr::null();
8796                raw.requiredFeatureCount = 0;
8797            }
8798            if let Some(value) = &self.required_limits {
8799                let (raw_value, storage_value) = value.to_ffi();
8800                let ptr = storage.push_value(raw_value);
8801                raw.requiredLimits = ptr;
8802                storage.push_storage(storage_value);
8803            } else {
8804                raw.requiredLimits = std::ptr::null();
8805            }
8806            (raw, storage)
8807        }
8808        pub fn with_extension(mut self, extension: InstanceDescriptorExtension) -> Self {
8809            self.extensions.push(extension);
8810            self
8811        }
8812        pub(crate) fn from_ffi(value: ffi::WGPUInstanceDescriptor) -> Self {
8813            Self {
8814                extensions: Vec::new(),
8815                required_features: if value.requiredFeatures.is_null() {
8816                    None
8817                } else {
8818                    Some(
8819                        unsafe {
8820                            std::slice::from_raw_parts(
8821                                value.requiredFeatures,
8822                                value.requiredFeatureCount as usize,
8823                            )
8824                        }
8825                            .iter()
8826                            .map(|raw| InstanceFeatureName::from(*raw))
8827                            .collect(),
8828                    )
8829                },
8830                required_limits: if value.requiredLimits.is_null() {
8831                    None
8832                } else {
8833                    Some(InstanceLimits::from_ffi(unsafe { *value.requiredLimits }))
8834                },
8835            }
8836        }
8837    }
8838    pub struct InstanceLimits {
8839        pub(crate) extensions: Vec<InstanceLimitsExtension>,
8840        pub timed_wait_any_max_count: Option<usize>,
8841    }
8842    impl Default for InstanceLimits {
8843        fn default() -> Self {
8844            Self {
8845                extensions: Vec::new(),
8846                timed_wait_any_max_count: Some(0),
8847            }
8848        }
8849    }
8850    impl InstanceLimits {
8851        pub fn new() -> Self {
8852            Self::default()
8853        }
8854        pub(crate) fn to_ffi(&self) -> (ffi::WGPUInstanceLimits, ChainedStructStorage) {
8855            let mut storage = ChainedStructStorage::new();
8856            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8857            for ext in self.extensions.iter().rev() {
8858                next = ext.push_chain(&mut storage, next);
8859            }
8860            let mut raw: ffi::WGPUInstanceLimits = unsafe { std::mem::zeroed() };
8861            raw.nextInChain = next;
8862            if let Some(value) = self.timed_wait_any_max_count {
8863                raw.timedWaitAnyMaxCount = value;
8864            }
8865            (raw, storage)
8866        }
8867        pub fn with_extension(mut self, extension: InstanceLimitsExtension) -> Self {
8868            self.extensions.push(extension);
8869            self
8870        }
8871        pub(crate) fn from_ffi(value: ffi::WGPUInstanceLimits) -> Self {
8872            Self {
8873                extensions: Vec::new(),
8874                timed_wait_any_max_count: Some(value.timedWaitAnyMaxCount),
8875            }
8876        }
8877    }
8878    pub struct Limits {
8879        pub(crate) extensions: Vec<LimitsExtension>,
8880        pub max_texture_dimension_1d: Option<u32>,
8881        pub max_texture_dimension_2d: Option<u32>,
8882        pub max_texture_dimension_3d: Option<u32>,
8883        pub max_texture_array_layers: Option<u32>,
8884        pub max_bind_groups: Option<u32>,
8885        pub max_bind_groups_plus_vertex_buffers: Option<u32>,
8886        pub max_bindings_per_bind_group: Option<u32>,
8887        pub max_dynamic_uniform_buffers_per_pipeline_layout: Option<u32>,
8888        pub max_dynamic_storage_buffers_per_pipeline_layout: Option<u32>,
8889        pub max_sampled_textures_per_shader_stage: Option<u32>,
8890        pub max_samplers_per_shader_stage: Option<u32>,
8891        pub max_storage_buffers_per_shader_stage: Option<u32>,
8892        pub max_storage_textures_per_shader_stage: Option<u32>,
8893        pub max_uniform_buffers_per_shader_stage: Option<u32>,
8894        pub max_uniform_buffer_binding_size: Option<u64>,
8895        pub max_storage_buffer_binding_size: Option<u64>,
8896        pub min_uniform_buffer_offset_alignment: Option<u32>,
8897        pub min_storage_buffer_offset_alignment: Option<u32>,
8898        pub max_vertex_buffers: Option<u32>,
8899        pub max_buffer_size: Option<u64>,
8900        pub max_vertex_attributes: Option<u32>,
8901        pub max_vertex_buffer_array_stride: Option<u32>,
8902        pub max_inter_stage_shader_variables: Option<u32>,
8903        pub max_color_attachments: Option<u32>,
8904        pub max_color_attachment_bytes_per_sample: Option<u32>,
8905        pub max_compute_workgroup_storage_size: Option<u32>,
8906        pub max_compute_invocations_per_workgroup: Option<u32>,
8907        pub max_compute_workgroup_size_x: Option<u32>,
8908        pub max_compute_workgroup_size_y: Option<u32>,
8909        pub max_compute_workgroup_size_z: Option<u32>,
8910        pub max_compute_workgroups_per_dimension: Option<u32>,
8911        pub max_immediate_size: Option<u32>,
8912    }
8913    impl Default for Limits {
8914        fn default() -> Self {
8915            Self {
8916                extensions: Vec::new(),
8917                max_texture_dimension_1d: Some(LIMIT_U32_UNDEFINED),
8918                max_texture_dimension_2d: Some(LIMIT_U32_UNDEFINED),
8919                max_texture_dimension_3d: Some(LIMIT_U32_UNDEFINED),
8920                max_texture_array_layers: Some(LIMIT_U32_UNDEFINED),
8921                max_bind_groups: Some(LIMIT_U32_UNDEFINED),
8922                max_bind_groups_plus_vertex_buffers: Some(LIMIT_U32_UNDEFINED),
8923                max_bindings_per_bind_group: Some(LIMIT_U32_UNDEFINED),
8924                max_dynamic_uniform_buffers_per_pipeline_layout: Some(
8925                    LIMIT_U32_UNDEFINED,
8926                ),
8927                max_dynamic_storage_buffers_per_pipeline_layout: Some(
8928                    LIMIT_U32_UNDEFINED,
8929                ),
8930                max_sampled_textures_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8931                max_samplers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8932                max_storage_buffers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8933                max_storage_textures_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8934                max_uniform_buffers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8935                max_uniform_buffer_binding_size: Some(LIMIT_U64_UNDEFINED),
8936                max_storage_buffer_binding_size: Some(LIMIT_U64_UNDEFINED),
8937                min_uniform_buffer_offset_alignment: Some(LIMIT_U32_UNDEFINED),
8938                min_storage_buffer_offset_alignment: Some(LIMIT_U32_UNDEFINED),
8939                max_vertex_buffers: Some(LIMIT_U32_UNDEFINED),
8940                max_buffer_size: Some(LIMIT_U64_UNDEFINED),
8941                max_vertex_attributes: Some(LIMIT_U32_UNDEFINED),
8942                max_vertex_buffer_array_stride: Some(LIMIT_U32_UNDEFINED),
8943                max_inter_stage_shader_variables: Some(LIMIT_U32_UNDEFINED),
8944                max_color_attachments: Some(LIMIT_U32_UNDEFINED),
8945                max_color_attachment_bytes_per_sample: Some(LIMIT_U32_UNDEFINED),
8946                max_compute_workgroup_storage_size: Some(LIMIT_U32_UNDEFINED),
8947                max_compute_invocations_per_workgroup: Some(LIMIT_U32_UNDEFINED),
8948                max_compute_workgroup_size_x: Some(LIMIT_U32_UNDEFINED),
8949                max_compute_workgroup_size_y: Some(LIMIT_U32_UNDEFINED),
8950                max_compute_workgroup_size_z: Some(LIMIT_U32_UNDEFINED),
8951                max_compute_workgroups_per_dimension: Some(LIMIT_U32_UNDEFINED),
8952                max_immediate_size: Some(LIMIT_U32_UNDEFINED),
8953            }
8954        }
8955    }
8956    impl Limits {
8957        pub fn new() -> Self {
8958            Self::default()
8959        }
8960        pub(crate) fn to_ffi(&self) -> (ffi::WGPULimits, ChainedStructStorage) {
8961            let mut storage = ChainedStructStorage::new();
8962            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8963            for ext in self.extensions.iter().rev() {
8964                next = ext.push_chain(&mut storage, next);
8965            }
8966            let mut raw: ffi::WGPULimits = unsafe { std::mem::zeroed() };
8967            raw.nextInChain = next;
8968            if let Some(value) = self.max_texture_dimension_1d {
8969                raw.maxTextureDimension1D = value;
8970            }
8971            if let Some(value) = self.max_texture_dimension_2d {
8972                raw.maxTextureDimension2D = value;
8973            }
8974            if let Some(value) = self.max_texture_dimension_3d {
8975                raw.maxTextureDimension3D = value;
8976            }
8977            if let Some(value) = self.max_texture_array_layers {
8978                raw.maxTextureArrayLayers = value;
8979            }
8980            if let Some(value) = self.max_bind_groups {
8981                raw.maxBindGroups = value;
8982            }
8983            if let Some(value) = self.max_bind_groups_plus_vertex_buffers {
8984                raw.maxBindGroupsPlusVertexBuffers = value;
8985            }
8986            if let Some(value) = self.max_bindings_per_bind_group {
8987                raw.maxBindingsPerBindGroup = value;
8988            }
8989            if let Some(value) = self.max_dynamic_uniform_buffers_per_pipeline_layout {
8990                raw.maxDynamicUniformBuffersPerPipelineLayout = value;
8991            }
8992            if let Some(value) = self.max_dynamic_storage_buffers_per_pipeline_layout {
8993                raw.maxDynamicStorageBuffersPerPipelineLayout = value;
8994            }
8995            if let Some(value) = self.max_sampled_textures_per_shader_stage {
8996                raw.maxSampledTexturesPerShaderStage = value;
8997            }
8998            if let Some(value) = self.max_samplers_per_shader_stage {
8999                raw.maxSamplersPerShaderStage = value;
9000            }
9001            if let Some(value) = self.max_storage_buffers_per_shader_stage {
9002                raw.maxStorageBuffersPerShaderStage = value;
9003            }
9004            if let Some(value) = self.max_storage_textures_per_shader_stage {
9005                raw.maxStorageTexturesPerShaderStage = value;
9006            }
9007            if let Some(value) = self.max_uniform_buffers_per_shader_stage {
9008                raw.maxUniformBuffersPerShaderStage = value;
9009            }
9010            if let Some(value) = self.max_uniform_buffer_binding_size {
9011                raw.maxUniformBufferBindingSize = value;
9012            }
9013            if let Some(value) = self.max_storage_buffer_binding_size {
9014                raw.maxStorageBufferBindingSize = value;
9015            }
9016            if let Some(value) = self.min_uniform_buffer_offset_alignment {
9017                raw.minUniformBufferOffsetAlignment = value;
9018            }
9019            if let Some(value) = self.min_storage_buffer_offset_alignment {
9020                raw.minStorageBufferOffsetAlignment = value;
9021            }
9022            if let Some(value) = self.max_vertex_buffers {
9023                raw.maxVertexBuffers = value;
9024            }
9025            if let Some(value) = self.max_buffer_size {
9026                raw.maxBufferSize = value;
9027            }
9028            if let Some(value) = self.max_vertex_attributes {
9029                raw.maxVertexAttributes = value;
9030            }
9031            if let Some(value) = self.max_vertex_buffer_array_stride {
9032                raw.maxVertexBufferArrayStride = value;
9033            }
9034            if let Some(value) = self.max_inter_stage_shader_variables {
9035                raw.maxInterStageShaderVariables = value;
9036            }
9037            if let Some(value) = self.max_color_attachments {
9038                raw.maxColorAttachments = value;
9039            }
9040            if let Some(value) = self.max_color_attachment_bytes_per_sample {
9041                raw.maxColorAttachmentBytesPerSample = value;
9042            }
9043            if let Some(value) = self.max_compute_workgroup_storage_size {
9044                raw.maxComputeWorkgroupStorageSize = value;
9045            }
9046            if let Some(value) = self.max_compute_invocations_per_workgroup {
9047                raw.maxComputeInvocationsPerWorkgroup = value;
9048            }
9049            if let Some(value) = self.max_compute_workgroup_size_x {
9050                raw.maxComputeWorkgroupSizeX = value;
9051            }
9052            if let Some(value) = self.max_compute_workgroup_size_y {
9053                raw.maxComputeWorkgroupSizeY = value;
9054            }
9055            if let Some(value) = self.max_compute_workgroup_size_z {
9056                raw.maxComputeWorkgroupSizeZ = value;
9057            }
9058            if let Some(value) = self.max_compute_workgroups_per_dimension {
9059                raw.maxComputeWorkgroupsPerDimension = value;
9060            }
9061            if let Some(value) = self.max_immediate_size {
9062                raw.maxImmediateSize = value;
9063            }
9064            (raw, storage)
9065        }
9066        pub fn with_extension(mut self, extension: LimitsExtension) -> Self {
9067            self.extensions.push(extension);
9068            self
9069        }
9070        pub(crate) fn from_ffi(value: ffi::WGPULimits) -> Self {
9071            Self {
9072                extensions: Vec::new(),
9073                max_texture_dimension_1d: Some(value.maxTextureDimension1D),
9074                max_texture_dimension_2d: Some(value.maxTextureDimension2D),
9075                max_texture_dimension_3d: Some(value.maxTextureDimension3D),
9076                max_texture_array_layers: Some(value.maxTextureArrayLayers),
9077                max_bind_groups: Some(value.maxBindGroups),
9078                max_bind_groups_plus_vertex_buffers: Some(
9079                    value.maxBindGroupsPlusVertexBuffers,
9080                ),
9081                max_bindings_per_bind_group: Some(value.maxBindingsPerBindGroup),
9082                max_dynamic_uniform_buffers_per_pipeline_layout: Some(
9083                    value.maxDynamicUniformBuffersPerPipelineLayout,
9084                ),
9085                max_dynamic_storage_buffers_per_pipeline_layout: Some(
9086                    value.maxDynamicStorageBuffersPerPipelineLayout,
9087                ),
9088                max_sampled_textures_per_shader_stage: Some(
9089                    value.maxSampledTexturesPerShaderStage,
9090                ),
9091                max_samplers_per_shader_stage: Some(value.maxSamplersPerShaderStage),
9092                max_storage_buffers_per_shader_stage: Some(
9093                    value.maxStorageBuffersPerShaderStage,
9094                ),
9095                max_storage_textures_per_shader_stage: Some(
9096                    value.maxStorageTexturesPerShaderStage,
9097                ),
9098                max_uniform_buffers_per_shader_stage: Some(
9099                    value.maxUniformBuffersPerShaderStage,
9100                ),
9101                max_uniform_buffer_binding_size: Some(value.maxUniformBufferBindingSize),
9102                max_storage_buffer_binding_size: Some(value.maxStorageBufferBindingSize),
9103                min_uniform_buffer_offset_alignment: Some(
9104                    value.minUniformBufferOffsetAlignment,
9105                ),
9106                min_storage_buffer_offset_alignment: Some(
9107                    value.minStorageBufferOffsetAlignment,
9108                ),
9109                max_vertex_buffers: Some(value.maxVertexBuffers),
9110                max_buffer_size: Some(value.maxBufferSize),
9111                max_vertex_attributes: Some(value.maxVertexAttributes),
9112                max_vertex_buffer_array_stride: Some(value.maxVertexBufferArrayStride),
9113                max_inter_stage_shader_variables: Some(
9114                    value.maxInterStageShaderVariables,
9115                ),
9116                max_color_attachments: Some(value.maxColorAttachments),
9117                max_color_attachment_bytes_per_sample: Some(
9118                    value.maxColorAttachmentBytesPerSample,
9119                ),
9120                max_compute_workgroup_storage_size: Some(
9121                    value.maxComputeWorkgroupStorageSize,
9122                ),
9123                max_compute_invocations_per_workgroup: Some(
9124                    value.maxComputeInvocationsPerWorkgroup,
9125                ),
9126                max_compute_workgroup_size_x: Some(value.maxComputeWorkgroupSizeX),
9127                max_compute_workgroup_size_y: Some(value.maxComputeWorkgroupSizeY),
9128                max_compute_workgroup_size_z: Some(value.maxComputeWorkgroupSizeZ),
9129                max_compute_workgroups_per_dimension: Some(
9130                    value.maxComputeWorkgroupsPerDimension,
9131                ),
9132                max_immediate_size: Some(value.maxImmediateSize),
9133            }
9134        }
9135    }
9136    pub struct MemoryHeapInfo {
9137        pub properties: Option<HeapProperty>,
9138        pub size: Option<u64>,
9139    }
9140    impl Default for MemoryHeapInfo {
9141        fn default() -> Self {
9142            Self {
9143                properties: None,
9144                size: None,
9145            }
9146        }
9147    }
9148    impl MemoryHeapInfo {
9149        pub fn new() -> Self {
9150            Self::default()
9151        }
9152        pub(crate) fn to_ffi(&self) -> (ffi::WGPUMemoryHeapInfo, ChainedStructStorage) {
9153            let mut storage = ChainedStructStorage::new();
9154            let mut raw: ffi::WGPUMemoryHeapInfo = unsafe { std::mem::zeroed() };
9155            if let Some(value) = self.properties {
9156                raw.properties = value.into();
9157            } else {
9158                raw.properties = 0 as ffi::WGPUHeapProperty;
9159            }
9160            if let Some(value) = self.size {
9161                raw.size = value;
9162            }
9163            (raw, storage)
9164        }
9165        pub(crate) fn from_ffi(value: ffi::WGPUMemoryHeapInfo) -> Self {
9166            Self {
9167                properties: Some(value.properties.into()),
9168                size: Some(value.size),
9169            }
9170        }
9171    }
9172    pub struct MultisampleState {
9173        pub(crate) extensions: Vec<MultisampleStateExtension>,
9174        pub count: Option<u32>,
9175        pub mask: Option<u32>,
9176        pub alpha_to_coverage_enabled: Option<bool>,
9177    }
9178    impl Default for MultisampleState {
9179        fn default() -> Self {
9180            Self {
9181                extensions: Vec::new(),
9182                count: Some(1),
9183                mask: Some(4294967295),
9184                alpha_to_coverage_enabled: None,
9185            }
9186        }
9187    }
9188    impl MultisampleState {
9189        pub fn new() -> Self {
9190            Self::default()
9191        }
9192        pub(crate) fn to_ffi(
9193            &self,
9194        ) -> (ffi::WGPUMultisampleState, ChainedStructStorage) {
9195            let mut storage = ChainedStructStorage::new();
9196            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9197            for ext in self.extensions.iter().rev() {
9198                next = ext.push_chain(&mut storage, next);
9199            }
9200            let mut raw: ffi::WGPUMultisampleState = unsafe { std::mem::zeroed() };
9201            raw.nextInChain = next;
9202            if let Some(value) = self.count {
9203                raw.count = value;
9204            }
9205            if let Some(value) = self.mask {
9206                raw.mask = value;
9207            }
9208            raw.alphaToCoverageEnabled = if self
9209                .alpha_to_coverage_enabled
9210                .unwrap_or(false)
9211            {
9212                1
9213            } else {
9214                0
9215            };
9216            (raw, storage)
9217        }
9218        pub fn with_extension(mut self, extension: MultisampleStateExtension) -> Self {
9219            self.extensions.push(extension);
9220            self
9221        }
9222        pub(crate) fn from_ffi(value: ffi::WGPUMultisampleState) -> Self {
9223            Self {
9224                extensions: Vec::new(),
9225                count: Some(value.count),
9226                mask: Some(value.mask),
9227                alpha_to_coverage_enabled: Some(value.alphaToCoverageEnabled != 0),
9228            }
9229        }
9230    }
9231    pub struct Origin2D {
9232        pub x: Option<u32>,
9233        pub y: Option<u32>,
9234    }
9235    impl Default for Origin2D {
9236        fn default() -> Self {
9237            Self { x: Some(0), y: Some(0) }
9238        }
9239    }
9240    impl Origin2D {
9241        pub fn new() -> Self {
9242            Self::default()
9243        }
9244        pub(crate) fn to_ffi(&self) -> (ffi::WGPUOrigin2D, ChainedStructStorage) {
9245            let mut storage = ChainedStructStorage::new();
9246            let mut raw: ffi::WGPUOrigin2D = unsafe { std::mem::zeroed() };
9247            if let Some(value) = self.x {
9248                raw.x = value;
9249            }
9250            if let Some(value) = self.y {
9251                raw.y = value;
9252            }
9253            (raw, storage)
9254        }
9255        pub(crate) fn from_ffi(value: ffi::WGPUOrigin2D) -> Self {
9256            Self {
9257                x: Some(value.x),
9258                y: Some(value.y),
9259            }
9260        }
9261    }
9262    pub struct Origin3D {
9263        pub x: Option<u32>,
9264        pub y: Option<u32>,
9265        pub z: Option<u32>,
9266    }
9267    impl Default for Origin3D {
9268        fn default() -> Self {
9269            Self {
9270                x: Some(0),
9271                y: Some(0),
9272                z: Some(0),
9273            }
9274        }
9275    }
9276    impl Origin3D {
9277        pub fn new() -> Self {
9278            Self::default()
9279        }
9280        pub(crate) fn to_ffi(&self) -> (ffi::WGPUOrigin3D, ChainedStructStorage) {
9281            let mut storage = ChainedStructStorage::new();
9282            let mut raw: ffi::WGPUOrigin3D = unsafe { std::mem::zeroed() };
9283            if let Some(value) = self.x {
9284                raw.x = value;
9285            }
9286            if let Some(value) = self.y {
9287                raw.y = value;
9288            }
9289            if let Some(value) = self.z {
9290                raw.z = value;
9291            }
9292            (raw, storage)
9293        }
9294        pub(crate) fn from_ffi(value: ffi::WGPUOrigin3D) -> Self {
9295            Self {
9296                x: Some(value.x),
9297                y: Some(value.y),
9298                z: Some(value.z),
9299            }
9300        }
9301    }
9302    pub struct PassTimestampWrites {
9303        pub(crate) extensions: Vec<PassTimestampWritesExtension>,
9304        pub query_set: Option<QuerySet>,
9305        pub beginning_of_pass_write_index: Option<u32>,
9306        pub end_of_pass_write_index: Option<u32>,
9307    }
9308    impl Default for PassTimestampWrites {
9309        fn default() -> Self {
9310            Self {
9311                extensions: Vec::new(),
9312                query_set: None,
9313                beginning_of_pass_write_index: Some(QUERY_SET_INDEX_UNDEFINED),
9314                end_of_pass_write_index: Some(QUERY_SET_INDEX_UNDEFINED),
9315            }
9316        }
9317    }
9318    impl PassTimestampWrites {
9319        pub fn new() -> Self {
9320            Self::default()
9321        }
9322        pub(crate) fn to_ffi(
9323            &self,
9324        ) -> (ffi::WGPUPassTimestampWrites, ChainedStructStorage) {
9325            let mut storage = ChainedStructStorage::new();
9326            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9327            for ext in self.extensions.iter().rev() {
9328                next = ext.push_chain(&mut storage, next);
9329            }
9330            let mut raw: ffi::WGPUPassTimestampWrites = unsafe { std::mem::zeroed() };
9331            raw.nextInChain = next;
9332            raw.querySet = self
9333                .query_set
9334                .as_ref()
9335                .map(|v| v.as_raw())
9336                .unwrap_or(std::ptr::null_mut());
9337            if let Some(value) = self.beginning_of_pass_write_index {
9338                raw.beginningOfPassWriteIndex = value;
9339            }
9340            if let Some(value) = self.end_of_pass_write_index {
9341                raw.endOfPassWriteIndex = value;
9342            }
9343            (raw, storage)
9344        }
9345        pub fn with_extension(
9346            mut self,
9347            extension: PassTimestampWritesExtension,
9348        ) -> Self {
9349            self.extensions.push(extension);
9350            self
9351        }
9352        pub(crate) fn from_ffi(value: ffi::WGPUPassTimestampWrites) -> Self {
9353            Self {
9354                extensions: Vec::new(),
9355                query_set: Some(unsafe { QuerySet::from_raw(value.querySet) }),
9356                beginning_of_pass_write_index: Some(value.beginningOfPassWriteIndex),
9357                end_of_pass_write_index: Some(value.endOfPassWriteIndex),
9358            }
9359        }
9360    }
9361    pub struct PipelineLayoutDescriptor {
9362        pub(crate) extensions: Vec<PipelineLayoutDescriptorExtension>,
9363        pub label: Option<String>,
9364        pub bind_group_layouts: Option<Vec<BindGroupLayout>>,
9365        pub immediate_size: Option<u32>,
9366    }
9367    impl Default for PipelineLayoutDescriptor {
9368        fn default() -> Self {
9369            Self {
9370                extensions: Vec::new(),
9371                label: None,
9372                bind_group_layouts: None,
9373                immediate_size: Some(0),
9374            }
9375        }
9376    }
9377    impl PipelineLayoutDescriptor {
9378        pub fn new() -> Self {
9379            Self::default()
9380        }
9381        pub(crate) fn to_ffi(
9382            &self,
9383        ) -> (ffi::WGPUPipelineLayoutDescriptor, ChainedStructStorage) {
9384            let mut storage = ChainedStructStorage::new();
9385            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9386            for ext in self.extensions.iter().rev() {
9387                next = ext.push_chain(&mut storage, next);
9388            }
9389            let mut raw: ffi::WGPUPipelineLayoutDescriptor = unsafe {
9390                std::mem::zeroed()
9391            };
9392            raw.nextInChain = next;
9393            if let Some(value) = &self.label {
9394                raw.label = ffi::WGPUStringView {
9395                    data: value.as_ptr().cast(),
9396                    length: value.len(),
9397                };
9398            } else {
9399                raw.label = ffi::WGPUStringView {
9400                    data: std::ptr::null(),
9401                    length: 0,
9402                };
9403            }
9404            raw.bindGroupLayoutCount = self
9405                .bind_group_layouts
9406                .as_ref()
9407                .map(|v| v.len())
9408                .unwrap_or(0);
9409            if let Some(values) = &self.bind_group_layouts {
9410                let len_value = values.len();
9411                let raw_vec: Vec<ffi::WGPUBindGroupLayout> = values
9412                    .iter()
9413                    .map(|v| v.as_raw())
9414                    .collect();
9415                let ptr = storage.push_vec(raw_vec);
9416                raw.bindGroupLayouts = ptr;
9417                raw.bindGroupLayoutCount = len_value;
9418            } else {
9419                raw.bindGroupLayouts = std::ptr::null();
9420                raw.bindGroupLayoutCount = 0;
9421            }
9422            if let Some(value) = self.immediate_size {
9423                raw.immediateSize = value;
9424            }
9425            (raw, storage)
9426        }
9427        pub fn with_extension(
9428            mut self,
9429            extension: PipelineLayoutDescriptorExtension,
9430        ) -> Self {
9431            self.extensions.push(extension);
9432            self
9433        }
9434        pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutDescriptor) -> Self {
9435            Self {
9436                extensions: Vec::new(),
9437                label: if value.label.data.is_null() || value.label.length == 0 {
9438                    None
9439                } else {
9440                    Some(string_view_to_string(value.label))
9441                },
9442                bind_group_layouts: if value.bindGroupLayouts.is_null() {
9443                    None
9444                } else {
9445                    Some(
9446                        unsafe {
9447                            std::slice::from_raw_parts(
9448                                value.bindGroupLayouts,
9449                                value.bindGroupLayoutCount as usize,
9450                            )
9451                        }
9452                            .iter()
9453                            .map(|raw| unsafe { BindGroupLayout::from_raw(*raw) })
9454                            .collect(),
9455                    )
9456                },
9457                immediate_size: Some(value.immediateSize),
9458            }
9459        }
9460    }
9461    pub struct PipelineLayoutPixelLocalStorage {
9462        pub total_pixel_local_storage_size: Option<u64>,
9463        pub storage_attachments: Option<Vec<PipelineLayoutStorageAttachment>>,
9464    }
9465    impl Default for PipelineLayoutPixelLocalStorage {
9466        fn default() -> Self {
9467            Self {
9468                total_pixel_local_storage_size: None,
9469                storage_attachments: None,
9470            }
9471        }
9472    }
9473    impl PipelineLayoutPixelLocalStorage {
9474        pub fn new() -> Self {
9475            Self::default()
9476        }
9477        pub(crate) fn to_ffi(
9478            &self,
9479        ) -> (ffi::WGPUPipelineLayoutPixelLocalStorage, ChainedStructStorage) {
9480            let mut storage = ChainedStructStorage::new();
9481            let mut raw: ffi::WGPUPipelineLayoutPixelLocalStorage = unsafe {
9482                std::mem::zeroed()
9483            };
9484            if let Some(value) = self.total_pixel_local_storage_size {
9485                raw.totalPixelLocalStorageSize = value;
9486            }
9487            raw.storageAttachmentCount = self
9488                .storage_attachments
9489                .as_ref()
9490                .map(|v| v.len())
9491                .unwrap_or(0);
9492            if let Some(values) = &self.storage_attachments {
9493                let len_value = values.len();
9494                let mut raw_vec: Vec<ffi::WGPUPipelineLayoutStorageAttachment> = Vec::with_capacity(
9495                    values.len(),
9496                );
9497                for item in values.iter() {
9498                    let (raw_item, storage_item) = item.to_ffi();
9499                    raw_vec.push(raw_item);
9500                    storage.push_storage(storage_item);
9501                }
9502                let ptr = storage.push_vec(raw_vec);
9503                raw.storageAttachments = ptr;
9504                raw.storageAttachmentCount = len_value;
9505            } else {
9506                raw.storageAttachments = std::ptr::null();
9507                raw.storageAttachmentCount = 0;
9508            }
9509            (raw, storage)
9510        }
9511        pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutPixelLocalStorage) -> Self {
9512            Self {
9513                total_pixel_local_storage_size: Some(value.totalPixelLocalStorageSize),
9514                storage_attachments: if value.storageAttachments.is_null() {
9515                    None
9516                } else {
9517                    Some(
9518                        unsafe {
9519                            std::slice::from_raw_parts(
9520                                value.storageAttachments,
9521                                value.storageAttachmentCount as usize,
9522                            )
9523                        }
9524                            .iter()
9525                            .map(|raw| PipelineLayoutStorageAttachment::from_ffi(*raw))
9526                            .collect(),
9527                    )
9528                },
9529            }
9530        }
9531    }
9532    pub struct PipelineLayoutResourceTable {
9533        pub uses_resource_table: Option<bool>,
9534    }
9535    impl Default for PipelineLayoutResourceTable {
9536        fn default() -> Self {
9537            Self { uses_resource_table: None }
9538        }
9539    }
9540    impl PipelineLayoutResourceTable {
9541        pub fn new() -> Self {
9542            Self::default()
9543        }
9544        pub(crate) fn to_ffi(
9545            &self,
9546        ) -> (ffi::WGPUPipelineLayoutResourceTable, ChainedStructStorage) {
9547            let mut storage = ChainedStructStorage::new();
9548            let mut raw: ffi::WGPUPipelineLayoutResourceTable = unsafe {
9549                std::mem::zeroed()
9550            };
9551            raw.usesResourceTable = if self.uses_resource_table.unwrap_or(false) {
9552                1
9553            } else {
9554                0
9555            };
9556            (raw, storage)
9557        }
9558        pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutResourceTable) -> Self {
9559            Self {
9560                uses_resource_table: Some(value.usesResourceTable != 0),
9561            }
9562        }
9563    }
9564    pub struct PipelineLayoutStorageAttachment {
9565        pub(crate) extensions: Vec<PipelineLayoutStorageAttachmentExtension>,
9566        pub offset: Option<u64>,
9567        pub format: Option<TextureFormat>,
9568    }
9569    impl Default for PipelineLayoutStorageAttachment {
9570        fn default() -> Self {
9571            Self {
9572                extensions: Vec::new(),
9573                offset: Some(0),
9574                format: None,
9575            }
9576        }
9577    }
9578    impl PipelineLayoutStorageAttachment {
9579        pub fn new() -> Self {
9580            Self::default()
9581        }
9582        pub(crate) fn to_ffi(
9583            &self,
9584        ) -> (ffi::WGPUPipelineLayoutStorageAttachment, ChainedStructStorage) {
9585            let mut storage = ChainedStructStorage::new();
9586            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9587            for ext in self.extensions.iter().rev() {
9588                next = ext.push_chain(&mut storage, next);
9589            }
9590            let mut raw: ffi::WGPUPipelineLayoutStorageAttachment = unsafe {
9591                std::mem::zeroed()
9592            };
9593            raw.nextInChain = next;
9594            if let Some(value) = self.offset {
9595                raw.offset = value;
9596            }
9597            if let Some(value) = self.format {
9598                raw.format = value.into();
9599            } else {
9600                raw.format = 0 as ffi::WGPUTextureFormat;
9601            }
9602            (raw, storage)
9603        }
9604        pub fn with_extension(
9605            mut self,
9606            extension: PipelineLayoutStorageAttachmentExtension,
9607        ) -> Self {
9608            self.extensions.push(extension);
9609            self
9610        }
9611        pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutStorageAttachment) -> Self {
9612            Self {
9613                extensions: Vec::new(),
9614                offset: Some(value.offset),
9615                format: Some(value.format.into()),
9616            }
9617        }
9618    }
9619    pub struct PrimitiveState {
9620        pub(crate) extensions: Vec<PrimitiveStateExtension>,
9621        pub topology: Option<PrimitiveTopology>,
9622        pub strip_index_format: Option<IndexFormat>,
9623        pub front_face: Option<FrontFace>,
9624        pub cull_mode: Option<CullMode>,
9625        pub unclipped_depth: Option<bool>,
9626    }
9627    impl Default for PrimitiveState {
9628        fn default() -> Self {
9629            Self {
9630                extensions: Vec::new(),
9631                topology: Some(PrimitiveTopology::TriangleList),
9632                strip_index_format: None,
9633                front_face: Some(FrontFace::Ccw),
9634                cull_mode: Some(CullMode::None),
9635                unclipped_depth: None,
9636            }
9637        }
9638    }
9639    impl PrimitiveState {
9640        pub fn new() -> Self {
9641            Self::default()
9642        }
9643        pub(crate) fn to_ffi(&self) -> (ffi::WGPUPrimitiveState, ChainedStructStorage) {
9644            let mut storage = ChainedStructStorage::new();
9645            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9646            for ext in self.extensions.iter().rev() {
9647                next = ext.push_chain(&mut storage, next);
9648            }
9649            let mut raw: ffi::WGPUPrimitiveState = unsafe { std::mem::zeroed() };
9650            raw.nextInChain = next;
9651            if let Some(value) = self.topology {
9652                raw.topology = value.into();
9653            } else {
9654                raw.topology = 0 as ffi::WGPUPrimitiveTopology;
9655            }
9656            if let Some(value) = self.strip_index_format {
9657                raw.stripIndexFormat = value.into();
9658            } else {
9659                raw.stripIndexFormat = 0 as ffi::WGPUIndexFormat;
9660            }
9661            if let Some(value) = self.front_face {
9662                raw.frontFace = value.into();
9663            } else {
9664                raw.frontFace = 0 as ffi::WGPUFrontFace;
9665            }
9666            if let Some(value) = self.cull_mode {
9667                raw.cullMode = value.into();
9668            } else {
9669                raw.cullMode = 0 as ffi::WGPUCullMode;
9670            }
9671            raw.unclippedDepth = if self.unclipped_depth.unwrap_or(false) {
9672                1
9673            } else {
9674                0
9675            };
9676            (raw, storage)
9677        }
9678        pub fn with_extension(mut self, extension: PrimitiveStateExtension) -> Self {
9679            self.extensions.push(extension);
9680            self
9681        }
9682        pub(crate) fn from_ffi(value: ffi::WGPUPrimitiveState) -> Self {
9683            Self {
9684                extensions: Vec::new(),
9685                topology: Some(value.topology.into()),
9686                strip_index_format: Some(value.stripIndexFormat.into()),
9687                front_face: Some(value.frontFace.into()),
9688                cull_mode: Some(value.cullMode.into()),
9689                unclipped_depth: Some(value.unclippedDepth != 0),
9690            }
9691        }
9692    }
9693    pub struct QuerySetDescriptor {
9694        pub(crate) extensions: Vec<QuerySetDescriptorExtension>,
9695        pub label: Option<String>,
9696        pub r#type: Option<QueryType>,
9697        pub count: Option<u32>,
9698    }
9699    impl Default for QuerySetDescriptor {
9700        fn default() -> Self {
9701            Self {
9702                extensions: Vec::new(),
9703                label: None,
9704                r#type: None,
9705                count: None,
9706            }
9707        }
9708    }
9709    impl QuerySetDescriptor {
9710        pub fn new() -> Self {
9711            Self::default()
9712        }
9713        pub(crate) fn to_ffi(
9714            &self,
9715        ) -> (ffi::WGPUQuerySetDescriptor, ChainedStructStorage) {
9716            let mut storage = ChainedStructStorage::new();
9717            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9718            for ext in self.extensions.iter().rev() {
9719                next = ext.push_chain(&mut storage, next);
9720            }
9721            let mut raw: ffi::WGPUQuerySetDescriptor = unsafe { std::mem::zeroed() };
9722            raw.nextInChain = next;
9723            if let Some(value) = &self.label {
9724                raw.label = ffi::WGPUStringView {
9725                    data: value.as_ptr().cast(),
9726                    length: value.len(),
9727                };
9728            } else {
9729                raw.label = ffi::WGPUStringView {
9730                    data: std::ptr::null(),
9731                    length: 0,
9732                };
9733            }
9734            if let Some(value) = self.r#type {
9735                raw.type_ = value.into();
9736            } else {
9737                raw.type_ = 0 as ffi::WGPUQueryType;
9738            }
9739            if let Some(value) = self.count {
9740                raw.count = value;
9741            }
9742            (raw, storage)
9743        }
9744        pub fn with_extension(mut self, extension: QuerySetDescriptorExtension) -> Self {
9745            self.extensions.push(extension);
9746            self
9747        }
9748        pub(crate) fn from_ffi(value: ffi::WGPUQuerySetDescriptor) -> Self {
9749            Self {
9750                extensions: Vec::new(),
9751                label: if value.label.data.is_null() || value.label.length == 0 {
9752                    None
9753                } else {
9754                    Some(string_view_to_string(value.label))
9755                },
9756                r#type: Some(value.type_.into()),
9757                count: Some(value.count),
9758            }
9759        }
9760    }
9761    pub struct QueueDescriptor {
9762        pub(crate) extensions: Vec<QueueDescriptorExtension>,
9763        pub label: Option<String>,
9764    }
9765    impl Default for QueueDescriptor {
9766        fn default() -> Self {
9767            Self {
9768                extensions: Vec::new(),
9769                label: None,
9770            }
9771        }
9772    }
9773    impl QueueDescriptor {
9774        pub fn new() -> Self {
9775            Self::default()
9776        }
9777        pub(crate) fn to_ffi(&self) -> (ffi::WGPUQueueDescriptor, ChainedStructStorage) {
9778            let mut storage = ChainedStructStorage::new();
9779            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9780            for ext in self.extensions.iter().rev() {
9781                next = ext.push_chain(&mut storage, next);
9782            }
9783            let mut raw: ffi::WGPUQueueDescriptor = unsafe { std::mem::zeroed() };
9784            raw.nextInChain = next;
9785            if let Some(value) = &self.label {
9786                raw.label = ffi::WGPUStringView {
9787                    data: value.as_ptr().cast(),
9788                    length: value.len(),
9789                };
9790            } else {
9791                raw.label = ffi::WGPUStringView {
9792                    data: std::ptr::null(),
9793                    length: 0,
9794                };
9795            }
9796            (raw, storage)
9797        }
9798        pub fn with_extension(mut self, extension: QueueDescriptorExtension) -> Self {
9799            self.extensions.push(extension);
9800            self
9801        }
9802        pub(crate) fn from_ffi(value: ffi::WGPUQueueDescriptor) -> Self {
9803            Self {
9804                extensions: Vec::new(),
9805                label: if value.label.data.is_null() || value.label.length == 0 {
9806                    None
9807                } else {
9808                    Some(string_view_to_string(value.label))
9809                },
9810            }
9811        }
9812    }
9813    pub struct RenderBundleDescriptor {
9814        pub(crate) extensions: Vec<RenderBundleDescriptorExtension>,
9815        pub label: Option<String>,
9816    }
9817    impl Default for RenderBundleDescriptor {
9818        fn default() -> Self {
9819            Self {
9820                extensions: Vec::new(),
9821                label: None,
9822            }
9823        }
9824    }
9825    impl RenderBundleDescriptor {
9826        pub fn new() -> Self {
9827            Self::default()
9828        }
9829        pub(crate) fn to_ffi(
9830            &self,
9831        ) -> (ffi::WGPURenderBundleDescriptor, ChainedStructStorage) {
9832            let mut storage = ChainedStructStorage::new();
9833            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9834            for ext in self.extensions.iter().rev() {
9835                next = ext.push_chain(&mut storage, next);
9836            }
9837            let mut raw: ffi::WGPURenderBundleDescriptor = unsafe { std::mem::zeroed() };
9838            raw.nextInChain = next;
9839            if let Some(value) = &self.label {
9840                raw.label = ffi::WGPUStringView {
9841                    data: value.as_ptr().cast(),
9842                    length: value.len(),
9843                };
9844            } else {
9845                raw.label = ffi::WGPUStringView {
9846                    data: std::ptr::null(),
9847                    length: 0,
9848                };
9849            }
9850            (raw, storage)
9851        }
9852        pub fn with_extension(
9853            mut self,
9854            extension: RenderBundleDescriptorExtension,
9855        ) -> Self {
9856            self.extensions.push(extension);
9857            self
9858        }
9859        pub(crate) fn from_ffi(value: ffi::WGPURenderBundleDescriptor) -> Self {
9860            Self {
9861                extensions: Vec::new(),
9862                label: if value.label.data.is_null() || value.label.length == 0 {
9863                    None
9864                } else {
9865                    Some(string_view_to_string(value.label))
9866                },
9867            }
9868        }
9869    }
9870    pub struct RenderBundleEncoderDescriptor {
9871        pub(crate) extensions: Vec<RenderBundleEncoderDescriptorExtension>,
9872        pub label: Option<String>,
9873        pub color_formats: Option<Vec<TextureFormat>>,
9874        pub depth_stencil_format: Option<TextureFormat>,
9875        pub sample_count: Option<u32>,
9876        pub depth_read_only: Option<bool>,
9877        pub stencil_read_only: Option<bool>,
9878    }
9879    impl Default for RenderBundleEncoderDescriptor {
9880        fn default() -> Self {
9881            Self {
9882                extensions: Vec::new(),
9883                label: None,
9884                color_formats: None,
9885                depth_stencil_format: None,
9886                sample_count: Some(1),
9887                depth_read_only: None,
9888                stencil_read_only: None,
9889            }
9890        }
9891    }
9892    impl RenderBundleEncoderDescriptor {
9893        pub fn new() -> Self {
9894            Self::default()
9895        }
9896        pub(crate) fn to_ffi(
9897            &self,
9898        ) -> (ffi::WGPURenderBundleEncoderDescriptor, ChainedStructStorage) {
9899            let mut storage = ChainedStructStorage::new();
9900            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9901            for ext in self.extensions.iter().rev() {
9902                next = ext.push_chain(&mut storage, next);
9903            }
9904            let mut raw: ffi::WGPURenderBundleEncoderDescriptor = unsafe {
9905                std::mem::zeroed()
9906            };
9907            raw.nextInChain = next;
9908            if let Some(value) = &self.label {
9909                raw.label = ffi::WGPUStringView {
9910                    data: value.as_ptr().cast(),
9911                    length: value.len(),
9912                };
9913            } else {
9914                raw.label = ffi::WGPUStringView {
9915                    data: std::ptr::null(),
9916                    length: 0,
9917                };
9918            }
9919            raw.colorFormatCount = self
9920                .color_formats
9921                .as_ref()
9922                .map(|v| v.len())
9923                .unwrap_or(0);
9924            if let Some(values) = &self.color_formats {
9925                let len_value = values.len();
9926                let raw_vec: Vec<ffi::WGPUTextureFormat> = values
9927                    .iter()
9928                    .map(|v| (*v).into())
9929                    .collect();
9930                let ptr = storage.push_vec(raw_vec);
9931                raw.colorFormats = ptr;
9932                raw.colorFormatCount = len_value;
9933            } else {
9934                raw.colorFormats = std::ptr::null();
9935                raw.colorFormatCount = 0;
9936            }
9937            if let Some(value) = self.depth_stencil_format {
9938                raw.depthStencilFormat = value.into();
9939            } else {
9940                raw.depthStencilFormat = 0 as ffi::WGPUTextureFormat;
9941            }
9942            if let Some(value) = self.sample_count {
9943                raw.sampleCount = value;
9944            }
9945            raw.depthReadOnly = if self.depth_read_only.unwrap_or(false) {
9946                1
9947            } else {
9948                0
9949            };
9950            raw.stencilReadOnly = if self.stencil_read_only.unwrap_or(false) {
9951                1
9952            } else {
9953                0
9954            };
9955            (raw, storage)
9956        }
9957        pub fn with_extension(
9958            mut self,
9959            extension: RenderBundleEncoderDescriptorExtension,
9960        ) -> Self {
9961            self.extensions.push(extension);
9962            self
9963        }
9964        pub(crate) fn from_ffi(value: ffi::WGPURenderBundleEncoderDescriptor) -> Self {
9965            Self {
9966                extensions: Vec::new(),
9967                label: if value.label.data.is_null() || value.label.length == 0 {
9968                    None
9969                } else {
9970                    Some(string_view_to_string(value.label))
9971                },
9972                color_formats: if value.colorFormats.is_null() {
9973                    None
9974                } else {
9975                    Some(
9976                        unsafe {
9977                            std::slice::from_raw_parts(
9978                                value.colorFormats,
9979                                value.colorFormatCount as usize,
9980                            )
9981                        }
9982                            .iter()
9983                            .map(|raw| TextureFormat::from(*raw))
9984                            .collect(),
9985                    )
9986                },
9987                depth_stencil_format: Some(value.depthStencilFormat.into()),
9988                sample_count: Some(value.sampleCount),
9989                depth_read_only: Some(value.depthReadOnly != 0),
9990                stencil_read_only: Some(value.stencilReadOnly != 0),
9991            }
9992        }
9993    }
9994    pub struct RenderPassColorAttachment {
9995        pub(crate) extensions: Vec<RenderPassColorAttachmentExtension>,
9996        pub view: Option<TextureView>,
9997        pub depth_slice: Option<u32>,
9998        pub resolve_target: Option<TextureView>,
9999        pub load_op: Option<LoadOp>,
10000        pub store_op: Option<StoreOp>,
10001        pub clear_value: Option<Color>,
10002    }
10003    impl Default for RenderPassColorAttachment {
10004        fn default() -> Self {
10005            Self {
10006                extensions: Vec::new(),
10007                view: None,
10008                depth_slice: Some(DEPTH_SLICE_UNDEFINED),
10009                resolve_target: None,
10010                load_op: None,
10011                store_op: None,
10012                clear_value: None,
10013            }
10014        }
10015    }
10016    impl RenderPassColorAttachment {
10017        pub fn new() -> Self {
10018            Self::default()
10019        }
10020        pub(crate) fn to_ffi(
10021            &self,
10022        ) -> (ffi::WGPURenderPassColorAttachment, ChainedStructStorage) {
10023            let mut storage = ChainedStructStorage::new();
10024            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10025            for ext in self.extensions.iter().rev() {
10026                next = ext.push_chain(&mut storage, next);
10027            }
10028            let mut raw: ffi::WGPURenderPassColorAttachment = unsafe {
10029                std::mem::zeroed()
10030            };
10031            raw.nextInChain = next;
10032            raw.view = self
10033                .view
10034                .as_ref()
10035                .map(|v| v.as_raw())
10036                .unwrap_or(std::ptr::null_mut());
10037            if let Some(value) = self.depth_slice {
10038                raw.depthSlice = value;
10039            }
10040            raw.resolveTarget = self
10041                .resolve_target
10042                .as_ref()
10043                .map(|v| v.as_raw())
10044                .unwrap_or(std::ptr::null_mut());
10045            if let Some(value) = self.load_op {
10046                raw.loadOp = value.into();
10047            } else {
10048                raw.loadOp = 0 as ffi::WGPULoadOp;
10049            }
10050            if let Some(value) = self.store_op {
10051                raw.storeOp = value.into();
10052            } else {
10053                raw.storeOp = 0 as ffi::WGPUStoreOp;
10054            }
10055            if let Some(value) = &self.clear_value {
10056                let (raw_value, storage_value) = value.to_ffi();
10057                raw.clearValue = raw_value;
10058                storage.push_storage(storage_value);
10059            }
10060            (raw, storage)
10061        }
10062        pub fn with_extension(
10063            mut self,
10064            extension: RenderPassColorAttachmentExtension,
10065        ) -> Self {
10066            self.extensions.push(extension);
10067            self
10068        }
10069        pub(crate) fn from_ffi(value: ffi::WGPURenderPassColorAttachment) -> Self {
10070            Self {
10071                extensions: Vec::new(),
10072                view: if value.view.is_null() {
10073                    None
10074                } else {
10075                    Some(unsafe { TextureView::from_raw(value.view) })
10076                },
10077                depth_slice: Some(value.depthSlice),
10078                resolve_target: if value.resolveTarget.is_null() {
10079                    None
10080                } else {
10081                    Some(unsafe { TextureView::from_raw(value.resolveTarget) })
10082                },
10083                load_op: Some(value.loadOp.into()),
10084                store_op: Some(value.storeOp.into()),
10085                clear_value: Some(Color::from_ffi(value.clearValue)),
10086            }
10087        }
10088    }
10089    pub struct RenderPassDepthStencilAttachment {
10090        pub(crate) extensions: Vec<RenderPassDepthStencilAttachmentExtension>,
10091        pub view: Option<TextureView>,
10092        pub depth_load_op: Option<LoadOp>,
10093        pub depth_store_op: Option<StoreOp>,
10094        pub depth_clear_value: Option<f32>,
10095        pub depth_read_only: Option<bool>,
10096        pub stencil_load_op: Option<LoadOp>,
10097        pub stencil_store_op: Option<StoreOp>,
10098        pub stencil_clear_value: Option<u32>,
10099        pub stencil_read_only: Option<bool>,
10100    }
10101    impl Default for RenderPassDepthStencilAttachment {
10102        fn default() -> Self {
10103            Self {
10104                extensions: Vec::new(),
10105                view: None,
10106                depth_load_op: None,
10107                depth_store_op: None,
10108                depth_clear_value: Some(DEPTH_CLEAR_VALUE_UNDEFINED),
10109                depth_read_only: None,
10110                stencil_load_op: None,
10111                stencil_store_op: None,
10112                stencil_clear_value: Some(0),
10113                stencil_read_only: None,
10114            }
10115        }
10116    }
10117    impl RenderPassDepthStencilAttachment {
10118        pub fn new() -> Self {
10119            Self::default()
10120        }
10121        pub(crate) fn to_ffi(
10122            &self,
10123        ) -> (ffi::WGPURenderPassDepthStencilAttachment, ChainedStructStorage) {
10124            let mut storage = ChainedStructStorage::new();
10125            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10126            for ext in self.extensions.iter().rev() {
10127                next = ext.push_chain(&mut storage, next);
10128            }
10129            let mut raw: ffi::WGPURenderPassDepthStencilAttachment = unsafe {
10130                std::mem::zeroed()
10131            };
10132            raw.nextInChain = next;
10133            raw.view = self
10134                .view
10135                .as_ref()
10136                .map(|v| v.as_raw())
10137                .unwrap_or(std::ptr::null_mut());
10138            if let Some(value) = self.depth_load_op {
10139                raw.depthLoadOp = value.into();
10140            } else {
10141                raw.depthLoadOp = 0 as ffi::WGPULoadOp;
10142            }
10143            if let Some(value) = self.depth_store_op {
10144                raw.depthStoreOp = value.into();
10145            } else {
10146                raw.depthStoreOp = 0 as ffi::WGPUStoreOp;
10147            }
10148            if let Some(value) = self.depth_clear_value {
10149                raw.depthClearValue = value;
10150            }
10151            raw.depthReadOnly = if self.depth_read_only.unwrap_or(false) {
10152                1
10153            } else {
10154                0
10155            };
10156            if let Some(value) = self.stencil_load_op {
10157                raw.stencilLoadOp = value.into();
10158            } else {
10159                raw.stencilLoadOp = 0 as ffi::WGPULoadOp;
10160            }
10161            if let Some(value) = self.stencil_store_op {
10162                raw.stencilStoreOp = value.into();
10163            } else {
10164                raw.stencilStoreOp = 0 as ffi::WGPUStoreOp;
10165            }
10166            if let Some(value) = self.stencil_clear_value {
10167                raw.stencilClearValue = value;
10168            }
10169            raw.stencilReadOnly = if self.stencil_read_only.unwrap_or(false) {
10170                1
10171            } else {
10172                0
10173            };
10174            (raw, storage)
10175        }
10176        pub fn with_extension(
10177            mut self,
10178            extension: RenderPassDepthStencilAttachmentExtension,
10179        ) -> Self {
10180            self.extensions.push(extension);
10181            self
10182        }
10183        pub(crate) fn from_ffi(
10184            value: ffi::WGPURenderPassDepthStencilAttachment,
10185        ) -> Self {
10186            Self {
10187                extensions: Vec::new(),
10188                view: Some(unsafe { TextureView::from_raw(value.view) }),
10189                depth_load_op: Some(value.depthLoadOp.into()),
10190                depth_store_op: Some(value.depthStoreOp.into()),
10191                depth_clear_value: Some(value.depthClearValue),
10192                depth_read_only: Some(value.depthReadOnly != 0),
10193                stencil_load_op: Some(value.stencilLoadOp.into()),
10194                stencil_store_op: Some(value.stencilStoreOp.into()),
10195                stencil_clear_value: Some(value.stencilClearValue),
10196                stencil_read_only: Some(value.stencilReadOnly != 0),
10197            }
10198        }
10199    }
10200    pub struct RenderPassDescriptor {
10201        pub(crate) extensions: Vec<RenderPassDescriptorExtension>,
10202        pub label: Option<String>,
10203        pub color_attachments: Option<Vec<RenderPassColorAttachment>>,
10204        pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachment>,
10205        pub occlusion_query_set: Option<QuerySet>,
10206        pub timestamp_writes: Option<PassTimestampWrites>,
10207    }
10208    impl Default for RenderPassDescriptor {
10209        fn default() -> Self {
10210            Self {
10211                extensions: Vec::new(),
10212                label: None,
10213                color_attachments: None,
10214                depth_stencil_attachment: None,
10215                occlusion_query_set: None,
10216                timestamp_writes: None,
10217            }
10218        }
10219    }
10220    impl RenderPassDescriptor {
10221        pub fn new() -> Self {
10222            Self::default()
10223        }
10224        pub(crate) fn to_ffi(
10225            &self,
10226        ) -> (ffi::WGPURenderPassDescriptor, ChainedStructStorage) {
10227            let mut storage = ChainedStructStorage::new();
10228            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10229            for ext in self.extensions.iter().rev() {
10230                next = ext.push_chain(&mut storage, next);
10231            }
10232            let mut raw: ffi::WGPURenderPassDescriptor = unsafe { std::mem::zeroed() };
10233            raw.nextInChain = next;
10234            if let Some(value) = &self.label {
10235                raw.label = ffi::WGPUStringView {
10236                    data: value.as_ptr().cast(),
10237                    length: value.len(),
10238                };
10239            } else {
10240                raw.label = ffi::WGPUStringView {
10241                    data: std::ptr::null(),
10242                    length: 0,
10243                };
10244            }
10245            raw.colorAttachmentCount = self
10246                .color_attachments
10247                .as_ref()
10248                .map(|v| v.len())
10249                .unwrap_or(0);
10250            if let Some(values) = &self.color_attachments {
10251                let len_value = values.len();
10252                let mut raw_vec: Vec<ffi::WGPURenderPassColorAttachment> = Vec::with_capacity(
10253                    values.len(),
10254                );
10255                for item in values.iter() {
10256                    let (raw_item, storage_item) = item.to_ffi();
10257                    raw_vec.push(raw_item);
10258                    storage.push_storage(storage_item);
10259                }
10260                let ptr = storage.push_vec(raw_vec);
10261                raw.colorAttachments = ptr;
10262                raw.colorAttachmentCount = len_value;
10263            } else {
10264                raw.colorAttachments = std::ptr::null();
10265                raw.colorAttachmentCount = 0;
10266            }
10267            if let Some(value) = &self.depth_stencil_attachment {
10268                let (raw_value, storage_value) = value.to_ffi();
10269                let ptr = storage.push_value(raw_value);
10270                raw.depthStencilAttachment = ptr;
10271                storage.push_storage(storage_value);
10272            } else {
10273                raw.depthStencilAttachment = std::ptr::null();
10274            }
10275            raw.occlusionQuerySet = self
10276                .occlusion_query_set
10277                .as_ref()
10278                .map(|v| v.as_raw())
10279                .unwrap_or(std::ptr::null_mut());
10280            if let Some(value) = &self.timestamp_writes {
10281                let (raw_value, storage_value) = value.to_ffi();
10282                let ptr = storage.push_value(raw_value);
10283                raw.timestampWrites = ptr;
10284                storage.push_storage(storage_value);
10285            } else {
10286                raw.timestampWrites = std::ptr::null();
10287            }
10288            (raw, storage)
10289        }
10290        pub fn with_extension(
10291            mut self,
10292            extension: RenderPassDescriptorExtension,
10293        ) -> Self {
10294            self.extensions.push(extension);
10295            self
10296        }
10297        pub(crate) fn from_ffi(value: ffi::WGPURenderPassDescriptor) -> Self {
10298            Self {
10299                extensions: Vec::new(),
10300                label: if value.label.data.is_null() || value.label.length == 0 {
10301                    None
10302                } else {
10303                    Some(string_view_to_string(value.label))
10304                },
10305                color_attachments: if value.colorAttachments.is_null() {
10306                    None
10307                } else {
10308                    Some(
10309                        unsafe {
10310                            std::slice::from_raw_parts(
10311                                value.colorAttachments,
10312                                value.colorAttachmentCount as usize,
10313                            )
10314                        }
10315                            .iter()
10316                            .map(|raw| RenderPassColorAttachment::from_ffi(*raw))
10317                            .collect(),
10318                    )
10319                },
10320                depth_stencil_attachment: if value.depthStencilAttachment.is_null() {
10321                    None
10322                } else {
10323                    Some(
10324                        RenderPassDepthStencilAttachment::from_ffi(unsafe {
10325                            *value.depthStencilAttachment
10326                        }),
10327                    )
10328                },
10329                occlusion_query_set: if value.occlusionQuerySet.is_null() {
10330                    None
10331                } else {
10332                    Some(unsafe { QuerySet::from_raw(value.occlusionQuerySet) })
10333                },
10334                timestamp_writes: if value.timestampWrites.is_null() {
10335                    None
10336                } else {
10337                    Some(
10338                        PassTimestampWrites::from_ffi(unsafe { *value.timestampWrites }),
10339                    )
10340                },
10341            }
10342        }
10343    }
10344    pub struct RenderPassDescriptorResolveRect {
10345        pub color_offset_x: Option<u32>,
10346        pub color_offset_y: Option<u32>,
10347        pub resolve_offset_x: Option<u32>,
10348        pub resolve_offset_y: Option<u32>,
10349        pub width: Option<u32>,
10350        pub height: Option<u32>,
10351    }
10352    impl Default for RenderPassDescriptorResolveRect {
10353        fn default() -> Self {
10354            Self {
10355                color_offset_x: None,
10356                color_offset_y: None,
10357                resolve_offset_x: None,
10358                resolve_offset_y: None,
10359                width: None,
10360                height: None,
10361            }
10362        }
10363    }
10364    impl RenderPassDescriptorResolveRect {
10365        pub fn new() -> Self {
10366            Self::default()
10367        }
10368        pub(crate) fn to_ffi(
10369            &self,
10370        ) -> (ffi::WGPURenderPassDescriptorResolveRect, ChainedStructStorage) {
10371            let mut storage = ChainedStructStorage::new();
10372            let mut raw: ffi::WGPURenderPassDescriptorResolveRect = unsafe {
10373                std::mem::zeroed()
10374            };
10375            if let Some(value) = self.color_offset_x {
10376                raw.colorOffsetX = value;
10377            }
10378            if let Some(value) = self.color_offset_y {
10379                raw.colorOffsetY = value;
10380            }
10381            if let Some(value) = self.resolve_offset_x {
10382                raw.resolveOffsetX = value;
10383            }
10384            if let Some(value) = self.resolve_offset_y {
10385                raw.resolveOffsetY = value;
10386            }
10387            if let Some(value) = self.width {
10388                raw.width = value;
10389            }
10390            if let Some(value) = self.height {
10391                raw.height = value;
10392            }
10393            (raw, storage)
10394        }
10395        pub(crate) fn from_ffi(value: ffi::WGPURenderPassDescriptorResolveRect) -> Self {
10396            Self {
10397                color_offset_x: Some(value.colorOffsetX),
10398                color_offset_y: Some(value.colorOffsetY),
10399                resolve_offset_x: Some(value.resolveOffsetX),
10400                resolve_offset_y: Some(value.resolveOffsetY),
10401                width: Some(value.width),
10402                height: Some(value.height),
10403            }
10404        }
10405    }
10406    pub struct RenderPassMaxDrawCount {
10407        pub max_draw_count: Option<u64>,
10408    }
10409    impl Default for RenderPassMaxDrawCount {
10410        fn default() -> Self {
10411            Self {
10412                max_draw_count: Some(50000000),
10413            }
10414        }
10415    }
10416    impl RenderPassMaxDrawCount {
10417        pub fn new() -> Self {
10418            Self::default()
10419        }
10420        pub(crate) fn to_ffi(
10421            &self,
10422        ) -> (ffi::WGPURenderPassMaxDrawCount, ChainedStructStorage) {
10423            let mut storage = ChainedStructStorage::new();
10424            let mut raw: ffi::WGPURenderPassMaxDrawCount = unsafe { std::mem::zeroed() };
10425            if let Some(value) = self.max_draw_count {
10426                raw.maxDrawCount = value;
10427            }
10428            (raw, storage)
10429        }
10430        pub(crate) fn from_ffi(value: ffi::WGPURenderPassMaxDrawCount) -> Self {
10431            Self {
10432                max_draw_count: Some(value.maxDrawCount),
10433            }
10434        }
10435    }
10436    pub struct RenderPassPixelLocalStorage {
10437        pub total_pixel_local_storage_size: Option<u64>,
10438        pub storage_attachments: Option<Vec<RenderPassStorageAttachment>>,
10439    }
10440    impl Default for RenderPassPixelLocalStorage {
10441        fn default() -> Self {
10442            Self {
10443                total_pixel_local_storage_size: None,
10444                storage_attachments: None,
10445            }
10446        }
10447    }
10448    impl RenderPassPixelLocalStorage {
10449        pub fn new() -> Self {
10450            Self::default()
10451        }
10452        pub(crate) fn to_ffi(
10453            &self,
10454        ) -> (ffi::WGPURenderPassPixelLocalStorage, ChainedStructStorage) {
10455            let mut storage = ChainedStructStorage::new();
10456            let mut raw: ffi::WGPURenderPassPixelLocalStorage = unsafe {
10457                std::mem::zeroed()
10458            };
10459            if let Some(value) = self.total_pixel_local_storage_size {
10460                raw.totalPixelLocalStorageSize = value;
10461            }
10462            raw.storageAttachmentCount = self
10463                .storage_attachments
10464                .as_ref()
10465                .map(|v| v.len())
10466                .unwrap_or(0);
10467            if let Some(values) = &self.storage_attachments {
10468                let len_value = values.len();
10469                let mut raw_vec: Vec<ffi::WGPURenderPassStorageAttachment> = Vec::with_capacity(
10470                    values.len(),
10471                );
10472                for item in values.iter() {
10473                    let (raw_item, storage_item) = item.to_ffi();
10474                    raw_vec.push(raw_item);
10475                    storage.push_storage(storage_item);
10476                }
10477                let ptr = storage.push_vec(raw_vec);
10478                raw.storageAttachments = ptr;
10479                raw.storageAttachmentCount = len_value;
10480            } else {
10481                raw.storageAttachments = std::ptr::null();
10482                raw.storageAttachmentCount = 0;
10483            }
10484            (raw, storage)
10485        }
10486        pub(crate) fn from_ffi(value: ffi::WGPURenderPassPixelLocalStorage) -> Self {
10487            Self {
10488                total_pixel_local_storage_size: Some(value.totalPixelLocalStorageSize),
10489                storage_attachments: if value.storageAttachments.is_null() {
10490                    None
10491                } else {
10492                    Some(
10493                        unsafe {
10494                            std::slice::from_raw_parts(
10495                                value.storageAttachments,
10496                                value.storageAttachmentCount as usize,
10497                            )
10498                        }
10499                            .iter()
10500                            .map(|raw| RenderPassStorageAttachment::from_ffi(*raw))
10501                            .collect(),
10502                    )
10503                },
10504            }
10505        }
10506    }
10507    pub struct RenderPassRenderAreaRect {
10508        pub origin: Option<Origin2D>,
10509        pub size: Option<Extent2D>,
10510    }
10511    impl Default for RenderPassRenderAreaRect {
10512        fn default() -> Self {
10513            Self { origin: None, size: None }
10514        }
10515    }
10516    impl RenderPassRenderAreaRect {
10517        pub fn new() -> Self {
10518            Self::default()
10519        }
10520        pub(crate) fn to_ffi(
10521            &self,
10522        ) -> (ffi::WGPURenderPassRenderAreaRect, ChainedStructStorage) {
10523            let mut storage = ChainedStructStorage::new();
10524            let mut raw: ffi::WGPURenderPassRenderAreaRect = unsafe {
10525                std::mem::zeroed()
10526            };
10527            if let Some(value) = &self.origin {
10528                let (raw_value, storage_value) = value.to_ffi();
10529                raw.origin = raw_value;
10530                storage.push_storage(storage_value);
10531            }
10532            if let Some(value) = &self.size {
10533                let (raw_value, storage_value) = value.to_ffi();
10534                raw.size = raw_value;
10535                storage.push_storage(storage_value);
10536            }
10537            (raw, storage)
10538        }
10539        pub(crate) fn from_ffi(value: ffi::WGPURenderPassRenderAreaRect) -> Self {
10540            Self {
10541                origin: Some(Origin2D::from_ffi(value.origin)),
10542                size: Some(Extent2D::from_ffi(value.size)),
10543            }
10544        }
10545    }
10546    pub struct RenderPassStorageAttachment {
10547        pub(crate) extensions: Vec<RenderPassStorageAttachmentExtension>,
10548        pub offset: Option<u64>,
10549        pub storage: Option<TextureView>,
10550        pub load_op: Option<LoadOp>,
10551        pub store_op: Option<StoreOp>,
10552        pub clear_value: Option<Color>,
10553    }
10554    impl Default for RenderPassStorageAttachment {
10555        fn default() -> Self {
10556            Self {
10557                extensions: Vec::new(),
10558                offset: Some(0),
10559                storage: None,
10560                load_op: None,
10561                store_op: None,
10562                clear_value: None,
10563            }
10564        }
10565    }
10566    impl RenderPassStorageAttachment {
10567        pub fn new() -> Self {
10568            Self::default()
10569        }
10570        pub(crate) fn to_ffi(
10571            &self,
10572        ) -> (ffi::WGPURenderPassStorageAttachment, ChainedStructStorage) {
10573            let mut storage = ChainedStructStorage::new();
10574            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10575            for ext in self.extensions.iter().rev() {
10576                next = ext.push_chain(&mut storage, next);
10577            }
10578            let mut raw: ffi::WGPURenderPassStorageAttachment = unsafe {
10579                std::mem::zeroed()
10580            };
10581            raw.nextInChain = next;
10582            if let Some(value) = self.offset {
10583                raw.offset = value;
10584            }
10585            raw.storage = self
10586                .storage
10587                .as_ref()
10588                .map(|v| v.as_raw())
10589                .unwrap_or(std::ptr::null_mut());
10590            if let Some(value) = self.load_op {
10591                raw.loadOp = value.into();
10592            } else {
10593                raw.loadOp = 0 as ffi::WGPULoadOp;
10594            }
10595            if let Some(value) = self.store_op {
10596                raw.storeOp = value.into();
10597            } else {
10598                raw.storeOp = 0 as ffi::WGPUStoreOp;
10599            }
10600            if let Some(value) = &self.clear_value {
10601                let (raw_value, storage_value) = value.to_ffi();
10602                raw.clearValue = raw_value;
10603                storage.push_storage(storage_value);
10604            }
10605            (raw, storage)
10606        }
10607        pub fn with_extension(
10608            mut self,
10609            extension: RenderPassStorageAttachmentExtension,
10610        ) -> Self {
10611            self.extensions.push(extension);
10612            self
10613        }
10614        pub(crate) fn from_ffi(value: ffi::WGPURenderPassStorageAttachment) -> Self {
10615            Self {
10616                extensions: Vec::new(),
10617                offset: Some(value.offset),
10618                storage: Some(unsafe { TextureView::from_raw(value.storage) }),
10619                load_op: Some(value.loadOp.into()),
10620                store_op: Some(value.storeOp.into()),
10621                clear_value: Some(Color::from_ffi(value.clearValue)),
10622            }
10623        }
10624    }
10625    pub struct RenderPipelineDescriptor {
10626        pub(crate) extensions: Vec<RenderPipelineDescriptorExtension>,
10627        pub label: Option<String>,
10628        pub layout: Option<PipelineLayout>,
10629        pub vertex: Option<VertexState>,
10630        pub primitive: Option<PrimitiveState>,
10631        pub depth_stencil: Option<DepthStencilState>,
10632        pub multisample: Option<MultisampleState>,
10633        pub fragment: Option<FragmentState>,
10634    }
10635    impl Default for RenderPipelineDescriptor {
10636        fn default() -> Self {
10637            Self {
10638                extensions: Vec::new(),
10639                label: None,
10640                layout: None,
10641                vertex: None,
10642                primitive: None,
10643                depth_stencil: None,
10644                multisample: None,
10645                fragment: None,
10646            }
10647        }
10648    }
10649    impl RenderPipelineDescriptor {
10650        pub fn new() -> Self {
10651            Self::default()
10652        }
10653        pub(crate) fn to_ffi(
10654            &self,
10655        ) -> (ffi::WGPURenderPipelineDescriptor, ChainedStructStorage) {
10656            let mut storage = ChainedStructStorage::new();
10657            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10658            for ext in self.extensions.iter().rev() {
10659                next = ext.push_chain(&mut storage, next);
10660            }
10661            let mut raw: ffi::WGPURenderPipelineDescriptor = unsafe {
10662                std::mem::zeroed()
10663            };
10664            raw.nextInChain = next;
10665            if let Some(value) = &self.label {
10666                raw.label = ffi::WGPUStringView {
10667                    data: value.as_ptr().cast(),
10668                    length: value.len(),
10669                };
10670            } else {
10671                raw.label = ffi::WGPUStringView {
10672                    data: std::ptr::null(),
10673                    length: 0,
10674                };
10675            }
10676            raw.layout = self
10677                .layout
10678                .as_ref()
10679                .map(|v| v.as_raw())
10680                .unwrap_or(std::ptr::null_mut());
10681            if let Some(value) = &self.vertex {
10682                let (raw_value, storage_value) = value.to_ffi();
10683                raw.vertex = raw_value;
10684                storage.push_storage(storage_value);
10685            }
10686            if let Some(value) = &self.primitive {
10687                let (raw_value, storage_value) = value.to_ffi();
10688                raw.primitive = raw_value;
10689                storage.push_storage(storage_value);
10690            }
10691            if let Some(value) = &self.depth_stencil {
10692                let (raw_value, storage_value) = value.to_ffi();
10693                let ptr = storage.push_value(raw_value);
10694                raw.depthStencil = ptr;
10695                storage.push_storage(storage_value);
10696            } else {
10697                raw.depthStencil = std::ptr::null();
10698            }
10699            if let Some(value) = &self.multisample {
10700                let (raw_value, storage_value) = value.to_ffi();
10701                raw.multisample = raw_value;
10702                storage.push_storage(storage_value);
10703            }
10704            if let Some(value) = &self.fragment {
10705                let (raw_value, storage_value) = value.to_ffi();
10706                let ptr = storage.push_value(raw_value);
10707                raw.fragment = ptr;
10708                storage.push_storage(storage_value);
10709            } else {
10710                raw.fragment = std::ptr::null();
10711            }
10712            (raw, storage)
10713        }
10714        pub fn with_extension(
10715            mut self,
10716            extension: RenderPipelineDescriptorExtension,
10717        ) -> Self {
10718            self.extensions.push(extension);
10719            self
10720        }
10721        pub(crate) fn from_ffi(value: ffi::WGPURenderPipelineDescriptor) -> Self {
10722            Self {
10723                extensions: Vec::new(),
10724                label: if value.label.data.is_null() || value.label.length == 0 {
10725                    None
10726                } else {
10727                    Some(string_view_to_string(value.label))
10728                },
10729                layout: if value.layout.is_null() {
10730                    None
10731                } else {
10732                    Some(unsafe { PipelineLayout::from_raw(value.layout) })
10733                },
10734                vertex: Some(VertexState::from_ffi(value.vertex)),
10735                primitive: Some(PrimitiveState::from_ffi(value.primitive)),
10736                depth_stencil: if value.depthStencil.is_null() {
10737                    None
10738                } else {
10739                    Some(DepthStencilState::from_ffi(unsafe { *value.depthStencil }))
10740                },
10741                multisample: Some(MultisampleState::from_ffi(value.multisample)),
10742                fragment: if value.fragment.is_null() {
10743                    None
10744                } else {
10745                    Some(FragmentState::from_ffi(unsafe { *value.fragment }))
10746                },
10747            }
10748        }
10749    }
10750    pub struct RequestAdapterWebGPUBackendOptions {}
10751    impl Default for RequestAdapterWebGPUBackendOptions {
10752        fn default() -> Self {
10753            Self {}
10754        }
10755    }
10756    impl RequestAdapterWebGPUBackendOptions {
10757        pub fn new() -> Self {
10758            Self::default()
10759        }
10760        pub(crate) fn to_ffi(
10761            &self,
10762        ) -> (ffi::WGPURequestAdapterWebGPUBackendOptions, ChainedStructStorage) {
10763            let mut storage = ChainedStructStorage::new();
10764            let mut raw: ffi::WGPURequestAdapterWebGPUBackendOptions = unsafe {
10765                std::mem::zeroed()
10766            };
10767            (raw, storage)
10768        }
10769        pub(crate) fn from_ffi(
10770            value: ffi::WGPURequestAdapterWebGPUBackendOptions,
10771        ) -> Self {
10772            let _ = value;
10773            Self::default()
10774        }
10775    }
10776    pub struct RequestAdapterWebXROptions {
10777        pub xr_compatible: Option<bool>,
10778    }
10779    impl Default for RequestAdapterWebXROptions {
10780        fn default() -> Self {
10781            Self { xr_compatible: None }
10782        }
10783    }
10784    impl RequestAdapterWebXROptions {
10785        pub fn new() -> Self {
10786            Self::default()
10787        }
10788        pub(crate) fn to_ffi(
10789            &self,
10790        ) -> (ffi::WGPURequestAdapterWebXROptions, ChainedStructStorage) {
10791            let mut storage = ChainedStructStorage::new();
10792            let mut raw: ffi::WGPURequestAdapterWebXROptions = unsafe {
10793                std::mem::zeroed()
10794            };
10795            raw.xrCompatible = if self.xr_compatible.unwrap_or(false) { 1 } else { 0 };
10796            (raw, storage)
10797        }
10798        pub(crate) fn from_ffi(value: ffi::WGPURequestAdapterWebXROptions) -> Self {
10799            Self {
10800                xr_compatible: Some(value.xrCompatible != 0),
10801            }
10802        }
10803    }
10804    pub struct RequestAdapterOptions {
10805        pub(crate) extensions: Vec<RequestAdapterOptionsExtension>,
10806        pub feature_level: Option<FeatureLevel>,
10807        pub power_preference: Option<PowerPreference>,
10808        pub force_fallback_adapter: Option<bool>,
10809        pub backend_type: Option<BackendType>,
10810        pub compatible_surface: Option<Surface>,
10811    }
10812    impl Default for RequestAdapterOptions {
10813        fn default() -> Self {
10814            Self {
10815                extensions: Vec::new(),
10816                feature_level: Some(FeatureLevel::Core),
10817                power_preference: None,
10818                force_fallback_adapter: None,
10819                backend_type: None,
10820                compatible_surface: None,
10821            }
10822        }
10823    }
10824    impl RequestAdapterOptions {
10825        pub fn new() -> Self {
10826            Self::default()
10827        }
10828        pub(crate) fn to_ffi(
10829            &self,
10830        ) -> (ffi::WGPURequestAdapterOptions, ChainedStructStorage) {
10831            let mut storage = ChainedStructStorage::new();
10832            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10833            for ext in self.extensions.iter().rev() {
10834                next = ext.push_chain(&mut storage, next);
10835            }
10836            let mut raw: ffi::WGPURequestAdapterOptions = unsafe { std::mem::zeroed() };
10837            raw.nextInChain = next;
10838            if let Some(value) = self.feature_level {
10839                raw.featureLevel = value.into();
10840            } else {
10841                raw.featureLevel = 0 as ffi::WGPUFeatureLevel;
10842            }
10843            if let Some(value) = self.power_preference {
10844                raw.powerPreference = value.into();
10845            } else {
10846                raw.powerPreference = 0 as ffi::WGPUPowerPreference;
10847            }
10848            raw.forceFallbackAdapter = if self.force_fallback_adapter.unwrap_or(false) {
10849                1
10850            } else {
10851                0
10852            };
10853            if let Some(value) = self.backend_type {
10854                raw.backendType = value.into();
10855            } else {
10856                raw.backendType = 0 as ffi::WGPUBackendType;
10857            }
10858            raw.compatibleSurface = self
10859                .compatible_surface
10860                .as_ref()
10861                .map(|v| v.as_raw())
10862                .unwrap_or(std::ptr::null_mut());
10863            (raw, storage)
10864        }
10865        pub fn with_extension(
10866            mut self,
10867            extension: RequestAdapterOptionsExtension,
10868        ) -> Self {
10869            self.extensions.push(extension);
10870            self
10871        }
10872        pub(crate) fn from_ffi(value: ffi::WGPURequestAdapterOptions) -> Self {
10873            Self {
10874                extensions: Vec::new(),
10875                feature_level: Some(value.featureLevel.into()),
10876                power_preference: Some(value.powerPreference.into()),
10877                force_fallback_adapter: Some(value.forceFallbackAdapter != 0),
10878                backend_type: Some(value.backendType.into()),
10879                compatible_surface: if value.compatibleSurface.is_null() {
10880                    None
10881                } else {
10882                    Some(unsafe { Surface::from_raw(value.compatibleSurface) })
10883                },
10884            }
10885        }
10886    }
10887    pub struct ResourceTableDescriptor {
10888        pub(crate) extensions: Vec<ResourceTableDescriptorExtension>,
10889        pub label: Option<String>,
10890        pub size: Option<u32>,
10891    }
10892    impl Default for ResourceTableDescriptor {
10893        fn default() -> Self {
10894            Self {
10895                extensions: Vec::new(),
10896                label: None,
10897                size: None,
10898            }
10899        }
10900    }
10901    impl ResourceTableDescriptor {
10902        pub fn new() -> Self {
10903            Self::default()
10904        }
10905        pub(crate) fn to_ffi(
10906            &self,
10907        ) -> (ffi::WGPUResourceTableDescriptor, ChainedStructStorage) {
10908            let mut storage = ChainedStructStorage::new();
10909            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10910            for ext in self.extensions.iter().rev() {
10911                next = ext.push_chain(&mut storage, next);
10912            }
10913            let mut raw: ffi::WGPUResourceTableDescriptor = unsafe {
10914                std::mem::zeroed()
10915            };
10916            raw.nextInChain = next;
10917            if let Some(value) = &self.label {
10918                raw.label = ffi::WGPUStringView {
10919                    data: value.as_ptr().cast(),
10920                    length: value.len(),
10921                };
10922            } else {
10923                raw.label = ffi::WGPUStringView {
10924                    data: std::ptr::null(),
10925                    length: 0,
10926                };
10927            }
10928            if let Some(value) = self.size {
10929                raw.size = value;
10930            }
10931            (raw, storage)
10932        }
10933        pub fn with_extension(
10934            mut self,
10935            extension: ResourceTableDescriptorExtension,
10936        ) -> Self {
10937            self.extensions.push(extension);
10938            self
10939        }
10940        pub(crate) fn from_ffi(value: ffi::WGPUResourceTableDescriptor) -> Self {
10941            Self {
10942                extensions: Vec::new(),
10943                label: if value.label.data.is_null() || value.label.length == 0 {
10944                    None
10945                } else {
10946                    Some(string_view_to_string(value.label))
10947                },
10948                size: Some(value.size),
10949            }
10950        }
10951    }
10952    pub struct SamplerBindingLayout {
10953        pub(crate) extensions: Vec<SamplerBindingLayoutExtension>,
10954        pub r#type: Option<SamplerBindingType>,
10955    }
10956    impl Default for SamplerBindingLayout {
10957        fn default() -> Self {
10958            Self {
10959                extensions: Vec::new(),
10960                r#type: Some(SamplerBindingType::Filtering),
10961            }
10962        }
10963    }
10964    impl SamplerBindingLayout {
10965        pub fn new() -> Self {
10966            Self::default()
10967        }
10968        pub(crate) fn to_ffi(
10969            &self,
10970        ) -> (ffi::WGPUSamplerBindingLayout, ChainedStructStorage) {
10971            let mut storage = ChainedStructStorage::new();
10972            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10973            for ext in self.extensions.iter().rev() {
10974                next = ext.push_chain(&mut storage, next);
10975            }
10976            let mut raw: ffi::WGPUSamplerBindingLayout = unsafe { std::mem::zeroed() };
10977            raw.nextInChain = next;
10978            if let Some(value) = self.r#type {
10979                raw.type_ = value.into();
10980            } else {
10981                raw.type_ = 0 as ffi::WGPUSamplerBindingType;
10982            }
10983            (raw, storage)
10984        }
10985        pub fn with_extension(
10986            mut self,
10987            extension: SamplerBindingLayoutExtension,
10988        ) -> Self {
10989            self.extensions.push(extension);
10990            self
10991        }
10992        pub(crate) fn from_ffi(value: ffi::WGPUSamplerBindingLayout) -> Self {
10993            Self {
10994                extensions: Vec::new(),
10995                r#type: Some(value.type_.into()),
10996            }
10997        }
10998    }
10999    pub struct SamplerDescriptor {
11000        pub(crate) extensions: Vec<SamplerDescriptorExtension>,
11001        pub label: Option<String>,
11002        pub address_mode_u: Option<AddressMode>,
11003        pub address_mode_v: Option<AddressMode>,
11004        pub address_mode_w: Option<AddressMode>,
11005        pub mag_filter: Option<FilterMode>,
11006        pub min_filter: Option<FilterMode>,
11007        pub mipmap_filter: Option<MipmapFilterMode>,
11008        pub lod_min_clamp: Option<f32>,
11009        pub lod_max_clamp: Option<f32>,
11010        pub compare: Option<CompareFunction>,
11011        pub max_anisotropy: Option<u16>,
11012    }
11013    impl Default for SamplerDescriptor {
11014        fn default() -> Self {
11015            Self {
11016                extensions: Vec::new(),
11017                label: None,
11018                address_mode_u: Some(AddressMode::ClampToEdge),
11019                address_mode_v: Some(AddressMode::ClampToEdge),
11020                address_mode_w: Some(AddressMode::ClampToEdge),
11021                mag_filter: Some(FilterMode::Nearest),
11022                min_filter: Some(FilterMode::Nearest),
11023                mipmap_filter: Some(MipmapFilterMode::Nearest),
11024                lod_min_clamp: None,
11025                lod_max_clamp: None,
11026                compare: None,
11027                max_anisotropy: Some(1),
11028            }
11029        }
11030    }
11031    impl SamplerDescriptor {
11032        pub fn new() -> Self {
11033            Self::default()
11034        }
11035        pub(crate) fn to_ffi(
11036            &self,
11037        ) -> (ffi::WGPUSamplerDescriptor, ChainedStructStorage) {
11038            let mut storage = ChainedStructStorage::new();
11039            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11040            for ext in self.extensions.iter().rev() {
11041                next = ext.push_chain(&mut storage, next);
11042            }
11043            let mut raw: ffi::WGPUSamplerDescriptor = unsafe { std::mem::zeroed() };
11044            raw.nextInChain = next;
11045            if let Some(value) = &self.label {
11046                raw.label = ffi::WGPUStringView {
11047                    data: value.as_ptr().cast(),
11048                    length: value.len(),
11049                };
11050            } else {
11051                raw.label = ffi::WGPUStringView {
11052                    data: std::ptr::null(),
11053                    length: 0,
11054                };
11055            }
11056            if let Some(value) = self.address_mode_u {
11057                raw.addressModeU = value.into();
11058            } else {
11059                raw.addressModeU = 0 as ffi::WGPUAddressMode;
11060            }
11061            if let Some(value) = self.address_mode_v {
11062                raw.addressModeV = value.into();
11063            } else {
11064                raw.addressModeV = 0 as ffi::WGPUAddressMode;
11065            }
11066            if let Some(value) = self.address_mode_w {
11067                raw.addressModeW = value.into();
11068            } else {
11069                raw.addressModeW = 0 as ffi::WGPUAddressMode;
11070            }
11071            if let Some(value) = self.mag_filter {
11072                raw.magFilter = value.into();
11073            } else {
11074                raw.magFilter = 0 as ffi::WGPUFilterMode;
11075            }
11076            if let Some(value) = self.min_filter {
11077                raw.minFilter = value.into();
11078            } else {
11079                raw.minFilter = 0 as ffi::WGPUFilterMode;
11080            }
11081            if let Some(value) = self.mipmap_filter {
11082                raw.mipmapFilter = value.into();
11083            } else {
11084                raw.mipmapFilter = 0 as ffi::WGPUMipmapFilterMode;
11085            }
11086            if let Some(value) = self.lod_min_clamp {
11087                raw.lodMinClamp = value;
11088            }
11089            if let Some(value) = self.lod_max_clamp {
11090                raw.lodMaxClamp = value;
11091            }
11092            if let Some(value) = self.compare {
11093                raw.compare = value.into();
11094            } else {
11095                raw.compare = 0 as ffi::WGPUCompareFunction;
11096            }
11097            if let Some(value) = self.max_anisotropy {
11098                raw.maxAnisotropy = value;
11099            }
11100            (raw, storage)
11101        }
11102        pub fn with_extension(mut self, extension: SamplerDescriptorExtension) -> Self {
11103            self.extensions.push(extension);
11104            self
11105        }
11106        pub(crate) fn from_ffi(value: ffi::WGPUSamplerDescriptor) -> Self {
11107            Self {
11108                extensions: Vec::new(),
11109                label: if value.label.data.is_null() || value.label.length == 0 {
11110                    None
11111                } else {
11112                    Some(string_view_to_string(value.label))
11113                },
11114                address_mode_u: Some(value.addressModeU.into()),
11115                address_mode_v: Some(value.addressModeV.into()),
11116                address_mode_w: Some(value.addressModeW.into()),
11117                mag_filter: Some(value.magFilter.into()),
11118                min_filter: Some(value.minFilter.into()),
11119                mipmap_filter: Some(value.mipmapFilter.into()),
11120                lod_min_clamp: Some(value.lodMinClamp),
11121                lod_max_clamp: Some(value.lodMaxClamp),
11122                compare: Some(value.compare.into()),
11123                max_anisotropy: Some(value.maxAnisotropy),
11124            }
11125        }
11126    }
11127    pub struct ShaderModuleCompilationOptions {
11128        pub strict_math: Option<bool>,
11129    }
11130    impl Default for ShaderModuleCompilationOptions {
11131        fn default() -> Self {
11132            Self { strict_math: None }
11133        }
11134    }
11135    impl ShaderModuleCompilationOptions {
11136        pub fn new() -> Self {
11137            Self::default()
11138        }
11139        pub(crate) fn to_ffi(
11140            &self,
11141        ) -> (ffi::WGPUShaderModuleCompilationOptions, ChainedStructStorage) {
11142            let mut storage = ChainedStructStorage::new();
11143            let mut raw: ffi::WGPUShaderModuleCompilationOptions = unsafe {
11144                std::mem::zeroed()
11145            };
11146            raw.strictMath = if self.strict_math.unwrap_or(false) { 1 } else { 0 };
11147            (raw, storage)
11148        }
11149        pub(crate) fn from_ffi(value: ffi::WGPUShaderModuleCompilationOptions) -> Self {
11150            Self {
11151                strict_math: Some(value.strictMath != 0),
11152            }
11153        }
11154    }
11155    pub struct ShaderModuleDescriptor {
11156        pub(crate) extensions: Vec<ShaderModuleDescriptorExtension>,
11157        pub label: Option<String>,
11158    }
11159    impl Default for ShaderModuleDescriptor {
11160        fn default() -> Self {
11161            Self {
11162                extensions: Vec::new(),
11163                label: None,
11164            }
11165        }
11166    }
11167    impl ShaderModuleDescriptor {
11168        pub fn new() -> Self {
11169            Self::default()
11170        }
11171        pub(crate) fn to_ffi(
11172            &self,
11173        ) -> (ffi::WGPUShaderModuleDescriptor, ChainedStructStorage) {
11174            let mut storage = ChainedStructStorage::new();
11175            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11176            for ext in self.extensions.iter().rev() {
11177                next = ext.push_chain(&mut storage, next);
11178            }
11179            let mut raw: ffi::WGPUShaderModuleDescriptor = unsafe { std::mem::zeroed() };
11180            raw.nextInChain = next;
11181            if let Some(value) = &self.label {
11182                raw.label = ffi::WGPUStringView {
11183                    data: value.as_ptr().cast(),
11184                    length: value.len(),
11185                };
11186            } else {
11187                raw.label = ffi::WGPUStringView {
11188                    data: std::ptr::null(),
11189                    length: 0,
11190                };
11191            }
11192            (raw, storage)
11193        }
11194        pub fn with_extension(
11195            mut self,
11196            extension: ShaderModuleDescriptorExtension,
11197        ) -> Self {
11198            self.extensions.push(extension);
11199            self
11200        }
11201        pub(crate) fn from_ffi(value: ffi::WGPUShaderModuleDescriptor) -> Self {
11202            Self {
11203                extensions: Vec::new(),
11204                label: if value.label.data.is_null() || value.label.length == 0 {
11205                    None
11206                } else {
11207                    Some(string_view_to_string(value.label))
11208                },
11209            }
11210        }
11211    }
11212    pub struct ShaderSourceSPIRV {
11213        pub code: Option<Vec<u32>>,
11214    }
11215    impl Default for ShaderSourceSPIRV {
11216        fn default() -> Self {
11217            Self { code: None }
11218        }
11219    }
11220    impl ShaderSourceSPIRV {
11221        pub fn new() -> Self {
11222            Self::default()
11223        }
11224        pub(crate) fn to_ffi(
11225            &self,
11226        ) -> (ffi::WGPUShaderSourceSPIRV, ChainedStructStorage) {
11227            let mut storage = ChainedStructStorage::new();
11228            let mut raw: ffi::WGPUShaderSourceSPIRV = unsafe { std::mem::zeroed() };
11229            raw.codeSize = (self.code.as_ref().map(|v| v.len()).unwrap_or(0)) as u32;
11230            if let Some(values) = &self.code {
11231                let len_value = values.len();
11232                let raw_vec = values.to_vec();
11233                let ptr = storage.push_vec(raw_vec);
11234                raw.code = ptr;
11235                raw.codeSize = len_value as u32;
11236            } else {
11237                raw.code = std::ptr::null();
11238                raw.codeSize = 0;
11239            }
11240            (raw, storage)
11241        }
11242        pub(crate) fn from_ffi(value: ffi::WGPUShaderSourceSPIRV) -> Self {
11243            Self {
11244                code: if value.code.is_null() {
11245                    None
11246                } else {
11247                    Some(
11248                        unsafe {
11249                            std::slice::from_raw_parts(
11250                                value.code,
11251                                value.codeSize as usize,
11252                            )
11253                        }
11254                            .to_vec(),
11255                    )
11256                },
11257            }
11258        }
11259    }
11260    pub struct ShaderSourceWGSL {
11261        pub code: Option<String>,
11262    }
11263    impl Default for ShaderSourceWGSL {
11264        fn default() -> Self {
11265            Self { code: None }
11266        }
11267    }
11268    impl ShaderSourceWGSL {
11269        pub fn new() -> Self {
11270            Self::default()
11271        }
11272        pub(crate) fn to_ffi(
11273            &self,
11274        ) -> (ffi::WGPUShaderSourceWGSL, ChainedStructStorage) {
11275            let mut storage = ChainedStructStorage::new();
11276            let mut raw: ffi::WGPUShaderSourceWGSL = unsafe { std::mem::zeroed() };
11277            if let Some(value) = &self.code {
11278                raw.code = ffi::WGPUStringView {
11279                    data: value.as_ptr().cast(),
11280                    length: value.len(),
11281                };
11282            } else {
11283                raw.code = ffi::WGPUStringView {
11284                    data: std::ptr::null(),
11285                    length: 0,
11286                };
11287            }
11288            (raw, storage)
11289        }
11290        pub(crate) fn from_ffi(value: ffi::WGPUShaderSourceWGSL) -> Self {
11291            Self {
11292                code: Some(string_view_to_string(value.code)),
11293            }
11294        }
11295    }
11296    pub struct SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor {
11297        pub handle: Option<*mut std::ffi::c_void>,
11298        pub size: Option<u64>,
11299    }
11300    impl Default for SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor {
11301        fn default() -> Self {
11302            Self { handle: None, size: None }
11303        }
11304    }
11305    impl SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor {
11306        pub fn new() -> Self {
11307            Self::default()
11308        }
11309        pub(crate) fn to_ffi(
11310            &self,
11311        ) -> (
11312            ffi::WGPUSharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
11313            ChainedStructStorage,
11314        ) {
11315            let mut storage = ChainedStructStorage::new();
11316            let mut raw: ffi::WGPUSharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor = unsafe {
11317                std::mem::zeroed()
11318            };
11319            if let Some(value) = self.handle {
11320                raw.handle = value;
11321            }
11322            if let Some(value) = self.size {
11323                raw.size = value;
11324            }
11325            (raw, storage)
11326        }
11327        pub(crate) fn from_ffi(
11328            value: ffi::WGPUSharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
11329        ) -> Self {
11330            Self {
11331                handle: Some(value.handle),
11332                size: Some(value.size),
11333            }
11334        }
11335    }
11336    pub struct SharedBufferMemoryBeginAccessDescriptor {
11337        pub(crate) extensions: Vec<SharedBufferMemoryBeginAccessDescriptorExtension>,
11338        pub initialized: Option<bool>,
11339        pub fences: Option<Vec<SharedFence>>,
11340        pub signaled_values: Option<Vec<u64>>,
11341    }
11342    impl Default for SharedBufferMemoryBeginAccessDescriptor {
11343        fn default() -> Self {
11344            Self {
11345                extensions: Vec::new(),
11346                initialized: None,
11347                fences: None,
11348                signaled_values: None,
11349            }
11350        }
11351    }
11352    impl SharedBufferMemoryBeginAccessDescriptor {
11353        pub fn new() -> Self {
11354            Self::default()
11355        }
11356        pub(crate) fn to_ffi(
11357            &self,
11358        ) -> (ffi::WGPUSharedBufferMemoryBeginAccessDescriptor, ChainedStructStorage) {
11359            let mut storage = ChainedStructStorage::new();
11360            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11361            for ext in self.extensions.iter().rev() {
11362                next = ext.push_chain(&mut storage, next);
11363            }
11364            let mut raw: ffi::WGPUSharedBufferMemoryBeginAccessDescriptor = unsafe {
11365                std::mem::zeroed()
11366            };
11367            raw.nextInChain = next;
11368            raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
11369            raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
11370            if let Some(values) = &self.fences {
11371                let len_value = values.len();
11372                let raw_vec: Vec<ffi::WGPUSharedFence> = values
11373                    .iter()
11374                    .map(|v| v.as_raw())
11375                    .collect();
11376                let ptr = storage.push_vec(raw_vec);
11377                raw.fences = ptr;
11378                raw.fenceCount = len_value;
11379            } else {
11380                raw.fences = std::ptr::null();
11381                raw.fenceCount = 0;
11382            }
11383            if let Some(values) = &self.signaled_values {
11384                let len_value = values.len();
11385                let raw_vec = values.to_vec();
11386                let ptr = storage.push_vec(raw_vec);
11387                raw.signaledValues = ptr;
11388                raw.fenceCount = len_value;
11389            } else {
11390                raw.signaledValues = std::ptr::null();
11391                raw.fenceCount = 0;
11392            }
11393            (raw, storage)
11394        }
11395        pub fn with_extension(
11396            mut self,
11397            extension: SharedBufferMemoryBeginAccessDescriptorExtension,
11398        ) -> Self {
11399            self.extensions.push(extension);
11400            self
11401        }
11402        pub(crate) fn from_ffi(
11403            value: ffi::WGPUSharedBufferMemoryBeginAccessDescriptor,
11404        ) -> Self {
11405            Self {
11406                extensions: Vec::new(),
11407                initialized: Some(value.initialized != 0),
11408                fences: if value.fences.is_null() {
11409                    None
11410                } else {
11411                    Some(
11412                        unsafe {
11413                            std::slice::from_raw_parts(
11414                                value.fences,
11415                                value.fenceCount as usize,
11416                            )
11417                        }
11418                            .iter()
11419                            .map(|raw| unsafe { SharedFence::from_raw(*raw) })
11420                            .collect(),
11421                    )
11422                },
11423                signaled_values: if value.signaledValues.is_null() {
11424                    None
11425                } else {
11426                    Some(
11427                        unsafe {
11428                            std::slice::from_raw_parts(
11429                                value.signaledValues,
11430                                value.fenceCount as usize,
11431                            )
11432                        }
11433                            .to_vec(),
11434                    )
11435                },
11436            }
11437        }
11438    }
11439    pub struct SharedBufferMemoryDescriptor {
11440        pub(crate) extensions: Vec<SharedBufferMemoryDescriptorExtension>,
11441        pub label: Option<String>,
11442    }
11443    impl Default for SharedBufferMemoryDescriptor {
11444        fn default() -> Self {
11445            Self {
11446                extensions: Vec::new(),
11447                label: None,
11448            }
11449        }
11450    }
11451    impl SharedBufferMemoryDescriptor {
11452        pub fn new() -> Self {
11453            Self::default()
11454        }
11455        pub(crate) fn to_ffi(
11456            &self,
11457        ) -> (ffi::WGPUSharedBufferMemoryDescriptor, ChainedStructStorage) {
11458            let mut storage = ChainedStructStorage::new();
11459            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11460            for ext in self.extensions.iter().rev() {
11461                next = ext.push_chain(&mut storage, next);
11462            }
11463            let mut raw: ffi::WGPUSharedBufferMemoryDescriptor = unsafe {
11464                std::mem::zeroed()
11465            };
11466            raw.nextInChain = next;
11467            if let Some(value) = &self.label {
11468                raw.label = ffi::WGPUStringView {
11469                    data: value.as_ptr().cast(),
11470                    length: value.len(),
11471                };
11472            } else {
11473                raw.label = ffi::WGPUStringView {
11474                    data: std::ptr::null(),
11475                    length: 0,
11476                };
11477            }
11478            (raw, storage)
11479        }
11480        pub fn with_extension(
11481            mut self,
11482            extension: SharedBufferMemoryDescriptorExtension,
11483        ) -> Self {
11484            self.extensions.push(extension);
11485            self
11486        }
11487        pub(crate) fn from_ffi(value: ffi::WGPUSharedBufferMemoryDescriptor) -> Self {
11488            Self {
11489                extensions: Vec::new(),
11490                label: if value.label.data.is_null() || value.label.length == 0 {
11491                    None
11492                } else {
11493                    Some(string_view_to_string(value.label))
11494                },
11495            }
11496        }
11497    }
11498    pub struct SharedBufferMemoryEndAccessState {
11499        pub(crate) extensions: Vec<SharedBufferMemoryEndAccessStateExtension>,
11500        pub initialized: Option<bool>,
11501        pub fences: Option<Vec<SharedFence>>,
11502        pub signaled_values: Option<Vec<u64>>,
11503        #[doc(hidden)]
11504        pub(crate) _free_members: Option<ffi::WGPUSharedBufferMemoryEndAccessState>,
11505    }
11506    impl Default for SharedBufferMemoryEndAccessState {
11507        fn default() -> Self {
11508            Self {
11509                extensions: Vec::new(),
11510                initialized: None,
11511                fences: None,
11512                signaled_values: None,
11513                _free_members: None,
11514            }
11515        }
11516    }
11517    impl SharedBufferMemoryEndAccessState {
11518        pub fn new() -> Self {
11519            Self::default()
11520        }
11521        pub(crate) fn to_ffi(
11522            &self,
11523        ) -> (ffi::WGPUSharedBufferMemoryEndAccessState, ChainedStructStorage) {
11524            let mut storage = ChainedStructStorage::new();
11525            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11526            for ext in self.extensions.iter().rev() {
11527                next = ext.push_chain(&mut storage, next);
11528            }
11529            let mut raw: ffi::WGPUSharedBufferMemoryEndAccessState = unsafe {
11530                std::mem::zeroed()
11531            };
11532            raw.nextInChain = next;
11533            raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
11534            raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
11535            if let Some(values) = &self.fences {
11536                let len_value = values.len();
11537                let raw_vec: Vec<ffi::WGPUSharedFence> = values
11538                    .iter()
11539                    .map(|v| v.as_raw())
11540                    .collect();
11541                let ptr = storage.push_vec(raw_vec);
11542                raw.fences = ptr;
11543                raw.fenceCount = len_value;
11544            } else {
11545                raw.fences = std::ptr::null();
11546                raw.fenceCount = 0;
11547            }
11548            if let Some(values) = &self.signaled_values {
11549                let len_value = values.len();
11550                let raw_vec = values.to_vec();
11551                let ptr = storage.push_vec(raw_vec);
11552                raw.signaledValues = ptr;
11553                raw.fenceCount = len_value;
11554            } else {
11555                raw.signaledValues = std::ptr::null();
11556                raw.fenceCount = 0;
11557            }
11558            (raw, storage)
11559        }
11560        pub fn with_extension(
11561            mut self,
11562            extension: SharedBufferMemoryEndAccessStateExtension,
11563        ) -> Self {
11564            self.extensions.push(extension);
11565            self
11566        }
11567        pub(crate) fn from_ffi(
11568            value: ffi::WGPUSharedBufferMemoryEndAccessState,
11569        ) -> Self {
11570            Self {
11571                extensions: Vec::new(),
11572                initialized: Some(value.initialized != 0),
11573                fences: if value.fences.is_null() {
11574                    None
11575                } else {
11576                    Some(
11577                        unsafe {
11578                            std::slice::from_raw_parts(
11579                                value.fences,
11580                                value.fenceCount as usize,
11581                            )
11582                        }
11583                            .iter()
11584                            .map(|raw| unsafe { SharedFence::from_raw(*raw) })
11585                            .collect(),
11586                    )
11587                },
11588                signaled_values: if value.signaledValues.is_null() {
11589                    None
11590                } else {
11591                    Some(
11592                        unsafe {
11593                            std::slice::from_raw_parts(
11594                                value.signaledValues,
11595                                value.fenceCount as usize,
11596                            )
11597                        }
11598                            .to_vec(),
11599                    )
11600                },
11601                _free_members: Some(value),
11602            }
11603        }
11604        pub(crate) fn free_members(value: ffi::WGPUSharedBufferMemoryEndAccessState) {
11605            unsafe { ffi::wgpuSharedBufferMemoryEndAccessStateFreeMembers(value) };
11606        }
11607    }
11608    impl Drop for SharedBufferMemoryEndAccessState {
11609        fn drop(&mut self) {
11610            if let Some(value) = self._free_members.take() {
11611                unsafe { ffi::wgpuSharedBufferMemoryEndAccessStateFreeMembers(value) };
11612            }
11613        }
11614    }
11615    pub struct SharedBufferMemoryProperties {
11616        pub(crate) extensions: Vec<SharedBufferMemoryPropertiesExtension>,
11617        pub usage: Option<BufferUsage>,
11618        pub size: Option<u64>,
11619    }
11620    impl Default for SharedBufferMemoryProperties {
11621        fn default() -> Self {
11622            Self {
11623                extensions: Vec::new(),
11624                usage: None,
11625                size: None,
11626            }
11627        }
11628    }
11629    impl SharedBufferMemoryProperties {
11630        pub fn new() -> Self {
11631            Self::default()
11632        }
11633        pub(crate) fn to_ffi(
11634            &self,
11635        ) -> (ffi::WGPUSharedBufferMemoryProperties, ChainedStructStorage) {
11636            let mut storage = ChainedStructStorage::new();
11637            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11638            for ext in self.extensions.iter().rev() {
11639                next = ext.push_chain(&mut storage, next);
11640            }
11641            let mut raw: ffi::WGPUSharedBufferMemoryProperties = unsafe {
11642                std::mem::zeroed()
11643            };
11644            raw.nextInChain = next;
11645            if let Some(value) = self.usage {
11646                raw.usage = value.into();
11647            } else {
11648                raw.usage = 0 as ffi::WGPUBufferUsage;
11649            }
11650            if let Some(value) = self.size {
11651                raw.size = value;
11652            }
11653            (raw, storage)
11654        }
11655        pub fn with_extension(
11656            mut self,
11657            extension: SharedBufferMemoryPropertiesExtension,
11658        ) -> Self {
11659            self.extensions.push(extension);
11660            self
11661        }
11662        pub(crate) fn from_ffi(value: ffi::WGPUSharedBufferMemoryProperties) -> Self {
11663            Self {
11664                extensions: Vec::new(),
11665                usage: Some(value.usage.into()),
11666                size: Some(value.size),
11667            }
11668        }
11669    }
11670    pub struct SharedFenceDXGISharedHandleDescriptor {
11671        pub handle: Option<*mut std::ffi::c_void>,
11672    }
11673    impl Default for SharedFenceDXGISharedHandleDescriptor {
11674        fn default() -> Self {
11675            Self { handle: None }
11676        }
11677    }
11678    impl SharedFenceDXGISharedHandleDescriptor {
11679        pub fn new() -> Self {
11680            Self::default()
11681        }
11682        pub(crate) fn to_ffi(
11683            &self,
11684        ) -> (ffi::WGPUSharedFenceDXGISharedHandleDescriptor, ChainedStructStorage) {
11685            let mut storage = ChainedStructStorage::new();
11686            let mut raw: ffi::WGPUSharedFenceDXGISharedHandleDescriptor = unsafe {
11687                std::mem::zeroed()
11688            };
11689            if let Some(value) = self.handle {
11690                raw.handle = value;
11691            }
11692            (raw, storage)
11693        }
11694        pub(crate) fn from_ffi(
11695            value: ffi::WGPUSharedFenceDXGISharedHandleDescriptor,
11696        ) -> Self {
11697            Self { handle: Some(value.handle) }
11698        }
11699    }
11700    pub struct SharedFenceDXGISharedHandleExportInfo {
11701        pub handle: Option<*mut std::ffi::c_void>,
11702    }
11703    impl Default for SharedFenceDXGISharedHandleExportInfo {
11704        fn default() -> Self {
11705            Self { handle: None }
11706        }
11707    }
11708    impl SharedFenceDXGISharedHandleExportInfo {
11709        pub fn new() -> Self {
11710            Self::default()
11711        }
11712        pub(crate) fn to_ffi(
11713            &self,
11714        ) -> (ffi::WGPUSharedFenceDXGISharedHandleExportInfo, ChainedStructStorage) {
11715            let mut storage = ChainedStructStorage::new();
11716            let mut raw: ffi::WGPUSharedFenceDXGISharedHandleExportInfo = unsafe {
11717                std::mem::zeroed()
11718            };
11719            if let Some(value) = self.handle {
11720                raw.handle = value;
11721            }
11722            (raw, storage)
11723        }
11724        pub(crate) fn from_ffi(
11725            value: ffi::WGPUSharedFenceDXGISharedHandleExportInfo,
11726        ) -> Self {
11727            Self { handle: Some(value.handle) }
11728        }
11729    }
11730    pub struct SharedFenceEGLSyncDescriptor {
11731        pub sync: Option<*mut std::ffi::c_void>,
11732    }
11733    impl Default for SharedFenceEGLSyncDescriptor {
11734        fn default() -> Self {
11735            Self { sync: None }
11736        }
11737    }
11738    impl SharedFenceEGLSyncDescriptor {
11739        pub fn new() -> Self {
11740            Self::default()
11741        }
11742        pub(crate) fn to_ffi(
11743            &self,
11744        ) -> (ffi::WGPUSharedFenceEGLSyncDescriptor, ChainedStructStorage) {
11745            let mut storage = ChainedStructStorage::new();
11746            let mut raw: ffi::WGPUSharedFenceEGLSyncDescriptor = unsafe {
11747                std::mem::zeroed()
11748            };
11749            if let Some(value) = self.sync {
11750                raw.sync = value;
11751            }
11752            (raw, storage)
11753        }
11754        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceEGLSyncDescriptor) -> Self {
11755            Self { sync: Some(value.sync) }
11756        }
11757    }
11758    pub struct SharedFenceEGLSyncExportInfo {
11759        pub sync: Option<*mut std::ffi::c_void>,
11760    }
11761    impl Default for SharedFenceEGLSyncExportInfo {
11762        fn default() -> Self {
11763            Self { sync: None }
11764        }
11765    }
11766    impl SharedFenceEGLSyncExportInfo {
11767        pub fn new() -> Self {
11768            Self::default()
11769        }
11770        pub(crate) fn to_ffi(
11771            &self,
11772        ) -> (ffi::WGPUSharedFenceEGLSyncExportInfo, ChainedStructStorage) {
11773            let mut storage = ChainedStructStorage::new();
11774            let mut raw: ffi::WGPUSharedFenceEGLSyncExportInfo = unsafe {
11775                std::mem::zeroed()
11776            };
11777            if let Some(value) = self.sync {
11778                raw.sync = value;
11779            }
11780            (raw, storage)
11781        }
11782        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceEGLSyncExportInfo) -> Self {
11783            Self { sync: Some(value.sync) }
11784        }
11785    }
11786    pub struct SharedFenceMTLSharedEventDescriptor {
11787        pub shared_event: Option<*mut std::ffi::c_void>,
11788    }
11789    impl Default for SharedFenceMTLSharedEventDescriptor {
11790        fn default() -> Self {
11791            Self { shared_event: None }
11792        }
11793    }
11794    impl SharedFenceMTLSharedEventDescriptor {
11795        pub fn new() -> Self {
11796            Self::default()
11797        }
11798        pub(crate) fn to_ffi(
11799            &self,
11800        ) -> (ffi::WGPUSharedFenceMTLSharedEventDescriptor, ChainedStructStorage) {
11801            let mut storage = ChainedStructStorage::new();
11802            let mut raw: ffi::WGPUSharedFenceMTLSharedEventDescriptor = unsafe {
11803                std::mem::zeroed()
11804            };
11805            if let Some(value) = self.shared_event {
11806                raw.sharedEvent = value;
11807            }
11808            (raw, storage)
11809        }
11810        pub(crate) fn from_ffi(
11811            value: ffi::WGPUSharedFenceMTLSharedEventDescriptor,
11812        ) -> Self {
11813            Self {
11814                shared_event: Some(value.sharedEvent),
11815            }
11816        }
11817    }
11818    pub struct SharedFenceMTLSharedEventExportInfo {
11819        pub shared_event: Option<*mut std::ffi::c_void>,
11820    }
11821    impl Default for SharedFenceMTLSharedEventExportInfo {
11822        fn default() -> Self {
11823            Self { shared_event: None }
11824        }
11825    }
11826    impl SharedFenceMTLSharedEventExportInfo {
11827        pub fn new() -> Self {
11828            Self::default()
11829        }
11830        pub(crate) fn to_ffi(
11831            &self,
11832        ) -> (ffi::WGPUSharedFenceMTLSharedEventExportInfo, ChainedStructStorage) {
11833            let mut storage = ChainedStructStorage::new();
11834            let mut raw: ffi::WGPUSharedFenceMTLSharedEventExportInfo = unsafe {
11835                std::mem::zeroed()
11836            };
11837            if let Some(value) = self.shared_event {
11838                raw.sharedEvent = value;
11839            }
11840            (raw, storage)
11841        }
11842        pub(crate) fn from_ffi(
11843            value: ffi::WGPUSharedFenceMTLSharedEventExportInfo,
11844        ) -> Self {
11845            Self {
11846                shared_event: Some(value.sharedEvent),
11847            }
11848        }
11849    }
11850    pub struct SharedFenceDescriptor {
11851        pub(crate) extensions: Vec<SharedFenceDescriptorExtension>,
11852        pub label: Option<String>,
11853    }
11854    impl Default for SharedFenceDescriptor {
11855        fn default() -> Self {
11856            Self {
11857                extensions: Vec::new(),
11858                label: None,
11859            }
11860        }
11861    }
11862    impl SharedFenceDescriptor {
11863        pub fn new() -> Self {
11864            Self::default()
11865        }
11866        pub(crate) fn to_ffi(
11867            &self,
11868        ) -> (ffi::WGPUSharedFenceDescriptor, ChainedStructStorage) {
11869            let mut storage = ChainedStructStorage::new();
11870            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11871            for ext in self.extensions.iter().rev() {
11872                next = ext.push_chain(&mut storage, next);
11873            }
11874            let mut raw: ffi::WGPUSharedFenceDescriptor = unsafe { std::mem::zeroed() };
11875            raw.nextInChain = next;
11876            if let Some(value) = &self.label {
11877                raw.label = ffi::WGPUStringView {
11878                    data: value.as_ptr().cast(),
11879                    length: value.len(),
11880                };
11881            } else {
11882                raw.label = ffi::WGPUStringView {
11883                    data: std::ptr::null(),
11884                    length: 0,
11885                };
11886            }
11887            (raw, storage)
11888        }
11889        pub fn with_extension(
11890            mut self,
11891            extension: SharedFenceDescriptorExtension,
11892        ) -> Self {
11893            self.extensions.push(extension);
11894            self
11895        }
11896        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceDescriptor) -> Self {
11897            Self {
11898                extensions: Vec::new(),
11899                label: if value.label.data.is_null() || value.label.length == 0 {
11900                    None
11901                } else {
11902                    Some(string_view_to_string(value.label))
11903                },
11904            }
11905        }
11906    }
11907    pub struct SharedFenceExportInfo {
11908        pub(crate) extensions: Vec<SharedFenceExportInfoExtension>,
11909        pub r#type: Option<SharedFenceType>,
11910    }
11911    impl Default for SharedFenceExportInfo {
11912        fn default() -> Self {
11913            Self {
11914                extensions: Vec::new(),
11915                r#type: None,
11916            }
11917        }
11918    }
11919    impl SharedFenceExportInfo {
11920        pub fn new() -> Self {
11921            Self::default()
11922        }
11923        pub(crate) fn to_ffi(
11924            &self,
11925        ) -> (ffi::WGPUSharedFenceExportInfo, ChainedStructStorage) {
11926            let mut storage = ChainedStructStorage::new();
11927            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11928            for ext in self.extensions.iter().rev() {
11929                next = ext.push_chain(&mut storage, next);
11930            }
11931            let mut raw: ffi::WGPUSharedFenceExportInfo = unsafe { std::mem::zeroed() };
11932            raw.nextInChain = next;
11933            if let Some(value) = self.r#type {
11934                raw.type_ = value.into();
11935            } else {
11936                raw.type_ = 0 as ffi::WGPUSharedFenceType;
11937            }
11938            (raw, storage)
11939        }
11940        pub fn with_extension(
11941            mut self,
11942            extension: SharedFenceExportInfoExtension,
11943        ) -> Self {
11944            self.extensions.push(extension);
11945            self
11946        }
11947        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceExportInfo) -> Self {
11948            Self {
11949                extensions: Vec::new(),
11950                r#type: Some(value.type_.into()),
11951            }
11952        }
11953    }
11954    pub struct SharedFenceSyncFDDescriptor {
11955        pub handle: Option<i32>,
11956    }
11957    impl Default for SharedFenceSyncFDDescriptor {
11958        fn default() -> Self {
11959            Self { handle: None }
11960        }
11961    }
11962    impl SharedFenceSyncFDDescriptor {
11963        pub fn new() -> Self {
11964            Self::default()
11965        }
11966        pub(crate) fn to_ffi(
11967            &self,
11968        ) -> (ffi::WGPUSharedFenceSyncFDDescriptor, ChainedStructStorage) {
11969            let mut storage = ChainedStructStorage::new();
11970            let mut raw: ffi::WGPUSharedFenceSyncFDDescriptor = unsafe {
11971                std::mem::zeroed()
11972            };
11973            if let Some(value) = self.handle {
11974                raw.handle = value;
11975            }
11976            (raw, storage)
11977        }
11978        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceSyncFDDescriptor) -> Self {
11979            Self { handle: Some(value.handle) }
11980        }
11981    }
11982    pub struct SharedFenceSyncFDExportInfo {
11983        pub handle: Option<i32>,
11984    }
11985    impl Default for SharedFenceSyncFDExportInfo {
11986        fn default() -> Self {
11987            Self { handle: None }
11988        }
11989    }
11990    impl SharedFenceSyncFDExportInfo {
11991        pub fn new() -> Self {
11992            Self::default()
11993        }
11994        pub(crate) fn to_ffi(
11995            &self,
11996        ) -> (ffi::WGPUSharedFenceSyncFDExportInfo, ChainedStructStorage) {
11997            let mut storage = ChainedStructStorage::new();
11998            let mut raw: ffi::WGPUSharedFenceSyncFDExportInfo = unsafe {
11999                std::mem::zeroed()
12000            };
12001            if let Some(value) = self.handle {
12002                raw.handle = value;
12003            }
12004            (raw, storage)
12005        }
12006        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceSyncFDExportInfo) -> Self {
12007            Self { handle: Some(value.handle) }
12008        }
12009    }
12010    pub struct SharedFenceVkSemaphoreOpaqueFDDescriptor {
12011        pub handle: Option<i32>,
12012    }
12013    impl Default for SharedFenceVkSemaphoreOpaqueFDDescriptor {
12014        fn default() -> Self {
12015            Self { handle: None }
12016        }
12017    }
12018    impl SharedFenceVkSemaphoreOpaqueFDDescriptor {
12019        pub fn new() -> Self {
12020            Self::default()
12021        }
12022        pub(crate) fn to_ffi(
12023            &self,
12024        ) -> (ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor, ChainedStructStorage) {
12025            let mut storage = ChainedStructStorage::new();
12026            let mut raw: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor = unsafe {
12027                std::mem::zeroed()
12028            };
12029            if let Some(value) = self.handle {
12030                raw.handle = value;
12031            }
12032            (raw, storage)
12033        }
12034        pub(crate) fn from_ffi(
12035            value: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor,
12036        ) -> Self {
12037            Self { handle: Some(value.handle) }
12038        }
12039    }
12040    pub struct SharedFenceVkSemaphoreOpaqueFDExportInfo {
12041        pub handle: Option<i32>,
12042    }
12043    impl Default for SharedFenceVkSemaphoreOpaqueFDExportInfo {
12044        fn default() -> Self {
12045            Self { handle: None }
12046        }
12047    }
12048    impl SharedFenceVkSemaphoreOpaqueFDExportInfo {
12049        pub fn new() -> Self {
12050            Self::default()
12051        }
12052        pub(crate) fn to_ffi(
12053            &self,
12054        ) -> (ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo, ChainedStructStorage) {
12055            let mut storage = ChainedStructStorage::new();
12056            let mut raw: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo = unsafe {
12057                std::mem::zeroed()
12058            };
12059            if let Some(value) = self.handle {
12060                raw.handle = value;
12061            }
12062            (raw, storage)
12063        }
12064        pub(crate) fn from_ffi(
12065            value: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo,
12066        ) -> Self {
12067            Self { handle: Some(value.handle) }
12068        }
12069    }
12070    pub struct SharedFenceVkSemaphoreZirconHandleDescriptor {
12071        pub handle: Option<u32>,
12072    }
12073    impl Default for SharedFenceVkSemaphoreZirconHandleDescriptor {
12074        fn default() -> Self {
12075            Self { handle: None }
12076        }
12077    }
12078    impl SharedFenceVkSemaphoreZirconHandleDescriptor {
12079        pub fn new() -> Self {
12080            Self::default()
12081        }
12082        pub(crate) fn to_ffi(
12083            &self,
12084        ) -> (
12085            ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor,
12086            ChainedStructStorage,
12087        ) {
12088            let mut storage = ChainedStructStorage::new();
12089            let mut raw: ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor = unsafe {
12090                std::mem::zeroed()
12091            };
12092            if let Some(value) = self.handle {
12093                raw.handle = value;
12094            }
12095            (raw, storage)
12096        }
12097        pub(crate) fn from_ffi(
12098            value: ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor,
12099        ) -> Self {
12100            Self { handle: Some(value.handle) }
12101        }
12102    }
12103    pub struct SharedFenceVkSemaphoreZirconHandleExportInfo {
12104        pub handle: Option<u32>,
12105    }
12106    impl Default for SharedFenceVkSemaphoreZirconHandleExportInfo {
12107        fn default() -> Self {
12108            Self { handle: None }
12109        }
12110    }
12111    impl SharedFenceVkSemaphoreZirconHandleExportInfo {
12112        pub fn new() -> Self {
12113            Self::default()
12114        }
12115        pub(crate) fn to_ffi(
12116            &self,
12117        ) -> (
12118            ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo,
12119            ChainedStructStorage,
12120        ) {
12121            let mut storage = ChainedStructStorage::new();
12122            let mut raw: ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo = unsafe {
12123                std::mem::zeroed()
12124            };
12125            if let Some(value) = self.handle {
12126                raw.handle = value;
12127            }
12128            (raw, storage)
12129        }
12130        pub(crate) fn from_ffi(
12131            value: ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo,
12132        ) -> Self {
12133            Self { handle: Some(value.handle) }
12134        }
12135    }
12136    pub struct SharedTextureMemoryD3DSwapchainBeginState {
12137        pub is_swapchain: Option<bool>,
12138    }
12139    impl Default for SharedTextureMemoryD3DSwapchainBeginState {
12140        fn default() -> Self {
12141            Self { is_swapchain: None }
12142        }
12143    }
12144    impl SharedTextureMemoryD3DSwapchainBeginState {
12145        pub fn new() -> Self {
12146            Self::default()
12147        }
12148        pub(crate) fn to_ffi(
12149            &self,
12150        ) -> (ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState, ChainedStructStorage) {
12151            let mut storage = ChainedStructStorage::new();
12152            let mut raw: ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState = unsafe {
12153                std::mem::zeroed()
12154            };
12155            raw.isSwapchain = if self.is_swapchain.unwrap_or(false) { 1 } else { 0 };
12156            (raw, storage)
12157        }
12158        pub(crate) fn from_ffi(
12159            value: ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState,
12160        ) -> Self {
12161            Self {
12162                is_swapchain: Some(value.isSwapchain != 0),
12163            }
12164        }
12165    }
12166    pub struct SharedTextureMemoryD3D11BeginState {
12167        pub requires_end_access_fence: Option<bool>,
12168    }
12169    impl Default for SharedTextureMemoryD3D11BeginState {
12170        fn default() -> Self {
12171            Self {
12172                requires_end_access_fence: None,
12173            }
12174        }
12175    }
12176    impl SharedTextureMemoryD3D11BeginState {
12177        pub fn new() -> Self {
12178            Self::default()
12179        }
12180        pub(crate) fn to_ffi(
12181            &self,
12182        ) -> (ffi::WGPUSharedTextureMemoryD3D11BeginState, ChainedStructStorage) {
12183            let mut storage = ChainedStructStorage::new();
12184            let mut raw: ffi::WGPUSharedTextureMemoryD3D11BeginState = unsafe {
12185                std::mem::zeroed()
12186            };
12187            raw.requiresEndAccessFence = if self
12188                .requires_end_access_fence
12189                .unwrap_or(false)
12190            {
12191                1
12192            } else {
12193                0
12194            };
12195            (raw, storage)
12196        }
12197        pub(crate) fn from_ffi(
12198            value: ffi::WGPUSharedTextureMemoryD3D11BeginState,
12199        ) -> Self {
12200            Self {
12201                requires_end_access_fence: Some(value.requiresEndAccessFence != 0),
12202            }
12203        }
12204    }
12205    pub struct SharedTextureMemoryDXGISharedHandleDescriptor {
12206        pub handle: Option<*mut std::ffi::c_void>,
12207        pub use_keyed_mutex: Option<bool>,
12208    }
12209    impl Default for SharedTextureMemoryDXGISharedHandleDescriptor {
12210        fn default() -> Self {
12211            Self {
12212                handle: None,
12213                use_keyed_mutex: None,
12214            }
12215        }
12216    }
12217    impl SharedTextureMemoryDXGISharedHandleDescriptor {
12218        pub fn new() -> Self {
12219            Self::default()
12220        }
12221        pub(crate) fn to_ffi(
12222            &self,
12223        ) -> (
12224            ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor,
12225            ChainedStructStorage,
12226        ) {
12227            let mut storage = ChainedStructStorage::new();
12228            let mut raw: ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor = unsafe {
12229                std::mem::zeroed()
12230            };
12231            if let Some(value) = self.handle {
12232                raw.handle = value;
12233            }
12234            raw.useKeyedMutex = if self.use_keyed_mutex.unwrap_or(false) {
12235                1
12236            } else {
12237                0
12238            };
12239            (raw, storage)
12240        }
12241        pub(crate) fn from_ffi(
12242            value: ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor,
12243        ) -> Self {
12244            Self {
12245                handle: Some(value.handle),
12246                use_keyed_mutex: Some(value.useKeyedMutex != 0),
12247            }
12248        }
12249    }
12250    pub struct SharedTextureMemoryEGLImageDescriptor {
12251        pub image: Option<*mut std::ffi::c_void>,
12252    }
12253    impl Default for SharedTextureMemoryEGLImageDescriptor {
12254        fn default() -> Self {
12255            Self { image: None }
12256        }
12257    }
12258    impl SharedTextureMemoryEGLImageDescriptor {
12259        pub fn new() -> Self {
12260            Self::default()
12261        }
12262        pub(crate) fn to_ffi(
12263            &self,
12264        ) -> (ffi::WGPUSharedTextureMemoryEGLImageDescriptor, ChainedStructStorage) {
12265            let mut storage = ChainedStructStorage::new();
12266            let mut raw: ffi::WGPUSharedTextureMemoryEGLImageDescriptor = unsafe {
12267                std::mem::zeroed()
12268            };
12269            if let Some(value) = self.image {
12270                raw.image = value;
12271            }
12272            (raw, storage)
12273        }
12274        pub(crate) fn from_ffi(
12275            value: ffi::WGPUSharedTextureMemoryEGLImageDescriptor,
12276        ) -> Self {
12277            Self { image: Some(value.image) }
12278        }
12279    }
12280    pub struct SharedTextureMemoryIOSurfaceDescriptor {
12281        pub io_surface: Option<*mut std::ffi::c_void>,
12282        pub allow_storage_binding: Option<bool>,
12283    }
12284    impl Default for SharedTextureMemoryIOSurfaceDescriptor {
12285        fn default() -> Self {
12286            Self {
12287                io_surface: None,
12288                allow_storage_binding: None,
12289            }
12290        }
12291    }
12292    impl SharedTextureMemoryIOSurfaceDescriptor {
12293        pub fn new() -> Self {
12294            Self::default()
12295        }
12296        pub(crate) fn to_ffi(
12297            &self,
12298        ) -> (ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor, ChainedStructStorage) {
12299            let mut storage = ChainedStructStorage::new();
12300            let mut raw: ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor = unsafe {
12301                std::mem::zeroed()
12302            };
12303            if let Some(value) = self.io_surface {
12304                raw.ioSurface = value;
12305            }
12306            raw.allowStorageBinding = if self.allow_storage_binding.unwrap_or(false) {
12307                1
12308            } else {
12309                0
12310            };
12311            (raw, storage)
12312        }
12313        pub(crate) fn from_ffi(
12314            value: ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor,
12315        ) -> Self {
12316            Self {
12317                io_surface: Some(value.ioSurface),
12318                allow_storage_binding: Some(value.allowStorageBinding != 0),
12319            }
12320        }
12321    }
12322    pub struct SharedTextureMemoryAHardwareBufferDescriptor {
12323        pub handle: Option<*mut std::ffi::c_void>,
12324    }
12325    impl Default for SharedTextureMemoryAHardwareBufferDescriptor {
12326        fn default() -> Self {
12327            Self { handle: None }
12328        }
12329    }
12330    impl SharedTextureMemoryAHardwareBufferDescriptor {
12331        pub fn new() -> Self {
12332            Self::default()
12333        }
12334        pub(crate) fn to_ffi(
12335            &self,
12336        ) -> (
12337            ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor,
12338            ChainedStructStorage,
12339        ) {
12340            let mut storage = ChainedStructStorage::new();
12341            let mut raw: ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor = unsafe {
12342                std::mem::zeroed()
12343            };
12344            if let Some(value) = self.handle {
12345                raw.handle = value;
12346            }
12347            (raw, storage)
12348        }
12349        pub(crate) fn from_ffi(
12350            value: ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor,
12351        ) -> Self {
12352            Self { handle: Some(value.handle) }
12353        }
12354    }
12355    pub struct SharedTextureMemoryAHardwareBufferProperties {
12356        pub y_cb_cr_info: Option<YCbCrVkDescriptor>,
12357    }
12358    impl Default for SharedTextureMemoryAHardwareBufferProperties {
12359        fn default() -> Self {
12360            Self { y_cb_cr_info: None }
12361        }
12362    }
12363    impl SharedTextureMemoryAHardwareBufferProperties {
12364        pub fn new() -> Self {
12365            Self::default()
12366        }
12367        pub(crate) fn to_ffi(
12368            &self,
12369        ) -> (
12370            ffi::WGPUSharedTextureMemoryAHardwareBufferProperties,
12371            ChainedStructStorage,
12372        ) {
12373            let mut storage = ChainedStructStorage::new();
12374            let mut raw: ffi::WGPUSharedTextureMemoryAHardwareBufferProperties = unsafe {
12375                std::mem::zeroed()
12376            };
12377            if let Some(value) = &self.y_cb_cr_info {
12378                let (raw_value, storage_value) = value.to_ffi();
12379                raw.yCbCrInfo = raw_value;
12380                storage.push_storage(storage_value);
12381            }
12382            (raw, storage)
12383        }
12384        pub(crate) fn from_ffi(
12385            value: ffi::WGPUSharedTextureMemoryAHardwareBufferProperties,
12386        ) -> Self {
12387            Self {
12388                y_cb_cr_info: Some(YCbCrVkDescriptor::from_ffi(value.yCbCrInfo)),
12389            }
12390        }
12391    }
12392    pub struct SharedTextureMemoryBeginAccessDescriptor {
12393        pub(crate) extensions: Vec<SharedTextureMemoryBeginAccessDescriptorExtension>,
12394        pub concurrent_read: Option<bool>,
12395        pub initialized: Option<bool>,
12396        pub fences: Option<Vec<SharedFence>>,
12397        pub signaled_values: Option<Vec<u64>>,
12398    }
12399    impl Default for SharedTextureMemoryBeginAccessDescriptor {
12400        fn default() -> Self {
12401            Self {
12402                extensions: Vec::new(),
12403                concurrent_read: None,
12404                initialized: None,
12405                fences: None,
12406                signaled_values: None,
12407            }
12408        }
12409    }
12410    impl SharedTextureMemoryBeginAccessDescriptor {
12411        pub fn new() -> Self {
12412            Self::default()
12413        }
12414        pub(crate) fn to_ffi(
12415            &self,
12416        ) -> (ffi::WGPUSharedTextureMemoryBeginAccessDescriptor, ChainedStructStorage) {
12417            let mut storage = ChainedStructStorage::new();
12418            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12419            for ext in self.extensions.iter().rev() {
12420                next = ext.push_chain(&mut storage, next);
12421            }
12422            let mut raw: ffi::WGPUSharedTextureMemoryBeginAccessDescriptor = unsafe {
12423                std::mem::zeroed()
12424            };
12425            raw.nextInChain = next;
12426            raw.concurrentRead = if self.concurrent_read.unwrap_or(false) {
12427                1
12428            } else {
12429                0
12430            };
12431            raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
12432            raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
12433            if let Some(values) = &self.fences {
12434                let len_value = values.len();
12435                let raw_vec: Vec<ffi::WGPUSharedFence> = values
12436                    .iter()
12437                    .map(|v| v.as_raw())
12438                    .collect();
12439                let ptr = storage.push_vec(raw_vec);
12440                raw.fences = ptr;
12441                raw.fenceCount = len_value;
12442            } else {
12443                raw.fences = std::ptr::null();
12444                raw.fenceCount = 0;
12445            }
12446            if let Some(values) = &self.signaled_values {
12447                let len_value = values.len();
12448                let raw_vec = values.to_vec();
12449                let ptr = storage.push_vec(raw_vec);
12450                raw.signaledValues = ptr;
12451                raw.fenceCount = len_value;
12452            } else {
12453                raw.signaledValues = std::ptr::null();
12454                raw.fenceCount = 0;
12455            }
12456            (raw, storage)
12457        }
12458        pub fn with_extension(
12459            mut self,
12460            extension: SharedTextureMemoryBeginAccessDescriptorExtension,
12461        ) -> Self {
12462            self.extensions.push(extension);
12463            self
12464        }
12465        pub(crate) fn from_ffi(
12466            value: ffi::WGPUSharedTextureMemoryBeginAccessDescriptor,
12467        ) -> Self {
12468            Self {
12469                extensions: Vec::new(),
12470                concurrent_read: Some(value.concurrentRead != 0),
12471                initialized: Some(value.initialized != 0),
12472                fences: if value.fences.is_null() {
12473                    None
12474                } else {
12475                    Some(
12476                        unsafe {
12477                            std::slice::from_raw_parts(
12478                                value.fences,
12479                                value.fenceCount as usize,
12480                            )
12481                        }
12482                            .iter()
12483                            .map(|raw| unsafe { SharedFence::from_raw(*raw) })
12484                            .collect(),
12485                    )
12486                },
12487                signaled_values: if value.signaledValues.is_null() {
12488                    None
12489                } else {
12490                    Some(
12491                        unsafe {
12492                            std::slice::from_raw_parts(
12493                                value.signaledValues,
12494                                value.fenceCount as usize,
12495                            )
12496                        }
12497                            .to_vec(),
12498                    )
12499                },
12500            }
12501        }
12502    }
12503    pub struct SharedTextureMemoryDescriptor {
12504        pub(crate) extensions: Vec<SharedTextureMemoryDescriptorExtension>,
12505        pub label: Option<String>,
12506    }
12507    impl Default for SharedTextureMemoryDescriptor {
12508        fn default() -> Self {
12509            Self {
12510                extensions: Vec::new(),
12511                label: None,
12512            }
12513        }
12514    }
12515    impl SharedTextureMemoryDescriptor {
12516        pub fn new() -> Self {
12517            Self::default()
12518        }
12519        pub(crate) fn to_ffi(
12520            &self,
12521        ) -> (ffi::WGPUSharedTextureMemoryDescriptor, ChainedStructStorage) {
12522            let mut storage = ChainedStructStorage::new();
12523            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12524            for ext in self.extensions.iter().rev() {
12525                next = ext.push_chain(&mut storage, next);
12526            }
12527            let mut raw: ffi::WGPUSharedTextureMemoryDescriptor = unsafe {
12528                std::mem::zeroed()
12529            };
12530            raw.nextInChain = next;
12531            if let Some(value) = &self.label {
12532                raw.label = ffi::WGPUStringView {
12533                    data: value.as_ptr().cast(),
12534                    length: value.len(),
12535                };
12536            } else {
12537                raw.label = ffi::WGPUStringView {
12538                    data: std::ptr::null(),
12539                    length: 0,
12540                };
12541            }
12542            (raw, storage)
12543        }
12544        pub fn with_extension(
12545            mut self,
12546            extension: SharedTextureMemoryDescriptorExtension,
12547        ) -> Self {
12548            self.extensions.push(extension);
12549            self
12550        }
12551        pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryDescriptor) -> Self {
12552            Self {
12553                extensions: Vec::new(),
12554                label: if value.label.data.is_null() || value.label.length == 0 {
12555                    None
12556                } else {
12557                    Some(string_view_to_string(value.label))
12558                },
12559            }
12560        }
12561    }
12562    pub struct SharedTextureMemoryDmaBufDescriptor {
12563        pub size: Option<Extent3D>,
12564        pub drm_format: Option<u32>,
12565        pub drm_modifier: Option<u64>,
12566        pub planes: Option<Vec<SharedTextureMemoryDmaBufPlane>>,
12567    }
12568    impl Default for SharedTextureMemoryDmaBufDescriptor {
12569        fn default() -> Self {
12570            Self {
12571                size: None,
12572                drm_format: None,
12573                drm_modifier: None,
12574                planes: None,
12575            }
12576        }
12577    }
12578    impl SharedTextureMemoryDmaBufDescriptor {
12579        pub fn new() -> Self {
12580            Self::default()
12581        }
12582        pub(crate) fn to_ffi(
12583            &self,
12584        ) -> (ffi::WGPUSharedTextureMemoryDmaBufDescriptor, ChainedStructStorage) {
12585            let mut storage = ChainedStructStorage::new();
12586            let mut raw: ffi::WGPUSharedTextureMemoryDmaBufDescriptor = unsafe {
12587                std::mem::zeroed()
12588            };
12589            if let Some(value) = &self.size {
12590                let (raw_value, storage_value) = value.to_ffi();
12591                raw.size = raw_value;
12592                storage.push_storage(storage_value);
12593            }
12594            if let Some(value) = self.drm_format {
12595                raw.drmFormat = value;
12596            }
12597            if let Some(value) = self.drm_modifier {
12598                raw.drmModifier = value;
12599            }
12600            raw.planeCount = self.planes.as_ref().map(|v| v.len()).unwrap_or(0);
12601            if let Some(values) = &self.planes {
12602                let len_value = values.len();
12603                let mut raw_vec: Vec<ffi::WGPUSharedTextureMemoryDmaBufPlane> = Vec::with_capacity(
12604                    values.len(),
12605                );
12606                for item in values.iter() {
12607                    let (raw_item, storage_item) = item.to_ffi();
12608                    raw_vec.push(raw_item);
12609                    storage.push_storage(storage_item);
12610                }
12611                let ptr = storage.push_vec(raw_vec);
12612                raw.planes = ptr;
12613                raw.planeCount = len_value;
12614            } else {
12615                raw.planes = std::ptr::null();
12616                raw.planeCount = 0;
12617            }
12618            (raw, storage)
12619        }
12620        pub(crate) fn from_ffi(
12621            value: ffi::WGPUSharedTextureMemoryDmaBufDescriptor,
12622        ) -> Self {
12623            Self {
12624                size: Some(Extent3D::from_ffi(value.size)),
12625                drm_format: Some(value.drmFormat),
12626                drm_modifier: Some(value.drmModifier),
12627                planes: if value.planes.is_null() {
12628                    None
12629                } else {
12630                    Some(
12631                        unsafe {
12632                            std::slice::from_raw_parts(
12633                                value.planes,
12634                                value.planeCount as usize,
12635                            )
12636                        }
12637                            .iter()
12638                            .map(|raw| SharedTextureMemoryDmaBufPlane::from_ffi(*raw))
12639                            .collect(),
12640                    )
12641                },
12642            }
12643        }
12644    }
12645    pub struct SharedTextureMemoryDmaBufPlane {
12646        pub fd: Option<i32>,
12647        pub offset: Option<u64>,
12648        pub stride: Option<u32>,
12649    }
12650    impl Default for SharedTextureMemoryDmaBufPlane {
12651        fn default() -> Self {
12652            Self {
12653                fd: None,
12654                offset: None,
12655                stride: None,
12656            }
12657        }
12658    }
12659    impl SharedTextureMemoryDmaBufPlane {
12660        pub fn new() -> Self {
12661            Self::default()
12662        }
12663        pub(crate) fn to_ffi(
12664            &self,
12665        ) -> (ffi::WGPUSharedTextureMemoryDmaBufPlane, ChainedStructStorage) {
12666            let mut storage = ChainedStructStorage::new();
12667            let mut raw: ffi::WGPUSharedTextureMemoryDmaBufPlane = unsafe {
12668                std::mem::zeroed()
12669            };
12670            if let Some(value) = self.fd {
12671                raw.fd = value;
12672            }
12673            if let Some(value) = self.offset {
12674                raw.offset = value;
12675            }
12676            if let Some(value) = self.stride {
12677                raw.stride = value;
12678            }
12679            (raw, storage)
12680        }
12681        pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryDmaBufPlane) -> Self {
12682            Self {
12683                fd: Some(value.fd),
12684                offset: Some(value.offset),
12685                stride: Some(value.stride),
12686            }
12687        }
12688    }
12689    pub struct SharedTextureMemoryEndAccessState {
12690        pub(crate) extensions: Vec<SharedTextureMemoryEndAccessStateExtension>,
12691        pub initialized: Option<bool>,
12692        pub fences: Option<Vec<SharedFence>>,
12693        pub signaled_values: Option<Vec<u64>>,
12694        #[doc(hidden)]
12695        pub(crate) _free_members: Option<ffi::WGPUSharedTextureMemoryEndAccessState>,
12696    }
12697    impl Default for SharedTextureMemoryEndAccessState {
12698        fn default() -> Self {
12699            Self {
12700                extensions: Vec::new(),
12701                initialized: None,
12702                fences: None,
12703                signaled_values: None,
12704                _free_members: None,
12705            }
12706        }
12707    }
12708    impl SharedTextureMemoryEndAccessState {
12709        pub fn new() -> Self {
12710            Self::default()
12711        }
12712        pub(crate) fn to_ffi(
12713            &self,
12714        ) -> (ffi::WGPUSharedTextureMemoryEndAccessState, ChainedStructStorage) {
12715            let mut storage = ChainedStructStorage::new();
12716            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12717            for ext in self.extensions.iter().rev() {
12718                next = ext.push_chain(&mut storage, next);
12719            }
12720            let mut raw: ffi::WGPUSharedTextureMemoryEndAccessState = unsafe {
12721                std::mem::zeroed()
12722            };
12723            raw.nextInChain = next;
12724            raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
12725            raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
12726            if let Some(values) = &self.fences {
12727                let len_value = values.len();
12728                let raw_vec: Vec<ffi::WGPUSharedFence> = values
12729                    .iter()
12730                    .map(|v| v.as_raw())
12731                    .collect();
12732                let ptr = storage.push_vec(raw_vec);
12733                raw.fences = ptr;
12734                raw.fenceCount = len_value;
12735            } else {
12736                raw.fences = std::ptr::null();
12737                raw.fenceCount = 0;
12738            }
12739            if let Some(values) = &self.signaled_values {
12740                let len_value = values.len();
12741                let raw_vec = values.to_vec();
12742                let ptr = storage.push_vec(raw_vec);
12743                raw.signaledValues = ptr;
12744                raw.fenceCount = len_value;
12745            } else {
12746                raw.signaledValues = std::ptr::null();
12747                raw.fenceCount = 0;
12748            }
12749            (raw, storage)
12750        }
12751        pub fn with_extension(
12752            mut self,
12753            extension: SharedTextureMemoryEndAccessStateExtension,
12754        ) -> Self {
12755            self.extensions.push(extension);
12756            self
12757        }
12758        pub(crate) fn from_ffi(
12759            value: ffi::WGPUSharedTextureMemoryEndAccessState,
12760        ) -> Self {
12761            Self {
12762                extensions: Vec::new(),
12763                initialized: Some(value.initialized != 0),
12764                fences: if value.fences.is_null() {
12765                    None
12766                } else {
12767                    Some(
12768                        unsafe {
12769                            std::slice::from_raw_parts(
12770                                value.fences,
12771                                value.fenceCount as usize,
12772                            )
12773                        }
12774                            .iter()
12775                            .map(|raw| unsafe { SharedFence::from_raw(*raw) })
12776                            .collect(),
12777                    )
12778                },
12779                signaled_values: if value.signaledValues.is_null() {
12780                    None
12781                } else {
12782                    Some(
12783                        unsafe {
12784                            std::slice::from_raw_parts(
12785                                value.signaledValues,
12786                                value.fenceCount as usize,
12787                            )
12788                        }
12789                            .to_vec(),
12790                    )
12791                },
12792                _free_members: Some(value),
12793            }
12794        }
12795        pub(crate) fn free_members(value: ffi::WGPUSharedTextureMemoryEndAccessState) {
12796            unsafe { ffi::wgpuSharedTextureMemoryEndAccessStateFreeMembers(value) };
12797        }
12798    }
12799    impl Drop for SharedTextureMemoryEndAccessState {
12800        fn drop(&mut self) {
12801            if let Some(value) = self._free_members.take() {
12802                unsafe { ffi::wgpuSharedTextureMemoryEndAccessStateFreeMembers(value) };
12803            }
12804        }
12805    }
12806    pub struct SharedTextureMemoryMetalEndAccessState {
12807        pub commands_scheduled_future: Option<Future>,
12808    }
12809    impl Default for SharedTextureMemoryMetalEndAccessState {
12810        fn default() -> Self {
12811            Self {
12812                commands_scheduled_future: None,
12813            }
12814        }
12815    }
12816    impl SharedTextureMemoryMetalEndAccessState {
12817        pub fn new() -> Self {
12818            Self::default()
12819        }
12820        pub(crate) fn to_ffi(
12821            &self,
12822        ) -> (ffi::WGPUSharedTextureMemoryMetalEndAccessState, ChainedStructStorage) {
12823            let mut storage = ChainedStructStorage::new();
12824            let mut raw: ffi::WGPUSharedTextureMemoryMetalEndAccessState = unsafe {
12825                std::mem::zeroed()
12826            };
12827            if let Some(value) = &self.commands_scheduled_future {
12828                let (raw_value, storage_value) = value.to_ffi();
12829                raw.commandsScheduledFuture = raw_value;
12830                storage.push_storage(storage_value);
12831            }
12832            (raw, storage)
12833        }
12834        pub(crate) fn from_ffi(
12835            value: ffi::WGPUSharedTextureMemoryMetalEndAccessState,
12836        ) -> Self {
12837            Self {
12838                commands_scheduled_future: Some(
12839                    Future::from_ffi(value.commandsScheduledFuture),
12840                ),
12841            }
12842        }
12843    }
12844    pub struct SharedTextureMemoryOpaqueFDDescriptor {
12845        pub vk_image_create_info: Option<*const std::ffi::c_void>,
12846        pub memory_fd: Option<i32>,
12847        pub memory_type_index: Option<u32>,
12848        pub allocation_size: Option<u64>,
12849        pub dedicated_allocation: Option<bool>,
12850    }
12851    impl Default for SharedTextureMemoryOpaqueFDDescriptor {
12852        fn default() -> Self {
12853            Self {
12854                vk_image_create_info: None,
12855                memory_fd: None,
12856                memory_type_index: None,
12857                allocation_size: None,
12858                dedicated_allocation: None,
12859            }
12860        }
12861    }
12862    impl SharedTextureMemoryOpaqueFDDescriptor {
12863        pub fn new() -> Self {
12864            Self::default()
12865        }
12866        pub(crate) fn to_ffi(
12867            &self,
12868        ) -> (ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor, ChainedStructStorage) {
12869            let mut storage = ChainedStructStorage::new();
12870            let mut raw: ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor = unsafe {
12871                std::mem::zeroed()
12872            };
12873            if let Some(value) = self.vk_image_create_info {
12874                raw.vkImageCreateInfo = value;
12875            }
12876            if let Some(value) = self.memory_fd {
12877                raw.memoryFD = value;
12878            }
12879            if let Some(value) = self.memory_type_index {
12880                raw.memoryTypeIndex = value;
12881            }
12882            if let Some(value) = self.allocation_size {
12883                raw.allocationSize = value;
12884            }
12885            raw.dedicatedAllocation = if self.dedicated_allocation.unwrap_or(false) {
12886                1
12887            } else {
12888                0
12889            };
12890            (raw, storage)
12891        }
12892        pub(crate) fn from_ffi(
12893            value: ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor,
12894        ) -> Self {
12895            Self {
12896                vk_image_create_info: Some(value.vkImageCreateInfo),
12897                memory_fd: Some(value.memoryFD),
12898                memory_type_index: Some(value.memoryTypeIndex),
12899                allocation_size: Some(value.allocationSize),
12900                dedicated_allocation: Some(value.dedicatedAllocation != 0),
12901            }
12902        }
12903    }
12904    pub struct SharedTextureMemoryProperties {
12905        pub(crate) extensions: Vec<SharedTextureMemoryPropertiesExtension>,
12906        pub usage: Option<TextureUsage>,
12907        pub size: Option<Extent3D>,
12908        pub format: Option<TextureFormat>,
12909    }
12910    impl Default for SharedTextureMemoryProperties {
12911        fn default() -> Self {
12912            Self {
12913                extensions: Vec::new(),
12914                usage: None,
12915                size: None,
12916                format: None,
12917            }
12918        }
12919    }
12920    impl SharedTextureMemoryProperties {
12921        pub fn new() -> Self {
12922            Self::default()
12923        }
12924        pub(crate) fn to_ffi(
12925            &self,
12926        ) -> (ffi::WGPUSharedTextureMemoryProperties, ChainedStructStorage) {
12927            let mut storage = ChainedStructStorage::new();
12928            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12929            for ext in self.extensions.iter().rev() {
12930                next = ext.push_chain(&mut storage, next);
12931            }
12932            let mut raw: ffi::WGPUSharedTextureMemoryProperties = unsafe {
12933                std::mem::zeroed()
12934            };
12935            raw.nextInChain = next;
12936            if let Some(value) = self.usage {
12937                raw.usage = value.into();
12938            } else {
12939                raw.usage = 0 as ffi::WGPUTextureUsage;
12940            }
12941            if let Some(value) = &self.size {
12942                let (raw_value, storage_value) = value.to_ffi();
12943                raw.size = raw_value;
12944                storage.push_storage(storage_value);
12945            }
12946            if let Some(value) = self.format {
12947                raw.format = value.into();
12948            } else {
12949                raw.format = 0 as ffi::WGPUTextureFormat;
12950            }
12951            (raw, storage)
12952        }
12953        pub fn with_extension(
12954            mut self,
12955            extension: SharedTextureMemoryPropertiesExtension,
12956        ) -> Self {
12957            self.extensions.push(extension);
12958            self
12959        }
12960        pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryProperties) -> Self {
12961            Self {
12962                extensions: Vec::new(),
12963                usage: Some(value.usage.into()),
12964                size: Some(Extent3D::from_ffi(value.size)),
12965                format: Some(value.format.into()),
12966            }
12967        }
12968    }
12969    pub struct SharedTextureMemoryVkDedicatedAllocationDescriptor {
12970        pub dedicated_allocation: Option<bool>,
12971    }
12972    impl Default for SharedTextureMemoryVkDedicatedAllocationDescriptor {
12973        fn default() -> Self {
12974            Self { dedicated_allocation: None }
12975        }
12976    }
12977    impl SharedTextureMemoryVkDedicatedAllocationDescriptor {
12978        pub fn new() -> Self {
12979            Self::default()
12980        }
12981        pub(crate) fn to_ffi(
12982            &self,
12983        ) -> (
12984            ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor,
12985            ChainedStructStorage,
12986        ) {
12987            let mut storage = ChainedStructStorage::new();
12988            let mut raw: ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor = unsafe {
12989                std::mem::zeroed()
12990            };
12991            raw.dedicatedAllocation = if self.dedicated_allocation.unwrap_or(false) {
12992                1
12993            } else {
12994                0
12995            };
12996            (raw, storage)
12997        }
12998        pub(crate) fn from_ffi(
12999            value: ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor,
13000        ) -> Self {
13001            Self {
13002                dedicated_allocation: Some(value.dedicatedAllocation != 0),
13003            }
13004        }
13005    }
13006    pub struct SharedTextureMemoryVkImageLayoutBeginState {
13007        pub old_layout: Option<i32>,
13008        pub new_layout: Option<i32>,
13009    }
13010    impl Default for SharedTextureMemoryVkImageLayoutBeginState {
13011        fn default() -> Self {
13012            Self {
13013                old_layout: None,
13014                new_layout: None,
13015            }
13016        }
13017    }
13018    impl SharedTextureMemoryVkImageLayoutBeginState {
13019        pub fn new() -> Self {
13020            Self::default()
13021        }
13022        pub(crate) fn to_ffi(
13023            &self,
13024        ) -> (
13025            ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState,
13026            ChainedStructStorage,
13027        ) {
13028            let mut storage = ChainedStructStorage::new();
13029            let mut raw: ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState = unsafe {
13030                std::mem::zeroed()
13031            };
13032            if let Some(value) = self.old_layout {
13033                raw.oldLayout = value;
13034            }
13035            if let Some(value) = self.new_layout {
13036                raw.newLayout = value;
13037            }
13038            (raw, storage)
13039        }
13040        pub(crate) fn from_ffi(
13041            value: ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState,
13042        ) -> Self {
13043            Self {
13044                old_layout: Some(value.oldLayout),
13045                new_layout: Some(value.newLayout),
13046            }
13047        }
13048    }
13049    pub struct SharedTextureMemoryVkImageLayoutEndState {
13050        pub old_layout: Option<i32>,
13051        pub new_layout: Option<i32>,
13052    }
13053    impl Default for SharedTextureMemoryVkImageLayoutEndState {
13054        fn default() -> Self {
13055            Self {
13056                old_layout: None,
13057                new_layout: None,
13058            }
13059        }
13060    }
13061    impl SharedTextureMemoryVkImageLayoutEndState {
13062        pub fn new() -> Self {
13063            Self::default()
13064        }
13065        pub(crate) fn to_ffi(
13066            &self,
13067        ) -> (ffi::WGPUSharedTextureMemoryVkImageLayoutEndState, ChainedStructStorage) {
13068            let mut storage = ChainedStructStorage::new();
13069            let mut raw: ffi::WGPUSharedTextureMemoryVkImageLayoutEndState = unsafe {
13070                std::mem::zeroed()
13071            };
13072            if let Some(value) = self.old_layout {
13073                raw.oldLayout = value;
13074            }
13075            if let Some(value) = self.new_layout {
13076                raw.newLayout = value;
13077            }
13078            (raw, storage)
13079        }
13080        pub(crate) fn from_ffi(
13081            value: ffi::WGPUSharedTextureMemoryVkImageLayoutEndState,
13082        ) -> Self {
13083            Self {
13084                old_layout: Some(value.oldLayout),
13085                new_layout: Some(value.newLayout),
13086            }
13087        }
13088    }
13089    pub struct SharedTextureMemoryZirconHandleDescriptor {
13090        pub memory_fd: Option<u32>,
13091        pub allocation_size: Option<u64>,
13092    }
13093    impl Default for SharedTextureMemoryZirconHandleDescriptor {
13094        fn default() -> Self {
13095            Self {
13096                memory_fd: None,
13097                allocation_size: None,
13098            }
13099        }
13100    }
13101    impl SharedTextureMemoryZirconHandleDescriptor {
13102        pub fn new() -> Self {
13103            Self::default()
13104        }
13105        pub(crate) fn to_ffi(
13106            &self,
13107        ) -> (ffi::WGPUSharedTextureMemoryZirconHandleDescriptor, ChainedStructStorage) {
13108            let mut storage = ChainedStructStorage::new();
13109            let mut raw: ffi::WGPUSharedTextureMemoryZirconHandleDescriptor = unsafe {
13110                std::mem::zeroed()
13111            };
13112            if let Some(value) = self.memory_fd {
13113                raw.memoryFD = value;
13114            }
13115            if let Some(value) = self.allocation_size {
13116                raw.allocationSize = value;
13117            }
13118            (raw, storage)
13119        }
13120        pub(crate) fn from_ffi(
13121            value: ffi::WGPUSharedTextureMemoryZirconHandleDescriptor,
13122        ) -> Self {
13123            Self {
13124                memory_fd: Some(value.memoryFD),
13125                allocation_size: Some(value.allocationSize),
13126            }
13127        }
13128    }
13129    pub struct StaticSamplerBindingLayout {
13130        pub sampler: Option<Sampler>,
13131        pub sampled_texture_binding: Option<u32>,
13132    }
13133    impl Default for StaticSamplerBindingLayout {
13134        fn default() -> Self {
13135            Self {
13136                sampler: None,
13137                sampled_texture_binding: Some(LIMIT_U32_UNDEFINED),
13138            }
13139        }
13140    }
13141    impl StaticSamplerBindingLayout {
13142        pub fn new() -> Self {
13143            Self::default()
13144        }
13145        pub(crate) fn to_ffi(
13146            &self,
13147        ) -> (ffi::WGPUStaticSamplerBindingLayout, ChainedStructStorage) {
13148            let mut storage = ChainedStructStorage::new();
13149            let mut raw: ffi::WGPUStaticSamplerBindingLayout = unsafe {
13150                std::mem::zeroed()
13151            };
13152            raw.sampler = self
13153                .sampler
13154                .as_ref()
13155                .map(|v| v.as_raw())
13156                .unwrap_or(std::ptr::null_mut());
13157            if let Some(value) = self.sampled_texture_binding {
13158                raw.sampledTextureBinding = value;
13159            }
13160            (raw, storage)
13161        }
13162        pub(crate) fn from_ffi(value: ffi::WGPUStaticSamplerBindingLayout) -> Self {
13163            Self {
13164                sampler: Some(unsafe { Sampler::from_raw(value.sampler) }),
13165                sampled_texture_binding: Some(value.sampledTextureBinding),
13166            }
13167        }
13168    }
13169    pub struct StencilFaceState {
13170        pub compare: Option<CompareFunction>,
13171        pub fail_op: Option<StencilOperation>,
13172        pub depth_fail_op: Option<StencilOperation>,
13173        pub pass_op: Option<StencilOperation>,
13174    }
13175    impl Default for StencilFaceState {
13176        fn default() -> Self {
13177            Self {
13178                compare: Some(CompareFunction::Always),
13179                fail_op: Some(StencilOperation::Keep),
13180                depth_fail_op: Some(StencilOperation::Keep),
13181                pass_op: Some(StencilOperation::Keep),
13182            }
13183        }
13184    }
13185    impl StencilFaceState {
13186        pub fn new() -> Self {
13187            Self::default()
13188        }
13189        pub(crate) fn to_ffi(
13190            &self,
13191        ) -> (ffi::WGPUStencilFaceState, ChainedStructStorage) {
13192            let mut storage = ChainedStructStorage::new();
13193            let mut raw: ffi::WGPUStencilFaceState = unsafe { std::mem::zeroed() };
13194            if let Some(value) = self.compare {
13195                raw.compare = value.into();
13196            } else {
13197                raw.compare = 0 as ffi::WGPUCompareFunction;
13198            }
13199            if let Some(value) = self.fail_op {
13200                raw.failOp = value.into();
13201            } else {
13202                raw.failOp = 0 as ffi::WGPUStencilOperation;
13203            }
13204            if let Some(value) = self.depth_fail_op {
13205                raw.depthFailOp = value.into();
13206            } else {
13207                raw.depthFailOp = 0 as ffi::WGPUStencilOperation;
13208            }
13209            if let Some(value) = self.pass_op {
13210                raw.passOp = value.into();
13211            } else {
13212                raw.passOp = 0 as ffi::WGPUStencilOperation;
13213            }
13214            (raw, storage)
13215        }
13216        pub(crate) fn from_ffi(value: ffi::WGPUStencilFaceState) -> Self {
13217            Self {
13218                compare: Some(value.compare.into()),
13219                fail_op: Some(value.failOp.into()),
13220                depth_fail_op: Some(value.depthFailOp.into()),
13221                pass_op: Some(value.passOp.into()),
13222            }
13223        }
13224    }
13225    pub struct StorageTextureBindingLayout {
13226        pub(crate) extensions: Vec<StorageTextureBindingLayoutExtension>,
13227        pub access: Option<StorageTextureAccess>,
13228        pub format: Option<TextureFormat>,
13229        pub view_dimension: Option<TextureViewDimension>,
13230    }
13231    impl Default for StorageTextureBindingLayout {
13232        fn default() -> Self {
13233            Self {
13234                extensions: Vec::new(),
13235                access: Some(StorageTextureAccess::WriteOnly),
13236                format: None,
13237                view_dimension: Some(TextureViewDimension::D2),
13238            }
13239        }
13240    }
13241    impl StorageTextureBindingLayout {
13242        pub fn new() -> Self {
13243            Self::default()
13244        }
13245        pub(crate) fn to_ffi(
13246            &self,
13247        ) -> (ffi::WGPUStorageTextureBindingLayout, ChainedStructStorage) {
13248            let mut storage = ChainedStructStorage::new();
13249            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13250            for ext in self.extensions.iter().rev() {
13251                next = ext.push_chain(&mut storage, next);
13252            }
13253            let mut raw: ffi::WGPUStorageTextureBindingLayout = unsafe {
13254                std::mem::zeroed()
13255            };
13256            raw.nextInChain = next;
13257            if let Some(value) = self.access {
13258                raw.access = value.into();
13259            } else {
13260                raw.access = 0 as ffi::WGPUStorageTextureAccess;
13261            }
13262            if let Some(value) = self.format {
13263                raw.format = value.into();
13264            } else {
13265                raw.format = 0 as ffi::WGPUTextureFormat;
13266            }
13267            if let Some(value) = self.view_dimension {
13268                raw.viewDimension = value.into();
13269            } else {
13270                raw.viewDimension = 0 as ffi::WGPUTextureViewDimension;
13271            }
13272            (raw, storage)
13273        }
13274        pub fn with_extension(
13275            mut self,
13276            extension: StorageTextureBindingLayoutExtension,
13277        ) -> Self {
13278            self.extensions.push(extension);
13279            self
13280        }
13281        pub(crate) fn from_ffi(value: ffi::WGPUStorageTextureBindingLayout) -> Self {
13282            Self {
13283                extensions: Vec::new(),
13284                access: Some(value.access.into()),
13285                format: Some(value.format.into()),
13286                view_dimension: Some(value.viewDimension.into()),
13287            }
13288        }
13289    }
13290    pub struct StringView {
13291        pub data: Option<*const std::os::raw::c_char>,
13292        pub length: Option<usize>,
13293    }
13294    impl Default for StringView {
13295        fn default() -> Self {
13296            Self {
13297                data: None,
13298                length: Some(STRLEN),
13299            }
13300        }
13301    }
13302    impl StringView {
13303        pub fn new() -> Self {
13304            Self::default()
13305        }
13306        pub(crate) fn to_ffi(&self) -> (ffi::WGPUStringView, ChainedStructStorage) {
13307            let mut storage = ChainedStructStorage::new();
13308            let mut raw: ffi::WGPUStringView = unsafe { std::mem::zeroed() };
13309            if let Some(value) = self.data {
13310                raw.data = value;
13311            }
13312            if let Some(value) = self.length {
13313                raw.length = value;
13314            }
13315            (raw, storage)
13316        }
13317        pub(crate) fn from_ffi(value: ffi::WGPUStringView) -> Self {
13318            Self {
13319                data: Some(value.data),
13320                length: Some(value.length),
13321            }
13322        }
13323    }
13324    pub struct SubgroupMatrixConfig {
13325        pub component_type: Option<SubgroupMatrixComponentType>,
13326        pub result_component_type: Option<SubgroupMatrixComponentType>,
13327        pub m: Option<u32>,
13328        pub n: Option<u32>,
13329        pub k: Option<u32>,
13330    }
13331    impl Default for SubgroupMatrixConfig {
13332        fn default() -> Self {
13333            Self {
13334                component_type: None,
13335                result_component_type: None,
13336                m: None,
13337                n: None,
13338                k: None,
13339            }
13340        }
13341    }
13342    impl SubgroupMatrixConfig {
13343        pub fn new() -> Self {
13344            Self::default()
13345        }
13346        pub(crate) fn to_ffi(
13347            &self,
13348        ) -> (ffi::WGPUSubgroupMatrixConfig, ChainedStructStorage) {
13349            let mut storage = ChainedStructStorage::new();
13350            let mut raw: ffi::WGPUSubgroupMatrixConfig = unsafe { std::mem::zeroed() };
13351            if let Some(value) = self.component_type {
13352                raw.componentType = value.into();
13353            } else {
13354                raw.componentType = 0 as ffi::WGPUSubgroupMatrixComponentType;
13355            }
13356            if let Some(value) = self.result_component_type {
13357                raw.resultComponentType = value.into();
13358            } else {
13359                raw.resultComponentType = 0 as ffi::WGPUSubgroupMatrixComponentType;
13360            }
13361            if let Some(value) = self.m {
13362                raw.M = value;
13363            }
13364            if let Some(value) = self.n {
13365                raw.N = value;
13366            }
13367            if let Some(value) = self.k {
13368                raw.K = value;
13369            }
13370            (raw, storage)
13371        }
13372        pub(crate) fn from_ffi(value: ffi::WGPUSubgroupMatrixConfig) -> Self {
13373            Self {
13374                component_type: Some(value.componentType.into()),
13375                result_component_type: Some(value.resultComponentType.into()),
13376                m: Some(value.M),
13377                n: Some(value.N),
13378                k: Some(value.K),
13379            }
13380        }
13381    }
13382    pub struct SupportedWGSLLanguageFeatures {
13383        pub features: Option<Vec<WGSLLanguageFeatureName>>,
13384        #[doc(hidden)]
13385        pub(crate) _free_members: Option<ffi::WGPUSupportedWGSLLanguageFeatures>,
13386    }
13387    impl Default for SupportedWGSLLanguageFeatures {
13388        fn default() -> Self {
13389            Self {
13390                features: None,
13391                _free_members: None,
13392            }
13393        }
13394    }
13395    impl SupportedWGSLLanguageFeatures {
13396        pub fn new() -> Self {
13397            Self::default()
13398        }
13399        pub(crate) fn to_ffi(
13400            &self,
13401        ) -> (ffi::WGPUSupportedWGSLLanguageFeatures, ChainedStructStorage) {
13402            let mut storage = ChainedStructStorage::new();
13403            let mut raw: ffi::WGPUSupportedWGSLLanguageFeatures = unsafe {
13404                std::mem::zeroed()
13405            };
13406            raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13407            if let Some(values) = &self.features {
13408                let len_value = values.len();
13409                let raw_vec: Vec<ffi::WGPUWGSLLanguageFeatureName> = values
13410                    .iter()
13411                    .map(|v| (*v).into())
13412                    .collect();
13413                let ptr = storage.push_vec(raw_vec);
13414                raw.features = ptr;
13415                raw.featureCount = len_value;
13416            } else {
13417                raw.features = std::ptr::null();
13418                raw.featureCount = 0;
13419            }
13420            (raw, storage)
13421        }
13422        pub(crate) fn from_ffi(value: ffi::WGPUSupportedWGSLLanguageFeatures) -> Self {
13423            Self {
13424                features: if value.features.is_null() {
13425                    None
13426                } else {
13427                    Some(
13428                        unsafe {
13429                            std::slice::from_raw_parts(
13430                                value.features,
13431                                value.featureCount as usize,
13432                            )
13433                        }
13434                            .iter()
13435                            .map(|raw| WGSLLanguageFeatureName::from(*raw))
13436                            .collect(),
13437                    )
13438                },
13439                _free_members: Some(value),
13440            }
13441        }
13442        pub(crate) fn free_members(value: ffi::WGPUSupportedWGSLLanguageFeatures) {
13443            unsafe { ffi::wgpuSupportedWGSLLanguageFeaturesFreeMembers(value) };
13444        }
13445    }
13446    impl Drop for SupportedWGSLLanguageFeatures {
13447        fn drop(&mut self) {
13448            if let Some(value) = self._free_members.take() {
13449                unsafe { ffi::wgpuSupportedWGSLLanguageFeaturesFreeMembers(value) };
13450            }
13451        }
13452    }
13453    pub struct SupportedFeatures {
13454        pub features: Option<Vec<FeatureName>>,
13455        #[doc(hidden)]
13456        pub(crate) _free_members: Option<ffi::WGPUSupportedFeatures>,
13457    }
13458    impl Default for SupportedFeatures {
13459        fn default() -> Self {
13460            Self {
13461                features: None,
13462                _free_members: None,
13463            }
13464        }
13465    }
13466    impl SupportedFeatures {
13467        pub fn new() -> Self {
13468            Self::default()
13469        }
13470        pub(crate) fn to_ffi(
13471            &self,
13472        ) -> (ffi::WGPUSupportedFeatures, ChainedStructStorage) {
13473            let mut storage = ChainedStructStorage::new();
13474            let mut raw: ffi::WGPUSupportedFeatures = unsafe { std::mem::zeroed() };
13475            raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13476            if let Some(values) = &self.features {
13477                let len_value = values.len();
13478                let raw_vec: Vec<ffi::WGPUFeatureName> = values
13479                    .iter()
13480                    .map(|v| (*v).into())
13481                    .collect();
13482                let ptr = storage.push_vec(raw_vec);
13483                raw.features = ptr;
13484                raw.featureCount = len_value;
13485            } else {
13486                raw.features = std::ptr::null();
13487                raw.featureCount = 0;
13488            }
13489            (raw, storage)
13490        }
13491        pub(crate) fn from_ffi(value: ffi::WGPUSupportedFeatures) -> Self {
13492            Self {
13493                features: if value.features.is_null() {
13494                    None
13495                } else {
13496                    Some(
13497                        unsafe {
13498                            std::slice::from_raw_parts(
13499                                value.features,
13500                                value.featureCount as usize,
13501                            )
13502                        }
13503                            .iter()
13504                            .map(|raw| FeatureName::from(*raw))
13505                            .collect(),
13506                    )
13507                },
13508                _free_members: Some(value),
13509            }
13510        }
13511        pub(crate) fn free_members(value: ffi::WGPUSupportedFeatures) {
13512            unsafe { ffi::wgpuSupportedFeaturesFreeMembers(value) };
13513        }
13514    }
13515    impl Drop for SupportedFeatures {
13516        fn drop(&mut self) {
13517            if let Some(value) = self._free_members.take() {
13518                unsafe { ffi::wgpuSupportedFeaturesFreeMembers(value) };
13519            }
13520        }
13521    }
13522    pub struct SupportedInstanceFeatures {
13523        pub features: Option<Vec<InstanceFeatureName>>,
13524        #[doc(hidden)]
13525        pub(crate) _free_members: Option<ffi::WGPUSupportedInstanceFeatures>,
13526    }
13527    impl Default for SupportedInstanceFeatures {
13528        fn default() -> Self {
13529            Self {
13530                features: None,
13531                _free_members: None,
13532            }
13533        }
13534    }
13535    impl SupportedInstanceFeatures {
13536        pub fn new() -> Self {
13537            Self::default()
13538        }
13539        pub(crate) fn to_ffi(
13540            &self,
13541        ) -> (ffi::WGPUSupportedInstanceFeatures, ChainedStructStorage) {
13542            let mut storage = ChainedStructStorage::new();
13543            let mut raw: ffi::WGPUSupportedInstanceFeatures = unsafe {
13544                std::mem::zeroed()
13545            };
13546            raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13547            if let Some(values) = &self.features {
13548                let len_value = values.len();
13549                let raw_vec: Vec<ffi::WGPUInstanceFeatureName> = values
13550                    .iter()
13551                    .map(|v| (*v).into())
13552                    .collect();
13553                let ptr = storage.push_vec(raw_vec);
13554                raw.features = ptr;
13555                raw.featureCount = len_value;
13556            } else {
13557                raw.features = std::ptr::null();
13558                raw.featureCount = 0;
13559            }
13560            (raw, storage)
13561        }
13562        pub(crate) fn from_ffi(value: ffi::WGPUSupportedInstanceFeatures) -> Self {
13563            Self {
13564                features: if value.features.is_null() {
13565                    None
13566                } else {
13567                    Some(
13568                        unsafe {
13569                            std::slice::from_raw_parts(
13570                                value.features,
13571                                value.featureCount as usize,
13572                            )
13573                        }
13574                            .iter()
13575                            .map(|raw| InstanceFeatureName::from(*raw))
13576                            .collect(),
13577                    )
13578                },
13579                _free_members: Some(value),
13580            }
13581        }
13582        pub(crate) fn free_members(value: ffi::WGPUSupportedInstanceFeatures) {
13583            unsafe { ffi::wgpuSupportedInstanceFeaturesFreeMembers(value) };
13584        }
13585    }
13586    impl Drop for SupportedInstanceFeatures {
13587        fn drop(&mut self) {
13588            if let Some(value) = self._free_members.take() {
13589                unsafe { ffi::wgpuSupportedInstanceFeaturesFreeMembers(value) };
13590            }
13591        }
13592    }
13593    pub struct SurfaceCapabilities {
13594        pub(crate) extensions: Vec<SurfaceCapabilitiesExtension>,
13595        pub usages: Option<TextureUsage>,
13596        pub formats: Option<Vec<TextureFormat>>,
13597        pub present_modes: Option<Vec<PresentMode>>,
13598        pub alpha_modes: Option<Vec<CompositeAlphaMode>>,
13599        #[doc(hidden)]
13600        pub(crate) _free_members: Option<ffi::WGPUSurfaceCapabilities>,
13601    }
13602    impl Default for SurfaceCapabilities {
13603        fn default() -> Self {
13604            Self {
13605                extensions: Vec::new(),
13606                usages: None,
13607                formats: None,
13608                present_modes: None,
13609                alpha_modes: None,
13610                _free_members: None,
13611            }
13612        }
13613    }
13614    impl SurfaceCapabilities {
13615        pub fn new() -> Self {
13616            Self::default()
13617        }
13618        pub(crate) fn to_ffi(
13619            &self,
13620        ) -> (ffi::WGPUSurfaceCapabilities, ChainedStructStorage) {
13621            let mut storage = ChainedStructStorage::new();
13622            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13623            for ext in self.extensions.iter().rev() {
13624                next = ext.push_chain(&mut storage, next);
13625            }
13626            let mut raw: ffi::WGPUSurfaceCapabilities = unsafe { std::mem::zeroed() };
13627            raw.nextInChain = next;
13628            if let Some(value) = self.usages {
13629                raw.usages = value.into();
13630            } else {
13631                raw.usages = 0 as ffi::WGPUTextureUsage;
13632            }
13633            raw.formatCount = self.formats.as_ref().map(|v| v.len()).unwrap_or(0);
13634            if let Some(values) = &self.formats {
13635                let len_value = values.len();
13636                let raw_vec: Vec<ffi::WGPUTextureFormat> = values
13637                    .iter()
13638                    .map(|v| (*v).into())
13639                    .collect();
13640                let ptr = storage.push_vec(raw_vec);
13641                raw.formats = ptr;
13642                raw.formatCount = len_value;
13643            } else {
13644                raw.formats = std::ptr::null();
13645                raw.formatCount = 0;
13646            }
13647            raw.presentModeCount = self
13648                .present_modes
13649                .as_ref()
13650                .map(|v| v.len())
13651                .unwrap_or(0);
13652            if let Some(values) = &self.present_modes {
13653                let len_value = values.len();
13654                let raw_vec: Vec<ffi::WGPUPresentMode> = values
13655                    .iter()
13656                    .map(|v| (*v).into())
13657                    .collect();
13658                let ptr = storage.push_vec(raw_vec);
13659                raw.presentModes = ptr;
13660                raw.presentModeCount = len_value;
13661            } else {
13662                raw.presentModes = std::ptr::null();
13663                raw.presentModeCount = 0;
13664            }
13665            raw.alphaModeCount = self.alpha_modes.as_ref().map(|v| v.len()).unwrap_or(0);
13666            if let Some(values) = &self.alpha_modes {
13667                let len_value = values.len();
13668                let raw_vec: Vec<ffi::WGPUCompositeAlphaMode> = values
13669                    .iter()
13670                    .map(|v| (*v).into())
13671                    .collect();
13672                let ptr = storage.push_vec(raw_vec);
13673                raw.alphaModes = ptr;
13674                raw.alphaModeCount = len_value;
13675            } else {
13676                raw.alphaModes = std::ptr::null();
13677                raw.alphaModeCount = 0;
13678            }
13679            (raw, storage)
13680        }
13681        pub fn with_extension(
13682            mut self,
13683            extension: SurfaceCapabilitiesExtension,
13684        ) -> Self {
13685            self.extensions.push(extension);
13686            self
13687        }
13688        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceCapabilities) -> Self {
13689            Self {
13690                extensions: Vec::new(),
13691                usages: Some(value.usages.into()),
13692                formats: if value.formats.is_null() {
13693                    None
13694                } else {
13695                    Some(
13696                        unsafe {
13697                            std::slice::from_raw_parts(
13698                                value.formats,
13699                                value.formatCount as usize,
13700                            )
13701                        }
13702                            .iter()
13703                            .map(|raw| TextureFormat::from(*raw))
13704                            .collect(),
13705                    )
13706                },
13707                present_modes: if value.presentModes.is_null() {
13708                    None
13709                } else {
13710                    Some(
13711                        unsafe {
13712                            std::slice::from_raw_parts(
13713                                value.presentModes,
13714                                value.presentModeCount as usize,
13715                            )
13716                        }
13717                            .iter()
13718                            .map(|raw| PresentMode::from(*raw))
13719                            .collect(),
13720                    )
13721                },
13722                alpha_modes: if value.alphaModes.is_null() {
13723                    None
13724                } else {
13725                    Some(
13726                        unsafe {
13727                            std::slice::from_raw_parts(
13728                                value.alphaModes,
13729                                value.alphaModeCount as usize,
13730                            )
13731                        }
13732                            .iter()
13733                            .map(|raw| CompositeAlphaMode::from(*raw))
13734                            .collect(),
13735                    )
13736                },
13737                _free_members: Some(value),
13738            }
13739        }
13740        pub(crate) fn free_members(value: ffi::WGPUSurfaceCapabilities) {
13741            unsafe { ffi::wgpuSurfaceCapabilitiesFreeMembers(value) };
13742        }
13743    }
13744    impl Drop for SurfaceCapabilities {
13745        fn drop(&mut self) {
13746            if let Some(value) = self._free_members.take() {
13747                unsafe { ffi::wgpuSurfaceCapabilitiesFreeMembers(value) };
13748            }
13749        }
13750    }
13751    pub struct SurfaceColorManagement {
13752        pub color_space: Option<PredefinedColorSpace>,
13753        pub tone_mapping_mode: Option<ToneMappingMode>,
13754    }
13755    impl Default for SurfaceColorManagement {
13756        fn default() -> Self {
13757            Self {
13758                color_space: None,
13759                tone_mapping_mode: None,
13760            }
13761        }
13762    }
13763    impl SurfaceColorManagement {
13764        pub fn new() -> Self {
13765            Self::default()
13766        }
13767        pub(crate) fn to_ffi(
13768            &self,
13769        ) -> (ffi::WGPUSurfaceColorManagement, ChainedStructStorage) {
13770            let mut storage = ChainedStructStorage::new();
13771            let mut raw: ffi::WGPUSurfaceColorManagement = unsafe { std::mem::zeroed() };
13772            if let Some(value) = self.color_space {
13773                raw.colorSpace = value.into();
13774            } else {
13775                raw.colorSpace = 0 as ffi::WGPUPredefinedColorSpace;
13776            }
13777            if let Some(value) = self.tone_mapping_mode {
13778                raw.toneMappingMode = value.into();
13779            } else {
13780                raw.toneMappingMode = 0 as ffi::WGPUToneMappingMode;
13781            }
13782            (raw, storage)
13783        }
13784        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceColorManagement) -> Self {
13785            Self {
13786                color_space: Some(value.colorSpace.into()),
13787                tone_mapping_mode: Some(value.toneMappingMode.into()),
13788            }
13789        }
13790    }
13791    pub struct SurfaceConfiguration {
13792        pub(crate) extensions: Vec<SurfaceConfigurationExtension>,
13793        pub device: Option<Device>,
13794        pub format: Option<TextureFormat>,
13795        pub usage: Option<TextureUsage>,
13796        pub width: Option<u32>,
13797        pub height: Option<u32>,
13798        pub view_formats: Option<Vec<TextureFormat>>,
13799        pub alpha_mode: Option<CompositeAlphaMode>,
13800        pub present_mode: Option<PresentMode>,
13801    }
13802    impl Default for SurfaceConfiguration {
13803        fn default() -> Self {
13804            Self {
13805                extensions: Vec::new(),
13806                device: None,
13807                format: None,
13808                usage: Some(TextureUsage::RENDER_ATTACHMENT),
13809                width: None,
13810                height: None,
13811                view_formats: None,
13812                alpha_mode: Some(CompositeAlphaMode::Auto),
13813                present_mode: Some(PresentMode::Fifo),
13814            }
13815        }
13816    }
13817    impl SurfaceConfiguration {
13818        pub fn new() -> Self {
13819            Self::default()
13820        }
13821        pub(crate) fn to_ffi(
13822            &self,
13823        ) -> (ffi::WGPUSurfaceConfiguration, ChainedStructStorage) {
13824            let mut storage = ChainedStructStorage::new();
13825            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13826            for ext in self.extensions.iter().rev() {
13827                next = ext.push_chain(&mut storage, next);
13828            }
13829            let mut raw: ffi::WGPUSurfaceConfiguration = unsafe { std::mem::zeroed() };
13830            raw.nextInChain = next;
13831            raw.device = self
13832                .device
13833                .as_ref()
13834                .map(|v| v.as_raw())
13835                .unwrap_or(std::ptr::null_mut());
13836            if let Some(value) = self.format {
13837                raw.format = value.into();
13838            } else {
13839                raw.format = 0 as ffi::WGPUTextureFormat;
13840            }
13841            if let Some(value) = self.usage {
13842                raw.usage = value.into();
13843            } else {
13844                raw.usage = 0 as ffi::WGPUTextureUsage;
13845            }
13846            if let Some(value) = self.width {
13847                raw.width = value;
13848            }
13849            if let Some(value) = self.height {
13850                raw.height = value;
13851            }
13852            raw.viewFormatCount = self
13853                .view_formats
13854                .as_ref()
13855                .map(|v| v.len())
13856                .unwrap_or(0);
13857            if let Some(values) = &self.view_formats {
13858                let len_value = values.len();
13859                let raw_vec: Vec<ffi::WGPUTextureFormat> = values
13860                    .iter()
13861                    .map(|v| (*v).into())
13862                    .collect();
13863                let ptr = storage.push_vec(raw_vec);
13864                raw.viewFormats = ptr;
13865                raw.viewFormatCount = len_value;
13866            } else {
13867                raw.viewFormats = std::ptr::null();
13868                raw.viewFormatCount = 0;
13869            }
13870            if let Some(value) = self.alpha_mode {
13871                raw.alphaMode = value.into();
13872            } else {
13873                raw.alphaMode = 0 as ffi::WGPUCompositeAlphaMode;
13874            }
13875            if let Some(value) = self.present_mode {
13876                raw.presentMode = value.into();
13877            } else {
13878                raw.presentMode = 0 as ffi::WGPUPresentMode;
13879            }
13880            (raw, storage)
13881        }
13882        pub fn with_extension(
13883            mut self,
13884            extension: SurfaceConfigurationExtension,
13885        ) -> Self {
13886            self.extensions.push(extension);
13887            self
13888        }
13889        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceConfiguration) -> Self {
13890            Self {
13891                extensions: Vec::new(),
13892                device: Some(unsafe { Device::from_raw(value.device) }),
13893                format: Some(value.format.into()),
13894                usage: Some(value.usage.into()),
13895                width: Some(value.width),
13896                height: Some(value.height),
13897                view_formats: if value.viewFormats.is_null() {
13898                    None
13899                } else {
13900                    Some(
13901                        unsafe {
13902                            std::slice::from_raw_parts(
13903                                value.viewFormats,
13904                                value.viewFormatCount as usize,
13905                            )
13906                        }
13907                            .iter()
13908                            .map(|raw| TextureFormat::from(*raw))
13909                            .collect(),
13910                    )
13911                },
13912                alpha_mode: Some(value.alphaMode.into()),
13913                present_mode: Some(value.presentMode.into()),
13914            }
13915        }
13916    }
13917    pub struct SurfaceDescriptor {
13918        pub(crate) extensions: Vec<SurfaceDescriptorExtension>,
13919        pub label: Option<String>,
13920    }
13921    impl Default for SurfaceDescriptor {
13922        fn default() -> Self {
13923            Self {
13924                extensions: Vec::new(),
13925                label: None,
13926            }
13927        }
13928    }
13929    impl SurfaceDescriptor {
13930        pub fn new() -> Self {
13931            Self::default()
13932        }
13933        pub(crate) fn to_ffi(
13934            &self,
13935        ) -> (ffi::WGPUSurfaceDescriptor, ChainedStructStorage) {
13936            let mut storage = ChainedStructStorage::new();
13937            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13938            for ext in self.extensions.iter().rev() {
13939                next = ext.push_chain(&mut storage, next);
13940            }
13941            let mut raw: ffi::WGPUSurfaceDescriptor = unsafe { std::mem::zeroed() };
13942            raw.nextInChain = next;
13943            if let Some(value) = &self.label {
13944                raw.label = ffi::WGPUStringView {
13945                    data: value.as_ptr().cast(),
13946                    length: value.len(),
13947                };
13948            } else {
13949                raw.label = ffi::WGPUStringView {
13950                    data: std::ptr::null(),
13951                    length: 0,
13952                };
13953            }
13954            (raw, storage)
13955        }
13956        pub fn with_extension(mut self, extension: SurfaceDescriptorExtension) -> Self {
13957            self.extensions.push(extension);
13958            self
13959        }
13960        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceDescriptor) -> Self {
13961            Self {
13962                extensions: Vec::new(),
13963                label: if value.label.data.is_null() || value.label.length == 0 {
13964                    None
13965                } else {
13966                    Some(string_view_to_string(value.label))
13967                },
13968            }
13969        }
13970    }
13971    pub struct SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13972        pub swap_chain_panel: Option<*mut std::ffi::c_void>,
13973    }
13974    impl Default for SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13975        fn default() -> Self {
13976            Self { swap_chain_panel: None }
13977        }
13978    }
13979    impl SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13980        pub fn new() -> Self {
13981            Self::default()
13982        }
13983        pub(crate) fn to_ffi(
13984            &self,
13985        ) -> (
13986            ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel,
13987            ChainedStructStorage,
13988        ) {
13989            let mut storage = ChainedStructStorage::new();
13990            let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel = unsafe {
13991                std::mem::zeroed()
13992            };
13993            if let Some(value) = self.swap_chain_panel {
13994                raw.swapChainPanel = value;
13995            }
13996            (raw, storage)
13997        }
13998        pub(crate) fn from_ffi(
13999            value: ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel,
14000        ) -> Self {
14001            Self {
14002                swap_chain_panel: Some(value.swapChainPanel),
14003            }
14004        }
14005    }
14006    pub struct SurfaceDescriptorFromWindowsWinUISwapChainPanel {
14007        pub swap_chain_panel: Option<*mut std::ffi::c_void>,
14008    }
14009    impl Default for SurfaceDescriptorFromWindowsWinUISwapChainPanel {
14010        fn default() -> Self {
14011            Self { swap_chain_panel: None }
14012        }
14013    }
14014    impl SurfaceDescriptorFromWindowsWinUISwapChainPanel {
14015        pub fn new() -> Self {
14016            Self::default()
14017        }
14018        pub(crate) fn to_ffi(
14019            &self,
14020        ) -> (
14021            ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel,
14022            ChainedStructStorage,
14023        ) {
14024            let mut storage = ChainedStructStorage::new();
14025            let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel = unsafe {
14026                std::mem::zeroed()
14027            };
14028            if let Some(value) = self.swap_chain_panel {
14029                raw.swapChainPanel = value;
14030            }
14031            (raw, storage)
14032        }
14033        pub(crate) fn from_ffi(
14034            value: ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel,
14035        ) -> Self {
14036            Self {
14037                swap_chain_panel: Some(value.swapChainPanel),
14038            }
14039        }
14040    }
14041    pub struct SurfaceDescriptorFromWindowsCoreWindow {
14042        pub core_window: Option<*mut std::ffi::c_void>,
14043    }
14044    impl Default for SurfaceDescriptorFromWindowsCoreWindow {
14045        fn default() -> Self {
14046            Self { core_window: None }
14047        }
14048    }
14049    impl SurfaceDescriptorFromWindowsCoreWindow {
14050        pub fn new() -> Self {
14051            Self::default()
14052        }
14053        pub(crate) fn to_ffi(
14054            &self,
14055        ) -> (ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow, ChainedStructStorage) {
14056            let mut storage = ChainedStructStorage::new();
14057            let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow = unsafe {
14058                std::mem::zeroed()
14059            };
14060            if let Some(value) = self.core_window {
14061                raw.coreWindow = value;
14062            }
14063            (raw, storage)
14064        }
14065        pub(crate) fn from_ffi(
14066            value: ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow,
14067        ) -> Self {
14068            Self {
14069                core_window: Some(value.coreWindow),
14070            }
14071        }
14072    }
14073    pub struct SurfaceSourceXCBWindow {
14074        pub connection: Option<*mut std::ffi::c_void>,
14075        pub window: Option<u32>,
14076    }
14077    impl Default for SurfaceSourceXCBWindow {
14078        fn default() -> Self {
14079            Self {
14080                connection: None,
14081                window: None,
14082            }
14083        }
14084    }
14085    impl SurfaceSourceXCBWindow {
14086        pub fn new() -> Self {
14087            Self::default()
14088        }
14089        pub(crate) fn to_ffi(
14090            &self,
14091        ) -> (ffi::WGPUSurfaceSourceXCBWindow, ChainedStructStorage) {
14092            let mut storage = ChainedStructStorage::new();
14093            let mut raw: ffi::WGPUSurfaceSourceXCBWindow = unsafe { std::mem::zeroed() };
14094            if let Some(value) = self.connection {
14095                raw.connection = value;
14096            }
14097            if let Some(value) = self.window {
14098                raw.window = value;
14099            }
14100            (raw, storage)
14101        }
14102        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceXCBWindow) -> Self {
14103            Self {
14104                connection: Some(value.connection),
14105                window: Some(value.window),
14106            }
14107        }
14108    }
14109    pub struct SurfaceSourceAndroidNativeWindow {
14110        pub window: Option<*mut std::ffi::c_void>,
14111    }
14112    impl Default for SurfaceSourceAndroidNativeWindow {
14113        fn default() -> Self {
14114            Self { window: None }
14115        }
14116    }
14117    impl SurfaceSourceAndroidNativeWindow {
14118        pub fn new() -> Self {
14119            Self::default()
14120        }
14121        pub(crate) fn to_ffi(
14122            &self,
14123        ) -> (ffi::WGPUSurfaceSourceAndroidNativeWindow, ChainedStructStorage) {
14124            let mut storage = ChainedStructStorage::new();
14125            let mut raw: ffi::WGPUSurfaceSourceAndroidNativeWindow = unsafe {
14126                std::mem::zeroed()
14127            };
14128            if let Some(value) = self.window {
14129                raw.window = value;
14130            }
14131            (raw, storage)
14132        }
14133        pub(crate) fn from_ffi(
14134            value: ffi::WGPUSurfaceSourceAndroidNativeWindow,
14135        ) -> Self {
14136            Self { window: Some(value.window) }
14137        }
14138    }
14139    pub struct SurfaceSourceMetalLayer {
14140        pub layer: Option<*mut std::ffi::c_void>,
14141    }
14142    impl Default for SurfaceSourceMetalLayer {
14143        fn default() -> Self {
14144            Self { layer: None }
14145        }
14146    }
14147    impl SurfaceSourceMetalLayer {
14148        pub fn new() -> Self {
14149            Self::default()
14150        }
14151        pub(crate) fn to_ffi(
14152            &self,
14153        ) -> (ffi::WGPUSurfaceSourceMetalLayer, ChainedStructStorage) {
14154            let mut storage = ChainedStructStorage::new();
14155            let mut raw: ffi::WGPUSurfaceSourceMetalLayer = unsafe {
14156                std::mem::zeroed()
14157            };
14158            if let Some(value) = self.layer {
14159                raw.layer = value;
14160            }
14161            (raw, storage)
14162        }
14163        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceMetalLayer) -> Self {
14164            Self { layer: Some(value.layer) }
14165        }
14166    }
14167    pub struct SurfaceSourceWaylandSurface {
14168        pub display: Option<*mut std::ffi::c_void>,
14169        pub surface: Option<*mut std::ffi::c_void>,
14170    }
14171    impl Default for SurfaceSourceWaylandSurface {
14172        fn default() -> Self {
14173            Self {
14174                display: None,
14175                surface: None,
14176            }
14177        }
14178    }
14179    impl SurfaceSourceWaylandSurface {
14180        pub fn new() -> Self {
14181            Self::default()
14182        }
14183        pub(crate) fn to_ffi(
14184            &self,
14185        ) -> (ffi::WGPUSurfaceSourceWaylandSurface, ChainedStructStorage) {
14186            let mut storage = ChainedStructStorage::new();
14187            let mut raw: ffi::WGPUSurfaceSourceWaylandSurface = unsafe {
14188                std::mem::zeroed()
14189            };
14190            if let Some(value) = self.display {
14191                raw.display = value;
14192            }
14193            if let Some(value) = self.surface {
14194                raw.surface = value;
14195            }
14196            (raw, storage)
14197        }
14198        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceWaylandSurface) -> Self {
14199            Self {
14200                display: Some(value.display),
14201                surface: Some(value.surface),
14202            }
14203        }
14204    }
14205    pub struct SurfaceSourceWindowsHWND {
14206        pub hinstance: Option<*mut std::ffi::c_void>,
14207        pub hwnd: Option<*mut std::ffi::c_void>,
14208    }
14209    impl Default for SurfaceSourceWindowsHWND {
14210        fn default() -> Self {
14211            Self {
14212                hinstance: None,
14213                hwnd: None,
14214            }
14215        }
14216    }
14217    impl SurfaceSourceWindowsHWND {
14218        pub fn new() -> Self {
14219            Self::default()
14220        }
14221        pub(crate) fn to_ffi(
14222            &self,
14223        ) -> (ffi::WGPUSurfaceSourceWindowsHWND, ChainedStructStorage) {
14224            let mut storage = ChainedStructStorage::new();
14225            let mut raw: ffi::WGPUSurfaceSourceWindowsHWND = unsafe {
14226                std::mem::zeroed()
14227            };
14228            if let Some(value) = self.hinstance {
14229                raw.hinstance = value;
14230            }
14231            if let Some(value) = self.hwnd {
14232                raw.hwnd = value;
14233            }
14234            (raw, storage)
14235        }
14236        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceWindowsHWND) -> Self {
14237            Self {
14238                hinstance: Some(value.hinstance),
14239                hwnd: Some(value.hwnd),
14240            }
14241        }
14242    }
14243    pub struct SurfaceSourceXlibWindow {
14244        pub display: Option<*mut std::ffi::c_void>,
14245        pub window: Option<u64>,
14246    }
14247    impl Default for SurfaceSourceXlibWindow {
14248        fn default() -> Self {
14249            Self {
14250                display: None,
14251                window: None,
14252            }
14253        }
14254    }
14255    impl SurfaceSourceXlibWindow {
14256        pub fn new() -> Self {
14257            Self::default()
14258        }
14259        pub(crate) fn to_ffi(
14260            &self,
14261        ) -> (ffi::WGPUSurfaceSourceXlibWindow, ChainedStructStorage) {
14262            let mut storage = ChainedStructStorage::new();
14263            let mut raw: ffi::WGPUSurfaceSourceXlibWindow = unsafe {
14264                std::mem::zeroed()
14265            };
14266            if let Some(value) = self.display {
14267                raw.display = value;
14268            }
14269            if let Some(value) = self.window {
14270                raw.window = value;
14271            }
14272            (raw, storage)
14273        }
14274        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceXlibWindow) -> Self {
14275            Self {
14276                display: Some(value.display),
14277                window: Some(value.window),
14278            }
14279        }
14280    }
14281    pub struct SurfaceTexture {
14282        pub(crate) extensions: Vec<SurfaceTextureExtension>,
14283        pub texture: Option<Texture>,
14284        pub status: Option<SurfaceGetCurrentTextureStatus>,
14285    }
14286    impl Default for SurfaceTexture {
14287        fn default() -> Self {
14288            Self {
14289                extensions: Vec::new(),
14290                texture: None,
14291                status: None,
14292            }
14293        }
14294    }
14295    impl SurfaceTexture {
14296        pub fn new() -> Self {
14297            Self::default()
14298        }
14299        pub(crate) fn to_ffi(&self) -> (ffi::WGPUSurfaceTexture, ChainedStructStorage) {
14300            let mut storage = ChainedStructStorage::new();
14301            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14302            for ext in self.extensions.iter().rev() {
14303                next = ext.push_chain(&mut storage, next);
14304            }
14305            let mut raw: ffi::WGPUSurfaceTexture = unsafe { std::mem::zeroed() };
14306            raw.nextInChain = next;
14307            raw.texture = self
14308                .texture
14309                .as_ref()
14310                .map(|v| v.as_raw())
14311                .unwrap_or(std::ptr::null_mut());
14312            if let Some(value) = self.status {
14313                raw.status = value.into();
14314            } else {
14315                raw.status = 0 as ffi::WGPUSurfaceGetCurrentTextureStatus;
14316            }
14317            (raw, storage)
14318        }
14319        pub fn with_extension(mut self, extension: SurfaceTextureExtension) -> Self {
14320            self.extensions.push(extension);
14321            self
14322        }
14323        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceTexture) -> Self {
14324            Self {
14325                extensions: Vec::new(),
14326                texture: Some(unsafe { Texture::from_raw(value.texture) }),
14327                status: Some(value.status.into()),
14328            }
14329        }
14330    }
14331    pub struct TexelBufferBindingEntry {
14332        pub texel_buffer_view: Option<TexelBufferView>,
14333    }
14334    impl Default for TexelBufferBindingEntry {
14335        fn default() -> Self {
14336            Self { texel_buffer_view: None }
14337        }
14338    }
14339    impl TexelBufferBindingEntry {
14340        pub fn new() -> Self {
14341            Self::default()
14342        }
14343        pub(crate) fn to_ffi(
14344            &self,
14345        ) -> (ffi::WGPUTexelBufferBindingEntry, ChainedStructStorage) {
14346            let mut storage = ChainedStructStorage::new();
14347            let mut raw: ffi::WGPUTexelBufferBindingEntry = unsafe {
14348                std::mem::zeroed()
14349            };
14350            raw.texelBufferView = self
14351                .texel_buffer_view
14352                .as_ref()
14353                .map(|v| v.as_raw())
14354                .unwrap_or(std::ptr::null_mut());
14355            (raw, storage)
14356        }
14357        pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferBindingEntry) -> Self {
14358            Self {
14359                texel_buffer_view: Some(unsafe {
14360                    TexelBufferView::from_raw(value.texelBufferView)
14361                }),
14362            }
14363        }
14364    }
14365    pub struct TexelBufferBindingLayout {
14366        pub access: Option<TexelBufferAccess>,
14367        pub format: Option<TextureFormat>,
14368    }
14369    impl Default for TexelBufferBindingLayout {
14370        fn default() -> Self {
14371            Self {
14372                access: Some(TexelBufferAccess::ReadWrite),
14373                format: None,
14374            }
14375        }
14376    }
14377    impl TexelBufferBindingLayout {
14378        pub fn new() -> Self {
14379            Self::default()
14380        }
14381        pub(crate) fn to_ffi(
14382            &self,
14383        ) -> (ffi::WGPUTexelBufferBindingLayout, ChainedStructStorage) {
14384            let mut storage = ChainedStructStorage::new();
14385            let mut raw: ffi::WGPUTexelBufferBindingLayout = unsafe {
14386                std::mem::zeroed()
14387            };
14388            if let Some(value) = self.access {
14389                raw.access = value.into();
14390            } else {
14391                raw.access = 0 as ffi::WGPUTexelBufferAccess;
14392            }
14393            if let Some(value) = self.format {
14394                raw.format = value.into();
14395            } else {
14396                raw.format = 0 as ffi::WGPUTextureFormat;
14397            }
14398            (raw, storage)
14399        }
14400        pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferBindingLayout) -> Self {
14401            Self {
14402                access: Some(value.access.into()),
14403                format: Some(value.format.into()),
14404            }
14405        }
14406    }
14407    pub struct TexelBufferViewDescriptor {
14408        pub(crate) extensions: Vec<TexelBufferViewDescriptorExtension>,
14409        pub label: Option<String>,
14410        pub format: Option<TextureFormat>,
14411        pub offset: Option<u64>,
14412        pub size: Option<u64>,
14413    }
14414    impl Default for TexelBufferViewDescriptor {
14415        fn default() -> Self {
14416            Self {
14417                extensions: Vec::new(),
14418                label: None,
14419                format: None,
14420                offset: Some(0),
14421                size: Some(WHOLE_SIZE),
14422            }
14423        }
14424    }
14425    impl TexelBufferViewDescriptor {
14426        pub fn new() -> Self {
14427            Self::default()
14428        }
14429        pub(crate) fn to_ffi(
14430            &self,
14431        ) -> (ffi::WGPUTexelBufferViewDescriptor, ChainedStructStorage) {
14432            let mut storage = ChainedStructStorage::new();
14433            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14434            for ext in self.extensions.iter().rev() {
14435                next = ext.push_chain(&mut storage, next);
14436            }
14437            let mut raw: ffi::WGPUTexelBufferViewDescriptor = unsafe {
14438                std::mem::zeroed()
14439            };
14440            raw.nextInChain = next;
14441            if let Some(value) = &self.label {
14442                raw.label = ffi::WGPUStringView {
14443                    data: value.as_ptr().cast(),
14444                    length: value.len(),
14445                };
14446            } else {
14447                raw.label = ffi::WGPUStringView {
14448                    data: std::ptr::null(),
14449                    length: 0,
14450                };
14451            }
14452            if let Some(value) = self.format {
14453                raw.format = value.into();
14454            } else {
14455                raw.format = 0 as ffi::WGPUTextureFormat;
14456            }
14457            if let Some(value) = self.offset {
14458                raw.offset = value;
14459            }
14460            if let Some(value) = self.size {
14461                raw.size = value;
14462            }
14463            (raw, storage)
14464        }
14465        pub fn with_extension(
14466            mut self,
14467            extension: TexelBufferViewDescriptorExtension,
14468        ) -> Self {
14469            self.extensions.push(extension);
14470            self
14471        }
14472        pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferViewDescriptor) -> Self {
14473            Self {
14474                extensions: Vec::new(),
14475                label: if value.label.data.is_null() || value.label.length == 0 {
14476                    None
14477                } else {
14478                    Some(string_view_to_string(value.label))
14479                },
14480                format: Some(value.format.into()),
14481                offset: Some(value.offset),
14482                size: Some(value.size),
14483            }
14484        }
14485    }
14486    pub struct TexelCopyBufferInfo {
14487        pub layout: Option<TexelCopyBufferLayout>,
14488        pub buffer: Option<Buffer>,
14489    }
14490    impl Default for TexelCopyBufferInfo {
14491        fn default() -> Self {
14492            Self { layout: None, buffer: None }
14493        }
14494    }
14495    impl TexelCopyBufferInfo {
14496        pub fn new() -> Self {
14497            Self::default()
14498        }
14499        pub(crate) fn to_ffi(
14500            &self,
14501        ) -> (ffi::WGPUTexelCopyBufferInfo, ChainedStructStorage) {
14502            let mut storage = ChainedStructStorage::new();
14503            let mut raw: ffi::WGPUTexelCopyBufferInfo = unsafe { std::mem::zeroed() };
14504            if let Some(value) = &self.layout {
14505                let (raw_value, storage_value) = value.to_ffi();
14506                raw.layout = raw_value;
14507                storage.push_storage(storage_value);
14508            }
14509            raw.buffer = self
14510                .buffer
14511                .as_ref()
14512                .map(|v| v.as_raw())
14513                .unwrap_or(std::ptr::null_mut());
14514            (raw, storage)
14515        }
14516        pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyBufferInfo) -> Self {
14517            Self {
14518                layout: Some(TexelCopyBufferLayout::from_ffi(value.layout)),
14519                buffer: Some(unsafe { Buffer::from_raw(value.buffer) }),
14520            }
14521        }
14522    }
14523    pub struct TexelCopyBufferLayout {
14524        pub offset: Option<u64>,
14525        pub bytes_per_row: Option<u32>,
14526        pub rows_per_image: Option<u32>,
14527    }
14528    impl Default for TexelCopyBufferLayout {
14529        fn default() -> Self {
14530            Self {
14531                offset: Some(0),
14532                bytes_per_row: Some(COPY_STRIDE_UNDEFINED),
14533                rows_per_image: Some(COPY_STRIDE_UNDEFINED),
14534            }
14535        }
14536    }
14537    impl TexelCopyBufferLayout {
14538        pub fn new() -> Self {
14539            Self::default()
14540        }
14541        pub(crate) fn to_ffi(
14542            &self,
14543        ) -> (ffi::WGPUTexelCopyBufferLayout, ChainedStructStorage) {
14544            let mut storage = ChainedStructStorage::new();
14545            let mut raw: ffi::WGPUTexelCopyBufferLayout = unsafe { std::mem::zeroed() };
14546            if let Some(value) = self.offset {
14547                raw.offset = value;
14548            }
14549            if let Some(value) = self.bytes_per_row {
14550                raw.bytesPerRow = value;
14551            }
14552            if let Some(value) = self.rows_per_image {
14553                raw.rowsPerImage = value;
14554            }
14555            (raw, storage)
14556        }
14557        pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyBufferLayout) -> Self {
14558            Self {
14559                offset: Some(value.offset),
14560                bytes_per_row: Some(value.bytesPerRow),
14561                rows_per_image: Some(value.rowsPerImage),
14562            }
14563        }
14564    }
14565    pub struct TexelCopyTextureInfo {
14566        pub texture: Option<Texture>,
14567        pub mip_level: Option<u32>,
14568        pub origin: Option<Origin3D>,
14569        pub aspect: Option<TextureAspect>,
14570    }
14571    impl Default for TexelCopyTextureInfo {
14572        fn default() -> Self {
14573            Self {
14574                texture: None,
14575                mip_level: Some(0),
14576                origin: None,
14577                aspect: Some(TextureAspect::All),
14578            }
14579        }
14580    }
14581    impl TexelCopyTextureInfo {
14582        pub fn new() -> Self {
14583            Self::default()
14584        }
14585        pub(crate) fn to_ffi(
14586            &self,
14587        ) -> (ffi::WGPUTexelCopyTextureInfo, ChainedStructStorage) {
14588            let mut storage = ChainedStructStorage::new();
14589            let mut raw: ffi::WGPUTexelCopyTextureInfo = unsafe { std::mem::zeroed() };
14590            raw.texture = self
14591                .texture
14592                .as_ref()
14593                .map(|v| v.as_raw())
14594                .unwrap_or(std::ptr::null_mut());
14595            if let Some(value) = self.mip_level {
14596                raw.mipLevel = value;
14597            }
14598            if let Some(value) = &self.origin {
14599                let (raw_value, storage_value) = value.to_ffi();
14600                raw.origin = raw_value;
14601                storage.push_storage(storage_value);
14602            }
14603            if let Some(value) = self.aspect {
14604                raw.aspect = value.into();
14605            } else {
14606                raw.aspect = 0 as ffi::WGPUTextureAspect;
14607            }
14608            (raw, storage)
14609        }
14610        pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyTextureInfo) -> Self {
14611            Self {
14612                texture: Some(unsafe { Texture::from_raw(value.texture) }),
14613                mip_level: Some(value.mipLevel),
14614                origin: Some(Origin3D::from_ffi(value.origin)),
14615                aspect: Some(value.aspect.into()),
14616            }
14617        }
14618    }
14619    pub struct TextureBindingLayout {
14620        pub(crate) extensions: Vec<TextureBindingLayoutExtension>,
14621        pub sample_type: Option<TextureSampleType>,
14622        pub view_dimension: Option<TextureViewDimension>,
14623        pub multisampled: Option<bool>,
14624    }
14625    impl Default for TextureBindingLayout {
14626        fn default() -> Self {
14627            Self {
14628                extensions: Vec::new(),
14629                sample_type: Some(TextureSampleType::Float),
14630                view_dimension: Some(TextureViewDimension::D2),
14631                multisampled: None,
14632            }
14633        }
14634    }
14635    impl TextureBindingLayout {
14636        pub fn new() -> Self {
14637            Self::default()
14638        }
14639        pub(crate) fn to_ffi(
14640            &self,
14641        ) -> (ffi::WGPUTextureBindingLayout, ChainedStructStorage) {
14642            let mut storage = ChainedStructStorage::new();
14643            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14644            for ext in self.extensions.iter().rev() {
14645                next = ext.push_chain(&mut storage, next);
14646            }
14647            let mut raw: ffi::WGPUTextureBindingLayout = unsafe { std::mem::zeroed() };
14648            raw.nextInChain = next;
14649            if let Some(value) = self.sample_type {
14650                raw.sampleType = value.into();
14651            } else {
14652                raw.sampleType = 0 as ffi::WGPUTextureSampleType;
14653            }
14654            if let Some(value) = self.view_dimension {
14655                raw.viewDimension = value.into();
14656            } else {
14657                raw.viewDimension = 0 as ffi::WGPUTextureViewDimension;
14658            }
14659            raw.multisampled = if self.multisampled.unwrap_or(false) { 1 } else { 0 };
14660            (raw, storage)
14661        }
14662        pub fn with_extension(
14663            mut self,
14664            extension: TextureBindingLayoutExtension,
14665        ) -> Self {
14666            self.extensions.push(extension);
14667            self
14668        }
14669        pub(crate) fn from_ffi(value: ffi::WGPUTextureBindingLayout) -> Self {
14670            Self {
14671                extensions: Vec::new(),
14672                sample_type: Some(value.sampleType.into()),
14673                view_dimension: Some(value.viewDimension.into()),
14674                multisampled: Some(value.multisampled != 0),
14675            }
14676        }
14677    }
14678    pub struct TextureComponentSwizzle {
14679        pub r: Option<ComponentSwizzle>,
14680        pub g: Option<ComponentSwizzle>,
14681        pub b: Option<ComponentSwizzle>,
14682        pub a: Option<ComponentSwizzle>,
14683    }
14684    impl Default for TextureComponentSwizzle {
14685        fn default() -> Self {
14686            Self {
14687                r: Some(ComponentSwizzle::R),
14688                g: Some(ComponentSwizzle::G),
14689                b: Some(ComponentSwizzle::B),
14690                a: Some(ComponentSwizzle::A),
14691            }
14692        }
14693    }
14694    impl TextureComponentSwizzle {
14695        pub fn new() -> Self {
14696            Self::default()
14697        }
14698        pub(crate) fn to_ffi(
14699            &self,
14700        ) -> (ffi::WGPUTextureComponentSwizzle, ChainedStructStorage) {
14701            let mut storage = ChainedStructStorage::new();
14702            let mut raw: ffi::WGPUTextureComponentSwizzle = unsafe {
14703                std::mem::zeroed()
14704            };
14705            if let Some(value) = self.r {
14706                raw.r = value.into();
14707            } else {
14708                raw.r = 0 as ffi::WGPUComponentSwizzle;
14709            }
14710            if let Some(value) = self.g {
14711                raw.g = value.into();
14712            } else {
14713                raw.g = 0 as ffi::WGPUComponentSwizzle;
14714            }
14715            if let Some(value) = self.b {
14716                raw.b = value.into();
14717            } else {
14718                raw.b = 0 as ffi::WGPUComponentSwizzle;
14719            }
14720            if let Some(value) = self.a {
14721                raw.a = value.into();
14722            } else {
14723                raw.a = 0 as ffi::WGPUComponentSwizzle;
14724            }
14725            (raw, storage)
14726        }
14727        pub(crate) fn from_ffi(value: ffi::WGPUTextureComponentSwizzle) -> Self {
14728            Self {
14729                r: Some(value.r.into()),
14730                g: Some(value.g.into()),
14731                b: Some(value.b.into()),
14732                a: Some(value.a.into()),
14733            }
14734        }
14735    }
14736    pub struct TextureComponentSwizzleDescriptor {
14737        pub swizzle: Option<TextureComponentSwizzle>,
14738    }
14739    impl Default for TextureComponentSwizzleDescriptor {
14740        fn default() -> Self {
14741            Self { swizzle: None }
14742        }
14743    }
14744    impl TextureComponentSwizzleDescriptor {
14745        pub fn new() -> Self {
14746            Self::default()
14747        }
14748        pub(crate) fn to_ffi(
14749            &self,
14750        ) -> (ffi::WGPUTextureComponentSwizzleDescriptor, ChainedStructStorage) {
14751            let mut storage = ChainedStructStorage::new();
14752            let mut raw: ffi::WGPUTextureComponentSwizzleDescriptor = unsafe {
14753                std::mem::zeroed()
14754            };
14755            if let Some(value) = &self.swizzle {
14756                let (raw_value, storage_value) = value.to_ffi();
14757                raw.swizzle = raw_value;
14758                storage.push_storage(storage_value);
14759            }
14760            (raw, storage)
14761        }
14762        pub(crate) fn from_ffi(
14763            value: ffi::WGPUTextureComponentSwizzleDescriptor,
14764        ) -> Self {
14765            Self {
14766                swizzle: Some(TextureComponentSwizzle::from_ffi(value.swizzle)),
14767            }
14768        }
14769    }
14770    pub struct TextureDescriptor {
14771        pub(crate) extensions: Vec<TextureDescriptorExtension>,
14772        pub label: Option<String>,
14773        pub usage: Option<TextureUsage>,
14774        pub dimension: Option<TextureDimension>,
14775        pub size: Option<Extent3D>,
14776        pub format: Option<TextureFormat>,
14777        pub mip_level_count: Option<u32>,
14778        pub sample_count: Option<u32>,
14779        pub view_formats: Option<Vec<TextureFormat>>,
14780    }
14781    impl Default for TextureDescriptor {
14782        fn default() -> Self {
14783            Self {
14784                extensions: Vec::new(),
14785                label: None,
14786                usage: None,
14787                dimension: Some(TextureDimension::D2),
14788                size: None,
14789                format: None,
14790                mip_level_count: Some(1),
14791                sample_count: Some(1),
14792                view_formats: None,
14793            }
14794        }
14795    }
14796    impl TextureDescriptor {
14797        pub fn new() -> Self {
14798            Self::default()
14799        }
14800        pub(crate) fn to_ffi(
14801            &self,
14802        ) -> (ffi::WGPUTextureDescriptor, ChainedStructStorage) {
14803            let mut storage = ChainedStructStorage::new();
14804            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14805            for ext in self.extensions.iter().rev() {
14806                next = ext.push_chain(&mut storage, next);
14807            }
14808            let mut raw: ffi::WGPUTextureDescriptor = unsafe { std::mem::zeroed() };
14809            raw.nextInChain = next;
14810            if let Some(value) = &self.label {
14811                raw.label = ffi::WGPUStringView {
14812                    data: value.as_ptr().cast(),
14813                    length: value.len(),
14814                };
14815            } else {
14816                raw.label = ffi::WGPUStringView {
14817                    data: std::ptr::null(),
14818                    length: 0,
14819                };
14820            }
14821            if let Some(value) = self.usage {
14822                raw.usage = value.into();
14823            } else {
14824                raw.usage = 0 as ffi::WGPUTextureUsage;
14825            }
14826            if let Some(value) = self.dimension {
14827                raw.dimension = value.into();
14828            } else {
14829                raw.dimension = 0 as ffi::WGPUTextureDimension;
14830            }
14831            if let Some(value) = &self.size {
14832                let (raw_value, storage_value) = value.to_ffi();
14833                raw.size = raw_value;
14834                storage.push_storage(storage_value);
14835            }
14836            if let Some(value) = self.format {
14837                raw.format = value.into();
14838            } else {
14839                raw.format = 0 as ffi::WGPUTextureFormat;
14840            }
14841            if let Some(value) = self.mip_level_count {
14842                raw.mipLevelCount = value;
14843            }
14844            if let Some(value) = self.sample_count {
14845                raw.sampleCount = value;
14846            }
14847            raw.viewFormatCount = self
14848                .view_formats
14849                .as_ref()
14850                .map(|v| v.len())
14851                .unwrap_or(0);
14852            if let Some(values) = &self.view_formats {
14853                let len_value = values.len();
14854                let raw_vec: Vec<ffi::WGPUTextureFormat> = values
14855                    .iter()
14856                    .map(|v| (*v).into())
14857                    .collect();
14858                let ptr = storage.push_vec(raw_vec);
14859                raw.viewFormats = ptr;
14860                raw.viewFormatCount = len_value;
14861            } else {
14862                raw.viewFormats = std::ptr::null();
14863                raw.viewFormatCount = 0;
14864            }
14865            (raw, storage)
14866        }
14867        pub fn with_extension(mut self, extension: TextureDescriptorExtension) -> Self {
14868            self.extensions.push(extension);
14869            self
14870        }
14871        pub(crate) fn from_ffi(value: ffi::WGPUTextureDescriptor) -> Self {
14872            Self {
14873                extensions: Vec::new(),
14874                label: if value.label.data.is_null() || value.label.length == 0 {
14875                    None
14876                } else {
14877                    Some(string_view_to_string(value.label))
14878                },
14879                usage: Some(value.usage.into()),
14880                dimension: Some(value.dimension.into()),
14881                size: Some(Extent3D::from_ffi(value.size)),
14882                format: Some(value.format.into()),
14883                mip_level_count: Some(value.mipLevelCount),
14884                sample_count: Some(value.sampleCount),
14885                view_formats: if value.viewFormats.is_null() {
14886                    None
14887                } else {
14888                    Some(
14889                        unsafe {
14890                            std::slice::from_raw_parts(
14891                                value.viewFormats,
14892                                value.viewFormatCount as usize,
14893                            )
14894                        }
14895                            .iter()
14896                            .map(|raw| TextureFormat::from(*raw))
14897                            .collect(),
14898                    )
14899                },
14900            }
14901        }
14902    }
14903    pub struct TextureViewDescriptor {
14904        pub(crate) extensions: Vec<TextureViewDescriptorExtension>,
14905        pub label: Option<String>,
14906        pub format: Option<TextureFormat>,
14907        pub dimension: Option<TextureViewDimension>,
14908        pub base_mip_level: Option<u32>,
14909        pub mip_level_count: Option<u32>,
14910        pub base_array_layer: Option<u32>,
14911        pub array_layer_count: Option<u32>,
14912        pub aspect: Option<TextureAspect>,
14913        pub usage: Option<TextureUsage>,
14914    }
14915    impl Default for TextureViewDescriptor {
14916        fn default() -> Self {
14917            Self {
14918                extensions: Vec::new(),
14919                label: None,
14920                format: None,
14921                dimension: None,
14922                base_mip_level: Some(0),
14923                mip_level_count: Some(MIP_LEVEL_COUNT_UNDEFINED),
14924                base_array_layer: Some(0),
14925                array_layer_count: Some(ARRAY_LAYER_COUNT_UNDEFINED),
14926                aspect: Some(TextureAspect::All),
14927                usage: Some(TextureUsage::NONE),
14928            }
14929        }
14930    }
14931    impl TextureViewDescriptor {
14932        pub fn new() -> Self {
14933            Self::default()
14934        }
14935        pub(crate) fn to_ffi(
14936            &self,
14937        ) -> (ffi::WGPUTextureViewDescriptor, ChainedStructStorage) {
14938            let mut storage = ChainedStructStorage::new();
14939            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14940            for ext in self.extensions.iter().rev() {
14941                next = ext.push_chain(&mut storage, next);
14942            }
14943            let mut raw: ffi::WGPUTextureViewDescriptor = unsafe { std::mem::zeroed() };
14944            raw.nextInChain = next;
14945            if let Some(value) = &self.label {
14946                raw.label = ffi::WGPUStringView {
14947                    data: value.as_ptr().cast(),
14948                    length: value.len(),
14949                };
14950            } else {
14951                raw.label = ffi::WGPUStringView {
14952                    data: std::ptr::null(),
14953                    length: 0,
14954                };
14955            }
14956            if let Some(value) = self.format {
14957                raw.format = value.into();
14958            } else {
14959                raw.format = 0 as ffi::WGPUTextureFormat;
14960            }
14961            if let Some(value) = self.dimension {
14962                raw.dimension = value.into();
14963            } else {
14964                raw.dimension = 0 as ffi::WGPUTextureViewDimension;
14965            }
14966            if let Some(value) = self.base_mip_level {
14967                raw.baseMipLevel = value;
14968            }
14969            if let Some(value) = self.mip_level_count {
14970                raw.mipLevelCount = value;
14971            }
14972            if let Some(value) = self.base_array_layer {
14973                raw.baseArrayLayer = value;
14974            }
14975            if let Some(value) = self.array_layer_count {
14976                raw.arrayLayerCount = value;
14977            }
14978            if let Some(value) = self.aspect {
14979                raw.aspect = value.into();
14980            } else {
14981                raw.aspect = 0 as ffi::WGPUTextureAspect;
14982            }
14983            if let Some(value) = self.usage {
14984                raw.usage = value.into();
14985            } else {
14986                raw.usage = 0 as ffi::WGPUTextureUsage;
14987            }
14988            (raw, storage)
14989        }
14990        pub fn with_extension(
14991            mut self,
14992            extension: TextureViewDescriptorExtension,
14993        ) -> Self {
14994            self.extensions.push(extension);
14995            self
14996        }
14997        pub(crate) fn from_ffi(value: ffi::WGPUTextureViewDescriptor) -> Self {
14998            Self {
14999                extensions: Vec::new(),
15000                label: if value.label.data.is_null() || value.label.length == 0 {
15001                    None
15002                } else {
15003                    Some(string_view_to_string(value.label))
15004                },
15005                format: Some(value.format.into()),
15006                dimension: Some(value.dimension.into()),
15007                base_mip_level: Some(value.baseMipLevel),
15008                mip_level_count: Some(value.mipLevelCount),
15009                base_array_layer: Some(value.baseArrayLayer),
15010                array_layer_count: Some(value.arrayLayerCount),
15011                aspect: Some(value.aspect.into()),
15012                usage: Some(value.usage.into()),
15013            }
15014        }
15015    }
15016    pub struct VertexAttribute {
15017        pub(crate) extensions: Vec<VertexAttributeExtension>,
15018        pub format: Option<VertexFormat>,
15019        pub offset: Option<u64>,
15020        pub shader_location: Option<u32>,
15021    }
15022    impl Default for VertexAttribute {
15023        fn default() -> Self {
15024            Self {
15025                extensions: Vec::new(),
15026                format: None,
15027                offset: None,
15028                shader_location: None,
15029            }
15030        }
15031    }
15032    impl VertexAttribute {
15033        pub fn new() -> Self {
15034            Self::default()
15035        }
15036        pub(crate) fn to_ffi(&self) -> (ffi::WGPUVertexAttribute, ChainedStructStorage) {
15037            let mut storage = ChainedStructStorage::new();
15038            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15039            for ext in self.extensions.iter().rev() {
15040                next = ext.push_chain(&mut storage, next);
15041            }
15042            let mut raw: ffi::WGPUVertexAttribute = unsafe { std::mem::zeroed() };
15043            raw.nextInChain = next;
15044            if let Some(value) = self.format {
15045                raw.format = value.into();
15046            } else {
15047                raw.format = 0 as ffi::WGPUVertexFormat;
15048            }
15049            if let Some(value) = self.offset {
15050                raw.offset = value;
15051            }
15052            if let Some(value) = self.shader_location {
15053                raw.shaderLocation = value;
15054            }
15055            (raw, storage)
15056        }
15057        pub fn with_extension(mut self, extension: VertexAttributeExtension) -> Self {
15058            self.extensions.push(extension);
15059            self
15060        }
15061        pub(crate) fn from_ffi(value: ffi::WGPUVertexAttribute) -> Self {
15062            Self {
15063                extensions: Vec::new(),
15064                format: Some(value.format.into()),
15065                offset: Some(value.offset),
15066                shader_location: Some(value.shaderLocation),
15067            }
15068        }
15069    }
15070    pub struct VertexBufferLayout {
15071        pub(crate) extensions: Vec<VertexBufferLayoutExtension>,
15072        pub step_mode: Option<VertexStepMode>,
15073        pub array_stride: Option<u64>,
15074        pub attributes: Option<Vec<VertexAttribute>>,
15075    }
15076    impl Default for VertexBufferLayout {
15077        fn default() -> Self {
15078            Self {
15079                extensions: Vec::new(),
15080                step_mode: None,
15081                array_stride: None,
15082                attributes: None,
15083            }
15084        }
15085    }
15086    impl VertexBufferLayout {
15087        pub fn new() -> Self {
15088            Self::default()
15089        }
15090        pub(crate) fn to_ffi(
15091            &self,
15092        ) -> (ffi::WGPUVertexBufferLayout, ChainedStructStorage) {
15093            let mut storage = ChainedStructStorage::new();
15094            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15095            for ext in self.extensions.iter().rev() {
15096                next = ext.push_chain(&mut storage, next);
15097            }
15098            let mut raw: ffi::WGPUVertexBufferLayout = unsafe { std::mem::zeroed() };
15099            raw.nextInChain = next;
15100            if let Some(value) = self.step_mode {
15101                raw.stepMode = value.into();
15102            } else {
15103                raw.stepMode = 0 as ffi::WGPUVertexStepMode;
15104            }
15105            if let Some(value) = self.array_stride {
15106                raw.arrayStride = value;
15107            }
15108            raw.attributeCount = self.attributes.as_ref().map(|v| v.len()).unwrap_or(0);
15109            if let Some(values) = &self.attributes {
15110                let len_value = values.len();
15111                let mut raw_vec: Vec<ffi::WGPUVertexAttribute> = Vec::with_capacity(
15112                    values.len(),
15113                );
15114                for item in values.iter() {
15115                    let (raw_item, storage_item) = item.to_ffi();
15116                    raw_vec.push(raw_item);
15117                    storage.push_storage(storage_item);
15118                }
15119                let ptr = storage.push_vec(raw_vec);
15120                raw.attributes = ptr;
15121                raw.attributeCount = len_value;
15122            } else {
15123                raw.attributes = std::ptr::null();
15124                raw.attributeCount = 0;
15125            }
15126            (raw, storage)
15127        }
15128        pub fn with_extension(mut self, extension: VertexBufferLayoutExtension) -> Self {
15129            self.extensions.push(extension);
15130            self
15131        }
15132        pub(crate) fn from_ffi(value: ffi::WGPUVertexBufferLayout) -> Self {
15133            Self {
15134                extensions: Vec::new(),
15135                step_mode: Some(value.stepMode.into()),
15136                array_stride: Some(value.arrayStride),
15137                attributes: if value.attributes.is_null() {
15138                    None
15139                } else {
15140                    Some(
15141                        unsafe {
15142                            std::slice::from_raw_parts(
15143                                value.attributes,
15144                                value.attributeCount as usize,
15145                            )
15146                        }
15147                            .iter()
15148                            .map(|raw| VertexAttribute::from_ffi(*raw))
15149                            .collect(),
15150                    )
15151                },
15152            }
15153        }
15154    }
15155    pub struct VertexState {
15156        pub(crate) extensions: Vec<VertexStateExtension>,
15157        pub module: Option<ShaderModule>,
15158        pub entry_point: Option<String>,
15159        pub constants: Option<Vec<ConstantEntry>>,
15160        pub buffers: Option<Vec<VertexBufferLayout>>,
15161    }
15162    impl Default for VertexState {
15163        fn default() -> Self {
15164            Self {
15165                extensions: Vec::new(),
15166                module: None,
15167                entry_point: None,
15168                constants: None,
15169                buffers: None,
15170            }
15171        }
15172    }
15173    impl VertexState {
15174        pub fn new() -> Self {
15175            Self::default()
15176        }
15177        pub(crate) fn to_ffi(&self) -> (ffi::WGPUVertexState, ChainedStructStorage) {
15178            let mut storage = ChainedStructStorage::new();
15179            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15180            for ext in self.extensions.iter().rev() {
15181                next = ext.push_chain(&mut storage, next);
15182            }
15183            let mut raw: ffi::WGPUVertexState = unsafe { std::mem::zeroed() };
15184            raw.nextInChain = next;
15185            raw.module = self
15186                .module
15187                .as_ref()
15188                .map(|v| v.as_raw())
15189                .unwrap_or(std::ptr::null_mut());
15190            if let Some(value) = &self.entry_point {
15191                raw.entryPoint = ffi::WGPUStringView {
15192                    data: value.as_ptr().cast(),
15193                    length: value.len(),
15194                };
15195            } else {
15196                raw.entryPoint = ffi::WGPUStringView {
15197                    data: std::ptr::null(),
15198                    length: 0,
15199                };
15200            }
15201            raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
15202            if let Some(values) = &self.constants {
15203                let len_value = values.len();
15204                let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
15205                    values.len(),
15206                );
15207                for item in values.iter() {
15208                    let (raw_item, storage_item) = item.to_ffi();
15209                    raw_vec.push(raw_item);
15210                    storage.push_storage(storage_item);
15211                }
15212                let ptr = storage.push_vec(raw_vec);
15213                raw.constants = ptr;
15214                raw.constantCount = len_value;
15215            } else {
15216                raw.constants = std::ptr::null();
15217                raw.constantCount = 0;
15218            }
15219            raw.bufferCount = self.buffers.as_ref().map(|v| v.len()).unwrap_or(0);
15220            if let Some(values) = &self.buffers {
15221                let len_value = values.len();
15222                let mut raw_vec: Vec<ffi::WGPUVertexBufferLayout> = Vec::with_capacity(
15223                    values.len(),
15224                );
15225                for item in values.iter() {
15226                    let (raw_item, storage_item) = item.to_ffi();
15227                    raw_vec.push(raw_item);
15228                    storage.push_storage(storage_item);
15229                }
15230                let ptr = storage.push_vec(raw_vec);
15231                raw.buffers = ptr;
15232                raw.bufferCount = len_value;
15233            } else {
15234                raw.buffers = std::ptr::null();
15235                raw.bufferCount = 0;
15236            }
15237            (raw, storage)
15238        }
15239        pub fn with_extension(mut self, extension: VertexStateExtension) -> Self {
15240            self.extensions.push(extension);
15241            self
15242        }
15243        pub(crate) fn from_ffi(value: ffi::WGPUVertexState) -> Self {
15244            Self {
15245                extensions: Vec::new(),
15246                module: Some(unsafe { ShaderModule::from_raw(value.module) }),
15247                entry_point: if value.entryPoint.data.is_null()
15248                    || value.entryPoint.length == 0
15249                {
15250                    None
15251                } else {
15252                    Some(string_view_to_string(value.entryPoint))
15253                },
15254                constants: if value.constants.is_null() {
15255                    None
15256                } else {
15257                    Some(
15258                        unsafe {
15259                            std::slice::from_raw_parts(
15260                                value.constants,
15261                                value.constantCount as usize,
15262                            )
15263                        }
15264                            .iter()
15265                            .map(|raw| ConstantEntry::from_ffi(*raw))
15266                            .collect(),
15267                    )
15268                },
15269                buffers: if value.buffers.is_null() {
15270                    None
15271                } else {
15272                    Some(
15273                        unsafe {
15274                            std::slice::from_raw_parts(
15275                                value.buffers,
15276                                value.bufferCount as usize,
15277                            )
15278                        }
15279                            .iter()
15280                            .map(|raw| VertexBufferLayout::from_ffi(*raw))
15281                            .collect(),
15282                    )
15283                },
15284            }
15285        }
15286    }
15287    pub struct YCbCrVkDescriptor {
15288        pub vk_format: Option<u32>,
15289        pub vk_y_cb_cr_model: Option<u32>,
15290        pub vk_y_cb_cr_range: Option<u32>,
15291        pub vk_component_swizzle_red: Option<u32>,
15292        pub vk_component_swizzle_green: Option<u32>,
15293        pub vk_component_swizzle_blue: Option<u32>,
15294        pub vk_component_swizzle_alpha: Option<u32>,
15295        pub vk_x_chroma_offset: Option<u32>,
15296        pub vk_y_chroma_offset: Option<u32>,
15297        pub vk_chroma_filter: Option<FilterMode>,
15298        pub force_explicit_reconstruction: Option<bool>,
15299        pub external_format: Option<u64>,
15300    }
15301    impl Default for YCbCrVkDescriptor {
15302        fn default() -> Self {
15303            Self {
15304                vk_format: Some(0),
15305                vk_y_cb_cr_model: Some(0),
15306                vk_y_cb_cr_range: Some(0),
15307                vk_component_swizzle_red: Some(0),
15308                vk_component_swizzle_green: Some(0),
15309                vk_component_swizzle_blue: Some(0),
15310                vk_component_swizzle_alpha: Some(0),
15311                vk_x_chroma_offset: Some(0),
15312                vk_y_chroma_offset: Some(0),
15313                vk_chroma_filter: Some(FilterMode::Nearest),
15314                force_explicit_reconstruction: None,
15315                external_format: Some(0),
15316            }
15317        }
15318    }
15319    impl YCbCrVkDescriptor {
15320        pub fn new() -> Self {
15321            Self::default()
15322        }
15323        pub(crate) fn to_ffi(
15324            &self,
15325        ) -> (ffi::WGPUYCbCrVkDescriptor, ChainedStructStorage) {
15326            let mut storage = ChainedStructStorage::new();
15327            let mut raw: ffi::WGPUYCbCrVkDescriptor = unsafe { std::mem::zeroed() };
15328            if let Some(value) = self.vk_format {
15329                raw.vkFormat = value;
15330            }
15331            if let Some(value) = self.vk_y_cb_cr_model {
15332                raw.vkYCbCrModel = value;
15333            }
15334            if let Some(value) = self.vk_y_cb_cr_range {
15335                raw.vkYCbCrRange = value;
15336            }
15337            if let Some(value) = self.vk_component_swizzle_red {
15338                raw.vkComponentSwizzleRed = value;
15339            }
15340            if let Some(value) = self.vk_component_swizzle_green {
15341                raw.vkComponentSwizzleGreen = value;
15342            }
15343            if let Some(value) = self.vk_component_swizzle_blue {
15344                raw.vkComponentSwizzleBlue = value;
15345            }
15346            if let Some(value) = self.vk_component_swizzle_alpha {
15347                raw.vkComponentSwizzleAlpha = value;
15348            }
15349            if let Some(value) = self.vk_x_chroma_offset {
15350                raw.vkXChromaOffset = value;
15351            }
15352            if let Some(value) = self.vk_y_chroma_offset {
15353                raw.vkYChromaOffset = value;
15354            }
15355            if let Some(value) = self.vk_chroma_filter {
15356                raw.vkChromaFilter = value.into();
15357            } else {
15358                raw.vkChromaFilter = 0 as ffi::WGPUFilterMode;
15359            }
15360            raw.forceExplicitReconstruction = if self
15361                .force_explicit_reconstruction
15362                .unwrap_or(false)
15363            {
15364                1
15365            } else {
15366                0
15367            };
15368            if let Some(value) = self.external_format {
15369                raw.externalFormat = value;
15370            }
15371            (raw, storage)
15372        }
15373        pub(crate) fn from_ffi(value: ffi::WGPUYCbCrVkDescriptor) -> Self {
15374            Self {
15375                vk_format: Some(value.vkFormat),
15376                vk_y_cb_cr_model: Some(value.vkYCbCrModel),
15377                vk_y_cb_cr_range: Some(value.vkYCbCrRange),
15378                vk_component_swizzle_red: Some(value.vkComponentSwizzleRed),
15379                vk_component_swizzle_green: Some(value.vkComponentSwizzleGreen),
15380                vk_component_swizzle_blue: Some(value.vkComponentSwizzleBlue),
15381                vk_component_swizzle_alpha: Some(value.vkComponentSwizzleAlpha),
15382                vk_x_chroma_offset: Some(value.vkXChromaOffset),
15383                vk_y_chroma_offset: Some(value.vkYChromaOffset),
15384                vk_chroma_filter: Some(value.vkChromaFilter.into()),
15385                force_explicit_reconstruction: Some(
15386                    value.forceExplicitReconstruction != 0,
15387                ),
15388                external_format: Some(value.externalFormat),
15389            }
15390        }
15391    }
15392}
15393mod extensions {
15394    #![allow(dead_code, unused_imports)]
15395    use crate::ffi;
15396    use crate::generated::*;
15397    use std::any::Any;
15398    pub(crate) struct ChainedStructStorage {
15399        entries: Vec<Box<ffi::WGPUChainedStruct>>,
15400        buffers: Vec<Box<dyn Any>>,
15401        nested: Vec<ChainedStructStorage>,
15402    }
15403    impl ChainedStructStorage {
15404        pub(crate) fn new() -> Self {
15405            Self {
15406                entries: Vec::new(),
15407                buffers: Vec::new(),
15408                nested: Vec::new(),
15409            }
15410        }
15411        pub(crate) fn push(
15412            &mut self,
15413            s_type: ffi::WGPUSType,
15414            next: *mut ffi::WGPUChainedStruct,
15415        ) -> *mut ffi::WGPUChainedStruct {
15416            let mut node = Box::new(ffi::WGPUChainedStruct {
15417                next,
15418                sType: s_type,
15419            });
15420            let ptr = std::ptr::from_mut(node.as_mut());
15421            self.entries.push(node);
15422            ptr
15423        }
15424        pub(crate) fn push_value<T: 'static>(&mut self, value: T) -> *const T {
15425            let boxed = Box::new(value);
15426            let ptr = std::ptr::from_ref(boxed.as_ref());
15427            self.buffers.push(boxed);
15428            ptr
15429        }
15430        pub(crate) fn push_value_mut<T: 'static>(&mut self, value: T) -> *mut T {
15431            let mut boxed = Box::new(value);
15432            let ptr = std::ptr::from_mut(boxed.as_mut());
15433            self.buffers.push(boxed);
15434            ptr
15435        }
15436        pub(crate) fn push_vec<T: 'static>(&mut self, value: Vec<T>) -> *const T {
15437            let ptr = value.as_ptr();
15438            self.buffers.push(Box::new(value));
15439            ptr
15440        }
15441        pub(crate) fn push_vec_mut<T: 'static>(&mut self, value: Vec<T>) -> *mut T {
15442            let mut value = value;
15443            let ptr = value.as_mut_ptr();
15444            self.buffers.push(Box::new(value));
15445            ptr
15446        }
15447        pub(crate) fn push_any<T: 'static>(&mut self, value: T) {
15448            self.buffers.push(Box::new(value));
15449        }
15450        pub(crate) fn push_storage(&mut self, storage: ChainedStructStorage) {
15451            self.nested.push(storage);
15452        }
15453    }
15454    #[allow(dead_code)]
15455    pub enum AdapterInfoExtension {
15456        AdapterPropertiesD3D(AdapterPropertiesD3D),
15457        AdapterPropertiesWGPU(AdapterPropertiesWGPU),
15458        AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15459            AdapterPropertiesExplicitComputeSubgroupSizeConfigs,
15460        ),
15461        AdapterPropertiesMemoryHeaps(AdapterPropertiesMemoryHeaps),
15462        AdapterPropertiesSubgroupMatrixConfigs(AdapterPropertiesSubgroupMatrixConfigs),
15463        AdapterPropertiesVk(AdapterPropertiesVk),
15464        DawnAdapterPropertiesPowerPreference(DawnAdapterPropertiesPowerPreference),
15465    }
15466    impl std::convert::From<AdapterPropertiesD3D> for AdapterInfoExtension {
15467        fn from(ext: AdapterPropertiesD3D) -> Self {
15468            AdapterInfoExtension::AdapterPropertiesD3D(ext)
15469        }
15470    }
15471    impl std::convert::From<AdapterPropertiesWGPU> for AdapterInfoExtension {
15472        fn from(ext: AdapterPropertiesWGPU) -> Self {
15473            AdapterInfoExtension::AdapterPropertiesWGPU(ext)
15474        }
15475    }
15476    impl std::convert::From<AdapterPropertiesExplicitComputeSubgroupSizeConfigs>
15477    for AdapterInfoExtension {
15478        fn from(ext: AdapterPropertiesExplicitComputeSubgroupSizeConfigs) -> Self {
15479            AdapterInfoExtension::AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15480                ext,
15481            )
15482        }
15483    }
15484    impl std::convert::From<AdapterPropertiesMemoryHeaps> for AdapterInfoExtension {
15485        fn from(ext: AdapterPropertiesMemoryHeaps) -> Self {
15486            AdapterInfoExtension::AdapterPropertiesMemoryHeaps(ext)
15487        }
15488    }
15489    impl std::convert::From<AdapterPropertiesSubgroupMatrixConfigs>
15490    for AdapterInfoExtension {
15491        fn from(ext: AdapterPropertiesSubgroupMatrixConfigs) -> Self {
15492            AdapterInfoExtension::AdapterPropertiesSubgroupMatrixConfigs(ext)
15493        }
15494    }
15495    impl std::convert::From<AdapterPropertiesVk> for AdapterInfoExtension {
15496        fn from(ext: AdapterPropertiesVk) -> Self {
15497            AdapterInfoExtension::AdapterPropertiesVk(ext)
15498        }
15499    }
15500    impl std::convert::From<DawnAdapterPropertiesPowerPreference>
15501    for AdapterInfoExtension {
15502        fn from(ext: DawnAdapterPropertiesPowerPreference) -> Self {
15503            AdapterInfoExtension::DawnAdapterPropertiesPowerPreference(ext)
15504        }
15505    }
15506    impl AdapterInfoExtension {
15507        pub(crate) fn push_chain(
15508            &self,
15509            storage: &mut ChainedStructStorage,
15510            next: *mut ffi::WGPUChainedStruct,
15511        ) -> *mut ffi::WGPUChainedStruct {
15512            match self {
15513                AdapterInfoExtension::AdapterPropertiesD3D(value) => {
15514                    let (mut raw, storage_value) = value.to_ffi();
15515                    raw.chain.sType = SType::AdapterPropertiesD3D.into();
15516                    raw.chain.next = next;
15517                    storage.push_storage(storage_value);
15518                    let raw_ptr = storage.push_value_mut(raw);
15519                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15520                }
15521                AdapterInfoExtension::AdapterPropertiesWGPU(value) => {
15522                    let (mut raw, storage_value) = value.to_ffi();
15523                    raw.chain.sType = SType::AdapterPropertiesWGPU.into();
15524                    raw.chain.next = next;
15525                    storage.push_storage(storage_value);
15526                    let raw_ptr = storage.push_value_mut(raw);
15527                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15528                }
15529                AdapterInfoExtension::AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15530                    value,
15531                ) => {
15532                    let (mut raw, storage_value) = value.to_ffi();
15533                    raw.chain.sType = SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs
15534                        .into();
15535                    raw.chain.next = next;
15536                    storage.push_storage(storage_value);
15537                    let raw_ptr = storage.push_value_mut(raw);
15538                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15539                }
15540                AdapterInfoExtension::AdapterPropertiesMemoryHeaps(value) => {
15541                    let (mut raw, storage_value) = value.to_ffi();
15542                    raw.chain.sType = SType::AdapterPropertiesMemoryHeaps.into();
15543                    raw.chain.next = next;
15544                    storage.push_storage(storage_value);
15545                    let raw_ptr = storage.push_value_mut(raw);
15546                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15547                }
15548                AdapterInfoExtension::AdapterPropertiesSubgroupMatrixConfigs(value) => {
15549                    let (mut raw, storage_value) = value.to_ffi();
15550                    raw.chain.sType = SType::AdapterPropertiesSubgroupMatrixConfigs
15551                        .into();
15552                    raw.chain.next = next;
15553                    storage.push_storage(storage_value);
15554                    let raw_ptr = storage.push_value_mut(raw);
15555                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15556                }
15557                AdapterInfoExtension::AdapterPropertiesVk(value) => {
15558                    let (mut raw, storage_value) = value.to_ffi();
15559                    raw.chain.sType = SType::AdapterPropertiesVk.into();
15560                    raw.chain.next = next;
15561                    storage.push_storage(storage_value);
15562                    let raw_ptr = storage.push_value_mut(raw);
15563                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15564                }
15565                AdapterInfoExtension::DawnAdapterPropertiesPowerPreference(value) => {
15566                    let (mut raw, storage_value) = value.to_ffi();
15567                    raw.chain.sType = SType::DawnAdapterPropertiesPowerPreference.into();
15568                    raw.chain.next = next;
15569                    storage.push_storage(storage_value);
15570                    let raw_ptr = storage.push_value_mut(raw);
15571                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15572                }
15573            }
15574        }
15575    }
15576    #[allow(dead_code)]
15577    pub enum BindGroupDescriptorExtension {}
15578    impl BindGroupDescriptorExtension {
15579        pub(crate) fn push_chain(
15580            &self,
15581            storage: &mut ChainedStructStorage,
15582            next: *mut ffi::WGPUChainedStruct,
15583        ) -> *mut ffi::WGPUChainedStruct {
15584            let _ = self;
15585            let _ = storage;
15586            next
15587        }
15588    }
15589    #[allow(dead_code)]
15590    pub enum BindGroupEntryExtension {
15591        ExternalTextureBindingEntry(ExternalTextureBindingEntry),
15592        TexelBufferBindingEntry(TexelBufferBindingEntry),
15593    }
15594    impl std::convert::From<ExternalTextureBindingEntry> for BindGroupEntryExtension {
15595        fn from(ext: ExternalTextureBindingEntry) -> Self {
15596            BindGroupEntryExtension::ExternalTextureBindingEntry(ext)
15597        }
15598    }
15599    impl std::convert::From<TexelBufferBindingEntry> for BindGroupEntryExtension {
15600        fn from(ext: TexelBufferBindingEntry) -> Self {
15601            BindGroupEntryExtension::TexelBufferBindingEntry(ext)
15602        }
15603    }
15604    impl BindGroupEntryExtension {
15605        pub(crate) fn push_chain(
15606            &self,
15607            storage: &mut ChainedStructStorage,
15608            next: *mut ffi::WGPUChainedStruct,
15609        ) -> *mut ffi::WGPUChainedStruct {
15610            match self {
15611                BindGroupEntryExtension::ExternalTextureBindingEntry(value) => {
15612                    let (mut raw, storage_value) = value.to_ffi();
15613                    raw.chain.sType = SType::ExternalTextureBindingEntry.into();
15614                    raw.chain.next = next;
15615                    storage.push_storage(storage_value);
15616                    let raw_ptr = storage.push_value_mut(raw);
15617                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15618                }
15619                BindGroupEntryExtension::TexelBufferBindingEntry(value) => {
15620                    let (mut raw, storage_value) = value.to_ffi();
15621                    raw.chain.sType = SType::TexelBufferBindingEntry.into();
15622                    raw.chain.next = next;
15623                    storage.push_storage(storage_value);
15624                    let raw_ptr = storage.push_value_mut(raw);
15625                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15626                }
15627            }
15628        }
15629    }
15630    #[allow(dead_code)]
15631    pub enum BindGroupLayoutDescriptorExtension {}
15632    impl BindGroupLayoutDescriptorExtension {
15633        pub(crate) fn push_chain(
15634            &self,
15635            storage: &mut ChainedStructStorage,
15636            next: *mut ffi::WGPUChainedStruct,
15637        ) -> *mut ffi::WGPUChainedStruct {
15638            let _ = self;
15639            let _ = storage;
15640            next
15641        }
15642    }
15643    #[allow(dead_code)]
15644    pub enum BindGroupLayoutEntryExtension {
15645        ExternalTextureBindingLayout(ExternalTextureBindingLayout),
15646        StaticSamplerBindingLayout(StaticSamplerBindingLayout),
15647        TexelBufferBindingLayout(TexelBufferBindingLayout),
15648    }
15649    impl std::convert::From<ExternalTextureBindingLayout>
15650    for BindGroupLayoutEntryExtension {
15651        fn from(ext: ExternalTextureBindingLayout) -> Self {
15652            BindGroupLayoutEntryExtension::ExternalTextureBindingLayout(ext)
15653        }
15654    }
15655    impl std::convert::From<StaticSamplerBindingLayout>
15656    for BindGroupLayoutEntryExtension {
15657        fn from(ext: StaticSamplerBindingLayout) -> Self {
15658            BindGroupLayoutEntryExtension::StaticSamplerBindingLayout(ext)
15659        }
15660    }
15661    impl std::convert::From<TexelBufferBindingLayout> for BindGroupLayoutEntryExtension {
15662        fn from(ext: TexelBufferBindingLayout) -> Self {
15663            BindGroupLayoutEntryExtension::TexelBufferBindingLayout(ext)
15664        }
15665    }
15666    impl BindGroupLayoutEntryExtension {
15667        pub(crate) fn push_chain(
15668            &self,
15669            storage: &mut ChainedStructStorage,
15670            next: *mut ffi::WGPUChainedStruct,
15671        ) -> *mut ffi::WGPUChainedStruct {
15672            match self {
15673                BindGroupLayoutEntryExtension::ExternalTextureBindingLayout(value) => {
15674                    let (mut raw, storage_value) = value.to_ffi();
15675                    raw.chain.sType = SType::ExternalTextureBindingLayout.into();
15676                    raw.chain.next = next;
15677                    storage.push_storage(storage_value);
15678                    let raw_ptr = storage.push_value_mut(raw);
15679                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15680                }
15681                BindGroupLayoutEntryExtension::StaticSamplerBindingLayout(value) => {
15682                    let (mut raw, storage_value) = value.to_ffi();
15683                    raw.chain.sType = SType::StaticSamplerBindingLayout.into();
15684                    raw.chain.next = next;
15685                    storage.push_storage(storage_value);
15686                    let raw_ptr = storage.push_value_mut(raw);
15687                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15688                }
15689                BindGroupLayoutEntryExtension::TexelBufferBindingLayout(value) => {
15690                    let (mut raw, storage_value) = value.to_ffi();
15691                    raw.chain.sType = SType::TexelBufferBindingLayout.into();
15692                    raw.chain.next = next;
15693                    storage.push_storage(storage_value);
15694                    let raw_ptr = storage.push_value_mut(raw);
15695                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15696                }
15697            }
15698        }
15699    }
15700    #[allow(dead_code)]
15701    pub enum BindingResourceExtension {}
15702    impl BindingResourceExtension {
15703        pub(crate) fn push_chain(
15704            &self,
15705            storage: &mut ChainedStructStorage,
15706            next: *mut ffi::WGPUChainedStruct,
15707        ) -> *mut ffi::WGPUChainedStruct {
15708            let _ = self;
15709            let _ = storage;
15710            next
15711        }
15712    }
15713    #[allow(dead_code)]
15714    pub enum BufferBindingLayoutExtension {}
15715    impl BufferBindingLayoutExtension {
15716        pub(crate) fn push_chain(
15717            &self,
15718            storage: &mut ChainedStructStorage,
15719            next: *mut ffi::WGPUChainedStruct,
15720        ) -> *mut ffi::WGPUChainedStruct {
15721            let _ = self;
15722            let _ = storage;
15723            next
15724        }
15725    }
15726    #[allow(dead_code)]
15727    pub enum BufferDescriptorExtension {
15728        BufferHostMappedPointer(BufferHostMappedPointer),
15729        DawnBufferDescriptorErrorInfoFromWireClient(
15730            DawnBufferDescriptorErrorInfoFromWireClient,
15731        ),
15732        DawnFakeBufferOOMForTesting(DawnFakeBufferOOMForTesting),
15733    }
15734    impl std::convert::From<BufferHostMappedPointer> for BufferDescriptorExtension {
15735        fn from(ext: BufferHostMappedPointer) -> Self {
15736            BufferDescriptorExtension::BufferHostMappedPointer(ext)
15737        }
15738    }
15739    impl std::convert::From<DawnBufferDescriptorErrorInfoFromWireClient>
15740    for BufferDescriptorExtension {
15741        fn from(ext: DawnBufferDescriptorErrorInfoFromWireClient) -> Self {
15742            BufferDescriptorExtension::DawnBufferDescriptorErrorInfoFromWireClient(ext)
15743        }
15744    }
15745    impl std::convert::From<DawnFakeBufferOOMForTesting> for BufferDescriptorExtension {
15746        fn from(ext: DawnFakeBufferOOMForTesting) -> Self {
15747            BufferDescriptorExtension::DawnFakeBufferOOMForTesting(ext)
15748        }
15749    }
15750    impl BufferDescriptorExtension {
15751        pub(crate) fn push_chain(
15752            &self,
15753            storage: &mut ChainedStructStorage,
15754            next: *mut ffi::WGPUChainedStruct,
15755        ) -> *mut ffi::WGPUChainedStruct {
15756            match self {
15757                BufferDescriptorExtension::BufferHostMappedPointer(value) => {
15758                    let (mut raw, storage_value) = value.to_ffi();
15759                    raw.chain.sType = SType::BufferHostMappedPointer.into();
15760                    raw.chain.next = next;
15761                    storage.push_storage(storage_value);
15762                    let raw_ptr = storage.push_value_mut(raw);
15763                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15764                }
15765                BufferDescriptorExtension::DawnBufferDescriptorErrorInfoFromWireClient(
15766                    value,
15767                ) => {
15768                    let (mut raw, storage_value) = value.to_ffi();
15769                    raw.chain.sType = SType::DawnBufferDescriptorErrorInfoFromWireClient
15770                        .into();
15771                    raw.chain.next = next;
15772                    storage.push_storage(storage_value);
15773                    let raw_ptr = storage.push_value_mut(raw);
15774                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15775                }
15776                BufferDescriptorExtension::DawnFakeBufferOOMForTesting(value) => {
15777                    let (mut raw, storage_value) = value.to_ffi();
15778                    raw.chain.sType = SType::DawnFakeBufferOOMForTesting.into();
15779                    raw.chain.next = next;
15780                    storage.push_storage(storage_value);
15781                    let raw_ptr = storage.push_value_mut(raw);
15782                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15783                }
15784            }
15785        }
15786    }
15787    #[allow(dead_code)]
15788    pub enum ColorTargetStateExtension {
15789        ColorTargetStateExpandResolveTextureDawn(
15790            ColorTargetStateExpandResolveTextureDawn,
15791        ),
15792    }
15793    impl std::convert::From<ColorTargetStateExpandResolveTextureDawn>
15794    for ColorTargetStateExtension {
15795        fn from(ext: ColorTargetStateExpandResolveTextureDawn) -> Self {
15796            ColorTargetStateExtension::ColorTargetStateExpandResolveTextureDawn(ext)
15797        }
15798    }
15799    impl ColorTargetStateExtension {
15800        pub(crate) fn push_chain(
15801            &self,
15802            storage: &mut ChainedStructStorage,
15803            next: *mut ffi::WGPUChainedStruct,
15804        ) -> *mut ffi::WGPUChainedStruct {
15805            match self {
15806                ColorTargetStateExtension::ColorTargetStateExpandResolveTextureDawn(
15807                    value,
15808                ) => {
15809                    let (mut raw, storage_value) = value.to_ffi();
15810                    raw.chain.sType = SType::ColorTargetStateExpandResolveTextureDawn
15811                        .into();
15812                    raw.chain.next = next;
15813                    storage.push_storage(storage_value);
15814                    let raw_ptr = storage.push_value_mut(raw);
15815                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15816                }
15817            }
15818        }
15819    }
15820    #[allow(dead_code)]
15821    pub enum CommandBufferDescriptorExtension {}
15822    impl CommandBufferDescriptorExtension {
15823        pub(crate) fn push_chain(
15824            &self,
15825            storage: &mut ChainedStructStorage,
15826            next: *mut ffi::WGPUChainedStruct,
15827        ) -> *mut ffi::WGPUChainedStruct {
15828            let _ = self;
15829            let _ = storage;
15830            next
15831        }
15832    }
15833    #[allow(dead_code)]
15834    pub enum CommandEncoderDescriptorExtension {
15835        DawnEncoderInternalUsageDescriptor(DawnEncoderInternalUsageDescriptor),
15836    }
15837    impl std::convert::From<DawnEncoderInternalUsageDescriptor>
15838    for CommandEncoderDescriptorExtension {
15839        fn from(ext: DawnEncoderInternalUsageDescriptor) -> Self {
15840            CommandEncoderDescriptorExtension::DawnEncoderInternalUsageDescriptor(ext)
15841        }
15842    }
15843    impl CommandEncoderDescriptorExtension {
15844        pub(crate) fn push_chain(
15845            &self,
15846            storage: &mut ChainedStructStorage,
15847            next: *mut ffi::WGPUChainedStruct,
15848        ) -> *mut ffi::WGPUChainedStruct {
15849            match self {
15850                CommandEncoderDescriptorExtension::DawnEncoderInternalUsageDescriptor(
15851                    value,
15852                ) => {
15853                    let (mut raw, storage_value) = value.to_ffi();
15854                    raw.chain.sType = SType::DawnEncoderInternalUsageDescriptor.into();
15855                    raw.chain.next = next;
15856                    storage.push_storage(storage_value);
15857                    let raw_ptr = storage.push_value_mut(raw);
15858                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15859                }
15860            }
15861        }
15862    }
15863    #[allow(dead_code)]
15864    pub enum CompilationInfoExtension {}
15865    impl CompilationInfoExtension {
15866        pub(crate) fn push_chain(
15867            &self,
15868            storage: &mut ChainedStructStorage,
15869            next: *mut ffi::WGPUChainedStruct,
15870        ) -> *mut ffi::WGPUChainedStruct {
15871            let _ = self;
15872            let _ = storage;
15873            next
15874        }
15875    }
15876    #[allow(dead_code)]
15877    pub enum CompilationMessageExtension {
15878        DawnCompilationMessageUtf16(DawnCompilationMessageUtf16),
15879    }
15880    impl std::convert::From<DawnCompilationMessageUtf16>
15881    for CompilationMessageExtension {
15882        fn from(ext: DawnCompilationMessageUtf16) -> Self {
15883            CompilationMessageExtension::DawnCompilationMessageUtf16(ext)
15884        }
15885    }
15886    impl CompilationMessageExtension {
15887        pub(crate) fn push_chain(
15888            &self,
15889            storage: &mut ChainedStructStorage,
15890            next: *mut ffi::WGPUChainedStruct,
15891        ) -> *mut ffi::WGPUChainedStruct {
15892            match self {
15893                CompilationMessageExtension::DawnCompilationMessageUtf16(value) => {
15894                    let (mut raw, storage_value) = value.to_ffi();
15895                    raw.chain.sType = SType::DawnCompilationMessageUtf16.into();
15896                    raw.chain.next = next;
15897                    storage.push_storage(storage_value);
15898                    let raw_ptr = storage.push_value_mut(raw);
15899                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15900                }
15901            }
15902        }
15903    }
15904    #[allow(dead_code)]
15905    pub enum ComputePassDescriptorExtension {}
15906    impl ComputePassDescriptorExtension {
15907        pub(crate) fn push_chain(
15908            &self,
15909            storage: &mut ChainedStructStorage,
15910            next: *mut ffi::WGPUChainedStruct,
15911        ) -> *mut ffi::WGPUChainedStruct {
15912            let _ = self;
15913            let _ = storage;
15914            next
15915        }
15916    }
15917    #[allow(dead_code)]
15918    pub enum ComputePipelineDescriptorExtension {}
15919    impl ComputePipelineDescriptorExtension {
15920        pub(crate) fn push_chain(
15921            &self,
15922            storage: &mut ChainedStructStorage,
15923            next: *mut ffi::WGPUChainedStruct,
15924        ) -> *mut ffi::WGPUChainedStruct {
15925            let _ = self;
15926            let _ = storage;
15927            next
15928        }
15929    }
15930    #[allow(dead_code)]
15931    pub enum ComputeStateExtension {}
15932    impl ComputeStateExtension {
15933        pub(crate) fn push_chain(
15934            &self,
15935            storage: &mut ChainedStructStorage,
15936            next: *mut ffi::WGPUChainedStruct,
15937        ) -> *mut ffi::WGPUChainedStruct {
15938            let _ = self;
15939            let _ = storage;
15940            next
15941        }
15942    }
15943    #[allow(dead_code)]
15944    pub enum ConstantEntryExtension {}
15945    impl ConstantEntryExtension {
15946        pub(crate) fn push_chain(
15947            &self,
15948            storage: &mut ChainedStructStorage,
15949            next: *mut ffi::WGPUChainedStruct,
15950        ) -> *mut ffi::WGPUChainedStruct {
15951            let _ = self;
15952            let _ = storage;
15953            next
15954        }
15955    }
15956    #[allow(dead_code)]
15957    pub enum CopyTextureForBrowserOptionsExtension {}
15958    impl CopyTextureForBrowserOptionsExtension {
15959        pub(crate) fn push_chain(
15960            &self,
15961            storage: &mut ChainedStructStorage,
15962            next: *mut ffi::WGPUChainedStruct,
15963        ) -> *mut ffi::WGPUChainedStruct {
15964            let _ = self;
15965            let _ = storage;
15966            next
15967        }
15968    }
15969    #[allow(dead_code)]
15970    pub enum DawnFormatCapabilitiesExtension {
15971        DawnDrmFormatCapabilities(DawnDrmFormatCapabilities),
15972    }
15973    impl std::convert::From<DawnDrmFormatCapabilities>
15974    for DawnFormatCapabilitiesExtension {
15975        fn from(ext: DawnDrmFormatCapabilities) -> Self {
15976            DawnFormatCapabilitiesExtension::DawnDrmFormatCapabilities(ext)
15977        }
15978    }
15979    impl DawnFormatCapabilitiesExtension {
15980        pub(crate) fn push_chain(
15981            &self,
15982            storage: &mut ChainedStructStorage,
15983            next: *mut ffi::WGPUChainedStruct,
15984        ) -> *mut ffi::WGPUChainedStruct {
15985            match self {
15986                DawnFormatCapabilitiesExtension::DawnDrmFormatCapabilities(value) => {
15987                    let (mut raw, storage_value) = value.to_ffi();
15988                    raw.chain.sType = SType::DawnDrmFormatCapabilities.into();
15989                    raw.chain.next = next;
15990                    storage.push_storage(storage_value);
15991                    let raw_ptr = storage.push_value_mut(raw);
15992                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15993                }
15994            }
15995        }
15996    }
15997    #[allow(dead_code)]
15998    pub enum DepthStencilStateExtension {}
15999    impl DepthStencilStateExtension {
16000        pub(crate) fn push_chain(
16001            &self,
16002            storage: &mut ChainedStructStorage,
16003            next: *mut ffi::WGPUChainedStruct,
16004        ) -> *mut ffi::WGPUChainedStruct {
16005            let _ = self;
16006            let _ = storage;
16007            next
16008        }
16009    }
16010    #[allow(dead_code)]
16011    pub enum DeviceDescriptorExtension {
16012        DawnCacheDeviceDescriptor(DawnCacheDeviceDescriptor),
16013        DawnConsumeAdapterDescriptor(DawnConsumeAdapterDescriptor),
16014        DawnDeviceAllocatorControl(DawnDeviceAllocatorControl),
16015        DawnFakeDeviceInitializeErrorForTesting(DawnFakeDeviceInitializeErrorForTesting),
16016        DawnTogglesDescriptor(DawnTogglesDescriptor),
16017    }
16018    impl std::convert::From<DawnCacheDeviceDescriptor> for DeviceDescriptorExtension {
16019        fn from(ext: DawnCacheDeviceDescriptor) -> Self {
16020            DeviceDescriptorExtension::DawnCacheDeviceDescriptor(ext)
16021        }
16022    }
16023    impl std::convert::From<DawnConsumeAdapterDescriptor> for DeviceDescriptorExtension {
16024        fn from(ext: DawnConsumeAdapterDescriptor) -> Self {
16025            DeviceDescriptorExtension::DawnConsumeAdapterDescriptor(ext)
16026        }
16027    }
16028    impl std::convert::From<DawnDeviceAllocatorControl> for DeviceDescriptorExtension {
16029        fn from(ext: DawnDeviceAllocatorControl) -> Self {
16030            DeviceDescriptorExtension::DawnDeviceAllocatorControl(ext)
16031        }
16032    }
16033    impl std::convert::From<DawnFakeDeviceInitializeErrorForTesting>
16034    for DeviceDescriptorExtension {
16035        fn from(ext: DawnFakeDeviceInitializeErrorForTesting) -> Self {
16036            DeviceDescriptorExtension::DawnFakeDeviceInitializeErrorForTesting(ext)
16037        }
16038    }
16039    impl std::convert::From<DawnTogglesDescriptor> for DeviceDescriptorExtension {
16040        fn from(ext: DawnTogglesDescriptor) -> Self {
16041            DeviceDescriptorExtension::DawnTogglesDescriptor(ext)
16042        }
16043    }
16044    impl DeviceDescriptorExtension {
16045        pub(crate) fn push_chain(
16046            &self,
16047            storage: &mut ChainedStructStorage,
16048            next: *mut ffi::WGPUChainedStruct,
16049        ) -> *mut ffi::WGPUChainedStruct {
16050            match self {
16051                DeviceDescriptorExtension::DawnCacheDeviceDescriptor(value) => {
16052                    let (mut raw, storage_value) = value.to_ffi();
16053                    raw.chain.sType = SType::DawnCacheDeviceDescriptor.into();
16054                    raw.chain.next = next;
16055                    storage.push_storage(storage_value);
16056                    let raw_ptr = storage.push_value_mut(raw);
16057                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16058                }
16059                DeviceDescriptorExtension::DawnConsumeAdapterDescriptor(value) => {
16060                    let (mut raw, storage_value) = value.to_ffi();
16061                    raw.chain.sType = SType::DawnConsumeAdapterDescriptor.into();
16062                    raw.chain.next = next;
16063                    storage.push_storage(storage_value);
16064                    let raw_ptr = storage.push_value_mut(raw);
16065                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16066                }
16067                DeviceDescriptorExtension::DawnDeviceAllocatorControl(value) => {
16068                    let (mut raw, storage_value) = value.to_ffi();
16069                    raw.chain.sType = SType::DawnDeviceAllocatorControl.into();
16070                    raw.chain.next = next;
16071                    storage.push_storage(storage_value);
16072                    let raw_ptr = storage.push_value_mut(raw);
16073                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16074                }
16075                DeviceDescriptorExtension::DawnFakeDeviceInitializeErrorForTesting(
16076                    value,
16077                ) => {
16078                    let (mut raw, storage_value) = value.to_ffi();
16079                    raw.chain.sType = SType::DawnFakeDeviceInitializeErrorForTesting
16080                        .into();
16081                    raw.chain.next = next;
16082                    storage.push_storage(storage_value);
16083                    let raw_ptr = storage.push_value_mut(raw);
16084                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16085                }
16086                DeviceDescriptorExtension::DawnTogglesDescriptor(value) => {
16087                    let (mut raw, storage_value) = value.to_ffi();
16088                    raw.chain.sType = SType::DawnTogglesDescriptor.into();
16089                    raw.chain.next = next;
16090                    storage.push_storage(storage_value);
16091                    let raw_ptr = storage.push_value_mut(raw);
16092                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16093                }
16094            }
16095        }
16096    }
16097    #[allow(dead_code)]
16098    pub enum ExternalTextureDescriptorExtension {}
16099    impl ExternalTextureDescriptorExtension {
16100        pub(crate) fn push_chain(
16101            &self,
16102            storage: &mut ChainedStructStorage,
16103            next: *mut ffi::WGPUChainedStruct,
16104        ) -> *mut ffi::WGPUChainedStruct {
16105            let _ = self;
16106            let _ = storage;
16107            next
16108        }
16109    }
16110    #[allow(dead_code)]
16111    pub enum FragmentStateExtension {}
16112    impl FragmentStateExtension {
16113        pub(crate) fn push_chain(
16114            &self,
16115            storage: &mut ChainedStructStorage,
16116            next: *mut ffi::WGPUChainedStruct,
16117        ) -> *mut ffi::WGPUChainedStruct {
16118            let _ = self;
16119            let _ = storage;
16120            next
16121        }
16122    }
16123    #[allow(dead_code)]
16124    pub enum ImageCopyExternalTextureExtension {}
16125    impl ImageCopyExternalTextureExtension {
16126        pub(crate) fn push_chain(
16127            &self,
16128            storage: &mut ChainedStructStorage,
16129            next: *mut ffi::WGPUChainedStruct,
16130        ) -> *mut ffi::WGPUChainedStruct {
16131            let _ = self;
16132            let _ = storage;
16133            next
16134        }
16135    }
16136    #[allow(dead_code)]
16137    pub enum InstanceDescriptorExtension {
16138        DawnWGSLBlocklist(DawnWGSLBlocklist),
16139        DawnTogglesDescriptor(DawnTogglesDescriptor),
16140        DawnWireWGSLControl(DawnWireWGSLControl),
16141    }
16142    impl std::convert::From<DawnWGSLBlocklist> for InstanceDescriptorExtension {
16143        fn from(ext: DawnWGSLBlocklist) -> Self {
16144            InstanceDescriptorExtension::DawnWGSLBlocklist(ext)
16145        }
16146    }
16147    impl std::convert::From<DawnTogglesDescriptor> for InstanceDescriptorExtension {
16148        fn from(ext: DawnTogglesDescriptor) -> Self {
16149            InstanceDescriptorExtension::DawnTogglesDescriptor(ext)
16150        }
16151    }
16152    impl std::convert::From<DawnWireWGSLControl> for InstanceDescriptorExtension {
16153        fn from(ext: DawnWireWGSLControl) -> Self {
16154            InstanceDescriptorExtension::DawnWireWGSLControl(ext)
16155        }
16156    }
16157    impl InstanceDescriptorExtension {
16158        pub(crate) fn push_chain(
16159            &self,
16160            storage: &mut ChainedStructStorage,
16161            next: *mut ffi::WGPUChainedStruct,
16162        ) -> *mut ffi::WGPUChainedStruct {
16163            match self {
16164                InstanceDescriptorExtension::DawnWGSLBlocklist(value) => {
16165                    let (mut raw, storage_value) = value.to_ffi();
16166                    raw.chain.sType = SType::DawnWGSLBlocklist.into();
16167                    raw.chain.next = next;
16168                    storage.push_storage(storage_value);
16169                    let raw_ptr = storage.push_value_mut(raw);
16170                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16171                }
16172                InstanceDescriptorExtension::DawnTogglesDescriptor(value) => {
16173                    let (mut raw, storage_value) = value.to_ffi();
16174                    raw.chain.sType = SType::DawnTogglesDescriptor.into();
16175                    raw.chain.next = next;
16176                    storage.push_storage(storage_value);
16177                    let raw_ptr = storage.push_value_mut(raw);
16178                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16179                }
16180                InstanceDescriptorExtension::DawnWireWGSLControl(value) => {
16181                    let (mut raw, storage_value) = value.to_ffi();
16182                    raw.chain.sType = SType::DawnWireWGSLControl.into();
16183                    raw.chain.next = next;
16184                    storage.push_storage(storage_value);
16185                    let raw_ptr = storage.push_value_mut(raw);
16186                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16187                }
16188            }
16189        }
16190    }
16191    #[allow(dead_code)]
16192    pub enum InstanceLimitsExtension {}
16193    impl InstanceLimitsExtension {
16194        pub(crate) fn push_chain(
16195            &self,
16196            storage: &mut ChainedStructStorage,
16197            next: *mut ffi::WGPUChainedStruct,
16198        ) -> *mut ffi::WGPUChainedStruct {
16199            let _ = self;
16200            let _ = storage;
16201            next
16202        }
16203    }
16204    #[allow(dead_code)]
16205    pub enum LimitsExtension {
16206        DawnHostMappedPointerLimits(DawnHostMappedPointerLimits),
16207        DawnTexelCopyBufferRowAlignmentLimits(DawnTexelCopyBufferRowAlignmentLimits),
16208    }
16209    impl std::convert::From<DawnHostMappedPointerLimits> for LimitsExtension {
16210        fn from(ext: DawnHostMappedPointerLimits) -> Self {
16211            LimitsExtension::DawnHostMappedPointerLimits(ext)
16212        }
16213    }
16214    impl std::convert::From<DawnTexelCopyBufferRowAlignmentLimits> for LimitsExtension {
16215        fn from(ext: DawnTexelCopyBufferRowAlignmentLimits) -> Self {
16216            LimitsExtension::DawnTexelCopyBufferRowAlignmentLimits(ext)
16217        }
16218    }
16219    impl LimitsExtension {
16220        pub(crate) fn push_chain(
16221            &self,
16222            storage: &mut ChainedStructStorage,
16223            next: *mut ffi::WGPUChainedStruct,
16224        ) -> *mut ffi::WGPUChainedStruct {
16225            match self {
16226                LimitsExtension::DawnHostMappedPointerLimits(value) => {
16227                    let (mut raw, storage_value) = value.to_ffi();
16228                    raw.chain.sType = SType::DawnHostMappedPointerLimits.into();
16229                    raw.chain.next = next;
16230                    storage.push_storage(storage_value);
16231                    let raw_ptr = storage.push_value_mut(raw);
16232                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16233                }
16234                LimitsExtension::DawnTexelCopyBufferRowAlignmentLimits(value) => {
16235                    let (mut raw, storage_value) = value.to_ffi();
16236                    raw.chain.sType = SType::DawnTexelCopyBufferRowAlignmentLimits
16237                        .into();
16238                    raw.chain.next = next;
16239                    storage.push_storage(storage_value);
16240                    let raw_ptr = storage.push_value_mut(raw);
16241                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16242                }
16243            }
16244        }
16245    }
16246    #[allow(dead_code)]
16247    pub enum MultisampleStateExtension {}
16248    impl MultisampleStateExtension {
16249        pub(crate) fn push_chain(
16250            &self,
16251            storage: &mut ChainedStructStorage,
16252            next: *mut ffi::WGPUChainedStruct,
16253        ) -> *mut ffi::WGPUChainedStruct {
16254            let _ = self;
16255            let _ = storage;
16256            next
16257        }
16258    }
16259    #[allow(dead_code)]
16260    pub enum PassTimestampWritesExtension {}
16261    impl PassTimestampWritesExtension {
16262        pub(crate) fn push_chain(
16263            &self,
16264            storage: &mut ChainedStructStorage,
16265            next: *mut ffi::WGPUChainedStruct,
16266        ) -> *mut ffi::WGPUChainedStruct {
16267            let _ = self;
16268            let _ = storage;
16269            next
16270        }
16271    }
16272    #[allow(dead_code)]
16273    pub enum PipelineLayoutDescriptorExtension {
16274        PipelineLayoutPixelLocalStorage(PipelineLayoutPixelLocalStorage),
16275        PipelineLayoutResourceTable(PipelineLayoutResourceTable),
16276    }
16277    impl std::convert::From<PipelineLayoutPixelLocalStorage>
16278    for PipelineLayoutDescriptorExtension {
16279        fn from(ext: PipelineLayoutPixelLocalStorage) -> Self {
16280            PipelineLayoutDescriptorExtension::PipelineLayoutPixelLocalStorage(ext)
16281        }
16282    }
16283    impl std::convert::From<PipelineLayoutResourceTable>
16284    for PipelineLayoutDescriptorExtension {
16285        fn from(ext: PipelineLayoutResourceTable) -> Self {
16286            PipelineLayoutDescriptorExtension::PipelineLayoutResourceTable(ext)
16287        }
16288    }
16289    impl PipelineLayoutDescriptorExtension {
16290        pub(crate) fn push_chain(
16291            &self,
16292            storage: &mut ChainedStructStorage,
16293            next: *mut ffi::WGPUChainedStruct,
16294        ) -> *mut ffi::WGPUChainedStruct {
16295            match self {
16296                PipelineLayoutDescriptorExtension::PipelineLayoutPixelLocalStorage(
16297                    value,
16298                ) => {
16299                    let (mut raw, storage_value) = value.to_ffi();
16300                    raw.chain.sType = SType::PipelineLayoutPixelLocalStorage.into();
16301                    raw.chain.next = next;
16302                    storage.push_storage(storage_value);
16303                    let raw_ptr = storage.push_value_mut(raw);
16304                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16305                }
16306                PipelineLayoutDescriptorExtension::PipelineLayoutResourceTable(
16307                    value,
16308                ) => {
16309                    let (mut raw, storage_value) = value.to_ffi();
16310                    raw.chain.sType = SType::PipelineLayoutResourceTable.into();
16311                    raw.chain.next = next;
16312                    storage.push_storage(storage_value);
16313                    let raw_ptr = storage.push_value_mut(raw);
16314                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16315                }
16316            }
16317        }
16318    }
16319    #[allow(dead_code)]
16320    pub enum PipelineLayoutStorageAttachmentExtension {}
16321    impl PipelineLayoutStorageAttachmentExtension {
16322        pub(crate) fn push_chain(
16323            &self,
16324            storage: &mut ChainedStructStorage,
16325            next: *mut ffi::WGPUChainedStruct,
16326        ) -> *mut ffi::WGPUChainedStruct {
16327            let _ = self;
16328            let _ = storage;
16329            next
16330        }
16331    }
16332    #[allow(dead_code)]
16333    pub enum PrimitiveStateExtension {}
16334    impl PrimitiveStateExtension {
16335        pub(crate) fn push_chain(
16336            &self,
16337            storage: &mut ChainedStructStorage,
16338            next: *mut ffi::WGPUChainedStruct,
16339        ) -> *mut ffi::WGPUChainedStruct {
16340            let _ = self;
16341            let _ = storage;
16342            next
16343        }
16344    }
16345    #[allow(dead_code)]
16346    pub enum QuerySetDescriptorExtension {}
16347    impl QuerySetDescriptorExtension {
16348        pub(crate) fn push_chain(
16349            &self,
16350            storage: &mut ChainedStructStorage,
16351            next: *mut ffi::WGPUChainedStruct,
16352        ) -> *mut ffi::WGPUChainedStruct {
16353            let _ = self;
16354            let _ = storage;
16355            next
16356        }
16357    }
16358    #[allow(dead_code)]
16359    pub enum QueueDescriptorExtension {}
16360    impl QueueDescriptorExtension {
16361        pub(crate) fn push_chain(
16362            &self,
16363            storage: &mut ChainedStructStorage,
16364            next: *mut ffi::WGPUChainedStruct,
16365        ) -> *mut ffi::WGPUChainedStruct {
16366            let _ = self;
16367            let _ = storage;
16368            next
16369        }
16370    }
16371    #[allow(dead_code)]
16372    pub enum RenderBundleDescriptorExtension {}
16373    impl RenderBundleDescriptorExtension {
16374        pub(crate) fn push_chain(
16375            &self,
16376            storage: &mut ChainedStructStorage,
16377            next: *mut ffi::WGPUChainedStruct,
16378        ) -> *mut ffi::WGPUChainedStruct {
16379            let _ = self;
16380            let _ = storage;
16381            next
16382        }
16383    }
16384    #[allow(dead_code)]
16385    pub enum RenderBundleEncoderDescriptorExtension {}
16386    impl RenderBundleEncoderDescriptorExtension {
16387        pub(crate) fn push_chain(
16388            &self,
16389            storage: &mut ChainedStructStorage,
16390            next: *mut ffi::WGPUChainedStruct,
16391        ) -> *mut ffi::WGPUChainedStruct {
16392            let _ = self;
16393            let _ = storage;
16394            next
16395        }
16396    }
16397    #[allow(dead_code)]
16398    pub enum RenderPassColorAttachmentExtension {}
16399    impl RenderPassColorAttachmentExtension {
16400        pub(crate) fn push_chain(
16401            &self,
16402            storage: &mut ChainedStructStorage,
16403            next: *mut ffi::WGPUChainedStruct,
16404        ) -> *mut ffi::WGPUChainedStruct {
16405            let _ = self;
16406            let _ = storage;
16407            next
16408        }
16409    }
16410    #[allow(dead_code)]
16411    pub enum RenderPassDepthStencilAttachmentExtension {}
16412    impl RenderPassDepthStencilAttachmentExtension {
16413        pub(crate) fn push_chain(
16414            &self,
16415            storage: &mut ChainedStructStorage,
16416            next: *mut ffi::WGPUChainedStruct,
16417        ) -> *mut ffi::WGPUChainedStruct {
16418            let _ = self;
16419            let _ = storage;
16420            next
16421        }
16422    }
16423    #[allow(dead_code)]
16424    pub enum RenderPassDescriptorExtension {
16425        DawnRenderPassSampleCount(DawnRenderPassSampleCount),
16426        RenderPassDescriptorResolveRect(RenderPassDescriptorResolveRect),
16427        RenderPassMaxDrawCount(RenderPassMaxDrawCount),
16428        RenderPassPixelLocalStorage(RenderPassPixelLocalStorage),
16429        RenderPassRenderAreaRect(RenderPassRenderAreaRect),
16430    }
16431    impl std::convert::From<DawnRenderPassSampleCount>
16432    for RenderPassDescriptorExtension {
16433        fn from(ext: DawnRenderPassSampleCount) -> Self {
16434            RenderPassDescriptorExtension::DawnRenderPassSampleCount(ext)
16435        }
16436    }
16437    impl std::convert::From<RenderPassDescriptorResolveRect>
16438    for RenderPassDescriptorExtension {
16439        fn from(ext: RenderPassDescriptorResolveRect) -> Self {
16440            RenderPassDescriptorExtension::RenderPassDescriptorResolveRect(ext)
16441        }
16442    }
16443    impl std::convert::From<RenderPassMaxDrawCount> for RenderPassDescriptorExtension {
16444        fn from(ext: RenderPassMaxDrawCount) -> Self {
16445            RenderPassDescriptorExtension::RenderPassMaxDrawCount(ext)
16446        }
16447    }
16448    impl std::convert::From<RenderPassPixelLocalStorage>
16449    for RenderPassDescriptorExtension {
16450        fn from(ext: RenderPassPixelLocalStorage) -> Self {
16451            RenderPassDescriptorExtension::RenderPassPixelLocalStorage(ext)
16452        }
16453    }
16454    impl std::convert::From<RenderPassRenderAreaRect> for RenderPassDescriptorExtension {
16455        fn from(ext: RenderPassRenderAreaRect) -> Self {
16456            RenderPassDescriptorExtension::RenderPassRenderAreaRect(ext)
16457        }
16458    }
16459    impl RenderPassDescriptorExtension {
16460        pub(crate) fn push_chain(
16461            &self,
16462            storage: &mut ChainedStructStorage,
16463            next: *mut ffi::WGPUChainedStruct,
16464        ) -> *mut ffi::WGPUChainedStruct {
16465            match self {
16466                RenderPassDescriptorExtension::DawnRenderPassSampleCount(value) => {
16467                    let (mut raw, storage_value) = value.to_ffi();
16468                    raw.chain.sType = SType::DawnRenderPassSampleCount.into();
16469                    raw.chain.next = next;
16470                    storage.push_storage(storage_value);
16471                    let raw_ptr = storage.push_value_mut(raw);
16472                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16473                }
16474                RenderPassDescriptorExtension::RenderPassDescriptorResolveRect(
16475                    value,
16476                ) => {
16477                    let (mut raw, storage_value) = value.to_ffi();
16478                    raw.chain.sType = SType::RenderPassDescriptorResolveRect.into();
16479                    raw.chain.next = next;
16480                    storage.push_storage(storage_value);
16481                    let raw_ptr = storage.push_value_mut(raw);
16482                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16483                }
16484                RenderPassDescriptorExtension::RenderPassMaxDrawCount(value) => {
16485                    let (mut raw, storage_value) = value.to_ffi();
16486                    raw.chain.sType = SType::RenderPassMaxDrawCount.into();
16487                    raw.chain.next = next;
16488                    storage.push_storage(storage_value);
16489                    let raw_ptr = storage.push_value_mut(raw);
16490                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16491                }
16492                RenderPassDescriptorExtension::RenderPassPixelLocalStorage(value) => {
16493                    let (mut raw, storage_value) = value.to_ffi();
16494                    raw.chain.sType = SType::RenderPassPixelLocalStorage.into();
16495                    raw.chain.next = next;
16496                    storage.push_storage(storage_value);
16497                    let raw_ptr = storage.push_value_mut(raw);
16498                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16499                }
16500                RenderPassDescriptorExtension::RenderPassRenderAreaRect(value) => {
16501                    let (mut raw, storage_value) = value.to_ffi();
16502                    raw.chain.sType = SType::RenderPassRenderAreaRect.into();
16503                    raw.chain.next = next;
16504                    storage.push_storage(storage_value);
16505                    let raw_ptr = storage.push_value_mut(raw);
16506                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16507                }
16508            }
16509        }
16510    }
16511    #[allow(dead_code)]
16512    pub enum RenderPassStorageAttachmentExtension {}
16513    impl RenderPassStorageAttachmentExtension {
16514        pub(crate) fn push_chain(
16515            &self,
16516            storage: &mut ChainedStructStorage,
16517            next: *mut ffi::WGPUChainedStruct,
16518        ) -> *mut ffi::WGPUChainedStruct {
16519            let _ = self;
16520            let _ = storage;
16521            next
16522        }
16523    }
16524    #[allow(dead_code)]
16525    pub enum RenderPipelineDescriptorExtension {}
16526    impl RenderPipelineDescriptorExtension {
16527        pub(crate) fn push_chain(
16528            &self,
16529            storage: &mut ChainedStructStorage,
16530            next: *mut ffi::WGPUChainedStruct,
16531        ) -> *mut ffi::WGPUChainedStruct {
16532            let _ = self;
16533            let _ = storage;
16534            next
16535        }
16536    }
16537    #[allow(dead_code)]
16538    pub enum RequestAdapterOptionsExtension {
16539        DawnTogglesDescriptor(DawnTogglesDescriptor),
16540        RequestAdapterWebGPUBackendOptions(RequestAdapterWebGPUBackendOptions),
16541        RequestAdapterWebXROptions(RequestAdapterWebXROptions),
16542    }
16543    impl std::convert::From<DawnTogglesDescriptor> for RequestAdapterOptionsExtension {
16544        fn from(ext: DawnTogglesDescriptor) -> Self {
16545            RequestAdapterOptionsExtension::DawnTogglesDescriptor(ext)
16546        }
16547    }
16548    impl std::convert::From<RequestAdapterWebGPUBackendOptions>
16549    for RequestAdapterOptionsExtension {
16550        fn from(ext: RequestAdapterWebGPUBackendOptions) -> Self {
16551            RequestAdapterOptionsExtension::RequestAdapterWebGPUBackendOptions(ext)
16552        }
16553    }
16554    impl std::convert::From<RequestAdapterWebXROptions>
16555    for RequestAdapterOptionsExtension {
16556        fn from(ext: RequestAdapterWebXROptions) -> Self {
16557            RequestAdapterOptionsExtension::RequestAdapterWebXROptions(ext)
16558        }
16559    }
16560    impl RequestAdapterOptionsExtension {
16561        pub(crate) fn push_chain(
16562            &self,
16563            storage: &mut ChainedStructStorage,
16564            next: *mut ffi::WGPUChainedStruct,
16565        ) -> *mut ffi::WGPUChainedStruct {
16566            match self {
16567                RequestAdapterOptionsExtension::DawnTogglesDescriptor(value) => {
16568                    let (mut raw, storage_value) = value.to_ffi();
16569                    raw.chain.sType = SType::DawnTogglesDescriptor.into();
16570                    raw.chain.next = next;
16571                    storage.push_storage(storage_value);
16572                    let raw_ptr = storage.push_value_mut(raw);
16573                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16574                }
16575                RequestAdapterOptionsExtension::RequestAdapterWebGPUBackendOptions(
16576                    value,
16577                ) => {
16578                    let (mut raw, storage_value) = value.to_ffi();
16579                    raw.chain.sType = SType::RequestAdapterWebGPUBackendOptions.into();
16580                    raw.chain.next = next;
16581                    storage.push_storage(storage_value);
16582                    let raw_ptr = storage.push_value_mut(raw);
16583                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16584                }
16585                RequestAdapterOptionsExtension::RequestAdapterWebXROptions(value) => {
16586                    let (mut raw, storage_value) = value.to_ffi();
16587                    raw.chain.sType = SType::RequestAdapterWebXROptions.into();
16588                    raw.chain.next = next;
16589                    storage.push_storage(storage_value);
16590                    let raw_ptr = storage.push_value_mut(raw);
16591                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16592                }
16593            }
16594        }
16595    }
16596    #[allow(dead_code)]
16597    pub enum ResourceTableDescriptorExtension {}
16598    impl ResourceTableDescriptorExtension {
16599        pub(crate) fn push_chain(
16600            &self,
16601            storage: &mut ChainedStructStorage,
16602            next: *mut ffi::WGPUChainedStruct,
16603        ) -> *mut ffi::WGPUChainedStruct {
16604            let _ = self;
16605            let _ = storage;
16606            next
16607        }
16608    }
16609    #[allow(dead_code)]
16610    pub enum SamplerBindingLayoutExtension {}
16611    impl SamplerBindingLayoutExtension {
16612        pub(crate) fn push_chain(
16613            &self,
16614            storage: &mut ChainedStructStorage,
16615            next: *mut ffi::WGPUChainedStruct,
16616        ) -> *mut ffi::WGPUChainedStruct {
16617            let _ = self;
16618            let _ = storage;
16619            next
16620        }
16621    }
16622    #[allow(dead_code)]
16623    pub enum SamplerDescriptorExtension {
16624        YCbCrVkDescriptor(YCbCrVkDescriptor),
16625    }
16626    impl std::convert::From<YCbCrVkDescriptor> for SamplerDescriptorExtension {
16627        fn from(ext: YCbCrVkDescriptor) -> Self {
16628            SamplerDescriptorExtension::YCbCrVkDescriptor(ext)
16629        }
16630    }
16631    impl SamplerDescriptorExtension {
16632        pub(crate) fn push_chain(
16633            &self,
16634            storage: &mut ChainedStructStorage,
16635            next: *mut ffi::WGPUChainedStruct,
16636        ) -> *mut ffi::WGPUChainedStruct {
16637            match self {
16638                SamplerDescriptorExtension::YCbCrVkDescriptor(value) => {
16639                    let (mut raw, storage_value) = value.to_ffi();
16640                    raw.chain.sType = SType::YCbCrVkDescriptor.into();
16641                    raw.chain.next = next;
16642                    storage.push_storage(storage_value);
16643                    let raw_ptr = storage.push_value_mut(raw);
16644                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16645                }
16646            }
16647        }
16648    }
16649    #[allow(dead_code)]
16650    pub enum ShaderModuleDescriptorExtension {
16651        DawnShaderModuleSPIRVOptionsDescriptor(DawnShaderModuleSPIRVOptionsDescriptor),
16652        ShaderModuleCompilationOptions(ShaderModuleCompilationOptions),
16653        ShaderSourceSPIRV(ShaderSourceSPIRV),
16654        ShaderSourceWGSL(ShaderSourceWGSL),
16655    }
16656    impl std::convert::From<DawnShaderModuleSPIRVOptionsDescriptor>
16657    for ShaderModuleDescriptorExtension {
16658        fn from(ext: DawnShaderModuleSPIRVOptionsDescriptor) -> Self {
16659            ShaderModuleDescriptorExtension::DawnShaderModuleSPIRVOptionsDescriptor(ext)
16660        }
16661    }
16662    impl std::convert::From<ShaderModuleCompilationOptions>
16663    for ShaderModuleDescriptorExtension {
16664        fn from(ext: ShaderModuleCompilationOptions) -> Self {
16665            ShaderModuleDescriptorExtension::ShaderModuleCompilationOptions(ext)
16666        }
16667    }
16668    impl std::convert::From<ShaderSourceSPIRV> for ShaderModuleDescriptorExtension {
16669        fn from(ext: ShaderSourceSPIRV) -> Self {
16670            ShaderModuleDescriptorExtension::ShaderSourceSPIRV(ext)
16671        }
16672    }
16673    impl std::convert::From<ShaderSourceWGSL> for ShaderModuleDescriptorExtension {
16674        fn from(ext: ShaderSourceWGSL) -> Self {
16675            ShaderModuleDescriptorExtension::ShaderSourceWGSL(ext)
16676        }
16677    }
16678    impl ShaderModuleDescriptorExtension {
16679        pub(crate) fn push_chain(
16680            &self,
16681            storage: &mut ChainedStructStorage,
16682            next: *mut ffi::WGPUChainedStruct,
16683        ) -> *mut ffi::WGPUChainedStruct {
16684            match self {
16685                ShaderModuleDescriptorExtension::DawnShaderModuleSPIRVOptionsDescriptor(
16686                    value,
16687                ) => {
16688                    let (mut raw, storage_value) = value.to_ffi();
16689                    raw.chain.sType = SType::DawnShaderModuleSPIRVOptionsDescriptor
16690                        .into();
16691                    raw.chain.next = next;
16692                    storage.push_storage(storage_value);
16693                    let raw_ptr = storage.push_value_mut(raw);
16694                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16695                }
16696                ShaderModuleDescriptorExtension::ShaderModuleCompilationOptions(
16697                    value,
16698                ) => {
16699                    let (mut raw, storage_value) = value.to_ffi();
16700                    raw.chain.sType = SType::ShaderModuleCompilationOptions.into();
16701                    raw.chain.next = next;
16702                    storage.push_storage(storage_value);
16703                    let raw_ptr = storage.push_value_mut(raw);
16704                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16705                }
16706                ShaderModuleDescriptorExtension::ShaderSourceSPIRV(value) => {
16707                    let (mut raw, storage_value) = value.to_ffi();
16708                    raw.chain.sType = SType::ShaderSourceSPIRV.into();
16709                    raw.chain.next = next;
16710                    storage.push_storage(storage_value);
16711                    let raw_ptr = storage.push_value_mut(raw);
16712                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16713                }
16714                ShaderModuleDescriptorExtension::ShaderSourceWGSL(value) => {
16715                    let (mut raw, storage_value) = value.to_ffi();
16716                    raw.chain.sType = SType::ShaderSourceWGSL.into();
16717                    raw.chain.next = next;
16718                    storage.push_storage(storage_value);
16719                    let raw_ptr = storage.push_value_mut(raw);
16720                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16721                }
16722            }
16723        }
16724    }
16725    #[allow(dead_code)]
16726    pub enum SharedBufferMemoryBeginAccessDescriptorExtension {}
16727    impl SharedBufferMemoryBeginAccessDescriptorExtension {
16728        pub(crate) fn push_chain(
16729            &self,
16730            storage: &mut ChainedStructStorage,
16731            next: *mut ffi::WGPUChainedStruct,
16732        ) -> *mut ffi::WGPUChainedStruct {
16733            let _ = self;
16734            let _ = storage;
16735            next
16736        }
16737    }
16738    #[allow(dead_code)]
16739    pub enum SharedBufferMemoryDescriptorExtension {
16740        SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor(
16741            SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
16742        ),
16743    }
16744    impl std::convert::From<
16745        SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
16746    > for SharedBufferMemoryDescriptorExtension {
16747        fn from(
16748            ext: SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
16749        ) -> Self {
16750            SharedBufferMemoryDescriptorExtension::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor(
16751                ext,
16752            )
16753        }
16754    }
16755    impl SharedBufferMemoryDescriptorExtension {
16756        pub(crate) fn push_chain(
16757            &self,
16758            storage: &mut ChainedStructStorage,
16759            next: *mut ffi::WGPUChainedStruct,
16760        ) -> *mut ffi::WGPUChainedStruct {
16761            match self {
16762                SharedBufferMemoryDescriptorExtension::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor(
16763                    value,
16764                ) => {
16765                    let (mut raw, storage_value) = value.to_ffi();
16766                    raw.chain.sType = SType::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor
16767                        .into();
16768                    raw.chain.next = next;
16769                    storage.push_storage(storage_value);
16770                    let raw_ptr = storage.push_value_mut(raw);
16771                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16772                }
16773            }
16774        }
16775    }
16776    #[allow(dead_code)]
16777    pub enum SharedBufferMemoryEndAccessStateExtension {}
16778    impl SharedBufferMemoryEndAccessStateExtension {
16779        pub(crate) fn push_chain(
16780            &self,
16781            storage: &mut ChainedStructStorage,
16782            next: *mut ffi::WGPUChainedStruct,
16783        ) -> *mut ffi::WGPUChainedStruct {
16784            let _ = self;
16785            let _ = storage;
16786            next
16787        }
16788    }
16789    #[allow(dead_code)]
16790    pub enum SharedBufferMemoryPropertiesExtension {}
16791    impl SharedBufferMemoryPropertiesExtension {
16792        pub(crate) fn push_chain(
16793            &self,
16794            storage: &mut ChainedStructStorage,
16795            next: *mut ffi::WGPUChainedStruct,
16796        ) -> *mut ffi::WGPUChainedStruct {
16797            let _ = self;
16798            let _ = storage;
16799            next
16800        }
16801    }
16802    #[allow(dead_code)]
16803    pub enum SharedFenceDescriptorExtension {
16804        SharedFenceDXGISharedHandleDescriptor(SharedFenceDXGISharedHandleDescriptor),
16805        SharedFenceEGLSyncDescriptor(SharedFenceEGLSyncDescriptor),
16806        SharedFenceMTLSharedEventDescriptor(SharedFenceMTLSharedEventDescriptor),
16807        SharedFenceSyncFDDescriptor(SharedFenceSyncFDDescriptor),
16808        SharedFenceVkSemaphoreOpaqueFDDescriptor(
16809            SharedFenceVkSemaphoreOpaqueFDDescriptor,
16810        ),
16811        SharedFenceVkSemaphoreZirconHandleDescriptor(
16812            SharedFenceVkSemaphoreZirconHandleDescriptor,
16813        ),
16814    }
16815    impl std::convert::From<SharedFenceDXGISharedHandleDescriptor>
16816    for SharedFenceDescriptorExtension {
16817        fn from(ext: SharedFenceDXGISharedHandleDescriptor) -> Self {
16818            SharedFenceDescriptorExtension::SharedFenceDXGISharedHandleDescriptor(ext)
16819        }
16820    }
16821    impl std::convert::From<SharedFenceEGLSyncDescriptor>
16822    for SharedFenceDescriptorExtension {
16823        fn from(ext: SharedFenceEGLSyncDescriptor) -> Self {
16824            SharedFenceDescriptorExtension::SharedFenceEGLSyncDescriptor(ext)
16825        }
16826    }
16827    impl std::convert::From<SharedFenceMTLSharedEventDescriptor>
16828    for SharedFenceDescriptorExtension {
16829        fn from(ext: SharedFenceMTLSharedEventDescriptor) -> Self {
16830            SharedFenceDescriptorExtension::SharedFenceMTLSharedEventDescriptor(ext)
16831        }
16832    }
16833    impl std::convert::From<SharedFenceSyncFDDescriptor>
16834    for SharedFenceDescriptorExtension {
16835        fn from(ext: SharedFenceSyncFDDescriptor) -> Self {
16836            SharedFenceDescriptorExtension::SharedFenceSyncFDDescriptor(ext)
16837        }
16838    }
16839    impl std::convert::From<SharedFenceVkSemaphoreOpaqueFDDescriptor>
16840    for SharedFenceDescriptorExtension {
16841        fn from(ext: SharedFenceVkSemaphoreOpaqueFDDescriptor) -> Self {
16842            SharedFenceDescriptorExtension::SharedFenceVkSemaphoreOpaqueFDDescriptor(ext)
16843        }
16844    }
16845    impl std::convert::From<SharedFenceVkSemaphoreZirconHandleDescriptor>
16846    for SharedFenceDescriptorExtension {
16847        fn from(ext: SharedFenceVkSemaphoreZirconHandleDescriptor) -> Self {
16848            SharedFenceDescriptorExtension::SharedFenceVkSemaphoreZirconHandleDescriptor(
16849                ext,
16850            )
16851        }
16852    }
16853    impl SharedFenceDescriptorExtension {
16854        pub(crate) fn push_chain(
16855            &self,
16856            storage: &mut ChainedStructStorage,
16857            next: *mut ffi::WGPUChainedStruct,
16858        ) -> *mut ffi::WGPUChainedStruct {
16859            match self {
16860                SharedFenceDescriptorExtension::SharedFenceDXGISharedHandleDescriptor(
16861                    value,
16862                ) => {
16863                    let (mut raw, storage_value) = value.to_ffi();
16864                    raw.chain.sType = SType::SharedFenceDXGISharedHandleDescriptor
16865                        .into();
16866                    raw.chain.next = next;
16867                    storage.push_storage(storage_value);
16868                    let raw_ptr = storage.push_value_mut(raw);
16869                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16870                }
16871                SharedFenceDescriptorExtension::SharedFenceEGLSyncDescriptor(value) => {
16872                    let (mut raw, storage_value) = value.to_ffi();
16873                    raw.chain.sType = SType::SharedFenceEGLSyncDescriptor.into();
16874                    raw.chain.next = next;
16875                    storage.push_storage(storage_value);
16876                    let raw_ptr = storage.push_value_mut(raw);
16877                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16878                }
16879                SharedFenceDescriptorExtension::SharedFenceMTLSharedEventDescriptor(
16880                    value,
16881                ) => {
16882                    let (mut raw, storage_value) = value.to_ffi();
16883                    raw.chain.sType = SType::SharedFenceMTLSharedEventDescriptor.into();
16884                    raw.chain.next = next;
16885                    storage.push_storage(storage_value);
16886                    let raw_ptr = storage.push_value_mut(raw);
16887                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16888                }
16889                SharedFenceDescriptorExtension::SharedFenceSyncFDDescriptor(value) => {
16890                    let (mut raw, storage_value) = value.to_ffi();
16891                    raw.chain.sType = SType::SharedFenceSyncFDDescriptor.into();
16892                    raw.chain.next = next;
16893                    storage.push_storage(storage_value);
16894                    let raw_ptr = storage.push_value_mut(raw);
16895                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16896                }
16897                SharedFenceDescriptorExtension::SharedFenceVkSemaphoreOpaqueFDDescriptor(
16898                    value,
16899                ) => {
16900                    let (mut raw, storage_value) = value.to_ffi();
16901                    raw.chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDDescriptor
16902                        .into();
16903                    raw.chain.next = next;
16904                    storage.push_storage(storage_value);
16905                    let raw_ptr = storage.push_value_mut(raw);
16906                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16907                }
16908                SharedFenceDescriptorExtension::SharedFenceVkSemaphoreZirconHandleDescriptor(
16909                    value,
16910                ) => {
16911                    let (mut raw, storage_value) = value.to_ffi();
16912                    raw.chain.sType = SType::SharedFenceVkSemaphoreZirconHandleDescriptor
16913                        .into();
16914                    raw.chain.next = next;
16915                    storage.push_storage(storage_value);
16916                    let raw_ptr = storage.push_value_mut(raw);
16917                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16918                }
16919            }
16920        }
16921    }
16922    #[allow(dead_code)]
16923    pub enum SharedFenceExportInfoExtension {
16924        SharedFenceDXGISharedHandleExportInfo(SharedFenceDXGISharedHandleExportInfo),
16925        SharedFenceEGLSyncExportInfo(SharedFenceEGLSyncExportInfo),
16926        SharedFenceMTLSharedEventExportInfo(SharedFenceMTLSharedEventExportInfo),
16927        SharedFenceSyncFDExportInfo(SharedFenceSyncFDExportInfo),
16928        SharedFenceVkSemaphoreOpaqueFDExportInfo(
16929            SharedFenceVkSemaphoreOpaqueFDExportInfo,
16930        ),
16931        SharedFenceVkSemaphoreZirconHandleExportInfo(
16932            SharedFenceVkSemaphoreZirconHandleExportInfo,
16933        ),
16934    }
16935    impl std::convert::From<SharedFenceDXGISharedHandleExportInfo>
16936    for SharedFenceExportInfoExtension {
16937        fn from(ext: SharedFenceDXGISharedHandleExportInfo) -> Self {
16938            SharedFenceExportInfoExtension::SharedFenceDXGISharedHandleExportInfo(ext)
16939        }
16940    }
16941    impl std::convert::From<SharedFenceEGLSyncExportInfo>
16942    for SharedFenceExportInfoExtension {
16943        fn from(ext: SharedFenceEGLSyncExportInfo) -> Self {
16944            SharedFenceExportInfoExtension::SharedFenceEGLSyncExportInfo(ext)
16945        }
16946    }
16947    impl std::convert::From<SharedFenceMTLSharedEventExportInfo>
16948    for SharedFenceExportInfoExtension {
16949        fn from(ext: SharedFenceMTLSharedEventExportInfo) -> Self {
16950            SharedFenceExportInfoExtension::SharedFenceMTLSharedEventExportInfo(ext)
16951        }
16952    }
16953    impl std::convert::From<SharedFenceSyncFDExportInfo>
16954    for SharedFenceExportInfoExtension {
16955        fn from(ext: SharedFenceSyncFDExportInfo) -> Self {
16956            SharedFenceExportInfoExtension::SharedFenceSyncFDExportInfo(ext)
16957        }
16958    }
16959    impl std::convert::From<SharedFenceVkSemaphoreOpaqueFDExportInfo>
16960    for SharedFenceExportInfoExtension {
16961        fn from(ext: SharedFenceVkSemaphoreOpaqueFDExportInfo) -> Self {
16962            SharedFenceExportInfoExtension::SharedFenceVkSemaphoreOpaqueFDExportInfo(ext)
16963        }
16964    }
16965    impl std::convert::From<SharedFenceVkSemaphoreZirconHandleExportInfo>
16966    for SharedFenceExportInfoExtension {
16967        fn from(ext: SharedFenceVkSemaphoreZirconHandleExportInfo) -> Self {
16968            SharedFenceExportInfoExtension::SharedFenceVkSemaphoreZirconHandleExportInfo(
16969                ext,
16970            )
16971        }
16972    }
16973    impl SharedFenceExportInfoExtension {
16974        pub(crate) fn push_chain(
16975            &self,
16976            storage: &mut ChainedStructStorage,
16977            next: *mut ffi::WGPUChainedStruct,
16978        ) -> *mut ffi::WGPUChainedStruct {
16979            match self {
16980                SharedFenceExportInfoExtension::SharedFenceDXGISharedHandleExportInfo(
16981                    value,
16982                ) => {
16983                    let (mut raw, storage_value) = value.to_ffi();
16984                    raw.chain.sType = SType::SharedFenceDXGISharedHandleExportInfo
16985                        .into();
16986                    raw.chain.next = next;
16987                    storage.push_storage(storage_value);
16988                    let raw_ptr = storage.push_value_mut(raw);
16989                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16990                }
16991                SharedFenceExportInfoExtension::SharedFenceEGLSyncExportInfo(value) => {
16992                    let (mut raw, storage_value) = value.to_ffi();
16993                    raw.chain.sType = SType::SharedFenceEGLSyncExportInfo.into();
16994                    raw.chain.next = next;
16995                    storage.push_storage(storage_value);
16996                    let raw_ptr = storage.push_value_mut(raw);
16997                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16998                }
16999                SharedFenceExportInfoExtension::SharedFenceMTLSharedEventExportInfo(
17000                    value,
17001                ) => {
17002                    let (mut raw, storage_value) = value.to_ffi();
17003                    raw.chain.sType = SType::SharedFenceMTLSharedEventExportInfo.into();
17004                    raw.chain.next = next;
17005                    storage.push_storage(storage_value);
17006                    let raw_ptr = storage.push_value_mut(raw);
17007                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17008                }
17009                SharedFenceExportInfoExtension::SharedFenceSyncFDExportInfo(value) => {
17010                    let (mut raw, storage_value) = value.to_ffi();
17011                    raw.chain.sType = SType::SharedFenceSyncFDExportInfo.into();
17012                    raw.chain.next = next;
17013                    storage.push_storage(storage_value);
17014                    let raw_ptr = storage.push_value_mut(raw);
17015                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17016                }
17017                SharedFenceExportInfoExtension::SharedFenceVkSemaphoreOpaqueFDExportInfo(
17018                    value,
17019                ) => {
17020                    let (mut raw, storage_value) = value.to_ffi();
17021                    raw.chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDExportInfo
17022                        .into();
17023                    raw.chain.next = next;
17024                    storage.push_storage(storage_value);
17025                    let raw_ptr = storage.push_value_mut(raw);
17026                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17027                }
17028                SharedFenceExportInfoExtension::SharedFenceVkSemaphoreZirconHandleExportInfo(
17029                    value,
17030                ) => {
17031                    let (mut raw, storage_value) = value.to_ffi();
17032                    raw.chain.sType = SType::SharedFenceVkSemaphoreZirconHandleExportInfo
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            }
17040        }
17041    }
17042    #[allow(dead_code)]
17043    pub enum SharedTextureMemoryBeginAccessDescriptorExtension {
17044        SharedTextureMemoryD3DSwapchainBeginState(
17045            SharedTextureMemoryD3DSwapchainBeginState,
17046        ),
17047        SharedTextureMemoryD3D11BeginState(SharedTextureMemoryD3D11BeginState),
17048        SharedTextureMemoryVkImageLayoutBeginState(
17049            SharedTextureMemoryVkImageLayoutBeginState,
17050        ),
17051    }
17052    impl std::convert::From<SharedTextureMemoryD3DSwapchainBeginState>
17053    for SharedTextureMemoryBeginAccessDescriptorExtension {
17054        fn from(ext: SharedTextureMemoryD3DSwapchainBeginState) -> Self {
17055            SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3DSwapchainBeginState(
17056                ext,
17057            )
17058        }
17059    }
17060    impl std::convert::From<SharedTextureMemoryD3D11BeginState>
17061    for SharedTextureMemoryBeginAccessDescriptorExtension {
17062        fn from(ext: SharedTextureMemoryD3D11BeginState) -> Self {
17063            SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3D11BeginState(
17064                ext,
17065            )
17066        }
17067    }
17068    impl std::convert::From<SharedTextureMemoryVkImageLayoutBeginState>
17069    for SharedTextureMemoryBeginAccessDescriptorExtension {
17070        fn from(ext: SharedTextureMemoryVkImageLayoutBeginState) -> Self {
17071            SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryVkImageLayoutBeginState(
17072                ext,
17073            )
17074        }
17075    }
17076    impl SharedTextureMemoryBeginAccessDescriptorExtension {
17077        pub(crate) fn push_chain(
17078            &self,
17079            storage: &mut ChainedStructStorage,
17080            next: *mut ffi::WGPUChainedStruct,
17081        ) -> *mut ffi::WGPUChainedStruct {
17082            match self {
17083                SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3DSwapchainBeginState(
17084                    value,
17085                ) => {
17086                    let (mut raw, storage_value) = value.to_ffi();
17087                    raw.chain.sType = SType::SharedTextureMemoryD3DSwapchainBeginState
17088                        .into();
17089                    raw.chain.next = next;
17090                    storage.push_storage(storage_value);
17091                    let raw_ptr = storage.push_value_mut(raw);
17092                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17093                }
17094                SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3D11BeginState(
17095                    value,
17096                ) => {
17097                    let (mut raw, storage_value) = value.to_ffi();
17098                    raw.chain.sType = SType::SharedTextureMemoryD3D11BeginState.into();
17099                    raw.chain.next = next;
17100                    storage.push_storage(storage_value);
17101                    let raw_ptr = storage.push_value_mut(raw);
17102                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17103                }
17104                SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryVkImageLayoutBeginState(
17105                    value,
17106                ) => {
17107                    let (mut raw, storage_value) = value.to_ffi();
17108                    raw.chain.sType = SType::SharedTextureMemoryVkImageLayoutBeginState
17109                        .into();
17110                    raw.chain.next = next;
17111                    storage.push_storage(storage_value);
17112                    let raw_ptr = storage.push_value_mut(raw);
17113                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17114                }
17115            }
17116        }
17117    }
17118    #[allow(dead_code)]
17119    pub enum SharedTextureMemoryDescriptorExtension {
17120        SharedTextureMemoryDXGISharedHandleDescriptor(
17121            SharedTextureMemoryDXGISharedHandleDescriptor,
17122        ),
17123        SharedTextureMemoryEGLImageDescriptor(SharedTextureMemoryEGLImageDescriptor),
17124        SharedTextureMemoryIOSurfaceDescriptor(SharedTextureMemoryIOSurfaceDescriptor),
17125        SharedTextureMemoryAHardwareBufferDescriptor(
17126            SharedTextureMemoryAHardwareBufferDescriptor,
17127        ),
17128        SharedTextureMemoryDmaBufDescriptor(SharedTextureMemoryDmaBufDescriptor),
17129        SharedTextureMemoryOpaqueFDDescriptor(SharedTextureMemoryOpaqueFDDescriptor),
17130        SharedTextureMemoryVkDedicatedAllocationDescriptor(
17131            SharedTextureMemoryVkDedicatedAllocationDescriptor,
17132        ),
17133        SharedTextureMemoryZirconHandleDescriptor(
17134            SharedTextureMemoryZirconHandleDescriptor,
17135        ),
17136    }
17137    impl std::convert::From<SharedTextureMemoryDXGISharedHandleDescriptor>
17138    for SharedTextureMemoryDescriptorExtension {
17139        fn from(ext: SharedTextureMemoryDXGISharedHandleDescriptor) -> Self {
17140            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDXGISharedHandleDescriptor(
17141                ext,
17142            )
17143        }
17144    }
17145    impl std::convert::From<SharedTextureMemoryEGLImageDescriptor>
17146    for SharedTextureMemoryDescriptorExtension {
17147        fn from(ext: SharedTextureMemoryEGLImageDescriptor) -> Self {
17148            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryEGLImageDescriptor(
17149                ext,
17150            )
17151        }
17152    }
17153    impl std::convert::From<SharedTextureMemoryIOSurfaceDescriptor>
17154    for SharedTextureMemoryDescriptorExtension {
17155        fn from(ext: SharedTextureMemoryIOSurfaceDescriptor) -> Self {
17156            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryIOSurfaceDescriptor(
17157                ext,
17158            )
17159        }
17160    }
17161    impl std::convert::From<SharedTextureMemoryAHardwareBufferDescriptor>
17162    for SharedTextureMemoryDescriptorExtension {
17163        fn from(ext: SharedTextureMemoryAHardwareBufferDescriptor) -> Self {
17164            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryAHardwareBufferDescriptor(
17165                ext,
17166            )
17167        }
17168    }
17169    impl std::convert::From<SharedTextureMemoryDmaBufDescriptor>
17170    for SharedTextureMemoryDescriptorExtension {
17171        fn from(ext: SharedTextureMemoryDmaBufDescriptor) -> Self {
17172            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDmaBufDescriptor(
17173                ext,
17174            )
17175        }
17176    }
17177    impl std::convert::From<SharedTextureMemoryOpaqueFDDescriptor>
17178    for SharedTextureMemoryDescriptorExtension {
17179        fn from(ext: SharedTextureMemoryOpaqueFDDescriptor) -> Self {
17180            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryOpaqueFDDescriptor(
17181                ext,
17182            )
17183        }
17184    }
17185    impl std::convert::From<SharedTextureMemoryVkDedicatedAllocationDescriptor>
17186    for SharedTextureMemoryDescriptorExtension {
17187        fn from(ext: SharedTextureMemoryVkDedicatedAllocationDescriptor) -> Self {
17188            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryVkDedicatedAllocationDescriptor(
17189                ext,
17190            )
17191        }
17192    }
17193    impl std::convert::From<SharedTextureMemoryZirconHandleDescriptor>
17194    for SharedTextureMemoryDescriptorExtension {
17195        fn from(ext: SharedTextureMemoryZirconHandleDescriptor) -> Self {
17196            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryZirconHandleDescriptor(
17197                ext,
17198            )
17199        }
17200    }
17201    impl SharedTextureMemoryDescriptorExtension {
17202        pub(crate) fn push_chain(
17203            &self,
17204            storage: &mut ChainedStructStorage,
17205            next: *mut ffi::WGPUChainedStruct,
17206        ) -> *mut ffi::WGPUChainedStruct {
17207            match self {
17208                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDXGISharedHandleDescriptor(
17209                    value,
17210                ) => {
17211                    let (mut raw, storage_value) = value.to_ffi();
17212                    raw.chain.sType = SType::SharedTextureMemoryDXGISharedHandleDescriptor
17213                        .into();
17214                    raw.chain.next = next;
17215                    storage.push_storage(storage_value);
17216                    let raw_ptr = storage.push_value_mut(raw);
17217                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17218                }
17219                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryEGLImageDescriptor(
17220                    value,
17221                ) => {
17222                    let (mut raw, storage_value) = value.to_ffi();
17223                    raw.chain.sType = SType::SharedTextureMemoryEGLImageDescriptor
17224                        .into();
17225                    raw.chain.next = next;
17226                    storage.push_storage(storage_value);
17227                    let raw_ptr = storage.push_value_mut(raw);
17228                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17229                }
17230                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryIOSurfaceDescriptor(
17231                    value,
17232                ) => {
17233                    let (mut raw, storage_value) = value.to_ffi();
17234                    raw.chain.sType = SType::SharedTextureMemoryIOSurfaceDescriptor
17235                        .into();
17236                    raw.chain.next = next;
17237                    storage.push_storage(storage_value);
17238                    let raw_ptr = storage.push_value_mut(raw);
17239                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17240                }
17241                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryAHardwareBufferDescriptor(
17242                    value,
17243                ) => {
17244                    let (mut raw, storage_value) = value.to_ffi();
17245                    raw.chain.sType = SType::SharedTextureMemoryAHardwareBufferDescriptor
17246                        .into();
17247                    raw.chain.next = next;
17248                    storage.push_storage(storage_value);
17249                    let raw_ptr = storage.push_value_mut(raw);
17250                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17251                }
17252                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDmaBufDescriptor(
17253                    value,
17254                ) => {
17255                    let (mut raw, storage_value) = value.to_ffi();
17256                    raw.chain.sType = SType::SharedTextureMemoryDmaBufDescriptor.into();
17257                    raw.chain.next = next;
17258                    storage.push_storage(storage_value);
17259                    let raw_ptr = storage.push_value_mut(raw);
17260                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17261                }
17262                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryOpaqueFDDescriptor(
17263                    value,
17264                ) => {
17265                    let (mut raw, storage_value) = value.to_ffi();
17266                    raw.chain.sType = SType::SharedTextureMemoryOpaqueFDDescriptor
17267                        .into();
17268                    raw.chain.next = next;
17269                    storage.push_storage(storage_value);
17270                    let raw_ptr = storage.push_value_mut(raw);
17271                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17272                }
17273                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryVkDedicatedAllocationDescriptor(
17274                    value,
17275                ) => {
17276                    let (mut raw, storage_value) = value.to_ffi();
17277                    raw.chain.sType = SType::SharedTextureMemoryVkDedicatedAllocationDescriptor
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                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryZirconHandleDescriptor(
17285                    value,
17286                ) => {
17287                    let (mut raw, storage_value) = value.to_ffi();
17288                    raw.chain.sType = SType::SharedTextureMemoryZirconHandleDescriptor
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 SharedTextureMemoryEndAccessStateExtension {
17300        SharedTextureMemoryMetalEndAccessState(SharedTextureMemoryMetalEndAccessState),
17301        SharedTextureMemoryVkImageLayoutEndState(
17302            SharedTextureMemoryVkImageLayoutEndState,
17303        ),
17304    }
17305    impl std::convert::From<SharedTextureMemoryMetalEndAccessState>
17306    for SharedTextureMemoryEndAccessStateExtension {
17307        fn from(ext: SharedTextureMemoryMetalEndAccessState) -> Self {
17308            SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryMetalEndAccessState(
17309                ext,
17310            )
17311        }
17312    }
17313    impl std::convert::From<SharedTextureMemoryVkImageLayoutEndState>
17314    for SharedTextureMemoryEndAccessStateExtension {
17315        fn from(ext: SharedTextureMemoryVkImageLayoutEndState) -> Self {
17316            SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryVkImageLayoutEndState(
17317                ext,
17318            )
17319        }
17320    }
17321    impl SharedTextureMemoryEndAccessStateExtension {
17322        pub(crate) fn push_chain(
17323            &self,
17324            storage: &mut ChainedStructStorage,
17325            next: *mut ffi::WGPUChainedStruct,
17326        ) -> *mut ffi::WGPUChainedStruct {
17327            match self {
17328                SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryMetalEndAccessState(
17329                    value,
17330                ) => {
17331                    let (mut raw, storage_value) = value.to_ffi();
17332                    raw.chain.sType = SType::SharedTextureMemoryMetalEndAccessState
17333                        .into();
17334                    raw.chain.next = next;
17335                    storage.push_storage(storage_value);
17336                    let raw_ptr = storage.push_value_mut(raw);
17337                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17338                }
17339                SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryVkImageLayoutEndState(
17340                    value,
17341                ) => {
17342                    let (mut raw, storage_value) = value.to_ffi();
17343                    raw.chain.sType = SType::SharedTextureMemoryVkImageLayoutEndState
17344                        .into();
17345                    raw.chain.next = next;
17346                    storage.push_storage(storage_value);
17347                    let raw_ptr = storage.push_value_mut(raw);
17348                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17349                }
17350            }
17351        }
17352    }
17353    #[allow(dead_code)]
17354    pub enum SharedTextureMemoryPropertiesExtension {
17355        SharedTextureMemoryAHardwareBufferProperties(
17356            SharedTextureMemoryAHardwareBufferProperties,
17357        ),
17358    }
17359    impl std::convert::From<SharedTextureMemoryAHardwareBufferProperties>
17360    for SharedTextureMemoryPropertiesExtension {
17361        fn from(ext: SharedTextureMemoryAHardwareBufferProperties) -> Self {
17362            SharedTextureMemoryPropertiesExtension::SharedTextureMemoryAHardwareBufferProperties(
17363                ext,
17364            )
17365        }
17366    }
17367    impl SharedTextureMemoryPropertiesExtension {
17368        pub(crate) fn push_chain(
17369            &self,
17370            storage: &mut ChainedStructStorage,
17371            next: *mut ffi::WGPUChainedStruct,
17372        ) -> *mut ffi::WGPUChainedStruct {
17373            match self {
17374                SharedTextureMemoryPropertiesExtension::SharedTextureMemoryAHardwareBufferProperties(
17375                    value,
17376                ) => {
17377                    let (mut raw, storage_value) = value.to_ffi();
17378                    raw.chain.sType = SType::SharedTextureMemoryAHardwareBufferProperties
17379                        .into();
17380                    raw.chain.next = next;
17381                    storage.push_storage(storage_value);
17382                    let raw_ptr = storage.push_value_mut(raw);
17383                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17384                }
17385            }
17386        }
17387    }
17388    #[allow(dead_code)]
17389    pub enum StorageTextureBindingLayoutExtension {}
17390    impl StorageTextureBindingLayoutExtension {
17391        pub(crate) fn push_chain(
17392            &self,
17393            storage: &mut ChainedStructStorage,
17394            next: *mut ffi::WGPUChainedStruct,
17395        ) -> *mut ffi::WGPUChainedStruct {
17396            let _ = self;
17397            let _ = storage;
17398            next
17399        }
17400    }
17401    #[allow(dead_code)]
17402    pub enum SurfaceCapabilitiesExtension {}
17403    impl SurfaceCapabilitiesExtension {
17404        pub(crate) fn push_chain(
17405            &self,
17406            storage: &mut ChainedStructStorage,
17407            next: *mut ffi::WGPUChainedStruct,
17408        ) -> *mut ffi::WGPUChainedStruct {
17409            let _ = self;
17410            let _ = storage;
17411            next
17412        }
17413    }
17414    #[allow(dead_code)]
17415    pub enum SurfaceConfigurationExtension {}
17416    impl SurfaceConfigurationExtension {
17417        pub(crate) fn push_chain(
17418            &self,
17419            storage: &mut ChainedStructStorage,
17420            next: *mut ffi::WGPUChainedStruct,
17421        ) -> *mut ffi::WGPUChainedStruct {
17422            let _ = self;
17423            let _ = storage;
17424            next
17425        }
17426    }
17427    #[allow(dead_code)]
17428    pub enum SurfaceDescriptorExtension {
17429        SurfaceColorManagement(SurfaceColorManagement),
17430        SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17431            SurfaceDescriptorFromWindowsUWPSwapChainPanel,
17432        ),
17433        SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17434            SurfaceDescriptorFromWindowsWinUISwapChainPanel,
17435        ),
17436        SurfaceDescriptorFromWindowsCoreWindow(SurfaceDescriptorFromWindowsCoreWindow),
17437        SurfaceSourceXCBWindow(SurfaceSourceXCBWindow),
17438        SurfaceSourceAndroidNativeWindow(SurfaceSourceAndroidNativeWindow),
17439        SurfaceSourceMetalLayer(SurfaceSourceMetalLayer),
17440        SurfaceSourceWaylandSurface(SurfaceSourceWaylandSurface),
17441        SurfaceSourceWindowsHWND(SurfaceSourceWindowsHWND),
17442        SurfaceSourceXlibWindow(SurfaceSourceXlibWindow),
17443    }
17444    impl std::convert::From<SurfaceColorManagement> for SurfaceDescriptorExtension {
17445        fn from(ext: SurfaceColorManagement) -> Self {
17446            SurfaceDescriptorExtension::SurfaceColorManagement(ext)
17447        }
17448    }
17449    impl std::convert::From<SurfaceDescriptorFromWindowsUWPSwapChainPanel>
17450    for SurfaceDescriptorExtension {
17451        fn from(ext: SurfaceDescriptorFromWindowsUWPSwapChainPanel) -> Self {
17452            SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17453                ext,
17454            )
17455        }
17456    }
17457    impl std::convert::From<SurfaceDescriptorFromWindowsWinUISwapChainPanel>
17458    for SurfaceDescriptorExtension {
17459        fn from(ext: SurfaceDescriptorFromWindowsWinUISwapChainPanel) -> Self {
17460            SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17461                ext,
17462            )
17463        }
17464    }
17465    impl std::convert::From<SurfaceDescriptorFromWindowsCoreWindow>
17466    for SurfaceDescriptorExtension {
17467        fn from(ext: SurfaceDescriptorFromWindowsCoreWindow) -> Self {
17468            SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsCoreWindow(ext)
17469        }
17470    }
17471    impl std::convert::From<SurfaceSourceXCBWindow> for SurfaceDescriptorExtension {
17472        fn from(ext: SurfaceSourceXCBWindow) -> Self {
17473            SurfaceDescriptorExtension::SurfaceSourceXCBWindow(ext)
17474        }
17475    }
17476    impl std::convert::From<SurfaceSourceAndroidNativeWindow>
17477    for SurfaceDescriptorExtension {
17478        fn from(ext: SurfaceSourceAndroidNativeWindow) -> Self {
17479            SurfaceDescriptorExtension::SurfaceSourceAndroidNativeWindow(ext)
17480        }
17481    }
17482    impl std::convert::From<SurfaceSourceMetalLayer> for SurfaceDescriptorExtension {
17483        fn from(ext: SurfaceSourceMetalLayer) -> Self {
17484            SurfaceDescriptorExtension::SurfaceSourceMetalLayer(ext)
17485        }
17486    }
17487    impl std::convert::From<SurfaceSourceWaylandSurface> for SurfaceDescriptorExtension {
17488        fn from(ext: SurfaceSourceWaylandSurface) -> Self {
17489            SurfaceDescriptorExtension::SurfaceSourceWaylandSurface(ext)
17490        }
17491    }
17492    impl std::convert::From<SurfaceSourceWindowsHWND> for SurfaceDescriptorExtension {
17493        fn from(ext: SurfaceSourceWindowsHWND) -> Self {
17494            SurfaceDescriptorExtension::SurfaceSourceWindowsHWND(ext)
17495        }
17496    }
17497    impl std::convert::From<SurfaceSourceXlibWindow> for SurfaceDescriptorExtension {
17498        fn from(ext: SurfaceSourceXlibWindow) -> Self {
17499            SurfaceDescriptorExtension::SurfaceSourceXlibWindow(ext)
17500        }
17501    }
17502    impl SurfaceDescriptorExtension {
17503        pub(crate) fn push_chain(
17504            &self,
17505            storage: &mut ChainedStructStorage,
17506            next: *mut ffi::WGPUChainedStruct,
17507        ) -> *mut ffi::WGPUChainedStruct {
17508            match self {
17509                SurfaceDescriptorExtension::SurfaceColorManagement(value) => {
17510                    let (mut raw, storage_value) = value.to_ffi();
17511                    raw.chain.sType = SType::SurfaceColorManagement.into();
17512                    raw.chain.next = next;
17513                    storage.push_storage(storage_value);
17514                    let raw_ptr = storage.push_value_mut(raw);
17515                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17516                }
17517                SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17518                    value,
17519                ) => {
17520                    let (mut raw, storage_value) = value.to_ffi();
17521                    raw.chain.sType = SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel
17522                        .into();
17523                    raw.chain.next = next;
17524                    storage.push_storage(storage_value);
17525                    let raw_ptr = storage.push_value_mut(raw);
17526                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17527                }
17528                SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17529                    value,
17530                ) => {
17531                    let (mut raw, storage_value) = value.to_ffi();
17532                    raw.chain.sType = SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel
17533                        .into();
17534                    raw.chain.next = next;
17535                    storage.push_storage(storage_value);
17536                    let raw_ptr = storage.push_value_mut(raw);
17537                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17538                }
17539                SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsCoreWindow(
17540                    value,
17541                ) => {
17542                    let (mut raw, storage_value) = value.to_ffi();
17543                    raw.chain.sType = SType::SurfaceDescriptorFromWindowsCoreWindow
17544                        .into();
17545                    raw.chain.next = next;
17546                    storage.push_storage(storage_value);
17547                    let raw_ptr = storage.push_value_mut(raw);
17548                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17549                }
17550                SurfaceDescriptorExtension::SurfaceSourceXCBWindow(value) => {
17551                    let (mut raw, storage_value) = value.to_ffi();
17552                    raw.chain.sType = SType::SurfaceSourceXCBWindow.into();
17553                    raw.chain.next = next;
17554                    storage.push_storage(storage_value);
17555                    let raw_ptr = storage.push_value_mut(raw);
17556                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17557                }
17558                SurfaceDescriptorExtension::SurfaceSourceAndroidNativeWindow(value) => {
17559                    let (mut raw, storage_value) = value.to_ffi();
17560                    raw.chain.sType = SType::SurfaceSourceAndroidNativeWindow.into();
17561                    raw.chain.next = next;
17562                    storage.push_storage(storage_value);
17563                    let raw_ptr = storage.push_value_mut(raw);
17564                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17565                }
17566                SurfaceDescriptorExtension::SurfaceSourceMetalLayer(value) => {
17567                    let (mut raw, storage_value) = value.to_ffi();
17568                    raw.chain.sType = SType::SurfaceSourceMetalLayer.into();
17569                    raw.chain.next = next;
17570                    storage.push_storage(storage_value);
17571                    let raw_ptr = storage.push_value_mut(raw);
17572                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17573                }
17574                SurfaceDescriptorExtension::SurfaceSourceWaylandSurface(value) => {
17575                    let (mut raw, storage_value) = value.to_ffi();
17576                    raw.chain.sType = SType::SurfaceSourceWaylandSurface.into();
17577                    raw.chain.next = next;
17578                    storage.push_storage(storage_value);
17579                    let raw_ptr = storage.push_value_mut(raw);
17580                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17581                }
17582                SurfaceDescriptorExtension::SurfaceSourceWindowsHWND(value) => {
17583                    let (mut raw, storage_value) = value.to_ffi();
17584                    raw.chain.sType = SType::SurfaceSourceWindowsHWND.into();
17585                    raw.chain.next = next;
17586                    storage.push_storage(storage_value);
17587                    let raw_ptr = storage.push_value_mut(raw);
17588                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17589                }
17590                SurfaceDescriptorExtension::SurfaceSourceXlibWindow(value) => {
17591                    let (mut raw, storage_value) = value.to_ffi();
17592                    raw.chain.sType = SType::SurfaceSourceXlibWindow.into();
17593                    raw.chain.next = next;
17594                    storage.push_storage(storage_value);
17595                    let raw_ptr = storage.push_value_mut(raw);
17596                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17597                }
17598            }
17599        }
17600    }
17601    #[allow(dead_code)]
17602    pub enum SurfaceTextureExtension {}
17603    impl SurfaceTextureExtension {
17604        pub(crate) fn push_chain(
17605            &self,
17606            storage: &mut ChainedStructStorage,
17607            next: *mut ffi::WGPUChainedStruct,
17608        ) -> *mut ffi::WGPUChainedStruct {
17609            let _ = self;
17610            let _ = storage;
17611            next
17612        }
17613    }
17614    #[allow(dead_code)]
17615    pub enum TexelBufferViewDescriptorExtension {}
17616    impl TexelBufferViewDescriptorExtension {
17617        pub(crate) fn push_chain(
17618            &self,
17619            storage: &mut ChainedStructStorage,
17620            next: *mut ffi::WGPUChainedStruct,
17621        ) -> *mut ffi::WGPUChainedStruct {
17622            let _ = self;
17623            let _ = storage;
17624            next
17625        }
17626    }
17627    #[allow(dead_code)]
17628    pub enum TextureBindingLayoutExtension {}
17629    impl TextureBindingLayoutExtension {
17630        pub(crate) fn push_chain(
17631            &self,
17632            storage: &mut ChainedStructStorage,
17633            next: *mut ffi::WGPUChainedStruct,
17634        ) -> *mut ffi::WGPUChainedStruct {
17635            let _ = self;
17636            let _ = storage;
17637            next
17638        }
17639    }
17640    #[allow(dead_code)]
17641    pub enum TextureDescriptorExtension {
17642        DawnTextureInternalUsageDescriptor(DawnTextureInternalUsageDescriptor),
17643    }
17644    impl std::convert::From<DawnTextureInternalUsageDescriptor>
17645    for TextureDescriptorExtension {
17646        fn from(ext: DawnTextureInternalUsageDescriptor) -> Self {
17647            TextureDescriptorExtension::DawnTextureInternalUsageDescriptor(ext)
17648        }
17649    }
17650    impl TextureDescriptorExtension {
17651        pub(crate) fn push_chain(
17652            &self,
17653            storage: &mut ChainedStructStorage,
17654            next: *mut ffi::WGPUChainedStruct,
17655        ) -> *mut ffi::WGPUChainedStruct {
17656            match self {
17657                TextureDescriptorExtension::DawnTextureInternalUsageDescriptor(
17658                    value,
17659                ) => {
17660                    let (mut raw, storage_value) = value.to_ffi();
17661                    raw.chain.sType = SType::DawnTextureInternalUsageDescriptor.into();
17662                    raw.chain.next = next;
17663                    storage.push_storage(storage_value);
17664                    let raw_ptr = storage.push_value_mut(raw);
17665                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17666                }
17667            }
17668        }
17669    }
17670    #[allow(dead_code)]
17671    pub enum TextureViewDescriptorExtension {
17672        TextureComponentSwizzleDescriptor(TextureComponentSwizzleDescriptor),
17673        YCbCrVkDescriptor(YCbCrVkDescriptor),
17674    }
17675    impl std::convert::From<TextureComponentSwizzleDescriptor>
17676    for TextureViewDescriptorExtension {
17677        fn from(ext: TextureComponentSwizzleDescriptor) -> Self {
17678            TextureViewDescriptorExtension::TextureComponentSwizzleDescriptor(ext)
17679        }
17680    }
17681    impl std::convert::From<YCbCrVkDescriptor> for TextureViewDescriptorExtension {
17682        fn from(ext: YCbCrVkDescriptor) -> Self {
17683            TextureViewDescriptorExtension::YCbCrVkDescriptor(ext)
17684        }
17685    }
17686    impl TextureViewDescriptorExtension {
17687        pub(crate) fn push_chain(
17688            &self,
17689            storage: &mut ChainedStructStorage,
17690            next: *mut ffi::WGPUChainedStruct,
17691        ) -> *mut ffi::WGPUChainedStruct {
17692            match self {
17693                TextureViewDescriptorExtension::TextureComponentSwizzleDescriptor(
17694                    value,
17695                ) => {
17696                    let (mut raw, storage_value) = value.to_ffi();
17697                    raw.chain.sType = SType::TextureComponentSwizzleDescriptor.into();
17698                    raw.chain.next = next;
17699                    storage.push_storage(storage_value);
17700                    let raw_ptr = storage.push_value_mut(raw);
17701                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17702                }
17703                TextureViewDescriptorExtension::YCbCrVkDescriptor(value) => {
17704                    let (mut raw, storage_value) = value.to_ffi();
17705                    raw.chain.sType = SType::YCbCrVkDescriptor.into();
17706                    raw.chain.next = next;
17707                    storage.push_storage(storage_value);
17708                    let raw_ptr = storage.push_value_mut(raw);
17709                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17710                }
17711            }
17712        }
17713    }
17714    #[allow(dead_code)]
17715    pub enum VertexAttributeExtension {}
17716    impl VertexAttributeExtension {
17717        pub(crate) fn push_chain(
17718            &self,
17719            storage: &mut ChainedStructStorage,
17720            next: *mut ffi::WGPUChainedStruct,
17721        ) -> *mut ffi::WGPUChainedStruct {
17722            let _ = self;
17723            let _ = storage;
17724            next
17725        }
17726    }
17727    #[allow(dead_code)]
17728    pub enum VertexBufferLayoutExtension {}
17729    impl VertexBufferLayoutExtension {
17730        pub(crate) fn push_chain(
17731            &self,
17732            storage: &mut ChainedStructStorage,
17733            next: *mut ffi::WGPUChainedStruct,
17734        ) -> *mut ffi::WGPUChainedStruct {
17735            let _ = self;
17736            let _ = storage;
17737            next
17738        }
17739    }
17740    #[allow(dead_code)]
17741    pub enum VertexStateExtension {}
17742    impl VertexStateExtension {
17743        pub(crate) fn push_chain(
17744            &self,
17745            storage: &mut ChainedStructStorage,
17746            next: *mut ffi::WGPUChainedStruct,
17747        ) -> *mut ffi::WGPUChainedStruct {
17748            let _ = self;
17749            let _ = storage;
17750            next
17751        }
17752    }
17753}
17754mod objects {
17755    #![allow(dead_code, unused_imports)]
17756    use crate::generated::*;
17757    use crate::ffi;
17758    #[derive(Debug)]
17759    pub struct Adapter {
17760        raw: ffi::WGPUAdapter,
17761    }
17762    impl Adapter {
17763        pub(crate) unsafe fn from_raw(raw: ffi::WGPUAdapter) -> Self {
17764            Self { raw }
17765        }
17766        pub(crate) fn as_raw(&self) -> ffi::WGPUAdapter {
17767            self.raw
17768        }
17769        pub fn get_instance(&self) -> Instance {
17770            let result = unsafe { ffi::wgpuAdapterGetInstance(self.raw) };
17771            unsafe { Instance::from_raw(result) }
17772        }
17773        pub fn get_limits(&self, limits: &mut Limits) -> Status {
17774            let (mut limits_ffi, _limits_storage) = limits.to_ffi();
17775            let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
17776            let result = unsafe { ffi::wgpuAdapterGetLimits(self.raw, limits_ptr) };
17777            *limits = Limits::from_ffi(limits_ffi);
17778            result.into()
17779        }
17780        pub fn get_info(&self, info: &mut AdapterInfo) -> Status {
17781            let (mut info_ffi, _info_storage) = info.to_ffi();
17782            let info_ptr = std::ptr::addr_of_mut!(info_ffi);
17783            let result = unsafe { ffi::wgpuAdapterGetInfo(self.raw, info_ptr) };
17784            *info = AdapterInfo::from_ffi(info_ffi);
17785            result.into()
17786        }
17787        pub fn has_feature(&self, feature: FeatureName) -> bool {
17788            let feature_ffi: ffi::WGPUFeatureName = feature.into();
17789            let result = unsafe { ffi::wgpuAdapterHasFeature(self.raw, feature_ffi) };
17790            result != 0
17791        }
17792        pub fn get_features(&self, features: &mut SupportedFeatures) -> () {
17793            let (mut features_ffi, _features_storage) = features.to_ffi();
17794            let features_ptr = std::ptr::addr_of_mut!(features_ffi);
17795            unsafe { ffi::wgpuAdapterGetFeatures(self.raw, features_ptr) };
17796            *features = SupportedFeatures::from_ffi(features_ffi);
17797            ()
17798        }
17799        pub fn request_device(
17800            &self,
17801            descriptor: Option<&DeviceDescriptor>,
17802            callback: impl FnMut(
17803                RequestDeviceStatus,
17804                Option<Device>,
17805                String,
17806            ) + Send + 'static,
17807        ) -> Future {
17808            let mut descriptor_storage = ChainedStructStorage::new();
17809            let descriptor_ptr = if let Some(value) = &descriptor {
17810                let (descriptor_ffi, storage) = value.to_ffi();
17811                descriptor_storage = storage;
17812                std::ptr::addr_of!(descriptor_ffi)
17813            } else {
17814                std::ptr::null()
17815            };
17816            let callback_box: RequestDeviceCallback = Box::new(callback);
17817            let callback_box = Box::new(Some(callback_box));
17818            let callback_userdata = Box::into_raw(callback_box)
17819                .cast::<std::ffi::c_void>();
17820            let callback_info_ffi = ffi::WGPURequestDeviceCallbackInfo {
17821                nextInChain: std::ptr::null_mut(),
17822                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
17823                callback: Some(request_device_callback_trampoline),
17824                userdata1: callback_userdata,
17825                userdata2: std::ptr::null_mut(),
17826            };
17827            let result = unsafe {
17828                ffi::wgpuAdapterRequestDevice(
17829                    self.raw,
17830                    descriptor_ptr,
17831                    callback_info_ffi,
17832                )
17833            };
17834            Future::from_ffi(result)
17835        }
17836        pub fn create_device(&self, descriptor: Option<&DeviceDescriptor>) -> Device {
17837            let mut descriptor_storage = ChainedStructStorage::new();
17838            let descriptor_ptr = if let Some(value) = &descriptor {
17839                let (descriptor_ffi, storage) = value.to_ffi();
17840                descriptor_storage = storage;
17841                std::ptr::addr_of!(descriptor_ffi)
17842            } else {
17843                std::ptr::null()
17844            };
17845            let result = unsafe {
17846                ffi::wgpuAdapterCreateDevice(self.raw, descriptor_ptr)
17847            };
17848            unsafe { Device::from_raw(result) }
17849        }
17850        pub fn get_format_capabilities(
17851            &self,
17852            format: TextureFormat,
17853            capabilities: &mut DawnFormatCapabilities,
17854        ) -> Status {
17855            let format_ffi: ffi::WGPUTextureFormat = format.into();
17856            let (mut capabilities_ffi, _capabilities_storage) = capabilities.to_ffi();
17857            let capabilities_ptr = std::ptr::addr_of_mut!(capabilities_ffi);
17858            let result = unsafe {
17859                ffi::wgpuAdapterGetFormatCapabilities(
17860                    self.raw,
17861                    format_ffi,
17862                    capabilities_ptr,
17863                )
17864            };
17865            *capabilities = DawnFormatCapabilities::from_ffi(capabilities_ffi);
17866            result.into()
17867        }
17868    }
17869    impl Drop for Adapter {
17870        fn drop(&mut self) {
17871            if self.as_raw().is_null() {
17872                return;
17873            }
17874            unsafe { ffi::wgpuAdapterRelease(self.raw) };
17875        }
17876    }
17877    impl Clone for Adapter {
17878        fn clone(&self) -> Self {
17879            unsafe { ffi::wgpuAdapterAddRef(self.raw) };
17880            Self { raw: self.raw }
17881        }
17882    }
17883    unsafe impl Send for Adapter {}
17884    unsafe impl Sync for Adapter {}
17885    #[derive(Debug)]
17886    pub struct BindGroup {
17887        raw: ffi::WGPUBindGroup,
17888    }
17889    impl BindGroup {
17890        pub(crate) unsafe fn from_raw(raw: ffi::WGPUBindGroup) -> Self {
17891            Self { raw }
17892        }
17893        pub(crate) fn as_raw(&self) -> ffi::WGPUBindGroup {
17894            self.raw
17895        }
17896        pub fn set_label(&self, label: String) -> () {
17897            let label_ffi = ffi::WGPUStringView {
17898                data: label.as_ptr().cast(),
17899                length: label.len(),
17900            };
17901            unsafe { ffi::wgpuBindGroupSetLabel(self.raw, label_ffi) };
17902            ()
17903        }
17904    }
17905    impl Drop for BindGroup {
17906        fn drop(&mut self) {
17907            if self.as_raw().is_null() {
17908                return;
17909            }
17910            unsafe { ffi::wgpuBindGroupRelease(self.raw) };
17911        }
17912    }
17913    impl Clone for BindGroup {
17914        fn clone(&self) -> Self {
17915            unsafe { ffi::wgpuBindGroupAddRef(self.raw) };
17916            Self { raw: self.raw }
17917        }
17918    }
17919    unsafe impl Send for BindGroup {}
17920    unsafe impl Sync for BindGroup {}
17921    #[derive(Debug)]
17922    pub struct BindGroupLayout {
17923        raw: ffi::WGPUBindGroupLayout,
17924    }
17925    impl BindGroupLayout {
17926        pub(crate) unsafe fn from_raw(raw: ffi::WGPUBindGroupLayout) -> Self {
17927            Self { raw }
17928        }
17929        pub(crate) fn as_raw(&self) -> ffi::WGPUBindGroupLayout {
17930            self.raw
17931        }
17932        pub fn set_label(&self, label: String) -> () {
17933            let label_ffi = ffi::WGPUStringView {
17934                data: label.as_ptr().cast(),
17935                length: label.len(),
17936            };
17937            unsafe { ffi::wgpuBindGroupLayoutSetLabel(self.raw, label_ffi) };
17938            ()
17939        }
17940    }
17941    impl Drop for BindGroupLayout {
17942        fn drop(&mut self) {
17943            if self.as_raw().is_null() {
17944                return;
17945            }
17946            unsafe { ffi::wgpuBindGroupLayoutRelease(self.raw) };
17947        }
17948    }
17949    impl Clone for BindGroupLayout {
17950        fn clone(&self) -> Self {
17951            unsafe { ffi::wgpuBindGroupLayoutAddRef(self.raw) };
17952            Self { raw: self.raw }
17953        }
17954    }
17955    unsafe impl Send for BindGroupLayout {}
17956    unsafe impl Sync for BindGroupLayout {}
17957    #[derive(Debug)]
17958    pub struct Buffer {
17959        raw: ffi::WGPUBuffer,
17960    }
17961    impl Buffer {
17962        pub(crate) unsafe fn from_raw(raw: ffi::WGPUBuffer) -> Self {
17963            Self { raw }
17964        }
17965        pub(crate) fn as_raw(&self) -> ffi::WGPUBuffer {
17966            self.raw
17967        }
17968        pub fn map_async(
17969            &self,
17970            mode: MapMode,
17971            offset: usize,
17972            size: usize,
17973            callback: impl FnMut(MapAsyncStatus, String) + Send + 'static,
17974        ) -> Future {
17975            let mode_ffi: ffi::WGPUMapMode = mode.into();
17976            let callback_box: BufferMapCallback = Box::new(callback);
17977            let callback_box = Box::new(Some(callback_box));
17978            let callback_userdata = Box::into_raw(callback_box)
17979                .cast::<std::ffi::c_void>();
17980            let callback_info_ffi = ffi::WGPUBufferMapCallbackInfo {
17981                nextInChain: std::ptr::null_mut(),
17982                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
17983                callback: Some(buffer_map_callback_trampoline),
17984                userdata1: callback_userdata,
17985                userdata2: std::ptr::null_mut(),
17986            };
17987            let result = unsafe {
17988                ffi::wgpuBufferMapAsync(
17989                    self.raw,
17990                    mode_ffi,
17991                    offset,
17992                    size,
17993                    callback_info_ffi,
17994                )
17995            };
17996            Future::from_ffi(result)
17997        }
17998        pub fn get_mapped_range(
17999            &self,
18000            offset: usize,
18001            size: usize,
18002        ) -> *mut std::ffi::c_void {
18003            let result = unsafe {
18004                ffi::wgpuBufferGetMappedRange(self.raw, offset, size)
18005            };
18006            result
18007        }
18008        pub fn get_const_mapped_range(
18009            &self,
18010            offset: usize,
18011            size: usize,
18012        ) -> *const std::ffi::c_void {
18013            let result = unsafe {
18014                ffi::wgpuBufferGetConstMappedRange(self.raw, offset, size)
18015            };
18016            result
18017        }
18018        pub fn write_mapped_range(
18019            &self,
18020            offset: usize,
18021            data: &[std::ffi::c_void],
18022        ) -> Status {
18023            let data_ptr = data.as_ptr();
18024            let result = unsafe {
18025                ffi::wgpuBufferWriteMappedRange(self.raw, offset, data_ptr, data.len())
18026            };
18027            result.into()
18028        }
18029        pub fn read_mapped_range(
18030            &self,
18031            offset: usize,
18032            mut data: &mut [std::ffi::c_void],
18033        ) -> Status {
18034            let data_ptr = data.as_mut_ptr();
18035            let result = unsafe {
18036                ffi::wgpuBufferReadMappedRange(self.raw, offset, data_ptr, data.len())
18037            };
18038            result.into()
18039        }
18040        pub fn create_texel_view(
18041            &self,
18042            descriptor: &TexelBufferViewDescriptor,
18043        ) -> TexelBufferView {
18044            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18045            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18046            let result = unsafe {
18047                ffi::wgpuBufferCreateTexelView(self.raw, descriptor_ptr)
18048            };
18049            unsafe { TexelBufferView::from_raw(result) }
18050        }
18051        pub fn set_label(&self, label: String) -> () {
18052            let label_ffi = ffi::WGPUStringView {
18053                data: label.as_ptr().cast(),
18054                length: label.len(),
18055            };
18056            unsafe { ffi::wgpuBufferSetLabel(self.raw, label_ffi) };
18057            ()
18058        }
18059        pub fn get_usage(&self) -> BufferUsage {
18060            let result = unsafe { ffi::wgpuBufferGetUsage(self.raw) };
18061            result.into()
18062        }
18063        pub fn get_size(&self) -> u64 {
18064            let result = unsafe { ffi::wgpuBufferGetSize(self.raw) };
18065            result
18066        }
18067        pub fn get_map_state(&self) -> BufferMapState {
18068            let result = unsafe { ffi::wgpuBufferGetMapState(self.raw) };
18069            result.into()
18070        }
18071        pub fn unmap(&self) -> () {
18072            unsafe { ffi::wgpuBufferUnmap(self.raw) };
18073            ()
18074        }
18075        pub fn destroy(&self) -> () {
18076            unsafe { ffi::wgpuBufferDestroy(self.raw) };
18077            ()
18078        }
18079    }
18080    impl Drop for Buffer {
18081        fn drop(&mut self) {
18082            if self.as_raw().is_null() {
18083                return;
18084            }
18085            unsafe { ffi::wgpuBufferRelease(self.raw) };
18086        }
18087    }
18088    impl Clone for Buffer {
18089        fn clone(&self) -> Self {
18090            unsafe { ffi::wgpuBufferAddRef(self.raw) };
18091            Self { raw: self.raw }
18092        }
18093    }
18094    unsafe impl Send for Buffer {}
18095    unsafe impl Sync for Buffer {}
18096    #[derive(Debug)]
18097    pub struct CommandBuffer {
18098        raw: ffi::WGPUCommandBuffer,
18099    }
18100    impl CommandBuffer {
18101        pub(crate) unsafe fn from_raw(raw: ffi::WGPUCommandBuffer) -> Self {
18102            Self { raw }
18103        }
18104        pub(crate) fn as_raw(&self) -> ffi::WGPUCommandBuffer {
18105            self.raw
18106        }
18107        pub fn set_label(&self, label: String) -> () {
18108            let label_ffi = ffi::WGPUStringView {
18109                data: label.as_ptr().cast(),
18110                length: label.len(),
18111            };
18112            unsafe { ffi::wgpuCommandBufferSetLabel(self.raw, label_ffi) };
18113            ()
18114        }
18115    }
18116    impl Drop for CommandBuffer {
18117        fn drop(&mut self) {
18118            if self.as_raw().is_null() {
18119                return;
18120            }
18121            unsafe { ffi::wgpuCommandBufferRelease(self.raw) };
18122        }
18123    }
18124    impl Clone for CommandBuffer {
18125        fn clone(&self) -> Self {
18126            unsafe { ffi::wgpuCommandBufferAddRef(self.raw) };
18127            Self { raw: self.raw }
18128        }
18129    }
18130    unsafe impl Send for CommandBuffer {}
18131    unsafe impl Sync for CommandBuffer {}
18132    #[derive(Debug)]
18133    pub struct CommandEncoder {
18134        raw: ffi::WGPUCommandEncoder,
18135    }
18136    impl CommandEncoder {
18137        pub(crate) unsafe fn from_raw(raw: ffi::WGPUCommandEncoder) -> Self {
18138            Self { raw }
18139        }
18140        pub(crate) fn as_raw(&self) -> ffi::WGPUCommandEncoder {
18141            self.raw
18142        }
18143        pub fn finish(
18144            &self,
18145            descriptor: Option<&CommandBufferDescriptor>,
18146        ) -> CommandBuffer {
18147            let mut descriptor_storage = ChainedStructStorage::new();
18148            let descriptor_ptr = if let Some(value) = &descriptor {
18149                let (descriptor_ffi, storage) = value.to_ffi();
18150                descriptor_storage = storage;
18151                std::ptr::addr_of!(descriptor_ffi)
18152            } else {
18153                std::ptr::null()
18154            };
18155            let result = unsafe {
18156                ffi::wgpuCommandEncoderFinish(self.raw, descriptor_ptr)
18157            };
18158            unsafe { CommandBuffer::from_raw(result) }
18159        }
18160        pub fn begin_compute_pass(
18161            &self,
18162            descriptor: Option<&ComputePassDescriptor>,
18163        ) -> ComputePassEncoder {
18164            let mut descriptor_storage = ChainedStructStorage::new();
18165            let descriptor_ptr = if let Some(value) = &descriptor {
18166                let (descriptor_ffi, storage) = value.to_ffi();
18167                descriptor_storage = storage;
18168                std::ptr::addr_of!(descriptor_ffi)
18169            } else {
18170                std::ptr::null()
18171            };
18172            let result = unsafe {
18173                ffi::wgpuCommandEncoderBeginComputePass(self.raw, descriptor_ptr)
18174            };
18175            unsafe { ComputePassEncoder::from_raw(result) }
18176        }
18177        pub fn begin_render_pass(
18178            &self,
18179            descriptor: &RenderPassDescriptor,
18180        ) -> RenderPassEncoder {
18181            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18182            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18183            let result = unsafe {
18184                ffi::wgpuCommandEncoderBeginRenderPass(self.raw, descriptor_ptr)
18185            };
18186            unsafe { RenderPassEncoder::from_raw(result) }
18187        }
18188        pub fn copy_buffer_to_buffer(
18189            &self,
18190            source: Buffer,
18191            source_offset: u64,
18192            destination: Buffer,
18193            destination_offset: u64,
18194            size: u64,
18195        ) -> () {
18196            unsafe {
18197                ffi::wgpuCommandEncoderCopyBufferToBuffer(
18198                    self.raw,
18199                    source.as_raw(),
18200                    source_offset,
18201                    destination.as_raw(),
18202                    destination_offset,
18203                    size,
18204                )
18205            };
18206            ()
18207        }
18208        pub fn copy_buffer_to_texture(
18209            &self,
18210            source: &TexelCopyBufferInfo,
18211            destination: &TexelCopyTextureInfo,
18212            copy_size: &Extent3D,
18213        ) -> () {
18214            let (source_ffi, _source_storage) = source.to_ffi();
18215            let source_ptr = std::ptr::addr_of!(source_ffi);
18216            let (destination_ffi, _destination_storage) = destination.to_ffi();
18217            let destination_ptr = std::ptr::addr_of!(destination_ffi);
18218            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18219            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18220            unsafe {
18221                ffi::wgpuCommandEncoderCopyBufferToTexture(
18222                    self.raw,
18223                    source_ptr,
18224                    destination_ptr,
18225                    copy_size_ptr,
18226                )
18227            };
18228            ()
18229        }
18230        pub fn copy_texture_to_buffer(
18231            &self,
18232            source: &TexelCopyTextureInfo,
18233            destination: &TexelCopyBufferInfo,
18234            copy_size: &Extent3D,
18235        ) -> () {
18236            let (source_ffi, _source_storage) = source.to_ffi();
18237            let source_ptr = std::ptr::addr_of!(source_ffi);
18238            let (destination_ffi, _destination_storage) = destination.to_ffi();
18239            let destination_ptr = std::ptr::addr_of!(destination_ffi);
18240            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18241            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18242            unsafe {
18243                ffi::wgpuCommandEncoderCopyTextureToBuffer(
18244                    self.raw,
18245                    source_ptr,
18246                    destination_ptr,
18247                    copy_size_ptr,
18248                )
18249            };
18250            ()
18251        }
18252        pub fn copy_texture_to_texture(
18253            &self,
18254            source: &TexelCopyTextureInfo,
18255            destination: &TexelCopyTextureInfo,
18256            copy_size: &Extent3D,
18257        ) -> () {
18258            let (source_ffi, _source_storage) = source.to_ffi();
18259            let source_ptr = std::ptr::addr_of!(source_ffi);
18260            let (destination_ffi, _destination_storage) = destination.to_ffi();
18261            let destination_ptr = std::ptr::addr_of!(destination_ffi);
18262            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18263            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18264            unsafe {
18265                ffi::wgpuCommandEncoderCopyTextureToTexture(
18266                    self.raw,
18267                    source_ptr,
18268                    destination_ptr,
18269                    copy_size_ptr,
18270                )
18271            };
18272            ()
18273        }
18274        pub fn clear_buffer(&self, buffer: Buffer, offset: u64, size: u64) -> () {
18275            unsafe {
18276                ffi::wgpuCommandEncoderClearBuffer(
18277                    self.raw,
18278                    buffer.as_raw(),
18279                    offset,
18280                    size,
18281                )
18282            };
18283            ()
18284        }
18285        pub fn inject_validation_error(&self, message: String) -> () {
18286            let message_ffi = ffi::WGPUStringView {
18287                data: message.as_ptr().cast(),
18288                length: message.len(),
18289            };
18290            unsafe {
18291                ffi::wgpuCommandEncoderInjectValidationError(self.raw, message_ffi)
18292            };
18293            ()
18294        }
18295        pub fn insert_debug_marker(&self, marker_label: String) -> () {
18296            let marker_label_ffi = ffi::WGPUStringView {
18297                data: marker_label.as_ptr().cast(),
18298                length: marker_label.len(),
18299            };
18300            unsafe {
18301                ffi::wgpuCommandEncoderInsertDebugMarker(self.raw, marker_label_ffi)
18302            };
18303            ()
18304        }
18305        pub fn pop_debug_group(&self) -> () {
18306            unsafe { ffi::wgpuCommandEncoderPopDebugGroup(self.raw) };
18307            ()
18308        }
18309        pub fn push_debug_group(&self, group_label: String) -> () {
18310            let group_label_ffi = ffi::WGPUStringView {
18311                data: group_label.as_ptr().cast(),
18312                length: group_label.len(),
18313            };
18314            unsafe { ffi::wgpuCommandEncoderPushDebugGroup(self.raw, group_label_ffi) };
18315            ()
18316        }
18317        pub fn resolve_query_set(
18318            &self,
18319            query_set: QuerySet,
18320            first_query: u32,
18321            query_count: u32,
18322            destination: Buffer,
18323            destination_offset: u64,
18324        ) -> () {
18325            unsafe {
18326                ffi::wgpuCommandEncoderResolveQuerySet(
18327                    self.raw,
18328                    query_set.as_raw(),
18329                    first_query,
18330                    query_count,
18331                    destination.as_raw(),
18332                    destination_offset,
18333                )
18334            };
18335            ()
18336        }
18337        pub fn write_buffer(
18338            &self,
18339            buffer: Buffer,
18340            buffer_offset: u64,
18341            data: &[u8],
18342        ) -> () {
18343            let data_ptr = data.as_ptr();
18344            unsafe {
18345                ffi::wgpuCommandEncoderWriteBuffer(
18346                    self.raw,
18347                    buffer.as_raw(),
18348                    buffer_offset,
18349                    data_ptr,
18350                    (data.len()) as u64,
18351                )
18352            };
18353            ()
18354        }
18355        pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
18356            unsafe {
18357                ffi::wgpuCommandEncoderWriteTimestamp(
18358                    self.raw,
18359                    query_set.as_raw(),
18360                    query_index,
18361                )
18362            };
18363            ()
18364        }
18365        pub fn set_label(&self, label: String) -> () {
18366            let label_ffi = ffi::WGPUStringView {
18367                data: label.as_ptr().cast(),
18368                length: label.len(),
18369            };
18370            unsafe { ffi::wgpuCommandEncoderSetLabel(self.raw, label_ffi) };
18371            ()
18372        }
18373    }
18374    impl Drop for CommandEncoder {
18375        fn drop(&mut self) {
18376            if self.as_raw().is_null() {
18377                return;
18378            }
18379            unsafe { ffi::wgpuCommandEncoderRelease(self.raw) };
18380        }
18381    }
18382    impl Clone for CommandEncoder {
18383        fn clone(&self) -> Self {
18384            unsafe { ffi::wgpuCommandEncoderAddRef(self.raw) };
18385            Self { raw: self.raw }
18386        }
18387    }
18388    unsafe impl Send for CommandEncoder {}
18389    unsafe impl Sync for CommandEncoder {}
18390    #[derive(Debug)]
18391    pub struct ComputePassEncoder {
18392        raw: ffi::WGPUComputePassEncoder,
18393    }
18394    impl ComputePassEncoder {
18395        pub(crate) unsafe fn from_raw(raw: ffi::WGPUComputePassEncoder) -> Self {
18396            Self { raw }
18397        }
18398        pub(crate) fn as_raw(&self) -> ffi::WGPUComputePassEncoder {
18399            self.raw
18400        }
18401        pub fn insert_debug_marker(&self, marker_label: String) -> () {
18402            let marker_label_ffi = ffi::WGPUStringView {
18403                data: marker_label.as_ptr().cast(),
18404                length: marker_label.len(),
18405            };
18406            unsafe {
18407                ffi::wgpuComputePassEncoderInsertDebugMarker(self.raw, marker_label_ffi)
18408            };
18409            ()
18410        }
18411        pub fn pop_debug_group(&self) -> () {
18412            unsafe { ffi::wgpuComputePassEncoderPopDebugGroup(self.raw) };
18413            ()
18414        }
18415        pub fn push_debug_group(&self, group_label: String) -> () {
18416            let group_label_ffi = ffi::WGPUStringView {
18417                data: group_label.as_ptr().cast(),
18418                length: group_label.len(),
18419            };
18420            unsafe {
18421                ffi::wgpuComputePassEncoderPushDebugGroup(self.raw, group_label_ffi)
18422            };
18423            ()
18424        }
18425        pub fn set_pipeline(&self, pipeline: ComputePipeline) -> () {
18426            unsafe {
18427                ffi::wgpuComputePassEncoderSetPipeline(self.raw, pipeline.as_raw())
18428            };
18429            ()
18430        }
18431        pub fn set_bind_group(
18432            &self,
18433            group_index: u32,
18434            group: Option<BindGroup>,
18435            dynamic_offsets: &[u32],
18436        ) -> () {
18437            let group_raw = group
18438                .as_ref()
18439                .map(|v| v.as_raw())
18440                .unwrap_or(std::ptr::null_mut());
18441            let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
18442            unsafe {
18443                ffi::wgpuComputePassEncoderSetBindGroup(
18444                    self.raw,
18445                    group_index,
18446                    group_raw,
18447                    dynamic_offsets.len(),
18448                    dynamic_offsets_ptr,
18449                )
18450            };
18451            ()
18452        }
18453        pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
18454            unsafe {
18455                ffi::wgpuComputePassEncoderWriteTimestamp(
18456                    self.raw,
18457                    query_set.as_raw(),
18458                    query_index,
18459                )
18460            };
18461            ()
18462        }
18463        pub fn dispatch_workgroups(
18464            &self,
18465            workgroup_count_x: u32,
18466            workgroup_count_y: u32,
18467            workgroup_count_z: u32,
18468        ) -> () {
18469            unsafe {
18470                ffi::wgpuComputePassEncoderDispatchWorkgroups(
18471                    self.raw,
18472                    workgroup_count_x,
18473                    workgroup_count_y,
18474                    workgroup_count_z,
18475                )
18476            };
18477            ()
18478        }
18479        pub fn dispatch_workgroups_indirect(
18480            &self,
18481            indirect_buffer: Buffer,
18482            indirect_offset: u64,
18483        ) -> () {
18484            unsafe {
18485                ffi::wgpuComputePassEncoderDispatchWorkgroupsIndirect(
18486                    self.raw,
18487                    indirect_buffer.as_raw(),
18488                    indirect_offset,
18489                )
18490            };
18491            ()
18492        }
18493        pub fn end(&self) -> () {
18494            unsafe { ffi::wgpuComputePassEncoderEnd(self.raw) };
18495            ()
18496        }
18497        pub fn set_label(&self, label: String) -> () {
18498            let label_ffi = ffi::WGPUStringView {
18499                data: label.as_ptr().cast(),
18500                length: label.len(),
18501            };
18502            unsafe { ffi::wgpuComputePassEncoderSetLabel(self.raw, label_ffi) };
18503            ()
18504        }
18505        pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
18506            let data_ptr = data.as_ptr();
18507            unsafe {
18508                ffi::wgpuComputePassEncoderSetImmediates(
18509                    self.raw,
18510                    offset,
18511                    data_ptr,
18512                    data.len(),
18513                )
18514            };
18515            ()
18516        }
18517        pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
18518            let table_raw = table
18519                .as_ref()
18520                .map(|v| v.as_raw())
18521                .unwrap_or(std::ptr::null_mut());
18522            unsafe { ffi::wgpuComputePassEncoderSetResourceTable(self.raw, table_raw) };
18523            ()
18524        }
18525    }
18526    impl Drop for ComputePassEncoder {
18527        fn drop(&mut self) {
18528            if self.as_raw().is_null() {
18529                return;
18530            }
18531            unsafe { ffi::wgpuComputePassEncoderRelease(self.raw) };
18532        }
18533    }
18534    impl Clone for ComputePassEncoder {
18535        fn clone(&self) -> Self {
18536            unsafe { ffi::wgpuComputePassEncoderAddRef(self.raw) };
18537            Self { raw: self.raw }
18538        }
18539    }
18540    unsafe impl Send for ComputePassEncoder {}
18541    unsafe impl Sync for ComputePassEncoder {}
18542    #[derive(Debug)]
18543    pub struct ComputePipeline {
18544        raw: ffi::WGPUComputePipeline,
18545    }
18546    impl ComputePipeline {
18547        pub(crate) unsafe fn from_raw(raw: ffi::WGPUComputePipeline) -> Self {
18548            Self { raw }
18549        }
18550        pub(crate) fn as_raw(&self) -> ffi::WGPUComputePipeline {
18551            self.raw
18552        }
18553        pub fn get_bind_group_layout(&self, group_index: u32) -> BindGroupLayout {
18554            let result = unsafe {
18555                ffi::wgpuComputePipelineGetBindGroupLayout(self.raw, group_index)
18556            };
18557            unsafe { BindGroupLayout::from_raw(result) }
18558        }
18559        pub fn set_label(&self, label: String) -> () {
18560            let label_ffi = ffi::WGPUStringView {
18561                data: label.as_ptr().cast(),
18562                length: label.len(),
18563            };
18564            unsafe { ffi::wgpuComputePipelineSetLabel(self.raw, label_ffi) };
18565            ()
18566        }
18567    }
18568    impl Drop for ComputePipeline {
18569        fn drop(&mut self) {
18570            if self.as_raw().is_null() {
18571                return;
18572            }
18573            unsafe { ffi::wgpuComputePipelineRelease(self.raw) };
18574        }
18575    }
18576    impl Clone for ComputePipeline {
18577        fn clone(&self) -> Self {
18578            unsafe { ffi::wgpuComputePipelineAddRef(self.raw) };
18579            Self { raw: self.raw }
18580        }
18581    }
18582    unsafe impl Send for ComputePipeline {}
18583    unsafe impl Sync for ComputePipeline {}
18584    #[derive(Debug)]
18585    pub struct Device {
18586        raw: ffi::WGPUDevice,
18587    }
18588    impl Device {
18589        pub(crate) unsafe fn from_raw(raw: ffi::WGPUDevice) -> Self {
18590            Self { raw }
18591        }
18592        pub(crate) fn as_raw(&self) -> ffi::WGPUDevice {
18593            self.raw
18594        }
18595        pub fn create_bind_group(&self, descriptor: &BindGroupDescriptor) -> BindGroup {
18596            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18597            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18598            let result = unsafe {
18599                ffi::wgpuDeviceCreateBindGroup(self.raw, descriptor_ptr)
18600            };
18601            unsafe { BindGroup::from_raw(result) }
18602        }
18603        pub fn create_bind_group_layout(
18604            &self,
18605            descriptor: &BindGroupLayoutDescriptor,
18606        ) -> BindGroupLayout {
18607            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18608            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18609            let result = unsafe {
18610                ffi::wgpuDeviceCreateBindGroupLayout(self.raw, descriptor_ptr)
18611            };
18612            unsafe { BindGroupLayout::from_raw(result) }
18613        }
18614        pub fn create_buffer(&self, descriptor: &BufferDescriptor) -> Option<Buffer> {
18615            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18616            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18617            let result = unsafe {
18618                ffi::wgpuDeviceCreateBuffer(self.raw, descriptor_ptr)
18619            };
18620            if result.is_null() {
18621                None
18622            } else {
18623                Some(unsafe { Buffer::from_raw(result) })
18624            }
18625        }
18626        pub fn create_error_buffer(&self, descriptor: &BufferDescriptor) -> Buffer {
18627            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18628            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18629            let result = unsafe {
18630                ffi::wgpuDeviceCreateErrorBuffer(self.raw, descriptor_ptr)
18631            };
18632            unsafe { Buffer::from_raw(result) }
18633        }
18634        pub fn create_command_encoder(
18635            &self,
18636            descriptor: Option<&CommandEncoderDescriptor>,
18637        ) -> CommandEncoder {
18638            let mut descriptor_storage = ChainedStructStorage::new();
18639            let descriptor_ptr = if let Some(value) = &descriptor {
18640                let (descriptor_ffi, storage) = value.to_ffi();
18641                descriptor_storage = storage;
18642                std::ptr::addr_of!(descriptor_ffi)
18643            } else {
18644                std::ptr::null()
18645            };
18646            let result = unsafe {
18647                ffi::wgpuDeviceCreateCommandEncoder(self.raw, descriptor_ptr)
18648            };
18649            unsafe { CommandEncoder::from_raw(result) }
18650        }
18651        pub fn create_compute_pipeline(
18652            &self,
18653            descriptor: &ComputePipelineDescriptor,
18654        ) -> ComputePipeline {
18655            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18656            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18657            let result = unsafe {
18658                ffi::wgpuDeviceCreateComputePipeline(self.raw, descriptor_ptr)
18659            };
18660            unsafe { ComputePipeline::from_raw(result) }
18661        }
18662        pub fn create_compute_pipeline_async(
18663            &self,
18664            descriptor: &ComputePipelineDescriptor,
18665            callback: impl FnMut(
18666                CreatePipelineAsyncStatus,
18667                Option<ComputePipeline>,
18668                String,
18669            ) + Send + 'static,
18670        ) -> Future {
18671            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18672            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18673            let callback_box: CreateComputePipelineAsyncCallback = Box::new(callback);
18674            let callback_box = Box::new(Some(callback_box));
18675            let callback_userdata = Box::into_raw(callback_box)
18676                .cast::<std::ffi::c_void>();
18677            let callback_info_ffi = ffi::WGPUCreateComputePipelineAsyncCallbackInfo {
18678                nextInChain: std::ptr::null_mut(),
18679                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18680                callback: Some(create_compute_pipeline_async_callback_trampoline),
18681                userdata1: callback_userdata,
18682                userdata2: std::ptr::null_mut(),
18683            };
18684            let result = unsafe {
18685                ffi::wgpuDeviceCreateComputePipelineAsync(
18686                    self.raw,
18687                    descriptor_ptr,
18688                    callback_info_ffi,
18689                )
18690            };
18691            Future::from_ffi(result)
18692        }
18693        pub fn create_external_texture(
18694            &self,
18695            external_texture_descriptor: &ExternalTextureDescriptor,
18696        ) -> ExternalTexture {
18697            let (
18698                external_texture_descriptor_ffi,
18699                _external_texture_descriptor_storage,
18700            ) = external_texture_descriptor.to_ffi();
18701            let external_texture_descriptor_ptr = std::ptr::addr_of!(
18702                external_texture_descriptor_ffi
18703            );
18704            let result = unsafe {
18705                ffi::wgpuDeviceCreateExternalTexture(
18706                    self.raw,
18707                    external_texture_descriptor_ptr,
18708                )
18709            };
18710            unsafe { ExternalTexture::from_raw(result) }
18711        }
18712        pub fn create_error_external_texture(&self) -> ExternalTexture {
18713            let result = unsafe { ffi::wgpuDeviceCreateErrorExternalTexture(self.raw) };
18714            unsafe { ExternalTexture::from_raw(result) }
18715        }
18716        pub fn create_pipeline_layout(
18717            &self,
18718            descriptor: &PipelineLayoutDescriptor,
18719        ) -> PipelineLayout {
18720            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18721            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18722            let result = unsafe {
18723                ffi::wgpuDeviceCreatePipelineLayout(self.raw, descriptor_ptr)
18724            };
18725            unsafe { PipelineLayout::from_raw(result) }
18726        }
18727        pub fn create_query_set(&self, descriptor: &QuerySetDescriptor) -> QuerySet {
18728            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18729            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18730            let result = unsafe {
18731                ffi::wgpuDeviceCreateQuerySet(self.raw, descriptor_ptr)
18732            };
18733            unsafe { QuerySet::from_raw(result) }
18734        }
18735        pub fn create_render_pipeline_async(
18736            &self,
18737            descriptor: &RenderPipelineDescriptor,
18738            callback: impl FnMut(
18739                CreatePipelineAsyncStatus,
18740                Option<RenderPipeline>,
18741                String,
18742            ) + Send + 'static,
18743        ) -> Future {
18744            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18745            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18746            let callback_box: CreateRenderPipelineAsyncCallback = Box::new(callback);
18747            let callback_box = Box::new(Some(callback_box));
18748            let callback_userdata = Box::into_raw(callback_box)
18749                .cast::<std::ffi::c_void>();
18750            let callback_info_ffi = ffi::WGPUCreateRenderPipelineAsyncCallbackInfo {
18751                nextInChain: std::ptr::null_mut(),
18752                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18753                callback: Some(create_render_pipeline_async_callback_trampoline),
18754                userdata1: callback_userdata,
18755                userdata2: std::ptr::null_mut(),
18756            };
18757            let result = unsafe {
18758                ffi::wgpuDeviceCreateRenderPipelineAsync(
18759                    self.raw,
18760                    descriptor_ptr,
18761                    callback_info_ffi,
18762                )
18763            };
18764            Future::from_ffi(result)
18765        }
18766        pub fn create_render_bundle_encoder(
18767            &self,
18768            descriptor: &RenderBundleEncoderDescriptor,
18769        ) -> RenderBundleEncoder {
18770            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18771            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18772            let result = unsafe {
18773                ffi::wgpuDeviceCreateRenderBundleEncoder(self.raw, descriptor_ptr)
18774            };
18775            unsafe { RenderBundleEncoder::from_raw(result) }
18776        }
18777        pub fn create_render_pipeline(
18778            &self,
18779            descriptor: &RenderPipelineDescriptor,
18780        ) -> RenderPipeline {
18781            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18782            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18783            let result = unsafe {
18784                ffi::wgpuDeviceCreateRenderPipeline(self.raw, descriptor_ptr)
18785            };
18786            unsafe { RenderPipeline::from_raw(result) }
18787        }
18788        pub fn create_sampler(&self, descriptor: Option<&SamplerDescriptor>) -> Sampler {
18789            let mut descriptor_storage = ChainedStructStorage::new();
18790            let descriptor_ptr = if let Some(value) = &descriptor {
18791                let (descriptor_ffi, storage) = value.to_ffi();
18792                descriptor_storage = storage;
18793                std::ptr::addr_of!(descriptor_ffi)
18794            } else {
18795                std::ptr::null()
18796            };
18797            let result = unsafe {
18798                ffi::wgpuDeviceCreateSampler(self.raw, descriptor_ptr)
18799            };
18800            unsafe { Sampler::from_raw(result) }
18801        }
18802        pub fn create_shader_module(
18803            &self,
18804            descriptor: &ShaderModuleDescriptor,
18805        ) -> ShaderModule {
18806            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18807            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18808            let result = unsafe {
18809                ffi::wgpuDeviceCreateShaderModule(self.raw, descriptor_ptr)
18810            };
18811            unsafe { ShaderModule::from_raw(result) }
18812        }
18813        pub fn create_error_shader_module(
18814            &self,
18815            descriptor: &ShaderModuleDescriptor,
18816            error_message: String,
18817        ) -> ShaderModule {
18818            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18819            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18820            let error_message_ffi = ffi::WGPUStringView {
18821                data: error_message.as_ptr().cast(),
18822                length: error_message.len(),
18823            };
18824            let result = unsafe {
18825                ffi::wgpuDeviceCreateErrorShaderModule(
18826                    self.raw,
18827                    descriptor_ptr,
18828                    error_message_ffi,
18829                )
18830            };
18831            unsafe { ShaderModule::from_raw(result) }
18832        }
18833        pub fn create_texture(&self, descriptor: &TextureDescriptor) -> Texture {
18834            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18835            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18836            let result = unsafe {
18837                ffi::wgpuDeviceCreateTexture(self.raw, descriptor_ptr)
18838            };
18839            unsafe { Texture::from_raw(result) }
18840        }
18841        pub fn create_resource_table(
18842            &self,
18843            descriptor: &ResourceTableDescriptor,
18844        ) -> ResourceTable {
18845            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18846            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18847            let result = unsafe {
18848                ffi::wgpuDeviceCreateResourceTable(self.raw, descriptor_ptr)
18849            };
18850            unsafe { ResourceTable::from_raw(result) }
18851        }
18852        pub fn import_shared_buffer_memory(
18853            &self,
18854            descriptor: &SharedBufferMemoryDescriptor,
18855        ) -> SharedBufferMemory {
18856            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18857            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18858            let result = unsafe {
18859                ffi::wgpuDeviceImportSharedBufferMemory(self.raw, descriptor_ptr)
18860            };
18861            unsafe { SharedBufferMemory::from_raw(result) }
18862        }
18863        pub fn import_shared_texture_memory(
18864            &self,
18865            descriptor: &SharedTextureMemoryDescriptor,
18866        ) -> SharedTextureMemory {
18867            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18868            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18869            let result = unsafe {
18870                ffi::wgpuDeviceImportSharedTextureMemory(self.raw, descriptor_ptr)
18871            };
18872            unsafe { SharedTextureMemory::from_raw(result) }
18873        }
18874        pub fn import_shared_fence(
18875            &self,
18876            descriptor: &SharedFenceDescriptor,
18877        ) -> SharedFence {
18878            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18879            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18880            let result = unsafe {
18881                ffi::wgpuDeviceImportSharedFence(self.raw, descriptor_ptr)
18882            };
18883            unsafe { SharedFence::from_raw(result) }
18884        }
18885        pub fn create_error_texture(&self, descriptor: &TextureDescriptor) -> Texture {
18886            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18887            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18888            let result = unsafe {
18889                ffi::wgpuDeviceCreateErrorTexture(self.raw, descriptor_ptr)
18890            };
18891            unsafe { Texture::from_raw(result) }
18892        }
18893        pub fn destroy(&self) -> () {
18894            unsafe { ffi::wgpuDeviceDestroy(self.raw) };
18895            ()
18896        }
18897        pub fn get_a_hardware_buffer_properties(
18898            &self,
18899            handle: *mut std::ffi::c_void,
18900            properties: &mut AHardwareBufferProperties,
18901        ) -> Status {
18902            let (mut properties_ffi, _properties_storage) = properties.to_ffi();
18903            let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
18904            let result = unsafe {
18905                ffi::wgpuDeviceGetAHardwareBufferProperties(
18906                    self.raw,
18907                    handle,
18908                    properties_ptr,
18909                )
18910            };
18911            *properties = AHardwareBufferProperties::from_ffi(properties_ffi);
18912            result.into()
18913        }
18914        pub fn get_limits(&self, limits: &mut Limits) -> Status {
18915            let (mut limits_ffi, _limits_storage) = limits.to_ffi();
18916            let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
18917            let result = unsafe { ffi::wgpuDeviceGetLimits(self.raw, limits_ptr) };
18918            *limits = Limits::from_ffi(limits_ffi);
18919            result.into()
18920        }
18921        pub fn get_lost_future(&self) -> Future {
18922            let result = unsafe { ffi::wgpuDeviceGetLostFuture(self.raw) };
18923            Future::from_ffi(result)
18924        }
18925        pub fn has_feature(&self, feature: FeatureName) -> bool {
18926            let feature_ffi: ffi::WGPUFeatureName = feature.into();
18927            let result = unsafe { ffi::wgpuDeviceHasFeature(self.raw, feature_ffi) };
18928            result != 0
18929        }
18930        pub fn get_features(&self, features: &mut SupportedFeatures) -> () {
18931            let (mut features_ffi, _features_storage) = features.to_ffi();
18932            let features_ptr = std::ptr::addr_of_mut!(features_ffi);
18933            unsafe { ffi::wgpuDeviceGetFeatures(self.raw, features_ptr) };
18934            *features = SupportedFeatures::from_ffi(features_ffi);
18935            ()
18936        }
18937        pub fn get_adapter_info(&self, adapter_info: &mut AdapterInfo) -> Status {
18938            let (mut adapter_info_ffi, _adapter_info_storage) = adapter_info.to_ffi();
18939            let adapter_info_ptr = std::ptr::addr_of_mut!(adapter_info_ffi);
18940            let result = unsafe {
18941                ffi::wgpuDeviceGetAdapterInfo(self.raw, adapter_info_ptr)
18942            };
18943            *adapter_info = AdapterInfo::from_ffi(adapter_info_ffi);
18944            result.into()
18945        }
18946        pub fn get_adapter(&self) -> Adapter {
18947            let result = unsafe { ffi::wgpuDeviceGetAdapter(self.raw) };
18948            unsafe { Adapter::from_raw(result) }
18949        }
18950        pub fn get_queue(&self) -> Queue {
18951            let result = unsafe { ffi::wgpuDeviceGetQueue(self.raw) };
18952            unsafe { Queue::from_raw(result) }
18953        }
18954        pub fn inject_error(&self, r#type: ErrorType, message: String) -> () {
18955            let r#type_ffi: ffi::WGPUErrorType = r#type.into();
18956            let message_ffi = ffi::WGPUStringView {
18957                data: message.as_ptr().cast(),
18958                length: message.len(),
18959            };
18960            unsafe { ffi::wgpuDeviceInjectError(self.raw, r#type_ffi, message_ffi) };
18961            ()
18962        }
18963        pub fn force_loss(&self, r#type: DeviceLostReason, message: String) -> () {
18964            let r#type_ffi: ffi::WGPUDeviceLostReason = r#type.into();
18965            let message_ffi = ffi::WGPUStringView {
18966                data: message.as_ptr().cast(),
18967                length: message.len(),
18968            };
18969            unsafe { ffi::wgpuDeviceForceLoss(self.raw, r#type_ffi, message_ffi) };
18970            ()
18971        }
18972        pub fn tick(&self) -> () {
18973            unsafe { ffi::wgpuDeviceTick(self.raw) };
18974            ()
18975        }
18976        pub fn set_logging_callback(
18977            &self,
18978            callback: impl FnMut(LoggingType, String) + Send + 'static,
18979        ) -> () {
18980            let callback_box: LoggingCallback = Box::new(callback);
18981            let callback_box = Box::new(Some(callback_box));
18982            let callback_userdata = Box::into_raw(callback_box)
18983                .cast::<std::ffi::c_void>();
18984            let callback_info_ffi = ffi::WGPULoggingCallbackInfo {
18985                nextInChain: std::ptr::null_mut(),
18986                callback: Some(logging_callback_trampoline),
18987                userdata1: callback_userdata,
18988                userdata2: std::ptr::null_mut(),
18989            };
18990            unsafe { ffi::wgpuDeviceSetLoggingCallback(self.raw, callback_info_ffi) };
18991            ()
18992        }
18993        pub fn push_error_scope(&self, filter: ErrorFilter) -> () {
18994            let filter_ffi: ffi::WGPUErrorFilter = filter.into();
18995            unsafe { ffi::wgpuDevicePushErrorScope(self.raw, filter_ffi) };
18996            ()
18997        }
18998        pub fn pop_error_scope(
18999            &self,
19000            callback: impl FnMut(PopErrorScopeStatus, ErrorType, String) + Send + 'static,
19001        ) -> Future {
19002            let callback_box: PopErrorScopeCallback = Box::new(callback);
19003            let callback_box = Box::new(Some(callback_box));
19004            let callback_userdata = Box::into_raw(callback_box)
19005                .cast::<std::ffi::c_void>();
19006            let callback_info_ffi = ffi::WGPUPopErrorScopeCallbackInfo {
19007                nextInChain: std::ptr::null_mut(),
19008                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19009                callback: Some(pop_error_scope_callback_trampoline),
19010                userdata1: callback_userdata,
19011                userdata2: std::ptr::null_mut(),
19012            };
19013            let result = unsafe {
19014                ffi::wgpuDevicePopErrorScope(self.raw, callback_info_ffi)
19015            };
19016            Future::from_ffi(result)
19017        }
19018        pub fn set_label(&self, label: String) -> () {
19019            let label_ffi = ffi::WGPUStringView {
19020                data: label.as_ptr().cast(),
19021                length: label.len(),
19022            };
19023            unsafe { ffi::wgpuDeviceSetLabel(self.raw, label_ffi) };
19024            ()
19025        }
19026        pub fn validate_texture_descriptor(&self, descriptor: &TextureDescriptor) -> () {
19027            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19028            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19029            unsafe {
19030                ffi::wgpuDeviceValidateTextureDescriptor(self.raw, descriptor_ptr)
19031            };
19032            ()
19033        }
19034    }
19035    impl Drop for Device {
19036        fn drop(&mut self) {
19037            if self.as_raw().is_null() {
19038                return;
19039            }
19040            unsafe { ffi::wgpuDeviceRelease(self.raw) };
19041        }
19042    }
19043    impl Clone for Device {
19044        fn clone(&self) -> Self {
19045            unsafe { ffi::wgpuDeviceAddRef(self.raw) };
19046            Self { raw: self.raw }
19047        }
19048    }
19049    unsafe impl Send for Device {}
19050    unsafe impl Sync for Device {}
19051    #[derive(Debug)]
19052    pub struct ExternalTexture {
19053        raw: ffi::WGPUExternalTexture,
19054    }
19055    impl ExternalTexture {
19056        pub(crate) unsafe fn from_raw(raw: ffi::WGPUExternalTexture) -> Self {
19057            Self { raw }
19058        }
19059        pub(crate) fn as_raw(&self) -> ffi::WGPUExternalTexture {
19060            self.raw
19061        }
19062        pub fn set_label(&self, label: String) -> () {
19063            let label_ffi = ffi::WGPUStringView {
19064                data: label.as_ptr().cast(),
19065                length: label.len(),
19066            };
19067            unsafe { ffi::wgpuExternalTextureSetLabel(self.raw, label_ffi) };
19068            ()
19069        }
19070        pub fn destroy(&self) -> () {
19071            unsafe { ffi::wgpuExternalTextureDestroy(self.raw) };
19072            ()
19073        }
19074        pub fn expire(&self) -> () {
19075            unsafe { ffi::wgpuExternalTextureExpire(self.raw) };
19076            ()
19077        }
19078        pub fn refresh(&self) -> () {
19079            unsafe { ffi::wgpuExternalTextureRefresh(self.raw) };
19080            ()
19081        }
19082    }
19083    impl Drop for ExternalTexture {
19084        fn drop(&mut self) {
19085            if self.as_raw().is_null() {
19086                return;
19087            }
19088            unsafe { ffi::wgpuExternalTextureRelease(self.raw) };
19089        }
19090    }
19091    impl Clone for ExternalTexture {
19092        fn clone(&self) -> Self {
19093            unsafe { ffi::wgpuExternalTextureAddRef(self.raw) };
19094            Self { raw: self.raw }
19095        }
19096    }
19097    unsafe impl Send for ExternalTexture {}
19098    unsafe impl Sync for ExternalTexture {}
19099    #[derive(Debug)]
19100    pub struct Instance {
19101        raw: ffi::WGPUInstance,
19102    }
19103    impl Instance {
19104        pub(crate) unsafe fn from_raw(raw: ffi::WGPUInstance) -> Self {
19105            Self { raw }
19106        }
19107        pub(crate) fn as_raw(&self) -> ffi::WGPUInstance {
19108            self.raw
19109        }
19110        pub fn new(descriptor: Option<&InstanceDescriptor>) -> Self {
19111            let mut descriptor_storage = ChainedStructStorage::new();
19112            let descriptor_ptr = if let Some(value) = &descriptor {
19113                let (descriptor_ffi, storage) = value.to_ffi();
19114                descriptor_storage = storage;
19115                std::ptr::addr_of!(descriptor_ffi)
19116            } else {
19117                std::ptr::null()
19118            };
19119            let result = unsafe { ffi::wgpuCreateInstance(descriptor_ptr) };
19120            unsafe { Instance::from_raw(result) }
19121        }
19122        pub fn create_surface(&self, descriptor: &SurfaceDescriptor) -> Surface {
19123            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19124            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19125            let result = unsafe {
19126                ffi::wgpuInstanceCreateSurface(self.raw, descriptor_ptr)
19127            };
19128            unsafe { Surface::from_raw(result) }
19129        }
19130        pub fn process_events(&self) -> () {
19131            unsafe { ffi::wgpuInstanceProcessEvents(self.raw) };
19132            ()
19133        }
19134        pub fn wait_any(
19135            &self,
19136            mut futures: Option<&mut [FutureWaitInfo]>,
19137            timeout_ns: u64,
19138        ) -> WaitStatus {
19139            let mut futures_raw: Vec<ffi::WGPUFutureWaitInfo> = Vec::new();
19140            let mut futures_storage: Vec<ChainedStructStorage> = Vec::new();
19141            let futures_ptr = if let Some(value) = futures.as_deref() {
19142                for item in value {
19143                    let (raw, storage) = item.to_ffi();
19144                    futures_raw.push(raw);
19145                    futures_storage.push(storage);
19146                }
19147                futures_raw.as_mut_ptr()
19148            } else {
19149                std::ptr::null_mut()
19150            };
19151            let result = unsafe {
19152                ffi::wgpuInstanceWaitAny(
19153                    self.raw,
19154                    futures.as_deref().map(|v| v.len()).unwrap_or(0),
19155                    futures_ptr,
19156                    timeout_ns,
19157                )
19158            };
19159            result.into()
19160        }
19161        pub fn request_adapter(
19162            &self,
19163            options: Option<&RequestAdapterOptions>,
19164            callback: impl FnMut(
19165                RequestAdapterStatus,
19166                Option<Adapter>,
19167                String,
19168            ) + Send + 'static,
19169        ) -> Future {
19170            let mut options_storage = ChainedStructStorage::new();
19171            let options_ptr = if let Some(value) = &options {
19172                let (options_ffi, storage) = value.to_ffi();
19173                options_storage = storage;
19174                std::ptr::addr_of!(options_ffi)
19175            } else {
19176                std::ptr::null()
19177            };
19178            let callback_box: RequestAdapterCallback = Box::new(callback);
19179            let callback_box = Box::new(Some(callback_box));
19180            let callback_userdata = Box::into_raw(callback_box)
19181                .cast::<std::ffi::c_void>();
19182            let callback_info_ffi = ffi::WGPURequestAdapterCallbackInfo {
19183                nextInChain: std::ptr::null_mut(),
19184                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19185                callback: Some(request_adapter_callback_trampoline),
19186                userdata1: callback_userdata,
19187                userdata2: std::ptr::null_mut(),
19188            };
19189            let result = unsafe {
19190                ffi::wgpuInstanceRequestAdapter(self.raw, options_ptr, callback_info_ffi)
19191            };
19192            Future::from_ffi(result)
19193        }
19194        pub fn has_wgsl_language_feature(
19195            &self,
19196            feature: WGSLLanguageFeatureName,
19197        ) -> bool {
19198            let feature_ffi: ffi::WGPUWGSLLanguageFeatureName = feature.into();
19199            let result = unsafe {
19200                ffi::wgpuInstanceHasWGSLLanguageFeature(self.raw, feature_ffi)
19201            };
19202            result != 0
19203        }
19204        pub fn get_wgsl_language_features(
19205            &self,
19206            features: &mut SupportedWGSLLanguageFeatures,
19207        ) -> () {
19208            let (mut features_ffi, _features_storage) = features.to_ffi();
19209            let features_ptr = std::ptr::addr_of_mut!(features_ffi);
19210            unsafe { ffi::wgpuInstanceGetWGSLLanguageFeatures(self.raw, features_ptr) };
19211            *features = SupportedWGSLLanguageFeatures::from_ffi(features_ffi);
19212            ()
19213        }
19214    }
19215    impl Drop for Instance {
19216        fn drop(&mut self) {
19217            if self.as_raw().is_null() {
19218                return;
19219            }
19220            unsafe { ffi::wgpuInstanceRelease(self.raw) };
19221        }
19222    }
19223    impl Clone for Instance {
19224        fn clone(&self) -> Self {
19225            unsafe { ffi::wgpuInstanceAddRef(self.raw) };
19226            Self { raw: self.raw }
19227        }
19228    }
19229    unsafe impl Send for Instance {}
19230    unsafe impl Sync for Instance {}
19231    #[derive(Debug)]
19232    pub struct PipelineLayout {
19233        raw: ffi::WGPUPipelineLayout,
19234    }
19235    impl PipelineLayout {
19236        pub(crate) unsafe fn from_raw(raw: ffi::WGPUPipelineLayout) -> Self {
19237            Self { raw }
19238        }
19239        pub(crate) fn as_raw(&self) -> ffi::WGPUPipelineLayout {
19240            self.raw
19241        }
19242        pub fn set_label(&self, label: String) -> () {
19243            let label_ffi = ffi::WGPUStringView {
19244                data: label.as_ptr().cast(),
19245                length: label.len(),
19246            };
19247            unsafe { ffi::wgpuPipelineLayoutSetLabel(self.raw, label_ffi) };
19248            ()
19249        }
19250    }
19251    impl Drop for PipelineLayout {
19252        fn drop(&mut self) {
19253            if self.as_raw().is_null() {
19254                return;
19255            }
19256            unsafe { ffi::wgpuPipelineLayoutRelease(self.raw) };
19257        }
19258    }
19259    impl Clone for PipelineLayout {
19260        fn clone(&self) -> Self {
19261            unsafe { ffi::wgpuPipelineLayoutAddRef(self.raw) };
19262            Self { raw: self.raw }
19263        }
19264    }
19265    unsafe impl Send for PipelineLayout {}
19266    unsafe impl Sync for PipelineLayout {}
19267    #[derive(Debug)]
19268    pub struct QuerySet {
19269        raw: ffi::WGPUQuerySet,
19270    }
19271    impl QuerySet {
19272        pub(crate) unsafe fn from_raw(raw: ffi::WGPUQuerySet) -> Self {
19273            Self { raw }
19274        }
19275        pub(crate) fn as_raw(&self) -> ffi::WGPUQuerySet {
19276            self.raw
19277        }
19278        pub fn set_label(&self, label: String) -> () {
19279            let label_ffi = ffi::WGPUStringView {
19280                data: label.as_ptr().cast(),
19281                length: label.len(),
19282            };
19283            unsafe { ffi::wgpuQuerySetSetLabel(self.raw, label_ffi) };
19284            ()
19285        }
19286        pub fn get_type(&self) -> QueryType {
19287            let result = unsafe { ffi::wgpuQuerySetGetType(self.raw) };
19288            result.into()
19289        }
19290        pub fn get_count(&self) -> u32 {
19291            let result = unsafe { ffi::wgpuQuerySetGetCount(self.raw) };
19292            result
19293        }
19294        pub fn destroy(&self) -> () {
19295            unsafe { ffi::wgpuQuerySetDestroy(self.raw) };
19296            ()
19297        }
19298    }
19299    impl Drop for QuerySet {
19300        fn drop(&mut self) {
19301            if self.as_raw().is_null() {
19302                return;
19303            }
19304            unsafe { ffi::wgpuQuerySetRelease(self.raw) };
19305        }
19306    }
19307    impl Clone for QuerySet {
19308        fn clone(&self) -> Self {
19309            unsafe { ffi::wgpuQuerySetAddRef(self.raw) };
19310            Self { raw: self.raw }
19311        }
19312    }
19313    unsafe impl Send for QuerySet {}
19314    unsafe impl Sync for QuerySet {}
19315    #[derive(Debug)]
19316    pub struct Queue {
19317        raw: ffi::WGPUQueue,
19318    }
19319    impl Queue {
19320        pub(crate) unsafe fn from_raw(raw: ffi::WGPUQueue) -> Self {
19321            Self { raw }
19322        }
19323        pub(crate) fn as_raw(&self) -> ffi::WGPUQueue {
19324            self.raw
19325        }
19326        pub fn submit(&self, commands: &[CommandBuffer]) -> () {
19327            let mut commands_raw: Vec<ffi::WGPUCommandBuffer> = commands
19328                .iter()
19329                .map(|v| v.as_raw())
19330                .collect();
19331            let commands_ptr = commands_raw.as_ptr();
19332            unsafe { ffi::wgpuQueueSubmit(self.raw, commands.len(), commands_ptr) };
19333            ()
19334        }
19335        pub fn on_submitted_work_done(
19336            &self,
19337            callback: impl FnMut(QueueWorkDoneStatus, String) + Send + 'static,
19338        ) -> Future {
19339            let callback_box: QueueWorkDoneCallback = Box::new(callback);
19340            let callback_box = Box::new(Some(callback_box));
19341            let callback_userdata = Box::into_raw(callback_box)
19342                .cast::<std::ffi::c_void>();
19343            let callback_info_ffi = ffi::WGPUQueueWorkDoneCallbackInfo {
19344                nextInChain: std::ptr::null_mut(),
19345                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19346                callback: Some(queue_work_done_callback_trampoline),
19347                userdata1: callback_userdata,
19348                userdata2: std::ptr::null_mut(),
19349            };
19350            let result = unsafe {
19351                ffi::wgpuQueueOnSubmittedWorkDone(self.raw, callback_info_ffi)
19352            };
19353            Future::from_ffi(result)
19354        }
19355        pub fn write_buffer(
19356            &self,
19357            buffer: Buffer,
19358            buffer_offset: u64,
19359            data: &[std::ffi::c_void],
19360        ) -> () {
19361            let data_ptr = data.as_ptr();
19362            unsafe {
19363                ffi::wgpuQueueWriteBuffer(
19364                    self.raw,
19365                    buffer.as_raw(),
19366                    buffer_offset,
19367                    data_ptr,
19368                    data.len(),
19369                )
19370            };
19371            ()
19372        }
19373        pub fn write_texture(
19374            &self,
19375            destination: &TexelCopyTextureInfo,
19376            data: &[std::ffi::c_void],
19377            data_layout: &TexelCopyBufferLayout,
19378            write_size: &Extent3D,
19379        ) -> () {
19380            let (destination_ffi, _destination_storage) = destination.to_ffi();
19381            let destination_ptr = std::ptr::addr_of!(destination_ffi);
19382            let data_ptr = data.as_ptr();
19383            let (data_layout_ffi, _data_layout_storage) = data_layout.to_ffi();
19384            let data_layout_ptr = std::ptr::addr_of!(data_layout_ffi);
19385            let (write_size_ffi, _write_size_storage) = write_size.to_ffi();
19386            let write_size_ptr = std::ptr::addr_of!(write_size_ffi);
19387            unsafe {
19388                ffi::wgpuQueueWriteTexture(
19389                    self.raw,
19390                    destination_ptr,
19391                    data_ptr,
19392                    data.len(),
19393                    data_layout_ptr,
19394                    write_size_ptr,
19395                )
19396            };
19397            ()
19398        }
19399        pub fn copy_texture_for_browser(
19400            &self,
19401            source: &TexelCopyTextureInfo,
19402            destination: &TexelCopyTextureInfo,
19403            copy_size: &Extent3D,
19404            options: &CopyTextureForBrowserOptions,
19405        ) -> () {
19406            let (source_ffi, _source_storage) = source.to_ffi();
19407            let source_ptr = std::ptr::addr_of!(source_ffi);
19408            let (destination_ffi, _destination_storage) = destination.to_ffi();
19409            let destination_ptr = std::ptr::addr_of!(destination_ffi);
19410            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
19411            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
19412            let (options_ffi, _options_storage) = options.to_ffi();
19413            let options_ptr = std::ptr::addr_of!(options_ffi);
19414            unsafe {
19415                ffi::wgpuQueueCopyTextureForBrowser(
19416                    self.raw,
19417                    source_ptr,
19418                    destination_ptr,
19419                    copy_size_ptr,
19420                    options_ptr,
19421                )
19422            };
19423            ()
19424        }
19425        pub fn copy_external_texture_for_browser(
19426            &self,
19427            source: &ImageCopyExternalTexture,
19428            destination: &TexelCopyTextureInfo,
19429            copy_size: &Extent3D,
19430            options: &CopyTextureForBrowserOptions,
19431        ) -> () {
19432            let (source_ffi, _source_storage) = source.to_ffi();
19433            let source_ptr = std::ptr::addr_of!(source_ffi);
19434            let (destination_ffi, _destination_storage) = destination.to_ffi();
19435            let destination_ptr = std::ptr::addr_of!(destination_ffi);
19436            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
19437            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
19438            let (options_ffi, _options_storage) = options.to_ffi();
19439            let options_ptr = std::ptr::addr_of!(options_ffi);
19440            unsafe {
19441                ffi::wgpuQueueCopyExternalTextureForBrowser(
19442                    self.raw,
19443                    source_ptr,
19444                    destination_ptr,
19445                    copy_size_ptr,
19446                    options_ptr,
19447                )
19448            };
19449            ()
19450        }
19451        pub fn set_label(&self, label: String) -> () {
19452            let label_ffi = ffi::WGPUStringView {
19453                data: label.as_ptr().cast(),
19454                length: label.len(),
19455            };
19456            unsafe { ffi::wgpuQueueSetLabel(self.raw, label_ffi) };
19457            ()
19458        }
19459    }
19460    impl Drop for Queue {
19461        fn drop(&mut self) {
19462            if self.as_raw().is_null() {
19463                return;
19464            }
19465            unsafe { ffi::wgpuQueueRelease(self.raw) };
19466        }
19467    }
19468    impl Clone for Queue {
19469        fn clone(&self) -> Self {
19470            unsafe { ffi::wgpuQueueAddRef(self.raw) };
19471            Self { raw: self.raw }
19472        }
19473    }
19474    unsafe impl Send for Queue {}
19475    unsafe impl Sync for Queue {}
19476    #[derive(Debug)]
19477    pub struct RenderBundle {
19478        raw: ffi::WGPURenderBundle,
19479    }
19480    impl RenderBundle {
19481        pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderBundle) -> Self {
19482            Self { raw }
19483        }
19484        pub(crate) fn as_raw(&self) -> ffi::WGPURenderBundle {
19485            self.raw
19486        }
19487        pub fn set_label(&self, label: String) -> () {
19488            let label_ffi = ffi::WGPUStringView {
19489                data: label.as_ptr().cast(),
19490                length: label.len(),
19491            };
19492            unsafe { ffi::wgpuRenderBundleSetLabel(self.raw, label_ffi) };
19493            ()
19494        }
19495    }
19496    impl Drop for RenderBundle {
19497        fn drop(&mut self) {
19498            if self.as_raw().is_null() {
19499                return;
19500            }
19501            unsafe { ffi::wgpuRenderBundleRelease(self.raw) };
19502        }
19503    }
19504    impl Clone for RenderBundle {
19505        fn clone(&self) -> Self {
19506            unsafe { ffi::wgpuRenderBundleAddRef(self.raw) };
19507            Self { raw: self.raw }
19508        }
19509    }
19510    unsafe impl Send for RenderBundle {}
19511    unsafe impl Sync for RenderBundle {}
19512    #[derive(Debug)]
19513    pub struct RenderBundleEncoder {
19514        raw: ffi::WGPURenderBundleEncoder,
19515    }
19516    impl RenderBundleEncoder {
19517        pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderBundleEncoder) -> Self {
19518            Self { raw }
19519        }
19520        pub(crate) fn as_raw(&self) -> ffi::WGPURenderBundleEncoder {
19521            self.raw
19522        }
19523        pub fn set_pipeline(&self, pipeline: RenderPipeline) -> () {
19524            unsafe {
19525                ffi::wgpuRenderBundleEncoderSetPipeline(self.raw, pipeline.as_raw())
19526            };
19527            ()
19528        }
19529        pub fn set_bind_group(
19530            &self,
19531            group_index: u32,
19532            group: Option<BindGroup>,
19533            dynamic_offsets: &[u32],
19534        ) -> () {
19535            let group_raw = group
19536                .as_ref()
19537                .map(|v| v.as_raw())
19538                .unwrap_or(std::ptr::null_mut());
19539            let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
19540            unsafe {
19541                ffi::wgpuRenderBundleEncoderSetBindGroup(
19542                    self.raw,
19543                    group_index,
19544                    group_raw,
19545                    dynamic_offsets.len(),
19546                    dynamic_offsets_ptr,
19547                )
19548            };
19549            ()
19550        }
19551        pub fn draw(
19552            &self,
19553            vertex_count: u32,
19554            instance_count: u32,
19555            first_vertex: u32,
19556            first_instance: u32,
19557        ) -> () {
19558            unsafe {
19559                ffi::wgpuRenderBundleEncoderDraw(
19560                    self.raw,
19561                    vertex_count,
19562                    instance_count,
19563                    first_vertex,
19564                    first_instance,
19565                )
19566            };
19567            ()
19568        }
19569        pub fn draw_indexed(
19570            &self,
19571            index_count: u32,
19572            instance_count: u32,
19573            first_index: u32,
19574            base_vertex: i32,
19575            first_instance: u32,
19576        ) -> () {
19577            unsafe {
19578                ffi::wgpuRenderBundleEncoderDrawIndexed(
19579                    self.raw,
19580                    index_count,
19581                    instance_count,
19582                    first_index,
19583                    base_vertex,
19584                    first_instance,
19585                )
19586            };
19587            ()
19588        }
19589        pub fn draw_indirect(
19590            &self,
19591            indirect_buffer: Buffer,
19592            indirect_offset: u64,
19593        ) -> () {
19594            unsafe {
19595                ffi::wgpuRenderBundleEncoderDrawIndirect(
19596                    self.raw,
19597                    indirect_buffer.as_raw(),
19598                    indirect_offset,
19599                )
19600            };
19601            ()
19602        }
19603        pub fn draw_indexed_indirect(
19604            &self,
19605            indirect_buffer: Buffer,
19606            indirect_offset: u64,
19607        ) -> () {
19608            unsafe {
19609                ffi::wgpuRenderBundleEncoderDrawIndexedIndirect(
19610                    self.raw,
19611                    indirect_buffer.as_raw(),
19612                    indirect_offset,
19613                )
19614            };
19615            ()
19616        }
19617        pub fn insert_debug_marker(&self, marker_label: String) -> () {
19618            let marker_label_ffi = ffi::WGPUStringView {
19619                data: marker_label.as_ptr().cast(),
19620                length: marker_label.len(),
19621            };
19622            unsafe {
19623                ffi::wgpuRenderBundleEncoderInsertDebugMarker(self.raw, marker_label_ffi)
19624            };
19625            ()
19626        }
19627        pub fn pop_debug_group(&self) -> () {
19628            unsafe { ffi::wgpuRenderBundleEncoderPopDebugGroup(self.raw) };
19629            ()
19630        }
19631        pub fn push_debug_group(&self, group_label: String) -> () {
19632            let group_label_ffi = ffi::WGPUStringView {
19633                data: group_label.as_ptr().cast(),
19634                length: group_label.len(),
19635            };
19636            unsafe {
19637                ffi::wgpuRenderBundleEncoderPushDebugGroup(self.raw, group_label_ffi)
19638            };
19639            ()
19640        }
19641        pub fn set_vertex_buffer(
19642            &self,
19643            slot: u32,
19644            buffer: Option<Buffer>,
19645            offset: u64,
19646            size: u64,
19647        ) -> () {
19648            let buffer_raw = buffer
19649                .as_ref()
19650                .map(|v| v.as_raw())
19651                .unwrap_or(std::ptr::null_mut());
19652            unsafe {
19653                ffi::wgpuRenderBundleEncoderSetVertexBuffer(
19654                    self.raw,
19655                    slot,
19656                    buffer_raw,
19657                    offset,
19658                    size,
19659                )
19660            };
19661            ()
19662        }
19663        pub fn set_index_buffer(
19664            &self,
19665            buffer: Buffer,
19666            format: IndexFormat,
19667            offset: u64,
19668            size: u64,
19669        ) -> () {
19670            let format_ffi: ffi::WGPUIndexFormat = format.into();
19671            unsafe {
19672                ffi::wgpuRenderBundleEncoderSetIndexBuffer(
19673                    self.raw,
19674                    buffer.as_raw(),
19675                    format_ffi,
19676                    offset,
19677                    size,
19678                )
19679            };
19680            ()
19681        }
19682        pub fn finish(
19683            &self,
19684            descriptor: Option<&RenderBundleDescriptor>,
19685        ) -> RenderBundle {
19686            let mut descriptor_storage = ChainedStructStorage::new();
19687            let descriptor_ptr = if let Some(value) = &descriptor {
19688                let (descriptor_ffi, storage) = value.to_ffi();
19689                descriptor_storage = storage;
19690                std::ptr::addr_of!(descriptor_ffi)
19691            } else {
19692                std::ptr::null()
19693            };
19694            let result = unsafe {
19695                ffi::wgpuRenderBundleEncoderFinish(self.raw, descriptor_ptr)
19696            };
19697            unsafe { RenderBundle::from_raw(result) }
19698        }
19699        pub fn set_label(&self, label: String) -> () {
19700            let label_ffi = ffi::WGPUStringView {
19701                data: label.as_ptr().cast(),
19702                length: label.len(),
19703            };
19704            unsafe { ffi::wgpuRenderBundleEncoderSetLabel(self.raw, label_ffi) };
19705            ()
19706        }
19707        pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
19708            let data_ptr = data.as_ptr();
19709            unsafe {
19710                ffi::wgpuRenderBundleEncoderSetImmediates(
19711                    self.raw,
19712                    offset,
19713                    data_ptr,
19714                    data.len(),
19715                )
19716            };
19717            ()
19718        }
19719        pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
19720            let table_raw = table
19721                .as_ref()
19722                .map(|v| v.as_raw())
19723                .unwrap_or(std::ptr::null_mut());
19724            unsafe { ffi::wgpuRenderBundleEncoderSetResourceTable(self.raw, table_raw) };
19725            ()
19726        }
19727    }
19728    impl Drop for RenderBundleEncoder {
19729        fn drop(&mut self) {
19730            if self.as_raw().is_null() {
19731                return;
19732            }
19733            unsafe { ffi::wgpuRenderBundleEncoderRelease(self.raw) };
19734        }
19735    }
19736    impl Clone for RenderBundleEncoder {
19737        fn clone(&self) -> Self {
19738            unsafe { ffi::wgpuRenderBundleEncoderAddRef(self.raw) };
19739            Self { raw: self.raw }
19740        }
19741    }
19742    unsafe impl Send for RenderBundleEncoder {}
19743    unsafe impl Sync for RenderBundleEncoder {}
19744    #[derive(Debug)]
19745    pub struct RenderPassEncoder {
19746        raw: ffi::WGPURenderPassEncoder,
19747    }
19748    impl RenderPassEncoder {
19749        pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderPassEncoder) -> Self {
19750            Self { raw }
19751        }
19752        pub(crate) fn as_raw(&self) -> ffi::WGPURenderPassEncoder {
19753            self.raw
19754        }
19755        pub fn set_pipeline(&self, pipeline: RenderPipeline) -> () {
19756            unsafe {
19757                ffi::wgpuRenderPassEncoderSetPipeline(self.raw, pipeline.as_raw())
19758            };
19759            ()
19760        }
19761        pub fn set_bind_group(
19762            &self,
19763            group_index: u32,
19764            group: Option<BindGroup>,
19765            dynamic_offsets: &[u32],
19766        ) -> () {
19767            let group_raw = group
19768                .as_ref()
19769                .map(|v| v.as_raw())
19770                .unwrap_or(std::ptr::null_mut());
19771            let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
19772            unsafe {
19773                ffi::wgpuRenderPassEncoderSetBindGroup(
19774                    self.raw,
19775                    group_index,
19776                    group_raw,
19777                    dynamic_offsets.len(),
19778                    dynamic_offsets_ptr,
19779                )
19780            };
19781            ()
19782        }
19783        pub fn draw(
19784            &self,
19785            vertex_count: u32,
19786            instance_count: u32,
19787            first_vertex: u32,
19788            first_instance: u32,
19789        ) -> () {
19790            unsafe {
19791                ffi::wgpuRenderPassEncoderDraw(
19792                    self.raw,
19793                    vertex_count,
19794                    instance_count,
19795                    first_vertex,
19796                    first_instance,
19797                )
19798            };
19799            ()
19800        }
19801        pub fn draw_indexed(
19802            &self,
19803            index_count: u32,
19804            instance_count: u32,
19805            first_index: u32,
19806            base_vertex: i32,
19807            first_instance: u32,
19808        ) -> () {
19809            unsafe {
19810                ffi::wgpuRenderPassEncoderDrawIndexed(
19811                    self.raw,
19812                    index_count,
19813                    instance_count,
19814                    first_index,
19815                    base_vertex,
19816                    first_instance,
19817                )
19818            };
19819            ()
19820        }
19821        pub fn draw_indirect(
19822            &self,
19823            indirect_buffer: Buffer,
19824            indirect_offset: u64,
19825        ) -> () {
19826            unsafe {
19827                ffi::wgpuRenderPassEncoderDrawIndirect(
19828                    self.raw,
19829                    indirect_buffer.as_raw(),
19830                    indirect_offset,
19831                )
19832            };
19833            ()
19834        }
19835        pub fn draw_indexed_indirect(
19836            &self,
19837            indirect_buffer: Buffer,
19838            indirect_offset: u64,
19839        ) -> () {
19840            unsafe {
19841                ffi::wgpuRenderPassEncoderDrawIndexedIndirect(
19842                    self.raw,
19843                    indirect_buffer.as_raw(),
19844                    indirect_offset,
19845                )
19846            };
19847            ()
19848        }
19849        pub fn multi_draw_indirect(
19850            &self,
19851            indirect_buffer: Buffer,
19852            indirect_offset: u64,
19853            max_draw_count: u32,
19854            draw_count_buffer: Option<Buffer>,
19855            draw_count_buffer_offset: u64,
19856        ) -> () {
19857            let draw_count_buffer_raw = draw_count_buffer
19858                .as_ref()
19859                .map(|v| v.as_raw())
19860                .unwrap_or(std::ptr::null_mut());
19861            unsafe {
19862                ffi::wgpuRenderPassEncoderMultiDrawIndirect(
19863                    self.raw,
19864                    indirect_buffer.as_raw(),
19865                    indirect_offset,
19866                    max_draw_count,
19867                    draw_count_buffer_raw,
19868                    draw_count_buffer_offset,
19869                )
19870            };
19871            ()
19872        }
19873        pub fn multi_draw_indexed_indirect(
19874            &self,
19875            indirect_buffer: Buffer,
19876            indirect_offset: u64,
19877            max_draw_count: u32,
19878            draw_count_buffer: Option<Buffer>,
19879            draw_count_buffer_offset: u64,
19880        ) -> () {
19881            let draw_count_buffer_raw = draw_count_buffer
19882                .as_ref()
19883                .map(|v| v.as_raw())
19884                .unwrap_or(std::ptr::null_mut());
19885            unsafe {
19886                ffi::wgpuRenderPassEncoderMultiDrawIndexedIndirect(
19887                    self.raw,
19888                    indirect_buffer.as_raw(),
19889                    indirect_offset,
19890                    max_draw_count,
19891                    draw_count_buffer_raw,
19892                    draw_count_buffer_offset,
19893                )
19894            };
19895            ()
19896        }
19897        pub fn execute_bundles(&self, bundles: &[RenderBundle]) -> () {
19898            let mut bundles_raw: Vec<ffi::WGPURenderBundle> = bundles
19899                .iter()
19900                .map(|v| v.as_raw())
19901                .collect();
19902            let bundles_ptr = bundles_raw.as_ptr();
19903            unsafe {
19904                ffi::wgpuRenderPassEncoderExecuteBundles(
19905                    self.raw,
19906                    bundles.len(),
19907                    bundles_ptr,
19908                )
19909            };
19910            ()
19911        }
19912        pub fn insert_debug_marker(&self, marker_label: String) -> () {
19913            let marker_label_ffi = ffi::WGPUStringView {
19914                data: marker_label.as_ptr().cast(),
19915                length: marker_label.len(),
19916            };
19917            unsafe {
19918                ffi::wgpuRenderPassEncoderInsertDebugMarker(self.raw, marker_label_ffi)
19919            };
19920            ()
19921        }
19922        pub fn pop_debug_group(&self) -> () {
19923            unsafe { ffi::wgpuRenderPassEncoderPopDebugGroup(self.raw) };
19924            ()
19925        }
19926        pub fn push_debug_group(&self, group_label: String) -> () {
19927            let group_label_ffi = ffi::WGPUStringView {
19928                data: group_label.as_ptr().cast(),
19929                length: group_label.len(),
19930            };
19931            unsafe {
19932                ffi::wgpuRenderPassEncoderPushDebugGroup(self.raw, group_label_ffi)
19933            };
19934            ()
19935        }
19936        pub fn set_stencil_reference(&self, reference: u32) -> () {
19937            unsafe {
19938                ffi::wgpuRenderPassEncoderSetStencilReference(self.raw, reference)
19939            };
19940            ()
19941        }
19942        pub fn set_blend_constant(&self, color: &Color) -> () {
19943            let (color_ffi, _color_storage) = color.to_ffi();
19944            let color_ptr = std::ptr::addr_of!(color_ffi);
19945            unsafe { ffi::wgpuRenderPassEncoderSetBlendConstant(self.raw, color_ptr) };
19946            ()
19947        }
19948        pub fn set_viewport(
19949            &self,
19950            x: f32,
19951            y: f32,
19952            width: f32,
19953            height: f32,
19954            min_depth: f32,
19955            max_depth: f32,
19956        ) -> () {
19957            unsafe {
19958                ffi::wgpuRenderPassEncoderSetViewport(
19959                    self.raw,
19960                    x,
19961                    y,
19962                    width,
19963                    height,
19964                    min_depth,
19965                    max_depth,
19966                )
19967            };
19968            ()
19969        }
19970        pub fn set_scissor_rect(&self, x: u32, y: u32, width: u32, height: u32) -> () {
19971            unsafe {
19972                ffi::wgpuRenderPassEncoderSetScissorRect(self.raw, x, y, width, height)
19973            };
19974            ()
19975        }
19976        pub fn set_vertex_buffer(
19977            &self,
19978            slot: u32,
19979            buffer: Option<Buffer>,
19980            offset: u64,
19981            size: u64,
19982        ) -> () {
19983            let buffer_raw = buffer
19984                .as_ref()
19985                .map(|v| v.as_raw())
19986                .unwrap_or(std::ptr::null_mut());
19987            unsafe {
19988                ffi::wgpuRenderPassEncoderSetVertexBuffer(
19989                    self.raw,
19990                    slot,
19991                    buffer_raw,
19992                    offset,
19993                    size,
19994                )
19995            };
19996            ()
19997        }
19998        pub fn set_index_buffer(
19999            &self,
20000            buffer: Buffer,
20001            format: IndexFormat,
20002            offset: u64,
20003            size: u64,
20004        ) -> () {
20005            let format_ffi: ffi::WGPUIndexFormat = format.into();
20006            unsafe {
20007                ffi::wgpuRenderPassEncoderSetIndexBuffer(
20008                    self.raw,
20009                    buffer.as_raw(),
20010                    format_ffi,
20011                    offset,
20012                    size,
20013                )
20014            };
20015            ()
20016        }
20017        pub fn begin_occlusion_query(&self, query_index: u32) -> () {
20018            unsafe {
20019                ffi::wgpuRenderPassEncoderBeginOcclusionQuery(self.raw, query_index)
20020            };
20021            ()
20022        }
20023        pub fn end_occlusion_query(&self) -> () {
20024            unsafe { ffi::wgpuRenderPassEncoderEndOcclusionQuery(self.raw) };
20025            ()
20026        }
20027        pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
20028            unsafe {
20029                ffi::wgpuRenderPassEncoderWriteTimestamp(
20030                    self.raw,
20031                    query_set.as_raw(),
20032                    query_index,
20033                )
20034            };
20035            ()
20036        }
20037        pub fn pixel_local_storage_barrier(&self) -> () {
20038            unsafe { ffi::wgpuRenderPassEncoderPixelLocalStorageBarrier(self.raw) };
20039            ()
20040        }
20041        pub fn end(&self) -> () {
20042            unsafe { ffi::wgpuRenderPassEncoderEnd(self.raw) };
20043            ()
20044        }
20045        pub fn set_label(&self, label: String) -> () {
20046            let label_ffi = ffi::WGPUStringView {
20047                data: label.as_ptr().cast(),
20048                length: label.len(),
20049            };
20050            unsafe { ffi::wgpuRenderPassEncoderSetLabel(self.raw, label_ffi) };
20051            ()
20052        }
20053        pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
20054            let data_ptr = data.as_ptr();
20055            unsafe {
20056                ffi::wgpuRenderPassEncoderSetImmediates(
20057                    self.raw,
20058                    offset,
20059                    data_ptr,
20060                    data.len(),
20061                )
20062            };
20063            ()
20064        }
20065        pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
20066            let table_raw = table
20067                .as_ref()
20068                .map(|v| v.as_raw())
20069                .unwrap_or(std::ptr::null_mut());
20070            unsafe { ffi::wgpuRenderPassEncoderSetResourceTable(self.raw, table_raw) };
20071            ()
20072        }
20073    }
20074    impl Drop for RenderPassEncoder {
20075        fn drop(&mut self) {
20076            if self.as_raw().is_null() {
20077                return;
20078            }
20079            unsafe { ffi::wgpuRenderPassEncoderRelease(self.raw) };
20080        }
20081    }
20082    impl Clone for RenderPassEncoder {
20083        fn clone(&self) -> Self {
20084            unsafe { ffi::wgpuRenderPassEncoderAddRef(self.raw) };
20085            Self { raw: self.raw }
20086        }
20087    }
20088    unsafe impl Send for RenderPassEncoder {}
20089    unsafe impl Sync for RenderPassEncoder {}
20090    #[derive(Debug)]
20091    pub struct RenderPipeline {
20092        raw: ffi::WGPURenderPipeline,
20093    }
20094    impl RenderPipeline {
20095        pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderPipeline) -> Self {
20096            Self { raw }
20097        }
20098        pub(crate) fn as_raw(&self) -> ffi::WGPURenderPipeline {
20099            self.raw
20100        }
20101        pub fn get_bind_group_layout(&self, group_index: u32) -> BindGroupLayout {
20102            let result = unsafe {
20103                ffi::wgpuRenderPipelineGetBindGroupLayout(self.raw, group_index)
20104            };
20105            unsafe { BindGroupLayout::from_raw(result) }
20106        }
20107        pub fn set_label(&self, label: String) -> () {
20108            let label_ffi = ffi::WGPUStringView {
20109                data: label.as_ptr().cast(),
20110                length: label.len(),
20111            };
20112            unsafe { ffi::wgpuRenderPipelineSetLabel(self.raw, label_ffi) };
20113            ()
20114        }
20115    }
20116    impl Drop for RenderPipeline {
20117        fn drop(&mut self) {
20118            if self.as_raw().is_null() {
20119                return;
20120            }
20121            unsafe { ffi::wgpuRenderPipelineRelease(self.raw) };
20122        }
20123    }
20124    impl Clone for RenderPipeline {
20125        fn clone(&self) -> Self {
20126            unsafe { ffi::wgpuRenderPipelineAddRef(self.raw) };
20127            Self { raw: self.raw }
20128        }
20129    }
20130    unsafe impl Send for RenderPipeline {}
20131    unsafe impl Sync for RenderPipeline {}
20132    #[derive(Debug)]
20133    pub struct ResourceTable {
20134        raw: ffi::WGPUResourceTable,
20135    }
20136    impl ResourceTable {
20137        pub(crate) unsafe fn from_raw(raw: ffi::WGPUResourceTable) -> Self {
20138            Self { raw }
20139        }
20140        pub(crate) fn as_raw(&self) -> ffi::WGPUResourceTable {
20141            self.raw
20142        }
20143        pub fn get_size(&self) -> u32 {
20144            let result = unsafe { ffi::wgpuResourceTableGetSize(self.raw) };
20145            result
20146        }
20147        pub fn destroy(&self) -> () {
20148            unsafe { ffi::wgpuResourceTableDestroy(self.raw) };
20149            ()
20150        }
20151        pub fn update(&self, slot: u32, resource: &BindingResource) -> Status {
20152            let (resource_ffi, _resource_storage) = resource.to_ffi();
20153            let resource_ptr = std::ptr::addr_of!(resource_ffi);
20154            let result = unsafe {
20155                ffi::wgpuResourceTableUpdate(self.raw, slot, resource_ptr)
20156            };
20157            result.into()
20158        }
20159        pub fn insert_binding(&self, resource: &BindingResource) -> u32 {
20160            let (resource_ffi, _resource_storage) = resource.to_ffi();
20161            let resource_ptr = std::ptr::addr_of!(resource_ffi);
20162            let result = unsafe {
20163                ffi::wgpuResourceTableInsertBinding(self.raw, resource_ptr)
20164            };
20165            result
20166        }
20167        pub fn remove_binding(&self, slot: u32) -> Status {
20168            let result = unsafe { ffi::wgpuResourceTableRemoveBinding(self.raw, slot) };
20169            result.into()
20170        }
20171    }
20172    impl Drop for ResourceTable {
20173        fn drop(&mut self) {
20174            if self.as_raw().is_null() {
20175                return;
20176            }
20177            unsafe { ffi::wgpuResourceTableRelease(self.raw) };
20178        }
20179    }
20180    impl Clone for ResourceTable {
20181        fn clone(&self) -> Self {
20182            unsafe { ffi::wgpuResourceTableAddRef(self.raw) };
20183            Self { raw: self.raw }
20184        }
20185    }
20186    unsafe impl Send for ResourceTable {}
20187    unsafe impl Sync for ResourceTable {}
20188    #[derive(Debug)]
20189    pub struct Sampler {
20190        raw: ffi::WGPUSampler,
20191    }
20192    impl Sampler {
20193        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSampler) -> Self {
20194            Self { raw }
20195        }
20196        pub(crate) fn as_raw(&self) -> ffi::WGPUSampler {
20197            self.raw
20198        }
20199        pub fn set_label(&self, label: String) -> () {
20200            let label_ffi = ffi::WGPUStringView {
20201                data: label.as_ptr().cast(),
20202                length: label.len(),
20203            };
20204            unsafe { ffi::wgpuSamplerSetLabel(self.raw, label_ffi) };
20205            ()
20206        }
20207    }
20208    impl Drop for Sampler {
20209        fn drop(&mut self) {
20210            if self.as_raw().is_null() {
20211                return;
20212            }
20213            unsafe { ffi::wgpuSamplerRelease(self.raw) };
20214        }
20215    }
20216    impl Clone for Sampler {
20217        fn clone(&self) -> Self {
20218            unsafe { ffi::wgpuSamplerAddRef(self.raw) };
20219            Self { raw: self.raw }
20220        }
20221    }
20222    unsafe impl Send for Sampler {}
20223    unsafe impl Sync for Sampler {}
20224    #[derive(Debug)]
20225    pub struct ShaderModule {
20226        raw: ffi::WGPUShaderModule,
20227    }
20228    impl ShaderModule {
20229        pub(crate) unsafe fn from_raw(raw: ffi::WGPUShaderModule) -> Self {
20230            Self { raw }
20231        }
20232        pub(crate) fn as_raw(&self) -> ffi::WGPUShaderModule {
20233            self.raw
20234        }
20235        pub fn get_compilation_info(
20236            &self,
20237            callback: impl FnMut(
20238                CompilationInfoRequestStatus,
20239                &CompilationInfo,
20240            ) + Send + 'static,
20241        ) -> Future {
20242            let callback_box: CompilationInfoCallback = Box::new(callback);
20243            let callback_box = Box::new(Some(callback_box));
20244            let callback_userdata = Box::into_raw(callback_box)
20245                .cast::<std::ffi::c_void>();
20246            let callback_info_ffi = ffi::WGPUCompilationInfoCallbackInfo {
20247                nextInChain: std::ptr::null_mut(),
20248                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
20249                callback: Some(compilation_info_callback_trampoline),
20250                userdata1: callback_userdata,
20251                userdata2: std::ptr::null_mut(),
20252            };
20253            let result = unsafe {
20254                ffi::wgpuShaderModuleGetCompilationInfo(self.raw, callback_info_ffi)
20255            };
20256            Future::from_ffi(result)
20257        }
20258        pub fn set_label(&self, label: String) -> () {
20259            let label_ffi = ffi::WGPUStringView {
20260                data: label.as_ptr().cast(),
20261                length: label.len(),
20262            };
20263            unsafe { ffi::wgpuShaderModuleSetLabel(self.raw, label_ffi) };
20264            ()
20265        }
20266    }
20267    impl Drop for ShaderModule {
20268        fn drop(&mut self) {
20269            if self.as_raw().is_null() {
20270                return;
20271            }
20272            unsafe { ffi::wgpuShaderModuleRelease(self.raw) };
20273        }
20274    }
20275    impl Clone for ShaderModule {
20276        fn clone(&self) -> Self {
20277            unsafe { ffi::wgpuShaderModuleAddRef(self.raw) };
20278            Self { raw: self.raw }
20279        }
20280    }
20281    unsafe impl Send for ShaderModule {}
20282    unsafe impl Sync for ShaderModule {}
20283    #[derive(Debug)]
20284    pub struct SharedBufferMemory {
20285        raw: ffi::WGPUSharedBufferMemory,
20286    }
20287    impl SharedBufferMemory {
20288        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedBufferMemory) -> Self {
20289            Self { raw }
20290        }
20291        pub(crate) fn as_raw(&self) -> ffi::WGPUSharedBufferMemory {
20292            self.raw
20293        }
20294        pub fn set_label(&self, label: String) -> () {
20295            let label_ffi = ffi::WGPUStringView {
20296                data: label.as_ptr().cast(),
20297                length: label.len(),
20298            };
20299            unsafe { ffi::wgpuSharedBufferMemorySetLabel(self.raw, label_ffi) };
20300            ()
20301        }
20302        pub fn get_properties(
20303            &self,
20304            properties: &mut SharedBufferMemoryProperties,
20305        ) -> Status {
20306            let (mut properties_ffi, _properties_storage) = properties.to_ffi();
20307            let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
20308            let result = unsafe {
20309                ffi::wgpuSharedBufferMemoryGetProperties(self.raw, properties_ptr)
20310            };
20311            *properties = SharedBufferMemoryProperties::from_ffi(properties_ffi);
20312            result.into()
20313        }
20314        pub fn create_buffer(&self, descriptor: Option<&BufferDescriptor>) -> Buffer {
20315            let mut descriptor_storage = ChainedStructStorage::new();
20316            let descriptor_ptr = if let Some(value) = &descriptor {
20317                let (descriptor_ffi, storage) = value.to_ffi();
20318                descriptor_storage = storage;
20319                std::ptr::addr_of!(descriptor_ffi)
20320            } else {
20321                std::ptr::null()
20322            };
20323            let result = unsafe {
20324                ffi::wgpuSharedBufferMemoryCreateBuffer(self.raw, descriptor_ptr)
20325            };
20326            unsafe { Buffer::from_raw(result) }
20327        }
20328        pub fn begin_access(
20329            &self,
20330            buffer: Buffer,
20331            descriptor: &SharedBufferMemoryBeginAccessDescriptor,
20332        ) -> Status {
20333            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20334            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
20335            let result = unsafe {
20336                ffi::wgpuSharedBufferMemoryBeginAccess(
20337                    self.raw,
20338                    buffer.as_raw(),
20339                    descriptor_ptr,
20340                )
20341            };
20342            result.into()
20343        }
20344        pub fn end_access(
20345            &self,
20346            buffer: Buffer,
20347            descriptor: &mut SharedBufferMemoryEndAccessState,
20348        ) -> Status {
20349            let (mut descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20350            let descriptor_ptr = std::ptr::addr_of_mut!(descriptor_ffi);
20351            let result = unsafe {
20352                ffi::wgpuSharedBufferMemoryEndAccess(
20353                    self.raw,
20354                    buffer.as_raw(),
20355                    descriptor_ptr,
20356                )
20357            };
20358            *descriptor = SharedBufferMemoryEndAccessState::from_ffi(descriptor_ffi);
20359            result.into()
20360        }
20361        pub fn is_device_lost(&self) -> bool {
20362            let result = unsafe { ffi::wgpuSharedBufferMemoryIsDeviceLost(self.raw) };
20363            result != 0
20364        }
20365    }
20366    impl Drop for SharedBufferMemory {
20367        fn drop(&mut self) {
20368            if self.as_raw().is_null() {
20369                return;
20370            }
20371            unsafe { ffi::wgpuSharedBufferMemoryRelease(self.raw) };
20372        }
20373    }
20374    impl Clone for SharedBufferMemory {
20375        fn clone(&self) -> Self {
20376            unsafe { ffi::wgpuSharedBufferMemoryAddRef(self.raw) };
20377            Self { raw: self.raw }
20378        }
20379    }
20380    unsafe impl Send for SharedBufferMemory {}
20381    unsafe impl Sync for SharedBufferMemory {}
20382    #[derive(Debug)]
20383    pub struct SharedFence {
20384        raw: ffi::WGPUSharedFence,
20385    }
20386    impl SharedFence {
20387        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedFence) -> Self {
20388            Self { raw }
20389        }
20390        pub(crate) fn as_raw(&self) -> ffi::WGPUSharedFence {
20391            self.raw
20392        }
20393        pub fn export_info(&self, info: &mut SharedFenceExportInfo) -> () {
20394            let (mut info_ffi, _info_storage) = info.to_ffi();
20395            let info_ptr = std::ptr::addr_of_mut!(info_ffi);
20396            unsafe { ffi::wgpuSharedFenceExportInfo(self.raw, info_ptr) };
20397            *info = SharedFenceExportInfo::from_ffi(info_ffi);
20398            ()
20399        }
20400    }
20401    impl Drop for SharedFence {
20402        fn drop(&mut self) {
20403            if self.as_raw().is_null() {
20404                return;
20405            }
20406            unsafe { ffi::wgpuSharedFenceRelease(self.raw) };
20407        }
20408    }
20409    impl Clone for SharedFence {
20410        fn clone(&self) -> Self {
20411            unsafe { ffi::wgpuSharedFenceAddRef(self.raw) };
20412            Self { raw: self.raw }
20413        }
20414    }
20415    unsafe impl Send for SharedFence {}
20416    unsafe impl Sync for SharedFence {}
20417    #[derive(Debug)]
20418    pub struct SharedTextureMemory {
20419        raw: ffi::WGPUSharedTextureMemory,
20420    }
20421    impl SharedTextureMemory {
20422        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedTextureMemory) -> Self {
20423            Self { raw }
20424        }
20425        pub(crate) fn as_raw(&self) -> ffi::WGPUSharedTextureMemory {
20426            self.raw
20427        }
20428        pub fn set_label(&self, label: String) -> () {
20429            let label_ffi = ffi::WGPUStringView {
20430                data: label.as_ptr().cast(),
20431                length: label.len(),
20432            };
20433            unsafe { ffi::wgpuSharedTextureMemorySetLabel(self.raw, label_ffi) };
20434            ()
20435        }
20436        pub fn get_properties(
20437            &self,
20438            properties: &mut SharedTextureMemoryProperties,
20439        ) -> Status {
20440            let (mut properties_ffi, _properties_storage) = properties.to_ffi();
20441            let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
20442            let result = unsafe {
20443                ffi::wgpuSharedTextureMemoryGetProperties(self.raw, properties_ptr)
20444            };
20445            *properties = SharedTextureMemoryProperties::from_ffi(properties_ffi);
20446            result.into()
20447        }
20448        pub fn create_texture(&self, descriptor: Option<&TextureDescriptor>) -> Texture {
20449            let mut descriptor_storage = ChainedStructStorage::new();
20450            let descriptor_ptr = if let Some(value) = &descriptor {
20451                let (descriptor_ffi, storage) = value.to_ffi();
20452                descriptor_storage = storage;
20453                std::ptr::addr_of!(descriptor_ffi)
20454            } else {
20455                std::ptr::null()
20456            };
20457            let result = unsafe {
20458                ffi::wgpuSharedTextureMemoryCreateTexture(self.raw, descriptor_ptr)
20459            };
20460            unsafe { Texture::from_raw(result) }
20461        }
20462        pub fn begin_access(
20463            &self,
20464            texture: Texture,
20465            descriptor: &SharedTextureMemoryBeginAccessDescriptor,
20466        ) -> Status {
20467            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20468            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
20469            let result = unsafe {
20470                ffi::wgpuSharedTextureMemoryBeginAccess(
20471                    self.raw,
20472                    texture.as_raw(),
20473                    descriptor_ptr,
20474                )
20475            };
20476            result.into()
20477        }
20478        pub fn end_access(
20479            &self,
20480            texture: Texture,
20481            descriptor: &mut SharedTextureMemoryEndAccessState,
20482        ) -> Status {
20483            let (mut descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20484            let descriptor_ptr = std::ptr::addr_of_mut!(descriptor_ffi);
20485            let result = unsafe {
20486                ffi::wgpuSharedTextureMemoryEndAccess(
20487                    self.raw,
20488                    texture.as_raw(),
20489                    descriptor_ptr,
20490                )
20491            };
20492            *descriptor = SharedTextureMemoryEndAccessState::from_ffi(descriptor_ffi);
20493            result.into()
20494        }
20495        pub fn is_device_lost(&self) -> bool {
20496            let result = unsafe { ffi::wgpuSharedTextureMemoryIsDeviceLost(self.raw) };
20497            result != 0
20498        }
20499    }
20500    impl Drop for SharedTextureMemory {
20501        fn drop(&mut self) {
20502            if self.as_raw().is_null() {
20503                return;
20504            }
20505            unsafe { ffi::wgpuSharedTextureMemoryRelease(self.raw) };
20506        }
20507    }
20508    impl Clone for SharedTextureMemory {
20509        fn clone(&self) -> Self {
20510            unsafe { ffi::wgpuSharedTextureMemoryAddRef(self.raw) };
20511            Self { raw: self.raw }
20512        }
20513    }
20514    unsafe impl Send for SharedTextureMemory {}
20515    unsafe impl Sync for SharedTextureMemory {}
20516    #[derive(Debug)]
20517    pub struct Surface {
20518        raw: ffi::WGPUSurface,
20519    }
20520    impl Surface {
20521        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSurface) -> Self {
20522            Self { raw }
20523        }
20524        pub(crate) fn as_raw(&self) -> ffi::WGPUSurface {
20525            self.raw
20526        }
20527        pub fn configure(&self, config: &SurfaceConfiguration) -> () {
20528            let (config_ffi, _config_storage) = config.to_ffi();
20529            let config_ptr = std::ptr::addr_of!(config_ffi);
20530            unsafe { ffi::wgpuSurfaceConfigure(self.raw, config_ptr) };
20531            ()
20532        }
20533        pub fn get_capabilities(
20534            &self,
20535            adapter: Adapter,
20536            capabilities: &mut SurfaceCapabilities,
20537        ) -> Status {
20538            let (mut capabilities_ffi, _capabilities_storage) = capabilities.to_ffi();
20539            let capabilities_ptr = std::ptr::addr_of_mut!(capabilities_ffi);
20540            let result = unsafe {
20541                ffi::wgpuSurfaceGetCapabilities(
20542                    self.raw,
20543                    adapter.as_raw(),
20544                    capabilities_ptr,
20545                )
20546            };
20547            *capabilities = SurfaceCapabilities::from_ffi(capabilities_ffi);
20548            result.into()
20549        }
20550        pub fn get_current_texture(&self, surface_texture: &mut SurfaceTexture) -> () {
20551            let (mut surface_texture_ffi, _surface_texture_storage) = surface_texture
20552                .to_ffi();
20553            let surface_texture_ptr = std::ptr::addr_of_mut!(surface_texture_ffi);
20554            unsafe { ffi::wgpuSurfaceGetCurrentTexture(self.raw, surface_texture_ptr) };
20555            *surface_texture = SurfaceTexture::from_ffi(surface_texture_ffi);
20556            ()
20557        }
20558        pub fn present(&self) -> Status {
20559            let result = unsafe { ffi::wgpuSurfacePresent(self.raw) };
20560            result.into()
20561        }
20562        pub fn unconfigure(&self) -> () {
20563            unsafe { ffi::wgpuSurfaceUnconfigure(self.raw) };
20564            ()
20565        }
20566        pub fn set_label(&self, label: String) -> () {
20567            let label_ffi = ffi::WGPUStringView {
20568                data: label.as_ptr().cast(),
20569                length: label.len(),
20570            };
20571            unsafe { ffi::wgpuSurfaceSetLabel(self.raw, label_ffi) };
20572            ()
20573        }
20574    }
20575    impl Drop for Surface {
20576        fn drop(&mut self) {
20577            if self.as_raw().is_null() {
20578                return;
20579            }
20580            unsafe { ffi::wgpuSurfaceRelease(self.raw) };
20581        }
20582    }
20583    impl Clone for Surface {
20584        fn clone(&self) -> Self {
20585            unsafe { ffi::wgpuSurfaceAddRef(self.raw) };
20586            Self { raw: self.raw }
20587        }
20588    }
20589    unsafe impl Send for Surface {}
20590    unsafe impl Sync for Surface {}
20591    #[derive(Debug)]
20592    pub struct TexelBufferView {
20593        raw: ffi::WGPUTexelBufferView,
20594    }
20595    impl TexelBufferView {
20596        pub(crate) unsafe fn from_raw(raw: ffi::WGPUTexelBufferView) -> Self {
20597            Self { raw }
20598        }
20599        pub(crate) fn as_raw(&self) -> ffi::WGPUTexelBufferView {
20600            self.raw
20601        }
20602        pub fn set_label(&self, label: String) -> () {
20603            let label_ffi = ffi::WGPUStringView {
20604                data: label.as_ptr().cast(),
20605                length: label.len(),
20606            };
20607            unsafe { ffi::wgpuTexelBufferViewSetLabel(self.raw, label_ffi) };
20608            ()
20609        }
20610    }
20611    impl Drop for TexelBufferView {
20612        fn drop(&mut self) {
20613            if self.as_raw().is_null() {
20614                return;
20615            }
20616            unsafe { ffi::wgpuTexelBufferViewRelease(self.raw) };
20617        }
20618    }
20619    impl Clone for TexelBufferView {
20620        fn clone(&self) -> Self {
20621            unsafe { ffi::wgpuTexelBufferViewAddRef(self.raw) };
20622            Self { raw: self.raw }
20623        }
20624    }
20625    unsafe impl Send for TexelBufferView {}
20626    unsafe impl Sync for TexelBufferView {}
20627    #[derive(Debug)]
20628    pub struct Texture {
20629        raw: ffi::WGPUTexture,
20630    }
20631    impl Texture {
20632        pub(crate) unsafe fn from_raw(raw: ffi::WGPUTexture) -> Self {
20633            Self { raw }
20634        }
20635        pub(crate) fn as_raw(&self) -> ffi::WGPUTexture {
20636            self.raw
20637        }
20638        pub fn create_view(
20639            &self,
20640            descriptor: Option<&TextureViewDescriptor>,
20641        ) -> TextureView {
20642            let mut descriptor_storage = ChainedStructStorage::new();
20643            let descriptor_ptr = if let Some(value) = &descriptor {
20644                let (descriptor_ffi, storage) = value.to_ffi();
20645                descriptor_storage = storage;
20646                std::ptr::addr_of!(descriptor_ffi)
20647            } else {
20648                std::ptr::null()
20649            };
20650            let result = unsafe { ffi::wgpuTextureCreateView(self.raw, descriptor_ptr) };
20651            unsafe { TextureView::from_raw(result) }
20652        }
20653        pub fn create_error_view(
20654            &self,
20655            descriptor: Option<&TextureViewDescriptor>,
20656        ) -> TextureView {
20657            let mut descriptor_storage = ChainedStructStorage::new();
20658            let descriptor_ptr = if let Some(value) = &descriptor {
20659                let (descriptor_ffi, storage) = value.to_ffi();
20660                descriptor_storage = storage;
20661                std::ptr::addr_of!(descriptor_ffi)
20662            } else {
20663                std::ptr::null()
20664            };
20665            let result = unsafe {
20666                ffi::wgpuTextureCreateErrorView(self.raw, descriptor_ptr)
20667            };
20668            unsafe { TextureView::from_raw(result) }
20669        }
20670        pub fn set_label(&self, label: String) -> () {
20671            let label_ffi = ffi::WGPUStringView {
20672                data: label.as_ptr().cast(),
20673                length: label.len(),
20674            };
20675            unsafe { ffi::wgpuTextureSetLabel(self.raw, label_ffi) };
20676            ()
20677        }
20678        pub fn get_width(&self) -> u32 {
20679            let result = unsafe { ffi::wgpuTextureGetWidth(self.raw) };
20680            result
20681        }
20682        pub fn get_height(&self) -> u32 {
20683            let result = unsafe { ffi::wgpuTextureGetHeight(self.raw) };
20684            result
20685        }
20686        pub fn get_depth_or_array_layers(&self) -> u32 {
20687            let result = unsafe { ffi::wgpuTextureGetDepthOrArrayLayers(self.raw) };
20688            result
20689        }
20690        pub fn get_mip_level_count(&self) -> u32 {
20691            let result = unsafe { ffi::wgpuTextureGetMipLevelCount(self.raw) };
20692            result
20693        }
20694        pub fn get_sample_count(&self) -> u32 {
20695            let result = unsafe { ffi::wgpuTextureGetSampleCount(self.raw) };
20696            result
20697        }
20698        pub fn get_dimension(&self) -> TextureDimension {
20699            let result = unsafe { ffi::wgpuTextureGetDimension(self.raw) };
20700            result.into()
20701        }
20702        pub fn get_format(&self) -> TextureFormat {
20703            let result = unsafe { ffi::wgpuTextureGetFormat(self.raw) };
20704            result.into()
20705        }
20706        pub fn get_usage(&self) -> TextureUsage {
20707            let result = unsafe { ffi::wgpuTextureGetUsage(self.raw) };
20708            result.into()
20709        }
20710        pub fn get_texture_binding_view_dimension(&self) -> TextureViewDimension {
20711            let result = unsafe {
20712                ffi::wgpuTextureGetTextureBindingViewDimension(self.raw)
20713            };
20714            result.into()
20715        }
20716        pub fn destroy(&self) -> () {
20717            unsafe { ffi::wgpuTextureDestroy(self.raw) };
20718            ()
20719        }
20720        pub fn pin(&self, usage: TextureUsage) -> () {
20721            let usage_ffi: ffi::WGPUTextureUsage = usage.into();
20722            unsafe { ffi::wgpuTexturePin(self.raw, usage_ffi) };
20723            ()
20724        }
20725        pub fn unpin(&self) -> () {
20726            unsafe { ffi::wgpuTextureUnpin(self.raw) };
20727            ()
20728        }
20729        pub fn set_ownership_for_memory_dump(&self, owner_guid: u64) -> () {
20730            unsafe { ffi::wgpuTextureSetOwnershipForMemoryDump(self.raw, owner_guid) };
20731            ()
20732        }
20733    }
20734    impl Drop for Texture {
20735        fn drop(&mut self) {
20736            if self.as_raw().is_null() {
20737                return;
20738            }
20739            unsafe { ffi::wgpuTextureRelease(self.raw) };
20740        }
20741    }
20742    impl Clone for Texture {
20743        fn clone(&self) -> Self {
20744            unsafe { ffi::wgpuTextureAddRef(self.raw) };
20745            Self { raw: self.raw }
20746        }
20747    }
20748    unsafe impl Send for Texture {}
20749    unsafe impl Sync for Texture {}
20750    #[derive(Debug)]
20751    pub struct TextureView {
20752        raw: ffi::WGPUTextureView,
20753    }
20754    impl TextureView {
20755        pub(crate) unsafe fn from_raw(raw: ffi::WGPUTextureView) -> Self {
20756            Self { raw }
20757        }
20758        pub(crate) fn as_raw(&self) -> ffi::WGPUTextureView {
20759            self.raw
20760        }
20761        pub fn set_label(&self, label: String) -> () {
20762            let label_ffi = ffi::WGPUStringView {
20763                data: label.as_ptr().cast(),
20764                length: label.len(),
20765            };
20766            unsafe { ffi::wgpuTextureViewSetLabel(self.raw, label_ffi) };
20767            ()
20768        }
20769    }
20770    impl Drop for TextureView {
20771        fn drop(&mut self) {
20772            if self.as_raw().is_null() {
20773                return;
20774            }
20775            unsafe { ffi::wgpuTextureViewRelease(self.raw) };
20776        }
20777    }
20778    impl Clone for TextureView {
20779        fn clone(&self) -> Self {
20780            unsafe { ffi::wgpuTextureViewAddRef(self.raw) };
20781            Self { raw: self.raw }
20782        }
20783    }
20784    unsafe impl Send for TextureView {}
20785    unsafe impl Sync for TextureView {}
20786}
20787mod callbacks {
20788    #![allow(dead_code, unused_imports)]
20789    use crate::ffi;
20790    use crate::generated::*;
20791    pub type Callback = Option<unsafe extern "C" fn(*mut std::ffi::c_void) -> ()>;
20792    pub type DawnLoadCacheDataFunction = Option<
20793        unsafe extern "C" fn(
20794            *const std::ffi::c_void,
20795            usize,
20796            *mut std::ffi::c_void,
20797            usize,
20798            *mut std::ffi::c_void,
20799        ) -> usize,
20800    >;
20801    pub type DawnStoreCacheDataFunction = Option<
20802        unsafe extern "C" fn(
20803            *const std::ffi::c_void,
20804            usize,
20805            *const std::ffi::c_void,
20806            usize,
20807            *mut std::ffi::c_void,
20808        ) -> (),
20809    >;
20810    pub type Proc = Option<unsafe extern "C" fn() -> ()>;
20811    pub type BufferMapCallback = Box<dyn FnMut(MapAsyncStatus, String) + Send + 'static>;
20812    pub(crate) unsafe extern "C" fn buffer_map_callback_trampoline(
20813        status: ffi::WGPUMapAsyncStatus,
20814        message: ffi::WGPUStringView,
20815        userdata1: *mut std::ffi::c_void,
20816        userdata2: *mut std::ffi::c_void,
20817    ) {
20818        let _ = userdata2;
20819        let status = status.into();
20820        let message = string_view_to_string(message);
20821        let mut callback = unsafe {
20822            Box::from_raw(userdata1.cast::<Option<BufferMapCallback>>())
20823        };
20824        if let Some(mut callback) = callback.take() {
20825            callback(status, message);
20826        }
20827    }
20828    pub type CompilationInfoCallback = Box<
20829        dyn FnMut(CompilationInfoRequestStatus, &CompilationInfo) + Send + 'static,
20830    >;
20831    pub(crate) unsafe extern "C" fn compilation_info_callback_trampoline(
20832        status: ffi::WGPUCompilationInfoRequestStatus,
20833        compilation_info: *const ffi::WGPUCompilationInfo,
20834        userdata1: *mut std::ffi::c_void,
20835        userdata2: *mut std::ffi::c_void,
20836    ) {
20837        let _ = userdata2;
20838        let status = status.into();
20839        let compilation_info = if compilation_info.is_null() {
20840            CompilationInfo::new()
20841        } else {
20842            CompilationInfo::new()
20843        };
20844        let mut callback = unsafe {
20845            Box::from_raw(userdata1.cast::<Option<CompilationInfoCallback>>())
20846        };
20847        if let Some(mut callback) = callback.take() {
20848            callback(status, &compilation_info);
20849        }
20850    }
20851    pub type CreateComputePipelineAsyncCallback = Box<
20852        dyn FnMut(
20853            CreatePipelineAsyncStatus,
20854            Option<ComputePipeline>,
20855            String,
20856        ) + Send + 'static,
20857    >;
20858    pub(crate) unsafe extern "C" fn create_compute_pipeline_async_callback_trampoline(
20859        status: ffi::WGPUCreatePipelineAsyncStatus,
20860        pipeline: ffi::WGPUComputePipeline,
20861        message: ffi::WGPUStringView,
20862        userdata1: *mut std::ffi::c_void,
20863        userdata2: *mut std::ffi::c_void,
20864    ) {
20865        let _ = userdata2;
20866        let status = status.into();
20867        let pipeline = if pipeline.is_null() {
20868            None
20869        } else {
20870            Some(unsafe { ComputePipeline::from_raw(pipeline) })
20871        };
20872        let message = string_view_to_string(message);
20873        let mut callback = unsafe {
20874            Box::from_raw(userdata1.cast::<Option<CreateComputePipelineAsyncCallback>>())
20875        };
20876        if let Some(mut callback) = callback.take() {
20877            callback(status, pipeline, message);
20878        }
20879    }
20880    pub type CreateRenderPipelineAsyncCallback = Box<
20881        dyn FnMut(
20882            CreatePipelineAsyncStatus,
20883            Option<RenderPipeline>,
20884            String,
20885        ) + Send + 'static,
20886    >;
20887    pub(crate) unsafe extern "C" fn create_render_pipeline_async_callback_trampoline(
20888        status: ffi::WGPUCreatePipelineAsyncStatus,
20889        pipeline: ffi::WGPURenderPipeline,
20890        message: ffi::WGPUStringView,
20891        userdata1: *mut std::ffi::c_void,
20892        userdata2: *mut std::ffi::c_void,
20893    ) {
20894        let _ = userdata2;
20895        let status = status.into();
20896        let pipeline = if pipeline.is_null() {
20897            None
20898        } else {
20899            Some(unsafe { RenderPipeline::from_raw(pipeline) })
20900        };
20901        let message = string_view_to_string(message);
20902        let mut callback = unsafe {
20903            Box::from_raw(userdata1.cast::<Option<CreateRenderPipelineAsyncCallback>>())
20904        };
20905        if let Some(mut callback) = callback.take() {
20906            callback(status, pipeline, message);
20907        }
20908    }
20909    pub type DeviceLostCallback = Box<
20910        dyn FnMut(Vec<Device>, DeviceLostReason, String) + Send + 'static,
20911    >;
20912    pub(crate) unsafe extern "C" fn device_lost_callback_trampoline(
20913        device: *const ffi::WGPUDevice,
20914        reason: ffi::WGPUDeviceLostReason,
20915        message: ffi::WGPUStringView,
20916        userdata1: *mut std::ffi::c_void,
20917        userdata2: *mut std::ffi::c_void,
20918    ) {
20919        let _ = userdata2;
20920        let device = if device.is_null() {
20921            Vec::new()
20922        } else {
20923            unsafe { std::slice::from_raw_parts(device, 1) }
20924                .iter()
20925                .map(|raw| unsafe { Device::from_raw(*raw) })
20926                .collect()
20927        };
20928        let reason = reason.into();
20929        let message = string_view_to_string(message);
20930        let mut callback = unsafe {
20931            Box::from_raw(userdata1.cast::<Option<DeviceLostCallback>>())
20932        };
20933        if let Some(mut callback) = callback.take() {
20934            callback(device, reason, message);
20935        }
20936    }
20937    pub type LoggingCallback = Box<dyn FnMut(LoggingType, String) + Send + 'static>;
20938    pub(crate) unsafe extern "C" fn logging_callback_trampoline(
20939        r#type: ffi::WGPULoggingType,
20940        message: ffi::WGPUStringView,
20941        userdata1: *mut std::ffi::c_void,
20942        userdata2: *mut std::ffi::c_void,
20943    ) {
20944        let _ = userdata2;
20945        let r#type = r#type.into();
20946        let message = string_view_to_string(message);
20947        let mut callback = unsafe {
20948            Box::from_raw(userdata1.cast::<Option<LoggingCallback>>())
20949        };
20950        if let Some(mut callback) = callback.take() {
20951            callback(r#type, message);
20952        }
20953    }
20954    pub type PopErrorScopeCallback = Box<
20955        dyn FnMut(PopErrorScopeStatus, ErrorType, String) + Send + 'static,
20956    >;
20957    pub(crate) unsafe extern "C" fn pop_error_scope_callback_trampoline(
20958        status: ffi::WGPUPopErrorScopeStatus,
20959        r#type: ffi::WGPUErrorType,
20960        message: ffi::WGPUStringView,
20961        userdata1: *mut std::ffi::c_void,
20962        userdata2: *mut std::ffi::c_void,
20963    ) {
20964        let _ = userdata2;
20965        let status = status.into();
20966        let r#type = r#type.into();
20967        let message = string_view_to_string(message);
20968        let mut callback = unsafe {
20969            Box::from_raw(userdata1.cast::<Option<PopErrorScopeCallback>>())
20970        };
20971        if let Some(mut callback) = callback.take() {
20972            callback(status, r#type, message);
20973        }
20974    }
20975    pub type QueueWorkDoneCallback = Box<
20976        dyn FnMut(QueueWorkDoneStatus, String) + Send + 'static,
20977    >;
20978    pub(crate) unsafe extern "C" fn queue_work_done_callback_trampoline(
20979        status: ffi::WGPUQueueWorkDoneStatus,
20980        message: ffi::WGPUStringView,
20981        userdata1: *mut std::ffi::c_void,
20982        userdata2: *mut std::ffi::c_void,
20983    ) {
20984        let _ = userdata2;
20985        let status = status.into();
20986        let message = string_view_to_string(message);
20987        let mut callback = unsafe {
20988            Box::from_raw(userdata1.cast::<Option<QueueWorkDoneCallback>>())
20989        };
20990        if let Some(mut callback) = callback.take() {
20991            callback(status, message);
20992        }
20993    }
20994    pub type RequestAdapterCallback = Box<
20995        dyn FnMut(RequestAdapterStatus, Option<Adapter>, String) + Send + 'static,
20996    >;
20997    pub(crate) unsafe extern "C" fn request_adapter_callback_trampoline(
20998        status: ffi::WGPURequestAdapterStatus,
20999        adapter: ffi::WGPUAdapter,
21000        message: ffi::WGPUStringView,
21001        userdata1: *mut std::ffi::c_void,
21002        userdata2: *mut std::ffi::c_void,
21003    ) {
21004        let _ = userdata2;
21005        let status = status.into();
21006        let adapter = if adapter.is_null() {
21007            None
21008        } else {
21009            Some(unsafe { Adapter::from_raw(adapter) })
21010        };
21011        let message = string_view_to_string(message);
21012        let mut callback = unsafe {
21013            Box::from_raw(userdata1.cast::<Option<RequestAdapterCallback>>())
21014        };
21015        if let Some(mut callback) = callback.take() {
21016            callback(status, adapter, message);
21017        }
21018    }
21019    pub type RequestDeviceCallback = Box<
21020        dyn FnMut(RequestDeviceStatus, Option<Device>, String) + Send + 'static,
21021    >;
21022    pub(crate) unsafe extern "C" fn request_device_callback_trampoline(
21023        status: ffi::WGPURequestDeviceStatus,
21024        device: ffi::WGPUDevice,
21025        message: ffi::WGPUStringView,
21026        userdata1: *mut std::ffi::c_void,
21027        userdata2: *mut std::ffi::c_void,
21028    ) {
21029        let _ = userdata2;
21030        let status = status.into();
21031        let device = if device.is_null() {
21032            None
21033        } else {
21034            Some(unsafe { Device::from_raw(device) })
21035        };
21036        let message = string_view_to_string(message);
21037        let mut callback = unsafe {
21038            Box::from_raw(userdata1.cast::<Option<RequestDeviceCallback>>())
21039        };
21040        if let Some(mut callback) = callback.take() {
21041            callback(status, device, message);
21042        }
21043    }
21044    pub type UncapturedErrorCallback = Box<
21045        dyn FnMut(Vec<Device>, ErrorType, String) + Send + 'static,
21046    >;
21047    pub(crate) unsafe extern "C" fn uncaptured_error_callback_trampoline(
21048        device: *const ffi::WGPUDevice,
21049        r#type: ffi::WGPUErrorType,
21050        message: ffi::WGPUStringView,
21051        userdata1: *mut std::ffi::c_void,
21052        userdata2: *mut std::ffi::c_void,
21053    ) {
21054        let _ = userdata2;
21055        let device = if device.is_null() {
21056            Vec::new()
21057        } else {
21058            unsafe { std::slice::from_raw_parts(device, 1) }
21059                .iter()
21060                .map(|raw| unsafe { Device::from_raw(*raw) })
21061                .collect()
21062        };
21063        let r#type = r#type.into();
21064        let message = string_view_to_string(message);
21065        let mut callback = unsafe {
21066            Box::from_raw(userdata1.cast::<Option<UncapturedErrorCallback>>())
21067        };
21068        if let Some(mut callback) = callback.take() {
21069            callback(device, r#type, message);
21070        }
21071    }
21072    pub struct BufferMapCallbackInfo {
21073        pub mode: Option<CallbackMode>,
21074        pub callback: std::cell::RefCell<Option<BufferMapCallback>>,
21075    }
21076    impl Default for BufferMapCallbackInfo {
21077        fn default() -> Self {
21078            Self {
21079                mode: None,
21080                callback: std::cell::RefCell::new(None),
21081            }
21082        }
21083    }
21084    impl BufferMapCallbackInfo {
21085        pub fn new() -> Self {
21086            Self::default()
21087        }
21088    }
21089    pub struct CompilationInfoCallbackInfo {
21090        pub mode: Option<CallbackMode>,
21091        pub callback: std::cell::RefCell<Option<CompilationInfoCallback>>,
21092    }
21093    impl Default for CompilationInfoCallbackInfo {
21094        fn default() -> Self {
21095            Self {
21096                mode: None,
21097                callback: std::cell::RefCell::new(None),
21098            }
21099        }
21100    }
21101    impl CompilationInfoCallbackInfo {
21102        pub fn new() -> Self {
21103            Self::default()
21104        }
21105    }
21106    pub struct CreateComputePipelineAsyncCallbackInfo {
21107        pub mode: Option<CallbackMode>,
21108        pub callback: std::cell::RefCell<Option<CreateComputePipelineAsyncCallback>>,
21109    }
21110    impl Default for CreateComputePipelineAsyncCallbackInfo {
21111        fn default() -> Self {
21112            Self {
21113                mode: None,
21114                callback: std::cell::RefCell::new(None),
21115            }
21116        }
21117    }
21118    impl CreateComputePipelineAsyncCallbackInfo {
21119        pub fn new() -> Self {
21120            Self::default()
21121        }
21122    }
21123    pub struct CreateRenderPipelineAsyncCallbackInfo {
21124        pub mode: Option<CallbackMode>,
21125        pub callback: std::cell::RefCell<Option<CreateRenderPipelineAsyncCallback>>,
21126    }
21127    impl Default for CreateRenderPipelineAsyncCallbackInfo {
21128        fn default() -> Self {
21129            Self {
21130                mode: None,
21131                callback: std::cell::RefCell::new(None),
21132            }
21133        }
21134    }
21135    impl CreateRenderPipelineAsyncCallbackInfo {
21136        pub fn new() -> Self {
21137            Self::default()
21138        }
21139    }
21140    pub struct DeviceLostCallbackInfo {
21141        pub mode: Option<CallbackMode>,
21142        pub callback: std::cell::RefCell<Option<DeviceLostCallback>>,
21143    }
21144    impl Default for DeviceLostCallbackInfo {
21145        fn default() -> Self {
21146            Self {
21147                mode: None,
21148                callback: std::cell::RefCell::new(None),
21149            }
21150        }
21151    }
21152    impl DeviceLostCallbackInfo {
21153        pub fn new() -> Self {
21154            Self::default()
21155        }
21156    }
21157    pub struct LoggingCallbackInfo {
21158        pub callback: std::cell::RefCell<Option<LoggingCallback>>,
21159    }
21160    impl Default for LoggingCallbackInfo {
21161        fn default() -> Self {
21162            Self {
21163                callback: std::cell::RefCell::new(None),
21164            }
21165        }
21166    }
21167    impl LoggingCallbackInfo {
21168        pub fn new() -> Self {
21169            Self::default()
21170        }
21171    }
21172    pub struct PopErrorScopeCallbackInfo {
21173        pub mode: Option<CallbackMode>,
21174        pub callback: std::cell::RefCell<Option<PopErrorScopeCallback>>,
21175    }
21176    impl Default for PopErrorScopeCallbackInfo {
21177        fn default() -> Self {
21178            Self {
21179                mode: None,
21180                callback: std::cell::RefCell::new(None),
21181            }
21182        }
21183    }
21184    impl PopErrorScopeCallbackInfo {
21185        pub fn new() -> Self {
21186            Self::default()
21187        }
21188    }
21189    pub struct QueueWorkDoneCallbackInfo {
21190        pub mode: Option<CallbackMode>,
21191        pub callback: std::cell::RefCell<Option<QueueWorkDoneCallback>>,
21192    }
21193    impl Default for QueueWorkDoneCallbackInfo {
21194        fn default() -> Self {
21195            Self {
21196                mode: None,
21197                callback: std::cell::RefCell::new(None),
21198            }
21199        }
21200    }
21201    impl QueueWorkDoneCallbackInfo {
21202        pub fn new() -> Self {
21203            Self::default()
21204        }
21205    }
21206    pub struct RequestAdapterCallbackInfo {
21207        pub mode: Option<CallbackMode>,
21208        pub callback: std::cell::RefCell<Option<RequestAdapterCallback>>,
21209    }
21210    impl Default for RequestAdapterCallbackInfo {
21211        fn default() -> Self {
21212            Self {
21213                mode: None,
21214                callback: std::cell::RefCell::new(None),
21215            }
21216        }
21217    }
21218    impl RequestAdapterCallbackInfo {
21219        pub fn new() -> Self {
21220            Self::default()
21221        }
21222    }
21223    pub struct RequestDeviceCallbackInfo {
21224        pub mode: Option<CallbackMode>,
21225        pub callback: std::cell::RefCell<Option<RequestDeviceCallback>>,
21226    }
21227    impl Default for RequestDeviceCallbackInfo {
21228        fn default() -> Self {
21229            Self {
21230                mode: None,
21231                callback: std::cell::RefCell::new(None),
21232            }
21233        }
21234    }
21235    impl RequestDeviceCallbackInfo {
21236        pub fn new() -> Self {
21237            Self::default()
21238        }
21239    }
21240    pub struct UncapturedErrorCallbackInfo {
21241        pub callback: std::cell::RefCell<Option<UncapturedErrorCallback>>,
21242    }
21243    impl Default for UncapturedErrorCallbackInfo {
21244        fn default() -> Self {
21245            Self {
21246                callback: std::cell::RefCell::new(None),
21247            }
21248        }
21249    }
21250    impl UncapturedErrorCallbackInfo {
21251        pub fn new() -> Self {
21252            Self::default()
21253        }
21254    }
21255}
21256mod functions {
21257    #![allow(dead_code, unused_imports)]
21258    use crate::generated::*;
21259    use crate::ffi;
21260    pub fn create_instance(descriptor: Option<&InstanceDescriptor>) -> Instance {
21261        let mut descriptor_storage = ChainedStructStorage::new();
21262        let descriptor_ptr = if let Some(value) = &descriptor {
21263            let (descriptor_ffi, storage) = value.to_ffi();
21264            descriptor_storage = storage;
21265            std::ptr::addr_of!(descriptor_ffi)
21266        } else {
21267            std::ptr::null()
21268        };
21269        let result = unsafe { ffi::wgpuCreateInstance(descriptor_ptr) };
21270        unsafe { Instance::from_raw(result) }
21271    }
21272    pub fn get_instance_features(features: &mut SupportedInstanceFeatures) -> () {
21273        let (mut features_ffi, _features_storage) = features.to_ffi();
21274        let features_ptr = std::ptr::addr_of_mut!(features_ffi);
21275        unsafe { ffi::wgpuGetInstanceFeatures(features_ptr) };
21276        *features = SupportedInstanceFeatures::from_ffi(features_ffi);
21277        ()
21278    }
21279    pub fn get_instance_limits(limits: &mut InstanceLimits) -> Status {
21280        let (mut limits_ffi, _limits_storage) = limits.to_ffi();
21281        let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
21282        let result = unsafe { ffi::wgpuGetInstanceLimits(limits_ptr) };
21283        *limits = InstanceLimits::from_ffi(limits_ffi);
21284        result.into()
21285    }
21286    pub fn get_proc_address(proc_name: String) -> Proc {
21287        let proc_name_ffi = ffi::WGPUStringView {
21288            data: proc_name.as_ptr().cast(),
21289            length: proc_name.len(),
21290        };
21291        let result = unsafe { ffi::wgpuGetProcAddress(proc_name_ffi) };
21292        result
21293    }
21294    pub fn has_instance_feature(feature: InstanceFeatureName) -> bool {
21295        let feature_ffi: ffi::WGPUInstanceFeatureName = feature.into();
21296        let result = unsafe { ffi::wgpuHasInstanceFeature(feature_ffi) };
21297        result != 0
21298    }
21299}
21300mod constants {
21301    #![allow(dead_code, unused_imports)]
21302    use crate::generated::*;
21303    use crate::ffi;
21304    pub const ARRAY_LAYER_COUNT_UNDEFINED: u32 = u32::MAX;
21305    pub const COPY_STRIDE_UNDEFINED: u32 = u32::MAX;
21306    pub const DEPTH_CLEAR_VALUE_UNDEFINED: f32 = f32::NAN;
21307    pub const DEPTH_SLICE_UNDEFINED: u32 = u32::MAX;
21308    pub const INVALID_BINDING: u32 = u32::MAX;
21309    pub const LIMIT_U32_UNDEFINED: u32 = u32::MAX;
21310    pub const LIMIT_U64_UNDEFINED: u64 = u64::MAX;
21311    pub const MIP_LEVEL_COUNT_UNDEFINED: u32 = u32::MAX;
21312    pub const QUERY_SET_INDEX_UNDEFINED: u32 = u32::MAX;
21313    pub const STRLEN: usize = usize::MAX;
21314    pub const WHOLE_MAP_SIZE: usize = usize::MAX;
21315    pub const WHOLE_SIZE: u64 = u64::MAX;
21316}
21317pub use enums::*;
21318pub use structs::*;
21319pub use extensions::*;
21320pub use objects::*;
21321pub use callbacks::*;
21322pub use functions::*;
21323pub use constants::*;