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        ExternalTextureBindingLayout,
2346        ExternalTextureBindingEntry,
2347        CompatibilityModeLimits,
2348        TextureBindingViewDimension,
2349        EmscriptenSurfaceSourceCanvasHTMLSelector,
2350        SurfaceDescriptorFromWindowsCoreWindow,
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_ExternalTextureBindingLayout => {
2466                    SType::ExternalTextureBindingLayout
2467                }
2468                ffi::WGPUSType_WGPUSType_ExternalTextureBindingEntry => {
2469                    SType::ExternalTextureBindingEntry
2470                }
2471                ffi::WGPUSType_WGPUSType_CompatibilityModeLimits => {
2472                    SType::CompatibilityModeLimits
2473                }
2474                ffi::WGPUSType_WGPUSType_TextureBindingViewDimension => {
2475                    SType::TextureBindingViewDimension
2476                }
2477                ffi::WGPUSType_WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector => {
2478                    SType::EmscriptenSurfaceSourceCanvasHTMLSelector
2479                }
2480                ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsCoreWindow => {
2481                    SType::SurfaceDescriptorFromWindowsCoreWindow
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::ExternalTextureBindingLayout => {
2753                    ffi::WGPUSType_WGPUSType_ExternalTextureBindingLayout
2754                }
2755                SType::ExternalTextureBindingEntry => {
2756                    ffi::WGPUSType_WGPUSType_ExternalTextureBindingEntry
2757                }
2758                SType::CompatibilityModeLimits => {
2759                    ffi::WGPUSType_WGPUSType_CompatibilityModeLimits
2760                }
2761                SType::TextureBindingViewDimension => {
2762                    ffi::WGPUSType_WGPUSType_TextureBindingViewDimension
2763                }
2764                SType::EmscriptenSurfaceSourceCanvasHTMLSelector => {
2765                    ffi::WGPUSType_WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector
2766                }
2767                SType::SurfaceDescriptorFromWindowsCoreWindow => {
2768                    ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsCoreWindow
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 CompatibilityModeLimits {
6302        pub max_storage_buffers_in_vertex_stage: Option<u32>,
6303        pub max_storage_textures_in_vertex_stage: Option<u32>,
6304        pub max_storage_buffers_in_fragment_stage: Option<u32>,
6305        pub max_storage_textures_in_fragment_stage: Option<u32>,
6306    }
6307    impl Default for CompatibilityModeLimits {
6308        fn default() -> Self {
6309            Self {
6310                max_storage_buffers_in_vertex_stage: Some(LIMIT_U32_UNDEFINED),
6311                max_storage_textures_in_vertex_stage: Some(LIMIT_U32_UNDEFINED),
6312                max_storage_buffers_in_fragment_stage: Some(LIMIT_U32_UNDEFINED),
6313                max_storage_textures_in_fragment_stage: Some(LIMIT_U32_UNDEFINED),
6314            }
6315        }
6316    }
6317    impl CompatibilityModeLimits {
6318        pub fn new() -> Self {
6319            Self::default()
6320        }
6321        pub(crate) fn to_ffi(
6322            &self,
6323        ) -> (ffi::WGPUCompatibilityModeLimits, ChainedStructStorage) {
6324            let mut storage = ChainedStructStorage::new();
6325            let mut raw: ffi::WGPUCompatibilityModeLimits = unsafe {
6326                std::mem::zeroed()
6327            };
6328            if let Some(value) = self.max_storage_buffers_in_vertex_stage {
6329                raw.maxStorageBuffersInVertexStage = value;
6330            }
6331            if let Some(value) = self.max_storage_textures_in_vertex_stage {
6332                raw.maxStorageTexturesInVertexStage = value;
6333            }
6334            if let Some(value) = self.max_storage_buffers_in_fragment_stage {
6335                raw.maxStorageBuffersInFragmentStage = value;
6336            }
6337            if let Some(value) = self.max_storage_textures_in_fragment_stage {
6338                raw.maxStorageTexturesInFragmentStage = value;
6339            }
6340            (raw, storage)
6341        }
6342        pub(crate) fn from_ffi(value: ffi::WGPUCompatibilityModeLimits) -> Self {
6343            Self {
6344                max_storage_buffers_in_vertex_stage: Some(
6345                    value.maxStorageBuffersInVertexStage,
6346                ),
6347                max_storage_textures_in_vertex_stage: Some(
6348                    value.maxStorageTexturesInVertexStage,
6349                ),
6350                max_storage_buffers_in_fragment_stage: Some(
6351                    value.maxStorageBuffersInFragmentStage,
6352                ),
6353                max_storage_textures_in_fragment_stage: Some(
6354                    value.maxStorageTexturesInFragmentStage,
6355                ),
6356            }
6357        }
6358    }
6359    pub struct CompilationInfo {
6360        pub(crate) extensions: Vec<CompilationInfoExtension>,
6361        pub messages: Option<Vec<CompilationMessage>>,
6362    }
6363    impl Default for CompilationInfo {
6364        fn default() -> Self {
6365            Self {
6366                extensions: Vec::new(),
6367                messages: None,
6368            }
6369        }
6370    }
6371    impl CompilationInfo {
6372        pub fn new() -> Self {
6373            Self::default()
6374        }
6375        pub(crate) fn to_ffi(&self) -> (ffi::WGPUCompilationInfo, ChainedStructStorage) {
6376            let mut storage = ChainedStructStorage::new();
6377            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6378            for ext in self.extensions.iter().rev() {
6379                next = ext.push_chain(&mut storage, next);
6380            }
6381            let mut raw: ffi::WGPUCompilationInfo = unsafe { std::mem::zeroed() };
6382            raw.nextInChain = next;
6383            raw.messageCount = self.messages.as_ref().map(|v| v.len()).unwrap_or(0);
6384            if let Some(values) = &self.messages {
6385                let len_value = values.len();
6386                let mut raw_vec: Vec<ffi::WGPUCompilationMessage> = Vec::with_capacity(
6387                    values.len(),
6388                );
6389                for item in values.iter() {
6390                    let (raw_item, storage_item) = item.to_ffi();
6391                    raw_vec.push(raw_item);
6392                    storage.push_storage(storage_item);
6393                }
6394                let ptr = storage.push_vec(raw_vec);
6395                raw.messages = ptr;
6396                raw.messageCount = len_value;
6397            } else {
6398                raw.messages = std::ptr::null();
6399                raw.messageCount = 0;
6400            }
6401            (raw, storage)
6402        }
6403        pub fn with_extension(mut self, extension: CompilationInfoExtension) -> Self {
6404            self.extensions.push(extension);
6405            self
6406        }
6407        pub(crate) fn from_ffi(value: ffi::WGPUCompilationInfo) -> Self {
6408            Self {
6409                extensions: Vec::new(),
6410                messages: if value.messages.is_null() {
6411                    None
6412                } else {
6413                    Some(
6414                        unsafe {
6415                            std::slice::from_raw_parts(
6416                                value.messages,
6417                                value.messageCount as usize,
6418                            )
6419                        }
6420                            .iter()
6421                            .map(|raw| CompilationMessage::from_ffi(*raw))
6422                            .collect(),
6423                    )
6424                },
6425            }
6426        }
6427    }
6428    pub struct CompilationMessage {
6429        pub(crate) extensions: Vec<CompilationMessageExtension>,
6430        pub message: Option<String>,
6431        pub r#type: Option<CompilationMessageType>,
6432        pub line_num: Option<u64>,
6433        pub line_pos: Option<u64>,
6434        pub offset: Option<u64>,
6435        pub length: Option<u64>,
6436    }
6437    impl Default for CompilationMessage {
6438        fn default() -> Self {
6439            Self {
6440                extensions: Vec::new(),
6441                message: None,
6442                r#type: None,
6443                line_num: None,
6444                line_pos: None,
6445                offset: None,
6446                length: None,
6447            }
6448        }
6449    }
6450    impl CompilationMessage {
6451        pub fn new() -> Self {
6452            Self::default()
6453        }
6454        pub(crate) fn to_ffi(
6455            &self,
6456        ) -> (ffi::WGPUCompilationMessage, ChainedStructStorage) {
6457            let mut storage = ChainedStructStorage::new();
6458            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6459            for ext in self.extensions.iter().rev() {
6460                next = ext.push_chain(&mut storage, next);
6461            }
6462            let mut raw: ffi::WGPUCompilationMessage = unsafe { std::mem::zeroed() };
6463            raw.nextInChain = next;
6464            if let Some(value) = &self.message {
6465                raw.message = ffi::WGPUStringView {
6466                    data: value.as_ptr().cast(),
6467                    length: value.len(),
6468                };
6469            } else {
6470                raw.message = ffi::WGPUStringView {
6471                    data: std::ptr::null(),
6472                    length: 0,
6473                };
6474            }
6475            if let Some(value) = self.r#type {
6476                raw.type_ = value.into();
6477            } else {
6478                raw.type_ = 0 as ffi::WGPUCompilationMessageType;
6479            }
6480            if let Some(value) = self.line_num {
6481                raw.lineNum = value;
6482            }
6483            if let Some(value) = self.line_pos {
6484                raw.linePos = value;
6485            }
6486            if let Some(value) = self.offset {
6487                raw.offset = value;
6488            }
6489            if let Some(value) = self.length {
6490                raw.length = value;
6491            }
6492            (raw, storage)
6493        }
6494        pub fn with_extension(mut self, extension: CompilationMessageExtension) -> Self {
6495            self.extensions.push(extension);
6496            self
6497        }
6498        pub(crate) fn from_ffi(value: ffi::WGPUCompilationMessage) -> Self {
6499            Self {
6500                extensions: Vec::new(),
6501                message: Some(string_view_to_string(value.message)),
6502                r#type: Some(value.type_.into()),
6503                line_num: Some(value.lineNum),
6504                line_pos: Some(value.linePos),
6505                offset: Some(value.offset),
6506                length: Some(value.length),
6507            }
6508        }
6509    }
6510    pub struct ComputePassDescriptor {
6511        pub(crate) extensions: Vec<ComputePassDescriptorExtension>,
6512        pub label: Option<String>,
6513        pub timestamp_writes: Option<PassTimestampWrites>,
6514    }
6515    impl Default for ComputePassDescriptor {
6516        fn default() -> Self {
6517            Self {
6518                extensions: Vec::new(),
6519                label: None,
6520                timestamp_writes: None,
6521            }
6522        }
6523    }
6524    impl ComputePassDescriptor {
6525        pub fn new() -> Self {
6526            Self::default()
6527        }
6528        pub(crate) fn to_ffi(
6529            &self,
6530        ) -> (ffi::WGPUComputePassDescriptor, ChainedStructStorage) {
6531            let mut storage = ChainedStructStorage::new();
6532            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6533            for ext in self.extensions.iter().rev() {
6534                next = ext.push_chain(&mut storage, next);
6535            }
6536            let mut raw: ffi::WGPUComputePassDescriptor = unsafe { std::mem::zeroed() };
6537            raw.nextInChain = next;
6538            if let Some(value) = &self.label {
6539                raw.label = ffi::WGPUStringView {
6540                    data: value.as_ptr().cast(),
6541                    length: value.len(),
6542                };
6543            } else {
6544                raw.label = ffi::WGPUStringView {
6545                    data: std::ptr::null(),
6546                    length: 0,
6547                };
6548            }
6549            if let Some(value) = &self.timestamp_writes {
6550                let (raw_value, storage_value) = value.to_ffi();
6551                let ptr = storage.push_value(raw_value);
6552                raw.timestampWrites = ptr;
6553                storage.push_storage(storage_value);
6554            } else {
6555                raw.timestampWrites = std::ptr::null();
6556            }
6557            (raw, storage)
6558        }
6559        pub fn with_extension(
6560            mut self,
6561            extension: ComputePassDescriptorExtension,
6562        ) -> Self {
6563            self.extensions.push(extension);
6564            self
6565        }
6566        pub(crate) fn from_ffi(value: ffi::WGPUComputePassDescriptor) -> Self {
6567            Self {
6568                extensions: Vec::new(),
6569                label: if value.label.data.is_null() || value.label.length == 0 {
6570                    None
6571                } else {
6572                    Some(string_view_to_string(value.label))
6573                },
6574                timestamp_writes: if value.timestampWrites.is_null() {
6575                    None
6576                } else {
6577                    Some(
6578                        PassTimestampWrites::from_ffi(unsafe { *value.timestampWrites }),
6579                    )
6580                },
6581            }
6582        }
6583    }
6584    pub struct ComputePipelineDescriptor {
6585        pub(crate) extensions: Vec<ComputePipelineDescriptorExtension>,
6586        pub label: Option<String>,
6587        pub layout: Option<PipelineLayout>,
6588        pub compute: Option<ComputeState>,
6589    }
6590    impl Default for ComputePipelineDescriptor {
6591        fn default() -> Self {
6592            Self {
6593                extensions: Vec::new(),
6594                label: None,
6595                layout: None,
6596                compute: None,
6597            }
6598        }
6599    }
6600    impl ComputePipelineDescriptor {
6601        pub fn new() -> Self {
6602            Self::default()
6603        }
6604        pub(crate) fn to_ffi(
6605            &self,
6606        ) -> (ffi::WGPUComputePipelineDescriptor, ChainedStructStorage) {
6607            let mut storage = ChainedStructStorage::new();
6608            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6609            for ext in self.extensions.iter().rev() {
6610                next = ext.push_chain(&mut storage, next);
6611            }
6612            let mut raw: ffi::WGPUComputePipelineDescriptor = unsafe {
6613                std::mem::zeroed()
6614            };
6615            raw.nextInChain = next;
6616            if let Some(value) = &self.label {
6617                raw.label = ffi::WGPUStringView {
6618                    data: value.as_ptr().cast(),
6619                    length: value.len(),
6620                };
6621            } else {
6622                raw.label = ffi::WGPUStringView {
6623                    data: std::ptr::null(),
6624                    length: 0,
6625                };
6626            }
6627            raw.layout = self
6628                .layout
6629                .as_ref()
6630                .map(|v| v.as_raw())
6631                .unwrap_or(std::ptr::null_mut());
6632            if let Some(value) = &self.compute {
6633                let (raw_value, storage_value) = value.to_ffi();
6634                raw.compute = raw_value;
6635                storage.push_storage(storage_value);
6636            }
6637            (raw, storage)
6638        }
6639        pub fn with_extension(
6640            mut self,
6641            extension: ComputePipelineDescriptorExtension,
6642        ) -> Self {
6643            self.extensions.push(extension);
6644            self
6645        }
6646        pub(crate) fn from_ffi(value: ffi::WGPUComputePipelineDescriptor) -> Self {
6647            Self {
6648                extensions: Vec::new(),
6649                label: if value.label.data.is_null() || value.label.length == 0 {
6650                    None
6651                } else {
6652                    Some(string_view_to_string(value.label))
6653                },
6654                layout: if value.layout.is_null() {
6655                    None
6656                } else {
6657                    Some(unsafe { PipelineLayout::from_raw(value.layout) })
6658                },
6659                compute: Some(ComputeState::from_ffi(value.compute)),
6660            }
6661        }
6662    }
6663    pub struct ComputeState {
6664        pub(crate) extensions: Vec<ComputeStateExtension>,
6665        pub module: Option<ShaderModule>,
6666        pub entry_point: Option<String>,
6667        pub constants: Option<Vec<ConstantEntry>>,
6668    }
6669    impl Default for ComputeState {
6670        fn default() -> Self {
6671            Self {
6672                extensions: Vec::new(),
6673                module: None,
6674                entry_point: None,
6675                constants: None,
6676            }
6677        }
6678    }
6679    impl ComputeState {
6680        pub fn new() -> Self {
6681            Self::default()
6682        }
6683        pub(crate) fn to_ffi(&self) -> (ffi::WGPUComputeState, ChainedStructStorage) {
6684            let mut storage = ChainedStructStorage::new();
6685            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6686            for ext in self.extensions.iter().rev() {
6687                next = ext.push_chain(&mut storage, next);
6688            }
6689            let mut raw: ffi::WGPUComputeState = unsafe { std::mem::zeroed() };
6690            raw.nextInChain = next;
6691            raw.module = self
6692                .module
6693                .as_ref()
6694                .map(|v| v.as_raw())
6695                .unwrap_or(std::ptr::null_mut());
6696            if let Some(value) = &self.entry_point {
6697                raw.entryPoint = ffi::WGPUStringView {
6698                    data: value.as_ptr().cast(),
6699                    length: value.len(),
6700                };
6701            } else {
6702                raw.entryPoint = ffi::WGPUStringView {
6703                    data: std::ptr::null(),
6704                    length: 0,
6705                };
6706            }
6707            raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
6708            if let Some(values) = &self.constants {
6709                let len_value = values.len();
6710                let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
6711                    values.len(),
6712                );
6713                for item in values.iter() {
6714                    let (raw_item, storage_item) = item.to_ffi();
6715                    raw_vec.push(raw_item);
6716                    storage.push_storage(storage_item);
6717                }
6718                let ptr = storage.push_vec(raw_vec);
6719                raw.constants = ptr;
6720                raw.constantCount = len_value;
6721            } else {
6722                raw.constants = std::ptr::null();
6723                raw.constantCount = 0;
6724            }
6725            (raw, storage)
6726        }
6727        pub fn with_extension(mut self, extension: ComputeStateExtension) -> Self {
6728            self.extensions.push(extension);
6729            self
6730        }
6731        pub(crate) fn from_ffi(value: ffi::WGPUComputeState) -> Self {
6732            Self {
6733                extensions: Vec::new(),
6734                module: Some(unsafe { ShaderModule::from_raw(value.module) }),
6735                entry_point: if value.entryPoint.data.is_null()
6736                    || value.entryPoint.length == 0
6737                {
6738                    None
6739                } else {
6740                    Some(string_view_to_string(value.entryPoint))
6741                },
6742                constants: if value.constants.is_null() {
6743                    None
6744                } else {
6745                    Some(
6746                        unsafe {
6747                            std::slice::from_raw_parts(
6748                                value.constants,
6749                                value.constantCount as usize,
6750                            )
6751                        }
6752                            .iter()
6753                            .map(|raw| ConstantEntry::from_ffi(*raw))
6754                            .collect(),
6755                    )
6756                },
6757            }
6758        }
6759    }
6760    pub struct ConstantEntry {
6761        pub(crate) extensions: Vec<ConstantEntryExtension>,
6762        pub key: Option<String>,
6763        pub value: Option<f64>,
6764    }
6765    impl Default for ConstantEntry {
6766        fn default() -> Self {
6767            Self {
6768                extensions: Vec::new(),
6769                key: None,
6770                value: None,
6771            }
6772        }
6773    }
6774    impl ConstantEntry {
6775        pub fn new() -> Self {
6776            Self::default()
6777        }
6778        pub(crate) fn to_ffi(&self) -> (ffi::WGPUConstantEntry, ChainedStructStorage) {
6779            let mut storage = ChainedStructStorage::new();
6780            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6781            for ext in self.extensions.iter().rev() {
6782                next = ext.push_chain(&mut storage, next);
6783            }
6784            let mut raw: ffi::WGPUConstantEntry = unsafe { std::mem::zeroed() };
6785            raw.nextInChain = next;
6786            if let Some(value) = &self.key {
6787                raw.key = ffi::WGPUStringView {
6788                    data: value.as_ptr().cast(),
6789                    length: value.len(),
6790                };
6791            } else {
6792                raw.key = ffi::WGPUStringView {
6793                    data: std::ptr::null(),
6794                    length: 0,
6795                };
6796            }
6797            if let Some(value) = self.value {
6798                raw.value = value;
6799            }
6800            (raw, storage)
6801        }
6802        pub fn with_extension(mut self, extension: ConstantEntryExtension) -> Self {
6803            self.extensions.push(extension);
6804            self
6805        }
6806        pub(crate) fn from_ffi(value: ffi::WGPUConstantEntry) -> Self {
6807            Self {
6808                extensions: Vec::new(),
6809                key: Some(string_view_to_string(value.key)),
6810                value: Some(value.value),
6811            }
6812        }
6813    }
6814    pub struct CopyTextureForBrowserOptions {
6815        pub(crate) extensions: Vec<CopyTextureForBrowserOptionsExtension>,
6816        pub flip_y: Option<bool>,
6817        pub needs_color_space_conversion: Option<bool>,
6818        pub src_alpha_mode: Option<AlphaMode>,
6819        pub src_transfer_function_parameters: Option<Vec<f32>>,
6820        pub conversion_matrix: Option<Vec<f32>>,
6821        pub dst_transfer_function_parameters: Option<Vec<f32>>,
6822        pub dst_alpha_mode: Option<AlphaMode>,
6823        pub internal_usage: Option<bool>,
6824    }
6825    impl Default for CopyTextureForBrowserOptions {
6826        fn default() -> Self {
6827            Self {
6828                extensions: Vec::new(),
6829                flip_y: None,
6830                needs_color_space_conversion: None,
6831                src_alpha_mode: Some(AlphaMode::Unpremultiplied),
6832                src_transfer_function_parameters: None,
6833                conversion_matrix: None,
6834                dst_transfer_function_parameters: None,
6835                dst_alpha_mode: Some(AlphaMode::Unpremultiplied),
6836                internal_usage: None,
6837            }
6838        }
6839    }
6840    impl CopyTextureForBrowserOptions {
6841        pub fn new() -> Self {
6842            Self::default()
6843        }
6844        pub(crate) fn to_ffi(
6845            &self,
6846        ) -> (ffi::WGPUCopyTextureForBrowserOptions, ChainedStructStorage) {
6847            let mut storage = ChainedStructStorage::new();
6848            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6849            for ext in self.extensions.iter().rev() {
6850                next = ext.push_chain(&mut storage, next);
6851            }
6852            let mut raw: ffi::WGPUCopyTextureForBrowserOptions = unsafe {
6853                std::mem::zeroed()
6854            };
6855            raw.nextInChain = next;
6856            raw.flipY = if self.flip_y.unwrap_or(false) { 1 } else { 0 };
6857            raw.needsColorSpaceConversion = if self
6858                .needs_color_space_conversion
6859                .unwrap_or(false)
6860            {
6861                1
6862            } else {
6863                0
6864            };
6865            if let Some(value) = self.src_alpha_mode {
6866                raw.srcAlphaMode = value.into();
6867            } else {
6868                raw.srcAlphaMode = 0 as ffi::WGPUAlphaMode;
6869            }
6870            if let Some(values) = &self.src_transfer_function_parameters {
6871                let len_value = values.len();
6872                let raw_vec = values.to_vec();
6873                let ptr = storage.push_vec(raw_vec);
6874                raw.srcTransferFunctionParameters = ptr;
6875            } else {
6876                raw.srcTransferFunctionParameters = std::ptr::null();
6877                let _ = 0;
6878            }
6879            if let Some(values) = &self.conversion_matrix {
6880                let len_value = values.len();
6881                let raw_vec = values.to_vec();
6882                let ptr = storage.push_vec(raw_vec);
6883                raw.conversionMatrix = ptr;
6884            } else {
6885                raw.conversionMatrix = std::ptr::null();
6886                let _ = 0;
6887            }
6888            if let Some(values) = &self.dst_transfer_function_parameters {
6889                let len_value = values.len();
6890                let raw_vec = values.to_vec();
6891                let ptr = storage.push_vec(raw_vec);
6892                raw.dstTransferFunctionParameters = ptr;
6893            } else {
6894                raw.dstTransferFunctionParameters = std::ptr::null();
6895                let _ = 0;
6896            }
6897            if let Some(value) = self.dst_alpha_mode {
6898                raw.dstAlphaMode = value.into();
6899            } else {
6900                raw.dstAlphaMode = 0 as ffi::WGPUAlphaMode;
6901            }
6902            raw.internalUsage = if self.internal_usage.unwrap_or(false) { 1 } else { 0 };
6903            (raw, storage)
6904        }
6905        pub fn with_extension(
6906            mut self,
6907            extension: CopyTextureForBrowserOptionsExtension,
6908        ) -> Self {
6909            self.extensions.push(extension);
6910            self
6911        }
6912        pub(crate) fn from_ffi(value: ffi::WGPUCopyTextureForBrowserOptions) -> Self {
6913            Self {
6914                extensions: Vec::new(),
6915                flip_y: Some(value.flipY != 0),
6916                needs_color_space_conversion: Some(value.needsColorSpaceConversion != 0),
6917                src_alpha_mode: Some(value.srcAlphaMode.into()),
6918                src_transfer_function_parameters: if value
6919                    .srcTransferFunctionParameters
6920                    .is_null()
6921                {
6922                    None
6923                } else {
6924                    Some(
6925                        unsafe {
6926                            std::slice::from_raw_parts(
6927                                value.srcTransferFunctionParameters,
6928                                7usize,
6929                            )
6930                        }
6931                            .to_vec(),
6932                    )
6933                },
6934                conversion_matrix: if value.conversionMatrix.is_null() {
6935                    None
6936                } else {
6937                    Some(
6938                        unsafe {
6939                            std::slice::from_raw_parts(value.conversionMatrix, 9usize)
6940                        }
6941                            .to_vec(),
6942                    )
6943                },
6944                dst_transfer_function_parameters: if value
6945                    .dstTransferFunctionParameters
6946                    .is_null()
6947                {
6948                    None
6949                } else {
6950                    Some(
6951                        unsafe {
6952                            std::slice::from_raw_parts(
6953                                value.dstTransferFunctionParameters,
6954                                7usize,
6955                            )
6956                        }
6957                            .to_vec(),
6958                    )
6959                },
6960                dst_alpha_mode: Some(value.dstAlphaMode.into()),
6961                internal_usage: Some(value.internalUsage != 0),
6962            }
6963        }
6964    }
6965    pub struct DawnWGSLBlocklist {
6966        pub blocklisted_features: Option<Vec<String>>,
6967    }
6968    impl Default for DawnWGSLBlocklist {
6969        fn default() -> Self {
6970            Self { blocklisted_features: None }
6971        }
6972    }
6973    impl DawnWGSLBlocklist {
6974        pub fn new() -> Self {
6975            Self::default()
6976        }
6977        pub(crate) fn to_ffi(
6978            &self,
6979        ) -> (ffi::WGPUDawnWGSLBlocklist, ChainedStructStorage) {
6980            let mut storage = ChainedStructStorage::new();
6981            let mut raw: ffi::WGPUDawnWGSLBlocklist = unsafe { std::mem::zeroed() };
6982            raw.blocklistedFeatureCount = self
6983                .blocklisted_features
6984                .as_ref()
6985                .map(|v| v.len())
6986                .unwrap_or(0);
6987            if let Some(values) = &self.blocklisted_features {
6988                let len_value = values.len();
6989                let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
6990                    values.len(),
6991                );
6992                let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
6993                    values.len(),
6994                );
6995                for item in values.iter() {
6996                    let c_string = std::ffi::CString::new(item.as_str())
6997                        .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
6998                    ptrs.push(c_string.as_ptr());
6999                    c_strings.push(c_string);
7000                }
7001                let ptr = storage.push_vec(ptrs);
7002                storage.push_any(c_strings);
7003                raw.blocklistedFeatures = ptr;
7004                raw.blocklistedFeatureCount = len_value;
7005            } else {
7006                raw.blocklistedFeatures = std::ptr::null();
7007                raw.blocklistedFeatureCount = 0;
7008            }
7009            (raw, storage)
7010        }
7011        pub(crate) fn from_ffi(value: ffi::WGPUDawnWGSLBlocklist) -> Self {
7012            Self {
7013                blocklisted_features: if value.blocklistedFeatures.is_null() {
7014                    None
7015                } else {
7016                    Some(
7017                        unsafe {
7018                            std::slice::from_raw_parts(
7019                                value.blocklistedFeatures,
7020                                value.blocklistedFeatureCount as usize,
7021                            )
7022                        }
7023                            .iter()
7024                            .map(|raw| {
7025                                if raw.is_null() {
7026                                    String::new()
7027                                } else {
7028                                    unsafe { CStr::from_ptr(*raw) }
7029                                        .to_string_lossy()
7030                                        .into_owned()
7031                                }
7032                            })
7033                            .collect(),
7034                    )
7035                },
7036            }
7037        }
7038    }
7039    pub struct DawnAdapterPropertiesPowerPreference {
7040        pub power_preference: Option<PowerPreference>,
7041    }
7042    impl Default for DawnAdapterPropertiesPowerPreference {
7043        fn default() -> Self {
7044            Self { power_preference: None }
7045        }
7046    }
7047    impl DawnAdapterPropertiesPowerPreference {
7048        pub fn new() -> Self {
7049            Self::default()
7050        }
7051        pub(crate) fn to_ffi(
7052            &self,
7053        ) -> (ffi::WGPUDawnAdapterPropertiesPowerPreference, ChainedStructStorage) {
7054            let mut storage = ChainedStructStorage::new();
7055            let mut raw: ffi::WGPUDawnAdapterPropertiesPowerPreference = unsafe {
7056                std::mem::zeroed()
7057            };
7058            if let Some(value) = self.power_preference {
7059                raw.powerPreference = value.into();
7060            } else {
7061                raw.powerPreference = 0 as ffi::WGPUPowerPreference;
7062            }
7063            (raw, storage)
7064        }
7065        pub(crate) fn from_ffi(
7066            value: ffi::WGPUDawnAdapterPropertiesPowerPreference,
7067        ) -> Self {
7068            Self {
7069                power_preference: Some(value.powerPreference.into()),
7070            }
7071        }
7072    }
7073    pub struct DawnBufferDescriptorErrorInfoFromWireClient {
7074        pub out_of_memory: Option<bool>,
7075    }
7076    impl Default for DawnBufferDescriptorErrorInfoFromWireClient {
7077        fn default() -> Self {
7078            Self { out_of_memory: None }
7079        }
7080    }
7081    impl DawnBufferDescriptorErrorInfoFromWireClient {
7082        pub fn new() -> Self {
7083            Self::default()
7084        }
7085        pub(crate) fn to_ffi(
7086            &self,
7087        ) -> (
7088            ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient,
7089            ChainedStructStorage,
7090        ) {
7091            let mut storage = ChainedStructStorage::new();
7092            let mut raw: ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient = unsafe {
7093                std::mem::zeroed()
7094            };
7095            raw.outOfMemory = if self.out_of_memory.unwrap_or(false) { 1 } else { 0 };
7096            (raw, storage)
7097        }
7098        pub(crate) fn from_ffi(
7099            value: ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient,
7100        ) -> Self {
7101            Self {
7102                out_of_memory: Some(value.outOfMemory != 0),
7103            }
7104        }
7105    }
7106    pub struct DawnCacheDeviceDescriptor {
7107        pub isolation_key: Option<String>,
7108        pub load_data_function: Option<DawnLoadCacheDataFunction>,
7109        pub store_data_function: Option<DawnStoreCacheDataFunction>,
7110        pub function_userdata: Option<*mut std::ffi::c_void>,
7111    }
7112    impl Default for DawnCacheDeviceDescriptor {
7113        fn default() -> Self {
7114            Self {
7115                isolation_key: None,
7116                load_data_function: None,
7117                store_data_function: None,
7118                function_userdata: None,
7119            }
7120        }
7121    }
7122    impl DawnCacheDeviceDescriptor {
7123        pub fn new() -> Self {
7124            Self::default()
7125        }
7126        pub(crate) fn to_ffi(
7127            &self,
7128        ) -> (ffi::WGPUDawnCacheDeviceDescriptor, ChainedStructStorage) {
7129            let mut storage = ChainedStructStorage::new();
7130            let mut raw: ffi::WGPUDawnCacheDeviceDescriptor = unsafe {
7131                std::mem::zeroed()
7132            };
7133            if let Some(value) = &self.isolation_key {
7134                raw.isolationKey = ffi::WGPUStringView {
7135                    data: value.as_ptr().cast(),
7136                    length: value.len(),
7137                };
7138            } else {
7139                raw.isolationKey = ffi::WGPUStringView {
7140                    data: std::ptr::null(),
7141                    length: 0,
7142                };
7143            }
7144            if let Some(value) = self.load_data_function {
7145                raw.loadDataFunction = value;
7146            }
7147            if let Some(value) = self.store_data_function {
7148                raw.storeDataFunction = value;
7149            }
7150            if let Some(value) = self.function_userdata {
7151                raw.functionUserdata = value;
7152            }
7153            (raw, storage)
7154        }
7155        pub(crate) fn from_ffi(value: ffi::WGPUDawnCacheDeviceDescriptor) -> Self {
7156            Self {
7157                isolation_key: Some(string_view_to_string(value.isolationKey)),
7158                load_data_function: Some(value.loadDataFunction),
7159                store_data_function: Some(value.storeDataFunction),
7160                function_userdata: Some(value.functionUserdata),
7161            }
7162        }
7163    }
7164    pub struct DawnCompilationMessageUtf16 {
7165        pub line_pos: Option<u64>,
7166        pub offset: Option<u64>,
7167        pub length: Option<u64>,
7168    }
7169    impl Default for DawnCompilationMessageUtf16 {
7170        fn default() -> Self {
7171            Self {
7172                line_pos: None,
7173                offset: None,
7174                length: None,
7175            }
7176        }
7177    }
7178    impl DawnCompilationMessageUtf16 {
7179        pub fn new() -> Self {
7180            Self::default()
7181        }
7182        pub(crate) fn to_ffi(
7183            &self,
7184        ) -> (ffi::WGPUDawnCompilationMessageUtf16, ChainedStructStorage) {
7185            let mut storage = ChainedStructStorage::new();
7186            let mut raw: ffi::WGPUDawnCompilationMessageUtf16 = unsafe {
7187                std::mem::zeroed()
7188            };
7189            if let Some(value) = self.line_pos {
7190                raw.linePos = value;
7191            }
7192            if let Some(value) = self.offset {
7193                raw.offset = value;
7194            }
7195            if let Some(value) = self.length {
7196                raw.length = value;
7197            }
7198            (raw, storage)
7199        }
7200        pub(crate) fn from_ffi(value: ffi::WGPUDawnCompilationMessageUtf16) -> Self {
7201            Self {
7202                line_pos: Some(value.linePos),
7203                offset: Some(value.offset),
7204                length: Some(value.length),
7205            }
7206        }
7207    }
7208    pub struct DawnConsumeAdapterDescriptor {
7209        pub consume_adapter: Option<bool>,
7210    }
7211    impl Default for DawnConsumeAdapterDescriptor {
7212        fn default() -> Self {
7213            Self { consume_adapter: None }
7214        }
7215    }
7216    impl DawnConsumeAdapterDescriptor {
7217        pub fn new() -> Self {
7218            Self::default()
7219        }
7220        pub(crate) fn to_ffi(
7221            &self,
7222        ) -> (ffi::WGPUDawnConsumeAdapterDescriptor, ChainedStructStorage) {
7223            let mut storage = ChainedStructStorage::new();
7224            let mut raw: ffi::WGPUDawnConsumeAdapterDescriptor = unsafe {
7225                std::mem::zeroed()
7226            };
7227            raw.consumeAdapter = if self.consume_adapter.unwrap_or(false) {
7228                1
7229            } else {
7230                0
7231            };
7232            (raw, storage)
7233        }
7234        pub(crate) fn from_ffi(value: ffi::WGPUDawnConsumeAdapterDescriptor) -> Self {
7235            Self {
7236                consume_adapter: Some(value.consumeAdapter != 0),
7237            }
7238        }
7239    }
7240    pub struct DawnDeviceAllocatorControl {
7241        pub allocator_heap_block_size: Option<usize>,
7242    }
7243    impl Default for DawnDeviceAllocatorControl {
7244        fn default() -> Self {
7245            Self {
7246                allocator_heap_block_size: Some(0),
7247            }
7248        }
7249    }
7250    impl DawnDeviceAllocatorControl {
7251        pub fn new() -> Self {
7252            Self::default()
7253        }
7254        pub(crate) fn to_ffi(
7255            &self,
7256        ) -> (ffi::WGPUDawnDeviceAllocatorControl, ChainedStructStorage) {
7257            let mut storage = ChainedStructStorage::new();
7258            let mut raw: ffi::WGPUDawnDeviceAllocatorControl = unsafe {
7259                std::mem::zeroed()
7260            };
7261            if let Some(value) = self.allocator_heap_block_size {
7262                raw.allocatorHeapBlockSize = value;
7263            }
7264            (raw, storage)
7265        }
7266        pub(crate) fn from_ffi(value: ffi::WGPUDawnDeviceAllocatorControl) -> Self {
7267            Self {
7268                allocator_heap_block_size: Some(value.allocatorHeapBlockSize),
7269            }
7270        }
7271    }
7272    pub struct DawnDrmFormatCapabilities {
7273        pub properties: Option<Vec<DawnDrmFormatProperties>>,
7274        #[doc(hidden)]
7275        pub(crate) _free_members: Option<ffi::WGPUDawnDrmFormatCapabilities>,
7276    }
7277    impl Default for DawnDrmFormatCapabilities {
7278        fn default() -> Self {
7279            Self {
7280                properties: None,
7281                _free_members: None,
7282            }
7283        }
7284    }
7285    impl DawnDrmFormatCapabilities {
7286        pub fn new() -> Self {
7287            Self::default()
7288        }
7289        pub(crate) fn to_ffi(
7290            &self,
7291        ) -> (ffi::WGPUDawnDrmFormatCapabilities, ChainedStructStorage) {
7292            let mut storage = ChainedStructStorage::new();
7293            let mut raw: ffi::WGPUDawnDrmFormatCapabilities = unsafe {
7294                std::mem::zeroed()
7295            };
7296            raw.propertiesCount = self.properties.as_ref().map(|v| v.len()).unwrap_or(0);
7297            if let Some(values) = &self.properties {
7298                let len_value = values.len();
7299                let mut raw_vec: Vec<ffi::WGPUDawnDrmFormatProperties> = Vec::with_capacity(
7300                    values.len(),
7301                );
7302                for item in values.iter() {
7303                    let (raw_item, storage_item) = item.to_ffi();
7304                    raw_vec.push(raw_item);
7305                    storage.push_storage(storage_item);
7306                }
7307                let ptr = storage.push_vec(raw_vec);
7308                raw.properties = ptr;
7309                raw.propertiesCount = len_value;
7310            } else {
7311                raw.properties = std::ptr::null();
7312                raw.propertiesCount = 0;
7313            }
7314            (raw, storage)
7315        }
7316        pub(crate) fn from_ffi(value: ffi::WGPUDawnDrmFormatCapabilities) -> Self {
7317            Self {
7318                properties: if value.properties.is_null() {
7319                    None
7320                } else {
7321                    Some(
7322                        unsafe {
7323                            std::slice::from_raw_parts(
7324                                value.properties,
7325                                value.propertiesCount as usize,
7326                            )
7327                        }
7328                            .iter()
7329                            .map(|raw| DawnDrmFormatProperties::from_ffi(*raw))
7330                            .collect(),
7331                    )
7332                },
7333                _free_members: Some(value),
7334            }
7335        }
7336        pub(crate) fn free_members(value: ffi::WGPUDawnDrmFormatCapabilities) {
7337            unsafe { ffi::wgpuDawnDrmFormatCapabilitiesFreeMembers(value) };
7338        }
7339    }
7340    impl Drop for DawnDrmFormatCapabilities {
7341        fn drop(&mut self) {
7342            if let Some(value) = self._free_members.take() {
7343                unsafe { ffi::wgpuDawnDrmFormatCapabilitiesFreeMembers(value) };
7344            }
7345        }
7346    }
7347    pub struct DawnDrmFormatProperties {
7348        pub modifier: Option<u64>,
7349        pub modifier_plane_count: Option<u32>,
7350    }
7351    impl Default for DawnDrmFormatProperties {
7352        fn default() -> Self {
7353            Self {
7354                modifier: None,
7355                modifier_plane_count: None,
7356            }
7357        }
7358    }
7359    impl DawnDrmFormatProperties {
7360        pub fn new() -> Self {
7361            Self::default()
7362        }
7363        pub(crate) fn to_ffi(
7364            &self,
7365        ) -> (ffi::WGPUDawnDrmFormatProperties, ChainedStructStorage) {
7366            let mut storage = ChainedStructStorage::new();
7367            let mut raw: ffi::WGPUDawnDrmFormatProperties = unsafe {
7368                std::mem::zeroed()
7369            };
7370            if let Some(value) = self.modifier {
7371                raw.modifier = value;
7372            }
7373            if let Some(value) = self.modifier_plane_count {
7374                raw.modifierPlaneCount = value;
7375            }
7376            (raw, storage)
7377        }
7378        pub(crate) fn from_ffi(value: ffi::WGPUDawnDrmFormatProperties) -> Self {
7379            Self {
7380                modifier: Some(value.modifier),
7381                modifier_plane_count: Some(value.modifierPlaneCount),
7382            }
7383        }
7384    }
7385    pub struct DawnEncoderInternalUsageDescriptor {
7386        pub use_internal_usages: Option<bool>,
7387    }
7388    impl Default for DawnEncoderInternalUsageDescriptor {
7389        fn default() -> Self {
7390            Self { use_internal_usages: None }
7391        }
7392    }
7393    impl DawnEncoderInternalUsageDescriptor {
7394        pub fn new() -> Self {
7395            Self::default()
7396        }
7397        pub(crate) fn to_ffi(
7398            &self,
7399        ) -> (ffi::WGPUDawnEncoderInternalUsageDescriptor, ChainedStructStorage) {
7400            let mut storage = ChainedStructStorage::new();
7401            let mut raw: ffi::WGPUDawnEncoderInternalUsageDescriptor = unsafe {
7402                std::mem::zeroed()
7403            };
7404            raw.useInternalUsages = if self.use_internal_usages.unwrap_or(false) {
7405                1
7406            } else {
7407                0
7408            };
7409            (raw, storage)
7410        }
7411        pub(crate) fn from_ffi(
7412            value: ffi::WGPUDawnEncoderInternalUsageDescriptor,
7413        ) -> Self {
7414            Self {
7415                use_internal_usages: Some(value.useInternalUsages != 0),
7416            }
7417        }
7418    }
7419    pub struct DawnFakeBufferOOMForTesting {
7420        pub fake_oom_at_wire_client_map: Option<bool>,
7421        pub fake_oom_at_native_map: Option<bool>,
7422        pub fake_oom_at_device: Option<bool>,
7423    }
7424    impl Default for DawnFakeBufferOOMForTesting {
7425        fn default() -> Self {
7426            Self {
7427                fake_oom_at_wire_client_map: None,
7428                fake_oom_at_native_map: None,
7429                fake_oom_at_device: None,
7430            }
7431        }
7432    }
7433    impl DawnFakeBufferOOMForTesting {
7434        pub fn new() -> Self {
7435            Self::default()
7436        }
7437        pub(crate) fn to_ffi(
7438            &self,
7439        ) -> (ffi::WGPUDawnFakeBufferOOMForTesting, ChainedStructStorage) {
7440            let mut storage = ChainedStructStorage::new();
7441            let mut raw: ffi::WGPUDawnFakeBufferOOMForTesting = unsafe {
7442                std::mem::zeroed()
7443            };
7444            raw.fakeOOMAtWireClientMap = if self
7445                .fake_oom_at_wire_client_map
7446                .unwrap_or(false)
7447            {
7448                1
7449            } else {
7450                0
7451            };
7452            raw.fakeOOMAtNativeMap = if self.fake_oom_at_native_map.unwrap_or(false) {
7453                1
7454            } else {
7455                0
7456            };
7457            raw.fakeOOMAtDevice = if self.fake_oom_at_device.unwrap_or(false) {
7458                1
7459            } else {
7460                0
7461            };
7462            (raw, storage)
7463        }
7464        pub(crate) fn from_ffi(value: ffi::WGPUDawnFakeBufferOOMForTesting) -> Self {
7465            Self {
7466                fake_oom_at_wire_client_map: Some(value.fakeOOMAtWireClientMap != 0),
7467                fake_oom_at_native_map: Some(value.fakeOOMAtNativeMap != 0),
7468                fake_oom_at_device: Some(value.fakeOOMAtDevice != 0),
7469            }
7470        }
7471    }
7472    pub struct DawnFakeDeviceInitializeErrorForTesting {}
7473    impl Default for DawnFakeDeviceInitializeErrorForTesting {
7474        fn default() -> Self {
7475            Self {}
7476        }
7477    }
7478    impl DawnFakeDeviceInitializeErrorForTesting {
7479        pub fn new() -> Self {
7480            Self::default()
7481        }
7482        pub(crate) fn to_ffi(
7483            &self,
7484        ) -> (ffi::WGPUDawnFakeDeviceInitializeErrorForTesting, ChainedStructStorage) {
7485            let mut storage = ChainedStructStorage::new();
7486            let mut raw: ffi::WGPUDawnFakeDeviceInitializeErrorForTesting = unsafe {
7487                std::mem::zeroed()
7488            };
7489            (raw, storage)
7490        }
7491        pub(crate) fn from_ffi(
7492            value: ffi::WGPUDawnFakeDeviceInitializeErrorForTesting,
7493        ) -> Self {
7494            let _ = value;
7495            Self::default()
7496        }
7497    }
7498    pub struct DawnFormatCapabilities {
7499        pub(crate) extensions: Vec<DawnFormatCapabilitiesExtension>,
7500    }
7501    impl Default for DawnFormatCapabilities {
7502        fn default() -> Self {
7503            Self { extensions: Vec::new() }
7504        }
7505    }
7506    impl DawnFormatCapabilities {
7507        pub fn new() -> Self {
7508            Self::default()
7509        }
7510        pub(crate) fn to_ffi(
7511            &self,
7512        ) -> (ffi::WGPUDawnFormatCapabilities, ChainedStructStorage) {
7513            let mut storage = ChainedStructStorage::new();
7514            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7515            for ext in self.extensions.iter().rev() {
7516                next = ext.push_chain(&mut storage, next);
7517            }
7518            let mut raw: ffi::WGPUDawnFormatCapabilities = unsafe { std::mem::zeroed() };
7519            raw.nextInChain = next;
7520            (raw, storage)
7521        }
7522        pub fn with_extension(
7523            mut self,
7524            extension: DawnFormatCapabilitiesExtension,
7525        ) -> Self {
7526            self.extensions.push(extension);
7527            self
7528        }
7529        pub(crate) fn from_ffi(value: ffi::WGPUDawnFormatCapabilities) -> Self {
7530            Self { extensions: Vec::new() }
7531        }
7532    }
7533    pub struct DawnHostMappedPointerLimits {
7534        pub host_mapped_pointer_alignment: Option<u32>,
7535    }
7536    impl Default for DawnHostMappedPointerLimits {
7537        fn default() -> Self {
7538            Self {
7539                host_mapped_pointer_alignment: Some(LIMIT_U32_UNDEFINED),
7540            }
7541        }
7542    }
7543    impl DawnHostMappedPointerLimits {
7544        pub fn new() -> Self {
7545            Self::default()
7546        }
7547        pub(crate) fn to_ffi(
7548            &self,
7549        ) -> (ffi::WGPUDawnHostMappedPointerLimits, ChainedStructStorage) {
7550            let mut storage = ChainedStructStorage::new();
7551            let mut raw: ffi::WGPUDawnHostMappedPointerLimits = unsafe {
7552                std::mem::zeroed()
7553            };
7554            if let Some(value) = self.host_mapped_pointer_alignment {
7555                raw.hostMappedPointerAlignment = value;
7556            }
7557            (raw, storage)
7558        }
7559        pub(crate) fn from_ffi(value: ffi::WGPUDawnHostMappedPointerLimits) -> Self {
7560            Self {
7561                host_mapped_pointer_alignment: Some(value.hostMappedPointerAlignment),
7562            }
7563        }
7564    }
7565    pub struct DawnInjectedInvalidSType {
7566        pub invalid_s_type: Option<SType>,
7567    }
7568    impl Default for DawnInjectedInvalidSType {
7569        fn default() -> Self {
7570            Self { invalid_s_type: None }
7571        }
7572    }
7573    impl DawnInjectedInvalidSType {
7574        pub fn new() -> Self {
7575            Self::default()
7576        }
7577        pub(crate) fn to_ffi(
7578            &self,
7579        ) -> (ffi::WGPUDawnInjectedInvalidSType, ChainedStructStorage) {
7580            let mut storage = ChainedStructStorage::new();
7581            let mut raw: ffi::WGPUDawnInjectedInvalidSType = unsafe {
7582                std::mem::zeroed()
7583            };
7584            if let Some(value) = self.invalid_s_type {
7585                raw.invalidSType = value.into();
7586            } else {
7587                raw.invalidSType = 0 as ffi::WGPUSType;
7588            }
7589            (raw, storage)
7590        }
7591        pub(crate) fn from_ffi(value: ffi::WGPUDawnInjectedInvalidSType) -> Self {
7592            Self {
7593                invalid_s_type: Some(value.invalidSType.into()),
7594            }
7595        }
7596    }
7597    pub struct DawnRenderPassSampleCount {
7598        pub sample_count: Option<u32>,
7599    }
7600    impl Default for DawnRenderPassSampleCount {
7601        fn default() -> Self {
7602            Self { sample_count: Some(1) }
7603        }
7604    }
7605    impl DawnRenderPassSampleCount {
7606        pub fn new() -> Self {
7607            Self::default()
7608        }
7609        pub(crate) fn to_ffi(
7610            &self,
7611        ) -> (ffi::WGPUDawnRenderPassSampleCount, ChainedStructStorage) {
7612            let mut storage = ChainedStructStorage::new();
7613            let mut raw: ffi::WGPUDawnRenderPassSampleCount = unsafe {
7614                std::mem::zeroed()
7615            };
7616            if let Some(value) = self.sample_count {
7617                raw.sampleCount = value;
7618            }
7619            (raw, storage)
7620        }
7621        pub(crate) fn from_ffi(value: ffi::WGPUDawnRenderPassSampleCount) -> Self {
7622            Self {
7623                sample_count: Some(value.sampleCount),
7624            }
7625        }
7626    }
7627    pub struct DawnShaderModuleSPIRVOptionsDescriptor {
7628        pub allow_non_uniform_derivatives: Option<bool>,
7629    }
7630    impl Default for DawnShaderModuleSPIRVOptionsDescriptor {
7631        fn default() -> Self {
7632            Self {
7633                allow_non_uniform_derivatives: None,
7634            }
7635        }
7636    }
7637    impl DawnShaderModuleSPIRVOptionsDescriptor {
7638        pub fn new() -> Self {
7639            Self::default()
7640        }
7641        pub(crate) fn to_ffi(
7642            &self,
7643        ) -> (ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor, ChainedStructStorage) {
7644            let mut storage = ChainedStructStorage::new();
7645            let mut raw: ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor = unsafe {
7646                std::mem::zeroed()
7647            };
7648            raw.allowNonUniformDerivatives = if self
7649                .allow_non_uniform_derivatives
7650                .unwrap_or(false)
7651            {
7652                1
7653            } else {
7654                0
7655            };
7656            (raw, storage)
7657        }
7658        pub(crate) fn from_ffi(
7659            value: ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor,
7660        ) -> Self {
7661            Self {
7662                allow_non_uniform_derivatives: Some(
7663                    value.allowNonUniformDerivatives != 0,
7664                ),
7665            }
7666        }
7667    }
7668    pub struct DawnTexelCopyBufferRowAlignmentLimits {
7669        pub min_texel_copy_buffer_row_alignment: Option<u32>,
7670    }
7671    impl Default for DawnTexelCopyBufferRowAlignmentLimits {
7672        fn default() -> Self {
7673            Self {
7674                min_texel_copy_buffer_row_alignment: Some(LIMIT_U32_UNDEFINED),
7675            }
7676        }
7677    }
7678    impl DawnTexelCopyBufferRowAlignmentLimits {
7679        pub fn new() -> Self {
7680            Self::default()
7681        }
7682        pub(crate) fn to_ffi(
7683            &self,
7684        ) -> (ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits, ChainedStructStorage) {
7685            let mut storage = ChainedStructStorage::new();
7686            let mut raw: ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits = unsafe {
7687                std::mem::zeroed()
7688            };
7689            if let Some(value) = self.min_texel_copy_buffer_row_alignment {
7690                raw.minTexelCopyBufferRowAlignment = value;
7691            }
7692            (raw, storage)
7693        }
7694        pub(crate) fn from_ffi(
7695            value: ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits,
7696        ) -> Self {
7697            Self {
7698                min_texel_copy_buffer_row_alignment: Some(
7699                    value.minTexelCopyBufferRowAlignment,
7700                ),
7701            }
7702        }
7703    }
7704    pub struct DawnTextureInternalUsageDescriptor {
7705        pub internal_usage: Option<TextureUsage>,
7706    }
7707    impl Default for DawnTextureInternalUsageDescriptor {
7708        fn default() -> Self {
7709            Self { internal_usage: None }
7710        }
7711    }
7712    impl DawnTextureInternalUsageDescriptor {
7713        pub fn new() -> Self {
7714            Self::default()
7715        }
7716        pub(crate) fn to_ffi(
7717            &self,
7718        ) -> (ffi::WGPUDawnTextureInternalUsageDescriptor, ChainedStructStorage) {
7719            let mut storage = ChainedStructStorage::new();
7720            let mut raw: ffi::WGPUDawnTextureInternalUsageDescriptor = unsafe {
7721                std::mem::zeroed()
7722            };
7723            if let Some(value) = self.internal_usage {
7724                raw.internalUsage = value.into();
7725            } else {
7726                raw.internalUsage = 0 as ffi::WGPUTextureUsage;
7727            }
7728            (raw, storage)
7729        }
7730        pub(crate) fn from_ffi(
7731            value: ffi::WGPUDawnTextureInternalUsageDescriptor,
7732        ) -> Self {
7733            Self {
7734                internal_usage: Some(value.internalUsage.into()),
7735            }
7736        }
7737    }
7738    pub struct DawnTogglesDescriptor {
7739        pub enabled_toggles: Option<Vec<String>>,
7740        pub disabled_toggles: Option<Vec<String>>,
7741    }
7742    impl Default for DawnTogglesDescriptor {
7743        fn default() -> Self {
7744            Self {
7745                enabled_toggles: None,
7746                disabled_toggles: None,
7747            }
7748        }
7749    }
7750    impl DawnTogglesDescriptor {
7751        pub fn new() -> Self {
7752            Self::default()
7753        }
7754        pub(crate) fn to_ffi(
7755            &self,
7756        ) -> (ffi::WGPUDawnTogglesDescriptor, ChainedStructStorage) {
7757            let mut storage = ChainedStructStorage::new();
7758            let mut raw: ffi::WGPUDawnTogglesDescriptor = unsafe { std::mem::zeroed() };
7759            raw.enabledToggleCount = self
7760                .enabled_toggles
7761                .as_ref()
7762                .map(|v| v.len())
7763                .unwrap_or(0);
7764            if let Some(values) = &self.enabled_toggles {
7765                let len_value = values.len();
7766                let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
7767                    values.len(),
7768                );
7769                let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
7770                    values.len(),
7771                );
7772                for item in values.iter() {
7773                    let c_string = std::ffi::CString::new(item.as_str())
7774                        .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
7775                    ptrs.push(c_string.as_ptr());
7776                    c_strings.push(c_string);
7777                }
7778                let ptr = storage.push_vec(ptrs);
7779                storage.push_any(c_strings);
7780                raw.enabledToggles = ptr;
7781                raw.enabledToggleCount = len_value;
7782            } else {
7783                raw.enabledToggles = std::ptr::null();
7784                raw.enabledToggleCount = 0;
7785            }
7786            raw.disabledToggleCount = self
7787                .disabled_toggles
7788                .as_ref()
7789                .map(|v| v.len())
7790                .unwrap_or(0);
7791            if let Some(values) = &self.disabled_toggles {
7792                let len_value = values.len();
7793                let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
7794                    values.len(),
7795                );
7796                let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
7797                    values.len(),
7798                );
7799                for item in values.iter() {
7800                    let c_string = std::ffi::CString::new(item.as_str())
7801                        .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
7802                    ptrs.push(c_string.as_ptr());
7803                    c_strings.push(c_string);
7804                }
7805                let ptr = storage.push_vec(ptrs);
7806                storage.push_any(c_strings);
7807                raw.disabledToggles = ptr;
7808                raw.disabledToggleCount = len_value;
7809            } else {
7810                raw.disabledToggles = std::ptr::null();
7811                raw.disabledToggleCount = 0;
7812            }
7813            (raw, storage)
7814        }
7815        pub(crate) fn from_ffi(value: ffi::WGPUDawnTogglesDescriptor) -> Self {
7816            Self {
7817                enabled_toggles: if value.enabledToggles.is_null() {
7818                    None
7819                } else {
7820                    Some(
7821                        unsafe {
7822                            std::slice::from_raw_parts(
7823                                value.enabledToggles,
7824                                value.enabledToggleCount as usize,
7825                            )
7826                        }
7827                            .iter()
7828                            .map(|raw| {
7829                                if raw.is_null() {
7830                                    String::new()
7831                                } else {
7832                                    unsafe { CStr::from_ptr(*raw) }
7833                                        .to_string_lossy()
7834                                        .into_owned()
7835                                }
7836                            })
7837                            .collect(),
7838                    )
7839                },
7840                disabled_toggles: if value.disabledToggles.is_null() {
7841                    None
7842                } else {
7843                    Some(
7844                        unsafe {
7845                            std::slice::from_raw_parts(
7846                                value.disabledToggles,
7847                                value.disabledToggleCount as usize,
7848                            )
7849                        }
7850                            .iter()
7851                            .map(|raw| {
7852                                if raw.is_null() {
7853                                    String::new()
7854                                } else {
7855                                    unsafe { CStr::from_ptr(*raw) }
7856                                        .to_string_lossy()
7857                                        .into_owned()
7858                                }
7859                            })
7860                            .collect(),
7861                    )
7862                },
7863            }
7864        }
7865    }
7866    pub struct DawnWireWGSLControl {
7867        pub enable_experimental: Option<bool>,
7868        pub enable_unsafe: Option<bool>,
7869        pub enable_testing: Option<bool>,
7870    }
7871    impl Default for DawnWireWGSLControl {
7872        fn default() -> Self {
7873            Self {
7874                enable_experimental: None,
7875                enable_unsafe: None,
7876                enable_testing: None,
7877            }
7878        }
7879    }
7880    impl DawnWireWGSLControl {
7881        pub fn new() -> Self {
7882            Self::default()
7883        }
7884        pub(crate) fn to_ffi(
7885            &self,
7886        ) -> (ffi::WGPUDawnWireWGSLControl, ChainedStructStorage) {
7887            let mut storage = ChainedStructStorage::new();
7888            let mut raw: ffi::WGPUDawnWireWGSLControl = unsafe { std::mem::zeroed() };
7889            raw.enableExperimental = if self.enable_experimental.unwrap_or(false) {
7890                1
7891            } else {
7892                0
7893            };
7894            raw.enableUnsafe = if self.enable_unsafe.unwrap_or(false) { 1 } else { 0 };
7895            raw.enableTesting = if self.enable_testing.unwrap_or(false) { 1 } else { 0 };
7896            (raw, storage)
7897        }
7898        pub(crate) fn from_ffi(value: ffi::WGPUDawnWireWGSLControl) -> Self {
7899            Self {
7900                enable_experimental: Some(value.enableExperimental != 0),
7901                enable_unsafe: Some(value.enableUnsafe != 0),
7902                enable_testing: Some(value.enableTesting != 0),
7903            }
7904        }
7905    }
7906    pub struct DepthStencilState {
7907        pub(crate) extensions: Vec<DepthStencilStateExtension>,
7908        pub format: Option<TextureFormat>,
7909        pub depth_write_enabled: Option<OptionalBool>,
7910        pub depth_compare: Option<CompareFunction>,
7911        pub stencil_front: Option<StencilFaceState>,
7912        pub stencil_back: Option<StencilFaceState>,
7913        pub stencil_read_mask: Option<u32>,
7914        pub stencil_write_mask: Option<u32>,
7915        pub depth_bias: Option<i32>,
7916        pub depth_bias_slope_scale: Option<f32>,
7917        pub depth_bias_clamp: Option<f32>,
7918    }
7919    impl Default for DepthStencilState {
7920        fn default() -> Self {
7921            Self {
7922                extensions: Vec::new(),
7923                format: None,
7924                depth_write_enabled: None,
7925                depth_compare: None,
7926                stencil_front: None,
7927                stencil_back: None,
7928                stencil_read_mask: Some(4294967295),
7929                stencil_write_mask: Some(4294967295),
7930                depth_bias: Some(0),
7931                depth_bias_slope_scale: None,
7932                depth_bias_clamp: None,
7933            }
7934        }
7935    }
7936    impl DepthStencilState {
7937        pub fn new() -> Self {
7938            Self::default()
7939        }
7940        pub(crate) fn to_ffi(
7941            &self,
7942        ) -> (ffi::WGPUDepthStencilState, ChainedStructStorage) {
7943            let mut storage = ChainedStructStorage::new();
7944            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7945            for ext in self.extensions.iter().rev() {
7946                next = ext.push_chain(&mut storage, next);
7947            }
7948            let mut raw: ffi::WGPUDepthStencilState = unsafe { std::mem::zeroed() };
7949            raw.nextInChain = next;
7950            if let Some(value) = self.format {
7951                raw.format = value.into();
7952            } else {
7953                raw.format = 0 as ffi::WGPUTextureFormat;
7954            }
7955            if let Some(value) = self.depth_write_enabled {
7956                raw.depthWriteEnabled = value.into();
7957            } else {
7958                raw.depthWriteEnabled = 0 as ffi::WGPUOptionalBool;
7959            }
7960            if let Some(value) = self.depth_compare {
7961                raw.depthCompare = value.into();
7962            } else {
7963                raw.depthCompare = 0 as ffi::WGPUCompareFunction;
7964            }
7965            if let Some(value) = &self.stencil_front {
7966                let (raw_value, storage_value) = value.to_ffi();
7967                raw.stencilFront = raw_value;
7968                storage.push_storage(storage_value);
7969            }
7970            if let Some(value) = &self.stencil_back {
7971                let (raw_value, storage_value) = value.to_ffi();
7972                raw.stencilBack = raw_value;
7973                storage.push_storage(storage_value);
7974            }
7975            if let Some(value) = self.stencil_read_mask {
7976                raw.stencilReadMask = value;
7977            }
7978            if let Some(value) = self.stencil_write_mask {
7979                raw.stencilWriteMask = value;
7980            }
7981            if let Some(value) = self.depth_bias {
7982                raw.depthBias = value;
7983            }
7984            if let Some(value) = self.depth_bias_slope_scale {
7985                raw.depthBiasSlopeScale = value;
7986            }
7987            if let Some(value) = self.depth_bias_clamp {
7988                raw.depthBiasClamp = value;
7989            }
7990            (raw, storage)
7991        }
7992        pub fn with_extension(mut self, extension: DepthStencilStateExtension) -> Self {
7993            self.extensions.push(extension);
7994            self
7995        }
7996        pub(crate) fn from_ffi(value: ffi::WGPUDepthStencilState) -> Self {
7997            Self {
7998                extensions: Vec::new(),
7999                format: Some(value.format.into()),
8000                depth_write_enabled: Some(value.depthWriteEnabled.into()),
8001                depth_compare: Some(value.depthCompare.into()),
8002                stencil_front: Some(StencilFaceState::from_ffi(value.stencilFront)),
8003                stencil_back: Some(StencilFaceState::from_ffi(value.stencilBack)),
8004                stencil_read_mask: Some(value.stencilReadMask),
8005                stencil_write_mask: Some(value.stencilWriteMask),
8006                depth_bias: Some(value.depthBias),
8007                depth_bias_slope_scale: Some(value.depthBiasSlopeScale),
8008                depth_bias_clamp: Some(value.depthBiasClamp),
8009            }
8010        }
8011    }
8012    pub struct DeviceDescriptor {
8013        pub(crate) extensions: Vec<DeviceDescriptorExtension>,
8014        pub label: Option<String>,
8015        pub required_features: Option<Vec<FeatureName>>,
8016        pub required_limits: Option<Limits>,
8017        pub default_queue: Option<QueueDescriptor>,
8018        pub device_lost_callback_info: Option<DeviceLostCallbackInfo>,
8019        pub uncaptured_error_callback_info: Option<UncapturedErrorCallbackInfo>,
8020    }
8021    impl Default for DeviceDescriptor {
8022        fn default() -> Self {
8023            Self {
8024                extensions: Vec::new(),
8025                label: None,
8026                required_features: None,
8027                required_limits: None,
8028                default_queue: None,
8029                device_lost_callback_info: None,
8030                uncaptured_error_callback_info: None,
8031            }
8032        }
8033    }
8034    impl DeviceDescriptor {
8035        pub fn new() -> Self {
8036            Self::default()
8037        }
8038        pub(crate) fn to_ffi(
8039            &self,
8040        ) -> (ffi::WGPUDeviceDescriptor, ChainedStructStorage) {
8041            let mut storage = ChainedStructStorage::new();
8042            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8043            for ext in self.extensions.iter().rev() {
8044                next = ext.push_chain(&mut storage, next);
8045            }
8046            let mut raw: ffi::WGPUDeviceDescriptor = unsafe { std::mem::zeroed() };
8047            raw.nextInChain = next;
8048            if let Some(value) = &self.label {
8049                raw.label = ffi::WGPUStringView {
8050                    data: value.as_ptr().cast(),
8051                    length: value.len(),
8052                };
8053            } else {
8054                raw.label = ffi::WGPUStringView {
8055                    data: std::ptr::null(),
8056                    length: 0,
8057                };
8058            }
8059            raw.requiredFeatureCount = self
8060                .required_features
8061                .as_ref()
8062                .map(|v| v.len())
8063                .unwrap_or(0);
8064            if let Some(values) = &self.required_features {
8065                let len_value = values.len();
8066                let raw_vec: Vec<ffi::WGPUFeatureName> = values
8067                    .iter()
8068                    .map(|v| (*v).into())
8069                    .collect();
8070                let ptr = storage.push_vec(raw_vec);
8071                raw.requiredFeatures = ptr;
8072                raw.requiredFeatureCount = len_value;
8073            } else {
8074                raw.requiredFeatures = std::ptr::null();
8075                raw.requiredFeatureCount = 0;
8076            }
8077            if let Some(value) = &self.required_limits {
8078                let (raw_value, storage_value) = value.to_ffi();
8079                let ptr = storage.push_value(raw_value);
8080                raw.requiredLimits = ptr;
8081                storage.push_storage(storage_value);
8082            } else {
8083                raw.requiredLimits = std::ptr::null();
8084            }
8085            if let Some(value) = &self.default_queue {
8086                let (raw_value, storage_value) = value.to_ffi();
8087                raw.defaultQueue = raw_value;
8088                storage.push_storage(storage_value);
8089            }
8090            if let Some(info) = &self.device_lost_callback_info {
8091                let mut callback_slot = info.callback.borrow_mut();
8092                let callback = callback_slot.take();
8093                let (
8094                    callback_ptr,
8095                    userdata1,
8096                ): (ffi::WGPUDeviceLostCallback, *mut std::ffi::c_void) = if let Some(
8097                    callback,
8098                ) = callback {
8099                    let callback_box: DeviceLostCallback = callback;
8100                    let callback_box = Box::new(Some(callback_box));
8101                    let userdata = Box::into_raw(callback_box)
8102                        .cast::<std::ffi::c_void>();
8103                    (Some(device_lost_callback_trampoline), userdata)
8104                } else {
8105                    (None, std::ptr::null_mut())
8106                };
8107                let mode = info.mode.unwrap_or(CallbackMode::AllowSpontaneous);
8108                raw.deviceLostCallbackInfo = ffi::WGPUDeviceLostCallbackInfo {
8109                    nextInChain: std::ptr::null_mut(),
8110                    mode: mode.into(),
8111                    callback: callback_ptr,
8112                    userdata1,
8113                    userdata2: std::ptr::null_mut(),
8114                };
8115            } else {
8116                raw.deviceLostCallbackInfo = ffi::WGPUDeviceLostCallbackInfo {
8117                    nextInChain: std::ptr::null_mut(),
8118                    mode: CallbackMode::AllowSpontaneous.into(),
8119                    callback: None,
8120                    userdata1: std::ptr::null_mut(),
8121                    userdata2: std::ptr::null_mut(),
8122                };
8123            }
8124            if let Some(info) = &self.uncaptured_error_callback_info {
8125                let mut callback_slot = info.callback.borrow_mut();
8126                let callback = callback_slot.take();
8127                let (
8128                    callback_ptr,
8129                    userdata1,
8130                ): (ffi::WGPUUncapturedErrorCallback, *mut std::ffi::c_void) = if let Some(
8131                    callback,
8132                ) = callback {
8133                    let callback_box: UncapturedErrorCallback = callback;
8134                    let callback_box = Box::new(Some(callback_box));
8135                    let userdata = Box::into_raw(callback_box)
8136                        .cast::<std::ffi::c_void>();
8137                    (Some(uncaptured_error_callback_trampoline), userdata)
8138                } else {
8139                    (None, std::ptr::null_mut())
8140                };
8141                raw.uncapturedErrorCallbackInfo = ffi::WGPUUncapturedErrorCallbackInfo {
8142                    nextInChain: std::ptr::null_mut(),
8143                    callback: callback_ptr,
8144                    userdata1,
8145                    userdata2: std::ptr::null_mut(),
8146                };
8147            } else {
8148                raw.uncapturedErrorCallbackInfo = ffi::WGPUUncapturedErrorCallbackInfo {
8149                    nextInChain: std::ptr::null_mut(),
8150                    callback: None,
8151                    userdata1: std::ptr::null_mut(),
8152                    userdata2: std::ptr::null_mut(),
8153                };
8154            }
8155            (raw, storage)
8156        }
8157        pub fn with_extension(mut self, extension: DeviceDescriptorExtension) -> Self {
8158            self.extensions.push(extension);
8159            self
8160        }
8161        pub(crate) fn from_ffi(value: ffi::WGPUDeviceDescriptor) -> Self {
8162            Self {
8163                extensions: Vec::new(),
8164                label: if value.label.data.is_null() || value.label.length == 0 {
8165                    None
8166                } else {
8167                    Some(string_view_to_string(value.label))
8168                },
8169                required_features: if value.requiredFeatures.is_null() {
8170                    None
8171                } else {
8172                    Some(
8173                        unsafe {
8174                            std::slice::from_raw_parts(
8175                                value.requiredFeatures,
8176                                value.requiredFeatureCount as usize,
8177                            )
8178                        }
8179                            .iter()
8180                            .map(|raw| FeatureName::from(*raw))
8181                            .collect(),
8182                    )
8183                },
8184                required_limits: if value.requiredLimits.is_null() {
8185                    None
8186                } else {
8187                    Some(Limits::from_ffi(unsafe { *value.requiredLimits }))
8188                },
8189                default_queue: Some(QueueDescriptor::from_ffi(value.defaultQueue)),
8190                device_lost_callback_info: None,
8191                uncaptured_error_callback_info: None,
8192            }
8193        }
8194    }
8195    pub struct Extent2D {
8196        pub width: Option<u32>,
8197        pub height: Option<u32>,
8198    }
8199    impl Default for Extent2D {
8200        fn default() -> Self {
8201            Self { width: None, height: None }
8202        }
8203    }
8204    impl Extent2D {
8205        pub fn new() -> Self {
8206            Self::default()
8207        }
8208        pub(crate) fn to_ffi(&self) -> (ffi::WGPUExtent2D, ChainedStructStorage) {
8209            let mut storage = ChainedStructStorage::new();
8210            let mut raw: ffi::WGPUExtent2D = unsafe { std::mem::zeroed() };
8211            if let Some(value) = self.width {
8212                raw.width = value;
8213            }
8214            if let Some(value) = self.height {
8215                raw.height = value;
8216            }
8217            (raw, storage)
8218        }
8219        pub(crate) fn from_ffi(value: ffi::WGPUExtent2D) -> Self {
8220            Self {
8221                width: Some(value.width),
8222                height: Some(value.height),
8223            }
8224        }
8225    }
8226    pub struct Extent3D {
8227        pub width: Option<u32>,
8228        pub height: Option<u32>,
8229        pub depth_or_array_layers: Option<u32>,
8230    }
8231    impl Default for Extent3D {
8232        fn default() -> Self {
8233            Self {
8234                width: None,
8235                height: Some(1),
8236                depth_or_array_layers: Some(1),
8237            }
8238        }
8239    }
8240    impl Extent3D {
8241        pub fn new() -> Self {
8242            Self::default()
8243        }
8244        pub(crate) fn to_ffi(&self) -> (ffi::WGPUExtent3D, ChainedStructStorage) {
8245            let mut storage = ChainedStructStorage::new();
8246            let mut raw: ffi::WGPUExtent3D = unsafe { std::mem::zeroed() };
8247            if let Some(value) = self.width {
8248                raw.width = value;
8249            }
8250            if let Some(value) = self.height {
8251                raw.height = value;
8252            }
8253            if let Some(value) = self.depth_or_array_layers {
8254                raw.depthOrArrayLayers = value;
8255            }
8256            (raw, storage)
8257        }
8258        pub(crate) fn from_ffi(value: ffi::WGPUExtent3D) -> Self {
8259            Self {
8260                width: Some(value.width),
8261                height: Some(value.height),
8262                depth_or_array_layers: Some(value.depthOrArrayLayers),
8263            }
8264        }
8265    }
8266    pub struct ExternalTextureBindingEntry {
8267        pub external_texture: Option<ExternalTexture>,
8268    }
8269    impl Default for ExternalTextureBindingEntry {
8270        fn default() -> Self {
8271            Self { external_texture: None }
8272        }
8273    }
8274    impl ExternalTextureBindingEntry {
8275        pub fn new() -> Self {
8276            Self::default()
8277        }
8278        pub(crate) fn to_ffi(
8279            &self,
8280        ) -> (ffi::WGPUExternalTextureBindingEntry, ChainedStructStorage) {
8281            let mut storage = ChainedStructStorage::new();
8282            let mut raw: ffi::WGPUExternalTextureBindingEntry = unsafe {
8283                std::mem::zeroed()
8284            };
8285            raw.externalTexture = self
8286                .external_texture
8287                .as_ref()
8288                .map(|v| v.as_raw())
8289                .unwrap_or(std::ptr::null_mut());
8290            (raw, storage)
8291        }
8292        pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureBindingEntry) -> Self {
8293            Self {
8294                external_texture: Some(unsafe {
8295                    ExternalTexture::from_raw(value.externalTexture)
8296                }),
8297            }
8298        }
8299    }
8300    pub struct ExternalTextureBindingLayout {}
8301    impl Default for ExternalTextureBindingLayout {
8302        fn default() -> Self {
8303            Self {}
8304        }
8305    }
8306    impl ExternalTextureBindingLayout {
8307        pub fn new() -> Self {
8308            Self::default()
8309        }
8310        pub(crate) fn to_ffi(
8311            &self,
8312        ) -> (ffi::WGPUExternalTextureBindingLayout, ChainedStructStorage) {
8313            let mut storage = ChainedStructStorage::new();
8314            let mut raw: ffi::WGPUExternalTextureBindingLayout = unsafe {
8315                std::mem::zeroed()
8316            };
8317            (raw, storage)
8318        }
8319        pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureBindingLayout) -> Self {
8320            let _ = value;
8321            Self::default()
8322        }
8323    }
8324    pub struct ExternalTextureDescriptor {
8325        pub(crate) extensions: Vec<ExternalTextureDescriptorExtension>,
8326        pub label: Option<String>,
8327        pub plane_0: Option<TextureView>,
8328        pub plane_1: Option<TextureView>,
8329        pub crop_origin: Option<Origin2D>,
8330        pub crop_size: Option<Extent2D>,
8331        pub apparent_size: Option<Extent2D>,
8332        pub do_yuv_to_rgb_conversion_only: Option<bool>,
8333        pub yuv_to_rgb_conversion_matrix: Option<Vec<f32>>,
8334        pub src_transfer_function_parameters: Option<Vec<f32>>,
8335        pub dst_transfer_function_parameters: Option<Vec<f32>>,
8336        pub gamut_conversion_matrix: Option<Vec<f32>>,
8337        pub mirrored: Option<bool>,
8338        pub rotation: Option<ExternalTextureRotation>,
8339    }
8340    impl Default for ExternalTextureDescriptor {
8341        fn default() -> Self {
8342            Self {
8343                extensions: Vec::new(),
8344                label: None,
8345                plane_0: None,
8346                plane_1: None,
8347                crop_origin: None,
8348                crop_size: None,
8349                apparent_size: None,
8350                do_yuv_to_rgb_conversion_only: None,
8351                yuv_to_rgb_conversion_matrix: None,
8352                src_transfer_function_parameters: None,
8353                dst_transfer_function_parameters: None,
8354                gamut_conversion_matrix: None,
8355                mirrored: None,
8356                rotation: Some(ExternalTextureRotation::Rotate0Degrees),
8357            }
8358        }
8359    }
8360    impl ExternalTextureDescriptor {
8361        pub fn new() -> Self {
8362            Self::default()
8363        }
8364        pub(crate) fn to_ffi(
8365            &self,
8366        ) -> (ffi::WGPUExternalTextureDescriptor, ChainedStructStorage) {
8367            let mut storage = ChainedStructStorage::new();
8368            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8369            for ext in self.extensions.iter().rev() {
8370                next = ext.push_chain(&mut storage, next);
8371            }
8372            let mut raw: ffi::WGPUExternalTextureDescriptor = unsafe {
8373                std::mem::zeroed()
8374            };
8375            raw.nextInChain = next;
8376            if let Some(value) = &self.label {
8377                raw.label = ffi::WGPUStringView {
8378                    data: value.as_ptr().cast(),
8379                    length: value.len(),
8380                };
8381            } else {
8382                raw.label = ffi::WGPUStringView {
8383                    data: std::ptr::null(),
8384                    length: 0,
8385                };
8386            }
8387            raw.plane0 = self
8388                .plane_0
8389                .as_ref()
8390                .map(|v| v.as_raw())
8391                .unwrap_or(std::ptr::null_mut());
8392            raw.plane1 = self
8393                .plane_1
8394                .as_ref()
8395                .map(|v| v.as_raw())
8396                .unwrap_or(std::ptr::null_mut());
8397            if let Some(value) = &self.crop_origin {
8398                let (raw_value, storage_value) = value.to_ffi();
8399                raw.cropOrigin = raw_value;
8400                storage.push_storage(storage_value);
8401            }
8402            if let Some(value) = &self.crop_size {
8403                let (raw_value, storage_value) = value.to_ffi();
8404                raw.cropSize = raw_value;
8405                storage.push_storage(storage_value);
8406            }
8407            if let Some(value) = &self.apparent_size {
8408                let (raw_value, storage_value) = value.to_ffi();
8409                raw.apparentSize = raw_value;
8410                storage.push_storage(storage_value);
8411            }
8412            raw.doYuvToRgbConversionOnly = if self
8413                .do_yuv_to_rgb_conversion_only
8414                .unwrap_or(false)
8415            {
8416                1
8417            } else {
8418                0
8419            };
8420            if let Some(values) = &self.yuv_to_rgb_conversion_matrix {
8421                let len_value = values.len();
8422                let raw_vec = values.to_vec();
8423                let ptr = storage.push_vec(raw_vec);
8424                raw.yuvToRgbConversionMatrix = ptr;
8425            } else {
8426                raw.yuvToRgbConversionMatrix = std::ptr::null();
8427                let _ = 0;
8428            }
8429            if let Some(values) = &self.src_transfer_function_parameters {
8430                let len_value = values.len();
8431                let raw_vec = values.to_vec();
8432                let ptr = storage.push_vec(raw_vec);
8433                raw.srcTransferFunctionParameters = ptr;
8434            } else {
8435                raw.srcTransferFunctionParameters = std::ptr::null();
8436                let _ = 0;
8437            }
8438            if let Some(values) = &self.dst_transfer_function_parameters {
8439                let len_value = values.len();
8440                let raw_vec = values.to_vec();
8441                let ptr = storage.push_vec(raw_vec);
8442                raw.dstTransferFunctionParameters = ptr;
8443            } else {
8444                raw.dstTransferFunctionParameters = std::ptr::null();
8445                let _ = 0;
8446            }
8447            if let Some(values) = &self.gamut_conversion_matrix {
8448                let len_value = values.len();
8449                let raw_vec = values.to_vec();
8450                let ptr = storage.push_vec(raw_vec);
8451                raw.gamutConversionMatrix = ptr;
8452            } else {
8453                raw.gamutConversionMatrix = std::ptr::null();
8454                let _ = 0;
8455            }
8456            raw.mirrored = if self.mirrored.unwrap_or(false) { 1 } else { 0 };
8457            if let Some(value) = self.rotation {
8458                raw.rotation = value.into();
8459            } else {
8460                raw.rotation = 0 as ffi::WGPUExternalTextureRotation;
8461            }
8462            (raw, storage)
8463        }
8464        pub fn with_extension(
8465            mut self,
8466            extension: ExternalTextureDescriptorExtension,
8467        ) -> Self {
8468            self.extensions.push(extension);
8469            self
8470        }
8471        pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureDescriptor) -> Self {
8472            Self {
8473                extensions: Vec::new(),
8474                label: if value.label.data.is_null() || value.label.length == 0 {
8475                    None
8476                } else {
8477                    Some(string_view_to_string(value.label))
8478                },
8479                plane_0: Some(unsafe { TextureView::from_raw(value.plane0) }),
8480                plane_1: if value.plane1.is_null() {
8481                    None
8482                } else {
8483                    Some(unsafe { TextureView::from_raw(value.plane1) })
8484                },
8485                crop_origin: Some(Origin2D::from_ffi(value.cropOrigin)),
8486                crop_size: Some(Extent2D::from_ffi(value.cropSize)),
8487                apparent_size: Some(Extent2D::from_ffi(value.apparentSize)),
8488                do_yuv_to_rgb_conversion_only: Some(value.doYuvToRgbConversionOnly != 0),
8489                yuv_to_rgb_conversion_matrix: if value.yuvToRgbConversionMatrix.is_null()
8490                {
8491                    None
8492                } else {
8493                    Some(
8494                        unsafe {
8495                            std::slice::from_raw_parts(
8496                                value.yuvToRgbConversionMatrix,
8497                                12usize,
8498                            )
8499                        }
8500                            .to_vec(),
8501                    )
8502                },
8503                src_transfer_function_parameters: if value
8504                    .srcTransferFunctionParameters
8505                    .is_null()
8506                {
8507                    None
8508                } else {
8509                    Some(
8510                        unsafe {
8511                            std::slice::from_raw_parts(
8512                                value.srcTransferFunctionParameters,
8513                                7usize,
8514                            )
8515                        }
8516                            .to_vec(),
8517                    )
8518                },
8519                dst_transfer_function_parameters: if value
8520                    .dstTransferFunctionParameters
8521                    .is_null()
8522                {
8523                    None
8524                } else {
8525                    Some(
8526                        unsafe {
8527                            std::slice::from_raw_parts(
8528                                value.dstTransferFunctionParameters,
8529                                7usize,
8530                            )
8531                        }
8532                            .to_vec(),
8533                    )
8534                },
8535                gamut_conversion_matrix: if value.gamutConversionMatrix.is_null() {
8536                    None
8537                } else {
8538                    Some(
8539                        unsafe {
8540                            std::slice::from_raw_parts(
8541                                value.gamutConversionMatrix,
8542                                9usize,
8543                            )
8544                        }
8545                            .to_vec(),
8546                    )
8547                },
8548                mirrored: Some(value.mirrored != 0),
8549                rotation: Some(value.rotation.into()),
8550            }
8551        }
8552    }
8553    pub struct FragmentState {
8554        pub(crate) extensions: Vec<FragmentStateExtension>,
8555        pub module: Option<ShaderModule>,
8556        pub entry_point: Option<String>,
8557        pub constants: Option<Vec<ConstantEntry>>,
8558        pub targets: Option<Vec<ColorTargetState>>,
8559    }
8560    impl Default for FragmentState {
8561        fn default() -> Self {
8562            Self {
8563                extensions: Vec::new(),
8564                module: None,
8565                entry_point: None,
8566                constants: None,
8567                targets: None,
8568            }
8569        }
8570    }
8571    impl FragmentState {
8572        pub fn new() -> Self {
8573            Self::default()
8574        }
8575        pub(crate) fn to_ffi(&self) -> (ffi::WGPUFragmentState, ChainedStructStorage) {
8576            let mut storage = ChainedStructStorage::new();
8577            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8578            for ext in self.extensions.iter().rev() {
8579                next = ext.push_chain(&mut storage, next);
8580            }
8581            let mut raw: ffi::WGPUFragmentState = unsafe { std::mem::zeroed() };
8582            raw.nextInChain = next;
8583            raw.module = self
8584                .module
8585                .as_ref()
8586                .map(|v| v.as_raw())
8587                .unwrap_or(std::ptr::null_mut());
8588            if let Some(value) = &self.entry_point {
8589                raw.entryPoint = ffi::WGPUStringView {
8590                    data: value.as_ptr().cast(),
8591                    length: value.len(),
8592                };
8593            } else {
8594                raw.entryPoint = ffi::WGPUStringView {
8595                    data: std::ptr::null(),
8596                    length: 0,
8597                };
8598            }
8599            raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
8600            if let Some(values) = &self.constants {
8601                let len_value = values.len();
8602                let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
8603                    values.len(),
8604                );
8605                for item in values.iter() {
8606                    let (raw_item, storage_item) = item.to_ffi();
8607                    raw_vec.push(raw_item);
8608                    storage.push_storage(storage_item);
8609                }
8610                let ptr = storage.push_vec(raw_vec);
8611                raw.constants = ptr;
8612                raw.constantCount = len_value;
8613            } else {
8614                raw.constants = std::ptr::null();
8615                raw.constantCount = 0;
8616            }
8617            raw.targetCount = self.targets.as_ref().map(|v| v.len()).unwrap_or(0);
8618            if let Some(values) = &self.targets {
8619                let len_value = values.len();
8620                let mut raw_vec: Vec<ffi::WGPUColorTargetState> = Vec::with_capacity(
8621                    values.len(),
8622                );
8623                for item in values.iter() {
8624                    let (raw_item, storage_item) = item.to_ffi();
8625                    raw_vec.push(raw_item);
8626                    storage.push_storage(storage_item);
8627                }
8628                let ptr = storage.push_vec(raw_vec);
8629                raw.targets = ptr;
8630                raw.targetCount = len_value;
8631            } else {
8632                raw.targets = std::ptr::null();
8633                raw.targetCount = 0;
8634            }
8635            (raw, storage)
8636        }
8637        pub fn with_extension(mut self, extension: FragmentStateExtension) -> Self {
8638            self.extensions.push(extension);
8639            self
8640        }
8641        pub(crate) fn from_ffi(value: ffi::WGPUFragmentState) -> Self {
8642            Self {
8643                extensions: Vec::new(),
8644                module: Some(unsafe { ShaderModule::from_raw(value.module) }),
8645                entry_point: if value.entryPoint.data.is_null()
8646                    || value.entryPoint.length == 0
8647                {
8648                    None
8649                } else {
8650                    Some(string_view_to_string(value.entryPoint))
8651                },
8652                constants: if value.constants.is_null() {
8653                    None
8654                } else {
8655                    Some(
8656                        unsafe {
8657                            std::slice::from_raw_parts(
8658                                value.constants,
8659                                value.constantCount as usize,
8660                            )
8661                        }
8662                            .iter()
8663                            .map(|raw| ConstantEntry::from_ffi(*raw))
8664                            .collect(),
8665                    )
8666                },
8667                targets: if value.targets.is_null() {
8668                    None
8669                } else {
8670                    Some(
8671                        unsafe {
8672                            std::slice::from_raw_parts(
8673                                value.targets,
8674                                value.targetCount as usize,
8675                            )
8676                        }
8677                            .iter()
8678                            .map(|raw| ColorTargetState::from_ffi(*raw))
8679                            .collect(),
8680                    )
8681                },
8682            }
8683        }
8684    }
8685    pub struct Future {
8686        pub id: Option<u64>,
8687    }
8688    impl Default for Future {
8689        fn default() -> Self {
8690            Self { id: None }
8691        }
8692    }
8693    impl Future {
8694        pub fn new() -> Self {
8695            Self::default()
8696        }
8697        pub(crate) fn to_ffi(&self) -> (ffi::WGPUFuture, ChainedStructStorage) {
8698            let mut storage = ChainedStructStorage::new();
8699            let mut raw: ffi::WGPUFuture = unsafe { std::mem::zeroed() };
8700            if let Some(value) = self.id {
8701                raw.id = value;
8702            }
8703            (raw, storage)
8704        }
8705        pub(crate) fn from_ffi(value: ffi::WGPUFuture) -> Self {
8706            Self { id: Some(value.id) }
8707        }
8708    }
8709    pub struct FutureWaitInfo {
8710        pub future: Option<Future>,
8711        pub completed: Option<bool>,
8712    }
8713    impl Default for FutureWaitInfo {
8714        fn default() -> Self {
8715            Self {
8716                future: None,
8717                completed: None,
8718            }
8719        }
8720    }
8721    impl FutureWaitInfo {
8722        pub fn new() -> Self {
8723            Self::default()
8724        }
8725        pub(crate) fn to_ffi(&self) -> (ffi::WGPUFutureWaitInfo, ChainedStructStorage) {
8726            let mut storage = ChainedStructStorage::new();
8727            let mut raw: ffi::WGPUFutureWaitInfo = unsafe { std::mem::zeroed() };
8728            if let Some(value) = &self.future {
8729                let (raw_value, storage_value) = value.to_ffi();
8730                raw.future = raw_value;
8731                storage.push_storage(storage_value);
8732            }
8733            raw.completed = if self.completed.unwrap_or(false) { 1 } else { 0 };
8734            (raw, storage)
8735        }
8736        pub(crate) fn from_ffi(value: ffi::WGPUFutureWaitInfo) -> Self {
8737            Self {
8738                future: Some(Future::from_ffi(value.future)),
8739                completed: Some(value.completed != 0),
8740            }
8741        }
8742    }
8743    pub struct ImageCopyExternalTexture {
8744        pub(crate) extensions: Vec<ImageCopyExternalTextureExtension>,
8745        pub external_texture: Option<ExternalTexture>,
8746        pub origin: Option<Origin3D>,
8747        pub natural_size: Option<Extent2D>,
8748    }
8749    impl Default for ImageCopyExternalTexture {
8750        fn default() -> Self {
8751            Self {
8752                extensions: Vec::new(),
8753                external_texture: None,
8754                origin: None,
8755                natural_size: None,
8756            }
8757        }
8758    }
8759    impl ImageCopyExternalTexture {
8760        pub fn new() -> Self {
8761            Self::default()
8762        }
8763        pub(crate) fn to_ffi(
8764            &self,
8765        ) -> (ffi::WGPUImageCopyExternalTexture, ChainedStructStorage) {
8766            let mut storage = ChainedStructStorage::new();
8767            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8768            for ext in self.extensions.iter().rev() {
8769                next = ext.push_chain(&mut storage, next);
8770            }
8771            let mut raw: ffi::WGPUImageCopyExternalTexture = unsafe {
8772                std::mem::zeroed()
8773            };
8774            raw.nextInChain = next;
8775            raw.externalTexture = self
8776                .external_texture
8777                .as_ref()
8778                .map(|v| v.as_raw())
8779                .unwrap_or(std::ptr::null_mut());
8780            if let Some(value) = &self.origin {
8781                let (raw_value, storage_value) = value.to_ffi();
8782                raw.origin = raw_value;
8783                storage.push_storage(storage_value);
8784            }
8785            if let Some(value) = &self.natural_size {
8786                let (raw_value, storage_value) = value.to_ffi();
8787                raw.naturalSize = raw_value;
8788                storage.push_storage(storage_value);
8789            }
8790            (raw, storage)
8791        }
8792        pub fn with_extension(
8793            mut self,
8794            extension: ImageCopyExternalTextureExtension,
8795        ) -> Self {
8796            self.extensions.push(extension);
8797            self
8798        }
8799        pub(crate) fn from_ffi(value: ffi::WGPUImageCopyExternalTexture) -> Self {
8800            Self {
8801                extensions: Vec::new(),
8802                external_texture: Some(unsafe {
8803                    ExternalTexture::from_raw(value.externalTexture)
8804                }),
8805                origin: Some(Origin3D::from_ffi(value.origin)),
8806                natural_size: Some(Extent2D::from_ffi(value.naturalSize)),
8807            }
8808        }
8809    }
8810    pub struct InstanceDescriptor {
8811        pub(crate) extensions: Vec<InstanceDescriptorExtension>,
8812        pub required_features: Option<Vec<InstanceFeatureName>>,
8813        pub required_limits: Option<InstanceLimits>,
8814    }
8815    impl Default for InstanceDescriptor {
8816        fn default() -> Self {
8817            Self {
8818                extensions: Vec::new(),
8819                required_features: None,
8820                required_limits: None,
8821            }
8822        }
8823    }
8824    impl InstanceDescriptor {
8825        pub fn new() -> Self {
8826            Self::default()
8827        }
8828        pub(crate) fn to_ffi(
8829            &self,
8830        ) -> (ffi::WGPUInstanceDescriptor, ChainedStructStorage) {
8831            let mut storage = ChainedStructStorage::new();
8832            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8833            for ext in self.extensions.iter().rev() {
8834                next = ext.push_chain(&mut storage, next);
8835            }
8836            let mut raw: ffi::WGPUInstanceDescriptor = unsafe { std::mem::zeroed() };
8837            raw.nextInChain = next;
8838            raw.requiredFeatureCount = self
8839                .required_features
8840                .as_ref()
8841                .map(|v| v.len())
8842                .unwrap_or(0);
8843            if let Some(values) = &self.required_features {
8844                let len_value = values.len();
8845                let raw_vec: Vec<ffi::WGPUInstanceFeatureName> = values
8846                    .iter()
8847                    .map(|v| (*v).into())
8848                    .collect();
8849                let ptr = storage.push_vec(raw_vec);
8850                raw.requiredFeatures = ptr;
8851                raw.requiredFeatureCount = len_value;
8852            } else {
8853                raw.requiredFeatures = std::ptr::null();
8854                raw.requiredFeatureCount = 0;
8855            }
8856            if let Some(value) = &self.required_limits {
8857                let (raw_value, storage_value) = value.to_ffi();
8858                let ptr = storage.push_value(raw_value);
8859                raw.requiredLimits = ptr;
8860                storage.push_storage(storage_value);
8861            } else {
8862                raw.requiredLimits = std::ptr::null();
8863            }
8864            (raw, storage)
8865        }
8866        pub fn with_extension(mut self, extension: InstanceDescriptorExtension) -> Self {
8867            self.extensions.push(extension);
8868            self
8869        }
8870        pub(crate) fn from_ffi(value: ffi::WGPUInstanceDescriptor) -> Self {
8871            Self {
8872                extensions: Vec::new(),
8873                required_features: if value.requiredFeatures.is_null() {
8874                    None
8875                } else {
8876                    Some(
8877                        unsafe {
8878                            std::slice::from_raw_parts(
8879                                value.requiredFeatures,
8880                                value.requiredFeatureCount as usize,
8881                            )
8882                        }
8883                            .iter()
8884                            .map(|raw| InstanceFeatureName::from(*raw))
8885                            .collect(),
8886                    )
8887                },
8888                required_limits: if value.requiredLimits.is_null() {
8889                    None
8890                } else {
8891                    Some(InstanceLimits::from_ffi(unsafe { *value.requiredLimits }))
8892                },
8893            }
8894        }
8895    }
8896    pub struct InstanceLimits {
8897        pub(crate) extensions: Vec<InstanceLimitsExtension>,
8898        pub timed_wait_any_max_count: Option<usize>,
8899    }
8900    impl Default for InstanceLimits {
8901        fn default() -> Self {
8902            Self {
8903                extensions: Vec::new(),
8904                timed_wait_any_max_count: Some(0),
8905            }
8906        }
8907    }
8908    impl InstanceLimits {
8909        pub fn new() -> Self {
8910            Self::default()
8911        }
8912        pub(crate) fn to_ffi(&self) -> (ffi::WGPUInstanceLimits, ChainedStructStorage) {
8913            let mut storage = ChainedStructStorage::new();
8914            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8915            for ext in self.extensions.iter().rev() {
8916                next = ext.push_chain(&mut storage, next);
8917            }
8918            let mut raw: ffi::WGPUInstanceLimits = unsafe { std::mem::zeroed() };
8919            raw.nextInChain = next;
8920            if let Some(value) = self.timed_wait_any_max_count {
8921                raw.timedWaitAnyMaxCount = value;
8922            }
8923            (raw, storage)
8924        }
8925        pub fn with_extension(mut self, extension: InstanceLimitsExtension) -> Self {
8926            self.extensions.push(extension);
8927            self
8928        }
8929        pub(crate) fn from_ffi(value: ffi::WGPUInstanceLimits) -> Self {
8930            Self {
8931                extensions: Vec::new(),
8932                timed_wait_any_max_count: Some(value.timedWaitAnyMaxCount),
8933            }
8934        }
8935    }
8936    pub struct Limits {
8937        pub(crate) extensions: Vec<LimitsExtension>,
8938        pub max_texture_dimension_1d: Option<u32>,
8939        pub max_texture_dimension_2d: Option<u32>,
8940        pub max_texture_dimension_3d: Option<u32>,
8941        pub max_texture_array_layers: Option<u32>,
8942        pub max_bind_groups: Option<u32>,
8943        pub max_bind_groups_plus_vertex_buffers: Option<u32>,
8944        pub max_bindings_per_bind_group: Option<u32>,
8945        pub max_dynamic_uniform_buffers_per_pipeline_layout: Option<u32>,
8946        pub max_dynamic_storage_buffers_per_pipeline_layout: Option<u32>,
8947        pub max_sampled_textures_per_shader_stage: Option<u32>,
8948        pub max_samplers_per_shader_stage: Option<u32>,
8949        pub max_storage_buffers_per_shader_stage: Option<u32>,
8950        pub max_storage_textures_per_shader_stage: Option<u32>,
8951        pub max_uniform_buffers_per_shader_stage: Option<u32>,
8952        pub max_uniform_buffer_binding_size: Option<u64>,
8953        pub max_storage_buffer_binding_size: Option<u64>,
8954        pub min_uniform_buffer_offset_alignment: Option<u32>,
8955        pub min_storage_buffer_offset_alignment: Option<u32>,
8956        pub max_vertex_buffers: Option<u32>,
8957        pub max_buffer_size: Option<u64>,
8958        pub max_vertex_attributes: Option<u32>,
8959        pub max_vertex_buffer_array_stride: Option<u32>,
8960        pub max_inter_stage_shader_variables: Option<u32>,
8961        pub max_color_attachments: Option<u32>,
8962        pub max_color_attachment_bytes_per_sample: Option<u32>,
8963        pub max_compute_workgroup_storage_size: Option<u32>,
8964        pub max_compute_invocations_per_workgroup: Option<u32>,
8965        pub max_compute_workgroup_size_x: Option<u32>,
8966        pub max_compute_workgroup_size_y: Option<u32>,
8967        pub max_compute_workgroup_size_z: Option<u32>,
8968        pub max_compute_workgroups_per_dimension: Option<u32>,
8969        pub max_immediate_size: Option<u32>,
8970    }
8971    impl Default for Limits {
8972        fn default() -> Self {
8973            Self {
8974                extensions: Vec::new(),
8975                max_texture_dimension_1d: Some(LIMIT_U32_UNDEFINED),
8976                max_texture_dimension_2d: Some(LIMIT_U32_UNDEFINED),
8977                max_texture_dimension_3d: Some(LIMIT_U32_UNDEFINED),
8978                max_texture_array_layers: Some(LIMIT_U32_UNDEFINED),
8979                max_bind_groups: Some(LIMIT_U32_UNDEFINED),
8980                max_bind_groups_plus_vertex_buffers: Some(LIMIT_U32_UNDEFINED),
8981                max_bindings_per_bind_group: Some(LIMIT_U32_UNDEFINED),
8982                max_dynamic_uniform_buffers_per_pipeline_layout: Some(
8983                    LIMIT_U32_UNDEFINED,
8984                ),
8985                max_dynamic_storage_buffers_per_pipeline_layout: Some(
8986                    LIMIT_U32_UNDEFINED,
8987                ),
8988                max_sampled_textures_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8989                max_samplers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8990                max_storage_buffers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8991                max_storage_textures_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8992                max_uniform_buffers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8993                max_uniform_buffer_binding_size: Some(LIMIT_U64_UNDEFINED),
8994                max_storage_buffer_binding_size: Some(LIMIT_U64_UNDEFINED),
8995                min_uniform_buffer_offset_alignment: Some(LIMIT_U32_UNDEFINED),
8996                min_storage_buffer_offset_alignment: Some(LIMIT_U32_UNDEFINED),
8997                max_vertex_buffers: Some(LIMIT_U32_UNDEFINED),
8998                max_buffer_size: Some(LIMIT_U64_UNDEFINED),
8999                max_vertex_attributes: Some(LIMIT_U32_UNDEFINED),
9000                max_vertex_buffer_array_stride: Some(LIMIT_U32_UNDEFINED),
9001                max_inter_stage_shader_variables: Some(LIMIT_U32_UNDEFINED),
9002                max_color_attachments: Some(LIMIT_U32_UNDEFINED),
9003                max_color_attachment_bytes_per_sample: Some(LIMIT_U32_UNDEFINED),
9004                max_compute_workgroup_storage_size: Some(LIMIT_U32_UNDEFINED),
9005                max_compute_invocations_per_workgroup: Some(LIMIT_U32_UNDEFINED),
9006                max_compute_workgroup_size_x: Some(LIMIT_U32_UNDEFINED),
9007                max_compute_workgroup_size_y: Some(LIMIT_U32_UNDEFINED),
9008                max_compute_workgroup_size_z: Some(LIMIT_U32_UNDEFINED),
9009                max_compute_workgroups_per_dimension: Some(LIMIT_U32_UNDEFINED),
9010                max_immediate_size: Some(LIMIT_U32_UNDEFINED),
9011            }
9012        }
9013    }
9014    impl Limits {
9015        pub fn new() -> Self {
9016            Self::default()
9017        }
9018        pub(crate) fn to_ffi(&self) -> (ffi::WGPULimits, ChainedStructStorage) {
9019            let mut storage = ChainedStructStorage::new();
9020            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9021            for ext in self.extensions.iter().rev() {
9022                next = ext.push_chain(&mut storage, next);
9023            }
9024            let mut raw: ffi::WGPULimits = unsafe { std::mem::zeroed() };
9025            raw.nextInChain = next;
9026            if let Some(value) = self.max_texture_dimension_1d {
9027                raw.maxTextureDimension1D = value;
9028            }
9029            if let Some(value) = self.max_texture_dimension_2d {
9030                raw.maxTextureDimension2D = value;
9031            }
9032            if let Some(value) = self.max_texture_dimension_3d {
9033                raw.maxTextureDimension3D = value;
9034            }
9035            if let Some(value) = self.max_texture_array_layers {
9036                raw.maxTextureArrayLayers = value;
9037            }
9038            if let Some(value) = self.max_bind_groups {
9039                raw.maxBindGroups = value;
9040            }
9041            if let Some(value) = self.max_bind_groups_plus_vertex_buffers {
9042                raw.maxBindGroupsPlusVertexBuffers = value;
9043            }
9044            if let Some(value) = self.max_bindings_per_bind_group {
9045                raw.maxBindingsPerBindGroup = value;
9046            }
9047            if let Some(value) = self.max_dynamic_uniform_buffers_per_pipeline_layout {
9048                raw.maxDynamicUniformBuffersPerPipelineLayout = value;
9049            }
9050            if let Some(value) = self.max_dynamic_storage_buffers_per_pipeline_layout {
9051                raw.maxDynamicStorageBuffersPerPipelineLayout = value;
9052            }
9053            if let Some(value) = self.max_sampled_textures_per_shader_stage {
9054                raw.maxSampledTexturesPerShaderStage = value;
9055            }
9056            if let Some(value) = self.max_samplers_per_shader_stage {
9057                raw.maxSamplersPerShaderStage = value;
9058            }
9059            if let Some(value) = self.max_storage_buffers_per_shader_stage {
9060                raw.maxStorageBuffersPerShaderStage = value;
9061            }
9062            if let Some(value) = self.max_storage_textures_per_shader_stage {
9063                raw.maxStorageTexturesPerShaderStage = value;
9064            }
9065            if let Some(value) = self.max_uniform_buffers_per_shader_stage {
9066                raw.maxUniformBuffersPerShaderStage = value;
9067            }
9068            if let Some(value) = self.max_uniform_buffer_binding_size {
9069                raw.maxUniformBufferBindingSize = value;
9070            }
9071            if let Some(value) = self.max_storage_buffer_binding_size {
9072                raw.maxStorageBufferBindingSize = value;
9073            }
9074            if let Some(value) = self.min_uniform_buffer_offset_alignment {
9075                raw.minUniformBufferOffsetAlignment = value;
9076            }
9077            if let Some(value) = self.min_storage_buffer_offset_alignment {
9078                raw.minStorageBufferOffsetAlignment = value;
9079            }
9080            if let Some(value) = self.max_vertex_buffers {
9081                raw.maxVertexBuffers = value;
9082            }
9083            if let Some(value) = self.max_buffer_size {
9084                raw.maxBufferSize = value;
9085            }
9086            if let Some(value) = self.max_vertex_attributes {
9087                raw.maxVertexAttributes = value;
9088            }
9089            if let Some(value) = self.max_vertex_buffer_array_stride {
9090                raw.maxVertexBufferArrayStride = value;
9091            }
9092            if let Some(value) = self.max_inter_stage_shader_variables {
9093                raw.maxInterStageShaderVariables = value;
9094            }
9095            if let Some(value) = self.max_color_attachments {
9096                raw.maxColorAttachments = value;
9097            }
9098            if let Some(value) = self.max_color_attachment_bytes_per_sample {
9099                raw.maxColorAttachmentBytesPerSample = value;
9100            }
9101            if let Some(value) = self.max_compute_workgroup_storage_size {
9102                raw.maxComputeWorkgroupStorageSize = value;
9103            }
9104            if let Some(value) = self.max_compute_invocations_per_workgroup {
9105                raw.maxComputeInvocationsPerWorkgroup = value;
9106            }
9107            if let Some(value) = self.max_compute_workgroup_size_x {
9108                raw.maxComputeWorkgroupSizeX = value;
9109            }
9110            if let Some(value) = self.max_compute_workgroup_size_y {
9111                raw.maxComputeWorkgroupSizeY = value;
9112            }
9113            if let Some(value) = self.max_compute_workgroup_size_z {
9114                raw.maxComputeWorkgroupSizeZ = value;
9115            }
9116            if let Some(value) = self.max_compute_workgroups_per_dimension {
9117                raw.maxComputeWorkgroupsPerDimension = value;
9118            }
9119            if let Some(value) = self.max_immediate_size {
9120                raw.maxImmediateSize = value;
9121            }
9122            (raw, storage)
9123        }
9124        pub fn with_extension(mut self, extension: LimitsExtension) -> Self {
9125            self.extensions.push(extension);
9126            self
9127        }
9128        pub(crate) fn from_ffi(value: ffi::WGPULimits) -> Self {
9129            Self {
9130                extensions: Vec::new(),
9131                max_texture_dimension_1d: Some(value.maxTextureDimension1D),
9132                max_texture_dimension_2d: Some(value.maxTextureDimension2D),
9133                max_texture_dimension_3d: Some(value.maxTextureDimension3D),
9134                max_texture_array_layers: Some(value.maxTextureArrayLayers),
9135                max_bind_groups: Some(value.maxBindGroups),
9136                max_bind_groups_plus_vertex_buffers: Some(
9137                    value.maxBindGroupsPlusVertexBuffers,
9138                ),
9139                max_bindings_per_bind_group: Some(value.maxBindingsPerBindGroup),
9140                max_dynamic_uniform_buffers_per_pipeline_layout: Some(
9141                    value.maxDynamicUniformBuffersPerPipelineLayout,
9142                ),
9143                max_dynamic_storage_buffers_per_pipeline_layout: Some(
9144                    value.maxDynamicStorageBuffersPerPipelineLayout,
9145                ),
9146                max_sampled_textures_per_shader_stage: Some(
9147                    value.maxSampledTexturesPerShaderStage,
9148                ),
9149                max_samplers_per_shader_stage: Some(value.maxSamplersPerShaderStage),
9150                max_storage_buffers_per_shader_stage: Some(
9151                    value.maxStorageBuffersPerShaderStage,
9152                ),
9153                max_storage_textures_per_shader_stage: Some(
9154                    value.maxStorageTexturesPerShaderStage,
9155                ),
9156                max_uniform_buffers_per_shader_stage: Some(
9157                    value.maxUniformBuffersPerShaderStage,
9158                ),
9159                max_uniform_buffer_binding_size: Some(value.maxUniformBufferBindingSize),
9160                max_storage_buffer_binding_size: Some(value.maxStorageBufferBindingSize),
9161                min_uniform_buffer_offset_alignment: Some(
9162                    value.minUniformBufferOffsetAlignment,
9163                ),
9164                min_storage_buffer_offset_alignment: Some(
9165                    value.minStorageBufferOffsetAlignment,
9166                ),
9167                max_vertex_buffers: Some(value.maxVertexBuffers),
9168                max_buffer_size: Some(value.maxBufferSize),
9169                max_vertex_attributes: Some(value.maxVertexAttributes),
9170                max_vertex_buffer_array_stride: Some(value.maxVertexBufferArrayStride),
9171                max_inter_stage_shader_variables: Some(
9172                    value.maxInterStageShaderVariables,
9173                ),
9174                max_color_attachments: Some(value.maxColorAttachments),
9175                max_color_attachment_bytes_per_sample: Some(
9176                    value.maxColorAttachmentBytesPerSample,
9177                ),
9178                max_compute_workgroup_storage_size: Some(
9179                    value.maxComputeWorkgroupStorageSize,
9180                ),
9181                max_compute_invocations_per_workgroup: Some(
9182                    value.maxComputeInvocationsPerWorkgroup,
9183                ),
9184                max_compute_workgroup_size_x: Some(value.maxComputeWorkgroupSizeX),
9185                max_compute_workgroup_size_y: Some(value.maxComputeWorkgroupSizeY),
9186                max_compute_workgroup_size_z: Some(value.maxComputeWorkgroupSizeZ),
9187                max_compute_workgroups_per_dimension: Some(
9188                    value.maxComputeWorkgroupsPerDimension,
9189                ),
9190                max_immediate_size: Some(value.maxImmediateSize),
9191            }
9192        }
9193    }
9194    pub struct MemoryHeapInfo {
9195        pub properties: Option<HeapProperty>,
9196        pub size: Option<u64>,
9197    }
9198    impl Default for MemoryHeapInfo {
9199        fn default() -> Self {
9200            Self {
9201                properties: None,
9202                size: None,
9203            }
9204        }
9205    }
9206    impl MemoryHeapInfo {
9207        pub fn new() -> Self {
9208            Self::default()
9209        }
9210        pub(crate) fn to_ffi(&self) -> (ffi::WGPUMemoryHeapInfo, ChainedStructStorage) {
9211            let mut storage = ChainedStructStorage::new();
9212            let mut raw: ffi::WGPUMemoryHeapInfo = unsafe { std::mem::zeroed() };
9213            if let Some(value) = self.properties {
9214                raw.properties = value.into();
9215            } else {
9216                raw.properties = 0 as ffi::WGPUHeapProperty;
9217            }
9218            if let Some(value) = self.size {
9219                raw.size = value;
9220            }
9221            (raw, storage)
9222        }
9223        pub(crate) fn from_ffi(value: ffi::WGPUMemoryHeapInfo) -> Self {
9224            Self {
9225                properties: Some(value.properties.into()),
9226                size: Some(value.size),
9227            }
9228        }
9229    }
9230    pub struct MultisampleState {
9231        pub(crate) extensions: Vec<MultisampleStateExtension>,
9232        pub count: Option<u32>,
9233        pub mask: Option<u32>,
9234        pub alpha_to_coverage_enabled: Option<bool>,
9235    }
9236    impl Default for MultisampleState {
9237        fn default() -> Self {
9238            Self {
9239                extensions: Vec::new(),
9240                count: Some(1),
9241                mask: Some(4294967295),
9242                alpha_to_coverage_enabled: None,
9243            }
9244        }
9245    }
9246    impl MultisampleState {
9247        pub fn new() -> Self {
9248            Self::default()
9249        }
9250        pub(crate) fn to_ffi(
9251            &self,
9252        ) -> (ffi::WGPUMultisampleState, ChainedStructStorage) {
9253            let mut storage = ChainedStructStorage::new();
9254            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9255            for ext in self.extensions.iter().rev() {
9256                next = ext.push_chain(&mut storage, next);
9257            }
9258            let mut raw: ffi::WGPUMultisampleState = unsafe { std::mem::zeroed() };
9259            raw.nextInChain = next;
9260            if let Some(value) = self.count {
9261                raw.count = value;
9262            }
9263            if let Some(value) = self.mask {
9264                raw.mask = value;
9265            }
9266            raw.alphaToCoverageEnabled = if self
9267                .alpha_to_coverage_enabled
9268                .unwrap_or(false)
9269            {
9270                1
9271            } else {
9272                0
9273            };
9274            (raw, storage)
9275        }
9276        pub fn with_extension(mut self, extension: MultisampleStateExtension) -> Self {
9277            self.extensions.push(extension);
9278            self
9279        }
9280        pub(crate) fn from_ffi(value: ffi::WGPUMultisampleState) -> Self {
9281            Self {
9282                extensions: Vec::new(),
9283                count: Some(value.count),
9284                mask: Some(value.mask),
9285                alpha_to_coverage_enabled: Some(value.alphaToCoverageEnabled != 0),
9286            }
9287        }
9288    }
9289    pub struct Origin2D {
9290        pub x: Option<u32>,
9291        pub y: Option<u32>,
9292    }
9293    impl Default for Origin2D {
9294        fn default() -> Self {
9295            Self { x: Some(0), y: Some(0) }
9296        }
9297    }
9298    impl Origin2D {
9299        pub fn new() -> Self {
9300            Self::default()
9301        }
9302        pub(crate) fn to_ffi(&self) -> (ffi::WGPUOrigin2D, ChainedStructStorage) {
9303            let mut storage = ChainedStructStorage::new();
9304            let mut raw: ffi::WGPUOrigin2D = unsafe { std::mem::zeroed() };
9305            if let Some(value) = self.x {
9306                raw.x = value;
9307            }
9308            if let Some(value) = self.y {
9309                raw.y = value;
9310            }
9311            (raw, storage)
9312        }
9313        pub(crate) fn from_ffi(value: ffi::WGPUOrigin2D) -> Self {
9314            Self {
9315                x: Some(value.x),
9316                y: Some(value.y),
9317            }
9318        }
9319    }
9320    pub struct Origin3D {
9321        pub x: Option<u32>,
9322        pub y: Option<u32>,
9323        pub z: Option<u32>,
9324    }
9325    impl Default for Origin3D {
9326        fn default() -> Self {
9327            Self {
9328                x: Some(0),
9329                y: Some(0),
9330                z: Some(0),
9331            }
9332        }
9333    }
9334    impl Origin3D {
9335        pub fn new() -> Self {
9336            Self::default()
9337        }
9338        pub(crate) fn to_ffi(&self) -> (ffi::WGPUOrigin3D, ChainedStructStorage) {
9339            let mut storage = ChainedStructStorage::new();
9340            let mut raw: ffi::WGPUOrigin3D = unsafe { std::mem::zeroed() };
9341            if let Some(value) = self.x {
9342                raw.x = value;
9343            }
9344            if let Some(value) = self.y {
9345                raw.y = value;
9346            }
9347            if let Some(value) = self.z {
9348                raw.z = value;
9349            }
9350            (raw, storage)
9351        }
9352        pub(crate) fn from_ffi(value: ffi::WGPUOrigin3D) -> Self {
9353            Self {
9354                x: Some(value.x),
9355                y: Some(value.y),
9356                z: Some(value.z),
9357            }
9358        }
9359    }
9360    pub struct PassTimestampWrites {
9361        pub(crate) extensions: Vec<PassTimestampWritesExtension>,
9362        pub query_set: Option<QuerySet>,
9363        pub beginning_of_pass_write_index: Option<u32>,
9364        pub end_of_pass_write_index: Option<u32>,
9365    }
9366    impl Default for PassTimestampWrites {
9367        fn default() -> Self {
9368            Self {
9369                extensions: Vec::new(),
9370                query_set: None,
9371                beginning_of_pass_write_index: Some(QUERY_SET_INDEX_UNDEFINED),
9372                end_of_pass_write_index: Some(QUERY_SET_INDEX_UNDEFINED),
9373            }
9374        }
9375    }
9376    impl PassTimestampWrites {
9377        pub fn new() -> Self {
9378            Self::default()
9379        }
9380        pub(crate) fn to_ffi(
9381            &self,
9382        ) -> (ffi::WGPUPassTimestampWrites, ChainedStructStorage) {
9383            let mut storage = ChainedStructStorage::new();
9384            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9385            for ext in self.extensions.iter().rev() {
9386                next = ext.push_chain(&mut storage, next);
9387            }
9388            let mut raw: ffi::WGPUPassTimestampWrites = unsafe { std::mem::zeroed() };
9389            raw.nextInChain = next;
9390            raw.querySet = self
9391                .query_set
9392                .as_ref()
9393                .map(|v| v.as_raw())
9394                .unwrap_or(std::ptr::null_mut());
9395            if let Some(value) = self.beginning_of_pass_write_index {
9396                raw.beginningOfPassWriteIndex = value;
9397            }
9398            if let Some(value) = self.end_of_pass_write_index {
9399                raw.endOfPassWriteIndex = value;
9400            }
9401            (raw, storage)
9402        }
9403        pub fn with_extension(
9404            mut self,
9405            extension: PassTimestampWritesExtension,
9406        ) -> Self {
9407            self.extensions.push(extension);
9408            self
9409        }
9410        pub(crate) fn from_ffi(value: ffi::WGPUPassTimestampWrites) -> Self {
9411            Self {
9412                extensions: Vec::new(),
9413                query_set: Some(unsafe { QuerySet::from_raw(value.querySet) }),
9414                beginning_of_pass_write_index: Some(value.beginningOfPassWriteIndex),
9415                end_of_pass_write_index: Some(value.endOfPassWriteIndex),
9416            }
9417        }
9418    }
9419    pub struct PipelineLayoutDescriptor {
9420        pub(crate) extensions: Vec<PipelineLayoutDescriptorExtension>,
9421        pub label: Option<String>,
9422        pub bind_group_layouts: Option<Vec<BindGroupLayout>>,
9423        pub immediate_size: Option<u32>,
9424    }
9425    impl Default for PipelineLayoutDescriptor {
9426        fn default() -> Self {
9427            Self {
9428                extensions: Vec::new(),
9429                label: None,
9430                bind_group_layouts: None,
9431                immediate_size: Some(0),
9432            }
9433        }
9434    }
9435    impl PipelineLayoutDescriptor {
9436        pub fn new() -> Self {
9437            Self::default()
9438        }
9439        pub(crate) fn to_ffi(
9440            &self,
9441        ) -> (ffi::WGPUPipelineLayoutDescriptor, ChainedStructStorage) {
9442            let mut storage = ChainedStructStorage::new();
9443            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9444            for ext in self.extensions.iter().rev() {
9445                next = ext.push_chain(&mut storage, next);
9446            }
9447            let mut raw: ffi::WGPUPipelineLayoutDescriptor = unsafe {
9448                std::mem::zeroed()
9449            };
9450            raw.nextInChain = next;
9451            if let Some(value) = &self.label {
9452                raw.label = ffi::WGPUStringView {
9453                    data: value.as_ptr().cast(),
9454                    length: value.len(),
9455                };
9456            } else {
9457                raw.label = ffi::WGPUStringView {
9458                    data: std::ptr::null(),
9459                    length: 0,
9460                };
9461            }
9462            raw.bindGroupLayoutCount = self
9463                .bind_group_layouts
9464                .as_ref()
9465                .map(|v| v.len())
9466                .unwrap_or(0);
9467            if let Some(values) = &self.bind_group_layouts {
9468                let len_value = values.len();
9469                let raw_vec: Vec<ffi::WGPUBindGroupLayout> = values
9470                    .iter()
9471                    .map(|v| v.as_raw())
9472                    .collect();
9473                let ptr = storage.push_vec(raw_vec);
9474                raw.bindGroupLayouts = ptr;
9475                raw.bindGroupLayoutCount = len_value;
9476            } else {
9477                raw.bindGroupLayouts = std::ptr::null();
9478                raw.bindGroupLayoutCount = 0;
9479            }
9480            if let Some(value) = self.immediate_size {
9481                raw.immediateSize = value;
9482            }
9483            (raw, storage)
9484        }
9485        pub fn with_extension(
9486            mut self,
9487            extension: PipelineLayoutDescriptorExtension,
9488        ) -> Self {
9489            self.extensions.push(extension);
9490            self
9491        }
9492        pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutDescriptor) -> Self {
9493            Self {
9494                extensions: Vec::new(),
9495                label: if value.label.data.is_null() || value.label.length == 0 {
9496                    None
9497                } else {
9498                    Some(string_view_to_string(value.label))
9499                },
9500                bind_group_layouts: if value.bindGroupLayouts.is_null() {
9501                    None
9502                } else {
9503                    Some(
9504                        unsafe {
9505                            std::slice::from_raw_parts(
9506                                value.bindGroupLayouts,
9507                                value.bindGroupLayoutCount as usize,
9508                            )
9509                        }
9510                            .iter()
9511                            .map(|raw| unsafe { BindGroupLayout::from_raw(*raw) })
9512                            .collect(),
9513                    )
9514                },
9515                immediate_size: Some(value.immediateSize),
9516            }
9517        }
9518    }
9519    pub struct PipelineLayoutPixelLocalStorage {
9520        pub total_pixel_local_storage_size: Option<u64>,
9521        pub storage_attachments: Option<Vec<PipelineLayoutStorageAttachment>>,
9522    }
9523    impl Default for PipelineLayoutPixelLocalStorage {
9524        fn default() -> Self {
9525            Self {
9526                total_pixel_local_storage_size: None,
9527                storage_attachments: None,
9528            }
9529        }
9530    }
9531    impl PipelineLayoutPixelLocalStorage {
9532        pub fn new() -> Self {
9533            Self::default()
9534        }
9535        pub(crate) fn to_ffi(
9536            &self,
9537        ) -> (ffi::WGPUPipelineLayoutPixelLocalStorage, ChainedStructStorage) {
9538            let mut storage = ChainedStructStorage::new();
9539            let mut raw: ffi::WGPUPipelineLayoutPixelLocalStorage = unsafe {
9540                std::mem::zeroed()
9541            };
9542            if let Some(value) = self.total_pixel_local_storage_size {
9543                raw.totalPixelLocalStorageSize = value;
9544            }
9545            raw.storageAttachmentCount = self
9546                .storage_attachments
9547                .as_ref()
9548                .map(|v| v.len())
9549                .unwrap_or(0);
9550            if let Some(values) = &self.storage_attachments {
9551                let len_value = values.len();
9552                let mut raw_vec: Vec<ffi::WGPUPipelineLayoutStorageAttachment> = Vec::with_capacity(
9553                    values.len(),
9554                );
9555                for item in values.iter() {
9556                    let (raw_item, storage_item) = item.to_ffi();
9557                    raw_vec.push(raw_item);
9558                    storage.push_storage(storage_item);
9559                }
9560                let ptr = storage.push_vec(raw_vec);
9561                raw.storageAttachments = ptr;
9562                raw.storageAttachmentCount = len_value;
9563            } else {
9564                raw.storageAttachments = std::ptr::null();
9565                raw.storageAttachmentCount = 0;
9566            }
9567            (raw, storage)
9568        }
9569        pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutPixelLocalStorage) -> Self {
9570            Self {
9571                total_pixel_local_storage_size: Some(value.totalPixelLocalStorageSize),
9572                storage_attachments: if value.storageAttachments.is_null() {
9573                    None
9574                } else {
9575                    Some(
9576                        unsafe {
9577                            std::slice::from_raw_parts(
9578                                value.storageAttachments,
9579                                value.storageAttachmentCount as usize,
9580                            )
9581                        }
9582                            .iter()
9583                            .map(|raw| PipelineLayoutStorageAttachment::from_ffi(*raw))
9584                            .collect(),
9585                    )
9586                },
9587            }
9588        }
9589    }
9590    pub struct PipelineLayoutResourceTable {
9591        pub uses_resource_table: Option<bool>,
9592    }
9593    impl Default for PipelineLayoutResourceTable {
9594        fn default() -> Self {
9595            Self { uses_resource_table: None }
9596        }
9597    }
9598    impl PipelineLayoutResourceTable {
9599        pub fn new() -> Self {
9600            Self::default()
9601        }
9602        pub(crate) fn to_ffi(
9603            &self,
9604        ) -> (ffi::WGPUPipelineLayoutResourceTable, ChainedStructStorage) {
9605            let mut storage = ChainedStructStorage::new();
9606            let mut raw: ffi::WGPUPipelineLayoutResourceTable = unsafe {
9607                std::mem::zeroed()
9608            };
9609            raw.usesResourceTable = if self.uses_resource_table.unwrap_or(false) {
9610                1
9611            } else {
9612                0
9613            };
9614            (raw, storage)
9615        }
9616        pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutResourceTable) -> Self {
9617            Self {
9618                uses_resource_table: Some(value.usesResourceTable != 0),
9619            }
9620        }
9621    }
9622    pub struct PipelineLayoutStorageAttachment {
9623        pub(crate) extensions: Vec<PipelineLayoutStorageAttachmentExtension>,
9624        pub offset: Option<u64>,
9625        pub format: Option<TextureFormat>,
9626    }
9627    impl Default for PipelineLayoutStorageAttachment {
9628        fn default() -> Self {
9629            Self {
9630                extensions: Vec::new(),
9631                offset: Some(0),
9632                format: None,
9633            }
9634        }
9635    }
9636    impl PipelineLayoutStorageAttachment {
9637        pub fn new() -> Self {
9638            Self::default()
9639        }
9640        pub(crate) fn to_ffi(
9641            &self,
9642        ) -> (ffi::WGPUPipelineLayoutStorageAttachment, ChainedStructStorage) {
9643            let mut storage = ChainedStructStorage::new();
9644            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9645            for ext in self.extensions.iter().rev() {
9646                next = ext.push_chain(&mut storage, next);
9647            }
9648            let mut raw: ffi::WGPUPipelineLayoutStorageAttachment = unsafe {
9649                std::mem::zeroed()
9650            };
9651            raw.nextInChain = next;
9652            if let Some(value) = self.offset {
9653                raw.offset = value;
9654            }
9655            if let Some(value) = self.format {
9656                raw.format = value.into();
9657            } else {
9658                raw.format = 0 as ffi::WGPUTextureFormat;
9659            }
9660            (raw, storage)
9661        }
9662        pub fn with_extension(
9663            mut self,
9664            extension: PipelineLayoutStorageAttachmentExtension,
9665        ) -> Self {
9666            self.extensions.push(extension);
9667            self
9668        }
9669        pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutStorageAttachment) -> Self {
9670            Self {
9671                extensions: Vec::new(),
9672                offset: Some(value.offset),
9673                format: Some(value.format.into()),
9674            }
9675        }
9676    }
9677    pub struct PrimitiveState {
9678        pub(crate) extensions: Vec<PrimitiveStateExtension>,
9679        pub topology: Option<PrimitiveTopology>,
9680        pub strip_index_format: Option<IndexFormat>,
9681        pub front_face: Option<FrontFace>,
9682        pub cull_mode: Option<CullMode>,
9683        pub unclipped_depth: Option<bool>,
9684    }
9685    impl Default for PrimitiveState {
9686        fn default() -> Self {
9687            Self {
9688                extensions: Vec::new(),
9689                topology: Some(PrimitiveTopology::TriangleList),
9690                strip_index_format: None,
9691                front_face: Some(FrontFace::Ccw),
9692                cull_mode: Some(CullMode::None),
9693                unclipped_depth: None,
9694            }
9695        }
9696    }
9697    impl PrimitiveState {
9698        pub fn new() -> Self {
9699            Self::default()
9700        }
9701        pub(crate) fn to_ffi(&self) -> (ffi::WGPUPrimitiveState, ChainedStructStorage) {
9702            let mut storage = ChainedStructStorage::new();
9703            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9704            for ext in self.extensions.iter().rev() {
9705                next = ext.push_chain(&mut storage, next);
9706            }
9707            let mut raw: ffi::WGPUPrimitiveState = unsafe { std::mem::zeroed() };
9708            raw.nextInChain = next;
9709            if let Some(value) = self.topology {
9710                raw.topology = value.into();
9711            } else {
9712                raw.topology = 0 as ffi::WGPUPrimitiveTopology;
9713            }
9714            if let Some(value) = self.strip_index_format {
9715                raw.stripIndexFormat = value.into();
9716            } else {
9717                raw.stripIndexFormat = 0 as ffi::WGPUIndexFormat;
9718            }
9719            if let Some(value) = self.front_face {
9720                raw.frontFace = value.into();
9721            } else {
9722                raw.frontFace = 0 as ffi::WGPUFrontFace;
9723            }
9724            if let Some(value) = self.cull_mode {
9725                raw.cullMode = value.into();
9726            } else {
9727                raw.cullMode = 0 as ffi::WGPUCullMode;
9728            }
9729            raw.unclippedDepth = if self.unclipped_depth.unwrap_or(false) {
9730                1
9731            } else {
9732                0
9733            };
9734            (raw, storage)
9735        }
9736        pub fn with_extension(mut self, extension: PrimitiveStateExtension) -> Self {
9737            self.extensions.push(extension);
9738            self
9739        }
9740        pub(crate) fn from_ffi(value: ffi::WGPUPrimitiveState) -> Self {
9741            Self {
9742                extensions: Vec::new(),
9743                topology: Some(value.topology.into()),
9744                strip_index_format: Some(value.stripIndexFormat.into()),
9745                front_face: Some(value.frontFace.into()),
9746                cull_mode: Some(value.cullMode.into()),
9747                unclipped_depth: Some(value.unclippedDepth != 0),
9748            }
9749        }
9750    }
9751    pub struct QuerySetDescriptor {
9752        pub(crate) extensions: Vec<QuerySetDescriptorExtension>,
9753        pub label: Option<String>,
9754        pub r#type: Option<QueryType>,
9755        pub count: Option<u32>,
9756    }
9757    impl Default for QuerySetDescriptor {
9758        fn default() -> Self {
9759            Self {
9760                extensions: Vec::new(),
9761                label: None,
9762                r#type: None,
9763                count: None,
9764            }
9765        }
9766    }
9767    impl QuerySetDescriptor {
9768        pub fn new() -> Self {
9769            Self::default()
9770        }
9771        pub(crate) fn to_ffi(
9772            &self,
9773        ) -> (ffi::WGPUQuerySetDescriptor, ChainedStructStorage) {
9774            let mut storage = ChainedStructStorage::new();
9775            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9776            for ext in self.extensions.iter().rev() {
9777                next = ext.push_chain(&mut storage, next);
9778            }
9779            let mut raw: ffi::WGPUQuerySetDescriptor = unsafe { std::mem::zeroed() };
9780            raw.nextInChain = next;
9781            if let Some(value) = &self.label {
9782                raw.label = ffi::WGPUStringView {
9783                    data: value.as_ptr().cast(),
9784                    length: value.len(),
9785                };
9786            } else {
9787                raw.label = ffi::WGPUStringView {
9788                    data: std::ptr::null(),
9789                    length: 0,
9790                };
9791            }
9792            if let Some(value) = self.r#type {
9793                raw.type_ = value.into();
9794            } else {
9795                raw.type_ = 0 as ffi::WGPUQueryType;
9796            }
9797            if let Some(value) = self.count {
9798                raw.count = value;
9799            }
9800            (raw, storage)
9801        }
9802        pub fn with_extension(mut self, extension: QuerySetDescriptorExtension) -> Self {
9803            self.extensions.push(extension);
9804            self
9805        }
9806        pub(crate) fn from_ffi(value: ffi::WGPUQuerySetDescriptor) -> Self {
9807            Self {
9808                extensions: Vec::new(),
9809                label: if value.label.data.is_null() || value.label.length == 0 {
9810                    None
9811                } else {
9812                    Some(string_view_to_string(value.label))
9813                },
9814                r#type: Some(value.type_.into()),
9815                count: Some(value.count),
9816            }
9817        }
9818    }
9819    pub struct QueueDescriptor {
9820        pub(crate) extensions: Vec<QueueDescriptorExtension>,
9821        pub label: Option<String>,
9822    }
9823    impl Default for QueueDescriptor {
9824        fn default() -> Self {
9825            Self {
9826                extensions: Vec::new(),
9827                label: None,
9828            }
9829        }
9830    }
9831    impl QueueDescriptor {
9832        pub fn new() -> Self {
9833            Self::default()
9834        }
9835        pub(crate) fn to_ffi(&self) -> (ffi::WGPUQueueDescriptor, ChainedStructStorage) {
9836            let mut storage = ChainedStructStorage::new();
9837            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9838            for ext in self.extensions.iter().rev() {
9839                next = ext.push_chain(&mut storage, next);
9840            }
9841            let mut raw: ffi::WGPUQueueDescriptor = unsafe { std::mem::zeroed() };
9842            raw.nextInChain = next;
9843            if let Some(value) = &self.label {
9844                raw.label = ffi::WGPUStringView {
9845                    data: value.as_ptr().cast(),
9846                    length: value.len(),
9847                };
9848            } else {
9849                raw.label = ffi::WGPUStringView {
9850                    data: std::ptr::null(),
9851                    length: 0,
9852                };
9853            }
9854            (raw, storage)
9855        }
9856        pub fn with_extension(mut self, extension: QueueDescriptorExtension) -> Self {
9857            self.extensions.push(extension);
9858            self
9859        }
9860        pub(crate) fn from_ffi(value: ffi::WGPUQueueDescriptor) -> Self {
9861            Self {
9862                extensions: Vec::new(),
9863                label: if value.label.data.is_null() || value.label.length == 0 {
9864                    None
9865                } else {
9866                    Some(string_view_to_string(value.label))
9867                },
9868            }
9869        }
9870    }
9871    pub struct RenderBundleDescriptor {
9872        pub(crate) extensions: Vec<RenderBundleDescriptorExtension>,
9873        pub label: Option<String>,
9874    }
9875    impl Default for RenderBundleDescriptor {
9876        fn default() -> Self {
9877            Self {
9878                extensions: Vec::new(),
9879                label: None,
9880            }
9881        }
9882    }
9883    impl RenderBundleDescriptor {
9884        pub fn new() -> Self {
9885            Self::default()
9886        }
9887        pub(crate) fn to_ffi(
9888            &self,
9889        ) -> (ffi::WGPURenderBundleDescriptor, ChainedStructStorage) {
9890            let mut storage = ChainedStructStorage::new();
9891            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9892            for ext in self.extensions.iter().rev() {
9893                next = ext.push_chain(&mut storage, next);
9894            }
9895            let mut raw: ffi::WGPURenderBundleDescriptor = unsafe { std::mem::zeroed() };
9896            raw.nextInChain = next;
9897            if let Some(value) = &self.label {
9898                raw.label = ffi::WGPUStringView {
9899                    data: value.as_ptr().cast(),
9900                    length: value.len(),
9901                };
9902            } else {
9903                raw.label = ffi::WGPUStringView {
9904                    data: std::ptr::null(),
9905                    length: 0,
9906                };
9907            }
9908            (raw, storage)
9909        }
9910        pub fn with_extension(
9911            mut self,
9912            extension: RenderBundleDescriptorExtension,
9913        ) -> Self {
9914            self.extensions.push(extension);
9915            self
9916        }
9917        pub(crate) fn from_ffi(value: ffi::WGPURenderBundleDescriptor) -> Self {
9918            Self {
9919                extensions: Vec::new(),
9920                label: if value.label.data.is_null() || value.label.length == 0 {
9921                    None
9922                } else {
9923                    Some(string_view_to_string(value.label))
9924                },
9925            }
9926        }
9927    }
9928    pub struct RenderBundleEncoderDescriptor {
9929        pub(crate) extensions: Vec<RenderBundleEncoderDescriptorExtension>,
9930        pub label: Option<String>,
9931        pub color_formats: Option<Vec<TextureFormat>>,
9932        pub depth_stencil_format: Option<TextureFormat>,
9933        pub sample_count: Option<u32>,
9934        pub depth_read_only: Option<bool>,
9935        pub stencil_read_only: Option<bool>,
9936    }
9937    impl Default for RenderBundleEncoderDescriptor {
9938        fn default() -> Self {
9939            Self {
9940                extensions: Vec::new(),
9941                label: None,
9942                color_formats: None,
9943                depth_stencil_format: None,
9944                sample_count: Some(1),
9945                depth_read_only: None,
9946                stencil_read_only: None,
9947            }
9948        }
9949    }
9950    impl RenderBundleEncoderDescriptor {
9951        pub fn new() -> Self {
9952            Self::default()
9953        }
9954        pub(crate) fn to_ffi(
9955            &self,
9956        ) -> (ffi::WGPURenderBundleEncoderDescriptor, ChainedStructStorage) {
9957            let mut storage = ChainedStructStorage::new();
9958            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9959            for ext in self.extensions.iter().rev() {
9960                next = ext.push_chain(&mut storage, next);
9961            }
9962            let mut raw: ffi::WGPURenderBundleEncoderDescriptor = unsafe {
9963                std::mem::zeroed()
9964            };
9965            raw.nextInChain = next;
9966            if let Some(value) = &self.label {
9967                raw.label = ffi::WGPUStringView {
9968                    data: value.as_ptr().cast(),
9969                    length: value.len(),
9970                };
9971            } else {
9972                raw.label = ffi::WGPUStringView {
9973                    data: std::ptr::null(),
9974                    length: 0,
9975                };
9976            }
9977            raw.colorFormatCount = self
9978                .color_formats
9979                .as_ref()
9980                .map(|v| v.len())
9981                .unwrap_or(0);
9982            if let Some(values) = &self.color_formats {
9983                let len_value = values.len();
9984                let raw_vec: Vec<ffi::WGPUTextureFormat> = values
9985                    .iter()
9986                    .map(|v| (*v).into())
9987                    .collect();
9988                let ptr = storage.push_vec(raw_vec);
9989                raw.colorFormats = ptr;
9990                raw.colorFormatCount = len_value;
9991            } else {
9992                raw.colorFormats = std::ptr::null();
9993                raw.colorFormatCount = 0;
9994            }
9995            if let Some(value) = self.depth_stencil_format {
9996                raw.depthStencilFormat = value.into();
9997            } else {
9998                raw.depthStencilFormat = 0 as ffi::WGPUTextureFormat;
9999            }
10000            if let Some(value) = self.sample_count {
10001                raw.sampleCount = value;
10002            }
10003            raw.depthReadOnly = if self.depth_read_only.unwrap_or(false) {
10004                1
10005            } else {
10006                0
10007            };
10008            raw.stencilReadOnly = if self.stencil_read_only.unwrap_or(false) {
10009                1
10010            } else {
10011                0
10012            };
10013            (raw, storage)
10014        }
10015        pub fn with_extension(
10016            mut self,
10017            extension: RenderBundleEncoderDescriptorExtension,
10018        ) -> Self {
10019            self.extensions.push(extension);
10020            self
10021        }
10022        pub(crate) fn from_ffi(value: ffi::WGPURenderBundleEncoderDescriptor) -> Self {
10023            Self {
10024                extensions: Vec::new(),
10025                label: if value.label.data.is_null() || value.label.length == 0 {
10026                    None
10027                } else {
10028                    Some(string_view_to_string(value.label))
10029                },
10030                color_formats: if value.colorFormats.is_null() {
10031                    None
10032                } else {
10033                    Some(
10034                        unsafe {
10035                            std::slice::from_raw_parts(
10036                                value.colorFormats,
10037                                value.colorFormatCount as usize,
10038                            )
10039                        }
10040                            .iter()
10041                            .map(|raw| TextureFormat::from(*raw))
10042                            .collect(),
10043                    )
10044                },
10045                depth_stencil_format: Some(value.depthStencilFormat.into()),
10046                sample_count: Some(value.sampleCount),
10047                depth_read_only: Some(value.depthReadOnly != 0),
10048                stencil_read_only: Some(value.stencilReadOnly != 0),
10049            }
10050        }
10051    }
10052    pub struct RenderPassColorAttachment {
10053        pub(crate) extensions: Vec<RenderPassColorAttachmentExtension>,
10054        pub view: Option<TextureView>,
10055        pub depth_slice: Option<u32>,
10056        pub resolve_target: Option<TextureView>,
10057        pub load_op: Option<LoadOp>,
10058        pub store_op: Option<StoreOp>,
10059        pub clear_value: Option<Color>,
10060    }
10061    impl Default for RenderPassColorAttachment {
10062        fn default() -> Self {
10063            Self {
10064                extensions: Vec::new(),
10065                view: None,
10066                depth_slice: Some(DEPTH_SLICE_UNDEFINED),
10067                resolve_target: None,
10068                load_op: None,
10069                store_op: None,
10070                clear_value: None,
10071            }
10072        }
10073    }
10074    impl RenderPassColorAttachment {
10075        pub fn new() -> Self {
10076            Self::default()
10077        }
10078        pub(crate) fn to_ffi(
10079            &self,
10080        ) -> (ffi::WGPURenderPassColorAttachment, ChainedStructStorage) {
10081            let mut storage = ChainedStructStorage::new();
10082            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10083            for ext in self.extensions.iter().rev() {
10084                next = ext.push_chain(&mut storage, next);
10085            }
10086            let mut raw: ffi::WGPURenderPassColorAttachment = unsafe {
10087                std::mem::zeroed()
10088            };
10089            raw.nextInChain = next;
10090            raw.view = self
10091                .view
10092                .as_ref()
10093                .map(|v| v.as_raw())
10094                .unwrap_or(std::ptr::null_mut());
10095            if let Some(value) = self.depth_slice {
10096                raw.depthSlice = value;
10097            }
10098            raw.resolveTarget = self
10099                .resolve_target
10100                .as_ref()
10101                .map(|v| v.as_raw())
10102                .unwrap_or(std::ptr::null_mut());
10103            if let Some(value) = self.load_op {
10104                raw.loadOp = value.into();
10105            } else {
10106                raw.loadOp = 0 as ffi::WGPULoadOp;
10107            }
10108            if let Some(value) = self.store_op {
10109                raw.storeOp = value.into();
10110            } else {
10111                raw.storeOp = 0 as ffi::WGPUStoreOp;
10112            }
10113            if let Some(value) = &self.clear_value {
10114                let (raw_value, storage_value) = value.to_ffi();
10115                raw.clearValue = raw_value;
10116                storage.push_storage(storage_value);
10117            }
10118            (raw, storage)
10119        }
10120        pub fn with_extension(
10121            mut self,
10122            extension: RenderPassColorAttachmentExtension,
10123        ) -> Self {
10124            self.extensions.push(extension);
10125            self
10126        }
10127        pub(crate) fn from_ffi(value: ffi::WGPURenderPassColorAttachment) -> Self {
10128            Self {
10129                extensions: Vec::new(),
10130                view: if value.view.is_null() {
10131                    None
10132                } else {
10133                    Some(unsafe { TextureView::from_raw(value.view) })
10134                },
10135                depth_slice: Some(value.depthSlice),
10136                resolve_target: if value.resolveTarget.is_null() {
10137                    None
10138                } else {
10139                    Some(unsafe { TextureView::from_raw(value.resolveTarget) })
10140                },
10141                load_op: Some(value.loadOp.into()),
10142                store_op: Some(value.storeOp.into()),
10143                clear_value: Some(Color::from_ffi(value.clearValue)),
10144            }
10145        }
10146    }
10147    pub struct RenderPassDepthStencilAttachment {
10148        pub(crate) extensions: Vec<RenderPassDepthStencilAttachmentExtension>,
10149        pub view: Option<TextureView>,
10150        pub depth_load_op: Option<LoadOp>,
10151        pub depth_store_op: Option<StoreOp>,
10152        pub depth_clear_value: Option<f32>,
10153        pub depth_read_only: Option<bool>,
10154        pub stencil_load_op: Option<LoadOp>,
10155        pub stencil_store_op: Option<StoreOp>,
10156        pub stencil_clear_value: Option<u32>,
10157        pub stencil_read_only: Option<bool>,
10158    }
10159    impl Default for RenderPassDepthStencilAttachment {
10160        fn default() -> Self {
10161            Self {
10162                extensions: Vec::new(),
10163                view: None,
10164                depth_load_op: None,
10165                depth_store_op: None,
10166                depth_clear_value: Some(DEPTH_CLEAR_VALUE_UNDEFINED),
10167                depth_read_only: None,
10168                stencil_load_op: None,
10169                stencil_store_op: None,
10170                stencil_clear_value: Some(0),
10171                stencil_read_only: None,
10172            }
10173        }
10174    }
10175    impl RenderPassDepthStencilAttachment {
10176        pub fn new() -> Self {
10177            Self::default()
10178        }
10179        pub(crate) fn to_ffi(
10180            &self,
10181        ) -> (ffi::WGPURenderPassDepthStencilAttachment, ChainedStructStorage) {
10182            let mut storage = ChainedStructStorage::new();
10183            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10184            for ext in self.extensions.iter().rev() {
10185                next = ext.push_chain(&mut storage, next);
10186            }
10187            let mut raw: ffi::WGPURenderPassDepthStencilAttachment = unsafe {
10188                std::mem::zeroed()
10189            };
10190            raw.nextInChain = next;
10191            raw.view = self
10192                .view
10193                .as_ref()
10194                .map(|v| v.as_raw())
10195                .unwrap_or(std::ptr::null_mut());
10196            if let Some(value) = self.depth_load_op {
10197                raw.depthLoadOp = value.into();
10198            } else {
10199                raw.depthLoadOp = 0 as ffi::WGPULoadOp;
10200            }
10201            if let Some(value) = self.depth_store_op {
10202                raw.depthStoreOp = value.into();
10203            } else {
10204                raw.depthStoreOp = 0 as ffi::WGPUStoreOp;
10205            }
10206            if let Some(value) = self.depth_clear_value {
10207                raw.depthClearValue = value;
10208            }
10209            raw.depthReadOnly = if self.depth_read_only.unwrap_or(false) {
10210                1
10211            } else {
10212                0
10213            };
10214            if let Some(value) = self.stencil_load_op {
10215                raw.stencilLoadOp = value.into();
10216            } else {
10217                raw.stencilLoadOp = 0 as ffi::WGPULoadOp;
10218            }
10219            if let Some(value) = self.stencil_store_op {
10220                raw.stencilStoreOp = value.into();
10221            } else {
10222                raw.stencilStoreOp = 0 as ffi::WGPUStoreOp;
10223            }
10224            if let Some(value) = self.stencil_clear_value {
10225                raw.stencilClearValue = value;
10226            }
10227            raw.stencilReadOnly = if self.stencil_read_only.unwrap_or(false) {
10228                1
10229            } else {
10230                0
10231            };
10232            (raw, storage)
10233        }
10234        pub fn with_extension(
10235            mut self,
10236            extension: RenderPassDepthStencilAttachmentExtension,
10237        ) -> Self {
10238            self.extensions.push(extension);
10239            self
10240        }
10241        pub(crate) fn from_ffi(
10242            value: ffi::WGPURenderPassDepthStencilAttachment,
10243        ) -> Self {
10244            Self {
10245                extensions: Vec::new(),
10246                view: Some(unsafe { TextureView::from_raw(value.view) }),
10247                depth_load_op: Some(value.depthLoadOp.into()),
10248                depth_store_op: Some(value.depthStoreOp.into()),
10249                depth_clear_value: Some(value.depthClearValue),
10250                depth_read_only: Some(value.depthReadOnly != 0),
10251                stencil_load_op: Some(value.stencilLoadOp.into()),
10252                stencil_store_op: Some(value.stencilStoreOp.into()),
10253                stencil_clear_value: Some(value.stencilClearValue),
10254                stencil_read_only: Some(value.stencilReadOnly != 0),
10255            }
10256        }
10257    }
10258    pub struct RenderPassDescriptor {
10259        pub(crate) extensions: Vec<RenderPassDescriptorExtension>,
10260        pub label: Option<String>,
10261        pub color_attachments: Option<Vec<RenderPassColorAttachment>>,
10262        pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachment>,
10263        pub occlusion_query_set: Option<QuerySet>,
10264        pub timestamp_writes: Option<PassTimestampWrites>,
10265    }
10266    impl Default for RenderPassDescriptor {
10267        fn default() -> Self {
10268            Self {
10269                extensions: Vec::new(),
10270                label: None,
10271                color_attachments: None,
10272                depth_stencil_attachment: None,
10273                occlusion_query_set: None,
10274                timestamp_writes: None,
10275            }
10276        }
10277    }
10278    impl RenderPassDescriptor {
10279        pub fn new() -> Self {
10280            Self::default()
10281        }
10282        pub(crate) fn to_ffi(
10283            &self,
10284        ) -> (ffi::WGPURenderPassDescriptor, ChainedStructStorage) {
10285            let mut storage = ChainedStructStorage::new();
10286            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10287            for ext in self.extensions.iter().rev() {
10288                next = ext.push_chain(&mut storage, next);
10289            }
10290            let mut raw: ffi::WGPURenderPassDescriptor = unsafe { std::mem::zeroed() };
10291            raw.nextInChain = next;
10292            if let Some(value) = &self.label {
10293                raw.label = ffi::WGPUStringView {
10294                    data: value.as_ptr().cast(),
10295                    length: value.len(),
10296                };
10297            } else {
10298                raw.label = ffi::WGPUStringView {
10299                    data: std::ptr::null(),
10300                    length: 0,
10301                };
10302            }
10303            raw.colorAttachmentCount = self
10304                .color_attachments
10305                .as_ref()
10306                .map(|v| v.len())
10307                .unwrap_or(0);
10308            if let Some(values) = &self.color_attachments {
10309                let len_value = values.len();
10310                let mut raw_vec: Vec<ffi::WGPURenderPassColorAttachment> = Vec::with_capacity(
10311                    values.len(),
10312                );
10313                for item in values.iter() {
10314                    let (raw_item, storage_item) = item.to_ffi();
10315                    raw_vec.push(raw_item);
10316                    storage.push_storage(storage_item);
10317                }
10318                let ptr = storage.push_vec(raw_vec);
10319                raw.colorAttachments = ptr;
10320                raw.colorAttachmentCount = len_value;
10321            } else {
10322                raw.colorAttachments = std::ptr::null();
10323                raw.colorAttachmentCount = 0;
10324            }
10325            if let Some(value) = &self.depth_stencil_attachment {
10326                let (raw_value, storage_value) = value.to_ffi();
10327                let ptr = storage.push_value(raw_value);
10328                raw.depthStencilAttachment = ptr;
10329                storage.push_storage(storage_value);
10330            } else {
10331                raw.depthStencilAttachment = std::ptr::null();
10332            }
10333            raw.occlusionQuerySet = self
10334                .occlusion_query_set
10335                .as_ref()
10336                .map(|v| v.as_raw())
10337                .unwrap_or(std::ptr::null_mut());
10338            if let Some(value) = &self.timestamp_writes {
10339                let (raw_value, storage_value) = value.to_ffi();
10340                let ptr = storage.push_value(raw_value);
10341                raw.timestampWrites = ptr;
10342                storage.push_storage(storage_value);
10343            } else {
10344                raw.timestampWrites = std::ptr::null();
10345            }
10346            (raw, storage)
10347        }
10348        pub fn with_extension(
10349            mut self,
10350            extension: RenderPassDescriptorExtension,
10351        ) -> Self {
10352            self.extensions.push(extension);
10353            self
10354        }
10355        pub(crate) fn from_ffi(value: ffi::WGPURenderPassDescriptor) -> Self {
10356            Self {
10357                extensions: Vec::new(),
10358                label: if value.label.data.is_null() || value.label.length == 0 {
10359                    None
10360                } else {
10361                    Some(string_view_to_string(value.label))
10362                },
10363                color_attachments: if value.colorAttachments.is_null() {
10364                    None
10365                } else {
10366                    Some(
10367                        unsafe {
10368                            std::slice::from_raw_parts(
10369                                value.colorAttachments,
10370                                value.colorAttachmentCount as usize,
10371                            )
10372                        }
10373                            .iter()
10374                            .map(|raw| RenderPassColorAttachment::from_ffi(*raw))
10375                            .collect(),
10376                    )
10377                },
10378                depth_stencil_attachment: if value.depthStencilAttachment.is_null() {
10379                    None
10380                } else {
10381                    Some(
10382                        RenderPassDepthStencilAttachment::from_ffi(unsafe {
10383                            *value.depthStencilAttachment
10384                        }),
10385                    )
10386                },
10387                occlusion_query_set: if value.occlusionQuerySet.is_null() {
10388                    None
10389                } else {
10390                    Some(unsafe { QuerySet::from_raw(value.occlusionQuerySet) })
10391                },
10392                timestamp_writes: if value.timestampWrites.is_null() {
10393                    None
10394                } else {
10395                    Some(
10396                        PassTimestampWrites::from_ffi(unsafe { *value.timestampWrites }),
10397                    )
10398                },
10399            }
10400        }
10401    }
10402    pub struct RenderPassDescriptorResolveRect {
10403        pub color_offset_x: Option<u32>,
10404        pub color_offset_y: Option<u32>,
10405        pub resolve_offset_x: Option<u32>,
10406        pub resolve_offset_y: Option<u32>,
10407        pub width: Option<u32>,
10408        pub height: Option<u32>,
10409    }
10410    impl Default for RenderPassDescriptorResolveRect {
10411        fn default() -> Self {
10412            Self {
10413                color_offset_x: None,
10414                color_offset_y: None,
10415                resolve_offset_x: None,
10416                resolve_offset_y: None,
10417                width: None,
10418                height: None,
10419            }
10420        }
10421    }
10422    impl RenderPassDescriptorResolveRect {
10423        pub fn new() -> Self {
10424            Self::default()
10425        }
10426        pub(crate) fn to_ffi(
10427            &self,
10428        ) -> (ffi::WGPURenderPassDescriptorResolveRect, ChainedStructStorage) {
10429            let mut storage = ChainedStructStorage::new();
10430            let mut raw: ffi::WGPURenderPassDescriptorResolveRect = unsafe {
10431                std::mem::zeroed()
10432            };
10433            if let Some(value) = self.color_offset_x {
10434                raw.colorOffsetX = value;
10435            }
10436            if let Some(value) = self.color_offset_y {
10437                raw.colorOffsetY = value;
10438            }
10439            if let Some(value) = self.resolve_offset_x {
10440                raw.resolveOffsetX = value;
10441            }
10442            if let Some(value) = self.resolve_offset_y {
10443                raw.resolveOffsetY = value;
10444            }
10445            if let Some(value) = self.width {
10446                raw.width = value;
10447            }
10448            if let Some(value) = self.height {
10449                raw.height = value;
10450            }
10451            (raw, storage)
10452        }
10453        pub(crate) fn from_ffi(value: ffi::WGPURenderPassDescriptorResolveRect) -> Self {
10454            Self {
10455                color_offset_x: Some(value.colorOffsetX),
10456                color_offset_y: Some(value.colorOffsetY),
10457                resolve_offset_x: Some(value.resolveOffsetX),
10458                resolve_offset_y: Some(value.resolveOffsetY),
10459                width: Some(value.width),
10460                height: Some(value.height),
10461            }
10462        }
10463    }
10464    pub struct RenderPassMaxDrawCount {
10465        pub max_draw_count: Option<u64>,
10466    }
10467    impl Default for RenderPassMaxDrawCount {
10468        fn default() -> Self {
10469            Self {
10470                max_draw_count: Some(50000000),
10471            }
10472        }
10473    }
10474    impl RenderPassMaxDrawCount {
10475        pub fn new() -> Self {
10476            Self::default()
10477        }
10478        pub(crate) fn to_ffi(
10479            &self,
10480        ) -> (ffi::WGPURenderPassMaxDrawCount, ChainedStructStorage) {
10481            let mut storage = ChainedStructStorage::new();
10482            let mut raw: ffi::WGPURenderPassMaxDrawCount = unsafe { std::mem::zeroed() };
10483            if let Some(value) = self.max_draw_count {
10484                raw.maxDrawCount = value;
10485            }
10486            (raw, storage)
10487        }
10488        pub(crate) fn from_ffi(value: ffi::WGPURenderPassMaxDrawCount) -> Self {
10489            Self {
10490                max_draw_count: Some(value.maxDrawCount),
10491            }
10492        }
10493    }
10494    pub struct RenderPassPixelLocalStorage {
10495        pub total_pixel_local_storage_size: Option<u64>,
10496        pub storage_attachments: Option<Vec<RenderPassStorageAttachment>>,
10497    }
10498    impl Default for RenderPassPixelLocalStorage {
10499        fn default() -> Self {
10500            Self {
10501                total_pixel_local_storage_size: None,
10502                storage_attachments: None,
10503            }
10504        }
10505    }
10506    impl RenderPassPixelLocalStorage {
10507        pub fn new() -> Self {
10508            Self::default()
10509        }
10510        pub(crate) fn to_ffi(
10511            &self,
10512        ) -> (ffi::WGPURenderPassPixelLocalStorage, ChainedStructStorage) {
10513            let mut storage = ChainedStructStorage::new();
10514            let mut raw: ffi::WGPURenderPassPixelLocalStorage = unsafe {
10515                std::mem::zeroed()
10516            };
10517            if let Some(value) = self.total_pixel_local_storage_size {
10518                raw.totalPixelLocalStorageSize = value;
10519            }
10520            raw.storageAttachmentCount = self
10521                .storage_attachments
10522                .as_ref()
10523                .map(|v| v.len())
10524                .unwrap_or(0);
10525            if let Some(values) = &self.storage_attachments {
10526                let len_value = values.len();
10527                let mut raw_vec: Vec<ffi::WGPURenderPassStorageAttachment> = Vec::with_capacity(
10528                    values.len(),
10529                );
10530                for item in values.iter() {
10531                    let (raw_item, storage_item) = item.to_ffi();
10532                    raw_vec.push(raw_item);
10533                    storage.push_storage(storage_item);
10534                }
10535                let ptr = storage.push_vec(raw_vec);
10536                raw.storageAttachments = ptr;
10537                raw.storageAttachmentCount = len_value;
10538            } else {
10539                raw.storageAttachments = std::ptr::null();
10540                raw.storageAttachmentCount = 0;
10541            }
10542            (raw, storage)
10543        }
10544        pub(crate) fn from_ffi(value: ffi::WGPURenderPassPixelLocalStorage) -> Self {
10545            Self {
10546                total_pixel_local_storage_size: Some(value.totalPixelLocalStorageSize),
10547                storage_attachments: if value.storageAttachments.is_null() {
10548                    None
10549                } else {
10550                    Some(
10551                        unsafe {
10552                            std::slice::from_raw_parts(
10553                                value.storageAttachments,
10554                                value.storageAttachmentCount as usize,
10555                            )
10556                        }
10557                            .iter()
10558                            .map(|raw| RenderPassStorageAttachment::from_ffi(*raw))
10559                            .collect(),
10560                    )
10561                },
10562            }
10563        }
10564    }
10565    pub struct RenderPassRenderAreaRect {
10566        pub origin: Option<Origin2D>,
10567        pub size: Option<Extent2D>,
10568    }
10569    impl Default for RenderPassRenderAreaRect {
10570        fn default() -> Self {
10571            Self { origin: None, size: None }
10572        }
10573    }
10574    impl RenderPassRenderAreaRect {
10575        pub fn new() -> Self {
10576            Self::default()
10577        }
10578        pub(crate) fn to_ffi(
10579            &self,
10580        ) -> (ffi::WGPURenderPassRenderAreaRect, ChainedStructStorage) {
10581            let mut storage = ChainedStructStorage::new();
10582            let mut raw: ffi::WGPURenderPassRenderAreaRect = unsafe {
10583                std::mem::zeroed()
10584            };
10585            if let Some(value) = &self.origin {
10586                let (raw_value, storage_value) = value.to_ffi();
10587                raw.origin = raw_value;
10588                storage.push_storage(storage_value);
10589            }
10590            if let Some(value) = &self.size {
10591                let (raw_value, storage_value) = value.to_ffi();
10592                raw.size = raw_value;
10593                storage.push_storage(storage_value);
10594            }
10595            (raw, storage)
10596        }
10597        pub(crate) fn from_ffi(value: ffi::WGPURenderPassRenderAreaRect) -> Self {
10598            Self {
10599                origin: Some(Origin2D::from_ffi(value.origin)),
10600                size: Some(Extent2D::from_ffi(value.size)),
10601            }
10602        }
10603    }
10604    pub struct RenderPassStorageAttachment {
10605        pub(crate) extensions: Vec<RenderPassStorageAttachmentExtension>,
10606        pub offset: Option<u64>,
10607        pub storage: Option<TextureView>,
10608        pub load_op: Option<LoadOp>,
10609        pub store_op: Option<StoreOp>,
10610        pub clear_value: Option<Color>,
10611    }
10612    impl Default for RenderPassStorageAttachment {
10613        fn default() -> Self {
10614            Self {
10615                extensions: Vec::new(),
10616                offset: Some(0),
10617                storage: None,
10618                load_op: None,
10619                store_op: None,
10620                clear_value: None,
10621            }
10622        }
10623    }
10624    impl RenderPassStorageAttachment {
10625        pub fn new() -> Self {
10626            Self::default()
10627        }
10628        pub(crate) fn to_ffi(
10629            &self,
10630        ) -> (ffi::WGPURenderPassStorageAttachment, ChainedStructStorage) {
10631            let mut storage = ChainedStructStorage::new();
10632            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10633            for ext in self.extensions.iter().rev() {
10634                next = ext.push_chain(&mut storage, next);
10635            }
10636            let mut raw: ffi::WGPURenderPassStorageAttachment = unsafe {
10637                std::mem::zeroed()
10638            };
10639            raw.nextInChain = next;
10640            if let Some(value) = self.offset {
10641                raw.offset = value;
10642            }
10643            raw.storage = self
10644                .storage
10645                .as_ref()
10646                .map(|v| v.as_raw())
10647                .unwrap_or(std::ptr::null_mut());
10648            if let Some(value) = self.load_op {
10649                raw.loadOp = value.into();
10650            } else {
10651                raw.loadOp = 0 as ffi::WGPULoadOp;
10652            }
10653            if let Some(value) = self.store_op {
10654                raw.storeOp = value.into();
10655            } else {
10656                raw.storeOp = 0 as ffi::WGPUStoreOp;
10657            }
10658            if let Some(value) = &self.clear_value {
10659                let (raw_value, storage_value) = value.to_ffi();
10660                raw.clearValue = raw_value;
10661                storage.push_storage(storage_value);
10662            }
10663            (raw, storage)
10664        }
10665        pub fn with_extension(
10666            mut self,
10667            extension: RenderPassStorageAttachmentExtension,
10668        ) -> Self {
10669            self.extensions.push(extension);
10670            self
10671        }
10672        pub(crate) fn from_ffi(value: ffi::WGPURenderPassStorageAttachment) -> Self {
10673            Self {
10674                extensions: Vec::new(),
10675                offset: Some(value.offset),
10676                storage: Some(unsafe { TextureView::from_raw(value.storage) }),
10677                load_op: Some(value.loadOp.into()),
10678                store_op: Some(value.storeOp.into()),
10679                clear_value: Some(Color::from_ffi(value.clearValue)),
10680            }
10681        }
10682    }
10683    pub struct RenderPipelineDescriptor {
10684        pub(crate) extensions: Vec<RenderPipelineDescriptorExtension>,
10685        pub label: Option<String>,
10686        pub layout: Option<PipelineLayout>,
10687        pub vertex: Option<VertexState>,
10688        pub primitive: Option<PrimitiveState>,
10689        pub depth_stencil: Option<DepthStencilState>,
10690        pub multisample: Option<MultisampleState>,
10691        pub fragment: Option<FragmentState>,
10692    }
10693    impl Default for RenderPipelineDescriptor {
10694        fn default() -> Self {
10695            Self {
10696                extensions: Vec::new(),
10697                label: None,
10698                layout: None,
10699                vertex: None,
10700                primitive: None,
10701                depth_stencil: None,
10702                multisample: None,
10703                fragment: None,
10704            }
10705        }
10706    }
10707    impl RenderPipelineDescriptor {
10708        pub fn new() -> Self {
10709            Self::default()
10710        }
10711        pub(crate) fn to_ffi(
10712            &self,
10713        ) -> (ffi::WGPURenderPipelineDescriptor, ChainedStructStorage) {
10714            let mut storage = ChainedStructStorage::new();
10715            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10716            for ext in self.extensions.iter().rev() {
10717                next = ext.push_chain(&mut storage, next);
10718            }
10719            let mut raw: ffi::WGPURenderPipelineDescriptor = unsafe {
10720                std::mem::zeroed()
10721            };
10722            raw.nextInChain = next;
10723            if let Some(value) = &self.label {
10724                raw.label = ffi::WGPUStringView {
10725                    data: value.as_ptr().cast(),
10726                    length: value.len(),
10727                };
10728            } else {
10729                raw.label = ffi::WGPUStringView {
10730                    data: std::ptr::null(),
10731                    length: 0,
10732                };
10733            }
10734            raw.layout = self
10735                .layout
10736                .as_ref()
10737                .map(|v| v.as_raw())
10738                .unwrap_or(std::ptr::null_mut());
10739            if let Some(value) = &self.vertex {
10740                let (raw_value, storage_value) = value.to_ffi();
10741                raw.vertex = raw_value;
10742                storage.push_storage(storage_value);
10743            }
10744            if let Some(value) = &self.primitive {
10745                let (raw_value, storage_value) = value.to_ffi();
10746                raw.primitive = raw_value;
10747                storage.push_storage(storage_value);
10748            }
10749            if let Some(value) = &self.depth_stencil {
10750                let (raw_value, storage_value) = value.to_ffi();
10751                let ptr = storage.push_value(raw_value);
10752                raw.depthStencil = ptr;
10753                storage.push_storage(storage_value);
10754            } else {
10755                raw.depthStencil = std::ptr::null();
10756            }
10757            if let Some(value) = &self.multisample {
10758                let (raw_value, storage_value) = value.to_ffi();
10759                raw.multisample = raw_value;
10760                storage.push_storage(storage_value);
10761            }
10762            if let Some(value) = &self.fragment {
10763                let (raw_value, storage_value) = value.to_ffi();
10764                let ptr = storage.push_value(raw_value);
10765                raw.fragment = ptr;
10766                storage.push_storage(storage_value);
10767            } else {
10768                raw.fragment = std::ptr::null();
10769            }
10770            (raw, storage)
10771        }
10772        pub fn with_extension(
10773            mut self,
10774            extension: RenderPipelineDescriptorExtension,
10775        ) -> Self {
10776            self.extensions.push(extension);
10777            self
10778        }
10779        pub(crate) fn from_ffi(value: ffi::WGPURenderPipelineDescriptor) -> Self {
10780            Self {
10781                extensions: Vec::new(),
10782                label: if value.label.data.is_null() || value.label.length == 0 {
10783                    None
10784                } else {
10785                    Some(string_view_to_string(value.label))
10786                },
10787                layout: if value.layout.is_null() {
10788                    None
10789                } else {
10790                    Some(unsafe { PipelineLayout::from_raw(value.layout) })
10791                },
10792                vertex: Some(VertexState::from_ffi(value.vertex)),
10793                primitive: Some(PrimitiveState::from_ffi(value.primitive)),
10794                depth_stencil: if value.depthStencil.is_null() {
10795                    None
10796                } else {
10797                    Some(DepthStencilState::from_ffi(unsafe { *value.depthStencil }))
10798                },
10799                multisample: Some(MultisampleState::from_ffi(value.multisample)),
10800                fragment: if value.fragment.is_null() {
10801                    None
10802                } else {
10803                    Some(FragmentState::from_ffi(unsafe { *value.fragment }))
10804                },
10805            }
10806        }
10807    }
10808    pub struct RequestAdapterWebGPUBackendOptions {}
10809    impl Default for RequestAdapterWebGPUBackendOptions {
10810        fn default() -> Self {
10811            Self {}
10812        }
10813    }
10814    impl RequestAdapterWebGPUBackendOptions {
10815        pub fn new() -> Self {
10816            Self::default()
10817        }
10818        pub(crate) fn to_ffi(
10819            &self,
10820        ) -> (ffi::WGPURequestAdapterWebGPUBackendOptions, ChainedStructStorage) {
10821            let mut storage = ChainedStructStorage::new();
10822            let mut raw: ffi::WGPURequestAdapterWebGPUBackendOptions = unsafe {
10823                std::mem::zeroed()
10824            };
10825            (raw, storage)
10826        }
10827        pub(crate) fn from_ffi(
10828            value: ffi::WGPURequestAdapterWebGPUBackendOptions,
10829        ) -> Self {
10830            let _ = value;
10831            Self::default()
10832        }
10833    }
10834    pub struct RequestAdapterWebXROptions {
10835        pub xr_compatible: Option<bool>,
10836    }
10837    impl Default for RequestAdapterWebXROptions {
10838        fn default() -> Self {
10839            Self { xr_compatible: None }
10840        }
10841    }
10842    impl RequestAdapterWebXROptions {
10843        pub fn new() -> Self {
10844            Self::default()
10845        }
10846        pub(crate) fn to_ffi(
10847            &self,
10848        ) -> (ffi::WGPURequestAdapterWebXROptions, ChainedStructStorage) {
10849            let mut storage = ChainedStructStorage::new();
10850            let mut raw: ffi::WGPURequestAdapterWebXROptions = unsafe {
10851                std::mem::zeroed()
10852            };
10853            raw.xrCompatible = if self.xr_compatible.unwrap_or(false) { 1 } else { 0 };
10854            (raw, storage)
10855        }
10856        pub(crate) fn from_ffi(value: ffi::WGPURequestAdapterWebXROptions) -> Self {
10857            Self {
10858                xr_compatible: Some(value.xrCompatible != 0),
10859            }
10860        }
10861    }
10862    pub struct RequestAdapterOptions {
10863        pub(crate) extensions: Vec<RequestAdapterOptionsExtension>,
10864        pub feature_level: Option<FeatureLevel>,
10865        pub power_preference: Option<PowerPreference>,
10866        pub force_fallback_adapter: Option<bool>,
10867        pub backend_type: Option<BackendType>,
10868        pub compatible_surface: Option<Surface>,
10869    }
10870    impl Default for RequestAdapterOptions {
10871        fn default() -> Self {
10872            Self {
10873                extensions: Vec::new(),
10874                feature_level: Some(FeatureLevel::Core),
10875                power_preference: None,
10876                force_fallback_adapter: None,
10877                backend_type: None,
10878                compatible_surface: None,
10879            }
10880        }
10881    }
10882    impl RequestAdapterOptions {
10883        pub fn new() -> Self {
10884            Self::default()
10885        }
10886        pub(crate) fn to_ffi(
10887            &self,
10888        ) -> (ffi::WGPURequestAdapterOptions, ChainedStructStorage) {
10889            let mut storage = ChainedStructStorage::new();
10890            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10891            for ext in self.extensions.iter().rev() {
10892                next = ext.push_chain(&mut storage, next);
10893            }
10894            let mut raw: ffi::WGPURequestAdapterOptions = unsafe { std::mem::zeroed() };
10895            raw.nextInChain = next;
10896            if let Some(value) = self.feature_level {
10897                raw.featureLevel = value.into();
10898            } else {
10899                raw.featureLevel = 0 as ffi::WGPUFeatureLevel;
10900            }
10901            if let Some(value) = self.power_preference {
10902                raw.powerPreference = value.into();
10903            } else {
10904                raw.powerPreference = 0 as ffi::WGPUPowerPreference;
10905            }
10906            raw.forceFallbackAdapter = if self.force_fallback_adapter.unwrap_or(false) {
10907                1
10908            } else {
10909                0
10910            };
10911            if let Some(value) = self.backend_type {
10912                raw.backendType = value.into();
10913            } else {
10914                raw.backendType = 0 as ffi::WGPUBackendType;
10915            }
10916            raw.compatibleSurface = self
10917                .compatible_surface
10918                .as_ref()
10919                .map(|v| v.as_raw())
10920                .unwrap_or(std::ptr::null_mut());
10921            (raw, storage)
10922        }
10923        pub fn with_extension(
10924            mut self,
10925            extension: RequestAdapterOptionsExtension,
10926        ) -> Self {
10927            self.extensions.push(extension);
10928            self
10929        }
10930        pub(crate) fn from_ffi(value: ffi::WGPURequestAdapterOptions) -> Self {
10931            Self {
10932                extensions: Vec::new(),
10933                feature_level: Some(value.featureLevel.into()),
10934                power_preference: Some(value.powerPreference.into()),
10935                force_fallback_adapter: Some(value.forceFallbackAdapter != 0),
10936                backend_type: Some(value.backendType.into()),
10937                compatible_surface: if value.compatibleSurface.is_null() {
10938                    None
10939                } else {
10940                    Some(unsafe { Surface::from_raw(value.compatibleSurface) })
10941                },
10942            }
10943        }
10944    }
10945    pub struct ResourceTableDescriptor {
10946        pub(crate) extensions: Vec<ResourceTableDescriptorExtension>,
10947        pub label: Option<String>,
10948        pub size: Option<u32>,
10949    }
10950    impl Default for ResourceTableDescriptor {
10951        fn default() -> Self {
10952            Self {
10953                extensions: Vec::new(),
10954                label: None,
10955                size: None,
10956            }
10957        }
10958    }
10959    impl ResourceTableDescriptor {
10960        pub fn new() -> Self {
10961            Self::default()
10962        }
10963        pub(crate) fn to_ffi(
10964            &self,
10965        ) -> (ffi::WGPUResourceTableDescriptor, ChainedStructStorage) {
10966            let mut storage = ChainedStructStorage::new();
10967            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10968            for ext in self.extensions.iter().rev() {
10969                next = ext.push_chain(&mut storage, next);
10970            }
10971            let mut raw: ffi::WGPUResourceTableDescriptor = unsafe {
10972                std::mem::zeroed()
10973            };
10974            raw.nextInChain = next;
10975            if let Some(value) = &self.label {
10976                raw.label = ffi::WGPUStringView {
10977                    data: value.as_ptr().cast(),
10978                    length: value.len(),
10979                };
10980            } else {
10981                raw.label = ffi::WGPUStringView {
10982                    data: std::ptr::null(),
10983                    length: 0,
10984                };
10985            }
10986            if let Some(value) = self.size {
10987                raw.size = value;
10988            }
10989            (raw, storage)
10990        }
10991        pub fn with_extension(
10992            mut self,
10993            extension: ResourceTableDescriptorExtension,
10994        ) -> Self {
10995            self.extensions.push(extension);
10996            self
10997        }
10998        pub(crate) fn from_ffi(value: ffi::WGPUResourceTableDescriptor) -> Self {
10999            Self {
11000                extensions: Vec::new(),
11001                label: if value.label.data.is_null() || value.label.length == 0 {
11002                    None
11003                } else {
11004                    Some(string_view_to_string(value.label))
11005                },
11006                size: Some(value.size),
11007            }
11008        }
11009    }
11010    pub struct SamplerBindingLayout {
11011        pub(crate) extensions: Vec<SamplerBindingLayoutExtension>,
11012        pub r#type: Option<SamplerBindingType>,
11013    }
11014    impl Default for SamplerBindingLayout {
11015        fn default() -> Self {
11016            Self {
11017                extensions: Vec::new(),
11018                r#type: Some(SamplerBindingType::Filtering),
11019            }
11020        }
11021    }
11022    impl SamplerBindingLayout {
11023        pub fn new() -> Self {
11024            Self::default()
11025        }
11026        pub(crate) fn to_ffi(
11027            &self,
11028        ) -> (ffi::WGPUSamplerBindingLayout, ChainedStructStorage) {
11029            let mut storage = ChainedStructStorage::new();
11030            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11031            for ext in self.extensions.iter().rev() {
11032                next = ext.push_chain(&mut storage, next);
11033            }
11034            let mut raw: ffi::WGPUSamplerBindingLayout = unsafe { std::mem::zeroed() };
11035            raw.nextInChain = next;
11036            if let Some(value) = self.r#type {
11037                raw.type_ = value.into();
11038            } else {
11039                raw.type_ = 0 as ffi::WGPUSamplerBindingType;
11040            }
11041            (raw, storage)
11042        }
11043        pub fn with_extension(
11044            mut self,
11045            extension: SamplerBindingLayoutExtension,
11046        ) -> Self {
11047            self.extensions.push(extension);
11048            self
11049        }
11050        pub(crate) fn from_ffi(value: ffi::WGPUSamplerBindingLayout) -> Self {
11051            Self {
11052                extensions: Vec::new(),
11053                r#type: Some(value.type_.into()),
11054            }
11055        }
11056    }
11057    pub struct SamplerDescriptor {
11058        pub(crate) extensions: Vec<SamplerDescriptorExtension>,
11059        pub label: Option<String>,
11060        pub address_mode_u: Option<AddressMode>,
11061        pub address_mode_v: Option<AddressMode>,
11062        pub address_mode_w: Option<AddressMode>,
11063        pub mag_filter: Option<FilterMode>,
11064        pub min_filter: Option<FilterMode>,
11065        pub mipmap_filter: Option<MipmapFilterMode>,
11066        pub lod_min_clamp: Option<f32>,
11067        pub lod_max_clamp: Option<f32>,
11068        pub compare: Option<CompareFunction>,
11069        pub max_anisotropy: Option<u16>,
11070    }
11071    impl Default for SamplerDescriptor {
11072        fn default() -> Self {
11073            Self {
11074                extensions: Vec::new(),
11075                label: None,
11076                address_mode_u: Some(AddressMode::ClampToEdge),
11077                address_mode_v: Some(AddressMode::ClampToEdge),
11078                address_mode_w: Some(AddressMode::ClampToEdge),
11079                mag_filter: Some(FilterMode::Nearest),
11080                min_filter: Some(FilterMode::Nearest),
11081                mipmap_filter: Some(MipmapFilterMode::Nearest),
11082                lod_min_clamp: None,
11083                lod_max_clamp: None,
11084                compare: None,
11085                max_anisotropy: Some(1),
11086            }
11087        }
11088    }
11089    impl SamplerDescriptor {
11090        pub fn new() -> Self {
11091            Self::default()
11092        }
11093        pub(crate) fn to_ffi(
11094            &self,
11095        ) -> (ffi::WGPUSamplerDescriptor, ChainedStructStorage) {
11096            let mut storage = ChainedStructStorage::new();
11097            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11098            for ext in self.extensions.iter().rev() {
11099                next = ext.push_chain(&mut storage, next);
11100            }
11101            let mut raw: ffi::WGPUSamplerDescriptor = unsafe { std::mem::zeroed() };
11102            raw.nextInChain = next;
11103            if let Some(value) = &self.label {
11104                raw.label = ffi::WGPUStringView {
11105                    data: value.as_ptr().cast(),
11106                    length: value.len(),
11107                };
11108            } else {
11109                raw.label = ffi::WGPUStringView {
11110                    data: std::ptr::null(),
11111                    length: 0,
11112                };
11113            }
11114            if let Some(value) = self.address_mode_u {
11115                raw.addressModeU = value.into();
11116            } else {
11117                raw.addressModeU = 0 as ffi::WGPUAddressMode;
11118            }
11119            if let Some(value) = self.address_mode_v {
11120                raw.addressModeV = value.into();
11121            } else {
11122                raw.addressModeV = 0 as ffi::WGPUAddressMode;
11123            }
11124            if let Some(value) = self.address_mode_w {
11125                raw.addressModeW = value.into();
11126            } else {
11127                raw.addressModeW = 0 as ffi::WGPUAddressMode;
11128            }
11129            if let Some(value) = self.mag_filter {
11130                raw.magFilter = value.into();
11131            } else {
11132                raw.magFilter = 0 as ffi::WGPUFilterMode;
11133            }
11134            if let Some(value) = self.min_filter {
11135                raw.minFilter = value.into();
11136            } else {
11137                raw.minFilter = 0 as ffi::WGPUFilterMode;
11138            }
11139            if let Some(value) = self.mipmap_filter {
11140                raw.mipmapFilter = value.into();
11141            } else {
11142                raw.mipmapFilter = 0 as ffi::WGPUMipmapFilterMode;
11143            }
11144            if let Some(value) = self.lod_min_clamp {
11145                raw.lodMinClamp = value;
11146            }
11147            if let Some(value) = self.lod_max_clamp {
11148                raw.lodMaxClamp = value;
11149            }
11150            if let Some(value) = self.compare {
11151                raw.compare = value.into();
11152            } else {
11153                raw.compare = 0 as ffi::WGPUCompareFunction;
11154            }
11155            if let Some(value) = self.max_anisotropy {
11156                raw.maxAnisotropy = value;
11157            }
11158            (raw, storage)
11159        }
11160        pub fn with_extension(mut self, extension: SamplerDescriptorExtension) -> Self {
11161            self.extensions.push(extension);
11162            self
11163        }
11164        pub(crate) fn from_ffi(value: ffi::WGPUSamplerDescriptor) -> Self {
11165            Self {
11166                extensions: Vec::new(),
11167                label: if value.label.data.is_null() || value.label.length == 0 {
11168                    None
11169                } else {
11170                    Some(string_view_to_string(value.label))
11171                },
11172                address_mode_u: Some(value.addressModeU.into()),
11173                address_mode_v: Some(value.addressModeV.into()),
11174                address_mode_w: Some(value.addressModeW.into()),
11175                mag_filter: Some(value.magFilter.into()),
11176                min_filter: Some(value.minFilter.into()),
11177                mipmap_filter: Some(value.mipmapFilter.into()),
11178                lod_min_clamp: Some(value.lodMinClamp),
11179                lod_max_clamp: Some(value.lodMaxClamp),
11180                compare: Some(value.compare.into()),
11181                max_anisotropy: Some(value.maxAnisotropy),
11182            }
11183        }
11184    }
11185    pub struct ShaderModuleCompilationOptions {
11186        pub strict_math: Option<bool>,
11187    }
11188    impl Default for ShaderModuleCompilationOptions {
11189        fn default() -> Self {
11190            Self { strict_math: None }
11191        }
11192    }
11193    impl ShaderModuleCompilationOptions {
11194        pub fn new() -> Self {
11195            Self::default()
11196        }
11197        pub(crate) fn to_ffi(
11198            &self,
11199        ) -> (ffi::WGPUShaderModuleCompilationOptions, ChainedStructStorage) {
11200            let mut storage = ChainedStructStorage::new();
11201            let mut raw: ffi::WGPUShaderModuleCompilationOptions = unsafe {
11202                std::mem::zeroed()
11203            };
11204            raw.strictMath = if self.strict_math.unwrap_or(false) { 1 } else { 0 };
11205            (raw, storage)
11206        }
11207        pub(crate) fn from_ffi(value: ffi::WGPUShaderModuleCompilationOptions) -> Self {
11208            Self {
11209                strict_math: Some(value.strictMath != 0),
11210            }
11211        }
11212    }
11213    pub struct ShaderModuleDescriptor {
11214        pub(crate) extensions: Vec<ShaderModuleDescriptorExtension>,
11215        pub label: Option<String>,
11216    }
11217    impl Default for ShaderModuleDescriptor {
11218        fn default() -> Self {
11219            Self {
11220                extensions: Vec::new(),
11221                label: None,
11222            }
11223        }
11224    }
11225    impl ShaderModuleDescriptor {
11226        pub fn new() -> Self {
11227            Self::default()
11228        }
11229        pub(crate) fn to_ffi(
11230            &self,
11231        ) -> (ffi::WGPUShaderModuleDescriptor, ChainedStructStorage) {
11232            let mut storage = ChainedStructStorage::new();
11233            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11234            for ext in self.extensions.iter().rev() {
11235                next = ext.push_chain(&mut storage, next);
11236            }
11237            let mut raw: ffi::WGPUShaderModuleDescriptor = unsafe { std::mem::zeroed() };
11238            raw.nextInChain = next;
11239            if let Some(value) = &self.label {
11240                raw.label = ffi::WGPUStringView {
11241                    data: value.as_ptr().cast(),
11242                    length: value.len(),
11243                };
11244            } else {
11245                raw.label = ffi::WGPUStringView {
11246                    data: std::ptr::null(),
11247                    length: 0,
11248                };
11249            }
11250            (raw, storage)
11251        }
11252        pub fn with_extension(
11253            mut self,
11254            extension: ShaderModuleDescriptorExtension,
11255        ) -> Self {
11256            self.extensions.push(extension);
11257            self
11258        }
11259        pub(crate) fn from_ffi(value: ffi::WGPUShaderModuleDescriptor) -> Self {
11260            Self {
11261                extensions: Vec::new(),
11262                label: if value.label.data.is_null() || value.label.length == 0 {
11263                    None
11264                } else {
11265                    Some(string_view_to_string(value.label))
11266                },
11267            }
11268        }
11269    }
11270    pub struct ShaderSourceSPIRV {
11271        pub code: Option<Vec<u32>>,
11272    }
11273    impl Default for ShaderSourceSPIRV {
11274        fn default() -> Self {
11275            Self { code: None }
11276        }
11277    }
11278    impl ShaderSourceSPIRV {
11279        pub fn new() -> Self {
11280            Self::default()
11281        }
11282        pub(crate) fn to_ffi(
11283            &self,
11284        ) -> (ffi::WGPUShaderSourceSPIRV, ChainedStructStorage) {
11285            let mut storage = ChainedStructStorage::new();
11286            let mut raw: ffi::WGPUShaderSourceSPIRV = unsafe { std::mem::zeroed() };
11287            raw.codeSize = (self.code.as_ref().map(|v| v.len()).unwrap_or(0)) as u32;
11288            if let Some(values) = &self.code {
11289                let len_value = values.len();
11290                let raw_vec = values.to_vec();
11291                let ptr = storage.push_vec(raw_vec);
11292                raw.code = ptr;
11293                raw.codeSize = len_value as u32;
11294            } else {
11295                raw.code = std::ptr::null();
11296                raw.codeSize = 0;
11297            }
11298            (raw, storage)
11299        }
11300        pub(crate) fn from_ffi(value: ffi::WGPUShaderSourceSPIRV) -> Self {
11301            Self {
11302                code: if value.code.is_null() {
11303                    None
11304                } else {
11305                    Some(
11306                        unsafe {
11307                            std::slice::from_raw_parts(
11308                                value.code,
11309                                value.codeSize as usize,
11310                            )
11311                        }
11312                            .to_vec(),
11313                    )
11314                },
11315            }
11316        }
11317    }
11318    pub struct ShaderSourceWGSL {
11319        pub code: Option<String>,
11320    }
11321    impl Default for ShaderSourceWGSL {
11322        fn default() -> Self {
11323            Self { code: None }
11324        }
11325    }
11326    impl ShaderSourceWGSL {
11327        pub fn new() -> Self {
11328            Self::default()
11329        }
11330        pub(crate) fn to_ffi(
11331            &self,
11332        ) -> (ffi::WGPUShaderSourceWGSL, ChainedStructStorage) {
11333            let mut storage = ChainedStructStorage::new();
11334            let mut raw: ffi::WGPUShaderSourceWGSL = unsafe { std::mem::zeroed() };
11335            if let Some(value) = &self.code {
11336                raw.code = ffi::WGPUStringView {
11337                    data: value.as_ptr().cast(),
11338                    length: value.len(),
11339                };
11340            } else {
11341                raw.code = ffi::WGPUStringView {
11342                    data: std::ptr::null(),
11343                    length: 0,
11344                };
11345            }
11346            (raw, storage)
11347        }
11348        pub(crate) fn from_ffi(value: ffi::WGPUShaderSourceWGSL) -> Self {
11349            Self {
11350                code: Some(string_view_to_string(value.code)),
11351            }
11352        }
11353    }
11354    pub struct SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor {
11355        pub handle: Option<*mut std::ffi::c_void>,
11356        pub size: Option<u64>,
11357    }
11358    impl Default for SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor {
11359        fn default() -> Self {
11360            Self { handle: None, size: None }
11361        }
11362    }
11363    impl SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor {
11364        pub fn new() -> Self {
11365            Self::default()
11366        }
11367        pub(crate) fn to_ffi(
11368            &self,
11369        ) -> (
11370            ffi::WGPUSharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
11371            ChainedStructStorage,
11372        ) {
11373            let mut storage = ChainedStructStorage::new();
11374            let mut raw: ffi::WGPUSharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor = unsafe {
11375                std::mem::zeroed()
11376            };
11377            if let Some(value) = self.handle {
11378                raw.handle = value;
11379            }
11380            if let Some(value) = self.size {
11381                raw.size = value;
11382            }
11383            (raw, storage)
11384        }
11385        pub(crate) fn from_ffi(
11386            value: ffi::WGPUSharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
11387        ) -> Self {
11388            Self {
11389                handle: Some(value.handle),
11390                size: Some(value.size),
11391            }
11392        }
11393    }
11394    pub struct SharedBufferMemoryBeginAccessDescriptor {
11395        pub(crate) extensions: Vec<SharedBufferMemoryBeginAccessDescriptorExtension>,
11396        pub initialized: Option<bool>,
11397        pub fences: Option<Vec<SharedFence>>,
11398        pub signaled_values: Option<Vec<u64>>,
11399    }
11400    impl Default for SharedBufferMemoryBeginAccessDescriptor {
11401        fn default() -> Self {
11402            Self {
11403                extensions: Vec::new(),
11404                initialized: None,
11405                fences: None,
11406                signaled_values: None,
11407            }
11408        }
11409    }
11410    impl SharedBufferMemoryBeginAccessDescriptor {
11411        pub fn new() -> Self {
11412            Self::default()
11413        }
11414        pub(crate) fn to_ffi(
11415            &self,
11416        ) -> (ffi::WGPUSharedBufferMemoryBeginAccessDescriptor, ChainedStructStorage) {
11417            let mut storage = ChainedStructStorage::new();
11418            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11419            for ext in self.extensions.iter().rev() {
11420                next = ext.push_chain(&mut storage, next);
11421            }
11422            let mut raw: ffi::WGPUSharedBufferMemoryBeginAccessDescriptor = unsafe {
11423                std::mem::zeroed()
11424            };
11425            raw.nextInChain = next;
11426            raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
11427            raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
11428            if let Some(values) = &self.fences {
11429                let len_value = values.len();
11430                let raw_vec: Vec<ffi::WGPUSharedFence> = values
11431                    .iter()
11432                    .map(|v| v.as_raw())
11433                    .collect();
11434                let ptr = storage.push_vec(raw_vec);
11435                raw.fences = ptr;
11436                raw.fenceCount = len_value;
11437            } else {
11438                raw.fences = std::ptr::null();
11439                raw.fenceCount = 0;
11440            }
11441            if let Some(values) = &self.signaled_values {
11442                let len_value = values.len();
11443                let raw_vec = values.to_vec();
11444                let ptr = storage.push_vec(raw_vec);
11445                raw.signaledValues = ptr;
11446                raw.fenceCount = len_value;
11447            } else {
11448                raw.signaledValues = std::ptr::null();
11449                raw.fenceCount = 0;
11450            }
11451            (raw, storage)
11452        }
11453        pub fn with_extension(
11454            mut self,
11455            extension: SharedBufferMemoryBeginAccessDescriptorExtension,
11456        ) -> Self {
11457            self.extensions.push(extension);
11458            self
11459        }
11460        pub(crate) fn from_ffi(
11461            value: ffi::WGPUSharedBufferMemoryBeginAccessDescriptor,
11462        ) -> Self {
11463            Self {
11464                extensions: Vec::new(),
11465                initialized: Some(value.initialized != 0),
11466                fences: if value.fences.is_null() {
11467                    None
11468                } else {
11469                    Some(
11470                        unsafe {
11471                            std::slice::from_raw_parts(
11472                                value.fences,
11473                                value.fenceCount as usize,
11474                            )
11475                        }
11476                            .iter()
11477                            .map(|raw| unsafe { SharedFence::from_raw(*raw) })
11478                            .collect(),
11479                    )
11480                },
11481                signaled_values: if value.signaledValues.is_null() {
11482                    None
11483                } else {
11484                    Some(
11485                        unsafe {
11486                            std::slice::from_raw_parts(
11487                                value.signaledValues,
11488                                value.fenceCount as usize,
11489                            )
11490                        }
11491                            .to_vec(),
11492                    )
11493                },
11494            }
11495        }
11496    }
11497    pub struct SharedBufferMemoryDescriptor {
11498        pub(crate) extensions: Vec<SharedBufferMemoryDescriptorExtension>,
11499        pub label: Option<String>,
11500    }
11501    impl Default for SharedBufferMemoryDescriptor {
11502        fn default() -> Self {
11503            Self {
11504                extensions: Vec::new(),
11505                label: None,
11506            }
11507        }
11508    }
11509    impl SharedBufferMemoryDescriptor {
11510        pub fn new() -> Self {
11511            Self::default()
11512        }
11513        pub(crate) fn to_ffi(
11514            &self,
11515        ) -> (ffi::WGPUSharedBufferMemoryDescriptor, ChainedStructStorage) {
11516            let mut storage = ChainedStructStorage::new();
11517            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11518            for ext in self.extensions.iter().rev() {
11519                next = ext.push_chain(&mut storage, next);
11520            }
11521            let mut raw: ffi::WGPUSharedBufferMemoryDescriptor = unsafe {
11522                std::mem::zeroed()
11523            };
11524            raw.nextInChain = next;
11525            if let Some(value) = &self.label {
11526                raw.label = ffi::WGPUStringView {
11527                    data: value.as_ptr().cast(),
11528                    length: value.len(),
11529                };
11530            } else {
11531                raw.label = ffi::WGPUStringView {
11532                    data: std::ptr::null(),
11533                    length: 0,
11534                };
11535            }
11536            (raw, storage)
11537        }
11538        pub fn with_extension(
11539            mut self,
11540            extension: SharedBufferMemoryDescriptorExtension,
11541        ) -> Self {
11542            self.extensions.push(extension);
11543            self
11544        }
11545        pub(crate) fn from_ffi(value: ffi::WGPUSharedBufferMemoryDescriptor) -> Self {
11546            Self {
11547                extensions: Vec::new(),
11548                label: if value.label.data.is_null() || value.label.length == 0 {
11549                    None
11550                } else {
11551                    Some(string_view_to_string(value.label))
11552                },
11553            }
11554        }
11555    }
11556    pub struct SharedBufferMemoryEndAccessState {
11557        pub(crate) extensions: Vec<SharedBufferMemoryEndAccessStateExtension>,
11558        pub initialized: Option<bool>,
11559        pub fences: Option<Vec<SharedFence>>,
11560        pub signaled_values: Option<Vec<u64>>,
11561        #[doc(hidden)]
11562        pub(crate) _free_members: Option<ffi::WGPUSharedBufferMemoryEndAccessState>,
11563    }
11564    impl Default for SharedBufferMemoryEndAccessState {
11565        fn default() -> Self {
11566            Self {
11567                extensions: Vec::new(),
11568                initialized: None,
11569                fences: None,
11570                signaled_values: None,
11571                _free_members: None,
11572            }
11573        }
11574    }
11575    impl SharedBufferMemoryEndAccessState {
11576        pub fn new() -> Self {
11577            Self::default()
11578        }
11579        pub(crate) fn to_ffi(
11580            &self,
11581        ) -> (ffi::WGPUSharedBufferMemoryEndAccessState, ChainedStructStorage) {
11582            let mut storage = ChainedStructStorage::new();
11583            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11584            for ext in self.extensions.iter().rev() {
11585                next = ext.push_chain(&mut storage, next);
11586            }
11587            let mut raw: ffi::WGPUSharedBufferMemoryEndAccessState = unsafe {
11588                std::mem::zeroed()
11589            };
11590            raw.nextInChain = next;
11591            raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
11592            raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
11593            if let Some(values) = &self.fences {
11594                let len_value = values.len();
11595                let raw_vec: Vec<ffi::WGPUSharedFence> = values
11596                    .iter()
11597                    .map(|v| v.as_raw())
11598                    .collect();
11599                let ptr = storage.push_vec(raw_vec);
11600                raw.fences = ptr;
11601                raw.fenceCount = len_value;
11602            } else {
11603                raw.fences = std::ptr::null();
11604                raw.fenceCount = 0;
11605            }
11606            if let Some(values) = &self.signaled_values {
11607                let len_value = values.len();
11608                let raw_vec = values.to_vec();
11609                let ptr = storage.push_vec(raw_vec);
11610                raw.signaledValues = ptr;
11611                raw.fenceCount = len_value;
11612            } else {
11613                raw.signaledValues = std::ptr::null();
11614                raw.fenceCount = 0;
11615            }
11616            (raw, storage)
11617        }
11618        pub fn with_extension(
11619            mut self,
11620            extension: SharedBufferMemoryEndAccessStateExtension,
11621        ) -> Self {
11622            self.extensions.push(extension);
11623            self
11624        }
11625        pub(crate) fn from_ffi(
11626            value: ffi::WGPUSharedBufferMemoryEndAccessState,
11627        ) -> Self {
11628            Self {
11629                extensions: Vec::new(),
11630                initialized: Some(value.initialized != 0),
11631                fences: if value.fences.is_null() {
11632                    None
11633                } else {
11634                    Some(
11635                        unsafe {
11636                            std::slice::from_raw_parts(
11637                                value.fences,
11638                                value.fenceCount as usize,
11639                            )
11640                        }
11641                            .iter()
11642                            .map(|raw| unsafe { SharedFence::from_raw(*raw) })
11643                            .collect(),
11644                    )
11645                },
11646                signaled_values: if value.signaledValues.is_null() {
11647                    None
11648                } else {
11649                    Some(
11650                        unsafe {
11651                            std::slice::from_raw_parts(
11652                                value.signaledValues,
11653                                value.fenceCount as usize,
11654                            )
11655                        }
11656                            .to_vec(),
11657                    )
11658                },
11659                _free_members: Some(value),
11660            }
11661        }
11662        pub(crate) fn free_members(value: ffi::WGPUSharedBufferMemoryEndAccessState) {
11663            unsafe { ffi::wgpuSharedBufferMemoryEndAccessStateFreeMembers(value) };
11664        }
11665    }
11666    impl Drop for SharedBufferMemoryEndAccessState {
11667        fn drop(&mut self) {
11668            if let Some(value) = self._free_members.take() {
11669                unsafe { ffi::wgpuSharedBufferMemoryEndAccessStateFreeMembers(value) };
11670            }
11671        }
11672    }
11673    pub struct SharedBufferMemoryProperties {
11674        pub(crate) extensions: Vec<SharedBufferMemoryPropertiesExtension>,
11675        pub usage: Option<BufferUsage>,
11676        pub size: Option<u64>,
11677    }
11678    impl Default for SharedBufferMemoryProperties {
11679        fn default() -> Self {
11680            Self {
11681                extensions: Vec::new(),
11682                usage: None,
11683                size: None,
11684            }
11685        }
11686    }
11687    impl SharedBufferMemoryProperties {
11688        pub fn new() -> Self {
11689            Self::default()
11690        }
11691        pub(crate) fn to_ffi(
11692            &self,
11693        ) -> (ffi::WGPUSharedBufferMemoryProperties, ChainedStructStorage) {
11694            let mut storage = ChainedStructStorage::new();
11695            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11696            for ext in self.extensions.iter().rev() {
11697                next = ext.push_chain(&mut storage, next);
11698            }
11699            let mut raw: ffi::WGPUSharedBufferMemoryProperties = unsafe {
11700                std::mem::zeroed()
11701            };
11702            raw.nextInChain = next;
11703            if let Some(value) = self.usage {
11704                raw.usage = value.into();
11705            } else {
11706                raw.usage = 0 as ffi::WGPUBufferUsage;
11707            }
11708            if let Some(value) = self.size {
11709                raw.size = value;
11710            }
11711            (raw, storage)
11712        }
11713        pub fn with_extension(
11714            mut self,
11715            extension: SharedBufferMemoryPropertiesExtension,
11716        ) -> Self {
11717            self.extensions.push(extension);
11718            self
11719        }
11720        pub(crate) fn from_ffi(value: ffi::WGPUSharedBufferMemoryProperties) -> Self {
11721            Self {
11722                extensions: Vec::new(),
11723                usage: Some(value.usage.into()),
11724                size: Some(value.size),
11725            }
11726        }
11727    }
11728    pub struct SharedFenceDXGISharedHandleDescriptor {
11729        pub handle: Option<*mut std::ffi::c_void>,
11730    }
11731    impl Default for SharedFenceDXGISharedHandleDescriptor {
11732        fn default() -> Self {
11733            Self { handle: None }
11734        }
11735    }
11736    impl SharedFenceDXGISharedHandleDescriptor {
11737        pub fn new() -> Self {
11738            Self::default()
11739        }
11740        pub(crate) fn to_ffi(
11741            &self,
11742        ) -> (ffi::WGPUSharedFenceDXGISharedHandleDescriptor, ChainedStructStorage) {
11743            let mut storage = ChainedStructStorage::new();
11744            let mut raw: ffi::WGPUSharedFenceDXGISharedHandleDescriptor = unsafe {
11745                std::mem::zeroed()
11746            };
11747            if let Some(value) = self.handle {
11748                raw.handle = value;
11749            }
11750            (raw, storage)
11751        }
11752        pub(crate) fn from_ffi(
11753            value: ffi::WGPUSharedFenceDXGISharedHandleDescriptor,
11754        ) -> Self {
11755            Self { handle: Some(value.handle) }
11756        }
11757    }
11758    pub struct SharedFenceDXGISharedHandleExportInfo {
11759        pub handle: Option<*mut std::ffi::c_void>,
11760    }
11761    impl Default for SharedFenceDXGISharedHandleExportInfo {
11762        fn default() -> Self {
11763            Self { handle: None }
11764        }
11765    }
11766    impl SharedFenceDXGISharedHandleExportInfo {
11767        pub fn new() -> Self {
11768            Self::default()
11769        }
11770        pub(crate) fn to_ffi(
11771            &self,
11772        ) -> (ffi::WGPUSharedFenceDXGISharedHandleExportInfo, ChainedStructStorage) {
11773            let mut storage = ChainedStructStorage::new();
11774            let mut raw: ffi::WGPUSharedFenceDXGISharedHandleExportInfo = unsafe {
11775                std::mem::zeroed()
11776            };
11777            if let Some(value) = self.handle {
11778                raw.handle = value;
11779            }
11780            (raw, storage)
11781        }
11782        pub(crate) fn from_ffi(
11783            value: ffi::WGPUSharedFenceDXGISharedHandleExportInfo,
11784        ) -> Self {
11785            Self { handle: Some(value.handle) }
11786        }
11787    }
11788    pub struct SharedFenceEGLSyncDescriptor {
11789        pub sync: Option<*mut std::ffi::c_void>,
11790    }
11791    impl Default for SharedFenceEGLSyncDescriptor {
11792        fn default() -> Self {
11793            Self { sync: None }
11794        }
11795    }
11796    impl SharedFenceEGLSyncDescriptor {
11797        pub fn new() -> Self {
11798            Self::default()
11799        }
11800        pub(crate) fn to_ffi(
11801            &self,
11802        ) -> (ffi::WGPUSharedFenceEGLSyncDescriptor, ChainedStructStorage) {
11803            let mut storage = ChainedStructStorage::new();
11804            let mut raw: ffi::WGPUSharedFenceEGLSyncDescriptor = unsafe {
11805                std::mem::zeroed()
11806            };
11807            if let Some(value) = self.sync {
11808                raw.sync = value;
11809            }
11810            (raw, storage)
11811        }
11812        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceEGLSyncDescriptor) -> Self {
11813            Self { sync: Some(value.sync) }
11814        }
11815    }
11816    pub struct SharedFenceEGLSyncExportInfo {
11817        pub sync: Option<*mut std::ffi::c_void>,
11818    }
11819    impl Default for SharedFenceEGLSyncExportInfo {
11820        fn default() -> Self {
11821            Self { sync: None }
11822        }
11823    }
11824    impl SharedFenceEGLSyncExportInfo {
11825        pub fn new() -> Self {
11826            Self::default()
11827        }
11828        pub(crate) fn to_ffi(
11829            &self,
11830        ) -> (ffi::WGPUSharedFenceEGLSyncExportInfo, ChainedStructStorage) {
11831            let mut storage = ChainedStructStorage::new();
11832            let mut raw: ffi::WGPUSharedFenceEGLSyncExportInfo = unsafe {
11833                std::mem::zeroed()
11834            };
11835            if let Some(value) = self.sync {
11836                raw.sync = value;
11837            }
11838            (raw, storage)
11839        }
11840        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceEGLSyncExportInfo) -> Self {
11841            Self { sync: Some(value.sync) }
11842        }
11843    }
11844    pub struct SharedFenceMTLSharedEventDescriptor {
11845        pub shared_event: Option<*mut std::ffi::c_void>,
11846    }
11847    impl Default for SharedFenceMTLSharedEventDescriptor {
11848        fn default() -> Self {
11849            Self { shared_event: None }
11850        }
11851    }
11852    impl SharedFenceMTLSharedEventDescriptor {
11853        pub fn new() -> Self {
11854            Self::default()
11855        }
11856        pub(crate) fn to_ffi(
11857            &self,
11858        ) -> (ffi::WGPUSharedFenceMTLSharedEventDescriptor, ChainedStructStorage) {
11859            let mut storage = ChainedStructStorage::new();
11860            let mut raw: ffi::WGPUSharedFenceMTLSharedEventDescriptor = unsafe {
11861                std::mem::zeroed()
11862            };
11863            if let Some(value) = self.shared_event {
11864                raw.sharedEvent = value;
11865            }
11866            (raw, storage)
11867        }
11868        pub(crate) fn from_ffi(
11869            value: ffi::WGPUSharedFenceMTLSharedEventDescriptor,
11870        ) -> Self {
11871            Self {
11872                shared_event: Some(value.sharedEvent),
11873            }
11874        }
11875    }
11876    pub struct SharedFenceMTLSharedEventExportInfo {
11877        pub shared_event: Option<*mut std::ffi::c_void>,
11878    }
11879    impl Default for SharedFenceMTLSharedEventExportInfo {
11880        fn default() -> Self {
11881            Self { shared_event: None }
11882        }
11883    }
11884    impl SharedFenceMTLSharedEventExportInfo {
11885        pub fn new() -> Self {
11886            Self::default()
11887        }
11888        pub(crate) fn to_ffi(
11889            &self,
11890        ) -> (ffi::WGPUSharedFenceMTLSharedEventExportInfo, ChainedStructStorage) {
11891            let mut storage = ChainedStructStorage::new();
11892            let mut raw: ffi::WGPUSharedFenceMTLSharedEventExportInfo = unsafe {
11893                std::mem::zeroed()
11894            };
11895            if let Some(value) = self.shared_event {
11896                raw.sharedEvent = value;
11897            }
11898            (raw, storage)
11899        }
11900        pub(crate) fn from_ffi(
11901            value: ffi::WGPUSharedFenceMTLSharedEventExportInfo,
11902        ) -> Self {
11903            Self {
11904                shared_event: Some(value.sharedEvent),
11905            }
11906        }
11907    }
11908    pub struct SharedFenceDescriptor {
11909        pub(crate) extensions: Vec<SharedFenceDescriptorExtension>,
11910        pub label: Option<String>,
11911    }
11912    impl Default for SharedFenceDescriptor {
11913        fn default() -> Self {
11914            Self {
11915                extensions: Vec::new(),
11916                label: None,
11917            }
11918        }
11919    }
11920    impl SharedFenceDescriptor {
11921        pub fn new() -> Self {
11922            Self::default()
11923        }
11924        pub(crate) fn to_ffi(
11925            &self,
11926        ) -> (ffi::WGPUSharedFenceDescriptor, ChainedStructStorage) {
11927            let mut storage = ChainedStructStorage::new();
11928            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11929            for ext in self.extensions.iter().rev() {
11930                next = ext.push_chain(&mut storage, next);
11931            }
11932            let mut raw: ffi::WGPUSharedFenceDescriptor = unsafe { std::mem::zeroed() };
11933            raw.nextInChain = next;
11934            if let Some(value) = &self.label {
11935                raw.label = ffi::WGPUStringView {
11936                    data: value.as_ptr().cast(),
11937                    length: value.len(),
11938                };
11939            } else {
11940                raw.label = ffi::WGPUStringView {
11941                    data: std::ptr::null(),
11942                    length: 0,
11943                };
11944            }
11945            (raw, storage)
11946        }
11947        pub fn with_extension(
11948            mut self,
11949            extension: SharedFenceDescriptorExtension,
11950        ) -> Self {
11951            self.extensions.push(extension);
11952            self
11953        }
11954        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceDescriptor) -> Self {
11955            Self {
11956                extensions: Vec::new(),
11957                label: if value.label.data.is_null() || value.label.length == 0 {
11958                    None
11959                } else {
11960                    Some(string_view_to_string(value.label))
11961                },
11962            }
11963        }
11964    }
11965    pub struct SharedFenceExportInfo {
11966        pub(crate) extensions: Vec<SharedFenceExportInfoExtension>,
11967        pub r#type: Option<SharedFenceType>,
11968    }
11969    impl Default for SharedFenceExportInfo {
11970        fn default() -> Self {
11971            Self {
11972                extensions: Vec::new(),
11973                r#type: None,
11974            }
11975        }
11976    }
11977    impl SharedFenceExportInfo {
11978        pub fn new() -> Self {
11979            Self::default()
11980        }
11981        pub(crate) fn to_ffi(
11982            &self,
11983        ) -> (ffi::WGPUSharedFenceExportInfo, ChainedStructStorage) {
11984            let mut storage = ChainedStructStorage::new();
11985            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11986            for ext in self.extensions.iter().rev() {
11987                next = ext.push_chain(&mut storage, next);
11988            }
11989            let mut raw: ffi::WGPUSharedFenceExportInfo = unsafe { std::mem::zeroed() };
11990            raw.nextInChain = next;
11991            if let Some(value) = self.r#type {
11992                raw.type_ = value.into();
11993            } else {
11994                raw.type_ = 0 as ffi::WGPUSharedFenceType;
11995            }
11996            (raw, storage)
11997        }
11998        pub fn with_extension(
11999            mut self,
12000            extension: SharedFenceExportInfoExtension,
12001        ) -> Self {
12002            self.extensions.push(extension);
12003            self
12004        }
12005        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceExportInfo) -> Self {
12006            Self {
12007                extensions: Vec::new(),
12008                r#type: Some(value.type_.into()),
12009            }
12010        }
12011    }
12012    pub struct SharedFenceSyncFDDescriptor {
12013        pub handle: Option<i32>,
12014    }
12015    impl Default for SharedFenceSyncFDDescriptor {
12016        fn default() -> Self {
12017            Self { handle: None }
12018        }
12019    }
12020    impl SharedFenceSyncFDDescriptor {
12021        pub fn new() -> Self {
12022            Self::default()
12023        }
12024        pub(crate) fn to_ffi(
12025            &self,
12026        ) -> (ffi::WGPUSharedFenceSyncFDDescriptor, ChainedStructStorage) {
12027            let mut storage = ChainedStructStorage::new();
12028            let mut raw: ffi::WGPUSharedFenceSyncFDDescriptor = unsafe {
12029                std::mem::zeroed()
12030            };
12031            if let Some(value) = self.handle {
12032                raw.handle = value;
12033            }
12034            (raw, storage)
12035        }
12036        pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceSyncFDDescriptor) -> Self {
12037            Self { handle: Some(value.handle) }
12038        }
12039    }
12040    pub struct SharedFenceSyncFDExportInfo {
12041        pub handle: Option<i32>,
12042    }
12043    impl Default for SharedFenceSyncFDExportInfo {
12044        fn default() -> Self {
12045            Self { handle: None }
12046        }
12047    }
12048    impl SharedFenceSyncFDExportInfo {
12049        pub fn new() -> Self {
12050            Self::default()
12051        }
12052        pub(crate) fn to_ffi(
12053            &self,
12054        ) -> (ffi::WGPUSharedFenceSyncFDExportInfo, ChainedStructStorage) {
12055            let mut storage = ChainedStructStorage::new();
12056            let mut raw: ffi::WGPUSharedFenceSyncFDExportInfo = 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(value: ffi::WGPUSharedFenceSyncFDExportInfo) -> Self {
12065            Self { handle: Some(value.handle) }
12066        }
12067    }
12068    pub struct SharedFenceVkSemaphoreOpaqueFDDescriptor {
12069        pub handle: Option<i32>,
12070    }
12071    impl Default for SharedFenceVkSemaphoreOpaqueFDDescriptor {
12072        fn default() -> Self {
12073            Self { handle: None }
12074        }
12075    }
12076    impl SharedFenceVkSemaphoreOpaqueFDDescriptor {
12077        pub fn new() -> Self {
12078            Self::default()
12079        }
12080        pub(crate) fn to_ffi(
12081            &self,
12082        ) -> (ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor, ChainedStructStorage) {
12083            let mut storage = ChainedStructStorage::new();
12084            let mut raw: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor = unsafe {
12085                std::mem::zeroed()
12086            };
12087            if let Some(value) = self.handle {
12088                raw.handle = value;
12089            }
12090            (raw, storage)
12091        }
12092        pub(crate) fn from_ffi(
12093            value: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor,
12094        ) -> Self {
12095            Self { handle: Some(value.handle) }
12096        }
12097    }
12098    pub struct SharedFenceVkSemaphoreOpaqueFDExportInfo {
12099        pub handle: Option<i32>,
12100    }
12101    impl Default for SharedFenceVkSemaphoreOpaqueFDExportInfo {
12102        fn default() -> Self {
12103            Self { handle: None }
12104        }
12105    }
12106    impl SharedFenceVkSemaphoreOpaqueFDExportInfo {
12107        pub fn new() -> Self {
12108            Self::default()
12109        }
12110        pub(crate) fn to_ffi(
12111            &self,
12112        ) -> (ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo, ChainedStructStorage) {
12113            let mut storage = ChainedStructStorage::new();
12114            let mut raw: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo = unsafe {
12115                std::mem::zeroed()
12116            };
12117            if let Some(value) = self.handle {
12118                raw.handle = value;
12119            }
12120            (raw, storage)
12121        }
12122        pub(crate) fn from_ffi(
12123            value: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo,
12124        ) -> Self {
12125            Self { handle: Some(value.handle) }
12126        }
12127    }
12128    pub struct SharedFenceVkSemaphoreZirconHandleDescriptor {
12129        pub handle: Option<u32>,
12130    }
12131    impl Default for SharedFenceVkSemaphoreZirconHandleDescriptor {
12132        fn default() -> Self {
12133            Self { handle: None }
12134        }
12135    }
12136    impl SharedFenceVkSemaphoreZirconHandleDescriptor {
12137        pub fn new() -> Self {
12138            Self::default()
12139        }
12140        pub(crate) fn to_ffi(
12141            &self,
12142        ) -> (
12143            ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor,
12144            ChainedStructStorage,
12145        ) {
12146            let mut storage = ChainedStructStorage::new();
12147            let mut raw: ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor = unsafe {
12148                std::mem::zeroed()
12149            };
12150            if let Some(value) = self.handle {
12151                raw.handle = value;
12152            }
12153            (raw, storage)
12154        }
12155        pub(crate) fn from_ffi(
12156            value: ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor,
12157        ) -> Self {
12158            Self { handle: Some(value.handle) }
12159        }
12160    }
12161    pub struct SharedFenceVkSemaphoreZirconHandleExportInfo {
12162        pub handle: Option<u32>,
12163    }
12164    impl Default for SharedFenceVkSemaphoreZirconHandleExportInfo {
12165        fn default() -> Self {
12166            Self { handle: None }
12167        }
12168    }
12169    impl SharedFenceVkSemaphoreZirconHandleExportInfo {
12170        pub fn new() -> Self {
12171            Self::default()
12172        }
12173        pub(crate) fn to_ffi(
12174            &self,
12175        ) -> (
12176            ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo,
12177            ChainedStructStorage,
12178        ) {
12179            let mut storage = ChainedStructStorage::new();
12180            let mut raw: ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo = unsafe {
12181                std::mem::zeroed()
12182            };
12183            if let Some(value) = self.handle {
12184                raw.handle = value;
12185            }
12186            (raw, storage)
12187        }
12188        pub(crate) fn from_ffi(
12189            value: ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo,
12190        ) -> Self {
12191            Self { handle: Some(value.handle) }
12192        }
12193    }
12194    pub struct SharedTextureMemoryD3DSwapchainBeginState {
12195        pub is_swapchain: Option<bool>,
12196    }
12197    impl Default for SharedTextureMemoryD3DSwapchainBeginState {
12198        fn default() -> Self {
12199            Self { is_swapchain: None }
12200        }
12201    }
12202    impl SharedTextureMemoryD3DSwapchainBeginState {
12203        pub fn new() -> Self {
12204            Self::default()
12205        }
12206        pub(crate) fn to_ffi(
12207            &self,
12208        ) -> (ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState, ChainedStructStorage) {
12209            let mut storage = ChainedStructStorage::new();
12210            let mut raw: ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState = unsafe {
12211                std::mem::zeroed()
12212            };
12213            raw.isSwapchain = if self.is_swapchain.unwrap_or(false) { 1 } else { 0 };
12214            (raw, storage)
12215        }
12216        pub(crate) fn from_ffi(
12217            value: ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState,
12218        ) -> Self {
12219            Self {
12220                is_swapchain: Some(value.isSwapchain != 0),
12221            }
12222        }
12223    }
12224    pub struct SharedTextureMemoryD3D11BeginState {
12225        pub requires_end_access_fence: Option<bool>,
12226    }
12227    impl Default for SharedTextureMemoryD3D11BeginState {
12228        fn default() -> Self {
12229            Self {
12230                requires_end_access_fence: None,
12231            }
12232        }
12233    }
12234    impl SharedTextureMemoryD3D11BeginState {
12235        pub fn new() -> Self {
12236            Self::default()
12237        }
12238        pub(crate) fn to_ffi(
12239            &self,
12240        ) -> (ffi::WGPUSharedTextureMemoryD3D11BeginState, ChainedStructStorage) {
12241            let mut storage = ChainedStructStorage::new();
12242            let mut raw: ffi::WGPUSharedTextureMemoryD3D11BeginState = unsafe {
12243                std::mem::zeroed()
12244            };
12245            raw.requiresEndAccessFence = if self
12246                .requires_end_access_fence
12247                .unwrap_or(false)
12248            {
12249                1
12250            } else {
12251                0
12252            };
12253            (raw, storage)
12254        }
12255        pub(crate) fn from_ffi(
12256            value: ffi::WGPUSharedTextureMemoryD3D11BeginState,
12257        ) -> Self {
12258            Self {
12259                requires_end_access_fence: Some(value.requiresEndAccessFence != 0),
12260            }
12261        }
12262    }
12263    pub struct SharedTextureMemoryDXGISharedHandleDescriptor {
12264        pub handle: Option<*mut std::ffi::c_void>,
12265        pub use_keyed_mutex: Option<bool>,
12266    }
12267    impl Default for SharedTextureMemoryDXGISharedHandleDescriptor {
12268        fn default() -> Self {
12269            Self {
12270                handle: None,
12271                use_keyed_mutex: None,
12272            }
12273        }
12274    }
12275    impl SharedTextureMemoryDXGISharedHandleDescriptor {
12276        pub fn new() -> Self {
12277            Self::default()
12278        }
12279        pub(crate) fn to_ffi(
12280            &self,
12281        ) -> (
12282            ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor,
12283            ChainedStructStorage,
12284        ) {
12285            let mut storage = ChainedStructStorage::new();
12286            let mut raw: ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor = unsafe {
12287                std::mem::zeroed()
12288            };
12289            if let Some(value) = self.handle {
12290                raw.handle = value;
12291            }
12292            raw.useKeyedMutex = if self.use_keyed_mutex.unwrap_or(false) {
12293                1
12294            } else {
12295                0
12296            };
12297            (raw, storage)
12298        }
12299        pub(crate) fn from_ffi(
12300            value: ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor,
12301        ) -> Self {
12302            Self {
12303                handle: Some(value.handle),
12304                use_keyed_mutex: Some(value.useKeyedMutex != 0),
12305            }
12306        }
12307    }
12308    pub struct SharedTextureMemoryEGLImageDescriptor {
12309        pub image: Option<*mut std::ffi::c_void>,
12310    }
12311    impl Default for SharedTextureMemoryEGLImageDescriptor {
12312        fn default() -> Self {
12313            Self { image: None }
12314        }
12315    }
12316    impl SharedTextureMemoryEGLImageDescriptor {
12317        pub fn new() -> Self {
12318            Self::default()
12319        }
12320        pub(crate) fn to_ffi(
12321            &self,
12322        ) -> (ffi::WGPUSharedTextureMemoryEGLImageDescriptor, ChainedStructStorage) {
12323            let mut storage = ChainedStructStorage::new();
12324            let mut raw: ffi::WGPUSharedTextureMemoryEGLImageDescriptor = unsafe {
12325                std::mem::zeroed()
12326            };
12327            if let Some(value) = self.image {
12328                raw.image = value;
12329            }
12330            (raw, storage)
12331        }
12332        pub(crate) fn from_ffi(
12333            value: ffi::WGPUSharedTextureMemoryEGLImageDescriptor,
12334        ) -> Self {
12335            Self { image: Some(value.image) }
12336        }
12337    }
12338    pub struct SharedTextureMemoryIOSurfaceDescriptor {
12339        pub io_surface: Option<*mut std::ffi::c_void>,
12340        pub allow_storage_binding: Option<bool>,
12341    }
12342    impl Default for SharedTextureMemoryIOSurfaceDescriptor {
12343        fn default() -> Self {
12344            Self {
12345                io_surface: None,
12346                allow_storage_binding: None,
12347            }
12348        }
12349    }
12350    impl SharedTextureMemoryIOSurfaceDescriptor {
12351        pub fn new() -> Self {
12352            Self::default()
12353        }
12354        pub(crate) fn to_ffi(
12355            &self,
12356        ) -> (ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor, ChainedStructStorage) {
12357            let mut storage = ChainedStructStorage::new();
12358            let mut raw: ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor = unsafe {
12359                std::mem::zeroed()
12360            };
12361            if let Some(value) = self.io_surface {
12362                raw.ioSurface = value;
12363            }
12364            raw.allowStorageBinding = if self.allow_storage_binding.unwrap_or(false) {
12365                1
12366            } else {
12367                0
12368            };
12369            (raw, storage)
12370        }
12371        pub(crate) fn from_ffi(
12372            value: ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor,
12373        ) -> Self {
12374            Self {
12375                io_surface: Some(value.ioSurface),
12376                allow_storage_binding: Some(value.allowStorageBinding != 0),
12377            }
12378        }
12379    }
12380    pub struct SharedTextureMemoryAHardwareBufferDescriptor {
12381        pub handle: Option<*mut std::ffi::c_void>,
12382    }
12383    impl Default for SharedTextureMemoryAHardwareBufferDescriptor {
12384        fn default() -> Self {
12385            Self { handle: None }
12386        }
12387    }
12388    impl SharedTextureMemoryAHardwareBufferDescriptor {
12389        pub fn new() -> Self {
12390            Self::default()
12391        }
12392        pub(crate) fn to_ffi(
12393            &self,
12394        ) -> (
12395            ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor,
12396            ChainedStructStorage,
12397        ) {
12398            let mut storage = ChainedStructStorage::new();
12399            let mut raw: ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor = unsafe {
12400                std::mem::zeroed()
12401            };
12402            if let Some(value) = self.handle {
12403                raw.handle = value;
12404            }
12405            (raw, storage)
12406        }
12407        pub(crate) fn from_ffi(
12408            value: ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor,
12409        ) -> Self {
12410            Self { handle: Some(value.handle) }
12411        }
12412    }
12413    pub struct SharedTextureMemoryAHardwareBufferProperties {
12414        pub y_cb_cr_info: Option<YCbCrVkDescriptor>,
12415    }
12416    impl Default for SharedTextureMemoryAHardwareBufferProperties {
12417        fn default() -> Self {
12418            Self { y_cb_cr_info: None }
12419        }
12420    }
12421    impl SharedTextureMemoryAHardwareBufferProperties {
12422        pub fn new() -> Self {
12423            Self::default()
12424        }
12425        pub(crate) fn to_ffi(
12426            &self,
12427        ) -> (
12428            ffi::WGPUSharedTextureMemoryAHardwareBufferProperties,
12429            ChainedStructStorage,
12430        ) {
12431            let mut storage = ChainedStructStorage::new();
12432            let mut raw: ffi::WGPUSharedTextureMemoryAHardwareBufferProperties = unsafe {
12433                std::mem::zeroed()
12434            };
12435            if let Some(value) = &self.y_cb_cr_info {
12436                let (raw_value, storage_value) = value.to_ffi();
12437                raw.yCbCrInfo = raw_value;
12438                storage.push_storage(storage_value);
12439            }
12440            (raw, storage)
12441        }
12442        pub(crate) fn from_ffi(
12443            value: ffi::WGPUSharedTextureMemoryAHardwareBufferProperties,
12444        ) -> Self {
12445            Self {
12446                y_cb_cr_info: Some(YCbCrVkDescriptor::from_ffi(value.yCbCrInfo)),
12447            }
12448        }
12449    }
12450    pub struct SharedTextureMemoryBeginAccessDescriptor {
12451        pub(crate) extensions: Vec<SharedTextureMemoryBeginAccessDescriptorExtension>,
12452        pub concurrent_read: Option<bool>,
12453        pub initialized: Option<bool>,
12454        pub fences: Option<Vec<SharedFence>>,
12455        pub signaled_values: Option<Vec<u64>>,
12456    }
12457    impl Default for SharedTextureMemoryBeginAccessDescriptor {
12458        fn default() -> Self {
12459            Self {
12460                extensions: Vec::new(),
12461                concurrent_read: None,
12462                initialized: None,
12463                fences: None,
12464                signaled_values: None,
12465            }
12466        }
12467    }
12468    impl SharedTextureMemoryBeginAccessDescriptor {
12469        pub fn new() -> Self {
12470            Self::default()
12471        }
12472        pub(crate) fn to_ffi(
12473            &self,
12474        ) -> (ffi::WGPUSharedTextureMemoryBeginAccessDescriptor, ChainedStructStorage) {
12475            let mut storage = ChainedStructStorage::new();
12476            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12477            for ext in self.extensions.iter().rev() {
12478                next = ext.push_chain(&mut storage, next);
12479            }
12480            let mut raw: ffi::WGPUSharedTextureMemoryBeginAccessDescriptor = unsafe {
12481                std::mem::zeroed()
12482            };
12483            raw.nextInChain = next;
12484            raw.concurrentRead = if self.concurrent_read.unwrap_or(false) {
12485                1
12486            } else {
12487                0
12488            };
12489            raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
12490            raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
12491            if let Some(values) = &self.fences {
12492                let len_value = values.len();
12493                let raw_vec: Vec<ffi::WGPUSharedFence> = values
12494                    .iter()
12495                    .map(|v| v.as_raw())
12496                    .collect();
12497                let ptr = storage.push_vec(raw_vec);
12498                raw.fences = ptr;
12499                raw.fenceCount = len_value;
12500            } else {
12501                raw.fences = std::ptr::null();
12502                raw.fenceCount = 0;
12503            }
12504            if let Some(values) = &self.signaled_values {
12505                let len_value = values.len();
12506                let raw_vec = values.to_vec();
12507                let ptr = storage.push_vec(raw_vec);
12508                raw.signaledValues = ptr;
12509                raw.fenceCount = len_value;
12510            } else {
12511                raw.signaledValues = std::ptr::null();
12512                raw.fenceCount = 0;
12513            }
12514            (raw, storage)
12515        }
12516        pub fn with_extension(
12517            mut self,
12518            extension: SharedTextureMemoryBeginAccessDescriptorExtension,
12519        ) -> Self {
12520            self.extensions.push(extension);
12521            self
12522        }
12523        pub(crate) fn from_ffi(
12524            value: ffi::WGPUSharedTextureMemoryBeginAccessDescriptor,
12525        ) -> Self {
12526            Self {
12527                extensions: Vec::new(),
12528                concurrent_read: Some(value.concurrentRead != 0),
12529                initialized: Some(value.initialized != 0),
12530                fences: if value.fences.is_null() {
12531                    None
12532                } else {
12533                    Some(
12534                        unsafe {
12535                            std::slice::from_raw_parts(
12536                                value.fences,
12537                                value.fenceCount as usize,
12538                            )
12539                        }
12540                            .iter()
12541                            .map(|raw| unsafe { SharedFence::from_raw(*raw) })
12542                            .collect(),
12543                    )
12544                },
12545                signaled_values: if value.signaledValues.is_null() {
12546                    None
12547                } else {
12548                    Some(
12549                        unsafe {
12550                            std::slice::from_raw_parts(
12551                                value.signaledValues,
12552                                value.fenceCount as usize,
12553                            )
12554                        }
12555                            .to_vec(),
12556                    )
12557                },
12558            }
12559        }
12560    }
12561    pub struct SharedTextureMemoryDescriptor {
12562        pub(crate) extensions: Vec<SharedTextureMemoryDescriptorExtension>,
12563        pub label: Option<String>,
12564    }
12565    impl Default for SharedTextureMemoryDescriptor {
12566        fn default() -> Self {
12567            Self {
12568                extensions: Vec::new(),
12569                label: None,
12570            }
12571        }
12572    }
12573    impl SharedTextureMemoryDescriptor {
12574        pub fn new() -> Self {
12575            Self::default()
12576        }
12577        pub(crate) fn to_ffi(
12578            &self,
12579        ) -> (ffi::WGPUSharedTextureMemoryDescriptor, ChainedStructStorage) {
12580            let mut storage = ChainedStructStorage::new();
12581            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12582            for ext in self.extensions.iter().rev() {
12583                next = ext.push_chain(&mut storage, next);
12584            }
12585            let mut raw: ffi::WGPUSharedTextureMemoryDescriptor = unsafe {
12586                std::mem::zeroed()
12587            };
12588            raw.nextInChain = next;
12589            if let Some(value) = &self.label {
12590                raw.label = ffi::WGPUStringView {
12591                    data: value.as_ptr().cast(),
12592                    length: value.len(),
12593                };
12594            } else {
12595                raw.label = ffi::WGPUStringView {
12596                    data: std::ptr::null(),
12597                    length: 0,
12598                };
12599            }
12600            (raw, storage)
12601        }
12602        pub fn with_extension(
12603            mut self,
12604            extension: SharedTextureMemoryDescriptorExtension,
12605        ) -> Self {
12606            self.extensions.push(extension);
12607            self
12608        }
12609        pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryDescriptor) -> Self {
12610            Self {
12611                extensions: Vec::new(),
12612                label: if value.label.data.is_null() || value.label.length == 0 {
12613                    None
12614                } else {
12615                    Some(string_view_to_string(value.label))
12616                },
12617            }
12618        }
12619    }
12620    pub struct SharedTextureMemoryDmaBufDescriptor {
12621        pub size: Option<Extent3D>,
12622        pub drm_format: Option<u32>,
12623        pub drm_modifier: Option<u64>,
12624        pub planes: Option<Vec<SharedTextureMemoryDmaBufPlane>>,
12625    }
12626    impl Default for SharedTextureMemoryDmaBufDescriptor {
12627        fn default() -> Self {
12628            Self {
12629                size: None,
12630                drm_format: None,
12631                drm_modifier: None,
12632                planes: None,
12633            }
12634        }
12635    }
12636    impl SharedTextureMemoryDmaBufDescriptor {
12637        pub fn new() -> Self {
12638            Self::default()
12639        }
12640        pub(crate) fn to_ffi(
12641            &self,
12642        ) -> (ffi::WGPUSharedTextureMemoryDmaBufDescriptor, ChainedStructStorage) {
12643            let mut storage = ChainedStructStorage::new();
12644            let mut raw: ffi::WGPUSharedTextureMemoryDmaBufDescriptor = unsafe {
12645                std::mem::zeroed()
12646            };
12647            if let Some(value) = &self.size {
12648                let (raw_value, storage_value) = value.to_ffi();
12649                raw.size = raw_value;
12650                storage.push_storage(storage_value);
12651            }
12652            if let Some(value) = self.drm_format {
12653                raw.drmFormat = value;
12654            }
12655            if let Some(value) = self.drm_modifier {
12656                raw.drmModifier = value;
12657            }
12658            raw.planeCount = self.planes.as_ref().map(|v| v.len()).unwrap_or(0);
12659            if let Some(values) = &self.planes {
12660                let len_value = values.len();
12661                let mut raw_vec: Vec<ffi::WGPUSharedTextureMemoryDmaBufPlane> = Vec::with_capacity(
12662                    values.len(),
12663                );
12664                for item in values.iter() {
12665                    let (raw_item, storage_item) = item.to_ffi();
12666                    raw_vec.push(raw_item);
12667                    storage.push_storage(storage_item);
12668                }
12669                let ptr = storage.push_vec(raw_vec);
12670                raw.planes = ptr;
12671                raw.planeCount = len_value;
12672            } else {
12673                raw.planes = std::ptr::null();
12674                raw.planeCount = 0;
12675            }
12676            (raw, storage)
12677        }
12678        pub(crate) fn from_ffi(
12679            value: ffi::WGPUSharedTextureMemoryDmaBufDescriptor,
12680        ) -> Self {
12681            Self {
12682                size: Some(Extent3D::from_ffi(value.size)),
12683                drm_format: Some(value.drmFormat),
12684                drm_modifier: Some(value.drmModifier),
12685                planes: if value.planes.is_null() {
12686                    None
12687                } else {
12688                    Some(
12689                        unsafe {
12690                            std::slice::from_raw_parts(
12691                                value.planes,
12692                                value.planeCount as usize,
12693                            )
12694                        }
12695                            .iter()
12696                            .map(|raw| SharedTextureMemoryDmaBufPlane::from_ffi(*raw))
12697                            .collect(),
12698                    )
12699                },
12700            }
12701        }
12702    }
12703    pub struct SharedTextureMemoryDmaBufPlane {
12704        pub fd: Option<i32>,
12705        pub offset: Option<u64>,
12706        pub stride: Option<u32>,
12707    }
12708    impl Default for SharedTextureMemoryDmaBufPlane {
12709        fn default() -> Self {
12710            Self {
12711                fd: None,
12712                offset: None,
12713                stride: None,
12714            }
12715        }
12716    }
12717    impl SharedTextureMemoryDmaBufPlane {
12718        pub fn new() -> Self {
12719            Self::default()
12720        }
12721        pub(crate) fn to_ffi(
12722            &self,
12723        ) -> (ffi::WGPUSharedTextureMemoryDmaBufPlane, ChainedStructStorage) {
12724            let mut storage = ChainedStructStorage::new();
12725            let mut raw: ffi::WGPUSharedTextureMemoryDmaBufPlane = unsafe {
12726                std::mem::zeroed()
12727            };
12728            if let Some(value) = self.fd {
12729                raw.fd = value;
12730            }
12731            if let Some(value) = self.offset {
12732                raw.offset = value;
12733            }
12734            if let Some(value) = self.stride {
12735                raw.stride = value;
12736            }
12737            (raw, storage)
12738        }
12739        pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryDmaBufPlane) -> Self {
12740            Self {
12741                fd: Some(value.fd),
12742                offset: Some(value.offset),
12743                stride: Some(value.stride),
12744            }
12745        }
12746    }
12747    pub struct SharedTextureMemoryEndAccessState {
12748        pub(crate) extensions: Vec<SharedTextureMemoryEndAccessStateExtension>,
12749        pub initialized: Option<bool>,
12750        pub fences: Option<Vec<SharedFence>>,
12751        pub signaled_values: Option<Vec<u64>>,
12752        #[doc(hidden)]
12753        pub(crate) _free_members: Option<ffi::WGPUSharedTextureMemoryEndAccessState>,
12754    }
12755    impl Default for SharedTextureMemoryEndAccessState {
12756        fn default() -> Self {
12757            Self {
12758                extensions: Vec::new(),
12759                initialized: None,
12760                fences: None,
12761                signaled_values: None,
12762                _free_members: None,
12763            }
12764        }
12765    }
12766    impl SharedTextureMemoryEndAccessState {
12767        pub fn new() -> Self {
12768            Self::default()
12769        }
12770        pub(crate) fn to_ffi(
12771            &self,
12772        ) -> (ffi::WGPUSharedTextureMemoryEndAccessState, ChainedStructStorage) {
12773            let mut storage = ChainedStructStorage::new();
12774            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12775            for ext in self.extensions.iter().rev() {
12776                next = ext.push_chain(&mut storage, next);
12777            }
12778            let mut raw: ffi::WGPUSharedTextureMemoryEndAccessState = unsafe {
12779                std::mem::zeroed()
12780            };
12781            raw.nextInChain = next;
12782            raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
12783            raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
12784            if let Some(values) = &self.fences {
12785                let len_value = values.len();
12786                let raw_vec: Vec<ffi::WGPUSharedFence> = values
12787                    .iter()
12788                    .map(|v| v.as_raw())
12789                    .collect();
12790                let ptr = storage.push_vec(raw_vec);
12791                raw.fences = ptr;
12792                raw.fenceCount = len_value;
12793            } else {
12794                raw.fences = std::ptr::null();
12795                raw.fenceCount = 0;
12796            }
12797            if let Some(values) = &self.signaled_values {
12798                let len_value = values.len();
12799                let raw_vec = values.to_vec();
12800                let ptr = storage.push_vec(raw_vec);
12801                raw.signaledValues = ptr;
12802                raw.fenceCount = len_value;
12803            } else {
12804                raw.signaledValues = std::ptr::null();
12805                raw.fenceCount = 0;
12806            }
12807            (raw, storage)
12808        }
12809        pub fn with_extension(
12810            mut self,
12811            extension: SharedTextureMemoryEndAccessStateExtension,
12812        ) -> Self {
12813            self.extensions.push(extension);
12814            self
12815        }
12816        pub(crate) fn from_ffi(
12817            value: ffi::WGPUSharedTextureMemoryEndAccessState,
12818        ) -> Self {
12819            Self {
12820                extensions: Vec::new(),
12821                initialized: Some(value.initialized != 0),
12822                fences: if value.fences.is_null() {
12823                    None
12824                } else {
12825                    Some(
12826                        unsafe {
12827                            std::slice::from_raw_parts(
12828                                value.fences,
12829                                value.fenceCount as usize,
12830                            )
12831                        }
12832                            .iter()
12833                            .map(|raw| unsafe { SharedFence::from_raw(*raw) })
12834                            .collect(),
12835                    )
12836                },
12837                signaled_values: if value.signaledValues.is_null() {
12838                    None
12839                } else {
12840                    Some(
12841                        unsafe {
12842                            std::slice::from_raw_parts(
12843                                value.signaledValues,
12844                                value.fenceCount as usize,
12845                            )
12846                        }
12847                            .to_vec(),
12848                    )
12849                },
12850                _free_members: Some(value),
12851            }
12852        }
12853        pub(crate) fn free_members(value: ffi::WGPUSharedTextureMemoryEndAccessState) {
12854            unsafe { ffi::wgpuSharedTextureMemoryEndAccessStateFreeMembers(value) };
12855        }
12856    }
12857    impl Drop for SharedTextureMemoryEndAccessState {
12858        fn drop(&mut self) {
12859            if let Some(value) = self._free_members.take() {
12860                unsafe { ffi::wgpuSharedTextureMemoryEndAccessStateFreeMembers(value) };
12861            }
12862        }
12863    }
12864    pub struct SharedTextureMemoryMetalEndAccessState {
12865        pub commands_scheduled_future: Option<Future>,
12866    }
12867    impl Default for SharedTextureMemoryMetalEndAccessState {
12868        fn default() -> Self {
12869            Self {
12870                commands_scheduled_future: None,
12871            }
12872        }
12873    }
12874    impl SharedTextureMemoryMetalEndAccessState {
12875        pub fn new() -> Self {
12876            Self::default()
12877        }
12878        pub(crate) fn to_ffi(
12879            &self,
12880        ) -> (ffi::WGPUSharedTextureMemoryMetalEndAccessState, ChainedStructStorage) {
12881            let mut storage = ChainedStructStorage::new();
12882            let mut raw: ffi::WGPUSharedTextureMemoryMetalEndAccessState = unsafe {
12883                std::mem::zeroed()
12884            };
12885            if let Some(value) = &self.commands_scheduled_future {
12886                let (raw_value, storage_value) = value.to_ffi();
12887                raw.commandsScheduledFuture = raw_value;
12888                storage.push_storage(storage_value);
12889            }
12890            (raw, storage)
12891        }
12892        pub(crate) fn from_ffi(
12893            value: ffi::WGPUSharedTextureMemoryMetalEndAccessState,
12894        ) -> Self {
12895            Self {
12896                commands_scheduled_future: Some(
12897                    Future::from_ffi(value.commandsScheduledFuture),
12898                ),
12899            }
12900        }
12901    }
12902    pub struct SharedTextureMemoryOpaqueFDDescriptor {
12903        pub vk_image_create_info: Option<*const std::ffi::c_void>,
12904        pub memory_fd: Option<i32>,
12905        pub memory_type_index: Option<u32>,
12906        pub allocation_size: Option<u64>,
12907        pub dedicated_allocation: Option<bool>,
12908    }
12909    impl Default for SharedTextureMemoryOpaqueFDDescriptor {
12910        fn default() -> Self {
12911            Self {
12912                vk_image_create_info: None,
12913                memory_fd: None,
12914                memory_type_index: None,
12915                allocation_size: None,
12916                dedicated_allocation: None,
12917            }
12918        }
12919    }
12920    impl SharedTextureMemoryOpaqueFDDescriptor {
12921        pub fn new() -> Self {
12922            Self::default()
12923        }
12924        pub(crate) fn to_ffi(
12925            &self,
12926        ) -> (ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor, ChainedStructStorage) {
12927            let mut storage = ChainedStructStorage::new();
12928            let mut raw: ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor = unsafe {
12929                std::mem::zeroed()
12930            };
12931            if let Some(value) = self.vk_image_create_info {
12932                raw.vkImageCreateInfo = value;
12933            }
12934            if let Some(value) = self.memory_fd {
12935                raw.memoryFD = value;
12936            }
12937            if let Some(value) = self.memory_type_index {
12938                raw.memoryTypeIndex = value;
12939            }
12940            if let Some(value) = self.allocation_size {
12941                raw.allocationSize = value;
12942            }
12943            raw.dedicatedAllocation = if self.dedicated_allocation.unwrap_or(false) {
12944                1
12945            } else {
12946                0
12947            };
12948            (raw, storage)
12949        }
12950        pub(crate) fn from_ffi(
12951            value: ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor,
12952        ) -> Self {
12953            Self {
12954                vk_image_create_info: Some(value.vkImageCreateInfo),
12955                memory_fd: Some(value.memoryFD),
12956                memory_type_index: Some(value.memoryTypeIndex),
12957                allocation_size: Some(value.allocationSize),
12958                dedicated_allocation: Some(value.dedicatedAllocation != 0),
12959            }
12960        }
12961    }
12962    pub struct SharedTextureMemoryProperties {
12963        pub(crate) extensions: Vec<SharedTextureMemoryPropertiesExtension>,
12964        pub usage: Option<TextureUsage>,
12965        pub size: Option<Extent3D>,
12966        pub format: Option<TextureFormat>,
12967    }
12968    impl Default for SharedTextureMemoryProperties {
12969        fn default() -> Self {
12970            Self {
12971                extensions: Vec::new(),
12972                usage: None,
12973                size: None,
12974                format: None,
12975            }
12976        }
12977    }
12978    impl SharedTextureMemoryProperties {
12979        pub fn new() -> Self {
12980            Self::default()
12981        }
12982        pub(crate) fn to_ffi(
12983            &self,
12984        ) -> (ffi::WGPUSharedTextureMemoryProperties, ChainedStructStorage) {
12985            let mut storage = ChainedStructStorage::new();
12986            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12987            for ext in self.extensions.iter().rev() {
12988                next = ext.push_chain(&mut storage, next);
12989            }
12990            let mut raw: ffi::WGPUSharedTextureMemoryProperties = unsafe {
12991                std::mem::zeroed()
12992            };
12993            raw.nextInChain = next;
12994            if let Some(value) = self.usage {
12995                raw.usage = value.into();
12996            } else {
12997                raw.usage = 0 as ffi::WGPUTextureUsage;
12998            }
12999            if let Some(value) = &self.size {
13000                let (raw_value, storage_value) = value.to_ffi();
13001                raw.size = raw_value;
13002                storage.push_storage(storage_value);
13003            }
13004            if let Some(value) = self.format {
13005                raw.format = value.into();
13006            } else {
13007                raw.format = 0 as ffi::WGPUTextureFormat;
13008            }
13009            (raw, storage)
13010        }
13011        pub fn with_extension(
13012            mut self,
13013            extension: SharedTextureMemoryPropertiesExtension,
13014        ) -> Self {
13015            self.extensions.push(extension);
13016            self
13017        }
13018        pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryProperties) -> Self {
13019            Self {
13020                extensions: Vec::new(),
13021                usage: Some(value.usage.into()),
13022                size: Some(Extent3D::from_ffi(value.size)),
13023                format: Some(value.format.into()),
13024            }
13025        }
13026    }
13027    pub struct SharedTextureMemoryVkDedicatedAllocationDescriptor {
13028        pub dedicated_allocation: Option<bool>,
13029    }
13030    impl Default for SharedTextureMemoryVkDedicatedAllocationDescriptor {
13031        fn default() -> Self {
13032            Self { dedicated_allocation: None }
13033        }
13034    }
13035    impl SharedTextureMemoryVkDedicatedAllocationDescriptor {
13036        pub fn new() -> Self {
13037            Self::default()
13038        }
13039        pub(crate) fn to_ffi(
13040            &self,
13041        ) -> (
13042            ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor,
13043            ChainedStructStorage,
13044        ) {
13045            let mut storage = ChainedStructStorage::new();
13046            let mut raw: ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor = unsafe {
13047                std::mem::zeroed()
13048            };
13049            raw.dedicatedAllocation = if self.dedicated_allocation.unwrap_or(false) {
13050                1
13051            } else {
13052                0
13053            };
13054            (raw, storage)
13055        }
13056        pub(crate) fn from_ffi(
13057            value: ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor,
13058        ) -> Self {
13059            Self {
13060                dedicated_allocation: Some(value.dedicatedAllocation != 0),
13061            }
13062        }
13063    }
13064    pub struct SharedTextureMemoryVkImageLayoutBeginState {
13065        pub old_layout: Option<i32>,
13066        pub new_layout: Option<i32>,
13067    }
13068    impl Default for SharedTextureMemoryVkImageLayoutBeginState {
13069        fn default() -> Self {
13070            Self {
13071                old_layout: None,
13072                new_layout: None,
13073            }
13074        }
13075    }
13076    impl SharedTextureMemoryVkImageLayoutBeginState {
13077        pub fn new() -> Self {
13078            Self::default()
13079        }
13080        pub(crate) fn to_ffi(
13081            &self,
13082        ) -> (
13083            ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState,
13084            ChainedStructStorage,
13085        ) {
13086            let mut storage = ChainedStructStorage::new();
13087            let mut raw: ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState = unsafe {
13088                std::mem::zeroed()
13089            };
13090            if let Some(value) = self.old_layout {
13091                raw.oldLayout = value;
13092            }
13093            if let Some(value) = self.new_layout {
13094                raw.newLayout = value;
13095            }
13096            (raw, storage)
13097        }
13098        pub(crate) fn from_ffi(
13099            value: ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState,
13100        ) -> Self {
13101            Self {
13102                old_layout: Some(value.oldLayout),
13103                new_layout: Some(value.newLayout),
13104            }
13105        }
13106    }
13107    pub struct SharedTextureMemoryVkImageLayoutEndState {
13108        pub old_layout: Option<i32>,
13109        pub new_layout: Option<i32>,
13110    }
13111    impl Default for SharedTextureMemoryVkImageLayoutEndState {
13112        fn default() -> Self {
13113            Self {
13114                old_layout: None,
13115                new_layout: None,
13116            }
13117        }
13118    }
13119    impl SharedTextureMemoryVkImageLayoutEndState {
13120        pub fn new() -> Self {
13121            Self::default()
13122        }
13123        pub(crate) fn to_ffi(
13124            &self,
13125        ) -> (ffi::WGPUSharedTextureMemoryVkImageLayoutEndState, ChainedStructStorage) {
13126            let mut storage = ChainedStructStorage::new();
13127            let mut raw: ffi::WGPUSharedTextureMemoryVkImageLayoutEndState = unsafe {
13128                std::mem::zeroed()
13129            };
13130            if let Some(value) = self.old_layout {
13131                raw.oldLayout = value;
13132            }
13133            if let Some(value) = self.new_layout {
13134                raw.newLayout = value;
13135            }
13136            (raw, storage)
13137        }
13138        pub(crate) fn from_ffi(
13139            value: ffi::WGPUSharedTextureMemoryVkImageLayoutEndState,
13140        ) -> Self {
13141            Self {
13142                old_layout: Some(value.oldLayout),
13143                new_layout: Some(value.newLayout),
13144            }
13145        }
13146    }
13147    pub struct SharedTextureMemoryZirconHandleDescriptor {
13148        pub memory_fd: Option<u32>,
13149        pub allocation_size: Option<u64>,
13150    }
13151    impl Default for SharedTextureMemoryZirconHandleDescriptor {
13152        fn default() -> Self {
13153            Self {
13154                memory_fd: None,
13155                allocation_size: None,
13156            }
13157        }
13158    }
13159    impl SharedTextureMemoryZirconHandleDescriptor {
13160        pub fn new() -> Self {
13161            Self::default()
13162        }
13163        pub(crate) fn to_ffi(
13164            &self,
13165        ) -> (ffi::WGPUSharedTextureMemoryZirconHandleDescriptor, ChainedStructStorage) {
13166            let mut storage = ChainedStructStorage::new();
13167            let mut raw: ffi::WGPUSharedTextureMemoryZirconHandleDescriptor = unsafe {
13168                std::mem::zeroed()
13169            };
13170            if let Some(value) = self.memory_fd {
13171                raw.memoryFD = value;
13172            }
13173            if let Some(value) = self.allocation_size {
13174                raw.allocationSize = value;
13175            }
13176            (raw, storage)
13177        }
13178        pub(crate) fn from_ffi(
13179            value: ffi::WGPUSharedTextureMemoryZirconHandleDescriptor,
13180        ) -> Self {
13181            Self {
13182                memory_fd: Some(value.memoryFD),
13183                allocation_size: Some(value.allocationSize),
13184            }
13185        }
13186    }
13187    pub struct StaticSamplerBindingLayout {
13188        pub sampler: Option<Sampler>,
13189        pub sampled_texture_binding: Option<u32>,
13190    }
13191    impl Default for StaticSamplerBindingLayout {
13192        fn default() -> Self {
13193            Self {
13194                sampler: None,
13195                sampled_texture_binding: Some(LIMIT_U32_UNDEFINED),
13196            }
13197        }
13198    }
13199    impl StaticSamplerBindingLayout {
13200        pub fn new() -> Self {
13201            Self::default()
13202        }
13203        pub(crate) fn to_ffi(
13204            &self,
13205        ) -> (ffi::WGPUStaticSamplerBindingLayout, ChainedStructStorage) {
13206            let mut storage = ChainedStructStorage::new();
13207            let mut raw: ffi::WGPUStaticSamplerBindingLayout = unsafe {
13208                std::mem::zeroed()
13209            };
13210            raw.sampler = self
13211                .sampler
13212                .as_ref()
13213                .map(|v| v.as_raw())
13214                .unwrap_or(std::ptr::null_mut());
13215            if let Some(value) = self.sampled_texture_binding {
13216                raw.sampledTextureBinding = value;
13217            }
13218            (raw, storage)
13219        }
13220        pub(crate) fn from_ffi(value: ffi::WGPUStaticSamplerBindingLayout) -> Self {
13221            Self {
13222                sampler: Some(unsafe { Sampler::from_raw(value.sampler) }),
13223                sampled_texture_binding: Some(value.sampledTextureBinding),
13224            }
13225        }
13226    }
13227    pub struct StencilFaceState {
13228        pub compare: Option<CompareFunction>,
13229        pub fail_op: Option<StencilOperation>,
13230        pub depth_fail_op: Option<StencilOperation>,
13231        pub pass_op: Option<StencilOperation>,
13232    }
13233    impl Default for StencilFaceState {
13234        fn default() -> Self {
13235            Self {
13236                compare: Some(CompareFunction::Always),
13237                fail_op: Some(StencilOperation::Keep),
13238                depth_fail_op: Some(StencilOperation::Keep),
13239                pass_op: Some(StencilOperation::Keep),
13240            }
13241        }
13242    }
13243    impl StencilFaceState {
13244        pub fn new() -> Self {
13245            Self::default()
13246        }
13247        pub(crate) fn to_ffi(
13248            &self,
13249        ) -> (ffi::WGPUStencilFaceState, ChainedStructStorage) {
13250            let mut storage = ChainedStructStorage::new();
13251            let mut raw: ffi::WGPUStencilFaceState = unsafe { std::mem::zeroed() };
13252            if let Some(value) = self.compare {
13253                raw.compare = value.into();
13254            } else {
13255                raw.compare = 0 as ffi::WGPUCompareFunction;
13256            }
13257            if let Some(value) = self.fail_op {
13258                raw.failOp = value.into();
13259            } else {
13260                raw.failOp = 0 as ffi::WGPUStencilOperation;
13261            }
13262            if let Some(value) = self.depth_fail_op {
13263                raw.depthFailOp = value.into();
13264            } else {
13265                raw.depthFailOp = 0 as ffi::WGPUStencilOperation;
13266            }
13267            if let Some(value) = self.pass_op {
13268                raw.passOp = value.into();
13269            } else {
13270                raw.passOp = 0 as ffi::WGPUStencilOperation;
13271            }
13272            (raw, storage)
13273        }
13274        pub(crate) fn from_ffi(value: ffi::WGPUStencilFaceState) -> Self {
13275            Self {
13276                compare: Some(value.compare.into()),
13277                fail_op: Some(value.failOp.into()),
13278                depth_fail_op: Some(value.depthFailOp.into()),
13279                pass_op: Some(value.passOp.into()),
13280            }
13281        }
13282    }
13283    pub struct StorageTextureBindingLayout {
13284        pub(crate) extensions: Vec<StorageTextureBindingLayoutExtension>,
13285        pub access: Option<StorageTextureAccess>,
13286        pub format: Option<TextureFormat>,
13287        pub view_dimension: Option<TextureViewDimension>,
13288    }
13289    impl Default for StorageTextureBindingLayout {
13290        fn default() -> Self {
13291            Self {
13292                extensions: Vec::new(),
13293                access: Some(StorageTextureAccess::WriteOnly),
13294                format: None,
13295                view_dimension: Some(TextureViewDimension::D2),
13296            }
13297        }
13298    }
13299    impl StorageTextureBindingLayout {
13300        pub fn new() -> Self {
13301            Self::default()
13302        }
13303        pub(crate) fn to_ffi(
13304            &self,
13305        ) -> (ffi::WGPUStorageTextureBindingLayout, ChainedStructStorage) {
13306            let mut storage = ChainedStructStorage::new();
13307            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13308            for ext in self.extensions.iter().rev() {
13309                next = ext.push_chain(&mut storage, next);
13310            }
13311            let mut raw: ffi::WGPUStorageTextureBindingLayout = unsafe {
13312                std::mem::zeroed()
13313            };
13314            raw.nextInChain = next;
13315            if let Some(value) = self.access {
13316                raw.access = value.into();
13317            } else {
13318                raw.access = 0 as ffi::WGPUStorageTextureAccess;
13319            }
13320            if let Some(value) = self.format {
13321                raw.format = value.into();
13322            } else {
13323                raw.format = 0 as ffi::WGPUTextureFormat;
13324            }
13325            if let Some(value) = self.view_dimension {
13326                raw.viewDimension = value.into();
13327            } else {
13328                raw.viewDimension = 0 as ffi::WGPUTextureViewDimension;
13329            }
13330            (raw, storage)
13331        }
13332        pub fn with_extension(
13333            mut self,
13334            extension: StorageTextureBindingLayoutExtension,
13335        ) -> Self {
13336            self.extensions.push(extension);
13337            self
13338        }
13339        pub(crate) fn from_ffi(value: ffi::WGPUStorageTextureBindingLayout) -> Self {
13340            Self {
13341                extensions: Vec::new(),
13342                access: Some(value.access.into()),
13343                format: Some(value.format.into()),
13344                view_dimension: Some(value.viewDimension.into()),
13345            }
13346        }
13347    }
13348    pub struct StringView {
13349        pub data: Option<*const std::os::raw::c_char>,
13350        pub length: Option<usize>,
13351    }
13352    impl Default for StringView {
13353        fn default() -> Self {
13354            Self {
13355                data: None,
13356                length: Some(STRLEN),
13357            }
13358        }
13359    }
13360    impl StringView {
13361        pub fn new() -> Self {
13362            Self::default()
13363        }
13364        pub(crate) fn to_ffi(&self) -> (ffi::WGPUStringView, ChainedStructStorage) {
13365            let mut storage = ChainedStructStorage::new();
13366            let mut raw: ffi::WGPUStringView = unsafe { std::mem::zeroed() };
13367            if let Some(value) = self.data {
13368                raw.data = value;
13369            }
13370            if let Some(value) = self.length {
13371                raw.length = value;
13372            }
13373            (raw, storage)
13374        }
13375        pub(crate) fn from_ffi(value: ffi::WGPUStringView) -> Self {
13376            Self {
13377                data: Some(value.data),
13378                length: Some(value.length),
13379            }
13380        }
13381    }
13382    pub struct SubgroupMatrixConfig {
13383        pub component_type: Option<SubgroupMatrixComponentType>,
13384        pub result_component_type: Option<SubgroupMatrixComponentType>,
13385        pub m: Option<u32>,
13386        pub n: Option<u32>,
13387        pub k: Option<u32>,
13388    }
13389    impl Default for SubgroupMatrixConfig {
13390        fn default() -> Self {
13391            Self {
13392                component_type: None,
13393                result_component_type: None,
13394                m: None,
13395                n: None,
13396                k: None,
13397            }
13398        }
13399    }
13400    impl SubgroupMatrixConfig {
13401        pub fn new() -> Self {
13402            Self::default()
13403        }
13404        pub(crate) fn to_ffi(
13405            &self,
13406        ) -> (ffi::WGPUSubgroupMatrixConfig, ChainedStructStorage) {
13407            let mut storage = ChainedStructStorage::new();
13408            let mut raw: ffi::WGPUSubgroupMatrixConfig = unsafe { std::mem::zeroed() };
13409            if let Some(value) = self.component_type {
13410                raw.componentType = value.into();
13411            } else {
13412                raw.componentType = 0 as ffi::WGPUSubgroupMatrixComponentType;
13413            }
13414            if let Some(value) = self.result_component_type {
13415                raw.resultComponentType = value.into();
13416            } else {
13417                raw.resultComponentType = 0 as ffi::WGPUSubgroupMatrixComponentType;
13418            }
13419            if let Some(value) = self.m {
13420                raw.M = value;
13421            }
13422            if let Some(value) = self.n {
13423                raw.N = value;
13424            }
13425            if let Some(value) = self.k {
13426                raw.K = value;
13427            }
13428            (raw, storage)
13429        }
13430        pub(crate) fn from_ffi(value: ffi::WGPUSubgroupMatrixConfig) -> Self {
13431            Self {
13432                component_type: Some(value.componentType.into()),
13433                result_component_type: Some(value.resultComponentType.into()),
13434                m: Some(value.M),
13435                n: Some(value.N),
13436                k: Some(value.K),
13437            }
13438        }
13439    }
13440    pub struct SupportedWGSLLanguageFeatures {
13441        pub features: Option<Vec<WGSLLanguageFeatureName>>,
13442        #[doc(hidden)]
13443        pub(crate) _free_members: Option<ffi::WGPUSupportedWGSLLanguageFeatures>,
13444    }
13445    impl Default for SupportedWGSLLanguageFeatures {
13446        fn default() -> Self {
13447            Self {
13448                features: None,
13449                _free_members: None,
13450            }
13451        }
13452    }
13453    impl SupportedWGSLLanguageFeatures {
13454        pub fn new() -> Self {
13455            Self::default()
13456        }
13457        pub(crate) fn to_ffi(
13458            &self,
13459        ) -> (ffi::WGPUSupportedWGSLLanguageFeatures, ChainedStructStorage) {
13460            let mut storage = ChainedStructStorage::new();
13461            let mut raw: ffi::WGPUSupportedWGSLLanguageFeatures = unsafe {
13462                std::mem::zeroed()
13463            };
13464            raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13465            if let Some(values) = &self.features {
13466                let len_value = values.len();
13467                let raw_vec: Vec<ffi::WGPUWGSLLanguageFeatureName> = values
13468                    .iter()
13469                    .map(|v| (*v).into())
13470                    .collect();
13471                let ptr = storage.push_vec(raw_vec);
13472                raw.features = ptr;
13473                raw.featureCount = len_value;
13474            } else {
13475                raw.features = std::ptr::null();
13476                raw.featureCount = 0;
13477            }
13478            (raw, storage)
13479        }
13480        pub(crate) fn from_ffi(value: ffi::WGPUSupportedWGSLLanguageFeatures) -> Self {
13481            Self {
13482                features: if value.features.is_null() {
13483                    None
13484                } else {
13485                    Some(
13486                        unsafe {
13487                            std::slice::from_raw_parts(
13488                                value.features,
13489                                value.featureCount as usize,
13490                            )
13491                        }
13492                            .iter()
13493                            .map(|raw| WGSLLanguageFeatureName::from(*raw))
13494                            .collect(),
13495                    )
13496                },
13497                _free_members: Some(value),
13498            }
13499        }
13500        pub(crate) fn free_members(value: ffi::WGPUSupportedWGSLLanguageFeatures) {
13501            unsafe { ffi::wgpuSupportedWGSLLanguageFeaturesFreeMembers(value) };
13502        }
13503    }
13504    impl Drop for SupportedWGSLLanguageFeatures {
13505        fn drop(&mut self) {
13506            if let Some(value) = self._free_members.take() {
13507                unsafe { ffi::wgpuSupportedWGSLLanguageFeaturesFreeMembers(value) };
13508            }
13509        }
13510    }
13511    pub struct SupportedFeatures {
13512        pub features: Option<Vec<FeatureName>>,
13513        #[doc(hidden)]
13514        pub(crate) _free_members: Option<ffi::WGPUSupportedFeatures>,
13515    }
13516    impl Default for SupportedFeatures {
13517        fn default() -> Self {
13518            Self {
13519                features: None,
13520                _free_members: None,
13521            }
13522        }
13523    }
13524    impl SupportedFeatures {
13525        pub fn new() -> Self {
13526            Self::default()
13527        }
13528        pub(crate) fn to_ffi(
13529            &self,
13530        ) -> (ffi::WGPUSupportedFeatures, ChainedStructStorage) {
13531            let mut storage = ChainedStructStorage::new();
13532            let mut raw: ffi::WGPUSupportedFeatures = unsafe { std::mem::zeroed() };
13533            raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13534            if let Some(values) = &self.features {
13535                let len_value = values.len();
13536                let raw_vec: Vec<ffi::WGPUFeatureName> = values
13537                    .iter()
13538                    .map(|v| (*v).into())
13539                    .collect();
13540                let ptr = storage.push_vec(raw_vec);
13541                raw.features = ptr;
13542                raw.featureCount = len_value;
13543            } else {
13544                raw.features = std::ptr::null();
13545                raw.featureCount = 0;
13546            }
13547            (raw, storage)
13548        }
13549        pub(crate) fn from_ffi(value: ffi::WGPUSupportedFeatures) -> Self {
13550            Self {
13551                features: if value.features.is_null() {
13552                    None
13553                } else {
13554                    Some(
13555                        unsafe {
13556                            std::slice::from_raw_parts(
13557                                value.features,
13558                                value.featureCount as usize,
13559                            )
13560                        }
13561                            .iter()
13562                            .map(|raw| FeatureName::from(*raw))
13563                            .collect(),
13564                    )
13565                },
13566                _free_members: Some(value),
13567            }
13568        }
13569        pub(crate) fn free_members(value: ffi::WGPUSupportedFeatures) {
13570            unsafe { ffi::wgpuSupportedFeaturesFreeMembers(value) };
13571        }
13572    }
13573    impl Drop for SupportedFeatures {
13574        fn drop(&mut self) {
13575            if let Some(value) = self._free_members.take() {
13576                unsafe { ffi::wgpuSupportedFeaturesFreeMembers(value) };
13577            }
13578        }
13579    }
13580    pub struct SupportedInstanceFeatures {
13581        pub features: Option<Vec<InstanceFeatureName>>,
13582        #[doc(hidden)]
13583        pub(crate) _free_members: Option<ffi::WGPUSupportedInstanceFeatures>,
13584    }
13585    impl Default for SupportedInstanceFeatures {
13586        fn default() -> Self {
13587            Self {
13588                features: None,
13589                _free_members: None,
13590            }
13591        }
13592    }
13593    impl SupportedInstanceFeatures {
13594        pub fn new() -> Self {
13595            Self::default()
13596        }
13597        pub(crate) fn to_ffi(
13598            &self,
13599        ) -> (ffi::WGPUSupportedInstanceFeatures, ChainedStructStorage) {
13600            let mut storage = ChainedStructStorage::new();
13601            let mut raw: ffi::WGPUSupportedInstanceFeatures = unsafe {
13602                std::mem::zeroed()
13603            };
13604            raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13605            if let Some(values) = &self.features {
13606                let len_value = values.len();
13607                let raw_vec: Vec<ffi::WGPUInstanceFeatureName> = values
13608                    .iter()
13609                    .map(|v| (*v).into())
13610                    .collect();
13611                let ptr = storage.push_vec(raw_vec);
13612                raw.features = ptr;
13613                raw.featureCount = len_value;
13614            } else {
13615                raw.features = std::ptr::null();
13616                raw.featureCount = 0;
13617            }
13618            (raw, storage)
13619        }
13620        pub(crate) fn from_ffi(value: ffi::WGPUSupportedInstanceFeatures) -> Self {
13621            Self {
13622                features: if value.features.is_null() {
13623                    None
13624                } else {
13625                    Some(
13626                        unsafe {
13627                            std::slice::from_raw_parts(
13628                                value.features,
13629                                value.featureCount as usize,
13630                            )
13631                        }
13632                            .iter()
13633                            .map(|raw| InstanceFeatureName::from(*raw))
13634                            .collect(),
13635                    )
13636                },
13637                _free_members: Some(value),
13638            }
13639        }
13640        pub(crate) fn free_members(value: ffi::WGPUSupportedInstanceFeatures) {
13641            unsafe { ffi::wgpuSupportedInstanceFeaturesFreeMembers(value) };
13642        }
13643    }
13644    impl Drop for SupportedInstanceFeatures {
13645        fn drop(&mut self) {
13646            if let Some(value) = self._free_members.take() {
13647                unsafe { ffi::wgpuSupportedInstanceFeaturesFreeMembers(value) };
13648            }
13649        }
13650    }
13651    pub struct SurfaceCapabilities {
13652        pub(crate) extensions: Vec<SurfaceCapabilitiesExtension>,
13653        pub usages: Option<TextureUsage>,
13654        pub formats: Option<Vec<TextureFormat>>,
13655        pub present_modes: Option<Vec<PresentMode>>,
13656        pub alpha_modes: Option<Vec<CompositeAlphaMode>>,
13657        #[doc(hidden)]
13658        pub(crate) _free_members: Option<ffi::WGPUSurfaceCapabilities>,
13659    }
13660    impl Default for SurfaceCapabilities {
13661        fn default() -> Self {
13662            Self {
13663                extensions: Vec::new(),
13664                usages: None,
13665                formats: None,
13666                present_modes: None,
13667                alpha_modes: None,
13668                _free_members: None,
13669            }
13670        }
13671    }
13672    impl SurfaceCapabilities {
13673        pub fn new() -> Self {
13674            Self::default()
13675        }
13676        pub(crate) fn to_ffi(
13677            &self,
13678        ) -> (ffi::WGPUSurfaceCapabilities, ChainedStructStorage) {
13679            let mut storage = ChainedStructStorage::new();
13680            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13681            for ext in self.extensions.iter().rev() {
13682                next = ext.push_chain(&mut storage, next);
13683            }
13684            let mut raw: ffi::WGPUSurfaceCapabilities = unsafe { std::mem::zeroed() };
13685            raw.nextInChain = next;
13686            if let Some(value) = self.usages {
13687                raw.usages = value.into();
13688            } else {
13689                raw.usages = 0 as ffi::WGPUTextureUsage;
13690            }
13691            raw.formatCount = self.formats.as_ref().map(|v| v.len()).unwrap_or(0);
13692            if let Some(values) = &self.formats {
13693                let len_value = values.len();
13694                let raw_vec: Vec<ffi::WGPUTextureFormat> = values
13695                    .iter()
13696                    .map(|v| (*v).into())
13697                    .collect();
13698                let ptr = storage.push_vec(raw_vec);
13699                raw.formats = ptr;
13700                raw.formatCount = len_value;
13701            } else {
13702                raw.formats = std::ptr::null();
13703                raw.formatCount = 0;
13704            }
13705            raw.presentModeCount = self
13706                .present_modes
13707                .as_ref()
13708                .map(|v| v.len())
13709                .unwrap_or(0);
13710            if let Some(values) = &self.present_modes {
13711                let len_value = values.len();
13712                let raw_vec: Vec<ffi::WGPUPresentMode> = values
13713                    .iter()
13714                    .map(|v| (*v).into())
13715                    .collect();
13716                let ptr = storage.push_vec(raw_vec);
13717                raw.presentModes = ptr;
13718                raw.presentModeCount = len_value;
13719            } else {
13720                raw.presentModes = std::ptr::null();
13721                raw.presentModeCount = 0;
13722            }
13723            raw.alphaModeCount = self.alpha_modes.as_ref().map(|v| v.len()).unwrap_or(0);
13724            if let Some(values) = &self.alpha_modes {
13725                let len_value = values.len();
13726                let raw_vec: Vec<ffi::WGPUCompositeAlphaMode> = values
13727                    .iter()
13728                    .map(|v| (*v).into())
13729                    .collect();
13730                let ptr = storage.push_vec(raw_vec);
13731                raw.alphaModes = ptr;
13732                raw.alphaModeCount = len_value;
13733            } else {
13734                raw.alphaModes = std::ptr::null();
13735                raw.alphaModeCount = 0;
13736            }
13737            (raw, storage)
13738        }
13739        pub fn with_extension(
13740            mut self,
13741            extension: SurfaceCapabilitiesExtension,
13742        ) -> Self {
13743            self.extensions.push(extension);
13744            self
13745        }
13746        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceCapabilities) -> Self {
13747            Self {
13748                extensions: Vec::new(),
13749                usages: Some(value.usages.into()),
13750                formats: if value.formats.is_null() {
13751                    None
13752                } else {
13753                    Some(
13754                        unsafe {
13755                            std::slice::from_raw_parts(
13756                                value.formats,
13757                                value.formatCount as usize,
13758                            )
13759                        }
13760                            .iter()
13761                            .map(|raw| TextureFormat::from(*raw))
13762                            .collect(),
13763                    )
13764                },
13765                present_modes: if value.presentModes.is_null() {
13766                    None
13767                } else {
13768                    Some(
13769                        unsafe {
13770                            std::slice::from_raw_parts(
13771                                value.presentModes,
13772                                value.presentModeCount as usize,
13773                            )
13774                        }
13775                            .iter()
13776                            .map(|raw| PresentMode::from(*raw))
13777                            .collect(),
13778                    )
13779                },
13780                alpha_modes: if value.alphaModes.is_null() {
13781                    None
13782                } else {
13783                    Some(
13784                        unsafe {
13785                            std::slice::from_raw_parts(
13786                                value.alphaModes,
13787                                value.alphaModeCount as usize,
13788                            )
13789                        }
13790                            .iter()
13791                            .map(|raw| CompositeAlphaMode::from(*raw))
13792                            .collect(),
13793                    )
13794                },
13795                _free_members: Some(value),
13796            }
13797        }
13798        pub(crate) fn free_members(value: ffi::WGPUSurfaceCapabilities) {
13799            unsafe { ffi::wgpuSurfaceCapabilitiesFreeMembers(value) };
13800        }
13801    }
13802    impl Drop for SurfaceCapabilities {
13803        fn drop(&mut self) {
13804            if let Some(value) = self._free_members.take() {
13805                unsafe { ffi::wgpuSurfaceCapabilitiesFreeMembers(value) };
13806            }
13807        }
13808    }
13809    pub struct SurfaceColorManagement {
13810        pub color_space: Option<PredefinedColorSpace>,
13811        pub tone_mapping_mode: Option<ToneMappingMode>,
13812    }
13813    impl Default for SurfaceColorManagement {
13814        fn default() -> Self {
13815            Self {
13816                color_space: None,
13817                tone_mapping_mode: None,
13818            }
13819        }
13820    }
13821    impl SurfaceColorManagement {
13822        pub fn new() -> Self {
13823            Self::default()
13824        }
13825        pub(crate) fn to_ffi(
13826            &self,
13827        ) -> (ffi::WGPUSurfaceColorManagement, ChainedStructStorage) {
13828            let mut storage = ChainedStructStorage::new();
13829            let mut raw: ffi::WGPUSurfaceColorManagement = unsafe { std::mem::zeroed() };
13830            if let Some(value) = self.color_space {
13831                raw.colorSpace = value.into();
13832            } else {
13833                raw.colorSpace = 0 as ffi::WGPUPredefinedColorSpace;
13834            }
13835            if let Some(value) = self.tone_mapping_mode {
13836                raw.toneMappingMode = value.into();
13837            } else {
13838                raw.toneMappingMode = 0 as ffi::WGPUToneMappingMode;
13839            }
13840            (raw, storage)
13841        }
13842        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceColorManagement) -> Self {
13843            Self {
13844                color_space: Some(value.colorSpace.into()),
13845                tone_mapping_mode: Some(value.toneMappingMode.into()),
13846            }
13847        }
13848    }
13849    pub struct SurfaceConfiguration {
13850        pub(crate) extensions: Vec<SurfaceConfigurationExtension>,
13851        pub device: Option<Device>,
13852        pub format: Option<TextureFormat>,
13853        pub usage: Option<TextureUsage>,
13854        pub width: Option<u32>,
13855        pub height: Option<u32>,
13856        pub view_formats: Option<Vec<TextureFormat>>,
13857        pub alpha_mode: Option<CompositeAlphaMode>,
13858        pub present_mode: Option<PresentMode>,
13859    }
13860    impl Default for SurfaceConfiguration {
13861        fn default() -> Self {
13862            Self {
13863                extensions: Vec::new(),
13864                device: None,
13865                format: None,
13866                usage: Some(TextureUsage::RENDER_ATTACHMENT),
13867                width: None,
13868                height: None,
13869                view_formats: None,
13870                alpha_mode: Some(CompositeAlphaMode::Auto),
13871                present_mode: Some(PresentMode::Fifo),
13872            }
13873        }
13874    }
13875    impl SurfaceConfiguration {
13876        pub fn new() -> Self {
13877            Self::default()
13878        }
13879        pub(crate) fn to_ffi(
13880            &self,
13881        ) -> (ffi::WGPUSurfaceConfiguration, ChainedStructStorage) {
13882            let mut storage = ChainedStructStorage::new();
13883            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13884            for ext in self.extensions.iter().rev() {
13885                next = ext.push_chain(&mut storage, next);
13886            }
13887            let mut raw: ffi::WGPUSurfaceConfiguration = unsafe { std::mem::zeroed() };
13888            raw.nextInChain = next;
13889            raw.device = self
13890                .device
13891                .as_ref()
13892                .map(|v| v.as_raw())
13893                .unwrap_or(std::ptr::null_mut());
13894            if let Some(value) = self.format {
13895                raw.format = value.into();
13896            } else {
13897                raw.format = 0 as ffi::WGPUTextureFormat;
13898            }
13899            if let Some(value) = self.usage {
13900                raw.usage = value.into();
13901            } else {
13902                raw.usage = 0 as ffi::WGPUTextureUsage;
13903            }
13904            if let Some(value) = self.width {
13905                raw.width = value;
13906            }
13907            if let Some(value) = self.height {
13908                raw.height = value;
13909            }
13910            raw.viewFormatCount = self
13911                .view_formats
13912                .as_ref()
13913                .map(|v| v.len())
13914                .unwrap_or(0);
13915            if let Some(values) = &self.view_formats {
13916                let len_value = values.len();
13917                let raw_vec: Vec<ffi::WGPUTextureFormat> = values
13918                    .iter()
13919                    .map(|v| (*v).into())
13920                    .collect();
13921                let ptr = storage.push_vec(raw_vec);
13922                raw.viewFormats = ptr;
13923                raw.viewFormatCount = len_value;
13924            } else {
13925                raw.viewFormats = std::ptr::null();
13926                raw.viewFormatCount = 0;
13927            }
13928            if let Some(value) = self.alpha_mode {
13929                raw.alphaMode = value.into();
13930            } else {
13931                raw.alphaMode = 0 as ffi::WGPUCompositeAlphaMode;
13932            }
13933            if let Some(value) = self.present_mode {
13934                raw.presentMode = value.into();
13935            } else {
13936                raw.presentMode = 0 as ffi::WGPUPresentMode;
13937            }
13938            (raw, storage)
13939        }
13940        pub fn with_extension(
13941            mut self,
13942            extension: SurfaceConfigurationExtension,
13943        ) -> Self {
13944            self.extensions.push(extension);
13945            self
13946        }
13947        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceConfiguration) -> Self {
13948            Self {
13949                extensions: Vec::new(),
13950                device: Some(unsafe { Device::from_raw(value.device) }),
13951                format: Some(value.format.into()),
13952                usage: Some(value.usage.into()),
13953                width: Some(value.width),
13954                height: Some(value.height),
13955                view_formats: if value.viewFormats.is_null() {
13956                    None
13957                } else {
13958                    Some(
13959                        unsafe {
13960                            std::slice::from_raw_parts(
13961                                value.viewFormats,
13962                                value.viewFormatCount as usize,
13963                            )
13964                        }
13965                            .iter()
13966                            .map(|raw| TextureFormat::from(*raw))
13967                            .collect(),
13968                    )
13969                },
13970                alpha_mode: Some(value.alphaMode.into()),
13971                present_mode: Some(value.presentMode.into()),
13972            }
13973        }
13974    }
13975    pub struct SurfaceDescriptor {
13976        pub(crate) extensions: Vec<SurfaceDescriptorExtension>,
13977        pub label: Option<String>,
13978    }
13979    impl Default for SurfaceDescriptor {
13980        fn default() -> Self {
13981            Self {
13982                extensions: Vec::new(),
13983                label: None,
13984            }
13985        }
13986    }
13987    impl SurfaceDescriptor {
13988        pub fn new() -> Self {
13989            Self::default()
13990        }
13991        pub(crate) fn to_ffi(
13992            &self,
13993        ) -> (ffi::WGPUSurfaceDescriptor, ChainedStructStorage) {
13994            let mut storage = ChainedStructStorage::new();
13995            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13996            for ext in self.extensions.iter().rev() {
13997                next = ext.push_chain(&mut storage, next);
13998            }
13999            let mut raw: ffi::WGPUSurfaceDescriptor = unsafe { std::mem::zeroed() };
14000            raw.nextInChain = next;
14001            if let Some(value) = &self.label {
14002                raw.label = ffi::WGPUStringView {
14003                    data: value.as_ptr().cast(),
14004                    length: value.len(),
14005                };
14006            } else {
14007                raw.label = ffi::WGPUStringView {
14008                    data: std::ptr::null(),
14009                    length: 0,
14010                };
14011            }
14012            (raw, storage)
14013        }
14014        pub fn with_extension(mut self, extension: SurfaceDescriptorExtension) -> Self {
14015            self.extensions.push(extension);
14016            self
14017        }
14018        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceDescriptor) -> Self {
14019            Self {
14020                extensions: Vec::new(),
14021                label: if value.label.data.is_null() || value.label.length == 0 {
14022                    None
14023                } else {
14024                    Some(string_view_to_string(value.label))
14025                },
14026            }
14027        }
14028    }
14029    pub struct SurfaceDescriptorFromWindowsUWPSwapChainPanel {
14030        pub swap_chain_panel: Option<*mut std::ffi::c_void>,
14031    }
14032    impl Default for SurfaceDescriptorFromWindowsUWPSwapChainPanel {
14033        fn default() -> Self {
14034            Self { swap_chain_panel: None }
14035        }
14036    }
14037    impl SurfaceDescriptorFromWindowsUWPSwapChainPanel {
14038        pub fn new() -> Self {
14039            Self::default()
14040        }
14041        pub(crate) fn to_ffi(
14042            &self,
14043        ) -> (
14044            ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel,
14045            ChainedStructStorage,
14046        ) {
14047            let mut storage = ChainedStructStorage::new();
14048            let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel = unsafe {
14049                std::mem::zeroed()
14050            };
14051            if let Some(value) = self.swap_chain_panel {
14052                raw.swapChainPanel = value;
14053            }
14054            (raw, storage)
14055        }
14056        pub(crate) fn from_ffi(
14057            value: ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel,
14058        ) -> Self {
14059            Self {
14060                swap_chain_panel: Some(value.swapChainPanel),
14061            }
14062        }
14063    }
14064    pub struct SurfaceDescriptorFromWindowsWinUISwapChainPanel {
14065        pub swap_chain_panel: Option<*mut std::ffi::c_void>,
14066    }
14067    impl Default for SurfaceDescriptorFromWindowsWinUISwapChainPanel {
14068        fn default() -> Self {
14069            Self { swap_chain_panel: None }
14070        }
14071    }
14072    impl SurfaceDescriptorFromWindowsWinUISwapChainPanel {
14073        pub fn new() -> Self {
14074            Self::default()
14075        }
14076        pub(crate) fn to_ffi(
14077            &self,
14078        ) -> (
14079            ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel,
14080            ChainedStructStorage,
14081        ) {
14082            let mut storage = ChainedStructStorage::new();
14083            let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel = unsafe {
14084                std::mem::zeroed()
14085            };
14086            if let Some(value) = self.swap_chain_panel {
14087                raw.swapChainPanel = value;
14088            }
14089            (raw, storage)
14090        }
14091        pub(crate) fn from_ffi(
14092            value: ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel,
14093        ) -> Self {
14094            Self {
14095                swap_chain_panel: Some(value.swapChainPanel),
14096            }
14097        }
14098    }
14099    pub struct SurfaceDescriptorFromWindowsCoreWindow {
14100        pub core_window: Option<*mut std::ffi::c_void>,
14101    }
14102    impl Default for SurfaceDescriptorFromWindowsCoreWindow {
14103        fn default() -> Self {
14104            Self { core_window: None }
14105        }
14106    }
14107    impl SurfaceDescriptorFromWindowsCoreWindow {
14108        pub fn new() -> Self {
14109            Self::default()
14110        }
14111        pub(crate) fn to_ffi(
14112            &self,
14113        ) -> (ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow, ChainedStructStorage) {
14114            let mut storage = ChainedStructStorage::new();
14115            let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow = unsafe {
14116                std::mem::zeroed()
14117            };
14118            if let Some(value) = self.core_window {
14119                raw.coreWindow = value;
14120            }
14121            (raw, storage)
14122        }
14123        pub(crate) fn from_ffi(
14124            value: ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow,
14125        ) -> Self {
14126            Self {
14127                core_window: Some(value.coreWindow),
14128            }
14129        }
14130    }
14131    pub struct SurfaceSourceXCBWindow {
14132        pub connection: Option<*mut std::ffi::c_void>,
14133        pub window: Option<u32>,
14134    }
14135    impl Default for SurfaceSourceXCBWindow {
14136        fn default() -> Self {
14137            Self {
14138                connection: None,
14139                window: None,
14140            }
14141        }
14142    }
14143    impl SurfaceSourceXCBWindow {
14144        pub fn new() -> Self {
14145            Self::default()
14146        }
14147        pub(crate) fn to_ffi(
14148            &self,
14149        ) -> (ffi::WGPUSurfaceSourceXCBWindow, ChainedStructStorage) {
14150            let mut storage = ChainedStructStorage::new();
14151            let mut raw: ffi::WGPUSurfaceSourceXCBWindow = unsafe { std::mem::zeroed() };
14152            if let Some(value) = self.connection {
14153                raw.connection = value;
14154            }
14155            if let Some(value) = self.window {
14156                raw.window = value;
14157            }
14158            (raw, storage)
14159        }
14160        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceXCBWindow) -> Self {
14161            Self {
14162                connection: Some(value.connection),
14163                window: Some(value.window),
14164            }
14165        }
14166    }
14167    pub struct SurfaceSourceAndroidNativeWindow {
14168        pub window: Option<*mut std::ffi::c_void>,
14169    }
14170    impl Default for SurfaceSourceAndroidNativeWindow {
14171        fn default() -> Self {
14172            Self { window: None }
14173        }
14174    }
14175    impl SurfaceSourceAndroidNativeWindow {
14176        pub fn new() -> Self {
14177            Self::default()
14178        }
14179        pub(crate) fn to_ffi(
14180            &self,
14181        ) -> (ffi::WGPUSurfaceSourceAndroidNativeWindow, ChainedStructStorage) {
14182            let mut storage = ChainedStructStorage::new();
14183            let mut raw: ffi::WGPUSurfaceSourceAndroidNativeWindow = unsafe {
14184                std::mem::zeroed()
14185            };
14186            if let Some(value) = self.window {
14187                raw.window = value;
14188            }
14189            (raw, storage)
14190        }
14191        pub(crate) fn from_ffi(
14192            value: ffi::WGPUSurfaceSourceAndroidNativeWindow,
14193        ) -> Self {
14194            Self { window: Some(value.window) }
14195        }
14196    }
14197    pub struct SurfaceSourceMetalLayer {
14198        pub layer: Option<*mut std::ffi::c_void>,
14199    }
14200    impl Default for SurfaceSourceMetalLayer {
14201        fn default() -> Self {
14202            Self { layer: None }
14203        }
14204    }
14205    impl SurfaceSourceMetalLayer {
14206        pub fn new() -> Self {
14207            Self::default()
14208        }
14209        pub(crate) fn to_ffi(
14210            &self,
14211        ) -> (ffi::WGPUSurfaceSourceMetalLayer, ChainedStructStorage) {
14212            let mut storage = ChainedStructStorage::new();
14213            let mut raw: ffi::WGPUSurfaceSourceMetalLayer = unsafe {
14214                std::mem::zeroed()
14215            };
14216            if let Some(value) = self.layer {
14217                raw.layer = value;
14218            }
14219            (raw, storage)
14220        }
14221        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceMetalLayer) -> Self {
14222            Self { layer: Some(value.layer) }
14223        }
14224    }
14225    pub struct SurfaceSourceWaylandSurface {
14226        pub display: Option<*mut std::ffi::c_void>,
14227        pub surface: Option<*mut std::ffi::c_void>,
14228    }
14229    impl Default for SurfaceSourceWaylandSurface {
14230        fn default() -> Self {
14231            Self {
14232                display: None,
14233                surface: None,
14234            }
14235        }
14236    }
14237    impl SurfaceSourceWaylandSurface {
14238        pub fn new() -> Self {
14239            Self::default()
14240        }
14241        pub(crate) fn to_ffi(
14242            &self,
14243        ) -> (ffi::WGPUSurfaceSourceWaylandSurface, ChainedStructStorage) {
14244            let mut storage = ChainedStructStorage::new();
14245            let mut raw: ffi::WGPUSurfaceSourceWaylandSurface = unsafe {
14246                std::mem::zeroed()
14247            };
14248            if let Some(value) = self.display {
14249                raw.display = value;
14250            }
14251            if let Some(value) = self.surface {
14252                raw.surface = value;
14253            }
14254            (raw, storage)
14255        }
14256        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceWaylandSurface) -> Self {
14257            Self {
14258                display: Some(value.display),
14259                surface: Some(value.surface),
14260            }
14261        }
14262    }
14263    pub struct SurfaceSourceWindowsHWND {
14264        pub hinstance: Option<*mut std::ffi::c_void>,
14265        pub hwnd: Option<*mut std::ffi::c_void>,
14266    }
14267    impl Default for SurfaceSourceWindowsHWND {
14268        fn default() -> Self {
14269            Self {
14270                hinstance: None,
14271                hwnd: None,
14272            }
14273        }
14274    }
14275    impl SurfaceSourceWindowsHWND {
14276        pub fn new() -> Self {
14277            Self::default()
14278        }
14279        pub(crate) fn to_ffi(
14280            &self,
14281        ) -> (ffi::WGPUSurfaceSourceWindowsHWND, ChainedStructStorage) {
14282            let mut storage = ChainedStructStorage::new();
14283            let mut raw: ffi::WGPUSurfaceSourceWindowsHWND = unsafe {
14284                std::mem::zeroed()
14285            };
14286            if let Some(value) = self.hinstance {
14287                raw.hinstance = value;
14288            }
14289            if let Some(value) = self.hwnd {
14290                raw.hwnd = value;
14291            }
14292            (raw, storage)
14293        }
14294        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceWindowsHWND) -> Self {
14295            Self {
14296                hinstance: Some(value.hinstance),
14297                hwnd: Some(value.hwnd),
14298            }
14299        }
14300    }
14301    pub struct SurfaceSourceXlibWindow {
14302        pub display: Option<*mut std::ffi::c_void>,
14303        pub window: Option<u64>,
14304    }
14305    impl Default for SurfaceSourceXlibWindow {
14306        fn default() -> Self {
14307            Self {
14308                display: None,
14309                window: None,
14310            }
14311        }
14312    }
14313    impl SurfaceSourceXlibWindow {
14314        pub fn new() -> Self {
14315            Self::default()
14316        }
14317        pub(crate) fn to_ffi(
14318            &self,
14319        ) -> (ffi::WGPUSurfaceSourceXlibWindow, ChainedStructStorage) {
14320            let mut storage = ChainedStructStorage::new();
14321            let mut raw: ffi::WGPUSurfaceSourceXlibWindow = unsafe {
14322                std::mem::zeroed()
14323            };
14324            if let Some(value) = self.display {
14325                raw.display = value;
14326            }
14327            if let Some(value) = self.window {
14328                raw.window = value;
14329            }
14330            (raw, storage)
14331        }
14332        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceXlibWindow) -> Self {
14333            Self {
14334                display: Some(value.display),
14335                window: Some(value.window),
14336            }
14337        }
14338    }
14339    pub struct SurfaceTexture {
14340        pub(crate) extensions: Vec<SurfaceTextureExtension>,
14341        pub texture: Option<Texture>,
14342        pub status: Option<SurfaceGetCurrentTextureStatus>,
14343    }
14344    impl Default for SurfaceTexture {
14345        fn default() -> Self {
14346            Self {
14347                extensions: Vec::new(),
14348                texture: None,
14349                status: None,
14350            }
14351        }
14352    }
14353    impl SurfaceTexture {
14354        pub fn new() -> Self {
14355            Self::default()
14356        }
14357        pub(crate) fn to_ffi(&self) -> (ffi::WGPUSurfaceTexture, ChainedStructStorage) {
14358            let mut storage = ChainedStructStorage::new();
14359            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14360            for ext in self.extensions.iter().rev() {
14361                next = ext.push_chain(&mut storage, next);
14362            }
14363            let mut raw: ffi::WGPUSurfaceTexture = unsafe { std::mem::zeroed() };
14364            raw.nextInChain = next;
14365            raw.texture = self
14366                .texture
14367                .as_ref()
14368                .map(|v| v.as_raw())
14369                .unwrap_or(std::ptr::null_mut());
14370            if let Some(value) = self.status {
14371                raw.status = value.into();
14372            } else {
14373                raw.status = 0 as ffi::WGPUSurfaceGetCurrentTextureStatus;
14374            }
14375            (raw, storage)
14376        }
14377        pub fn with_extension(mut self, extension: SurfaceTextureExtension) -> Self {
14378            self.extensions.push(extension);
14379            self
14380        }
14381        pub(crate) fn from_ffi(value: ffi::WGPUSurfaceTexture) -> Self {
14382            Self {
14383                extensions: Vec::new(),
14384                texture: Some(unsafe { Texture::from_raw(value.texture) }),
14385                status: Some(value.status.into()),
14386            }
14387        }
14388    }
14389    pub struct TexelBufferBindingEntry {
14390        pub texel_buffer_view: Option<TexelBufferView>,
14391    }
14392    impl Default for TexelBufferBindingEntry {
14393        fn default() -> Self {
14394            Self { texel_buffer_view: None }
14395        }
14396    }
14397    impl TexelBufferBindingEntry {
14398        pub fn new() -> Self {
14399            Self::default()
14400        }
14401        pub(crate) fn to_ffi(
14402            &self,
14403        ) -> (ffi::WGPUTexelBufferBindingEntry, ChainedStructStorage) {
14404            let mut storage = ChainedStructStorage::new();
14405            let mut raw: ffi::WGPUTexelBufferBindingEntry = unsafe {
14406                std::mem::zeroed()
14407            };
14408            raw.texelBufferView = self
14409                .texel_buffer_view
14410                .as_ref()
14411                .map(|v| v.as_raw())
14412                .unwrap_or(std::ptr::null_mut());
14413            (raw, storage)
14414        }
14415        pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferBindingEntry) -> Self {
14416            Self {
14417                texel_buffer_view: Some(unsafe {
14418                    TexelBufferView::from_raw(value.texelBufferView)
14419                }),
14420            }
14421        }
14422    }
14423    pub struct TexelBufferBindingLayout {
14424        pub access: Option<TexelBufferAccess>,
14425        pub format: Option<TextureFormat>,
14426    }
14427    impl Default for TexelBufferBindingLayout {
14428        fn default() -> Self {
14429            Self {
14430                access: Some(TexelBufferAccess::ReadWrite),
14431                format: None,
14432            }
14433        }
14434    }
14435    impl TexelBufferBindingLayout {
14436        pub fn new() -> Self {
14437            Self::default()
14438        }
14439        pub(crate) fn to_ffi(
14440            &self,
14441        ) -> (ffi::WGPUTexelBufferBindingLayout, ChainedStructStorage) {
14442            let mut storage = ChainedStructStorage::new();
14443            let mut raw: ffi::WGPUTexelBufferBindingLayout = unsafe {
14444                std::mem::zeroed()
14445            };
14446            if let Some(value) = self.access {
14447                raw.access = value.into();
14448            } else {
14449                raw.access = 0 as ffi::WGPUTexelBufferAccess;
14450            }
14451            if let Some(value) = self.format {
14452                raw.format = value.into();
14453            } else {
14454                raw.format = 0 as ffi::WGPUTextureFormat;
14455            }
14456            (raw, storage)
14457        }
14458        pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferBindingLayout) -> Self {
14459            Self {
14460                access: Some(value.access.into()),
14461                format: Some(value.format.into()),
14462            }
14463        }
14464    }
14465    pub struct TexelBufferViewDescriptor {
14466        pub(crate) extensions: Vec<TexelBufferViewDescriptorExtension>,
14467        pub label: Option<String>,
14468        pub format: Option<TextureFormat>,
14469        pub offset: Option<u64>,
14470        pub size: Option<u64>,
14471    }
14472    impl Default for TexelBufferViewDescriptor {
14473        fn default() -> Self {
14474            Self {
14475                extensions: Vec::new(),
14476                label: None,
14477                format: None,
14478                offset: Some(0),
14479                size: Some(WHOLE_SIZE),
14480            }
14481        }
14482    }
14483    impl TexelBufferViewDescriptor {
14484        pub fn new() -> Self {
14485            Self::default()
14486        }
14487        pub(crate) fn to_ffi(
14488            &self,
14489        ) -> (ffi::WGPUTexelBufferViewDescriptor, ChainedStructStorage) {
14490            let mut storage = ChainedStructStorage::new();
14491            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14492            for ext in self.extensions.iter().rev() {
14493                next = ext.push_chain(&mut storage, next);
14494            }
14495            let mut raw: ffi::WGPUTexelBufferViewDescriptor = unsafe {
14496                std::mem::zeroed()
14497            };
14498            raw.nextInChain = next;
14499            if let Some(value) = &self.label {
14500                raw.label = ffi::WGPUStringView {
14501                    data: value.as_ptr().cast(),
14502                    length: value.len(),
14503                };
14504            } else {
14505                raw.label = ffi::WGPUStringView {
14506                    data: std::ptr::null(),
14507                    length: 0,
14508                };
14509            }
14510            if let Some(value) = self.format {
14511                raw.format = value.into();
14512            } else {
14513                raw.format = 0 as ffi::WGPUTextureFormat;
14514            }
14515            if let Some(value) = self.offset {
14516                raw.offset = value;
14517            }
14518            if let Some(value) = self.size {
14519                raw.size = value;
14520            }
14521            (raw, storage)
14522        }
14523        pub fn with_extension(
14524            mut self,
14525            extension: TexelBufferViewDescriptorExtension,
14526        ) -> Self {
14527            self.extensions.push(extension);
14528            self
14529        }
14530        pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferViewDescriptor) -> Self {
14531            Self {
14532                extensions: Vec::new(),
14533                label: if value.label.data.is_null() || value.label.length == 0 {
14534                    None
14535                } else {
14536                    Some(string_view_to_string(value.label))
14537                },
14538                format: Some(value.format.into()),
14539                offset: Some(value.offset),
14540                size: Some(value.size),
14541            }
14542        }
14543    }
14544    pub struct TexelCopyBufferInfo {
14545        pub layout: Option<TexelCopyBufferLayout>,
14546        pub buffer: Option<Buffer>,
14547    }
14548    impl Default for TexelCopyBufferInfo {
14549        fn default() -> Self {
14550            Self { layout: None, buffer: None }
14551        }
14552    }
14553    impl TexelCopyBufferInfo {
14554        pub fn new() -> Self {
14555            Self::default()
14556        }
14557        pub(crate) fn to_ffi(
14558            &self,
14559        ) -> (ffi::WGPUTexelCopyBufferInfo, ChainedStructStorage) {
14560            let mut storage = ChainedStructStorage::new();
14561            let mut raw: ffi::WGPUTexelCopyBufferInfo = unsafe { std::mem::zeroed() };
14562            if let Some(value) = &self.layout {
14563                let (raw_value, storage_value) = value.to_ffi();
14564                raw.layout = raw_value;
14565                storage.push_storage(storage_value);
14566            }
14567            raw.buffer = self
14568                .buffer
14569                .as_ref()
14570                .map(|v| v.as_raw())
14571                .unwrap_or(std::ptr::null_mut());
14572            (raw, storage)
14573        }
14574        pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyBufferInfo) -> Self {
14575            Self {
14576                layout: Some(TexelCopyBufferLayout::from_ffi(value.layout)),
14577                buffer: Some(unsafe { Buffer::from_raw(value.buffer) }),
14578            }
14579        }
14580    }
14581    pub struct TexelCopyBufferLayout {
14582        pub offset: Option<u64>,
14583        pub bytes_per_row: Option<u32>,
14584        pub rows_per_image: Option<u32>,
14585    }
14586    impl Default for TexelCopyBufferLayout {
14587        fn default() -> Self {
14588            Self {
14589                offset: Some(0),
14590                bytes_per_row: Some(COPY_STRIDE_UNDEFINED),
14591                rows_per_image: Some(COPY_STRIDE_UNDEFINED),
14592            }
14593        }
14594    }
14595    impl TexelCopyBufferLayout {
14596        pub fn new() -> Self {
14597            Self::default()
14598        }
14599        pub(crate) fn to_ffi(
14600            &self,
14601        ) -> (ffi::WGPUTexelCopyBufferLayout, ChainedStructStorage) {
14602            let mut storage = ChainedStructStorage::new();
14603            let mut raw: ffi::WGPUTexelCopyBufferLayout = unsafe { std::mem::zeroed() };
14604            if let Some(value) = self.offset {
14605                raw.offset = value;
14606            }
14607            if let Some(value) = self.bytes_per_row {
14608                raw.bytesPerRow = value;
14609            }
14610            if let Some(value) = self.rows_per_image {
14611                raw.rowsPerImage = value;
14612            }
14613            (raw, storage)
14614        }
14615        pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyBufferLayout) -> Self {
14616            Self {
14617                offset: Some(value.offset),
14618                bytes_per_row: Some(value.bytesPerRow),
14619                rows_per_image: Some(value.rowsPerImage),
14620            }
14621        }
14622    }
14623    pub struct TexelCopyTextureInfo {
14624        pub texture: Option<Texture>,
14625        pub mip_level: Option<u32>,
14626        pub origin: Option<Origin3D>,
14627        pub aspect: Option<TextureAspect>,
14628    }
14629    impl Default for TexelCopyTextureInfo {
14630        fn default() -> Self {
14631            Self {
14632                texture: None,
14633                mip_level: Some(0),
14634                origin: None,
14635                aspect: Some(TextureAspect::All),
14636            }
14637        }
14638    }
14639    impl TexelCopyTextureInfo {
14640        pub fn new() -> Self {
14641            Self::default()
14642        }
14643        pub(crate) fn to_ffi(
14644            &self,
14645        ) -> (ffi::WGPUTexelCopyTextureInfo, ChainedStructStorage) {
14646            let mut storage = ChainedStructStorage::new();
14647            let mut raw: ffi::WGPUTexelCopyTextureInfo = unsafe { std::mem::zeroed() };
14648            raw.texture = self
14649                .texture
14650                .as_ref()
14651                .map(|v| v.as_raw())
14652                .unwrap_or(std::ptr::null_mut());
14653            if let Some(value) = self.mip_level {
14654                raw.mipLevel = value;
14655            }
14656            if let Some(value) = &self.origin {
14657                let (raw_value, storage_value) = value.to_ffi();
14658                raw.origin = raw_value;
14659                storage.push_storage(storage_value);
14660            }
14661            if let Some(value) = self.aspect {
14662                raw.aspect = value.into();
14663            } else {
14664                raw.aspect = 0 as ffi::WGPUTextureAspect;
14665            }
14666            (raw, storage)
14667        }
14668        pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyTextureInfo) -> Self {
14669            Self {
14670                texture: Some(unsafe { Texture::from_raw(value.texture) }),
14671                mip_level: Some(value.mipLevel),
14672                origin: Some(Origin3D::from_ffi(value.origin)),
14673                aspect: Some(value.aspect.into()),
14674            }
14675        }
14676    }
14677    pub struct TextureBindingLayout {
14678        pub(crate) extensions: Vec<TextureBindingLayoutExtension>,
14679        pub sample_type: Option<TextureSampleType>,
14680        pub view_dimension: Option<TextureViewDimension>,
14681        pub multisampled: Option<bool>,
14682    }
14683    impl Default for TextureBindingLayout {
14684        fn default() -> Self {
14685            Self {
14686                extensions: Vec::new(),
14687                sample_type: Some(TextureSampleType::Float),
14688                view_dimension: Some(TextureViewDimension::D2),
14689                multisampled: None,
14690            }
14691        }
14692    }
14693    impl TextureBindingLayout {
14694        pub fn new() -> Self {
14695            Self::default()
14696        }
14697        pub(crate) fn to_ffi(
14698            &self,
14699        ) -> (ffi::WGPUTextureBindingLayout, ChainedStructStorage) {
14700            let mut storage = ChainedStructStorage::new();
14701            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14702            for ext in self.extensions.iter().rev() {
14703                next = ext.push_chain(&mut storage, next);
14704            }
14705            let mut raw: ffi::WGPUTextureBindingLayout = unsafe { std::mem::zeroed() };
14706            raw.nextInChain = next;
14707            if let Some(value) = self.sample_type {
14708                raw.sampleType = value.into();
14709            } else {
14710                raw.sampleType = 0 as ffi::WGPUTextureSampleType;
14711            }
14712            if let Some(value) = self.view_dimension {
14713                raw.viewDimension = value.into();
14714            } else {
14715                raw.viewDimension = 0 as ffi::WGPUTextureViewDimension;
14716            }
14717            raw.multisampled = if self.multisampled.unwrap_or(false) { 1 } else { 0 };
14718            (raw, storage)
14719        }
14720        pub fn with_extension(
14721            mut self,
14722            extension: TextureBindingLayoutExtension,
14723        ) -> Self {
14724            self.extensions.push(extension);
14725            self
14726        }
14727        pub(crate) fn from_ffi(value: ffi::WGPUTextureBindingLayout) -> Self {
14728            Self {
14729                extensions: Vec::new(),
14730                sample_type: Some(value.sampleType.into()),
14731                view_dimension: Some(value.viewDimension.into()),
14732                multisampled: Some(value.multisampled != 0),
14733            }
14734        }
14735    }
14736    pub struct TextureBindingViewDimension {
14737        pub texture_binding_view_dimension: Option<TextureViewDimension>,
14738    }
14739    impl Default for TextureBindingViewDimension {
14740        fn default() -> Self {
14741            Self {
14742                texture_binding_view_dimension: None,
14743            }
14744        }
14745    }
14746    impl TextureBindingViewDimension {
14747        pub fn new() -> Self {
14748            Self::default()
14749        }
14750        pub(crate) fn to_ffi(
14751            &self,
14752        ) -> (ffi::WGPUTextureBindingViewDimension, ChainedStructStorage) {
14753            let mut storage = ChainedStructStorage::new();
14754            let mut raw: ffi::WGPUTextureBindingViewDimension = unsafe {
14755                std::mem::zeroed()
14756            };
14757            if let Some(value) = self.texture_binding_view_dimension {
14758                raw.textureBindingViewDimension = value.into();
14759            } else {
14760                raw.textureBindingViewDimension = 0 as ffi::WGPUTextureViewDimension;
14761            }
14762            (raw, storage)
14763        }
14764        pub(crate) fn from_ffi(value: ffi::WGPUTextureBindingViewDimension) -> Self {
14765            Self {
14766                texture_binding_view_dimension: Some(
14767                    value.textureBindingViewDimension.into(),
14768                ),
14769            }
14770        }
14771    }
14772    pub struct TextureComponentSwizzle {
14773        pub r: Option<ComponentSwizzle>,
14774        pub g: Option<ComponentSwizzle>,
14775        pub b: Option<ComponentSwizzle>,
14776        pub a: Option<ComponentSwizzle>,
14777    }
14778    impl Default for TextureComponentSwizzle {
14779        fn default() -> Self {
14780            Self {
14781                r: Some(ComponentSwizzle::R),
14782                g: Some(ComponentSwizzle::G),
14783                b: Some(ComponentSwizzle::B),
14784                a: Some(ComponentSwizzle::A),
14785            }
14786        }
14787    }
14788    impl TextureComponentSwizzle {
14789        pub fn new() -> Self {
14790            Self::default()
14791        }
14792        pub(crate) fn to_ffi(
14793            &self,
14794        ) -> (ffi::WGPUTextureComponentSwizzle, ChainedStructStorage) {
14795            let mut storage = ChainedStructStorage::new();
14796            let mut raw: ffi::WGPUTextureComponentSwizzle = unsafe {
14797                std::mem::zeroed()
14798            };
14799            if let Some(value) = self.r {
14800                raw.r = value.into();
14801            } else {
14802                raw.r = 0 as ffi::WGPUComponentSwizzle;
14803            }
14804            if let Some(value) = self.g {
14805                raw.g = value.into();
14806            } else {
14807                raw.g = 0 as ffi::WGPUComponentSwizzle;
14808            }
14809            if let Some(value) = self.b {
14810                raw.b = value.into();
14811            } else {
14812                raw.b = 0 as ffi::WGPUComponentSwizzle;
14813            }
14814            if let Some(value) = self.a {
14815                raw.a = value.into();
14816            } else {
14817                raw.a = 0 as ffi::WGPUComponentSwizzle;
14818            }
14819            (raw, storage)
14820        }
14821        pub(crate) fn from_ffi(value: ffi::WGPUTextureComponentSwizzle) -> Self {
14822            Self {
14823                r: Some(value.r.into()),
14824                g: Some(value.g.into()),
14825                b: Some(value.b.into()),
14826                a: Some(value.a.into()),
14827            }
14828        }
14829    }
14830    pub struct TextureComponentSwizzleDescriptor {
14831        pub swizzle: Option<TextureComponentSwizzle>,
14832    }
14833    impl Default for TextureComponentSwizzleDescriptor {
14834        fn default() -> Self {
14835            Self { swizzle: None }
14836        }
14837    }
14838    impl TextureComponentSwizzleDescriptor {
14839        pub fn new() -> Self {
14840            Self::default()
14841        }
14842        pub(crate) fn to_ffi(
14843            &self,
14844        ) -> (ffi::WGPUTextureComponentSwizzleDescriptor, ChainedStructStorage) {
14845            let mut storage = ChainedStructStorage::new();
14846            let mut raw: ffi::WGPUTextureComponentSwizzleDescriptor = unsafe {
14847                std::mem::zeroed()
14848            };
14849            if let Some(value) = &self.swizzle {
14850                let (raw_value, storage_value) = value.to_ffi();
14851                raw.swizzle = raw_value;
14852                storage.push_storage(storage_value);
14853            }
14854            (raw, storage)
14855        }
14856        pub(crate) fn from_ffi(
14857            value: ffi::WGPUTextureComponentSwizzleDescriptor,
14858        ) -> Self {
14859            Self {
14860                swizzle: Some(TextureComponentSwizzle::from_ffi(value.swizzle)),
14861            }
14862        }
14863    }
14864    pub struct TextureDescriptor {
14865        pub(crate) extensions: Vec<TextureDescriptorExtension>,
14866        pub label: Option<String>,
14867        pub usage: Option<TextureUsage>,
14868        pub dimension: Option<TextureDimension>,
14869        pub size: Option<Extent3D>,
14870        pub format: Option<TextureFormat>,
14871        pub mip_level_count: Option<u32>,
14872        pub sample_count: Option<u32>,
14873        pub view_formats: Option<Vec<TextureFormat>>,
14874    }
14875    impl Default for TextureDescriptor {
14876        fn default() -> Self {
14877            Self {
14878                extensions: Vec::new(),
14879                label: None,
14880                usage: None,
14881                dimension: Some(TextureDimension::D2),
14882                size: None,
14883                format: None,
14884                mip_level_count: Some(1),
14885                sample_count: Some(1),
14886                view_formats: None,
14887            }
14888        }
14889    }
14890    impl TextureDescriptor {
14891        pub fn new() -> Self {
14892            Self::default()
14893        }
14894        pub(crate) fn to_ffi(
14895            &self,
14896        ) -> (ffi::WGPUTextureDescriptor, ChainedStructStorage) {
14897            let mut storage = ChainedStructStorage::new();
14898            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14899            for ext in self.extensions.iter().rev() {
14900                next = ext.push_chain(&mut storage, next);
14901            }
14902            let mut raw: ffi::WGPUTextureDescriptor = unsafe { std::mem::zeroed() };
14903            raw.nextInChain = next;
14904            if let Some(value) = &self.label {
14905                raw.label = ffi::WGPUStringView {
14906                    data: value.as_ptr().cast(),
14907                    length: value.len(),
14908                };
14909            } else {
14910                raw.label = ffi::WGPUStringView {
14911                    data: std::ptr::null(),
14912                    length: 0,
14913                };
14914            }
14915            if let Some(value) = self.usage {
14916                raw.usage = value.into();
14917            } else {
14918                raw.usage = 0 as ffi::WGPUTextureUsage;
14919            }
14920            if let Some(value) = self.dimension {
14921                raw.dimension = value.into();
14922            } else {
14923                raw.dimension = 0 as ffi::WGPUTextureDimension;
14924            }
14925            if let Some(value) = &self.size {
14926                let (raw_value, storage_value) = value.to_ffi();
14927                raw.size = raw_value;
14928                storage.push_storage(storage_value);
14929            }
14930            if let Some(value) = self.format {
14931                raw.format = value.into();
14932            } else {
14933                raw.format = 0 as ffi::WGPUTextureFormat;
14934            }
14935            if let Some(value) = self.mip_level_count {
14936                raw.mipLevelCount = value;
14937            }
14938            if let Some(value) = self.sample_count {
14939                raw.sampleCount = value;
14940            }
14941            raw.viewFormatCount = self
14942                .view_formats
14943                .as_ref()
14944                .map(|v| v.len())
14945                .unwrap_or(0);
14946            if let Some(values) = &self.view_formats {
14947                let len_value = values.len();
14948                let raw_vec: Vec<ffi::WGPUTextureFormat> = values
14949                    .iter()
14950                    .map(|v| (*v).into())
14951                    .collect();
14952                let ptr = storage.push_vec(raw_vec);
14953                raw.viewFormats = ptr;
14954                raw.viewFormatCount = len_value;
14955            } else {
14956                raw.viewFormats = std::ptr::null();
14957                raw.viewFormatCount = 0;
14958            }
14959            (raw, storage)
14960        }
14961        pub fn with_extension(mut self, extension: TextureDescriptorExtension) -> Self {
14962            self.extensions.push(extension);
14963            self
14964        }
14965        pub(crate) fn from_ffi(value: ffi::WGPUTextureDescriptor) -> Self {
14966            Self {
14967                extensions: Vec::new(),
14968                label: if value.label.data.is_null() || value.label.length == 0 {
14969                    None
14970                } else {
14971                    Some(string_view_to_string(value.label))
14972                },
14973                usage: Some(value.usage.into()),
14974                dimension: Some(value.dimension.into()),
14975                size: Some(Extent3D::from_ffi(value.size)),
14976                format: Some(value.format.into()),
14977                mip_level_count: Some(value.mipLevelCount),
14978                sample_count: Some(value.sampleCount),
14979                view_formats: if value.viewFormats.is_null() {
14980                    None
14981                } else {
14982                    Some(
14983                        unsafe {
14984                            std::slice::from_raw_parts(
14985                                value.viewFormats,
14986                                value.viewFormatCount as usize,
14987                            )
14988                        }
14989                            .iter()
14990                            .map(|raw| TextureFormat::from(*raw))
14991                            .collect(),
14992                    )
14993                },
14994            }
14995        }
14996    }
14997    pub struct TextureViewDescriptor {
14998        pub(crate) extensions: Vec<TextureViewDescriptorExtension>,
14999        pub label: Option<String>,
15000        pub format: Option<TextureFormat>,
15001        pub dimension: Option<TextureViewDimension>,
15002        pub base_mip_level: Option<u32>,
15003        pub mip_level_count: Option<u32>,
15004        pub base_array_layer: Option<u32>,
15005        pub array_layer_count: Option<u32>,
15006        pub aspect: Option<TextureAspect>,
15007        pub usage: Option<TextureUsage>,
15008    }
15009    impl Default for TextureViewDescriptor {
15010        fn default() -> Self {
15011            Self {
15012                extensions: Vec::new(),
15013                label: None,
15014                format: None,
15015                dimension: None,
15016                base_mip_level: Some(0),
15017                mip_level_count: Some(MIP_LEVEL_COUNT_UNDEFINED),
15018                base_array_layer: Some(0),
15019                array_layer_count: Some(ARRAY_LAYER_COUNT_UNDEFINED),
15020                aspect: Some(TextureAspect::All),
15021                usage: Some(TextureUsage::NONE),
15022            }
15023        }
15024    }
15025    impl TextureViewDescriptor {
15026        pub fn new() -> Self {
15027            Self::default()
15028        }
15029        pub(crate) fn to_ffi(
15030            &self,
15031        ) -> (ffi::WGPUTextureViewDescriptor, ChainedStructStorage) {
15032            let mut storage = ChainedStructStorage::new();
15033            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15034            for ext in self.extensions.iter().rev() {
15035                next = ext.push_chain(&mut storage, next);
15036            }
15037            let mut raw: ffi::WGPUTextureViewDescriptor = unsafe { std::mem::zeroed() };
15038            raw.nextInChain = next;
15039            if let Some(value) = &self.label {
15040                raw.label = ffi::WGPUStringView {
15041                    data: value.as_ptr().cast(),
15042                    length: value.len(),
15043                };
15044            } else {
15045                raw.label = ffi::WGPUStringView {
15046                    data: std::ptr::null(),
15047                    length: 0,
15048                };
15049            }
15050            if let Some(value) = self.format {
15051                raw.format = value.into();
15052            } else {
15053                raw.format = 0 as ffi::WGPUTextureFormat;
15054            }
15055            if let Some(value) = self.dimension {
15056                raw.dimension = value.into();
15057            } else {
15058                raw.dimension = 0 as ffi::WGPUTextureViewDimension;
15059            }
15060            if let Some(value) = self.base_mip_level {
15061                raw.baseMipLevel = value;
15062            }
15063            if let Some(value) = self.mip_level_count {
15064                raw.mipLevelCount = value;
15065            }
15066            if let Some(value) = self.base_array_layer {
15067                raw.baseArrayLayer = value;
15068            }
15069            if let Some(value) = self.array_layer_count {
15070                raw.arrayLayerCount = value;
15071            }
15072            if let Some(value) = self.aspect {
15073                raw.aspect = value.into();
15074            } else {
15075                raw.aspect = 0 as ffi::WGPUTextureAspect;
15076            }
15077            if let Some(value) = self.usage {
15078                raw.usage = value.into();
15079            } else {
15080                raw.usage = 0 as ffi::WGPUTextureUsage;
15081            }
15082            (raw, storage)
15083        }
15084        pub fn with_extension(
15085            mut self,
15086            extension: TextureViewDescriptorExtension,
15087        ) -> Self {
15088            self.extensions.push(extension);
15089            self
15090        }
15091        pub(crate) fn from_ffi(value: ffi::WGPUTextureViewDescriptor) -> Self {
15092            Self {
15093                extensions: Vec::new(),
15094                label: if value.label.data.is_null() || value.label.length == 0 {
15095                    None
15096                } else {
15097                    Some(string_view_to_string(value.label))
15098                },
15099                format: Some(value.format.into()),
15100                dimension: Some(value.dimension.into()),
15101                base_mip_level: Some(value.baseMipLevel),
15102                mip_level_count: Some(value.mipLevelCount),
15103                base_array_layer: Some(value.baseArrayLayer),
15104                array_layer_count: Some(value.arrayLayerCount),
15105                aspect: Some(value.aspect.into()),
15106                usage: Some(value.usage.into()),
15107            }
15108        }
15109    }
15110    pub struct VertexAttribute {
15111        pub(crate) extensions: Vec<VertexAttributeExtension>,
15112        pub format: Option<VertexFormat>,
15113        pub offset: Option<u64>,
15114        pub shader_location: Option<u32>,
15115    }
15116    impl Default for VertexAttribute {
15117        fn default() -> Self {
15118            Self {
15119                extensions: Vec::new(),
15120                format: None,
15121                offset: None,
15122                shader_location: None,
15123            }
15124        }
15125    }
15126    impl VertexAttribute {
15127        pub fn new() -> Self {
15128            Self::default()
15129        }
15130        pub(crate) fn to_ffi(&self) -> (ffi::WGPUVertexAttribute, ChainedStructStorage) {
15131            let mut storage = ChainedStructStorage::new();
15132            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15133            for ext in self.extensions.iter().rev() {
15134                next = ext.push_chain(&mut storage, next);
15135            }
15136            let mut raw: ffi::WGPUVertexAttribute = unsafe { std::mem::zeroed() };
15137            raw.nextInChain = next;
15138            if let Some(value) = self.format {
15139                raw.format = value.into();
15140            } else {
15141                raw.format = 0 as ffi::WGPUVertexFormat;
15142            }
15143            if let Some(value) = self.offset {
15144                raw.offset = value;
15145            }
15146            if let Some(value) = self.shader_location {
15147                raw.shaderLocation = value;
15148            }
15149            (raw, storage)
15150        }
15151        pub fn with_extension(mut self, extension: VertexAttributeExtension) -> Self {
15152            self.extensions.push(extension);
15153            self
15154        }
15155        pub(crate) fn from_ffi(value: ffi::WGPUVertexAttribute) -> Self {
15156            Self {
15157                extensions: Vec::new(),
15158                format: Some(value.format.into()),
15159                offset: Some(value.offset),
15160                shader_location: Some(value.shaderLocation),
15161            }
15162        }
15163    }
15164    pub struct VertexBufferLayout {
15165        pub(crate) extensions: Vec<VertexBufferLayoutExtension>,
15166        pub step_mode: Option<VertexStepMode>,
15167        pub array_stride: Option<u64>,
15168        pub attributes: Option<Vec<VertexAttribute>>,
15169    }
15170    impl Default for VertexBufferLayout {
15171        fn default() -> Self {
15172            Self {
15173                extensions: Vec::new(),
15174                step_mode: None,
15175                array_stride: None,
15176                attributes: None,
15177            }
15178        }
15179    }
15180    impl VertexBufferLayout {
15181        pub fn new() -> Self {
15182            Self::default()
15183        }
15184        pub(crate) fn to_ffi(
15185            &self,
15186        ) -> (ffi::WGPUVertexBufferLayout, ChainedStructStorage) {
15187            let mut storage = ChainedStructStorage::new();
15188            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15189            for ext in self.extensions.iter().rev() {
15190                next = ext.push_chain(&mut storage, next);
15191            }
15192            let mut raw: ffi::WGPUVertexBufferLayout = unsafe { std::mem::zeroed() };
15193            raw.nextInChain = next;
15194            if let Some(value) = self.step_mode {
15195                raw.stepMode = value.into();
15196            } else {
15197                raw.stepMode = 0 as ffi::WGPUVertexStepMode;
15198            }
15199            if let Some(value) = self.array_stride {
15200                raw.arrayStride = value;
15201            }
15202            raw.attributeCount = self.attributes.as_ref().map(|v| v.len()).unwrap_or(0);
15203            if let Some(values) = &self.attributes {
15204                let len_value = values.len();
15205                let mut raw_vec: Vec<ffi::WGPUVertexAttribute> = Vec::with_capacity(
15206                    values.len(),
15207                );
15208                for item in values.iter() {
15209                    let (raw_item, storage_item) = item.to_ffi();
15210                    raw_vec.push(raw_item);
15211                    storage.push_storage(storage_item);
15212                }
15213                let ptr = storage.push_vec(raw_vec);
15214                raw.attributes = ptr;
15215                raw.attributeCount = len_value;
15216            } else {
15217                raw.attributes = std::ptr::null();
15218                raw.attributeCount = 0;
15219            }
15220            (raw, storage)
15221        }
15222        pub fn with_extension(mut self, extension: VertexBufferLayoutExtension) -> Self {
15223            self.extensions.push(extension);
15224            self
15225        }
15226        pub(crate) fn from_ffi(value: ffi::WGPUVertexBufferLayout) -> Self {
15227            Self {
15228                extensions: Vec::new(),
15229                step_mode: Some(value.stepMode.into()),
15230                array_stride: Some(value.arrayStride),
15231                attributes: if value.attributes.is_null() {
15232                    None
15233                } else {
15234                    Some(
15235                        unsafe {
15236                            std::slice::from_raw_parts(
15237                                value.attributes,
15238                                value.attributeCount as usize,
15239                            )
15240                        }
15241                            .iter()
15242                            .map(|raw| VertexAttribute::from_ffi(*raw))
15243                            .collect(),
15244                    )
15245                },
15246            }
15247        }
15248    }
15249    pub struct VertexState {
15250        pub(crate) extensions: Vec<VertexStateExtension>,
15251        pub module: Option<ShaderModule>,
15252        pub entry_point: Option<String>,
15253        pub constants: Option<Vec<ConstantEntry>>,
15254        pub buffers: Option<Vec<VertexBufferLayout>>,
15255    }
15256    impl Default for VertexState {
15257        fn default() -> Self {
15258            Self {
15259                extensions: Vec::new(),
15260                module: None,
15261                entry_point: None,
15262                constants: None,
15263                buffers: None,
15264            }
15265        }
15266    }
15267    impl VertexState {
15268        pub fn new() -> Self {
15269            Self::default()
15270        }
15271        pub(crate) fn to_ffi(&self) -> (ffi::WGPUVertexState, ChainedStructStorage) {
15272            let mut storage = ChainedStructStorage::new();
15273            let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15274            for ext in self.extensions.iter().rev() {
15275                next = ext.push_chain(&mut storage, next);
15276            }
15277            let mut raw: ffi::WGPUVertexState = unsafe { std::mem::zeroed() };
15278            raw.nextInChain = next;
15279            raw.module = self
15280                .module
15281                .as_ref()
15282                .map(|v| v.as_raw())
15283                .unwrap_or(std::ptr::null_mut());
15284            if let Some(value) = &self.entry_point {
15285                raw.entryPoint = ffi::WGPUStringView {
15286                    data: value.as_ptr().cast(),
15287                    length: value.len(),
15288                };
15289            } else {
15290                raw.entryPoint = ffi::WGPUStringView {
15291                    data: std::ptr::null(),
15292                    length: 0,
15293                };
15294            }
15295            raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
15296            if let Some(values) = &self.constants {
15297                let len_value = values.len();
15298                let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
15299                    values.len(),
15300                );
15301                for item in values.iter() {
15302                    let (raw_item, storage_item) = item.to_ffi();
15303                    raw_vec.push(raw_item);
15304                    storage.push_storage(storage_item);
15305                }
15306                let ptr = storage.push_vec(raw_vec);
15307                raw.constants = ptr;
15308                raw.constantCount = len_value;
15309            } else {
15310                raw.constants = std::ptr::null();
15311                raw.constantCount = 0;
15312            }
15313            raw.bufferCount = self.buffers.as_ref().map(|v| v.len()).unwrap_or(0);
15314            if let Some(values) = &self.buffers {
15315                let len_value = values.len();
15316                let mut raw_vec: Vec<ffi::WGPUVertexBufferLayout> = Vec::with_capacity(
15317                    values.len(),
15318                );
15319                for item in values.iter() {
15320                    let (raw_item, storage_item) = item.to_ffi();
15321                    raw_vec.push(raw_item);
15322                    storage.push_storage(storage_item);
15323                }
15324                let ptr = storage.push_vec(raw_vec);
15325                raw.buffers = ptr;
15326                raw.bufferCount = len_value;
15327            } else {
15328                raw.buffers = std::ptr::null();
15329                raw.bufferCount = 0;
15330            }
15331            (raw, storage)
15332        }
15333        pub fn with_extension(mut self, extension: VertexStateExtension) -> Self {
15334            self.extensions.push(extension);
15335            self
15336        }
15337        pub(crate) fn from_ffi(value: ffi::WGPUVertexState) -> Self {
15338            Self {
15339                extensions: Vec::new(),
15340                module: Some(unsafe { ShaderModule::from_raw(value.module) }),
15341                entry_point: if value.entryPoint.data.is_null()
15342                    || value.entryPoint.length == 0
15343                {
15344                    None
15345                } else {
15346                    Some(string_view_to_string(value.entryPoint))
15347                },
15348                constants: if value.constants.is_null() {
15349                    None
15350                } else {
15351                    Some(
15352                        unsafe {
15353                            std::slice::from_raw_parts(
15354                                value.constants,
15355                                value.constantCount as usize,
15356                            )
15357                        }
15358                            .iter()
15359                            .map(|raw| ConstantEntry::from_ffi(*raw))
15360                            .collect(),
15361                    )
15362                },
15363                buffers: if value.buffers.is_null() {
15364                    None
15365                } else {
15366                    Some(
15367                        unsafe {
15368                            std::slice::from_raw_parts(
15369                                value.buffers,
15370                                value.bufferCount as usize,
15371                            )
15372                        }
15373                            .iter()
15374                            .map(|raw| VertexBufferLayout::from_ffi(*raw))
15375                            .collect(),
15376                    )
15377                },
15378            }
15379        }
15380    }
15381    pub struct YCbCrVkDescriptor {
15382        pub vk_format: Option<u32>,
15383        pub vk_y_cb_cr_model: Option<u32>,
15384        pub vk_y_cb_cr_range: Option<u32>,
15385        pub vk_component_swizzle_red: Option<u32>,
15386        pub vk_component_swizzle_green: Option<u32>,
15387        pub vk_component_swizzle_blue: Option<u32>,
15388        pub vk_component_swizzle_alpha: Option<u32>,
15389        pub vk_x_chroma_offset: Option<u32>,
15390        pub vk_y_chroma_offset: Option<u32>,
15391        pub vk_chroma_filter: Option<FilterMode>,
15392        pub force_explicit_reconstruction: Option<bool>,
15393        pub external_format: Option<u64>,
15394    }
15395    impl Default for YCbCrVkDescriptor {
15396        fn default() -> Self {
15397            Self {
15398                vk_format: Some(0),
15399                vk_y_cb_cr_model: Some(0),
15400                vk_y_cb_cr_range: Some(0),
15401                vk_component_swizzle_red: Some(0),
15402                vk_component_swizzle_green: Some(0),
15403                vk_component_swizzle_blue: Some(0),
15404                vk_component_swizzle_alpha: Some(0),
15405                vk_x_chroma_offset: Some(0),
15406                vk_y_chroma_offset: Some(0),
15407                vk_chroma_filter: Some(FilterMode::Nearest),
15408                force_explicit_reconstruction: None,
15409                external_format: Some(0),
15410            }
15411        }
15412    }
15413    impl YCbCrVkDescriptor {
15414        pub fn new() -> Self {
15415            Self::default()
15416        }
15417        pub(crate) fn to_ffi(
15418            &self,
15419        ) -> (ffi::WGPUYCbCrVkDescriptor, ChainedStructStorage) {
15420            let mut storage = ChainedStructStorage::new();
15421            let mut raw: ffi::WGPUYCbCrVkDescriptor = unsafe { std::mem::zeroed() };
15422            if let Some(value) = self.vk_format {
15423                raw.vkFormat = value;
15424            }
15425            if let Some(value) = self.vk_y_cb_cr_model {
15426                raw.vkYCbCrModel = value;
15427            }
15428            if let Some(value) = self.vk_y_cb_cr_range {
15429                raw.vkYCbCrRange = value;
15430            }
15431            if let Some(value) = self.vk_component_swizzle_red {
15432                raw.vkComponentSwizzleRed = value;
15433            }
15434            if let Some(value) = self.vk_component_swizzle_green {
15435                raw.vkComponentSwizzleGreen = value;
15436            }
15437            if let Some(value) = self.vk_component_swizzle_blue {
15438                raw.vkComponentSwizzleBlue = value;
15439            }
15440            if let Some(value) = self.vk_component_swizzle_alpha {
15441                raw.vkComponentSwizzleAlpha = value;
15442            }
15443            if let Some(value) = self.vk_x_chroma_offset {
15444                raw.vkXChromaOffset = value;
15445            }
15446            if let Some(value) = self.vk_y_chroma_offset {
15447                raw.vkYChromaOffset = value;
15448            }
15449            if let Some(value) = self.vk_chroma_filter {
15450                raw.vkChromaFilter = value.into();
15451            } else {
15452                raw.vkChromaFilter = 0 as ffi::WGPUFilterMode;
15453            }
15454            raw.forceExplicitReconstruction = if self
15455                .force_explicit_reconstruction
15456                .unwrap_or(false)
15457            {
15458                1
15459            } else {
15460                0
15461            };
15462            if let Some(value) = self.external_format {
15463                raw.externalFormat = value;
15464            }
15465            (raw, storage)
15466        }
15467        pub(crate) fn from_ffi(value: ffi::WGPUYCbCrVkDescriptor) -> Self {
15468            Self {
15469                vk_format: Some(value.vkFormat),
15470                vk_y_cb_cr_model: Some(value.vkYCbCrModel),
15471                vk_y_cb_cr_range: Some(value.vkYCbCrRange),
15472                vk_component_swizzle_red: Some(value.vkComponentSwizzleRed),
15473                vk_component_swizzle_green: Some(value.vkComponentSwizzleGreen),
15474                vk_component_swizzle_blue: Some(value.vkComponentSwizzleBlue),
15475                vk_component_swizzle_alpha: Some(value.vkComponentSwizzleAlpha),
15476                vk_x_chroma_offset: Some(value.vkXChromaOffset),
15477                vk_y_chroma_offset: Some(value.vkYChromaOffset),
15478                vk_chroma_filter: Some(value.vkChromaFilter.into()),
15479                force_explicit_reconstruction: Some(
15480                    value.forceExplicitReconstruction != 0,
15481                ),
15482                external_format: Some(value.externalFormat),
15483            }
15484        }
15485    }
15486}
15487mod extensions {
15488    #![allow(dead_code, unused_imports)]
15489    use crate::ffi;
15490    use crate::generated::*;
15491    use std::any::Any;
15492    pub(crate) struct ChainedStructStorage {
15493        entries: Vec<Box<ffi::WGPUChainedStruct>>,
15494        buffers: Vec<Box<dyn Any>>,
15495        nested: Vec<ChainedStructStorage>,
15496    }
15497    impl ChainedStructStorage {
15498        pub(crate) fn new() -> Self {
15499            Self {
15500                entries: Vec::new(),
15501                buffers: Vec::new(),
15502                nested: Vec::new(),
15503            }
15504        }
15505        pub(crate) fn push(
15506            &mut self,
15507            s_type: ffi::WGPUSType,
15508            next: *mut ffi::WGPUChainedStruct,
15509        ) -> *mut ffi::WGPUChainedStruct {
15510            let mut node = Box::new(ffi::WGPUChainedStruct {
15511                next,
15512                sType: s_type,
15513            });
15514            let ptr = std::ptr::from_mut(node.as_mut());
15515            self.entries.push(node);
15516            ptr
15517        }
15518        pub(crate) fn push_value<T: 'static>(&mut self, value: T) -> *const T {
15519            let boxed = Box::new(value);
15520            let ptr = std::ptr::from_ref(boxed.as_ref());
15521            self.buffers.push(boxed);
15522            ptr
15523        }
15524        pub(crate) fn push_value_mut<T: 'static>(&mut self, value: T) -> *mut T {
15525            let mut boxed = Box::new(value);
15526            let ptr = std::ptr::from_mut(boxed.as_mut());
15527            self.buffers.push(boxed);
15528            ptr
15529        }
15530        pub(crate) fn push_vec<T: 'static>(&mut self, value: Vec<T>) -> *const T {
15531            let ptr = value.as_ptr();
15532            self.buffers.push(Box::new(value));
15533            ptr
15534        }
15535        pub(crate) fn push_vec_mut<T: 'static>(&mut self, value: Vec<T>) -> *mut T {
15536            let mut value = value;
15537            let ptr = value.as_mut_ptr();
15538            self.buffers.push(Box::new(value));
15539            ptr
15540        }
15541        pub(crate) fn push_any<T: 'static>(&mut self, value: T) {
15542            self.buffers.push(Box::new(value));
15543        }
15544        pub(crate) fn push_storage(&mut self, storage: ChainedStructStorage) {
15545            self.nested.push(storage);
15546        }
15547    }
15548    #[allow(dead_code)]
15549    pub enum AdapterInfoExtension {
15550        AdapterPropertiesD3D(AdapterPropertiesD3D),
15551        AdapterPropertiesWGPU(AdapterPropertiesWGPU),
15552        AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15553            AdapterPropertiesExplicitComputeSubgroupSizeConfigs,
15554        ),
15555        AdapterPropertiesMemoryHeaps(AdapterPropertiesMemoryHeaps),
15556        AdapterPropertiesSubgroupMatrixConfigs(AdapterPropertiesSubgroupMatrixConfigs),
15557        AdapterPropertiesVk(AdapterPropertiesVk),
15558        DawnAdapterPropertiesPowerPreference(DawnAdapterPropertiesPowerPreference),
15559    }
15560    impl std::convert::From<AdapterPropertiesD3D> for AdapterInfoExtension {
15561        fn from(ext: AdapterPropertiesD3D) -> Self {
15562            AdapterInfoExtension::AdapterPropertiesD3D(ext)
15563        }
15564    }
15565    impl std::convert::From<AdapterPropertiesWGPU> for AdapterInfoExtension {
15566        fn from(ext: AdapterPropertiesWGPU) -> Self {
15567            AdapterInfoExtension::AdapterPropertiesWGPU(ext)
15568        }
15569    }
15570    impl std::convert::From<AdapterPropertiesExplicitComputeSubgroupSizeConfigs>
15571    for AdapterInfoExtension {
15572        fn from(ext: AdapterPropertiesExplicitComputeSubgroupSizeConfigs) -> Self {
15573            AdapterInfoExtension::AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15574                ext,
15575            )
15576        }
15577    }
15578    impl std::convert::From<AdapterPropertiesMemoryHeaps> for AdapterInfoExtension {
15579        fn from(ext: AdapterPropertiesMemoryHeaps) -> Self {
15580            AdapterInfoExtension::AdapterPropertiesMemoryHeaps(ext)
15581        }
15582    }
15583    impl std::convert::From<AdapterPropertiesSubgroupMatrixConfigs>
15584    for AdapterInfoExtension {
15585        fn from(ext: AdapterPropertiesSubgroupMatrixConfigs) -> Self {
15586            AdapterInfoExtension::AdapterPropertiesSubgroupMatrixConfigs(ext)
15587        }
15588    }
15589    impl std::convert::From<AdapterPropertiesVk> for AdapterInfoExtension {
15590        fn from(ext: AdapterPropertiesVk) -> Self {
15591            AdapterInfoExtension::AdapterPropertiesVk(ext)
15592        }
15593    }
15594    impl std::convert::From<DawnAdapterPropertiesPowerPreference>
15595    for AdapterInfoExtension {
15596        fn from(ext: DawnAdapterPropertiesPowerPreference) -> Self {
15597            AdapterInfoExtension::DawnAdapterPropertiesPowerPreference(ext)
15598        }
15599    }
15600    impl AdapterInfoExtension {
15601        pub(crate) fn push_chain(
15602            &self,
15603            storage: &mut ChainedStructStorage,
15604            next: *mut ffi::WGPUChainedStruct,
15605        ) -> *mut ffi::WGPUChainedStruct {
15606            match self {
15607                AdapterInfoExtension::AdapterPropertiesD3D(value) => {
15608                    let (mut raw, storage_value) = value.to_ffi();
15609                    raw.chain.sType = SType::AdapterPropertiesD3D.into();
15610                    raw.chain.next = next;
15611                    storage.push_storage(storage_value);
15612                    let raw_ptr = storage.push_value_mut(raw);
15613                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15614                }
15615                AdapterInfoExtension::AdapterPropertiesWGPU(value) => {
15616                    let (mut raw, storage_value) = value.to_ffi();
15617                    raw.chain.sType = SType::AdapterPropertiesWGPU.into();
15618                    raw.chain.next = next;
15619                    storage.push_storage(storage_value);
15620                    let raw_ptr = storage.push_value_mut(raw);
15621                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15622                }
15623                AdapterInfoExtension::AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15624                    value,
15625                ) => {
15626                    let (mut raw, storage_value) = value.to_ffi();
15627                    raw.chain.sType = SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs
15628                        .into();
15629                    raw.chain.next = next;
15630                    storage.push_storage(storage_value);
15631                    let raw_ptr = storage.push_value_mut(raw);
15632                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15633                }
15634                AdapterInfoExtension::AdapterPropertiesMemoryHeaps(value) => {
15635                    let (mut raw, storage_value) = value.to_ffi();
15636                    raw.chain.sType = SType::AdapterPropertiesMemoryHeaps.into();
15637                    raw.chain.next = next;
15638                    storage.push_storage(storage_value);
15639                    let raw_ptr = storage.push_value_mut(raw);
15640                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15641                }
15642                AdapterInfoExtension::AdapterPropertiesSubgroupMatrixConfigs(value) => {
15643                    let (mut raw, storage_value) = value.to_ffi();
15644                    raw.chain.sType = SType::AdapterPropertiesSubgroupMatrixConfigs
15645                        .into();
15646                    raw.chain.next = next;
15647                    storage.push_storage(storage_value);
15648                    let raw_ptr = storage.push_value_mut(raw);
15649                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15650                }
15651                AdapterInfoExtension::AdapterPropertiesVk(value) => {
15652                    let (mut raw, storage_value) = value.to_ffi();
15653                    raw.chain.sType = SType::AdapterPropertiesVk.into();
15654                    raw.chain.next = next;
15655                    storage.push_storage(storage_value);
15656                    let raw_ptr = storage.push_value_mut(raw);
15657                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15658                }
15659                AdapterInfoExtension::DawnAdapterPropertiesPowerPreference(value) => {
15660                    let (mut raw, storage_value) = value.to_ffi();
15661                    raw.chain.sType = SType::DawnAdapterPropertiesPowerPreference.into();
15662                    raw.chain.next = next;
15663                    storage.push_storage(storage_value);
15664                    let raw_ptr = storage.push_value_mut(raw);
15665                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15666                }
15667            }
15668        }
15669    }
15670    #[allow(dead_code)]
15671    pub enum BindGroupDescriptorExtension {}
15672    impl BindGroupDescriptorExtension {
15673        pub(crate) fn push_chain(
15674            &self,
15675            storage: &mut ChainedStructStorage,
15676            next: *mut ffi::WGPUChainedStruct,
15677        ) -> *mut ffi::WGPUChainedStruct {
15678            let _ = self;
15679            let _ = storage;
15680            next
15681        }
15682    }
15683    #[allow(dead_code)]
15684    pub enum BindGroupEntryExtension {
15685        ExternalTextureBindingEntry(ExternalTextureBindingEntry),
15686        TexelBufferBindingEntry(TexelBufferBindingEntry),
15687    }
15688    impl std::convert::From<ExternalTextureBindingEntry> for BindGroupEntryExtension {
15689        fn from(ext: ExternalTextureBindingEntry) -> Self {
15690            BindGroupEntryExtension::ExternalTextureBindingEntry(ext)
15691        }
15692    }
15693    impl std::convert::From<TexelBufferBindingEntry> for BindGroupEntryExtension {
15694        fn from(ext: TexelBufferBindingEntry) -> Self {
15695            BindGroupEntryExtension::TexelBufferBindingEntry(ext)
15696        }
15697    }
15698    impl BindGroupEntryExtension {
15699        pub(crate) fn push_chain(
15700            &self,
15701            storage: &mut ChainedStructStorage,
15702            next: *mut ffi::WGPUChainedStruct,
15703        ) -> *mut ffi::WGPUChainedStruct {
15704            match self {
15705                BindGroupEntryExtension::ExternalTextureBindingEntry(value) => {
15706                    let (mut raw, storage_value) = value.to_ffi();
15707                    raw.chain.sType = SType::ExternalTextureBindingEntry.into();
15708                    raw.chain.next = next;
15709                    storage.push_storage(storage_value);
15710                    let raw_ptr = storage.push_value_mut(raw);
15711                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15712                }
15713                BindGroupEntryExtension::TexelBufferBindingEntry(value) => {
15714                    let (mut raw, storage_value) = value.to_ffi();
15715                    raw.chain.sType = SType::TexelBufferBindingEntry.into();
15716                    raw.chain.next = next;
15717                    storage.push_storage(storage_value);
15718                    let raw_ptr = storage.push_value_mut(raw);
15719                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15720                }
15721            }
15722        }
15723    }
15724    #[allow(dead_code)]
15725    pub enum BindGroupLayoutDescriptorExtension {}
15726    impl BindGroupLayoutDescriptorExtension {
15727        pub(crate) fn push_chain(
15728            &self,
15729            storage: &mut ChainedStructStorage,
15730            next: *mut ffi::WGPUChainedStruct,
15731        ) -> *mut ffi::WGPUChainedStruct {
15732            let _ = self;
15733            let _ = storage;
15734            next
15735        }
15736    }
15737    #[allow(dead_code)]
15738    pub enum BindGroupLayoutEntryExtension {
15739        ExternalTextureBindingLayout(ExternalTextureBindingLayout),
15740        StaticSamplerBindingLayout(StaticSamplerBindingLayout),
15741        TexelBufferBindingLayout(TexelBufferBindingLayout),
15742    }
15743    impl std::convert::From<ExternalTextureBindingLayout>
15744    for BindGroupLayoutEntryExtension {
15745        fn from(ext: ExternalTextureBindingLayout) -> Self {
15746            BindGroupLayoutEntryExtension::ExternalTextureBindingLayout(ext)
15747        }
15748    }
15749    impl std::convert::From<StaticSamplerBindingLayout>
15750    for BindGroupLayoutEntryExtension {
15751        fn from(ext: StaticSamplerBindingLayout) -> Self {
15752            BindGroupLayoutEntryExtension::StaticSamplerBindingLayout(ext)
15753        }
15754    }
15755    impl std::convert::From<TexelBufferBindingLayout> for BindGroupLayoutEntryExtension {
15756        fn from(ext: TexelBufferBindingLayout) -> Self {
15757            BindGroupLayoutEntryExtension::TexelBufferBindingLayout(ext)
15758        }
15759    }
15760    impl BindGroupLayoutEntryExtension {
15761        pub(crate) fn push_chain(
15762            &self,
15763            storage: &mut ChainedStructStorage,
15764            next: *mut ffi::WGPUChainedStruct,
15765        ) -> *mut ffi::WGPUChainedStruct {
15766            match self {
15767                BindGroupLayoutEntryExtension::ExternalTextureBindingLayout(value) => {
15768                    let (mut raw, storage_value) = value.to_ffi();
15769                    raw.chain.sType = SType::ExternalTextureBindingLayout.into();
15770                    raw.chain.next = next;
15771                    storage.push_storage(storage_value);
15772                    let raw_ptr = storage.push_value_mut(raw);
15773                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15774                }
15775                BindGroupLayoutEntryExtension::StaticSamplerBindingLayout(value) => {
15776                    let (mut raw, storage_value) = value.to_ffi();
15777                    raw.chain.sType = SType::StaticSamplerBindingLayout.into();
15778                    raw.chain.next = next;
15779                    storage.push_storage(storage_value);
15780                    let raw_ptr = storage.push_value_mut(raw);
15781                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15782                }
15783                BindGroupLayoutEntryExtension::TexelBufferBindingLayout(value) => {
15784                    let (mut raw, storage_value) = value.to_ffi();
15785                    raw.chain.sType = SType::TexelBufferBindingLayout.into();
15786                    raw.chain.next = next;
15787                    storage.push_storage(storage_value);
15788                    let raw_ptr = storage.push_value_mut(raw);
15789                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15790                }
15791            }
15792        }
15793    }
15794    #[allow(dead_code)]
15795    pub enum BindingResourceExtension {}
15796    impl BindingResourceExtension {
15797        pub(crate) fn push_chain(
15798            &self,
15799            storage: &mut ChainedStructStorage,
15800            next: *mut ffi::WGPUChainedStruct,
15801        ) -> *mut ffi::WGPUChainedStruct {
15802            let _ = self;
15803            let _ = storage;
15804            next
15805        }
15806    }
15807    #[allow(dead_code)]
15808    pub enum BufferBindingLayoutExtension {}
15809    impl BufferBindingLayoutExtension {
15810        pub(crate) fn push_chain(
15811            &self,
15812            storage: &mut ChainedStructStorage,
15813            next: *mut ffi::WGPUChainedStruct,
15814        ) -> *mut ffi::WGPUChainedStruct {
15815            let _ = self;
15816            let _ = storage;
15817            next
15818        }
15819    }
15820    #[allow(dead_code)]
15821    pub enum BufferDescriptorExtension {
15822        BufferHostMappedPointer(BufferHostMappedPointer),
15823        DawnBufferDescriptorErrorInfoFromWireClient(
15824            DawnBufferDescriptorErrorInfoFromWireClient,
15825        ),
15826        DawnFakeBufferOOMForTesting(DawnFakeBufferOOMForTesting),
15827    }
15828    impl std::convert::From<BufferHostMappedPointer> for BufferDescriptorExtension {
15829        fn from(ext: BufferHostMappedPointer) -> Self {
15830            BufferDescriptorExtension::BufferHostMappedPointer(ext)
15831        }
15832    }
15833    impl std::convert::From<DawnBufferDescriptorErrorInfoFromWireClient>
15834    for BufferDescriptorExtension {
15835        fn from(ext: DawnBufferDescriptorErrorInfoFromWireClient) -> Self {
15836            BufferDescriptorExtension::DawnBufferDescriptorErrorInfoFromWireClient(ext)
15837        }
15838    }
15839    impl std::convert::From<DawnFakeBufferOOMForTesting> for BufferDescriptorExtension {
15840        fn from(ext: DawnFakeBufferOOMForTesting) -> Self {
15841            BufferDescriptorExtension::DawnFakeBufferOOMForTesting(ext)
15842        }
15843    }
15844    impl BufferDescriptorExtension {
15845        pub(crate) fn push_chain(
15846            &self,
15847            storage: &mut ChainedStructStorage,
15848            next: *mut ffi::WGPUChainedStruct,
15849        ) -> *mut ffi::WGPUChainedStruct {
15850            match self {
15851                BufferDescriptorExtension::BufferHostMappedPointer(value) => {
15852                    let (mut raw, storage_value) = value.to_ffi();
15853                    raw.chain.sType = SType::BufferHostMappedPointer.into();
15854                    raw.chain.next = next;
15855                    storage.push_storage(storage_value);
15856                    let raw_ptr = storage.push_value_mut(raw);
15857                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15858                }
15859                BufferDescriptorExtension::DawnBufferDescriptorErrorInfoFromWireClient(
15860                    value,
15861                ) => {
15862                    let (mut raw, storage_value) = value.to_ffi();
15863                    raw.chain.sType = SType::DawnBufferDescriptorErrorInfoFromWireClient
15864                        .into();
15865                    raw.chain.next = next;
15866                    storage.push_storage(storage_value);
15867                    let raw_ptr = storage.push_value_mut(raw);
15868                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15869                }
15870                BufferDescriptorExtension::DawnFakeBufferOOMForTesting(value) => {
15871                    let (mut raw, storage_value) = value.to_ffi();
15872                    raw.chain.sType = SType::DawnFakeBufferOOMForTesting.into();
15873                    raw.chain.next = next;
15874                    storage.push_storage(storage_value);
15875                    let raw_ptr = storage.push_value_mut(raw);
15876                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15877                }
15878            }
15879        }
15880    }
15881    #[allow(dead_code)]
15882    pub enum ColorTargetStateExtension {
15883        ColorTargetStateExpandResolveTextureDawn(
15884            ColorTargetStateExpandResolveTextureDawn,
15885        ),
15886    }
15887    impl std::convert::From<ColorTargetStateExpandResolveTextureDawn>
15888    for ColorTargetStateExtension {
15889        fn from(ext: ColorTargetStateExpandResolveTextureDawn) -> Self {
15890            ColorTargetStateExtension::ColorTargetStateExpandResolveTextureDawn(ext)
15891        }
15892    }
15893    impl ColorTargetStateExtension {
15894        pub(crate) fn push_chain(
15895            &self,
15896            storage: &mut ChainedStructStorage,
15897            next: *mut ffi::WGPUChainedStruct,
15898        ) -> *mut ffi::WGPUChainedStruct {
15899            match self {
15900                ColorTargetStateExtension::ColorTargetStateExpandResolveTextureDawn(
15901                    value,
15902                ) => {
15903                    let (mut raw, storage_value) = value.to_ffi();
15904                    raw.chain.sType = SType::ColorTargetStateExpandResolveTextureDawn
15905                        .into();
15906                    raw.chain.next = next;
15907                    storage.push_storage(storage_value);
15908                    let raw_ptr = storage.push_value_mut(raw);
15909                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15910                }
15911            }
15912        }
15913    }
15914    #[allow(dead_code)]
15915    pub enum CommandBufferDescriptorExtension {}
15916    impl CommandBufferDescriptorExtension {
15917        pub(crate) fn push_chain(
15918            &self,
15919            storage: &mut ChainedStructStorage,
15920            next: *mut ffi::WGPUChainedStruct,
15921        ) -> *mut ffi::WGPUChainedStruct {
15922            let _ = self;
15923            let _ = storage;
15924            next
15925        }
15926    }
15927    #[allow(dead_code)]
15928    pub enum CommandEncoderDescriptorExtension {
15929        DawnEncoderInternalUsageDescriptor(DawnEncoderInternalUsageDescriptor),
15930    }
15931    impl std::convert::From<DawnEncoderInternalUsageDescriptor>
15932    for CommandEncoderDescriptorExtension {
15933        fn from(ext: DawnEncoderInternalUsageDescriptor) -> Self {
15934            CommandEncoderDescriptorExtension::DawnEncoderInternalUsageDescriptor(ext)
15935        }
15936    }
15937    impl CommandEncoderDescriptorExtension {
15938        pub(crate) fn push_chain(
15939            &self,
15940            storage: &mut ChainedStructStorage,
15941            next: *mut ffi::WGPUChainedStruct,
15942        ) -> *mut ffi::WGPUChainedStruct {
15943            match self {
15944                CommandEncoderDescriptorExtension::DawnEncoderInternalUsageDescriptor(
15945                    value,
15946                ) => {
15947                    let (mut raw, storage_value) = value.to_ffi();
15948                    raw.chain.sType = SType::DawnEncoderInternalUsageDescriptor.into();
15949                    raw.chain.next = next;
15950                    storage.push_storage(storage_value);
15951                    let raw_ptr = storage.push_value_mut(raw);
15952                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15953                }
15954            }
15955        }
15956    }
15957    #[allow(dead_code)]
15958    pub enum CompilationInfoExtension {}
15959    impl CompilationInfoExtension {
15960        pub(crate) fn push_chain(
15961            &self,
15962            storage: &mut ChainedStructStorage,
15963            next: *mut ffi::WGPUChainedStruct,
15964        ) -> *mut ffi::WGPUChainedStruct {
15965            let _ = self;
15966            let _ = storage;
15967            next
15968        }
15969    }
15970    #[allow(dead_code)]
15971    pub enum CompilationMessageExtension {
15972        DawnCompilationMessageUtf16(DawnCompilationMessageUtf16),
15973    }
15974    impl std::convert::From<DawnCompilationMessageUtf16>
15975    for CompilationMessageExtension {
15976        fn from(ext: DawnCompilationMessageUtf16) -> Self {
15977            CompilationMessageExtension::DawnCompilationMessageUtf16(ext)
15978        }
15979    }
15980    impl CompilationMessageExtension {
15981        pub(crate) fn push_chain(
15982            &self,
15983            storage: &mut ChainedStructStorage,
15984            next: *mut ffi::WGPUChainedStruct,
15985        ) -> *mut ffi::WGPUChainedStruct {
15986            match self {
15987                CompilationMessageExtension::DawnCompilationMessageUtf16(value) => {
15988                    let (mut raw, storage_value) = value.to_ffi();
15989                    raw.chain.sType = SType::DawnCompilationMessageUtf16.into();
15990                    raw.chain.next = next;
15991                    storage.push_storage(storage_value);
15992                    let raw_ptr = storage.push_value_mut(raw);
15993                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
15994                }
15995            }
15996        }
15997    }
15998    #[allow(dead_code)]
15999    pub enum ComputePassDescriptorExtension {}
16000    impl ComputePassDescriptorExtension {
16001        pub(crate) fn push_chain(
16002            &self,
16003            storage: &mut ChainedStructStorage,
16004            next: *mut ffi::WGPUChainedStruct,
16005        ) -> *mut ffi::WGPUChainedStruct {
16006            let _ = self;
16007            let _ = storage;
16008            next
16009        }
16010    }
16011    #[allow(dead_code)]
16012    pub enum ComputePipelineDescriptorExtension {}
16013    impl ComputePipelineDescriptorExtension {
16014        pub(crate) fn push_chain(
16015            &self,
16016            storage: &mut ChainedStructStorage,
16017            next: *mut ffi::WGPUChainedStruct,
16018        ) -> *mut ffi::WGPUChainedStruct {
16019            let _ = self;
16020            let _ = storage;
16021            next
16022        }
16023    }
16024    #[allow(dead_code)]
16025    pub enum ComputeStateExtension {}
16026    impl ComputeStateExtension {
16027        pub(crate) fn push_chain(
16028            &self,
16029            storage: &mut ChainedStructStorage,
16030            next: *mut ffi::WGPUChainedStruct,
16031        ) -> *mut ffi::WGPUChainedStruct {
16032            let _ = self;
16033            let _ = storage;
16034            next
16035        }
16036    }
16037    #[allow(dead_code)]
16038    pub enum ConstantEntryExtension {}
16039    impl ConstantEntryExtension {
16040        pub(crate) fn push_chain(
16041            &self,
16042            storage: &mut ChainedStructStorage,
16043            next: *mut ffi::WGPUChainedStruct,
16044        ) -> *mut ffi::WGPUChainedStruct {
16045            let _ = self;
16046            let _ = storage;
16047            next
16048        }
16049    }
16050    #[allow(dead_code)]
16051    pub enum CopyTextureForBrowserOptionsExtension {}
16052    impl CopyTextureForBrowserOptionsExtension {
16053        pub(crate) fn push_chain(
16054            &self,
16055            storage: &mut ChainedStructStorage,
16056            next: *mut ffi::WGPUChainedStruct,
16057        ) -> *mut ffi::WGPUChainedStruct {
16058            let _ = self;
16059            let _ = storage;
16060            next
16061        }
16062    }
16063    #[allow(dead_code)]
16064    pub enum DawnFormatCapabilitiesExtension {
16065        DawnDrmFormatCapabilities(DawnDrmFormatCapabilities),
16066    }
16067    impl std::convert::From<DawnDrmFormatCapabilities>
16068    for DawnFormatCapabilitiesExtension {
16069        fn from(ext: DawnDrmFormatCapabilities) -> Self {
16070            DawnFormatCapabilitiesExtension::DawnDrmFormatCapabilities(ext)
16071        }
16072    }
16073    impl DawnFormatCapabilitiesExtension {
16074        pub(crate) fn push_chain(
16075            &self,
16076            storage: &mut ChainedStructStorage,
16077            next: *mut ffi::WGPUChainedStruct,
16078        ) -> *mut ffi::WGPUChainedStruct {
16079            match self {
16080                DawnFormatCapabilitiesExtension::DawnDrmFormatCapabilities(value) => {
16081                    let (mut raw, storage_value) = value.to_ffi();
16082                    raw.chain.sType = SType::DawnDrmFormatCapabilities.into();
16083                    raw.chain.next = next;
16084                    storage.push_storage(storage_value);
16085                    let raw_ptr = storage.push_value_mut(raw);
16086                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16087                }
16088            }
16089        }
16090    }
16091    #[allow(dead_code)]
16092    pub enum DepthStencilStateExtension {}
16093    impl DepthStencilStateExtension {
16094        pub(crate) fn push_chain(
16095            &self,
16096            storage: &mut ChainedStructStorage,
16097            next: *mut ffi::WGPUChainedStruct,
16098        ) -> *mut ffi::WGPUChainedStruct {
16099            let _ = self;
16100            let _ = storage;
16101            next
16102        }
16103    }
16104    #[allow(dead_code)]
16105    pub enum DeviceDescriptorExtension {
16106        DawnCacheDeviceDescriptor(DawnCacheDeviceDescriptor),
16107        DawnConsumeAdapterDescriptor(DawnConsumeAdapterDescriptor),
16108        DawnDeviceAllocatorControl(DawnDeviceAllocatorControl),
16109        DawnFakeDeviceInitializeErrorForTesting(DawnFakeDeviceInitializeErrorForTesting),
16110        DawnTogglesDescriptor(DawnTogglesDescriptor),
16111    }
16112    impl std::convert::From<DawnCacheDeviceDescriptor> for DeviceDescriptorExtension {
16113        fn from(ext: DawnCacheDeviceDescriptor) -> Self {
16114            DeviceDescriptorExtension::DawnCacheDeviceDescriptor(ext)
16115        }
16116    }
16117    impl std::convert::From<DawnConsumeAdapterDescriptor> for DeviceDescriptorExtension {
16118        fn from(ext: DawnConsumeAdapterDescriptor) -> Self {
16119            DeviceDescriptorExtension::DawnConsumeAdapterDescriptor(ext)
16120        }
16121    }
16122    impl std::convert::From<DawnDeviceAllocatorControl> for DeviceDescriptorExtension {
16123        fn from(ext: DawnDeviceAllocatorControl) -> Self {
16124            DeviceDescriptorExtension::DawnDeviceAllocatorControl(ext)
16125        }
16126    }
16127    impl std::convert::From<DawnFakeDeviceInitializeErrorForTesting>
16128    for DeviceDescriptorExtension {
16129        fn from(ext: DawnFakeDeviceInitializeErrorForTesting) -> Self {
16130            DeviceDescriptorExtension::DawnFakeDeviceInitializeErrorForTesting(ext)
16131        }
16132    }
16133    impl std::convert::From<DawnTogglesDescriptor> for DeviceDescriptorExtension {
16134        fn from(ext: DawnTogglesDescriptor) -> Self {
16135            DeviceDescriptorExtension::DawnTogglesDescriptor(ext)
16136        }
16137    }
16138    impl DeviceDescriptorExtension {
16139        pub(crate) fn push_chain(
16140            &self,
16141            storage: &mut ChainedStructStorage,
16142            next: *mut ffi::WGPUChainedStruct,
16143        ) -> *mut ffi::WGPUChainedStruct {
16144            match self {
16145                DeviceDescriptorExtension::DawnCacheDeviceDescriptor(value) => {
16146                    let (mut raw, storage_value) = value.to_ffi();
16147                    raw.chain.sType = SType::DawnCacheDeviceDescriptor.into();
16148                    raw.chain.next = next;
16149                    storage.push_storage(storage_value);
16150                    let raw_ptr = storage.push_value_mut(raw);
16151                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16152                }
16153                DeviceDescriptorExtension::DawnConsumeAdapterDescriptor(value) => {
16154                    let (mut raw, storage_value) = value.to_ffi();
16155                    raw.chain.sType = SType::DawnConsumeAdapterDescriptor.into();
16156                    raw.chain.next = next;
16157                    storage.push_storage(storage_value);
16158                    let raw_ptr = storage.push_value_mut(raw);
16159                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16160                }
16161                DeviceDescriptorExtension::DawnDeviceAllocatorControl(value) => {
16162                    let (mut raw, storage_value) = value.to_ffi();
16163                    raw.chain.sType = SType::DawnDeviceAllocatorControl.into();
16164                    raw.chain.next = next;
16165                    storage.push_storage(storage_value);
16166                    let raw_ptr = storage.push_value_mut(raw);
16167                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16168                }
16169                DeviceDescriptorExtension::DawnFakeDeviceInitializeErrorForTesting(
16170                    value,
16171                ) => {
16172                    let (mut raw, storage_value) = value.to_ffi();
16173                    raw.chain.sType = SType::DawnFakeDeviceInitializeErrorForTesting
16174                        .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                DeviceDescriptorExtension::DawnTogglesDescriptor(value) => {
16181                    let (mut raw, storage_value) = value.to_ffi();
16182                    raw.chain.sType = SType::DawnTogglesDescriptor.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 ExternalTextureDescriptorExtension {}
16193    impl ExternalTextureDescriptorExtension {
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 FragmentStateExtension {}
16206    impl FragmentStateExtension {
16207        pub(crate) fn push_chain(
16208            &self,
16209            storage: &mut ChainedStructStorage,
16210            next: *mut ffi::WGPUChainedStruct,
16211        ) -> *mut ffi::WGPUChainedStruct {
16212            let _ = self;
16213            let _ = storage;
16214            next
16215        }
16216    }
16217    #[allow(dead_code)]
16218    pub enum ImageCopyExternalTextureExtension {}
16219    impl ImageCopyExternalTextureExtension {
16220        pub(crate) fn push_chain(
16221            &self,
16222            storage: &mut ChainedStructStorage,
16223            next: *mut ffi::WGPUChainedStruct,
16224        ) -> *mut ffi::WGPUChainedStruct {
16225            let _ = self;
16226            let _ = storage;
16227            next
16228        }
16229    }
16230    #[allow(dead_code)]
16231    pub enum InstanceDescriptorExtension {
16232        DawnWGSLBlocklist(DawnWGSLBlocklist),
16233        DawnTogglesDescriptor(DawnTogglesDescriptor),
16234        DawnWireWGSLControl(DawnWireWGSLControl),
16235    }
16236    impl std::convert::From<DawnWGSLBlocklist> for InstanceDescriptorExtension {
16237        fn from(ext: DawnWGSLBlocklist) -> Self {
16238            InstanceDescriptorExtension::DawnWGSLBlocklist(ext)
16239        }
16240    }
16241    impl std::convert::From<DawnTogglesDescriptor> for InstanceDescriptorExtension {
16242        fn from(ext: DawnTogglesDescriptor) -> Self {
16243            InstanceDescriptorExtension::DawnTogglesDescriptor(ext)
16244        }
16245    }
16246    impl std::convert::From<DawnWireWGSLControl> for InstanceDescriptorExtension {
16247        fn from(ext: DawnWireWGSLControl) -> Self {
16248            InstanceDescriptorExtension::DawnWireWGSLControl(ext)
16249        }
16250    }
16251    impl InstanceDescriptorExtension {
16252        pub(crate) fn push_chain(
16253            &self,
16254            storage: &mut ChainedStructStorage,
16255            next: *mut ffi::WGPUChainedStruct,
16256        ) -> *mut ffi::WGPUChainedStruct {
16257            match self {
16258                InstanceDescriptorExtension::DawnWGSLBlocklist(value) => {
16259                    let (mut raw, storage_value) = value.to_ffi();
16260                    raw.chain.sType = SType::DawnWGSLBlocklist.into();
16261                    raw.chain.next = next;
16262                    storage.push_storage(storage_value);
16263                    let raw_ptr = storage.push_value_mut(raw);
16264                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16265                }
16266                InstanceDescriptorExtension::DawnTogglesDescriptor(value) => {
16267                    let (mut raw, storage_value) = value.to_ffi();
16268                    raw.chain.sType = SType::DawnTogglesDescriptor.into();
16269                    raw.chain.next = next;
16270                    storage.push_storage(storage_value);
16271                    let raw_ptr = storage.push_value_mut(raw);
16272                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16273                }
16274                InstanceDescriptorExtension::DawnWireWGSLControl(value) => {
16275                    let (mut raw, storage_value) = value.to_ffi();
16276                    raw.chain.sType = SType::DawnWireWGSLControl.into();
16277                    raw.chain.next = next;
16278                    storage.push_storage(storage_value);
16279                    let raw_ptr = storage.push_value_mut(raw);
16280                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16281                }
16282            }
16283        }
16284    }
16285    #[allow(dead_code)]
16286    pub enum InstanceLimitsExtension {}
16287    impl InstanceLimitsExtension {
16288        pub(crate) fn push_chain(
16289            &self,
16290            storage: &mut ChainedStructStorage,
16291            next: *mut ffi::WGPUChainedStruct,
16292        ) -> *mut ffi::WGPUChainedStruct {
16293            let _ = self;
16294            let _ = storage;
16295            next
16296        }
16297    }
16298    #[allow(dead_code)]
16299    pub enum LimitsExtension {
16300        CompatibilityModeLimits(CompatibilityModeLimits),
16301        DawnHostMappedPointerLimits(DawnHostMappedPointerLimits),
16302        DawnTexelCopyBufferRowAlignmentLimits(DawnTexelCopyBufferRowAlignmentLimits),
16303    }
16304    impl std::convert::From<CompatibilityModeLimits> for LimitsExtension {
16305        fn from(ext: CompatibilityModeLimits) -> Self {
16306            LimitsExtension::CompatibilityModeLimits(ext)
16307        }
16308    }
16309    impl std::convert::From<DawnHostMappedPointerLimits> for LimitsExtension {
16310        fn from(ext: DawnHostMappedPointerLimits) -> Self {
16311            LimitsExtension::DawnHostMappedPointerLimits(ext)
16312        }
16313    }
16314    impl std::convert::From<DawnTexelCopyBufferRowAlignmentLimits> for LimitsExtension {
16315        fn from(ext: DawnTexelCopyBufferRowAlignmentLimits) -> Self {
16316            LimitsExtension::DawnTexelCopyBufferRowAlignmentLimits(ext)
16317        }
16318    }
16319    impl LimitsExtension {
16320        pub(crate) fn push_chain(
16321            &self,
16322            storage: &mut ChainedStructStorage,
16323            next: *mut ffi::WGPUChainedStruct,
16324        ) -> *mut ffi::WGPUChainedStruct {
16325            match self {
16326                LimitsExtension::CompatibilityModeLimits(value) => {
16327                    let (mut raw, storage_value) = value.to_ffi();
16328                    raw.chain.sType = SType::CompatibilityModeLimits.into();
16329                    raw.chain.next = next;
16330                    storage.push_storage(storage_value);
16331                    let raw_ptr = storage.push_value_mut(raw);
16332                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16333                }
16334                LimitsExtension::DawnHostMappedPointerLimits(value) => {
16335                    let (mut raw, storage_value) = value.to_ffi();
16336                    raw.chain.sType = SType::DawnHostMappedPointerLimits.into();
16337                    raw.chain.next = next;
16338                    storage.push_storage(storage_value);
16339                    let raw_ptr = storage.push_value_mut(raw);
16340                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16341                }
16342                LimitsExtension::DawnTexelCopyBufferRowAlignmentLimits(value) => {
16343                    let (mut raw, storage_value) = value.to_ffi();
16344                    raw.chain.sType = SType::DawnTexelCopyBufferRowAlignmentLimits
16345                        .into();
16346                    raw.chain.next = next;
16347                    storage.push_storage(storage_value);
16348                    let raw_ptr = storage.push_value_mut(raw);
16349                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16350                }
16351            }
16352        }
16353    }
16354    #[allow(dead_code)]
16355    pub enum MultisampleStateExtension {}
16356    impl MultisampleStateExtension {
16357        pub(crate) fn push_chain(
16358            &self,
16359            storage: &mut ChainedStructStorage,
16360            next: *mut ffi::WGPUChainedStruct,
16361        ) -> *mut ffi::WGPUChainedStruct {
16362            let _ = self;
16363            let _ = storage;
16364            next
16365        }
16366    }
16367    #[allow(dead_code)]
16368    pub enum PassTimestampWritesExtension {}
16369    impl PassTimestampWritesExtension {
16370        pub(crate) fn push_chain(
16371            &self,
16372            storage: &mut ChainedStructStorage,
16373            next: *mut ffi::WGPUChainedStruct,
16374        ) -> *mut ffi::WGPUChainedStruct {
16375            let _ = self;
16376            let _ = storage;
16377            next
16378        }
16379    }
16380    #[allow(dead_code)]
16381    pub enum PipelineLayoutDescriptorExtension {
16382        PipelineLayoutPixelLocalStorage(PipelineLayoutPixelLocalStorage),
16383        PipelineLayoutResourceTable(PipelineLayoutResourceTable),
16384    }
16385    impl std::convert::From<PipelineLayoutPixelLocalStorage>
16386    for PipelineLayoutDescriptorExtension {
16387        fn from(ext: PipelineLayoutPixelLocalStorage) -> Self {
16388            PipelineLayoutDescriptorExtension::PipelineLayoutPixelLocalStorage(ext)
16389        }
16390    }
16391    impl std::convert::From<PipelineLayoutResourceTable>
16392    for PipelineLayoutDescriptorExtension {
16393        fn from(ext: PipelineLayoutResourceTable) -> Self {
16394            PipelineLayoutDescriptorExtension::PipelineLayoutResourceTable(ext)
16395        }
16396    }
16397    impl PipelineLayoutDescriptorExtension {
16398        pub(crate) fn push_chain(
16399            &self,
16400            storage: &mut ChainedStructStorage,
16401            next: *mut ffi::WGPUChainedStruct,
16402        ) -> *mut ffi::WGPUChainedStruct {
16403            match self {
16404                PipelineLayoutDescriptorExtension::PipelineLayoutPixelLocalStorage(
16405                    value,
16406                ) => {
16407                    let (mut raw, storage_value) = value.to_ffi();
16408                    raw.chain.sType = SType::PipelineLayoutPixelLocalStorage.into();
16409                    raw.chain.next = next;
16410                    storage.push_storage(storage_value);
16411                    let raw_ptr = storage.push_value_mut(raw);
16412                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16413                }
16414                PipelineLayoutDescriptorExtension::PipelineLayoutResourceTable(
16415                    value,
16416                ) => {
16417                    let (mut raw, storage_value) = value.to_ffi();
16418                    raw.chain.sType = SType::PipelineLayoutResourceTable.into();
16419                    raw.chain.next = next;
16420                    storage.push_storage(storage_value);
16421                    let raw_ptr = storage.push_value_mut(raw);
16422                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16423                }
16424            }
16425        }
16426    }
16427    #[allow(dead_code)]
16428    pub enum PipelineLayoutStorageAttachmentExtension {}
16429    impl PipelineLayoutStorageAttachmentExtension {
16430        pub(crate) fn push_chain(
16431            &self,
16432            storage: &mut ChainedStructStorage,
16433            next: *mut ffi::WGPUChainedStruct,
16434        ) -> *mut ffi::WGPUChainedStruct {
16435            let _ = self;
16436            let _ = storage;
16437            next
16438        }
16439    }
16440    #[allow(dead_code)]
16441    pub enum PrimitiveStateExtension {}
16442    impl PrimitiveStateExtension {
16443        pub(crate) fn push_chain(
16444            &self,
16445            storage: &mut ChainedStructStorage,
16446            next: *mut ffi::WGPUChainedStruct,
16447        ) -> *mut ffi::WGPUChainedStruct {
16448            let _ = self;
16449            let _ = storage;
16450            next
16451        }
16452    }
16453    #[allow(dead_code)]
16454    pub enum QuerySetDescriptorExtension {}
16455    impl QuerySetDescriptorExtension {
16456        pub(crate) fn push_chain(
16457            &self,
16458            storage: &mut ChainedStructStorage,
16459            next: *mut ffi::WGPUChainedStruct,
16460        ) -> *mut ffi::WGPUChainedStruct {
16461            let _ = self;
16462            let _ = storage;
16463            next
16464        }
16465    }
16466    #[allow(dead_code)]
16467    pub enum QueueDescriptorExtension {}
16468    impl QueueDescriptorExtension {
16469        pub(crate) fn push_chain(
16470            &self,
16471            storage: &mut ChainedStructStorage,
16472            next: *mut ffi::WGPUChainedStruct,
16473        ) -> *mut ffi::WGPUChainedStruct {
16474            let _ = self;
16475            let _ = storage;
16476            next
16477        }
16478    }
16479    #[allow(dead_code)]
16480    pub enum RenderBundleDescriptorExtension {}
16481    impl RenderBundleDescriptorExtension {
16482        pub(crate) fn push_chain(
16483            &self,
16484            storage: &mut ChainedStructStorage,
16485            next: *mut ffi::WGPUChainedStruct,
16486        ) -> *mut ffi::WGPUChainedStruct {
16487            let _ = self;
16488            let _ = storage;
16489            next
16490        }
16491    }
16492    #[allow(dead_code)]
16493    pub enum RenderBundleEncoderDescriptorExtension {}
16494    impl RenderBundleEncoderDescriptorExtension {
16495        pub(crate) fn push_chain(
16496            &self,
16497            storage: &mut ChainedStructStorage,
16498            next: *mut ffi::WGPUChainedStruct,
16499        ) -> *mut ffi::WGPUChainedStruct {
16500            let _ = self;
16501            let _ = storage;
16502            next
16503        }
16504    }
16505    #[allow(dead_code)]
16506    pub enum RenderPassColorAttachmentExtension {}
16507    impl RenderPassColorAttachmentExtension {
16508        pub(crate) fn push_chain(
16509            &self,
16510            storage: &mut ChainedStructStorage,
16511            next: *mut ffi::WGPUChainedStruct,
16512        ) -> *mut ffi::WGPUChainedStruct {
16513            let _ = self;
16514            let _ = storage;
16515            next
16516        }
16517    }
16518    #[allow(dead_code)]
16519    pub enum RenderPassDepthStencilAttachmentExtension {}
16520    impl RenderPassDepthStencilAttachmentExtension {
16521        pub(crate) fn push_chain(
16522            &self,
16523            storage: &mut ChainedStructStorage,
16524            next: *mut ffi::WGPUChainedStruct,
16525        ) -> *mut ffi::WGPUChainedStruct {
16526            let _ = self;
16527            let _ = storage;
16528            next
16529        }
16530    }
16531    #[allow(dead_code)]
16532    pub enum RenderPassDescriptorExtension {
16533        DawnRenderPassSampleCount(DawnRenderPassSampleCount),
16534        RenderPassDescriptorResolveRect(RenderPassDescriptorResolveRect),
16535        RenderPassMaxDrawCount(RenderPassMaxDrawCount),
16536        RenderPassPixelLocalStorage(RenderPassPixelLocalStorage),
16537        RenderPassRenderAreaRect(RenderPassRenderAreaRect),
16538    }
16539    impl std::convert::From<DawnRenderPassSampleCount>
16540    for RenderPassDescriptorExtension {
16541        fn from(ext: DawnRenderPassSampleCount) -> Self {
16542            RenderPassDescriptorExtension::DawnRenderPassSampleCount(ext)
16543        }
16544    }
16545    impl std::convert::From<RenderPassDescriptorResolveRect>
16546    for RenderPassDescriptorExtension {
16547        fn from(ext: RenderPassDescriptorResolveRect) -> Self {
16548            RenderPassDescriptorExtension::RenderPassDescriptorResolveRect(ext)
16549        }
16550    }
16551    impl std::convert::From<RenderPassMaxDrawCount> for RenderPassDescriptorExtension {
16552        fn from(ext: RenderPassMaxDrawCount) -> Self {
16553            RenderPassDescriptorExtension::RenderPassMaxDrawCount(ext)
16554        }
16555    }
16556    impl std::convert::From<RenderPassPixelLocalStorage>
16557    for RenderPassDescriptorExtension {
16558        fn from(ext: RenderPassPixelLocalStorage) -> Self {
16559            RenderPassDescriptorExtension::RenderPassPixelLocalStorage(ext)
16560        }
16561    }
16562    impl std::convert::From<RenderPassRenderAreaRect> for RenderPassDescriptorExtension {
16563        fn from(ext: RenderPassRenderAreaRect) -> Self {
16564            RenderPassDescriptorExtension::RenderPassRenderAreaRect(ext)
16565        }
16566    }
16567    impl RenderPassDescriptorExtension {
16568        pub(crate) fn push_chain(
16569            &self,
16570            storage: &mut ChainedStructStorage,
16571            next: *mut ffi::WGPUChainedStruct,
16572        ) -> *mut ffi::WGPUChainedStruct {
16573            match self {
16574                RenderPassDescriptorExtension::DawnRenderPassSampleCount(value) => {
16575                    let (mut raw, storage_value) = value.to_ffi();
16576                    raw.chain.sType = SType::DawnRenderPassSampleCount.into();
16577                    raw.chain.next = next;
16578                    storage.push_storage(storage_value);
16579                    let raw_ptr = storage.push_value_mut(raw);
16580                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16581                }
16582                RenderPassDescriptorExtension::RenderPassDescriptorResolveRect(
16583                    value,
16584                ) => {
16585                    let (mut raw, storage_value) = value.to_ffi();
16586                    raw.chain.sType = SType::RenderPassDescriptorResolveRect.into();
16587                    raw.chain.next = next;
16588                    storage.push_storage(storage_value);
16589                    let raw_ptr = storage.push_value_mut(raw);
16590                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16591                }
16592                RenderPassDescriptorExtension::RenderPassMaxDrawCount(value) => {
16593                    let (mut raw, storage_value) = value.to_ffi();
16594                    raw.chain.sType = SType::RenderPassMaxDrawCount.into();
16595                    raw.chain.next = next;
16596                    storage.push_storage(storage_value);
16597                    let raw_ptr = storage.push_value_mut(raw);
16598                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16599                }
16600                RenderPassDescriptorExtension::RenderPassPixelLocalStorage(value) => {
16601                    let (mut raw, storage_value) = value.to_ffi();
16602                    raw.chain.sType = SType::RenderPassPixelLocalStorage.into();
16603                    raw.chain.next = next;
16604                    storage.push_storage(storage_value);
16605                    let raw_ptr = storage.push_value_mut(raw);
16606                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16607                }
16608                RenderPassDescriptorExtension::RenderPassRenderAreaRect(value) => {
16609                    let (mut raw, storage_value) = value.to_ffi();
16610                    raw.chain.sType = SType::RenderPassRenderAreaRect.into();
16611                    raw.chain.next = next;
16612                    storage.push_storage(storage_value);
16613                    let raw_ptr = storage.push_value_mut(raw);
16614                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16615                }
16616            }
16617        }
16618    }
16619    #[allow(dead_code)]
16620    pub enum RenderPassStorageAttachmentExtension {}
16621    impl RenderPassStorageAttachmentExtension {
16622        pub(crate) fn push_chain(
16623            &self,
16624            storage: &mut ChainedStructStorage,
16625            next: *mut ffi::WGPUChainedStruct,
16626        ) -> *mut ffi::WGPUChainedStruct {
16627            let _ = self;
16628            let _ = storage;
16629            next
16630        }
16631    }
16632    #[allow(dead_code)]
16633    pub enum RenderPipelineDescriptorExtension {}
16634    impl RenderPipelineDescriptorExtension {
16635        pub(crate) fn push_chain(
16636            &self,
16637            storage: &mut ChainedStructStorage,
16638            next: *mut ffi::WGPUChainedStruct,
16639        ) -> *mut ffi::WGPUChainedStruct {
16640            let _ = self;
16641            let _ = storage;
16642            next
16643        }
16644    }
16645    #[allow(dead_code)]
16646    pub enum RequestAdapterOptionsExtension {
16647        DawnTogglesDescriptor(DawnTogglesDescriptor),
16648        RequestAdapterWebGPUBackendOptions(RequestAdapterWebGPUBackendOptions),
16649        RequestAdapterWebXROptions(RequestAdapterWebXROptions),
16650    }
16651    impl std::convert::From<DawnTogglesDescriptor> for RequestAdapterOptionsExtension {
16652        fn from(ext: DawnTogglesDescriptor) -> Self {
16653            RequestAdapterOptionsExtension::DawnTogglesDescriptor(ext)
16654        }
16655    }
16656    impl std::convert::From<RequestAdapterWebGPUBackendOptions>
16657    for RequestAdapterOptionsExtension {
16658        fn from(ext: RequestAdapterWebGPUBackendOptions) -> Self {
16659            RequestAdapterOptionsExtension::RequestAdapterWebGPUBackendOptions(ext)
16660        }
16661    }
16662    impl std::convert::From<RequestAdapterWebXROptions>
16663    for RequestAdapterOptionsExtension {
16664        fn from(ext: RequestAdapterWebXROptions) -> Self {
16665            RequestAdapterOptionsExtension::RequestAdapterWebXROptions(ext)
16666        }
16667    }
16668    impl RequestAdapterOptionsExtension {
16669        pub(crate) fn push_chain(
16670            &self,
16671            storage: &mut ChainedStructStorage,
16672            next: *mut ffi::WGPUChainedStruct,
16673        ) -> *mut ffi::WGPUChainedStruct {
16674            match self {
16675                RequestAdapterOptionsExtension::DawnTogglesDescriptor(value) => {
16676                    let (mut raw, storage_value) = value.to_ffi();
16677                    raw.chain.sType = SType::DawnTogglesDescriptor.into();
16678                    raw.chain.next = next;
16679                    storage.push_storage(storage_value);
16680                    let raw_ptr = storage.push_value_mut(raw);
16681                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16682                }
16683                RequestAdapterOptionsExtension::RequestAdapterWebGPUBackendOptions(
16684                    value,
16685                ) => {
16686                    let (mut raw, storage_value) = value.to_ffi();
16687                    raw.chain.sType = SType::RequestAdapterWebGPUBackendOptions.into();
16688                    raw.chain.next = next;
16689                    storage.push_storage(storage_value);
16690                    let raw_ptr = storage.push_value_mut(raw);
16691                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16692                }
16693                RequestAdapterOptionsExtension::RequestAdapterWebXROptions(value) => {
16694                    let (mut raw, storage_value) = value.to_ffi();
16695                    raw.chain.sType = SType::RequestAdapterWebXROptions.into();
16696                    raw.chain.next = next;
16697                    storage.push_storage(storage_value);
16698                    let raw_ptr = storage.push_value_mut(raw);
16699                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16700                }
16701            }
16702        }
16703    }
16704    #[allow(dead_code)]
16705    pub enum ResourceTableDescriptorExtension {}
16706    impl ResourceTableDescriptorExtension {
16707        pub(crate) fn push_chain(
16708            &self,
16709            storage: &mut ChainedStructStorage,
16710            next: *mut ffi::WGPUChainedStruct,
16711        ) -> *mut ffi::WGPUChainedStruct {
16712            let _ = self;
16713            let _ = storage;
16714            next
16715        }
16716    }
16717    #[allow(dead_code)]
16718    pub enum SamplerBindingLayoutExtension {}
16719    impl SamplerBindingLayoutExtension {
16720        pub(crate) fn push_chain(
16721            &self,
16722            storage: &mut ChainedStructStorage,
16723            next: *mut ffi::WGPUChainedStruct,
16724        ) -> *mut ffi::WGPUChainedStruct {
16725            let _ = self;
16726            let _ = storage;
16727            next
16728        }
16729    }
16730    #[allow(dead_code)]
16731    pub enum SamplerDescriptorExtension {
16732        YCbCrVkDescriptor(YCbCrVkDescriptor),
16733    }
16734    impl std::convert::From<YCbCrVkDescriptor> for SamplerDescriptorExtension {
16735        fn from(ext: YCbCrVkDescriptor) -> Self {
16736            SamplerDescriptorExtension::YCbCrVkDescriptor(ext)
16737        }
16738    }
16739    impl SamplerDescriptorExtension {
16740        pub(crate) fn push_chain(
16741            &self,
16742            storage: &mut ChainedStructStorage,
16743            next: *mut ffi::WGPUChainedStruct,
16744        ) -> *mut ffi::WGPUChainedStruct {
16745            match self {
16746                SamplerDescriptorExtension::YCbCrVkDescriptor(value) => {
16747                    let (mut raw, storage_value) = value.to_ffi();
16748                    raw.chain.sType = SType::YCbCrVkDescriptor.into();
16749                    raw.chain.next = next;
16750                    storage.push_storage(storage_value);
16751                    let raw_ptr = storage.push_value_mut(raw);
16752                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16753                }
16754            }
16755        }
16756    }
16757    #[allow(dead_code)]
16758    pub enum ShaderModuleDescriptorExtension {
16759        DawnShaderModuleSPIRVOptionsDescriptor(DawnShaderModuleSPIRVOptionsDescriptor),
16760        ShaderModuleCompilationOptions(ShaderModuleCompilationOptions),
16761        ShaderSourceSPIRV(ShaderSourceSPIRV),
16762        ShaderSourceWGSL(ShaderSourceWGSL),
16763    }
16764    impl std::convert::From<DawnShaderModuleSPIRVOptionsDescriptor>
16765    for ShaderModuleDescriptorExtension {
16766        fn from(ext: DawnShaderModuleSPIRVOptionsDescriptor) -> Self {
16767            ShaderModuleDescriptorExtension::DawnShaderModuleSPIRVOptionsDescriptor(ext)
16768        }
16769    }
16770    impl std::convert::From<ShaderModuleCompilationOptions>
16771    for ShaderModuleDescriptorExtension {
16772        fn from(ext: ShaderModuleCompilationOptions) -> Self {
16773            ShaderModuleDescriptorExtension::ShaderModuleCompilationOptions(ext)
16774        }
16775    }
16776    impl std::convert::From<ShaderSourceSPIRV> for ShaderModuleDescriptorExtension {
16777        fn from(ext: ShaderSourceSPIRV) -> Self {
16778            ShaderModuleDescriptorExtension::ShaderSourceSPIRV(ext)
16779        }
16780    }
16781    impl std::convert::From<ShaderSourceWGSL> for ShaderModuleDescriptorExtension {
16782        fn from(ext: ShaderSourceWGSL) -> Self {
16783            ShaderModuleDescriptorExtension::ShaderSourceWGSL(ext)
16784        }
16785    }
16786    impl ShaderModuleDescriptorExtension {
16787        pub(crate) fn push_chain(
16788            &self,
16789            storage: &mut ChainedStructStorage,
16790            next: *mut ffi::WGPUChainedStruct,
16791        ) -> *mut ffi::WGPUChainedStruct {
16792            match self {
16793                ShaderModuleDescriptorExtension::DawnShaderModuleSPIRVOptionsDescriptor(
16794                    value,
16795                ) => {
16796                    let (mut raw, storage_value) = value.to_ffi();
16797                    raw.chain.sType = SType::DawnShaderModuleSPIRVOptionsDescriptor
16798                        .into();
16799                    raw.chain.next = next;
16800                    storage.push_storage(storage_value);
16801                    let raw_ptr = storage.push_value_mut(raw);
16802                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16803                }
16804                ShaderModuleDescriptorExtension::ShaderModuleCompilationOptions(
16805                    value,
16806                ) => {
16807                    let (mut raw, storage_value) = value.to_ffi();
16808                    raw.chain.sType = SType::ShaderModuleCompilationOptions.into();
16809                    raw.chain.next = next;
16810                    storage.push_storage(storage_value);
16811                    let raw_ptr = storage.push_value_mut(raw);
16812                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16813                }
16814                ShaderModuleDescriptorExtension::ShaderSourceSPIRV(value) => {
16815                    let (mut raw, storage_value) = value.to_ffi();
16816                    raw.chain.sType = SType::ShaderSourceSPIRV.into();
16817                    raw.chain.next = next;
16818                    storage.push_storage(storage_value);
16819                    let raw_ptr = storage.push_value_mut(raw);
16820                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16821                }
16822                ShaderModuleDescriptorExtension::ShaderSourceWGSL(value) => {
16823                    let (mut raw, storage_value) = value.to_ffi();
16824                    raw.chain.sType = SType::ShaderSourceWGSL.into();
16825                    raw.chain.next = next;
16826                    storage.push_storage(storage_value);
16827                    let raw_ptr = storage.push_value_mut(raw);
16828                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16829                }
16830            }
16831        }
16832    }
16833    #[allow(dead_code)]
16834    pub enum SharedBufferMemoryBeginAccessDescriptorExtension {}
16835    impl SharedBufferMemoryBeginAccessDescriptorExtension {
16836        pub(crate) fn push_chain(
16837            &self,
16838            storage: &mut ChainedStructStorage,
16839            next: *mut ffi::WGPUChainedStruct,
16840        ) -> *mut ffi::WGPUChainedStruct {
16841            let _ = self;
16842            let _ = storage;
16843            next
16844        }
16845    }
16846    #[allow(dead_code)]
16847    pub enum SharedBufferMemoryDescriptorExtension {
16848        SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor(
16849            SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
16850        ),
16851    }
16852    impl std::convert::From<
16853        SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
16854    > for SharedBufferMemoryDescriptorExtension {
16855        fn from(
16856            ext: SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
16857        ) -> Self {
16858            SharedBufferMemoryDescriptorExtension::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor(
16859                ext,
16860            )
16861        }
16862    }
16863    impl SharedBufferMemoryDescriptorExtension {
16864        pub(crate) fn push_chain(
16865            &self,
16866            storage: &mut ChainedStructStorage,
16867            next: *mut ffi::WGPUChainedStruct,
16868        ) -> *mut ffi::WGPUChainedStruct {
16869            match self {
16870                SharedBufferMemoryDescriptorExtension::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor(
16871                    value,
16872                ) => {
16873                    let (mut raw, storage_value) = value.to_ffi();
16874                    raw.chain.sType = SType::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor
16875                        .into();
16876                    raw.chain.next = next;
16877                    storage.push_storage(storage_value);
16878                    let raw_ptr = storage.push_value_mut(raw);
16879                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16880                }
16881            }
16882        }
16883    }
16884    #[allow(dead_code)]
16885    pub enum SharedBufferMemoryEndAccessStateExtension {}
16886    impl SharedBufferMemoryEndAccessStateExtension {
16887        pub(crate) fn push_chain(
16888            &self,
16889            storage: &mut ChainedStructStorage,
16890            next: *mut ffi::WGPUChainedStruct,
16891        ) -> *mut ffi::WGPUChainedStruct {
16892            let _ = self;
16893            let _ = storage;
16894            next
16895        }
16896    }
16897    #[allow(dead_code)]
16898    pub enum SharedBufferMemoryPropertiesExtension {}
16899    impl SharedBufferMemoryPropertiesExtension {
16900        pub(crate) fn push_chain(
16901            &self,
16902            storage: &mut ChainedStructStorage,
16903            next: *mut ffi::WGPUChainedStruct,
16904        ) -> *mut ffi::WGPUChainedStruct {
16905            let _ = self;
16906            let _ = storage;
16907            next
16908        }
16909    }
16910    #[allow(dead_code)]
16911    pub enum SharedFenceDescriptorExtension {
16912        SharedFenceDXGISharedHandleDescriptor(SharedFenceDXGISharedHandleDescriptor),
16913        SharedFenceEGLSyncDescriptor(SharedFenceEGLSyncDescriptor),
16914        SharedFenceMTLSharedEventDescriptor(SharedFenceMTLSharedEventDescriptor),
16915        SharedFenceSyncFDDescriptor(SharedFenceSyncFDDescriptor),
16916        SharedFenceVkSemaphoreOpaqueFDDescriptor(
16917            SharedFenceVkSemaphoreOpaqueFDDescriptor,
16918        ),
16919        SharedFenceVkSemaphoreZirconHandleDescriptor(
16920            SharedFenceVkSemaphoreZirconHandleDescriptor,
16921        ),
16922    }
16923    impl std::convert::From<SharedFenceDXGISharedHandleDescriptor>
16924    for SharedFenceDescriptorExtension {
16925        fn from(ext: SharedFenceDXGISharedHandleDescriptor) -> Self {
16926            SharedFenceDescriptorExtension::SharedFenceDXGISharedHandleDescriptor(ext)
16927        }
16928    }
16929    impl std::convert::From<SharedFenceEGLSyncDescriptor>
16930    for SharedFenceDescriptorExtension {
16931        fn from(ext: SharedFenceEGLSyncDescriptor) -> Self {
16932            SharedFenceDescriptorExtension::SharedFenceEGLSyncDescriptor(ext)
16933        }
16934    }
16935    impl std::convert::From<SharedFenceMTLSharedEventDescriptor>
16936    for SharedFenceDescriptorExtension {
16937        fn from(ext: SharedFenceMTLSharedEventDescriptor) -> Self {
16938            SharedFenceDescriptorExtension::SharedFenceMTLSharedEventDescriptor(ext)
16939        }
16940    }
16941    impl std::convert::From<SharedFenceSyncFDDescriptor>
16942    for SharedFenceDescriptorExtension {
16943        fn from(ext: SharedFenceSyncFDDescriptor) -> Self {
16944            SharedFenceDescriptorExtension::SharedFenceSyncFDDescriptor(ext)
16945        }
16946    }
16947    impl std::convert::From<SharedFenceVkSemaphoreOpaqueFDDescriptor>
16948    for SharedFenceDescriptorExtension {
16949        fn from(ext: SharedFenceVkSemaphoreOpaqueFDDescriptor) -> Self {
16950            SharedFenceDescriptorExtension::SharedFenceVkSemaphoreOpaqueFDDescriptor(ext)
16951        }
16952    }
16953    impl std::convert::From<SharedFenceVkSemaphoreZirconHandleDescriptor>
16954    for SharedFenceDescriptorExtension {
16955        fn from(ext: SharedFenceVkSemaphoreZirconHandleDescriptor) -> Self {
16956            SharedFenceDescriptorExtension::SharedFenceVkSemaphoreZirconHandleDescriptor(
16957                ext,
16958            )
16959        }
16960    }
16961    impl SharedFenceDescriptorExtension {
16962        pub(crate) fn push_chain(
16963            &self,
16964            storage: &mut ChainedStructStorage,
16965            next: *mut ffi::WGPUChainedStruct,
16966        ) -> *mut ffi::WGPUChainedStruct {
16967            match self {
16968                SharedFenceDescriptorExtension::SharedFenceDXGISharedHandleDescriptor(
16969                    value,
16970                ) => {
16971                    let (mut raw, storage_value) = value.to_ffi();
16972                    raw.chain.sType = SType::SharedFenceDXGISharedHandleDescriptor
16973                        .into();
16974                    raw.chain.next = next;
16975                    storage.push_storage(storage_value);
16976                    let raw_ptr = storage.push_value_mut(raw);
16977                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16978                }
16979                SharedFenceDescriptorExtension::SharedFenceEGLSyncDescriptor(value) => {
16980                    let (mut raw, storage_value) = value.to_ffi();
16981                    raw.chain.sType = SType::SharedFenceEGLSyncDescriptor.into();
16982                    raw.chain.next = next;
16983                    storage.push_storage(storage_value);
16984                    let raw_ptr = storage.push_value_mut(raw);
16985                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16986                }
16987                SharedFenceDescriptorExtension::SharedFenceMTLSharedEventDescriptor(
16988                    value,
16989                ) => {
16990                    let (mut raw, storage_value) = value.to_ffi();
16991                    raw.chain.sType = SType::SharedFenceMTLSharedEventDescriptor.into();
16992                    raw.chain.next = next;
16993                    storage.push_storage(storage_value);
16994                    let raw_ptr = storage.push_value_mut(raw);
16995                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
16996                }
16997                SharedFenceDescriptorExtension::SharedFenceSyncFDDescriptor(value) => {
16998                    let (mut raw, storage_value) = value.to_ffi();
16999                    raw.chain.sType = SType::SharedFenceSyncFDDescriptor.into();
17000                    raw.chain.next = next;
17001                    storage.push_storage(storage_value);
17002                    let raw_ptr = storage.push_value_mut(raw);
17003                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17004                }
17005                SharedFenceDescriptorExtension::SharedFenceVkSemaphoreOpaqueFDDescriptor(
17006                    value,
17007                ) => {
17008                    let (mut raw, storage_value) = value.to_ffi();
17009                    raw.chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDDescriptor
17010                        .into();
17011                    raw.chain.next = next;
17012                    storage.push_storage(storage_value);
17013                    let raw_ptr = storage.push_value_mut(raw);
17014                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17015                }
17016                SharedFenceDescriptorExtension::SharedFenceVkSemaphoreZirconHandleDescriptor(
17017                    value,
17018                ) => {
17019                    let (mut raw, storage_value) = value.to_ffi();
17020                    raw.chain.sType = SType::SharedFenceVkSemaphoreZirconHandleDescriptor
17021                        .into();
17022                    raw.chain.next = next;
17023                    storage.push_storage(storage_value);
17024                    let raw_ptr = storage.push_value_mut(raw);
17025                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17026                }
17027            }
17028        }
17029    }
17030    #[allow(dead_code)]
17031    pub enum SharedFenceExportInfoExtension {
17032        SharedFenceDXGISharedHandleExportInfo(SharedFenceDXGISharedHandleExportInfo),
17033        SharedFenceEGLSyncExportInfo(SharedFenceEGLSyncExportInfo),
17034        SharedFenceMTLSharedEventExportInfo(SharedFenceMTLSharedEventExportInfo),
17035        SharedFenceSyncFDExportInfo(SharedFenceSyncFDExportInfo),
17036        SharedFenceVkSemaphoreOpaqueFDExportInfo(
17037            SharedFenceVkSemaphoreOpaqueFDExportInfo,
17038        ),
17039        SharedFenceVkSemaphoreZirconHandleExportInfo(
17040            SharedFenceVkSemaphoreZirconHandleExportInfo,
17041        ),
17042    }
17043    impl std::convert::From<SharedFenceDXGISharedHandleExportInfo>
17044    for SharedFenceExportInfoExtension {
17045        fn from(ext: SharedFenceDXGISharedHandleExportInfo) -> Self {
17046            SharedFenceExportInfoExtension::SharedFenceDXGISharedHandleExportInfo(ext)
17047        }
17048    }
17049    impl std::convert::From<SharedFenceEGLSyncExportInfo>
17050    for SharedFenceExportInfoExtension {
17051        fn from(ext: SharedFenceEGLSyncExportInfo) -> Self {
17052            SharedFenceExportInfoExtension::SharedFenceEGLSyncExportInfo(ext)
17053        }
17054    }
17055    impl std::convert::From<SharedFenceMTLSharedEventExportInfo>
17056    for SharedFenceExportInfoExtension {
17057        fn from(ext: SharedFenceMTLSharedEventExportInfo) -> Self {
17058            SharedFenceExportInfoExtension::SharedFenceMTLSharedEventExportInfo(ext)
17059        }
17060    }
17061    impl std::convert::From<SharedFenceSyncFDExportInfo>
17062    for SharedFenceExportInfoExtension {
17063        fn from(ext: SharedFenceSyncFDExportInfo) -> Self {
17064            SharedFenceExportInfoExtension::SharedFenceSyncFDExportInfo(ext)
17065        }
17066    }
17067    impl std::convert::From<SharedFenceVkSemaphoreOpaqueFDExportInfo>
17068    for SharedFenceExportInfoExtension {
17069        fn from(ext: SharedFenceVkSemaphoreOpaqueFDExportInfo) -> Self {
17070            SharedFenceExportInfoExtension::SharedFenceVkSemaphoreOpaqueFDExportInfo(ext)
17071        }
17072    }
17073    impl std::convert::From<SharedFenceVkSemaphoreZirconHandleExportInfo>
17074    for SharedFenceExportInfoExtension {
17075        fn from(ext: SharedFenceVkSemaphoreZirconHandleExportInfo) -> Self {
17076            SharedFenceExportInfoExtension::SharedFenceVkSemaphoreZirconHandleExportInfo(
17077                ext,
17078            )
17079        }
17080    }
17081    impl SharedFenceExportInfoExtension {
17082        pub(crate) fn push_chain(
17083            &self,
17084            storage: &mut ChainedStructStorage,
17085            next: *mut ffi::WGPUChainedStruct,
17086        ) -> *mut ffi::WGPUChainedStruct {
17087            match self {
17088                SharedFenceExportInfoExtension::SharedFenceDXGISharedHandleExportInfo(
17089                    value,
17090                ) => {
17091                    let (mut raw, storage_value) = value.to_ffi();
17092                    raw.chain.sType = SType::SharedFenceDXGISharedHandleExportInfo
17093                        .into();
17094                    raw.chain.next = next;
17095                    storage.push_storage(storage_value);
17096                    let raw_ptr = storage.push_value_mut(raw);
17097                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17098                }
17099                SharedFenceExportInfoExtension::SharedFenceEGLSyncExportInfo(value) => {
17100                    let (mut raw, storage_value) = value.to_ffi();
17101                    raw.chain.sType = SType::SharedFenceEGLSyncExportInfo.into();
17102                    raw.chain.next = next;
17103                    storage.push_storage(storage_value);
17104                    let raw_ptr = storage.push_value_mut(raw);
17105                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17106                }
17107                SharedFenceExportInfoExtension::SharedFenceMTLSharedEventExportInfo(
17108                    value,
17109                ) => {
17110                    let (mut raw, storage_value) = value.to_ffi();
17111                    raw.chain.sType = SType::SharedFenceMTLSharedEventExportInfo.into();
17112                    raw.chain.next = next;
17113                    storage.push_storage(storage_value);
17114                    let raw_ptr = storage.push_value_mut(raw);
17115                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17116                }
17117                SharedFenceExportInfoExtension::SharedFenceSyncFDExportInfo(value) => {
17118                    let (mut raw, storage_value) = value.to_ffi();
17119                    raw.chain.sType = SType::SharedFenceSyncFDExportInfo.into();
17120                    raw.chain.next = next;
17121                    storage.push_storage(storage_value);
17122                    let raw_ptr = storage.push_value_mut(raw);
17123                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17124                }
17125                SharedFenceExportInfoExtension::SharedFenceVkSemaphoreOpaqueFDExportInfo(
17126                    value,
17127                ) => {
17128                    let (mut raw, storage_value) = value.to_ffi();
17129                    raw.chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDExportInfo
17130                        .into();
17131                    raw.chain.next = next;
17132                    storage.push_storage(storage_value);
17133                    let raw_ptr = storage.push_value_mut(raw);
17134                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17135                }
17136                SharedFenceExportInfoExtension::SharedFenceVkSemaphoreZirconHandleExportInfo(
17137                    value,
17138                ) => {
17139                    let (mut raw, storage_value) = value.to_ffi();
17140                    raw.chain.sType = SType::SharedFenceVkSemaphoreZirconHandleExportInfo
17141                        .into();
17142                    raw.chain.next = next;
17143                    storage.push_storage(storage_value);
17144                    let raw_ptr = storage.push_value_mut(raw);
17145                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17146                }
17147            }
17148        }
17149    }
17150    #[allow(dead_code)]
17151    pub enum SharedTextureMemoryBeginAccessDescriptorExtension {
17152        SharedTextureMemoryD3DSwapchainBeginState(
17153            SharedTextureMemoryD3DSwapchainBeginState,
17154        ),
17155        SharedTextureMemoryD3D11BeginState(SharedTextureMemoryD3D11BeginState),
17156        SharedTextureMemoryVkImageLayoutBeginState(
17157            SharedTextureMemoryVkImageLayoutBeginState,
17158        ),
17159    }
17160    impl std::convert::From<SharedTextureMemoryD3DSwapchainBeginState>
17161    for SharedTextureMemoryBeginAccessDescriptorExtension {
17162        fn from(ext: SharedTextureMemoryD3DSwapchainBeginState) -> Self {
17163            SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3DSwapchainBeginState(
17164                ext,
17165            )
17166        }
17167    }
17168    impl std::convert::From<SharedTextureMemoryD3D11BeginState>
17169    for SharedTextureMemoryBeginAccessDescriptorExtension {
17170        fn from(ext: SharedTextureMemoryD3D11BeginState) -> Self {
17171            SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3D11BeginState(
17172                ext,
17173            )
17174        }
17175    }
17176    impl std::convert::From<SharedTextureMemoryVkImageLayoutBeginState>
17177    for SharedTextureMemoryBeginAccessDescriptorExtension {
17178        fn from(ext: SharedTextureMemoryVkImageLayoutBeginState) -> Self {
17179            SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryVkImageLayoutBeginState(
17180                ext,
17181            )
17182        }
17183    }
17184    impl SharedTextureMemoryBeginAccessDescriptorExtension {
17185        pub(crate) fn push_chain(
17186            &self,
17187            storage: &mut ChainedStructStorage,
17188            next: *mut ffi::WGPUChainedStruct,
17189        ) -> *mut ffi::WGPUChainedStruct {
17190            match self {
17191                SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3DSwapchainBeginState(
17192                    value,
17193                ) => {
17194                    let (mut raw, storage_value) = value.to_ffi();
17195                    raw.chain.sType = SType::SharedTextureMemoryD3DSwapchainBeginState
17196                        .into();
17197                    raw.chain.next = next;
17198                    storage.push_storage(storage_value);
17199                    let raw_ptr = storage.push_value_mut(raw);
17200                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17201                }
17202                SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3D11BeginState(
17203                    value,
17204                ) => {
17205                    let (mut raw, storage_value) = value.to_ffi();
17206                    raw.chain.sType = SType::SharedTextureMemoryD3D11BeginState.into();
17207                    raw.chain.next = next;
17208                    storage.push_storage(storage_value);
17209                    let raw_ptr = storage.push_value_mut(raw);
17210                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17211                }
17212                SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryVkImageLayoutBeginState(
17213                    value,
17214                ) => {
17215                    let (mut raw, storage_value) = value.to_ffi();
17216                    raw.chain.sType = SType::SharedTextureMemoryVkImageLayoutBeginState
17217                        .into();
17218                    raw.chain.next = next;
17219                    storage.push_storage(storage_value);
17220                    let raw_ptr = storage.push_value_mut(raw);
17221                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17222                }
17223            }
17224        }
17225    }
17226    #[allow(dead_code)]
17227    pub enum SharedTextureMemoryDescriptorExtension {
17228        SharedTextureMemoryDXGISharedHandleDescriptor(
17229            SharedTextureMemoryDXGISharedHandleDescriptor,
17230        ),
17231        SharedTextureMemoryEGLImageDescriptor(SharedTextureMemoryEGLImageDescriptor),
17232        SharedTextureMemoryIOSurfaceDescriptor(SharedTextureMemoryIOSurfaceDescriptor),
17233        SharedTextureMemoryAHardwareBufferDescriptor(
17234            SharedTextureMemoryAHardwareBufferDescriptor,
17235        ),
17236        SharedTextureMemoryDmaBufDescriptor(SharedTextureMemoryDmaBufDescriptor),
17237        SharedTextureMemoryOpaqueFDDescriptor(SharedTextureMemoryOpaqueFDDescriptor),
17238        SharedTextureMemoryVkDedicatedAllocationDescriptor(
17239            SharedTextureMemoryVkDedicatedAllocationDescriptor,
17240        ),
17241        SharedTextureMemoryZirconHandleDescriptor(
17242            SharedTextureMemoryZirconHandleDescriptor,
17243        ),
17244    }
17245    impl std::convert::From<SharedTextureMemoryDXGISharedHandleDescriptor>
17246    for SharedTextureMemoryDescriptorExtension {
17247        fn from(ext: SharedTextureMemoryDXGISharedHandleDescriptor) -> Self {
17248            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDXGISharedHandleDescriptor(
17249                ext,
17250            )
17251        }
17252    }
17253    impl std::convert::From<SharedTextureMemoryEGLImageDescriptor>
17254    for SharedTextureMemoryDescriptorExtension {
17255        fn from(ext: SharedTextureMemoryEGLImageDescriptor) -> Self {
17256            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryEGLImageDescriptor(
17257                ext,
17258            )
17259        }
17260    }
17261    impl std::convert::From<SharedTextureMemoryIOSurfaceDescriptor>
17262    for SharedTextureMemoryDescriptorExtension {
17263        fn from(ext: SharedTextureMemoryIOSurfaceDescriptor) -> Self {
17264            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryIOSurfaceDescriptor(
17265                ext,
17266            )
17267        }
17268    }
17269    impl std::convert::From<SharedTextureMemoryAHardwareBufferDescriptor>
17270    for SharedTextureMemoryDescriptorExtension {
17271        fn from(ext: SharedTextureMemoryAHardwareBufferDescriptor) -> Self {
17272            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryAHardwareBufferDescriptor(
17273                ext,
17274            )
17275        }
17276    }
17277    impl std::convert::From<SharedTextureMemoryDmaBufDescriptor>
17278    for SharedTextureMemoryDescriptorExtension {
17279        fn from(ext: SharedTextureMemoryDmaBufDescriptor) -> Self {
17280            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDmaBufDescriptor(
17281                ext,
17282            )
17283        }
17284    }
17285    impl std::convert::From<SharedTextureMemoryOpaqueFDDescriptor>
17286    for SharedTextureMemoryDescriptorExtension {
17287        fn from(ext: SharedTextureMemoryOpaqueFDDescriptor) -> Self {
17288            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryOpaqueFDDescriptor(
17289                ext,
17290            )
17291        }
17292    }
17293    impl std::convert::From<SharedTextureMemoryVkDedicatedAllocationDescriptor>
17294    for SharedTextureMemoryDescriptorExtension {
17295        fn from(ext: SharedTextureMemoryVkDedicatedAllocationDescriptor) -> Self {
17296            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryVkDedicatedAllocationDescriptor(
17297                ext,
17298            )
17299        }
17300    }
17301    impl std::convert::From<SharedTextureMemoryZirconHandleDescriptor>
17302    for SharedTextureMemoryDescriptorExtension {
17303        fn from(ext: SharedTextureMemoryZirconHandleDescriptor) -> Self {
17304            SharedTextureMemoryDescriptorExtension::SharedTextureMemoryZirconHandleDescriptor(
17305                ext,
17306            )
17307        }
17308    }
17309    impl SharedTextureMemoryDescriptorExtension {
17310        pub(crate) fn push_chain(
17311            &self,
17312            storage: &mut ChainedStructStorage,
17313            next: *mut ffi::WGPUChainedStruct,
17314        ) -> *mut ffi::WGPUChainedStruct {
17315            match self {
17316                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDXGISharedHandleDescriptor(
17317                    value,
17318                ) => {
17319                    let (mut raw, storage_value) = value.to_ffi();
17320                    raw.chain.sType = SType::SharedTextureMemoryDXGISharedHandleDescriptor
17321                        .into();
17322                    raw.chain.next = next;
17323                    storage.push_storage(storage_value);
17324                    let raw_ptr = storage.push_value_mut(raw);
17325                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17326                }
17327                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryEGLImageDescriptor(
17328                    value,
17329                ) => {
17330                    let (mut raw, storage_value) = value.to_ffi();
17331                    raw.chain.sType = SType::SharedTextureMemoryEGLImageDescriptor
17332                        .into();
17333                    raw.chain.next = next;
17334                    storage.push_storage(storage_value);
17335                    let raw_ptr = storage.push_value_mut(raw);
17336                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17337                }
17338                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryIOSurfaceDescriptor(
17339                    value,
17340                ) => {
17341                    let (mut raw, storage_value) = value.to_ffi();
17342                    raw.chain.sType = SType::SharedTextureMemoryIOSurfaceDescriptor
17343                        .into();
17344                    raw.chain.next = next;
17345                    storage.push_storage(storage_value);
17346                    let raw_ptr = storage.push_value_mut(raw);
17347                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17348                }
17349                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryAHardwareBufferDescriptor(
17350                    value,
17351                ) => {
17352                    let (mut raw, storage_value) = value.to_ffi();
17353                    raw.chain.sType = SType::SharedTextureMemoryAHardwareBufferDescriptor
17354                        .into();
17355                    raw.chain.next = next;
17356                    storage.push_storage(storage_value);
17357                    let raw_ptr = storage.push_value_mut(raw);
17358                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17359                }
17360                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDmaBufDescriptor(
17361                    value,
17362                ) => {
17363                    let (mut raw, storage_value) = value.to_ffi();
17364                    raw.chain.sType = SType::SharedTextureMemoryDmaBufDescriptor.into();
17365                    raw.chain.next = next;
17366                    storage.push_storage(storage_value);
17367                    let raw_ptr = storage.push_value_mut(raw);
17368                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17369                }
17370                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryOpaqueFDDescriptor(
17371                    value,
17372                ) => {
17373                    let (mut raw, storage_value) = value.to_ffi();
17374                    raw.chain.sType = SType::SharedTextureMemoryOpaqueFDDescriptor
17375                        .into();
17376                    raw.chain.next = next;
17377                    storage.push_storage(storage_value);
17378                    let raw_ptr = storage.push_value_mut(raw);
17379                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17380                }
17381                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryVkDedicatedAllocationDescriptor(
17382                    value,
17383                ) => {
17384                    let (mut raw, storage_value) = value.to_ffi();
17385                    raw.chain.sType = SType::SharedTextureMemoryVkDedicatedAllocationDescriptor
17386                        .into();
17387                    raw.chain.next = next;
17388                    storage.push_storage(storage_value);
17389                    let raw_ptr = storage.push_value_mut(raw);
17390                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17391                }
17392                SharedTextureMemoryDescriptorExtension::SharedTextureMemoryZirconHandleDescriptor(
17393                    value,
17394                ) => {
17395                    let (mut raw, storage_value) = value.to_ffi();
17396                    raw.chain.sType = SType::SharedTextureMemoryZirconHandleDescriptor
17397                        .into();
17398                    raw.chain.next = next;
17399                    storage.push_storage(storage_value);
17400                    let raw_ptr = storage.push_value_mut(raw);
17401                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17402                }
17403            }
17404        }
17405    }
17406    #[allow(dead_code)]
17407    pub enum SharedTextureMemoryEndAccessStateExtension {
17408        SharedTextureMemoryMetalEndAccessState(SharedTextureMemoryMetalEndAccessState),
17409        SharedTextureMemoryVkImageLayoutEndState(
17410            SharedTextureMemoryVkImageLayoutEndState,
17411        ),
17412    }
17413    impl std::convert::From<SharedTextureMemoryMetalEndAccessState>
17414    for SharedTextureMemoryEndAccessStateExtension {
17415        fn from(ext: SharedTextureMemoryMetalEndAccessState) -> Self {
17416            SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryMetalEndAccessState(
17417                ext,
17418            )
17419        }
17420    }
17421    impl std::convert::From<SharedTextureMemoryVkImageLayoutEndState>
17422    for SharedTextureMemoryEndAccessStateExtension {
17423        fn from(ext: SharedTextureMemoryVkImageLayoutEndState) -> Self {
17424            SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryVkImageLayoutEndState(
17425                ext,
17426            )
17427        }
17428    }
17429    impl SharedTextureMemoryEndAccessStateExtension {
17430        pub(crate) fn push_chain(
17431            &self,
17432            storage: &mut ChainedStructStorage,
17433            next: *mut ffi::WGPUChainedStruct,
17434        ) -> *mut ffi::WGPUChainedStruct {
17435            match self {
17436                SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryMetalEndAccessState(
17437                    value,
17438                ) => {
17439                    let (mut raw, storage_value) = value.to_ffi();
17440                    raw.chain.sType = SType::SharedTextureMemoryMetalEndAccessState
17441                        .into();
17442                    raw.chain.next = next;
17443                    storage.push_storage(storage_value);
17444                    let raw_ptr = storage.push_value_mut(raw);
17445                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17446                }
17447                SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryVkImageLayoutEndState(
17448                    value,
17449                ) => {
17450                    let (mut raw, storage_value) = value.to_ffi();
17451                    raw.chain.sType = SType::SharedTextureMemoryVkImageLayoutEndState
17452                        .into();
17453                    raw.chain.next = next;
17454                    storage.push_storage(storage_value);
17455                    let raw_ptr = storage.push_value_mut(raw);
17456                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17457                }
17458            }
17459        }
17460    }
17461    #[allow(dead_code)]
17462    pub enum SharedTextureMemoryPropertiesExtension {
17463        SharedTextureMemoryAHardwareBufferProperties(
17464            SharedTextureMemoryAHardwareBufferProperties,
17465        ),
17466    }
17467    impl std::convert::From<SharedTextureMemoryAHardwareBufferProperties>
17468    for SharedTextureMemoryPropertiesExtension {
17469        fn from(ext: SharedTextureMemoryAHardwareBufferProperties) -> Self {
17470            SharedTextureMemoryPropertiesExtension::SharedTextureMemoryAHardwareBufferProperties(
17471                ext,
17472            )
17473        }
17474    }
17475    impl SharedTextureMemoryPropertiesExtension {
17476        pub(crate) fn push_chain(
17477            &self,
17478            storage: &mut ChainedStructStorage,
17479            next: *mut ffi::WGPUChainedStruct,
17480        ) -> *mut ffi::WGPUChainedStruct {
17481            match self {
17482                SharedTextureMemoryPropertiesExtension::SharedTextureMemoryAHardwareBufferProperties(
17483                    value,
17484                ) => {
17485                    let (mut raw, storage_value) = value.to_ffi();
17486                    raw.chain.sType = SType::SharedTextureMemoryAHardwareBufferProperties
17487                        .into();
17488                    raw.chain.next = next;
17489                    storage.push_storage(storage_value);
17490                    let raw_ptr = storage.push_value_mut(raw);
17491                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17492                }
17493            }
17494        }
17495    }
17496    #[allow(dead_code)]
17497    pub enum StorageTextureBindingLayoutExtension {}
17498    impl StorageTextureBindingLayoutExtension {
17499        pub(crate) fn push_chain(
17500            &self,
17501            storage: &mut ChainedStructStorage,
17502            next: *mut ffi::WGPUChainedStruct,
17503        ) -> *mut ffi::WGPUChainedStruct {
17504            let _ = self;
17505            let _ = storage;
17506            next
17507        }
17508    }
17509    #[allow(dead_code)]
17510    pub enum SurfaceCapabilitiesExtension {}
17511    impl SurfaceCapabilitiesExtension {
17512        pub(crate) fn push_chain(
17513            &self,
17514            storage: &mut ChainedStructStorage,
17515            next: *mut ffi::WGPUChainedStruct,
17516        ) -> *mut ffi::WGPUChainedStruct {
17517            let _ = self;
17518            let _ = storage;
17519            next
17520        }
17521    }
17522    #[allow(dead_code)]
17523    pub enum SurfaceConfigurationExtension {}
17524    impl SurfaceConfigurationExtension {
17525        pub(crate) fn push_chain(
17526            &self,
17527            storage: &mut ChainedStructStorage,
17528            next: *mut ffi::WGPUChainedStruct,
17529        ) -> *mut ffi::WGPUChainedStruct {
17530            let _ = self;
17531            let _ = storage;
17532            next
17533        }
17534    }
17535    #[allow(dead_code)]
17536    pub enum SurfaceDescriptorExtension {
17537        SurfaceColorManagement(SurfaceColorManagement),
17538        SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17539            SurfaceDescriptorFromWindowsUWPSwapChainPanel,
17540        ),
17541        SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17542            SurfaceDescriptorFromWindowsWinUISwapChainPanel,
17543        ),
17544        SurfaceDescriptorFromWindowsCoreWindow(SurfaceDescriptorFromWindowsCoreWindow),
17545        SurfaceSourceXCBWindow(SurfaceSourceXCBWindow),
17546        SurfaceSourceAndroidNativeWindow(SurfaceSourceAndroidNativeWindow),
17547        SurfaceSourceMetalLayer(SurfaceSourceMetalLayer),
17548        SurfaceSourceWaylandSurface(SurfaceSourceWaylandSurface),
17549        SurfaceSourceWindowsHWND(SurfaceSourceWindowsHWND),
17550        SurfaceSourceXlibWindow(SurfaceSourceXlibWindow),
17551    }
17552    impl std::convert::From<SurfaceColorManagement> for SurfaceDescriptorExtension {
17553        fn from(ext: SurfaceColorManagement) -> Self {
17554            SurfaceDescriptorExtension::SurfaceColorManagement(ext)
17555        }
17556    }
17557    impl std::convert::From<SurfaceDescriptorFromWindowsUWPSwapChainPanel>
17558    for SurfaceDescriptorExtension {
17559        fn from(ext: SurfaceDescriptorFromWindowsUWPSwapChainPanel) -> Self {
17560            SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17561                ext,
17562            )
17563        }
17564    }
17565    impl std::convert::From<SurfaceDescriptorFromWindowsWinUISwapChainPanel>
17566    for SurfaceDescriptorExtension {
17567        fn from(ext: SurfaceDescriptorFromWindowsWinUISwapChainPanel) -> Self {
17568            SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17569                ext,
17570            )
17571        }
17572    }
17573    impl std::convert::From<SurfaceDescriptorFromWindowsCoreWindow>
17574    for SurfaceDescriptorExtension {
17575        fn from(ext: SurfaceDescriptorFromWindowsCoreWindow) -> Self {
17576            SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsCoreWindow(ext)
17577        }
17578    }
17579    impl std::convert::From<SurfaceSourceXCBWindow> for SurfaceDescriptorExtension {
17580        fn from(ext: SurfaceSourceXCBWindow) -> Self {
17581            SurfaceDescriptorExtension::SurfaceSourceXCBWindow(ext)
17582        }
17583    }
17584    impl std::convert::From<SurfaceSourceAndroidNativeWindow>
17585    for SurfaceDescriptorExtension {
17586        fn from(ext: SurfaceSourceAndroidNativeWindow) -> Self {
17587            SurfaceDescriptorExtension::SurfaceSourceAndroidNativeWindow(ext)
17588        }
17589    }
17590    impl std::convert::From<SurfaceSourceMetalLayer> for SurfaceDescriptorExtension {
17591        fn from(ext: SurfaceSourceMetalLayer) -> Self {
17592            SurfaceDescriptorExtension::SurfaceSourceMetalLayer(ext)
17593        }
17594    }
17595    impl std::convert::From<SurfaceSourceWaylandSurface> for SurfaceDescriptorExtension {
17596        fn from(ext: SurfaceSourceWaylandSurface) -> Self {
17597            SurfaceDescriptorExtension::SurfaceSourceWaylandSurface(ext)
17598        }
17599    }
17600    impl std::convert::From<SurfaceSourceWindowsHWND> for SurfaceDescriptorExtension {
17601        fn from(ext: SurfaceSourceWindowsHWND) -> Self {
17602            SurfaceDescriptorExtension::SurfaceSourceWindowsHWND(ext)
17603        }
17604    }
17605    impl std::convert::From<SurfaceSourceXlibWindow> for SurfaceDescriptorExtension {
17606        fn from(ext: SurfaceSourceXlibWindow) -> Self {
17607            SurfaceDescriptorExtension::SurfaceSourceXlibWindow(ext)
17608        }
17609    }
17610    impl SurfaceDescriptorExtension {
17611        pub(crate) fn push_chain(
17612            &self,
17613            storage: &mut ChainedStructStorage,
17614            next: *mut ffi::WGPUChainedStruct,
17615        ) -> *mut ffi::WGPUChainedStruct {
17616            match self {
17617                SurfaceDescriptorExtension::SurfaceColorManagement(value) => {
17618                    let (mut raw, storage_value) = value.to_ffi();
17619                    raw.chain.sType = SType::SurfaceColorManagement.into();
17620                    raw.chain.next = next;
17621                    storage.push_storage(storage_value);
17622                    let raw_ptr = storage.push_value_mut(raw);
17623                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17624                }
17625                SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17626                    value,
17627                ) => {
17628                    let (mut raw, storage_value) = value.to_ffi();
17629                    raw.chain.sType = SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel
17630                        .into();
17631                    raw.chain.next = next;
17632                    storage.push_storage(storage_value);
17633                    let raw_ptr = storage.push_value_mut(raw);
17634                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17635                }
17636                SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17637                    value,
17638                ) => {
17639                    let (mut raw, storage_value) = value.to_ffi();
17640                    raw.chain.sType = SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel
17641                        .into();
17642                    raw.chain.next = next;
17643                    storage.push_storage(storage_value);
17644                    let raw_ptr = storage.push_value_mut(raw);
17645                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17646                }
17647                SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsCoreWindow(
17648                    value,
17649                ) => {
17650                    let (mut raw, storage_value) = value.to_ffi();
17651                    raw.chain.sType = SType::SurfaceDescriptorFromWindowsCoreWindow
17652                        .into();
17653                    raw.chain.next = next;
17654                    storage.push_storage(storage_value);
17655                    let raw_ptr = storage.push_value_mut(raw);
17656                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17657                }
17658                SurfaceDescriptorExtension::SurfaceSourceXCBWindow(value) => {
17659                    let (mut raw, storage_value) = value.to_ffi();
17660                    raw.chain.sType = SType::SurfaceSourceXCBWindow.into();
17661                    raw.chain.next = next;
17662                    storage.push_storage(storage_value);
17663                    let raw_ptr = storage.push_value_mut(raw);
17664                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17665                }
17666                SurfaceDescriptorExtension::SurfaceSourceAndroidNativeWindow(value) => {
17667                    let (mut raw, storage_value) = value.to_ffi();
17668                    raw.chain.sType = SType::SurfaceSourceAndroidNativeWindow.into();
17669                    raw.chain.next = next;
17670                    storage.push_storage(storage_value);
17671                    let raw_ptr = storage.push_value_mut(raw);
17672                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17673                }
17674                SurfaceDescriptorExtension::SurfaceSourceMetalLayer(value) => {
17675                    let (mut raw, storage_value) = value.to_ffi();
17676                    raw.chain.sType = SType::SurfaceSourceMetalLayer.into();
17677                    raw.chain.next = next;
17678                    storage.push_storage(storage_value);
17679                    let raw_ptr = storage.push_value_mut(raw);
17680                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17681                }
17682                SurfaceDescriptorExtension::SurfaceSourceWaylandSurface(value) => {
17683                    let (mut raw, storage_value) = value.to_ffi();
17684                    raw.chain.sType = SType::SurfaceSourceWaylandSurface.into();
17685                    raw.chain.next = next;
17686                    storage.push_storage(storage_value);
17687                    let raw_ptr = storage.push_value_mut(raw);
17688                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17689                }
17690                SurfaceDescriptorExtension::SurfaceSourceWindowsHWND(value) => {
17691                    let (mut raw, storage_value) = value.to_ffi();
17692                    raw.chain.sType = SType::SurfaceSourceWindowsHWND.into();
17693                    raw.chain.next = next;
17694                    storage.push_storage(storage_value);
17695                    let raw_ptr = storage.push_value_mut(raw);
17696                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17697                }
17698                SurfaceDescriptorExtension::SurfaceSourceXlibWindow(value) => {
17699                    let (mut raw, storage_value) = value.to_ffi();
17700                    raw.chain.sType = SType::SurfaceSourceXlibWindow.into();
17701                    raw.chain.next = next;
17702                    storage.push_storage(storage_value);
17703                    let raw_ptr = storage.push_value_mut(raw);
17704                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17705                }
17706            }
17707        }
17708    }
17709    #[allow(dead_code)]
17710    pub enum SurfaceTextureExtension {}
17711    impl SurfaceTextureExtension {
17712        pub(crate) fn push_chain(
17713            &self,
17714            storage: &mut ChainedStructStorage,
17715            next: *mut ffi::WGPUChainedStruct,
17716        ) -> *mut ffi::WGPUChainedStruct {
17717            let _ = self;
17718            let _ = storage;
17719            next
17720        }
17721    }
17722    #[allow(dead_code)]
17723    pub enum TexelBufferViewDescriptorExtension {}
17724    impl TexelBufferViewDescriptorExtension {
17725        pub(crate) fn push_chain(
17726            &self,
17727            storage: &mut ChainedStructStorage,
17728            next: *mut ffi::WGPUChainedStruct,
17729        ) -> *mut ffi::WGPUChainedStruct {
17730            let _ = self;
17731            let _ = storage;
17732            next
17733        }
17734    }
17735    #[allow(dead_code)]
17736    pub enum TextureBindingLayoutExtension {}
17737    impl TextureBindingLayoutExtension {
17738        pub(crate) fn push_chain(
17739            &self,
17740            storage: &mut ChainedStructStorage,
17741            next: *mut ffi::WGPUChainedStruct,
17742        ) -> *mut ffi::WGPUChainedStruct {
17743            let _ = self;
17744            let _ = storage;
17745            next
17746        }
17747    }
17748    #[allow(dead_code)]
17749    pub enum TextureDescriptorExtension {
17750        DawnTextureInternalUsageDescriptor(DawnTextureInternalUsageDescriptor),
17751        TextureBindingViewDimension(TextureBindingViewDimension),
17752    }
17753    impl std::convert::From<DawnTextureInternalUsageDescriptor>
17754    for TextureDescriptorExtension {
17755        fn from(ext: DawnTextureInternalUsageDescriptor) -> Self {
17756            TextureDescriptorExtension::DawnTextureInternalUsageDescriptor(ext)
17757        }
17758    }
17759    impl std::convert::From<TextureBindingViewDimension> for TextureDescriptorExtension {
17760        fn from(ext: TextureBindingViewDimension) -> Self {
17761            TextureDescriptorExtension::TextureBindingViewDimension(ext)
17762        }
17763    }
17764    impl TextureDescriptorExtension {
17765        pub(crate) fn push_chain(
17766            &self,
17767            storage: &mut ChainedStructStorage,
17768            next: *mut ffi::WGPUChainedStruct,
17769        ) -> *mut ffi::WGPUChainedStruct {
17770            match self {
17771                TextureDescriptorExtension::DawnTextureInternalUsageDescriptor(
17772                    value,
17773                ) => {
17774                    let (mut raw, storage_value) = value.to_ffi();
17775                    raw.chain.sType = SType::DawnTextureInternalUsageDescriptor.into();
17776                    raw.chain.next = next;
17777                    storage.push_storage(storage_value);
17778                    let raw_ptr = storage.push_value_mut(raw);
17779                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17780                }
17781                TextureDescriptorExtension::TextureBindingViewDimension(value) => {
17782                    let (mut raw, storage_value) = value.to_ffi();
17783                    raw.chain.sType = SType::TextureBindingViewDimension.into();
17784                    raw.chain.next = next;
17785                    storage.push_storage(storage_value);
17786                    let raw_ptr = storage.push_value_mut(raw);
17787                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17788                }
17789            }
17790        }
17791    }
17792    #[allow(dead_code)]
17793    pub enum TextureViewDescriptorExtension {
17794        TextureComponentSwizzleDescriptor(TextureComponentSwizzleDescriptor),
17795        YCbCrVkDescriptor(YCbCrVkDescriptor),
17796    }
17797    impl std::convert::From<TextureComponentSwizzleDescriptor>
17798    for TextureViewDescriptorExtension {
17799        fn from(ext: TextureComponentSwizzleDescriptor) -> Self {
17800            TextureViewDescriptorExtension::TextureComponentSwizzleDescriptor(ext)
17801        }
17802    }
17803    impl std::convert::From<YCbCrVkDescriptor> for TextureViewDescriptorExtension {
17804        fn from(ext: YCbCrVkDescriptor) -> Self {
17805            TextureViewDescriptorExtension::YCbCrVkDescriptor(ext)
17806        }
17807    }
17808    impl TextureViewDescriptorExtension {
17809        pub(crate) fn push_chain(
17810            &self,
17811            storage: &mut ChainedStructStorage,
17812            next: *mut ffi::WGPUChainedStruct,
17813        ) -> *mut ffi::WGPUChainedStruct {
17814            match self {
17815                TextureViewDescriptorExtension::TextureComponentSwizzleDescriptor(
17816                    value,
17817                ) => {
17818                    let (mut raw, storage_value) = value.to_ffi();
17819                    raw.chain.sType = SType::TextureComponentSwizzleDescriptor.into();
17820                    raw.chain.next = next;
17821                    storage.push_storage(storage_value);
17822                    let raw_ptr = storage.push_value_mut(raw);
17823                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17824                }
17825                TextureViewDescriptorExtension::YCbCrVkDescriptor(value) => {
17826                    let (mut raw, storage_value) = value.to_ffi();
17827                    raw.chain.sType = SType::YCbCrVkDescriptor.into();
17828                    raw.chain.next = next;
17829                    storage.push_storage(storage_value);
17830                    let raw_ptr = storage.push_value_mut(raw);
17831                    raw_ptr.cast::<ffi::WGPUChainedStruct>()
17832                }
17833            }
17834        }
17835    }
17836    #[allow(dead_code)]
17837    pub enum VertexAttributeExtension {}
17838    impl VertexAttributeExtension {
17839        pub(crate) fn push_chain(
17840            &self,
17841            storage: &mut ChainedStructStorage,
17842            next: *mut ffi::WGPUChainedStruct,
17843        ) -> *mut ffi::WGPUChainedStruct {
17844            let _ = self;
17845            let _ = storage;
17846            next
17847        }
17848    }
17849    #[allow(dead_code)]
17850    pub enum VertexBufferLayoutExtension {}
17851    impl VertexBufferLayoutExtension {
17852        pub(crate) fn push_chain(
17853            &self,
17854            storage: &mut ChainedStructStorage,
17855            next: *mut ffi::WGPUChainedStruct,
17856        ) -> *mut ffi::WGPUChainedStruct {
17857            let _ = self;
17858            let _ = storage;
17859            next
17860        }
17861    }
17862    #[allow(dead_code)]
17863    pub enum VertexStateExtension {}
17864    impl VertexStateExtension {
17865        pub(crate) fn push_chain(
17866            &self,
17867            storage: &mut ChainedStructStorage,
17868            next: *mut ffi::WGPUChainedStruct,
17869        ) -> *mut ffi::WGPUChainedStruct {
17870            let _ = self;
17871            let _ = storage;
17872            next
17873        }
17874    }
17875}
17876mod objects {
17877    #![allow(dead_code, unused_imports)]
17878    use crate::generated::*;
17879    use crate::ffi;
17880    #[derive(Debug)]
17881    pub struct Adapter {
17882        raw: ffi::WGPUAdapter,
17883    }
17884    impl Adapter {
17885        pub(crate) unsafe fn from_raw(raw: ffi::WGPUAdapter) -> Self {
17886            Self { raw }
17887        }
17888        pub(crate) fn as_raw(&self) -> ffi::WGPUAdapter {
17889            self.raw
17890        }
17891        pub fn get_instance(&self) -> Instance {
17892            let result = unsafe { ffi::wgpuAdapterGetInstance(self.raw) };
17893            unsafe { Instance::from_raw(result) }
17894        }
17895        pub fn get_limits(&self, limits: &mut Limits) -> Status {
17896            let (mut limits_ffi, _limits_storage) = limits.to_ffi();
17897            let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
17898            let result = unsafe { ffi::wgpuAdapterGetLimits(self.raw, limits_ptr) };
17899            *limits = Limits::from_ffi(limits_ffi);
17900            result.into()
17901        }
17902        pub fn get_info(&self, info: &mut AdapterInfo) -> Status {
17903            let (mut info_ffi, _info_storage) = info.to_ffi();
17904            let info_ptr = std::ptr::addr_of_mut!(info_ffi);
17905            let result = unsafe { ffi::wgpuAdapterGetInfo(self.raw, info_ptr) };
17906            *info = AdapterInfo::from_ffi(info_ffi);
17907            result.into()
17908        }
17909        pub fn has_feature(&self, feature: FeatureName) -> bool {
17910            let feature_ffi: ffi::WGPUFeatureName = feature.into();
17911            let result = unsafe { ffi::wgpuAdapterHasFeature(self.raw, feature_ffi) };
17912            result != 0
17913        }
17914        pub fn get_features(&self, features: &mut SupportedFeatures) -> () {
17915            let (mut features_ffi, _features_storage) = features.to_ffi();
17916            let features_ptr = std::ptr::addr_of_mut!(features_ffi);
17917            unsafe { ffi::wgpuAdapterGetFeatures(self.raw, features_ptr) };
17918            *features = SupportedFeatures::from_ffi(features_ffi);
17919            ()
17920        }
17921        pub fn request_device(
17922            &self,
17923            descriptor: Option<&DeviceDescriptor>,
17924            callback: impl FnMut(
17925                RequestDeviceStatus,
17926                Option<Device>,
17927                String,
17928            ) + Send + 'static,
17929        ) -> Future {
17930            let mut descriptor_storage = ChainedStructStorage::new();
17931            let mut descriptor_ffi: Option<ffi::WGPUDeviceDescriptor> = None;
17932            let descriptor_ptr = if let Some(value) = &descriptor {
17933                let (raw, storage) = value.to_ffi();
17934                descriptor_storage = storage;
17935                descriptor_ffi = Some(raw);
17936                if let Some(raw_ref) = descriptor_ffi.as_ref() {
17937                    std::ptr::from_ref(raw_ref)
17938                } else {
17939                    unreachable!(
17940                        "internal error: descriptor_ffi missing after assignment",
17941                    )
17942                }
17943            } else {
17944                std::ptr::null()
17945            };
17946            let callback_box: RequestDeviceCallback = Box::new(callback);
17947            let callback_box = Box::new(Some(callback_box));
17948            let callback_userdata = Box::into_raw(callback_box)
17949                .cast::<std::ffi::c_void>();
17950            let callback_info_ffi = ffi::WGPURequestDeviceCallbackInfo {
17951                nextInChain: std::ptr::null_mut(),
17952                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
17953                callback: Some(request_device_callback_trampoline),
17954                userdata1: callback_userdata,
17955                userdata2: std::ptr::null_mut(),
17956            };
17957            let result = unsafe {
17958                ffi::wgpuAdapterRequestDevice(
17959                    self.raw,
17960                    descriptor_ptr,
17961                    callback_info_ffi,
17962                )
17963            };
17964            Future::from_ffi(result)
17965        }
17966        pub fn create_device(&self, descriptor: Option<&DeviceDescriptor>) -> Device {
17967            let mut descriptor_storage = ChainedStructStorage::new();
17968            let mut descriptor_ffi: Option<ffi::WGPUDeviceDescriptor> = None;
17969            let descriptor_ptr = if let Some(value) = &descriptor {
17970                let (raw, storage) = value.to_ffi();
17971                descriptor_storage = storage;
17972                descriptor_ffi = Some(raw);
17973                if let Some(raw_ref) = descriptor_ffi.as_ref() {
17974                    std::ptr::from_ref(raw_ref)
17975                } else {
17976                    unreachable!(
17977                        "internal error: descriptor_ffi missing after assignment",
17978                    )
17979                }
17980            } else {
17981                std::ptr::null()
17982            };
17983            let result = unsafe {
17984                ffi::wgpuAdapterCreateDevice(self.raw, descriptor_ptr)
17985            };
17986            unsafe { Device::from_raw(result) }
17987        }
17988        pub fn get_format_capabilities(
17989            &self,
17990            format: TextureFormat,
17991            capabilities: &mut DawnFormatCapabilities,
17992        ) -> Status {
17993            let format_ffi: ffi::WGPUTextureFormat = format.into();
17994            let (mut capabilities_ffi, _capabilities_storage) = capabilities.to_ffi();
17995            let capabilities_ptr = std::ptr::addr_of_mut!(capabilities_ffi);
17996            let result = unsafe {
17997                ffi::wgpuAdapterGetFormatCapabilities(
17998                    self.raw,
17999                    format_ffi,
18000                    capabilities_ptr,
18001                )
18002            };
18003            *capabilities = DawnFormatCapabilities::from_ffi(capabilities_ffi);
18004            result.into()
18005        }
18006    }
18007    impl Drop for Adapter {
18008        fn drop(&mut self) {
18009            if self.as_raw().is_null() {
18010                return;
18011            }
18012            unsafe { ffi::wgpuAdapterRelease(self.raw) };
18013        }
18014    }
18015    impl Clone for Adapter {
18016        fn clone(&self) -> Self {
18017            unsafe { ffi::wgpuAdapterAddRef(self.raw) };
18018            Self { raw: self.raw }
18019        }
18020    }
18021    #[derive(Debug)]
18022    pub struct BindGroup {
18023        raw: ffi::WGPUBindGroup,
18024    }
18025    impl BindGroup {
18026        pub(crate) unsafe fn from_raw(raw: ffi::WGPUBindGroup) -> Self {
18027            Self { raw }
18028        }
18029        pub(crate) fn as_raw(&self) -> ffi::WGPUBindGroup {
18030            self.raw
18031        }
18032        pub fn set_label(&self, label: String) -> () {
18033            let label_ffi = ffi::WGPUStringView {
18034                data: label.as_ptr().cast(),
18035                length: label.len(),
18036            };
18037            unsafe { ffi::wgpuBindGroupSetLabel(self.raw, label_ffi) };
18038            ()
18039        }
18040    }
18041    impl Drop for BindGroup {
18042        fn drop(&mut self) {
18043            if self.as_raw().is_null() {
18044                return;
18045            }
18046            unsafe { ffi::wgpuBindGroupRelease(self.raw) };
18047        }
18048    }
18049    impl Clone for BindGroup {
18050        fn clone(&self) -> Self {
18051            unsafe { ffi::wgpuBindGroupAddRef(self.raw) };
18052            Self { raw: self.raw }
18053        }
18054    }
18055    unsafe impl Send for BindGroup {}
18056    unsafe impl Sync for BindGroup {}
18057    #[derive(Debug)]
18058    pub struct BindGroupLayout {
18059        raw: ffi::WGPUBindGroupLayout,
18060    }
18061    impl BindGroupLayout {
18062        pub(crate) unsafe fn from_raw(raw: ffi::WGPUBindGroupLayout) -> Self {
18063            Self { raw }
18064        }
18065        pub(crate) fn as_raw(&self) -> ffi::WGPUBindGroupLayout {
18066            self.raw
18067        }
18068        pub fn set_label(&self, label: String) -> () {
18069            let label_ffi = ffi::WGPUStringView {
18070                data: label.as_ptr().cast(),
18071                length: label.len(),
18072            };
18073            unsafe { ffi::wgpuBindGroupLayoutSetLabel(self.raw, label_ffi) };
18074            ()
18075        }
18076    }
18077    impl Drop for BindGroupLayout {
18078        fn drop(&mut self) {
18079            if self.as_raw().is_null() {
18080                return;
18081            }
18082            unsafe { ffi::wgpuBindGroupLayoutRelease(self.raw) };
18083        }
18084    }
18085    impl Clone for BindGroupLayout {
18086        fn clone(&self) -> Self {
18087            unsafe { ffi::wgpuBindGroupLayoutAddRef(self.raw) };
18088            Self { raw: self.raw }
18089        }
18090    }
18091    unsafe impl Send for BindGroupLayout {}
18092    unsafe impl Sync for BindGroupLayout {}
18093    #[derive(Debug)]
18094    pub struct Buffer {
18095        raw: ffi::WGPUBuffer,
18096    }
18097    impl Buffer {
18098        pub(crate) unsafe fn from_raw(raw: ffi::WGPUBuffer) -> Self {
18099            Self { raw }
18100        }
18101        pub(crate) fn as_raw(&self) -> ffi::WGPUBuffer {
18102            self.raw
18103        }
18104        pub fn map_async(
18105            &self,
18106            mode: MapMode,
18107            offset: usize,
18108            size: usize,
18109            callback: impl FnMut(MapAsyncStatus, String) + Send + 'static,
18110        ) -> Future {
18111            let mode_ffi: ffi::WGPUMapMode = mode.into();
18112            let callback_box: BufferMapCallback = Box::new(callback);
18113            let callback_box = Box::new(Some(callback_box));
18114            let callback_userdata = Box::into_raw(callback_box)
18115                .cast::<std::ffi::c_void>();
18116            let callback_info_ffi = ffi::WGPUBufferMapCallbackInfo {
18117                nextInChain: std::ptr::null_mut(),
18118                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18119                callback: Some(buffer_map_callback_trampoline),
18120                userdata1: callback_userdata,
18121                userdata2: std::ptr::null_mut(),
18122            };
18123            let result = unsafe {
18124                ffi::wgpuBufferMapAsync(
18125                    self.raw,
18126                    mode_ffi,
18127                    offset,
18128                    size,
18129                    callback_info_ffi,
18130                )
18131            };
18132            Future::from_ffi(result)
18133        }
18134        pub fn get_mapped_range(
18135            &self,
18136            offset: usize,
18137            size: usize,
18138        ) -> *mut std::ffi::c_void {
18139            let result = unsafe {
18140                ffi::wgpuBufferGetMappedRange(self.raw, offset, size)
18141            };
18142            result
18143        }
18144        pub fn get_const_mapped_range(
18145            &self,
18146            offset: usize,
18147            size: usize,
18148        ) -> *const std::ffi::c_void {
18149            let result = unsafe {
18150                ffi::wgpuBufferGetConstMappedRange(self.raw, offset, size)
18151            };
18152            result
18153        }
18154        pub fn write_mapped_range(
18155            &self,
18156            offset: usize,
18157            data: &[std::ffi::c_void],
18158        ) -> Status {
18159            let data_ptr = data.as_ptr();
18160            let result = unsafe {
18161                ffi::wgpuBufferWriteMappedRange(self.raw, offset, data_ptr, data.len())
18162            };
18163            result.into()
18164        }
18165        pub fn read_mapped_range(
18166            &self,
18167            offset: usize,
18168            mut data: &mut [std::ffi::c_void],
18169        ) -> Status {
18170            let data_ptr = data.as_mut_ptr();
18171            let result = unsafe {
18172                ffi::wgpuBufferReadMappedRange(self.raw, offset, data_ptr, data.len())
18173            };
18174            result.into()
18175        }
18176        pub fn create_texel_view(
18177            &self,
18178            descriptor: &TexelBufferViewDescriptor,
18179        ) -> TexelBufferView {
18180            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18181            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18182            let result = unsafe {
18183                ffi::wgpuBufferCreateTexelView(self.raw, descriptor_ptr)
18184            };
18185            unsafe { TexelBufferView::from_raw(result) }
18186        }
18187        pub fn set_label(&self, label: String) -> () {
18188            let label_ffi = ffi::WGPUStringView {
18189                data: label.as_ptr().cast(),
18190                length: label.len(),
18191            };
18192            unsafe { ffi::wgpuBufferSetLabel(self.raw, label_ffi) };
18193            ()
18194        }
18195        pub fn get_usage(&self) -> BufferUsage {
18196            let result = unsafe { ffi::wgpuBufferGetUsage(self.raw) };
18197            result.into()
18198        }
18199        pub fn get_size(&self) -> u64 {
18200            let result = unsafe { ffi::wgpuBufferGetSize(self.raw) };
18201            result
18202        }
18203        pub fn get_map_state(&self) -> BufferMapState {
18204            let result = unsafe { ffi::wgpuBufferGetMapState(self.raw) };
18205            result.into()
18206        }
18207        pub fn unmap(&self) -> () {
18208            unsafe { ffi::wgpuBufferUnmap(self.raw) };
18209            ()
18210        }
18211        pub fn destroy(&self) -> () {
18212            unsafe { ffi::wgpuBufferDestroy(self.raw) };
18213            ()
18214        }
18215    }
18216    impl Drop for Buffer {
18217        fn drop(&mut self) {
18218            if self.as_raw().is_null() {
18219                return;
18220            }
18221            unsafe { ffi::wgpuBufferRelease(self.raw) };
18222        }
18223    }
18224    impl Clone for Buffer {
18225        fn clone(&self) -> Self {
18226            unsafe { ffi::wgpuBufferAddRef(self.raw) };
18227            Self { raw: self.raw }
18228        }
18229    }
18230    unsafe impl Send for Buffer {}
18231    unsafe impl Sync for Buffer {}
18232    #[derive(Debug)]
18233    pub struct CommandBuffer {
18234        raw: ffi::WGPUCommandBuffer,
18235    }
18236    impl CommandBuffer {
18237        pub(crate) unsafe fn from_raw(raw: ffi::WGPUCommandBuffer) -> Self {
18238            Self { raw }
18239        }
18240        pub(crate) fn as_raw(&self) -> ffi::WGPUCommandBuffer {
18241            self.raw
18242        }
18243        pub fn set_label(&self, label: String) -> () {
18244            let label_ffi = ffi::WGPUStringView {
18245                data: label.as_ptr().cast(),
18246                length: label.len(),
18247            };
18248            unsafe { ffi::wgpuCommandBufferSetLabel(self.raw, label_ffi) };
18249            ()
18250        }
18251    }
18252    impl Drop for CommandBuffer {
18253        fn drop(&mut self) {
18254            if self.as_raw().is_null() {
18255                return;
18256            }
18257            unsafe { ffi::wgpuCommandBufferRelease(self.raw) };
18258        }
18259    }
18260    impl Clone for CommandBuffer {
18261        fn clone(&self) -> Self {
18262            unsafe { ffi::wgpuCommandBufferAddRef(self.raw) };
18263            Self { raw: self.raw }
18264        }
18265    }
18266    unsafe impl Send for CommandBuffer {}
18267    unsafe impl Sync for CommandBuffer {}
18268    #[derive(Debug)]
18269    pub struct CommandEncoder {
18270        raw: ffi::WGPUCommandEncoder,
18271    }
18272    impl CommandEncoder {
18273        pub(crate) unsafe fn from_raw(raw: ffi::WGPUCommandEncoder) -> Self {
18274            Self { raw }
18275        }
18276        pub(crate) fn as_raw(&self) -> ffi::WGPUCommandEncoder {
18277            self.raw
18278        }
18279        pub fn finish(
18280            &self,
18281            descriptor: Option<&CommandBufferDescriptor>,
18282        ) -> CommandBuffer {
18283            let mut descriptor_storage = ChainedStructStorage::new();
18284            let mut descriptor_ffi: Option<ffi::WGPUCommandBufferDescriptor> = None;
18285            let descriptor_ptr = if let Some(value) = &descriptor {
18286                let (raw, storage) = value.to_ffi();
18287                descriptor_storage = storage;
18288                descriptor_ffi = Some(raw);
18289                if let Some(raw_ref) = descriptor_ffi.as_ref() {
18290                    std::ptr::from_ref(raw_ref)
18291                } else {
18292                    unreachable!(
18293                        "internal error: descriptor_ffi missing after assignment",
18294                    )
18295                }
18296            } else {
18297                std::ptr::null()
18298            };
18299            let result = unsafe {
18300                ffi::wgpuCommandEncoderFinish(self.raw, descriptor_ptr)
18301            };
18302            unsafe { CommandBuffer::from_raw(result) }
18303        }
18304        pub fn begin_compute_pass(
18305            &self,
18306            descriptor: Option<&ComputePassDescriptor>,
18307        ) -> ComputePassEncoder {
18308            let mut descriptor_storage = ChainedStructStorage::new();
18309            let mut descriptor_ffi: Option<ffi::WGPUComputePassDescriptor> = None;
18310            let descriptor_ptr = if let Some(value) = &descriptor {
18311                let (raw, storage) = value.to_ffi();
18312                descriptor_storage = storage;
18313                descriptor_ffi = Some(raw);
18314                if let Some(raw_ref) = descriptor_ffi.as_ref() {
18315                    std::ptr::from_ref(raw_ref)
18316                } else {
18317                    unreachable!(
18318                        "internal error: descriptor_ffi missing after assignment",
18319                    )
18320                }
18321            } else {
18322                std::ptr::null()
18323            };
18324            let result = unsafe {
18325                ffi::wgpuCommandEncoderBeginComputePass(self.raw, descriptor_ptr)
18326            };
18327            unsafe { ComputePassEncoder::from_raw(result) }
18328        }
18329        pub fn begin_render_pass(
18330            &self,
18331            descriptor: &RenderPassDescriptor,
18332        ) -> RenderPassEncoder {
18333            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18334            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18335            let result = unsafe {
18336                ffi::wgpuCommandEncoderBeginRenderPass(self.raw, descriptor_ptr)
18337            };
18338            unsafe { RenderPassEncoder::from_raw(result) }
18339        }
18340        pub fn copy_buffer_to_buffer(
18341            &self,
18342            source: Buffer,
18343            source_offset: u64,
18344            destination: Buffer,
18345            destination_offset: u64,
18346            size: u64,
18347        ) -> () {
18348            unsafe {
18349                ffi::wgpuCommandEncoderCopyBufferToBuffer(
18350                    self.raw,
18351                    source.as_raw(),
18352                    source_offset,
18353                    destination.as_raw(),
18354                    destination_offset,
18355                    size,
18356                )
18357            };
18358            ()
18359        }
18360        pub fn copy_buffer_to_texture(
18361            &self,
18362            source: &TexelCopyBufferInfo,
18363            destination: &TexelCopyTextureInfo,
18364            copy_size: &Extent3D,
18365        ) -> () {
18366            let (source_ffi, _source_storage) = source.to_ffi();
18367            let source_ptr = std::ptr::addr_of!(source_ffi);
18368            let (destination_ffi, _destination_storage) = destination.to_ffi();
18369            let destination_ptr = std::ptr::addr_of!(destination_ffi);
18370            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18371            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18372            unsafe {
18373                ffi::wgpuCommandEncoderCopyBufferToTexture(
18374                    self.raw,
18375                    source_ptr,
18376                    destination_ptr,
18377                    copy_size_ptr,
18378                )
18379            };
18380            ()
18381        }
18382        pub fn copy_texture_to_buffer(
18383            &self,
18384            source: &TexelCopyTextureInfo,
18385            destination: &TexelCopyBufferInfo,
18386            copy_size: &Extent3D,
18387        ) -> () {
18388            let (source_ffi, _source_storage) = source.to_ffi();
18389            let source_ptr = std::ptr::addr_of!(source_ffi);
18390            let (destination_ffi, _destination_storage) = destination.to_ffi();
18391            let destination_ptr = std::ptr::addr_of!(destination_ffi);
18392            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18393            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18394            unsafe {
18395                ffi::wgpuCommandEncoderCopyTextureToBuffer(
18396                    self.raw,
18397                    source_ptr,
18398                    destination_ptr,
18399                    copy_size_ptr,
18400                )
18401            };
18402            ()
18403        }
18404        pub fn copy_texture_to_texture(
18405            &self,
18406            source: &TexelCopyTextureInfo,
18407            destination: &TexelCopyTextureInfo,
18408            copy_size: &Extent3D,
18409        ) -> () {
18410            let (source_ffi, _source_storage) = source.to_ffi();
18411            let source_ptr = std::ptr::addr_of!(source_ffi);
18412            let (destination_ffi, _destination_storage) = destination.to_ffi();
18413            let destination_ptr = std::ptr::addr_of!(destination_ffi);
18414            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18415            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18416            unsafe {
18417                ffi::wgpuCommandEncoderCopyTextureToTexture(
18418                    self.raw,
18419                    source_ptr,
18420                    destination_ptr,
18421                    copy_size_ptr,
18422                )
18423            };
18424            ()
18425        }
18426        pub fn clear_buffer(&self, buffer: Buffer, offset: u64, size: u64) -> () {
18427            unsafe {
18428                ffi::wgpuCommandEncoderClearBuffer(
18429                    self.raw,
18430                    buffer.as_raw(),
18431                    offset,
18432                    size,
18433                )
18434            };
18435            ()
18436        }
18437        pub fn inject_validation_error(&self, message: String) -> () {
18438            let message_ffi = ffi::WGPUStringView {
18439                data: message.as_ptr().cast(),
18440                length: message.len(),
18441            };
18442            unsafe {
18443                ffi::wgpuCommandEncoderInjectValidationError(self.raw, message_ffi)
18444            };
18445            ()
18446        }
18447        pub fn insert_debug_marker(&self, marker_label: String) -> () {
18448            let marker_label_ffi = ffi::WGPUStringView {
18449                data: marker_label.as_ptr().cast(),
18450                length: marker_label.len(),
18451            };
18452            unsafe {
18453                ffi::wgpuCommandEncoderInsertDebugMarker(self.raw, marker_label_ffi)
18454            };
18455            ()
18456        }
18457        pub fn pop_debug_group(&self) -> () {
18458            unsafe { ffi::wgpuCommandEncoderPopDebugGroup(self.raw) };
18459            ()
18460        }
18461        pub fn push_debug_group(&self, group_label: String) -> () {
18462            let group_label_ffi = ffi::WGPUStringView {
18463                data: group_label.as_ptr().cast(),
18464                length: group_label.len(),
18465            };
18466            unsafe { ffi::wgpuCommandEncoderPushDebugGroup(self.raw, group_label_ffi) };
18467            ()
18468        }
18469        pub fn resolve_query_set(
18470            &self,
18471            query_set: QuerySet,
18472            first_query: u32,
18473            query_count: u32,
18474            destination: Buffer,
18475            destination_offset: u64,
18476        ) -> () {
18477            unsafe {
18478                ffi::wgpuCommandEncoderResolveQuerySet(
18479                    self.raw,
18480                    query_set.as_raw(),
18481                    first_query,
18482                    query_count,
18483                    destination.as_raw(),
18484                    destination_offset,
18485                )
18486            };
18487            ()
18488        }
18489        pub fn write_buffer(
18490            &self,
18491            buffer: Buffer,
18492            buffer_offset: u64,
18493            data: &[u8],
18494        ) -> () {
18495            let data_ptr = data.as_ptr();
18496            unsafe {
18497                ffi::wgpuCommandEncoderWriteBuffer(
18498                    self.raw,
18499                    buffer.as_raw(),
18500                    buffer_offset,
18501                    data_ptr,
18502                    (data.len()) as u64,
18503                )
18504            };
18505            ()
18506        }
18507        pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
18508            unsafe {
18509                ffi::wgpuCommandEncoderWriteTimestamp(
18510                    self.raw,
18511                    query_set.as_raw(),
18512                    query_index,
18513                )
18514            };
18515            ()
18516        }
18517        pub fn set_label(&self, label: String) -> () {
18518            let label_ffi = ffi::WGPUStringView {
18519                data: label.as_ptr().cast(),
18520                length: label.len(),
18521            };
18522            unsafe { ffi::wgpuCommandEncoderSetLabel(self.raw, label_ffi) };
18523            ()
18524        }
18525    }
18526    impl Drop for CommandEncoder {
18527        fn drop(&mut self) {
18528            if self.as_raw().is_null() {
18529                return;
18530            }
18531            unsafe { ffi::wgpuCommandEncoderRelease(self.raw) };
18532        }
18533    }
18534    impl Clone for CommandEncoder {
18535        fn clone(&self) -> Self {
18536            unsafe { ffi::wgpuCommandEncoderAddRef(self.raw) };
18537            Self { raw: self.raw }
18538        }
18539    }
18540    unsafe impl Send for CommandEncoder {}
18541    unsafe impl Sync for CommandEncoder {}
18542    #[derive(Debug)]
18543    pub struct ComputePassEncoder {
18544        raw: ffi::WGPUComputePassEncoder,
18545    }
18546    impl ComputePassEncoder {
18547        pub(crate) unsafe fn from_raw(raw: ffi::WGPUComputePassEncoder) -> Self {
18548            Self { raw }
18549        }
18550        pub(crate) fn as_raw(&self) -> ffi::WGPUComputePassEncoder {
18551            self.raw
18552        }
18553        pub fn insert_debug_marker(&self, marker_label: String) -> () {
18554            let marker_label_ffi = ffi::WGPUStringView {
18555                data: marker_label.as_ptr().cast(),
18556                length: marker_label.len(),
18557            };
18558            unsafe {
18559                ffi::wgpuComputePassEncoderInsertDebugMarker(self.raw, marker_label_ffi)
18560            };
18561            ()
18562        }
18563        pub fn pop_debug_group(&self) -> () {
18564            unsafe { ffi::wgpuComputePassEncoderPopDebugGroup(self.raw) };
18565            ()
18566        }
18567        pub fn push_debug_group(&self, group_label: String) -> () {
18568            let group_label_ffi = ffi::WGPUStringView {
18569                data: group_label.as_ptr().cast(),
18570                length: group_label.len(),
18571            };
18572            unsafe {
18573                ffi::wgpuComputePassEncoderPushDebugGroup(self.raw, group_label_ffi)
18574            };
18575            ()
18576        }
18577        pub fn set_pipeline(&self, pipeline: ComputePipeline) -> () {
18578            unsafe {
18579                ffi::wgpuComputePassEncoderSetPipeline(self.raw, pipeline.as_raw())
18580            };
18581            ()
18582        }
18583        pub fn set_bind_group(
18584            &self,
18585            group_index: u32,
18586            group: Option<BindGroup>,
18587            dynamic_offsets: &[u32],
18588        ) -> () {
18589            let group_raw = group
18590                .as_ref()
18591                .map(|v| v.as_raw())
18592                .unwrap_or(std::ptr::null_mut());
18593            let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
18594            unsafe {
18595                ffi::wgpuComputePassEncoderSetBindGroup(
18596                    self.raw,
18597                    group_index,
18598                    group_raw,
18599                    dynamic_offsets.len(),
18600                    dynamic_offsets_ptr,
18601                )
18602            };
18603            ()
18604        }
18605        pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
18606            unsafe {
18607                ffi::wgpuComputePassEncoderWriteTimestamp(
18608                    self.raw,
18609                    query_set.as_raw(),
18610                    query_index,
18611                )
18612            };
18613            ()
18614        }
18615        pub fn dispatch_workgroups(
18616            &self,
18617            workgroup_count_x: u32,
18618            workgroup_count_y: u32,
18619            workgroup_count_z: u32,
18620        ) -> () {
18621            unsafe {
18622                ffi::wgpuComputePassEncoderDispatchWorkgroups(
18623                    self.raw,
18624                    workgroup_count_x,
18625                    workgroup_count_y,
18626                    workgroup_count_z,
18627                )
18628            };
18629            ()
18630        }
18631        pub fn dispatch_workgroups_indirect(
18632            &self,
18633            indirect_buffer: Buffer,
18634            indirect_offset: u64,
18635        ) -> () {
18636            unsafe {
18637                ffi::wgpuComputePassEncoderDispatchWorkgroupsIndirect(
18638                    self.raw,
18639                    indirect_buffer.as_raw(),
18640                    indirect_offset,
18641                )
18642            };
18643            ()
18644        }
18645        pub fn end(&self) -> () {
18646            unsafe { ffi::wgpuComputePassEncoderEnd(self.raw) };
18647            ()
18648        }
18649        pub fn set_label(&self, label: String) -> () {
18650            let label_ffi = ffi::WGPUStringView {
18651                data: label.as_ptr().cast(),
18652                length: label.len(),
18653            };
18654            unsafe { ffi::wgpuComputePassEncoderSetLabel(self.raw, label_ffi) };
18655            ()
18656        }
18657        pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
18658            let data_ptr = data.as_ptr();
18659            unsafe {
18660                ffi::wgpuComputePassEncoderSetImmediates(
18661                    self.raw,
18662                    offset,
18663                    data_ptr,
18664                    data.len(),
18665                )
18666            };
18667            ()
18668        }
18669        pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
18670            let table_raw = table
18671                .as_ref()
18672                .map(|v| v.as_raw())
18673                .unwrap_or(std::ptr::null_mut());
18674            unsafe { ffi::wgpuComputePassEncoderSetResourceTable(self.raw, table_raw) };
18675            ()
18676        }
18677    }
18678    impl Drop for ComputePassEncoder {
18679        fn drop(&mut self) {
18680            if self.as_raw().is_null() {
18681                return;
18682            }
18683            unsafe { ffi::wgpuComputePassEncoderRelease(self.raw) };
18684        }
18685    }
18686    impl Clone for ComputePassEncoder {
18687        fn clone(&self) -> Self {
18688            unsafe { ffi::wgpuComputePassEncoderAddRef(self.raw) };
18689            Self { raw: self.raw }
18690        }
18691    }
18692    unsafe impl Send for ComputePassEncoder {}
18693    unsafe impl Sync for ComputePassEncoder {}
18694    #[derive(Debug)]
18695    pub struct ComputePipeline {
18696        raw: ffi::WGPUComputePipeline,
18697    }
18698    impl ComputePipeline {
18699        pub(crate) unsafe fn from_raw(raw: ffi::WGPUComputePipeline) -> Self {
18700            Self { raw }
18701        }
18702        pub(crate) fn as_raw(&self) -> ffi::WGPUComputePipeline {
18703            self.raw
18704        }
18705        pub fn get_bind_group_layout(&self, group_index: u32) -> BindGroupLayout {
18706            let result = unsafe {
18707                ffi::wgpuComputePipelineGetBindGroupLayout(self.raw, group_index)
18708            };
18709            unsafe { BindGroupLayout::from_raw(result) }
18710        }
18711        pub fn set_label(&self, label: String) -> () {
18712            let label_ffi = ffi::WGPUStringView {
18713                data: label.as_ptr().cast(),
18714                length: label.len(),
18715            };
18716            unsafe { ffi::wgpuComputePipelineSetLabel(self.raw, label_ffi) };
18717            ()
18718        }
18719    }
18720    impl Drop for ComputePipeline {
18721        fn drop(&mut self) {
18722            if self.as_raw().is_null() {
18723                return;
18724            }
18725            unsafe { ffi::wgpuComputePipelineRelease(self.raw) };
18726        }
18727    }
18728    impl Clone for ComputePipeline {
18729        fn clone(&self) -> Self {
18730            unsafe { ffi::wgpuComputePipelineAddRef(self.raw) };
18731            Self { raw: self.raw }
18732        }
18733    }
18734    unsafe impl Send for ComputePipeline {}
18735    unsafe impl Sync for ComputePipeline {}
18736    #[derive(Debug)]
18737    pub struct Device {
18738        raw: ffi::WGPUDevice,
18739    }
18740    impl Device {
18741        pub(crate) unsafe fn from_raw(raw: ffi::WGPUDevice) -> Self {
18742            Self { raw }
18743        }
18744        pub(crate) fn as_raw(&self) -> ffi::WGPUDevice {
18745            self.raw
18746        }
18747        pub fn create_bind_group(&self, descriptor: &BindGroupDescriptor) -> BindGroup {
18748            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18749            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18750            let result = unsafe {
18751                ffi::wgpuDeviceCreateBindGroup(self.raw, descriptor_ptr)
18752            };
18753            unsafe { BindGroup::from_raw(result) }
18754        }
18755        pub fn create_bind_group_layout(
18756            &self,
18757            descriptor: &BindGroupLayoutDescriptor,
18758        ) -> BindGroupLayout {
18759            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18760            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18761            let result = unsafe {
18762                ffi::wgpuDeviceCreateBindGroupLayout(self.raw, descriptor_ptr)
18763            };
18764            unsafe { BindGroupLayout::from_raw(result) }
18765        }
18766        pub fn create_buffer(&self, descriptor: &BufferDescriptor) -> Option<Buffer> {
18767            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18768            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18769            let result = unsafe {
18770                ffi::wgpuDeviceCreateBuffer(self.raw, descriptor_ptr)
18771            };
18772            if result.is_null() {
18773                None
18774            } else {
18775                Some(unsafe { Buffer::from_raw(result) })
18776            }
18777        }
18778        pub fn create_error_buffer(&self, descriptor: &BufferDescriptor) -> Buffer {
18779            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18780            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18781            let result = unsafe {
18782                ffi::wgpuDeviceCreateErrorBuffer(self.raw, descriptor_ptr)
18783            };
18784            unsafe { Buffer::from_raw(result) }
18785        }
18786        pub fn create_command_encoder(
18787            &self,
18788            descriptor: Option<&CommandEncoderDescriptor>,
18789        ) -> CommandEncoder {
18790            let mut descriptor_storage = ChainedStructStorage::new();
18791            let mut descriptor_ffi: Option<ffi::WGPUCommandEncoderDescriptor> = None;
18792            let descriptor_ptr = if let Some(value) = &descriptor {
18793                let (raw, storage) = value.to_ffi();
18794                descriptor_storage = storage;
18795                descriptor_ffi = Some(raw);
18796                if let Some(raw_ref) = descriptor_ffi.as_ref() {
18797                    std::ptr::from_ref(raw_ref)
18798                } else {
18799                    unreachable!(
18800                        "internal error: descriptor_ffi missing after assignment",
18801                    )
18802                }
18803            } else {
18804                std::ptr::null()
18805            };
18806            let result = unsafe {
18807                ffi::wgpuDeviceCreateCommandEncoder(self.raw, descriptor_ptr)
18808            };
18809            unsafe { CommandEncoder::from_raw(result) }
18810        }
18811        pub fn create_compute_pipeline(
18812            &self,
18813            descriptor: &ComputePipelineDescriptor,
18814        ) -> ComputePipeline {
18815            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18816            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18817            let result = unsafe {
18818                ffi::wgpuDeviceCreateComputePipeline(self.raw, descriptor_ptr)
18819            };
18820            unsafe { ComputePipeline::from_raw(result) }
18821        }
18822        pub fn create_compute_pipeline_async(
18823            &self,
18824            descriptor: &ComputePipelineDescriptor,
18825            callback: impl FnMut(
18826                CreatePipelineAsyncStatus,
18827                Option<ComputePipeline>,
18828                String,
18829            ) + Send + 'static,
18830        ) -> Future {
18831            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18832            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18833            let callback_box: CreateComputePipelineAsyncCallback = Box::new(callback);
18834            let callback_box = Box::new(Some(callback_box));
18835            let callback_userdata = Box::into_raw(callback_box)
18836                .cast::<std::ffi::c_void>();
18837            let callback_info_ffi = ffi::WGPUCreateComputePipelineAsyncCallbackInfo {
18838                nextInChain: std::ptr::null_mut(),
18839                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18840                callback: Some(create_compute_pipeline_async_callback_trampoline),
18841                userdata1: callback_userdata,
18842                userdata2: std::ptr::null_mut(),
18843            };
18844            let result = unsafe {
18845                ffi::wgpuDeviceCreateComputePipelineAsync(
18846                    self.raw,
18847                    descriptor_ptr,
18848                    callback_info_ffi,
18849                )
18850            };
18851            Future::from_ffi(result)
18852        }
18853        pub fn create_external_texture(
18854            &self,
18855            external_texture_descriptor: &ExternalTextureDescriptor,
18856        ) -> ExternalTexture {
18857            let (
18858                external_texture_descriptor_ffi,
18859                _external_texture_descriptor_storage,
18860            ) = external_texture_descriptor.to_ffi();
18861            let external_texture_descriptor_ptr = std::ptr::addr_of!(
18862                external_texture_descriptor_ffi
18863            );
18864            let result = unsafe {
18865                ffi::wgpuDeviceCreateExternalTexture(
18866                    self.raw,
18867                    external_texture_descriptor_ptr,
18868                )
18869            };
18870            unsafe { ExternalTexture::from_raw(result) }
18871        }
18872        pub fn create_error_external_texture(&self) -> ExternalTexture {
18873            let result = unsafe { ffi::wgpuDeviceCreateErrorExternalTexture(self.raw) };
18874            unsafe { ExternalTexture::from_raw(result) }
18875        }
18876        pub fn create_pipeline_layout(
18877            &self,
18878            descriptor: &PipelineLayoutDescriptor,
18879        ) -> PipelineLayout {
18880            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18881            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18882            let result = unsafe {
18883                ffi::wgpuDeviceCreatePipelineLayout(self.raw, descriptor_ptr)
18884            };
18885            unsafe { PipelineLayout::from_raw(result) }
18886        }
18887        pub fn create_query_set(&self, descriptor: &QuerySetDescriptor) -> QuerySet {
18888            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18889            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18890            let result = unsafe {
18891                ffi::wgpuDeviceCreateQuerySet(self.raw, descriptor_ptr)
18892            };
18893            unsafe { QuerySet::from_raw(result) }
18894        }
18895        pub fn create_render_pipeline_async(
18896            &self,
18897            descriptor: &RenderPipelineDescriptor,
18898            callback: impl FnMut(
18899                CreatePipelineAsyncStatus,
18900                Option<RenderPipeline>,
18901                String,
18902            ) + Send + 'static,
18903        ) -> Future {
18904            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18905            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18906            let callback_box: CreateRenderPipelineAsyncCallback = Box::new(callback);
18907            let callback_box = Box::new(Some(callback_box));
18908            let callback_userdata = Box::into_raw(callback_box)
18909                .cast::<std::ffi::c_void>();
18910            let callback_info_ffi = ffi::WGPUCreateRenderPipelineAsyncCallbackInfo {
18911                nextInChain: std::ptr::null_mut(),
18912                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18913                callback: Some(create_render_pipeline_async_callback_trampoline),
18914                userdata1: callback_userdata,
18915                userdata2: std::ptr::null_mut(),
18916            };
18917            let result = unsafe {
18918                ffi::wgpuDeviceCreateRenderPipelineAsync(
18919                    self.raw,
18920                    descriptor_ptr,
18921                    callback_info_ffi,
18922                )
18923            };
18924            Future::from_ffi(result)
18925        }
18926        pub fn create_render_bundle_encoder(
18927            &self,
18928            descriptor: &RenderBundleEncoderDescriptor,
18929        ) -> RenderBundleEncoder {
18930            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18931            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18932            let result = unsafe {
18933                ffi::wgpuDeviceCreateRenderBundleEncoder(self.raw, descriptor_ptr)
18934            };
18935            unsafe { RenderBundleEncoder::from_raw(result) }
18936        }
18937        pub fn create_render_pipeline(
18938            &self,
18939            descriptor: &RenderPipelineDescriptor,
18940        ) -> RenderPipeline {
18941            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18942            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18943            let result = unsafe {
18944                ffi::wgpuDeviceCreateRenderPipeline(self.raw, descriptor_ptr)
18945            };
18946            unsafe { RenderPipeline::from_raw(result) }
18947        }
18948        pub fn create_sampler(&self, descriptor: Option<&SamplerDescriptor>) -> Sampler {
18949            let mut descriptor_storage = ChainedStructStorage::new();
18950            let mut descriptor_ffi: Option<ffi::WGPUSamplerDescriptor> = None;
18951            let descriptor_ptr = if let Some(value) = &descriptor {
18952                let (raw, storage) = value.to_ffi();
18953                descriptor_storage = storage;
18954                descriptor_ffi = Some(raw);
18955                if let Some(raw_ref) = descriptor_ffi.as_ref() {
18956                    std::ptr::from_ref(raw_ref)
18957                } else {
18958                    unreachable!(
18959                        "internal error: descriptor_ffi missing after assignment",
18960                    )
18961                }
18962            } else {
18963                std::ptr::null()
18964            };
18965            let result = unsafe {
18966                ffi::wgpuDeviceCreateSampler(self.raw, descriptor_ptr)
18967            };
18968            unsafe { Sampler::from_raw(result) }
18969        }
18970        pub fn create_shader_module(
18971            &self,
18972            descriptor: &ShaderModuleDescriptor,
18973        ) -> ShaderModule {
18974            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18975            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18976            let result = unsafe {
18977                ffi::wgpuDeviceCreateShaderModule(self.raw, descriptor_ptr)
18978            };
18979            unsafe { ShaderModule::from_raw(result) }
18980        }
18981        pub fn create_error_shader_module(
18982            &self,
18983            descriptor: &ShaderModuleDescriptor,
18984            error_message: String,
18985        ) -> ShaderModule {
18986            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18987            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18988            let error_message_ffi = ffi::WGPUStringView {
18989                data: error_message.as_ptr().cast(),
18990                length: error_message.len(),
18991            };
18992            let result = unsafe {
18993                ffi::wgpuDeviceCreateErrorShaderModule(
18994                    self.raw,
18995                    descriptor_ptr,
18996                    error_message_ffi,
18997                )
18998            };
18999            unsafe { ShaderModule::from_raw(result) }
19000        }
19001        pub fn create_texture(&self, descriptor: &TextureDescriptor) -> Texture {
19002            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19003            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19004            let result = unsafe {
19005                ffi::wgpuDeviceCreateTexture(self.raw, descriptor_ptr)
19006            };
19007            unsafe { Texture::from_raw(result) }
19008        }
19009        pub fn create_resource_table(
19010            &self,
19011            descriptor: &ResourceTableDescriptor,
19012        ) -> ResourceTable {
19013            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19014            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19015            let result = unsafe {
19016                ffi::wgpuDeviceCreateResourceTable(self.raw, descriptor_ptr)
19017            };
19018            unsafe { ResourceTable::from_raw(result) }
19019        }
19020        pub fn import_shared_buffer_memory(
19021            &self,
19022            descriptor: &SharedBufferMemoryDescriptor,
19023        ) -> SharedBufferMemory {
19024            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19025            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19026            let result = unsafe {
19027                ffi::wgpuDeviceImportSharedBufferMemory(self.raw, descriptor_ptr)
19028            };
19029            unsafe { SharedBufferMemory::from_raw(result) }
19030        }
19031        pub fn import_shared_texture_memory(
19032            &self,
19033            descriptor: &SharedTextureMemoryDescriptor,
19034        ) -> SharedTextureMemory {
19035            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19036            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19037            let result = unsafe {
19038                ffi::wgpuDeviceImportSharedTextureMemory(self.raw, descriptor_ptr)
19039            };
19040            unsafe { SharedTextureMemory::from_raw(result) }
19041        }
19042        pub fn import_shared_fence(
19043            &self,
19044            descriptor: &SharedFenceDescriptor,
19045        ) -> SharedFence {
19046            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19047            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19048            let result = unsafe {
19049                ffi::wgpuDeviceImportSharedFence(self.raw, descriptor_ptr)
19050            };
19051            unsafe { SharedFence::from_raw(result) }
19052        }
19053        pub fn create_error_texture(&self, descriptor: &TextureDescriptor) -> Texture {
19054            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19055            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19056            let result = unsafe {
19057                ffi::wgpuDeviceCreateErrorTexture(self.raw, descriptor_ptr)
19058            };
19059            unsafe { Texture::from_raw(result) }
19060        }
19061        pub fn destroy(&self) -> () {
19062            unsafe { ffi::wgpuDeviceDestroy(self.raw) };
19063            ()
19064        }
19065        pub fn get_a_hardware_buffer_properties(
19066            &self,
19067            handle: *mut std::ffi::c_void,
19068            properties: &mut AHardwareBufferProperties,
19069        ) -> Status {
19070            let (mut properties_ffi, _properties_storage) = properties.to_ffi();
19071            let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
19072            let result = unsafe {
19073                ffi::wgpuDeviceGetAHardwareBufferProperties(
19074                    self.raw,
19075                    handle,
19076                    properties_ptr,
19077                )
19078            };
19079            *properties = AHardwareBufferProperties::from_ffi(properties_ffi);
19080            result.into()
19081        }
19082        pub fn get_limits(&self, limits: &mut Limits) -> Status {
19083            let (mut limits_ffi, _limits_storage) = limits.to_ffi();
19084            let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
19085            let result = unsafe { ffi::wgpuDeviceGetLimits(self.raw, limits_ptr) };
19086            *limits = Limits::from_ffi(limits_ffi);
19087            result.into()
19088        }
19089        pub fn get_lost_future(&self) -> Future {
19090            let result = unsafe { ffi::wgpuDeviceGetLostFuture(self.raw) };
19091            Future::from_ffi(result)
19092        }
19093        pub fn has_feature(&self, feature: FeatureName) -> bool {
19094            let feature_ffi: ffi::WGPUFeatureName = feature.into();
19095            let result = unsafe { ffi::wgpuDeviceHasFeature(self.raw, feature_ffi) };
19096            result != 0
19097        }
19098        pub fn get_features(&self, features: &mut SupportedFeatures) -> () {
19099            let (mut features_ffi, _features_storage) = features.to_ffi();
19100            let features_ptr = std::ptr::addr_of_mut!(features_ffi);
19101            unsafe { ffi::wgpuDeviceGetFeatures(self.raw, features_ptr) };
19102            *features = SupportedFeatures::from_ffi(features_ffi);
19103            ()
19104        }
19105        pub fn get_adapter_info(&self, adapter_info: &mut AdapterInfo) -> Status {
19106            let (mut adapter_info_ffi, _adapter_info_storage) = adapter_info.to_ffi();
19107            let adapter_info_ptr = std::ptr::addr_of_mut!(adapter_info_ffi);
19108            let result = unsafe {
19109                ffi::wgpuDeviceGetAdapterInfo(self.raw, adapter_info_ptr)
19110            };
19111            *adapter_info = AdapterInfo::from_ffi(adapter_info_ffi);
19112            result.into()
19113        }
19114        pub fn get_adapter(&self) -> Adapter {
19115            let result = unsafe { ffi::wgpuDeviceGetAdapter(self.raw) };
19116            unsafe { Adapter::from_raw(result) }
19117        }
19118        pub fn get_queue(&self) -> Queue {
19119            let result = unsafe { ffi::wgpuDeviceGetQueue(self.raw) };
19120            unsafe { Queue::from_raw(result) }
19121        }
19122        pub fn inject_error(&self, r#type: ErrorType, message: String) -> () {
19123            let r#type_ffi: ffi::WGPUErrorType = r#type.into();
19124            let message_ffi = ffi::WGPUStringView {
19125                data: message.as_ptr().cast(),
19126                length: message.len(),
19127            };
19128            unsafe { ffi::wgpuDeviceInjectError(self.raw, r#type_ffi, message_ffi) };
19129            ()
19130        }
19131        pub fn force_loss(&self, r#type: DeviceLostReason, message: String) -> () {
19132            let r#type_ffi: ffi::WGPUDeviceLostReason = r#type.into();
19133            let message_ffi = ffi::WGPUStringView {
19134                data: message.as_ptr().cast(),
19135                length: message.len(),
19136            };
19137            unsafe { ffi::wgpuDeviceForceLoss(self.raw, r#type_ffi, message_ffi) };
19138            ()
19139        }
19140        pub fn tick(&self) -> () {
19141            unsafe { ffi::wgpuDeviceTick(self.raw) };
19142            ()
19143        }
19144        pub fn set_logging_callback(
19145            &self,
19146            callback: impl FnMut(LoggingType, String) + Send + 'static,
19147        ) -> () {
19148            let callback_box: LoggingCallback = Box::new(callback);
19149            let callback_box = Box::new(Some(callback_box));
19150            let callback_userdata = Box::into_raw(callback_box)
19151                .cast::<std::ffi::c_void>();
19152            let callback_info_ffi = ffi::WGPULoggingCallbackInfo {
19153                nextInChain: std::ptr::null_mut(),
19154                callback: Some(logging_callback_trampoline),
19155                userdata1: callback_userdata,
19156                userdata2: std::ptr::null_mut(),
19157            };
19158            unsafe { ffi::wgpuDeviceSetLoggingCallback(self.raw, callback_info_ffi) };
19159            ()
19160        }
19161        pub fn push_error_scope(&self, filter: ErrorFilter) -> () {
19162            let filter_ffi: ffi::WGPUErrorFilter = filter.into();
19163            unsafe { ffi::wgpuDevicePushErrorScope(self.raw, filter_ffi) };
19164            ()
19165        }
19166        pub fn pop_error_scope(
19167            &self,
19168            callback: impl FnMut(PopErrorScopeStatus, ErrorType, String) + Send + 'static,
19169        ) -> Future {
19170            let callback_box: PopErrorScopeCallback = Box::new(callback);
19171            let callback_box = Box::new(Some(callback_box));
19172            let callback_userdata = Box::into_raw(callback_box)
19173                .cast::<std::ffi::c_void>();
19174            let callback_info_ffi = ffi::WGPUPopErrorScopeCallbackInfo {
19175                nextInChain: std::ptr::null_mut(),
19176                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19177                callback: Some(pop_error_scope_callback_trampoline),
19178                userdata1: callback_userdata,
19179                userdata2: std::ptr::null_mut(),
19180            };
19181            let result = unsafe {
19182                ffi::wgpuDevicePopErrorScope(self.raw, callback_info_ffi)
19183            };
19184            Future::from_ffi(result)
19185        }
19186        pub fn set_label(&self, label: String) -> () {
19187            let label_ffi = ffi::WGPUStringView {
19188                data: label.as_ptr().cast(),
19189                length: label.len(),
19190            };
19191            unsafe { ffi::wgpuDeviceSetLabel(self.raw, label_ffi) };
19192            ()
19193        }
19194        pub fn validate_texture_descriptor(&self, descriptor: &TextureDescriptor) -> () {
19195            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19196            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19197            unsafe {
19198                ffi::wgpuDeviceValidateTextureDescriptor(self.raw, descriptor_ptr)
19199            };
19200            ()
19201        }
19202    }
19203    impl Drop for Device {
19204        fn drop(&mut self) {
19205            if self.as_raw().is_null() {
19206                return;
19207            }
19208            unsafe { ffi::wgpuDeviceRelease(self.raw) };
19209        }
19210    }
19211    impl Clone for Device {
19212        fn clone(&self) -> Self {
19213            unsafe { ffi::wgpuDeviceAddRef(self.raw) };
19214            Self { raw: self.raw }
19215        }
19216    }
19217    unsafe impl Send for Device {}
19218    unsafe impl Sync for Device {}
19219    #[derive(Debug)]
19220    pub struct ExternalTexture {
19221        raw: ffi::WGPUExternalTexture,
19222    }
19223    impl ExternalTexture {
19224        pub(crate) unsafe fn from_raw(raw: ffi::WGPUExternalTexture) -> Self {
19225            Self { raw }
19226        }
19227        pub(crate) fn as_raw(&self) -> ffi::WGPUExternalTexture {
19228            self.raw
19229        }
19230        pub fn set_label(&self, label: String) -> () {
19231            let label_ffi = ffi::WGPUStringView {
19232                data: label.as_ptr().cast(),
19233                length: label.len(),
19234            };
19235            unsafe { ffi::wgpuExternalTextureSetLabel(self.raw, label_ffi) };
19236            ()
19237        }
19238        pub fn destroy(&self) -> () {
19239            unsafe { ffi::wgpuExternalTextureDestroy(self.raw) };
19240            ()
19241        }
19242        pub fn expire(&self) -> () {
19243            unsafe { ffi::wgpuExternalTextureExpire(self.raw) };
19244            ()
19245        }
19246        pub fn refresh(&self) -> () {
19247            unsafe { ffi::wgpuExternalTextureRefresh(self.raw) };
19248            ()
19249        }
19250    }
19251    impl Drop for ExternalTexture {
19252        fn drop(&mut self) {
19253            if self.as_raw().is_null() {
19254                return;
19255            }
19256            unsafe { ffi::wgpuExternalTextureRelease(self.raw) };
19257        }
19258    }
19259    impl Clone for ExternalTexture {
19260        fn clone(&self) -> Self {
19261            unsafe { ffi::wgpuExternalTextureAddRef(self.raw) };
19262            Self { raw: self.raw }
19263        }
19264    }
19265    unsafe impl Send for ExternalTexture {}
19266    unsafe impl Sync for ExternalTexture {}
19267    #[derive(Debug)]
19268    pub struct Instance {
19269        raw: ffi::WGPUInstance,
19270    }
19271    impl Instance {
19272        pub(crate) unsafe fn from_raw(raw: ffi::WGPUInstance) -> Self {
19273            Self { raw }
19274        }
19275        pub(crate) fn as_raw(&self) -> ffi::WGPUInstance {
19276            self.raw
19277        }
19278        pub fn new(descriptor: Option<&InstanceDescriptor>) -> Self {
19279            let mut descriptor_storage = ChainedStructStorage::new();
19280            let mut descriptor_ffi: Option<ffi::WGPUInstanceDescriptor> = None;
19281            let descriptor_ptr = if let Some(value) = &descriptor {
19282                let (raw, storage) = value.to_ffi();
19283                descriptor_storage = storage;
19284                descriptor_ffi = Some(raw);
19285                if let Some(raw_ref) = descriptor_ffi.as_ref() {
19286                    std::ptr::from_ref(raw_ref)
19287                } else {
19288                    unreachable!(
19289                        "internal error: descriptor_ffi missing after assignment",
19290                    )
19291                }
19292            } else {
19293                std::ptr::null()
19294            };
19295            let result = unsafe { ffi::wgpuCreateInstance(descriptor_ptr) };
19296            unsafe { Instance::from_raw(result) }
19297        }
19298        pub fn create_surface(&self, descriptor: &SurfaceDescriptor) -> Surface {
19299            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19300            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19301            let result = unsafe {
19302                ffi::wgpuInstanceCreateSurface(self.raw, descriptor_ptr)
19303            };
19304            unsafe { Surface::from_raw(result) }
19305        }
19306        pub fn process_events(&self) -> () {
19307            unsafe { ffi::wgpuInstanceProcessEvents(self.raw) };
19308            ()
19309        }
19310        pub fn wait_any(
19311            &self,
19312            mut futures: Option<&mut [FutureWaitInfo]>,
19313            timeout_ns: u64,
19314        ) -> WaitStatus {
19315            let mut futures_raw: Vec<ffi::WGPUFutureWaitInfo> = Vec::new();
19316            let mut futures_storage: Vec<ChainedStructStorage> = Vec::new();
19317            let futures_ptr = if let Some(value) = futures.as_deref() {
19318                for item in value {
19319                    let (raw, storage) = item.to_ffi();
19320                    futures_raw.push(raw);
19321                    futures_storage.push(storage);
19322                }
19323                futures_raw.as_mut_ptr()
19324            } else {
19325                std::ptr::null_mut()
19326            };
19327            let result = unsafe {
19328                ffi::wgpuInstanceWaitAny(
19329                    self.raw,
19330                    futures.as_deref().map(|v| v.len()).unwrap_or(0),
19331                    futures_ptr,
19332                    timeout_ns,
19333                )
19334            };
19335            result.into()
19336        }
19337        pub fn request_adapter(
19338            &self,
19339            options: Option<&RequestAdapterOptions>,
19340            callback: impl FnMut(
19341                RequestAdapterStatus,
19342                Option<Adapter>,
19343                String,
19344            ) + Send + 'static,
19345        ) -> Future {
19346            let mut options_storage = ChainedStructStorage::new();
19347            let mut options_ffi: Option<ffi::WGPURequestAdapterOptions> = None;
19348            let options_ptr = if let Some(value) = &options {
19349                let (raw, storage) = value.to_ffi();
19350                options_storage = storage;
19351                options_ffi = Some(raw);
19352                if let Some(raw_ref) = options_ffi.as_ref() {
19353                    std::ptr::from_ref(raw_ref)
19354                } else {
19355                    unreachable!("internal error: options_ffi missing after assignment")
19356                }
19357            } else {
19358                std::ptr::null()
19359            };
19360            let callback_box: RequestAdapterCallback = Box::new(callback);
19361            let callback_box = Box::new(Some(callback_box));
19362            let callback_userdata = Box::into_raw(callback_box)
19363                .cast::<std::ffi::c_void>();
19364            let callback_info_ffi = ffi::WGPURequestAdapterCallbackInfo {
19365                nextInChain: std::ptr::null_mut(),
19366                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19367                callback: Some(request_adapter_callback_trampoline),
19368                userdata1: callback_userdata,
19369                userdata2: std::ptr::null_mut(),
19370            };
19371            let result = unsafe {
19372                ffi::wgpuInstanceRequestAdapter(self.raw, options_ptr, callback_info_ffi)
19373            };
19374            Future::from_ffi(result)
19375        }
19376        pub fn has_wgsl_language_feature(
19377            &self,
19378            feature: WGSLLanguageFeatureName,
19379        ) -> bool {
19380            let feature_ffi: ffi::WGPUWGSLLanguageFeatureName = feature.into();
19381            let result = unsafe {
19382                ffi::wgpuInstanceHasWGSLLanguageFeature(self.raw, feature_ffi)
19383            };
19384            result != 0
19385        }
19386        pub fn get_wgsl_language_features(
19387            &self,
19388            features: &mut SupportedWGSLLanguageFeatures,
19389        ) -> () {
19390            let (mut features_ffi, _features_storage) = features.to_ffi();
19391            let features_ptr = std::ptr::addr_of_mut!(features_ffi);
19392            unsafe { ffi::wgpuInstanceGetWGSLLanguageFeatures(self.raw, features_ptr) };
19393            *features = SupportedWGSLLanguageFeatures::from_ffi(features_ffi);
19394            ()
19395        }
19396    }
19397    impl Drop for Instance {
19398        fn drop(&mut self) {
19399            if self.as_raw().is_null() {
19400                return;
19401            }
19402            unsafe { ffi::wgpuInstanceRelease(self.raw) };
19403        }
19404    }
19405    impl Clone for Instance {
19406        fn clone(&self) -> Self {
19407            unsafe { ffi::wgpuInstanceAddRef(self.raw) };
19408            Self { raw: self.raw }
19409        }
19410    }
19411    #[derive(Debug)]
19412    pub struct PipelineLayout {
19413        raw: ffi::WGPUPipelineLayout,
19414    }
19415    impl PipelineLayout {
19416        pub(crate) unsafe fn from_raw(raw: ffi::WGPUPipelineLayout) -> Self {
19417            Self { raw }
19418        }
19419        pub(crate) fn as_raw(&self) -> ffi::WGPUPipelineLayout {
19420            self.raw
19421        }
19422        pub fn set_label(&self, label: String) -> () {
19423            let label_ffi = ffi::WGPUStringView {
19424                data: label.as_ptr().cast(),
19425                length: label.len(),
19426            };
19427            unsafe { ffi::wgpuPipelineLayoutSetLabel(self.raw, label_ffi) };
19428            ()
19429        }
19430    }
19431    impl Drop for PipelineLayout {
19432        fn drop(&mut self) {
19433            if self.as_raw().is_null() {
19434                return;
19435            }
19436            unsafe { ffi::wgpuPipelineLayoutRelease(self.raw) };
19437        }
19438    }
19439    impl Clone for PipelineLayout {
19440        fn clone(&self) -> Self {
19441            unsafe { ffi::wgpuPipelineLayoutAddRef(self.raw) };
19442            Self { raw: self.raw }
19443        }
19444    }
19445    unsafe impl Send for PipelineLayout {}
19446    unsafe impl Sync for PipelineLayout {}
19447    #[derive(Debug)]
19448    pub struct QuerySet {
19449        raw: ffi::WGPUQuerySet,
19450    }
19451    impl QuerySet {
19452        pub(crate) unsafe fn from_raw(raw: ffi::WGPUQuerySet) -> Self {
19453            Self { raw }
19454        }
19455        pub(crate) fn as_raw(&self) -> ffi::WGPUQuerySet {
19456            self.raw
19457        }
19458        pub fn set_label(&self, label: String) -> () {
19459            let label_ffi = ffi::WGPUStringView {
19460                data: label.as_ptr().cast(),
19461                length: label.len(),
19462            };
19463            unsafe { ffi::wgpuQuerySetSetLabel(self.raw, label_ffi) };
19464            ()
19465        }
19466        pub fn get_type(&self) -> QueryType {
19467            let result = unsafe { ffi::wgpuQuerySetGetType(self.raw) };
19468            result.into()
19469        }
19470        pub fn get_count(&self) -> u32 {
19471            let result = unsafe { ffi::wgpuQuerySetGetCount(self.raw) };
19472            result
19473        }
19474        pub fn destroy(&self) -> () {
19475            unsafe { ffi::wgpuQuerySetDestroy(self.raw) };
19476            ()
19477        }
19478    }
19479    impl Drop for QuerySet {
19480        fn drop(&mut self) {
19481            if self.as_raw().is_null() {
19482                return;
19483            }
19484            unsafe { ffi::wgpuQuerySetRelease(self.raw) };
19485        }
19486    }
19487    impl Clone for QuerySet {
19488        fn clone(&self) -> Self {
19489            unsafe { ffi::wgpuQuerySetAddRef(self.raw) };
19490            Self { raw: self.raw }
19491        }
19492    }
19493    unsafe impl Send for QuerySet {}
19494    unsafe impl Sync for QuerySet {}
19495    #[derive(Debug)]
19496    pub struct Queue {
19497        raw: ffi::WGPUQueue,
19498    }
19499    impl Queue {
19500        pub(crate) unsafe fn from_raw(raw: ffi::WGPUQueue) -> Self {
19501            Self { raw }
19502        }
19503        pub(crate) fn as_raw(&self) -> ffi::WGPUQueue {
19504            self.raw
19505        }
19506        pub fn submit(&self, commands: &[CommandBuffer]) -> () {
19507            let mut commands_raw: Vec<ffi::WGPUCommandBuffer> = commands
19508                .iter()
19509                .map(|v| v.as_raw())
19510                .collect();
19511            let commands_ptr = commands_raw.as_ptr();
19512            unsafe { ffi::wgpuQueueSubmit(self.raw, commands.len(), commands_ptr) };
19513            ()
19514        }
19515        pub fn on_submitted_work_done(
19516            &self,
19517            callback: impl FnMut(QueueWorkDoneStatus, String) + Send + 'static,
19518        ) -> Future {
19519            let callback_box: QueueWorkDoneCallback = Box::new(callback);
19520            let callback_box = Box::new(Some(callback_box));
19521            let callback_userdata = Box::into_raw(callback_box)
19522                .cast::<std::ffi::c_void>();
19523            let callback_info_ffi = ffi::WGPUQueueWorkDoneCallbackInfo {
19524                nextInChain: std::ptr::null_mut(),
19525                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19526                callback: Some(queue_work_done_callback_trampoline),
19527                userdata1: callback_userdata,
19528                userdata2: std::ptr::null_mut(),
19529            };
19530            let result = unsafe {
19531                ffi::wgpuQueueOnSubmittedWorkDone(self.raw, callback_info_ffi)
19532            };
19533            Future::from_ffi(result)
19534        }
19535        pub fn write_buffer(
19536            &self,
19537            buffer: Buffer,
19538            buffer_offset: u64,
19539            data: &[std::ffi::c_void],
19540        ) -> () {
19541            let data_ptr = data.as_ptr();
19542            unsafe {
19543                ffi::wgpuQueueWriteBuffer(
19544                    self.raw,
19545                    buffer.as_raw(),
19546                    buffer_offset,
19547                    data_ptr,
19548                    data.len(),
19549                )
19550            };
19551            ()
19552        }
19553        pub fn write_texture(
19554            &self,
19555            destination: &TexelCopyTextureInfo,
19556            data: &[std::ffi::c_void],
19557            data_layout: &TexelCopyBufferLayout,
19558            write_size: &Extent3D,
19559        ) -> () {
19560            let (destination_ffi, _destination_storage) = destination.to_ffi();
19561            let destination_ptr = std::ptr::addr_of!(destination_ffi);
19562            let data_ptr = data.as_ptr();
19563            let (data_layout_ffi, _data_layout_storage) = data_layout.to_ffi();
19564            let data_layout_ptr = std::ptr::addr_of!(data_layout_ffi);
19565            let (write_size_ffi, _write_size_storage) = write_size.to_ffi();
19566            let write_size_ptr = std::ptr::addr_of!(write_size_ffi);
19567            unsafe {
19568                ffi::wgpuQueueWriteTexture(
19569                    self.raw,
19570                    destination_ptr,
19571                    data_ptr,
19572                    data.len(),
19573                    data_layout_ptr,
19574                    write_size_ptr,
19575                )
19576            };
19577            ()
19578        }
19579        pub fn copy_texture_for_browser(
19580            &self,
19581            source: &TexelCopyTextureInfo,
19582            destination: &TexelCopyTextureInfo,
19583            copy_size: &Extent3D,
19584            options: &CopyTextureForBrowserOptions,
19585        ) -> () {
19586            let (source_ffi, _source_storage) = source.to_ffi();
19587            let source_ptr = std::ptr::addr_of!(source_ffi);
19588            let (destination_ffi, _destination_storage) = destination.to_ffi();
19589            let destination_ptr = std::ptr::addr_of!(destination_ffi);
19590            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
19591            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
19592            let (options_ffi, _options_storage) = options.to_ffi();
19593            let options_ptr = std::ptr::addr_of!(options_ffi);
19594            unsafe {
19595                ffi::wgpuQueueCopyTextureForBrowser(
19596                    self.raw,
19597                    source_ptr,
19598                    destination_ptr,
19599                    copy_size_ptr,
19600                    options_ptr,
19601                )
19602            };
19603            ()
19604        }
19605        pub fn copy_external_texture_for_browser(
19606            &self,
19607            source: &ImageCopyExternalTexture,
19608            destination: &TexelCopyTextureInfo,
19609            copy_size: &Extent3D,
19610            options: &CopyTextureForBrowserOptions,
19611        ) -> () {
19612            let (source_ffi, _source_storage) = source.to_ffi();
19613            let source_ptr = std::ptr::addr_of!(source_ffi);
19614            let (destination_ffi, _destination_storage) = destination.to_ffi();
19615            let destination_ptr = std::ptr::addr_of!(destination_ffi);
19616            let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
19617            let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
19618            let (options_ffi, _options_storage) = options.to_ffi();
19619            let options_ptr = std::ptr::addr_of!(options_ffi);
19620            unsafe {
19621                ffi::wgpuQueueCopyExternalTextureForBrowser(
19622                    self.raw,
19623                    source_ptr,
19624                    destination_ptr,
19625                    copy_size_ptr,
19626                    options_ptr,
19627                )
19628            };
19629            ()
19630        }
19631        pub fn set_label(&self, label: String) -> () {
19632            let label_ffi = ffi::WGPUStringView {
19633                data: label.as_ptr().cast(),
19634                length: label.len(),
19635            };
19636            unsafe { ffi::wgpuQueueSetLabel(self.raw, label_ffi) };
19637            ()
19638        }
19639    }
19640    impl Drop for Queue {
19641        fn drop(&mut self) {
19642            if self.as_raw().is_null() {
19643                return;
19644            }
19645            unsafe { ffi::wgpuQueueRelease(self.raw) };
19646        }
19647    }
19648    impl Clone for Queue {
19649        fn clone(&self) -> Self {
19650            unsafe { ffi::wgpuQueueAddRef(self.raw) };
19651            Self { raw: self.raw }
19652        }
19653    }
19654    unsafe impl Send for Queue {}
19655    unsafe impl Sync for Queue {}
19656    #[derive(Debug)]
19657    pub struct RenderBundle {
19658        raw: ffi::WGPURenderBundle,
19659    }
19660    impl RenderBundle {
19661        pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderBundle) -> Self {
19662            Self { raw }
19663        }
19664        pub(crate) fn as_raw(&self) -> ffi::WGPURenderBundle {
19665            self.raw
19666        }
19667        pub fn set_label(&self, label: String) -> () {
19668            let label_ffi = ffi::WGPUStringView {
19669                data: label.as_ptr().cast(),
19670                length: label.len(),
19671            };
19672            unsafe { ffi::wgpuRenderBundleSetLabel(self.raw, label_ffi) };
19673            ()
19674        }
19675    }
19676    impl Drop for RenderBundle {
19677        fn drop(&mut self) {
19678            if self.as_raw().is_null() {
19679                return;
19680            }
19681            unsafe { ffi::wgpuRenderBundleRelease(self.raw) };
19682        }
19683    }
19684    impl Clone for RenderBundle {
19685        fn clone(&self) -> Self {
19686            unsafe { ffi::wgpuRenderBundleAddRef(self.raw) };
19687            Self { raw: self.raw }
19688        }
19689    }
19690    unsafe impl Send for RenderBundle {}
19691    unsafe impl Sync for RenderBundle {}
19692    #[derive(Debug)]
19693    pub struct RenderBundleEncoder {
19694        raw: ffi::WGPURenderBundleEncoder,
19695    }
19696    impl RenderBundleEncoder {
19697        pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderBundleEncoder) -> Self {
19698            Self { raw }
19699        }
19700        pub(crate) fn as_raw(&self) -> ffi::WGPURenderBundleEncoder {
19701            self.raw
19702        }
19703        pub fn set_pipeline(&self, pipeline: RenderPipeline) -> () {
19704            unsafe {
19705                ffi::wgpuRenderBundleEncoderSetPipeline(self.raw, pipeline.as_raw())
19706            };
19707            ()
19708        }
19709        pub fn set_bind_group(
19710            &self,
19711            group_index: u32,
19712            group: Option<BindGroup>,
19713            dynamic_offsets: &[u32],
19714        ) -> () {
19715            let group_raw = group
19716                .as_ref()
19717                .map(|v| v.as_raw())
19718                .unwrap_or(std::ptr::null_mut());
19719            let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
19720            unsafe {
19721                ffi::wgpuRenderBundleEncoderSetBindGroup(
19722                    self.raw,
19723                    group_index,
19724                    group_raw,
19725                    dynamic_offsets.len(),
19726                    dynamic_offsets_ptr,
19727                )
19728            };
19729            ()
19730        }
19731        pub fn draw(
19732            &self,
19733            vertex_count: u32,
19734            instance_count: u32,
19735            first_vertex: u32,
19736            first_instance: u32,
19737        ) -> () {
19738            unsafe {
19739                ffi::wgpuRenderBundleEncoderDraw(
19740                    self.raw,
19741                    vertex_count,
19742                    instance_count,
19743                    first_vertex,
19744                    first_instance,
19745                )
19746            };
19747            ()
19748        }
19749        pub fn draw_indexed(
19750            &self,
19751            index_count: u32,
19752            instance_count: u32,
19753            first_index: u32,
19754            base_vertex: i32,
19755            first_instance: u32,
19756        ) -> () {
19757            unsafe {
19758                ffi::wgpuRenderBundleEncoderDrawIndexed(
19759                    self.raw,
19760                    index_count,
19761                    instance_count,
19762                    first_index,
19763                    base_vertex,
19764                    first_instance,
19765                )
19766            };
19767            ()
19768        }
19769        pub fn draw_indirect(
19770            &self,
19771            indirect_buffer: Buffer,
19772            indirect_offset: u64,
19773        ) -> () {
19774            unsafe {
19775                ffi::wgpuRenderBundleEncoderDrawIndirect(
19776                    self.raw,
19777                    indirect_buffer.as_raw(),
19778                    indirect_offset,
19779                )
19780            };
19781            ()
19782        }
19783        pub fn draw_indexed_indirect(
19784            &self,
19785            indirect_buffer: Buffer,
19786            indirect_offset: u64,
19787        ) -> () {
19788            unsafe {
19789                ffi::wgpuRenderBundleEncoderDrawIndexedIndirect(
19790                    self.raw,
19791                    indirect_buffer.as_raw(),
19792                    indirect_offset,
19793                )
19794            };
19795            ()
19796        }
19797        pub fn insert_debug_marker(&self, marker_label: String) -> () {
19798            let marker_label_ffi = ffi::WGPUStringView {
19799                data: marker_label.as_ptr().cast(),
19800                length: marker_label.len(),
19801            };
19802            unsafe {
19803                ffi::wgpuRenderBundleEncoderInsertDebugMarker(self.raw, marker_label_ffi)
19804            };
19805            ()
19806        }
19807        pub fn pop_debug_group(&self) -> () {
19808            unsafe { ffi::wgpuRenderBundleEncoderPopDebugGroup(self.raw) };
19809            ()
19810        }
19811        pub fn push_debug_group(&self, group_label: String) -> () {
19812            let group_label_ffi = ffi::WGPUStringView {
19813                data: group_label.as_ptr().cast(),
19814                length: group_label.len(),
19815            };
19816            unsafe {
19817                ffi::wgpuRenderBundleEncoderPushDebugGroup(self.raw, group_label_ffi)
19818            };
19819            ()
19820        }
19821        pub fn set_vertex_buffer(
19822            &self,
19823            slot: u32,
19824            buffer: Option<Buffer>,
19825            offset: u64,
19826            size: u64,
19827        ) -> () {
19828            let buffer_raw = buffer
19829                .as_ref()
19830                .map(|v| v.as_raw())
19831                .unwrap_or(std::ptr::null_mut());
19832            unsafe {
19833                ffi::wgpuRenderBundleEncoderSetVertexBuffer(
19834                    self.raw,
19835                    slot,
19836                    buffer_raw,
19837                    offset,
19838                    size,
19839                )
19840            };
19841            ()
19842        }
19843        pub fn set_index_buffer(
19844            &self,
19845            buffer: Buffer,
19846            format: IndexFormat,
19847            offset: u64,
19848            size: u64,
19849        ) -> () {
19850            let format_ffi: ffi::WGPUIndexFormat = format.into();
19851            unsafe {
19852                ffi::wgpuRenderBundleEncoderSetIndexBuffer(
19853                    self.raw,
19854                    buffer.as_raw(),
19855                    format_ffi,
19856                    offset,
19857                    size,
19858                )
19859            };
19860            ()
19861        }
19862        pub fn finish(
19863            &self,
19864            descriptor: Option<&RenderBundleDescriptor>,
19865        ) -> RenderBundle {
19866            let mut descriptor_storage = ChainedStructStorage::new();
19867            let mut descriptor_ffi: Option<ffi::WGPURenderBundleDescriptor> = None;
19868            let descriptor_ptr = if let Some(value) = &descriptor {
19869                let (raw, storage) = value.to_ffi();
19870                descriptor_storage = storage;
19871                descriptor_ffi = Some(raw);
19872                if let Some(raw_ref) = descriptor_ffi.as_ref() {
19873                    std::ptr::from_ref(raw_ref)
19874                } else {
19875                    unreachable!(
19876                        "internal error: descriptor_ffi missing after assignment",
19877                    )
19878                }
19879            } else {
19880                std::ptr::null()
19881            };
19882            let result = unsafe {
19883                ffi::wgpuRenderBundleEncoderFinish(self.raw, descriptor_ptr)
19884            };
19885            unsafe { RenderBundle::from_raw(result) }
19886        }
19887        pub fn set_label(&self, label: String) -> () {
19888            let label_ffi = ffi::WGPUStringView {
19889                data: label.as_ptr().cast(),
19890                length: label.len(),
19891            };
19892            unsafe { ffi::wgpuRenderBundleEncoderSetLabel(self.raw, label_ffi) };
19893            ()
19894        }
19895        pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
19896            let data_ptr = data.as_ptr();
19897            unsafe {
19898                ffi::wgpuRenderBundleEncoderSetImmediates(
19899                    self.raw,
19900                    offset,
19901                    data_ptr,
19902                    data.len(),
19903                )
19904            };
19905            ()
19906        }
19907        pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
19908            let table_raw = table
19909                .as_ref()
19910                .map(|v| v.as_raw())
19911                .unwrap_or(std::ptr::null_mut());
19912            unsafe { ffi::wgpuRenderBundleEncoderSetResourceTable(self.raw, table_raw) };
19913            ()
19914        }
19915    }
19916    impl Drop for RenderBundleEncoder {
19917        fn drop(&mut self) {
19918            if self.as_raw().is_null() {
19919                return;
19920            }
19921            unsafe { ffi::wgpuRenderBundleEncoderRelease(self.raw) };
19922        }
19923    }
19924    impl Clone for RenderBundleEncoder {
19925        fn clone(&self) -> Self {
19926            unsafe { ffi::wgpuRenderBundleEncoderAddRef(self.raw) };
19927            Self { raw: self.raw }
19928        }
19929    }
19930    unsafe impl Send for RenderBundleEncoder {}
19931    unsafe impl Sync for RenderBundleEncoder {}
19932    #[derive(Debug)]
19933    pub struct RenderPassEncoder {
19934        raw: ffi::WGPURenderPassEncoder,
19935    }
19936    impl RenderPassEncoder {
19937        pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderPassEncoder) -> Self {
19938            Self { raw }
19939        }
19940        pub(crate) fn as_raw(&self) -> ffi::WGPURenderPassEncoder {
19941            self.raw
19942        }
19943        pub fn set_pipeline(&self, pipeline: RenderPipeline) -> () {
19944            unsafe {
19945                ffi::wgpuRenderPassEncoderSetPipeline(self.raw, pipeline.as_raw())
19946            };
19947            ()
19948        }
19949        pub fn set_bind_group(
19950            &self,
19951            group_index: u32,
19952            group: Option<BindGroup>,
19953            dynamic_offsets: &[u32],
19954        ) -> () {
19955            let group_raw = group
19956                .as_ref()
19957                .map(|v| v.as_raw())
19958                .unwrap_or(std::ptr::null_mut());
19959            let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
19960            unsafe {
19961                ffi::wgpuRenderPassEncoderSetBindGroup(
19962                    self.raw,
19963                    group_index,
19964                    group_raw,
19965                    dynamic_offsets.len(),
19966                    dynamic_offsets_ptr,
19967                )
19968            };
19969            ()
19970        }
19971        pub fn draw(
19972            &self,
19973            vertex_count: u32,
19974            instance_count: u32,
19975            first_vertex: u32,
19976            first_instance: u32,
19977        ) -> () {
19978            unsafe {
19979                ffi::wgpuRenderPassEncoderDraw(
19980                    self.raw,
19981                    vertex_count,
19982                    instance_count,
19983                    first_vertex,
19984                    first_instance,
19985                )
19986            };
19987            ()
19988        }
19989        pub fn draw_indexed(
19990            &self,
19991            index_count: u32,
19992            instance_count: u32,
19993            first_index: u32,
19994            base_vertex: i32,
19995            first_instance: u32,
19996        ) -> () {
19997            unsafe {
19998                ffi::wgpuRenderPassEncoderDrawIndexed(
19999                    self.raw,
20000                    index_count,
20001                    instance_count,
20002                    first_index,
20003                    base_vertex,
20004                    first_instance,
20005                )
20006            };
20007            ()
20008        }
20009        pub fn draw_indirect(
20010            &self,
20011            indirect_buffer: Buffer,
20012            indirect_offset: u64,
20013        ) -> () {
20014            unsafe {
20015                ffi::wgpuRenderPassEncoderDrawIndirect(
20016                    self.raw,
20017                    indirect_buffer.as_raw(),
20018                    indirect_offset,
20019                )
20020            };
20021            ()
20022        }
20023        pub fn draw_indexed_indirect(
20024            &self,
20025            indirect_buffer: Buffer,
20026            indirect_offset: u64,
20027        ) -> () {
20028            unsafe {
20029                ffi::wgpuRenderPassEncoderDrawIndexedIndirect(
20030                    self.raw,
20031                    indirect_buffer.as_raw(),
20032                    indirect_offset,
20033                )
20034            };
20035            ()
20036        }
20037        pub fn multi_draw_indirect(
20038            &self,
20039            indirect_buffer: Buffer,
20040            indirect_offset: u64,
20041            max_draw_count: u32,
20042            draw_count_buffer: Option<Buffer>,
20043            draw_count_buffer_offset: u64,
20044        ) -> () {
20045            let draw_count_buffer_raw = draw_count_buffer
20046                .as_ref()
20047                .map(|v| v.as_raw())
20048                .unwrap_or(std::ptr::null_mut());
20049            unsafe {
20050                ffi::wgpuRenderPassEncoderMultiDrawIndirect(
20051                    self.raw,
20052                    indirect_buffer.as_raw(),
20053                    indirect_offset,
20054                    max_draw_count,
20055                    draw_count_buffer_raw,
20056                    draw_count_buffer_offset,
20057                )
20058            };
20059            ()
20060        }
20061        pub fn multi_draw_indexed_indirect(
20062            &self,
20063            indirect_buffer: Buffer,
20064            indirect_offset: u64,
20065            max_draw_count: u32,
20066            draw_count_buffer: Option<Buffer>,
20067            draw_count_buffer_offset: u64,
20068        ) -> () {
20069            let draw_count_buffer_raw = draw_count_buffer
20070                .as_ref()
20071                .map(|v| v.as_raw())
20072                .unwrap_or(std::ptr::null_mut());
20073            unsafe {
20074                ffi::wgpuRenderPassEncoderMultiDrawIndexedIndirect(
20075                    self.raw,
20076                    indirect_buffer.as_raw(),
20077                    indirect_offset,
20078                    max_draw_count,
20079                    draw_count_buffer_raw,
20080                    draw_count_buffer_offset,
20081                )
20082            };
20083            ()
20084        }
20085        pub fn execute_bundles(&self, bundles: &[RenderBundle]) -> () {
20086            let mut bundles_raw: Vec<ffi::WGPURenderBundle> = bundles
20087                .iter()
20088                .map(|v| v.as_raw())
20089                .collect();
20090            let bundles_ptr = bundles_raw.as_ptr();
20091            unsafe {
20092                ffi::wgpuRenderPassEncoderExecuteBundles(
20093                    self.raw,
20094                    bundles.len(),
20095                    bundles_ptr,
20096                )
20097            };
20098            ()
20099        }
20100        pub fn insert_debug_marker(&self, marker_label: String) -> () {
20101            let marker_label_ffi = ffi::WGPUStringView {
20102                data: marker_label.as_ptr().cast(),
20103                length: marker_label.len(),
20104            };
20105            unsafe {
20106                ffi::wgpuRenderPassEncoderInsertDebugMarker(self.raw, marker_label_ffi)
20107            };
20108            ()
20109        }
20110        pub fn pop_debug_group(&self) -> () {
20111            unsafe { ffi::wgpuRenderPassEncoderPopDebugGroup(self.raw) };
20112            ()
20113        }
20114        pub fn push_debug_group(&self, group_label: String) -> () {
20115            let group_label_ffi = ffi::WGPUStringView {
20116                data: group_label.as_ptr().cast(),
20117                length: group_label.len(),
20118            };
20119            unsafe {
20120                ffi::wgpuRenderPassEncoderPushDebugGroup(self.raw, group_label_ffi)
20121            };
20122            ()
20123        }
20124        pub fn set_stencil_reference(&self, reference: u32) -> () {
20125            unsafe {
20126                ffi::wgpuRenderPassEncoderSetStencilReference(self.raw, reference)
20127            };
20128            ()
20129        }
20130        pub fn set_blend_constant(&self, color: &Color) -> () {
20131            let (color_ffi, _color_storage) = color.to_ffi();
20132            let color_ptr = std::ptr::addr_of!(color_ffi);
20133            unsafe { ffi::wgpuRenderPassEncoderSetBlendConstant(self.raw, color_ptr) };
20134            ()
20135        }
20136        pub fn set_viewport(
20137            &self,
20138            x: f32,
20139            y: f32,
20140            width: f32,
20141            height: f32,
20142            min_depth: f32,
20143            max_depth: f32,
20144        ) -> () {
20145            unsafe {
20146                ffi::wgpuRenderPassEncoderSetViewport(
20147                    self.raw,
20148                    x,
20149                    y,
20150                    width,
20151                    height,
20152                    min_depth,
20153                    max_depth,
20154                )
20155            };
20156            ()
20157        }
20158        pub fn set_scissor_rect(&self, x: u32, y: u32, width: u32, height: u32) -> () {
20159            unsafe {
20160                ffi::wgpuRenderPassEncoderSetScissorRect(self.raw, x, y, width, height)
20161            };
20162            ()
20163        }
20164        pub fn set_vertex_buffer(
20165            &self,
20166            slot: u32,
20167            buffer: Option<Buffer>,
20168            offset: u64,
20169            size: u64,
20170        ) -> () {
20171            let buffer_raw = buffer
20172                .as_ref()
20173                .map(|v| v.as_raw())
20174                .unwrap_or(std::ptr::null_mut());
20175            unsafe {
20176                ffi::wgpuRenderPassEncoderSetVertexBuffer(
20177                    self.raw,
20178                    slot,
20179                    buffer_raw,
20180                    offset,
20181                    size,
20182                )
20183            };
20184            ()
20185        }
20186        pub fn set_index_buffer(
20187            &self,
20188            buffer: Buffer,
20189            format: IndexFormat,
20190            offset: u64,
20191            size: u64,
20192        ) -> () {
20193            let format_ffi: ffi::WGPUIndexFormat = format.into();
20194            unsafe {
20195                ffi::wgpuRenderPassEncoderSetIndexBuffer(
20196                    self.raw,
20197                    buffer.as_raw(),
20198                    format_ffi,
20199                    offset,
20200                    size,
20201                )
20202            };
20203            ()
20204        }
20205        pub fn begin_occlusion_query(&self, query_index: u32) -> () {
20206            unsafe {
20207                ffi::wgpuRenderPassEncoderBeginOcclusionQuery(self.raw, query_index)
20208            };
20209            ()
20210        }
20211        pub fn end_occlusion_query(&self) -> () {
20212            unsafe { ffi::wgpuRenderPassEncoderEndOcclusionQuery(self.raw) };
20213            ()
20214        }
20215        pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
20216            unsafe {
20217                ffi::wgpuRenderPassEncoderWriteTimestamp(
20218                    self.raw,
20219                    query_set.as_raw(),
20220                    query_index,
20221                )
20222            };
20223            ()
20224        }
20225        pub fn pixel_local_storage_barrier(&self) -> () {
20226            unsafe { ffi::wgpuRenderPassEncoderPixelLocalStorageBarrier(self.raw) };
20227            ()
20228        }
20229        pub fn end(&self) -> () {
20230            unsafe { ffi::wgpuRenderPassEncoderEnd(self.raw) };
20231            ()
20232        }
20233        pub fn set_label(&self, label: String) -> () {
20234            let label_ffi = ffi::WGPUStringView {
20235                data: label.as_ptr().cast(),
20236                length: label.len(),
20237            };
20238            unsafe { ffi::wgpuRenderPassEncoderSetLabel(self.raw, label_ffi) };
20239            ()
20240        }
20241        pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
20242            let data_ptr = data.as_ptr();
20243            unsafe {
20244                ffi::wgpuRenderPassEncoderSetImmediates(
20245                    self.raw,
20246                    offset,
20247                    data_ptr,
20248                    data.len(),
20249                )
20250            };
20251            ()
20252        }
20253        pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
20254            let table_raw = table
20255                .as_ref()
20256                .map(|v| v.as_raw())
20257                .unwrap_or(std::ptr::null_mut());
20258            unsafe { ffi::wgpuRenderPassEncoderSetResourceTable(self.raw, table_raw) };
20259            ()
20260        }
20261    }
20262    impl Drop for RenderPassEncoder {
20263        fn drop(&mut self) {
20264            if self.as_raw().is_null() {
20265                return;
20266            }
20267            unsafe { ffi::wgpuRenderPassEncoderRelease(self.raw) };
20268        }
20269    }
20270    impl Clone for RenderPassEncoder {
20271        fn clone(&self) -> Self {
20272            unsafe { ffi::wgpuRenderPassEncoderAddRef(self.raw) };
20273            Self { raw: self.raw }
20274        }
20275    }
20276    unsafe impl Send for RenderPassEncoder {}
20277    unsafe impl Sync for RenderPassEncoder {}
20278    #[derive(Debug)]
20279    pub struct RenderPipeline {
20280        raw: ffi::WGPURenderPipeline,
20281    }
20282    impl RenderPipeline {
20283        pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderPipeline) -> Self {
20284            Self { raw }
20285        }
20286        pub(crate) fn as_raw(&self) -> ffi::WGPURenderPipeline {
20287            self.raw
20288        }
20289        pub fn get_bind_group_layout(&self, group_index: u32) -> BindGroupLayout {
20290            let result = unsafe {
20291                ffi::wgpuRenderPipelineGetBindGroupLayout(self.raw, group_index)
20292            };
20293            unsafe { BindGroupLayout::from_raw(result) }
20294        }
20295        pub fn set_label(&self, label: String) -> () {
20296            let label_ffi = ffi::WGPUStringView {
20297                data: label.as_ptr().cast(),
20298                length: label.len(),
20299            };
20300            unsafe { ffi::wgpuRenderPipelineSetLabel(self.raw, label_ffi) };
20301            ()
20302        }
20303    }
20304    impl Drop for RenderPipeline {
20305        fn drop(&mut self) {
20306            if self.as_raw().is_null() {
20307                return;
20308            }
20309            unsafe { ffi::wgpuRenderPipelineRelease(self.raw) };
20310        }
20311    }
20312    impl Clone for RenderPipeline {
20313        fn clone(&self) -> Self {
20314            unsafe { ffi::wgpuRenderPipelineAddRef(self.raw) };
20315            Self { raw: self.raw }
20316        }
20317    }
20318    unsafe impl Send for RenderPipeline {}
20319    unsafe impl Sync for RenderPipeline {}
20320    #[derive(Debug)]
20321    pub struct ResourceTable {
20322        raw: ffi::WGPUResourceTable,
20323    }
20324    impl ResourceTable {
20325        pub(crate) unsafe fn from_raw(raw: ffi::WGPUResourceTable) -> Self {
20326            Self { raw }
20327        }
20328        pub(crate) fn as_raw(&self) -> ffi::WGPUResourceTable {
20329            self.raw
20330        }
20331        pub fn get_size(&self) -> u32 {
20332            let result = unsafe { ffi::wgpuResourceTableGetSize(self.raw) };
20333            result
20334        }
20335        pub fn destroy(&self) -> () {
20336            unsafe { ffi::wgpuResourceTableDestroy(self.raw) };
20337            ()
20338        }
20339        pub fn update(&self, slot: u32, resource: &BindingResource) -> Status {
20340            let (resource_ffi, _resource_storage) = resource.to_ffi();
20341            let resource_ptr = std::ptr::addr_of!(resource_ffi);
20342            let result = unsafe {
20343                ffi::wgpuResourceTableUpdate(self.raw, slot, resource_ptr)
20344            };
20345            result.into()
20346        }
20347        pub fn insert_binding(&self, resource: &BindingResource) -> u32 {
20348            let (resource_ffi, _resource_storage) = resource.to_ffi();
20349            let resource_ptr = std::ptr::addr_of!(resource_ffi);
20350            let result = unsafe {
20351                ffi::wgpuResourceTableInsertBinding(self.raw, resource_ptr)
20352            };
20353            result
20354        }
20355        pub fn remove_binding(&self, slot: u32) -> Status {
20356            let result = unsafe { ffi::wgpuResourceTableRemoveBinding(self.raw, slot) };
20357            result.into()
20358        }
20359    }
20360    impl Drop for ResourceTable {
20361        fn drop(&mut self) {
20362            if self.as_raw().is_null() {
20363                return;
20364            }
20365            unsafe { ffi::wgpuResourceTableRelease(self.raw) };
20366        }
20367    }
20368    impl Clone for ResourceTable {
20369        fn clone(&self) -> Self {
20370            unsafe { ffi::wgpuResourceTableAddRef(self.raw) };
20371            Self { raw: self.raw }
20372        }
20373    }
20374    unsafe impl Send for ResourceTable {}
20375    unsafe impl Sync for ResourceTable {}
20376    #[derive(Debug)]
20377    pub struct Sampler {
20378        raw: ffi::WGPUSampler,
20379    }
20380    impl Sampler {
20381        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSampler) -> Self {
20382            Self { raw }
20383        }
20384        pub(crate) fn as_raw(&self) -> ffi::WGPUSampler {
20385            self.raw
20386        }
20387        pub fn set_label(&self, label: String) -> () {
20388            let label_ffi = ffi::WGPUStringView {
20389                data: label.as_ptr().cast(),
20390                length: label.len(),
20391            };
20392            unsafe { ffi::wgpuSamplerSetLabel(self.raw, label_ffi) };
20393            ()
20394        }
20395    }
20396    impl Drop for Sampler {
20397        fn drop(&mut self) {
20398            if self.as_raw().is_null() {
20399                return;
20400            }
20401            unsafe { ffi::wgpuSamplerRelease(self.raw) };
20402        }
20403    }
20404    impl Clone for Sampler {
20405        fn clone(&self) -> Self {
20406            unsafe { ffi::wgpuSamplerAddRef(self.raw) };
20407            Self { raw: self.raw }
20408        }
20409    }
20410    unsafe impl Send for Sampler {}
20411    unsafe impl Sync for Sampler {}
20412    #[derive(Debug)]
20413    pub struct ShaderModule {
20414        raw: ffi::WGPUShaderModule,
20415    }
20416    impl ShaderModule {
20417        pub(crate) unsafe fn from_raw(raw: ffi::WGPUShaderModule) -> Self {
20418            Self { raw }
20419        }
20420        pub(crate) fn as_raw(&self) -> ffi::WGPUShaderModule {
20421            self.raw
20422        }
20423        pub fn get_compilation_info(
20424            &self,
20425            callback: impl FnMut(
20426                CompilationInfoRequestStatus,
20427                &CompilationInfo,
20428            ) + Send + 'static,
20429        ) -> Future {
20430            let callback_box: CompilationInfoCallback = Box::new(callback);
20431            let callback_box = Box::new(Some(callback_box));
20432            let callback_userdata = Box::into_raw(callback_box)
20433                .cast::<std::ffi::c_void>();
20434            let callback_info_ffi = ffi::WGPUCompilationInfoCallbackInfo {
20435                nextInChain: std::ptr::null_mut(),
20436                mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
20437                callback: Some(compilation_info_callback_trampoline),
20438                userdata1: callback_userdata,
20439                userdata2: std::ptr::null_mut(),
20440            };
20441            let result = unsafe {
20442                ffi::wgpuShaderModuleGetCompilationInfo(self.raw, callback_info_ffi)
20443            };
20444            Future::from_ffi(result)
20445        }
20446        pub fn set_label(&self, label: String) -> () {
20447            let label_ffi = ffi::WGPUStringView {
20448                data: label.as_ptr().cast(),
20449                length: label.len(),
20450            };
20451            unsafe { ffi::wgpuShaderModuleSetLabel(self.raw, label_ffi) };
20452            ()
20453        }
20454    }
20455    impl Drop for ShaderModule {
20456        fn drop(&mut self) {
20457            if self.as_raw().is_null() {
20458                return;
20459            }
20460            unsafe { ffi::wgpuShaderModuleRelease(self.raw) };
20461        }
20462    }
20463    impl Clone for ShaderModule {
20464        fn clone(&self) -> Self {
20465            unsafe { ffi::wgpuShaderModuleAddRef(self.raw) };
20466            Self { raw: self.raw }
20467        }
20468    }
20469    unsafe impl Send for ShaderModule {}
20470    unsafe impl Sync for ShaderModule {}
20471    #[derive(Debug)]
20472    pub struct SharedBufferMemory {
20473        raw: ffi::WGPUSharedBufferMemory,
20474    }
20475    impl SharedBufferMemory {
20476        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedBufferMemory) -> Self {
20477            Self { raw }
20478        }
20479        pub(crate) fn as_raw(&self) -> ffi::WGPUSharedBufferMemory {
20480            self.raw
20481        }
20482        pub fn set_label(&self, label: String) -> () {
20483            let label_ffi = ffi::WGPUStringView {
20484                data: label.as_ptr().cast(),
20485                length: label.len(),
20486            };
20487            unsafe { ffi::wgpuSharedBufferMemorySetLabel(self.raw, label_ffi) };
20488            ()
20489        }
20490        pub fn get_properties(
20491            &self,
20492            properties: &mut SharedBufferMemoryProperties,
20493        ) -> Status {
20494            let (mut properties_ffi, _properties_storage) = properties.to_ffi();
20495            let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
20496            let result = unsafe {
20497                ffi::wgpuSharedBufferMemoryGetProperties(self.raw, properties_ptr)
20498            };
20499            *properties = SharedBufferMemoryProperties::from_ffi(properties_ffi);
20500            result.into()
20501        }
20502        pub fn create_buffer(&self, descriptor: Option<&BufferDescriptor>) -> Buffer {
20503            let mut descriptor_storage = ChainedStructStorage::new();
20504            let mut descriptor_ffi: Option<ffi::WGPUBufferDescriptor> = None;
20505            let descriptor_ptr = if let Some(value) = &descriptor {
20506                let (raw, storage) = value.to_ffi();
20507                descriptor_storage = storage;
20508                descriptor_ffi = Some(raw);
20509                if let Some(raw_ref) = descriptor_ffi.as_ref() {
20510                    std::ptr::from_ref(raw_ref)
20511                } else {
20512                    unreachable!(
20513                        "internal error: descriptor_ffi missing after assignment",
20514                    )
20515                }
20516            } else {
20517                std::ptr::null()
20518            };
20519            let result = unsafe {
20520                ffi::wgpuSharedBufferMemoryCreateBuffer(self.raw, descriptor_ptr)
20521            };
20522            unsafe { Buffer::from_raw(result) }
20523        }
20524        pub fn begin_access(
20525            &self,
20526            buffer: Buffer,
20527            descriptor: &SharedBufferMemoryBeginAccessDescriptor,
20528        ) -> Status {
20529            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20530            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
20531            let result = unsafe {
20532                ffi::wgpuSharedBufferMemoryBeginAccess(
20533                    self.raw,
20534                    buffer.as_raw(),
20535                    descriptor_ptr,
20536                )
20537            };
20538            result.into()
20539        }
20540        pub fn end_access(
20541            &self,
20542            buffer: Buffer,
20543            descriptor: &mut SharedBufferMemoryEndAccessState,
20544        ) -> Status {
20545            let (mut descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20546            let descriptor_ptr = std::ptr::addr_of_mut!(descriptor_ffi);
20547            let result = unsafe {
20548                ffi::wgpuSharedBufferMemoryEndAccess(
20549                    self.raw,
20550                    buffer.as_raw(),
20551                    descriptor_ptr,
20552                )
20553            };
20554            *descriptor = SharedBufferMemoryEndAccessState::from_ffi(descriptor_ffi);
20555            result.into()
20556        }
20557        pub fn is_device_lost(&self) -> bool {
20558            let result = unsafe { ffi::wgpuSharedBufferMemoryIsDeviceLost(self.raw) };
20559            result != 0
20560        }
20561    }
20562    impl Drop for SharedBufferMemory {
20563        fn drop(&mut self) {
20564            if self.as_raw().is_null() {
20565                return;
20566            }
20567            unsafe { ffi::wgpuSharedBufferMemoryRelease(self.raw) };
20568        }
20569    }
20570    impl Clone for SharedBufferMemory {
20571        fn clone(&self) -> Self {
20572            unsafe { ffi::wgpuSharedBufferMemoryAddRef(self.raw) };
20573            Self { raw: self.raw }
20574        }
20575    }
20576    unsafe impl Send for SharedBufferMemory {}
20577    unsafe impl Sync for SharedBufferMemory {}
20578    #[derive(Debug)]
20579    pub struct SharedFence {
20580        raw: ffi::WGPUSharedFence,
20581    }
20582    impl SharedFence {
20583        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedFence) -> Self {
20584            Self { raw }
20585        }
20586        pub(crate) fn as_raw(&self) -> ffi::WGPUSharedFence {
20587            self.raw
20588        }
20589        pub fn set_label(&self, label: String) -> () {
20590            let label_ffi = ffi::WGPUStringView {
20591                data: label.as_ptr().cast(),
20592                length: label.len(),
20593            };
20594            unsafe { ffi::wgpuSharedFenceSetLabel(self.raw, label_ffi) };
20595            ()
20596        }
20597        pub fn export_info(&self, info: &mut SharedFenceExportInfo) -> () {
20598            let (mut info_ffi, _info_storage) = info.to_ffi();
20599            let info_ptr = std::ptr::addr_of_mut!(info_ffi);
20600            unsafe { ffi::wgpuSharedFenceExportInfo(self.raw, info_ptr) };
20601            *info = SharedFenceExportInfo::from_ffi(info_ffi);
20602            ()
20603        }
20604    }
20605    impl Drop for SharedFence {
20606        fn drop(&mut self) {
20607            if self.as_raw().is_null() {
20608                return;
20609            }
20610            unsafe { ffi::wgpuSharedFenceRelease(self.raw) };
20611        }
20612    }
20613    impl Clone for SharedFence {
20614        fn clone(&self) -> Self {
20615            unsafe { ffi::wgpuSharedFenceAddRef(self.raw) };
20616            Self { raw: self.raw }
20617        }
20618    }
20619    unsafe impl Send for SharedFence {}
20620    unsafe impl Sync for SharedFence {}
20621    #[derive(Debug)]
20622    pub struct SharedTextureMemory {
20623        raw: ffi::WGPUSharedTextureMemory,
20624    }
20625    impl SharedTextureMemory {
20626        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedTextureMemory) -> Self {
20627            Self { raw }
20628        }
20629        pub(crate) fn as_raw(&self) -> ffi::WGPUSharedTextureMemory {
20630            self.raw
20631        }
20632        pub fn set_label(&self, label: String) -> () {
20633            let label_ffi = ffi::WGPUStringView {
20634                data: label.as_ptr().cast(),
20635                length: label.len(),
20636            };
20637            unsafe { ffi::wgpuSharedTextureMemorySetLabel(self.raw, label_ffi) };
20638            ()
20639        }
20640        pub fn get_properties(
20641            &self,
20642            properties: &mut SharedTextureMemoryProperties,
20643        ) -> Status {
20644            let (mut properties_ffi, _properties_storage) = properties.to_ffi();
20645            let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
20646            let result = unsafe {
20647                ffi::wgpuSharedTextureMemoryGetProperties(self.raw, properties_ptr)
20648            };
20649            *properties = SharedTextureMemoryProperties::from_ffi(properties_ffi);
20650            result.into()
20651        }
20652        pub fn create_texture(&self, descriptor: Option<&TextureDescriptor>) -> Texture {
20653            let mut descriptor_storage = ChainedStructStorage::new();
20654            let mut descriptor_ffi: Option<ffi::WGPUTextureDescriptor> = None;
20655            let descriptor_ptr = if let Some(value) = &descriptor {
20656                let (raw, storage) = value.to_ffi();
20657                descriptor_storage = storage;
20658                descriptor_ffi = Some(raw);
20659                if let Some(raw_ref) = descriptor_ffi.as_ref() {
20660                    std::ptr::from_ref(raw_ref)
20661                } else {
20662                    unreachable!(
20663                        "internal error: descriptor_ffi missing after assignment",
20664                    )
20665                }
20666            } else {
20667                std::ptr::null()
20668            };
20669            let result = unsafe {
20670                ffi::wgpuSharedTextureMemoryCreateTexture(self.raw, descriptor_ptr)
20671            };
20672            unsafe { Texture::from_raw(result) }
20673        }
20674        pub fn begin_access(
20675            &self,
20676            texture: Texture,
20677            descriptor: &SharedTextureMemoryBeginAccessDescriptor,
20678        ) -> Status {
20679            let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20680            let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
20681            let result = unsafe {
20682                ffi::wgpuSharedTextureMemoryBeginAccess(
20683                    self.raw,
20684                    texture.as_raw(),
20685                    descriptor_ptr,
20686                )
20687            };
20688            result.into()
20689        }
20690        pub fn end_access(
20691            &self,
20692            texture: Texture,
20693            descriptor: &mut SharedTextureMemoryEndAccessState,
20694        ) -> Status {
20695            let (mut descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20696            let descriptor_ptr = std::ptr::addr_of_mut!(descriptor_ffi);
20697            let result = unsafe {
20698                ffi::wgpuSharedTextureMemoryEndAccess(
20699                    self.raw,
20700                    texture.as_raw(),
20701                    descriptor_ptr,
20702                )
20703            };
20704            *descriptor = SharedTextureMemoryEndAccessState::from_ffi(descriptor_ffi);
20705            result.into()
20706        }
20707        pub fn is_device_lost(&self) -> bool {
20708            let result = unsafe { ffi::wgpuSharedTextureMemoryIsDeviceLost(self.raw) };
20709            result != 0
20710        }
20711    }
20712    impl Drop for SharedTextureMemory {
20713        fn drop(&mut self) {
20714            if self.as_raw().is_null() {
20715                return;
20716            }
20717            unsafe { ffi::wgpuSharedTextureMemoryRelease(self.raw) };
20718        }
20719    }
20720    impl Clone for SharedTextureMemory {
20721        fn clone(&self) -> Self {
20722            unsafe { ffi::wgpuSharedTextureMemoryAddRef(self.raw) };
20723            Self { raw: self.raw }
20724        }
20725    }
20726    unsafe impl Send for SharedTextureMemory {}
20727    unsafe impl Sync for SharedTextureMemory {}
20728    #[derive(Debug)]
20729    pub struct Surface {
20730        raw: ffi::WGPUSurface,
20731    }
20732    impl Surface {
20733        pub(crate) unsafe fn from_raw(raw: ffi::WGPUSurface) -> Self {
20734            Self { raw }
20735        }
20736        pub(crate) fn as_raw(&self) -> ffi::WGPUSurface {
20737            self.raw
20738        }
20739        pub fn configure(&self, config: &SurfaceConfiguration) -> () {
20740            let (config_ffi, _config_storage) = config.to_ffi();
20741            let config_ptr = std::ptr::addr_of!(config_ffi);
20742            unsafe { ffi::wgpuSurfaceConfigure(self.raw, config_ptr) };
20743            ()
20744        }
20745        pub fn get_capabilities(
20746            &self,
20747            adapter: Adapter,
20748            capabilities: &mut SurfaceCapabilities,
20749        ) -> Status {
20750            let (mut capabilities_ffi, _capabilities_storage) = capabilities.to_ffi();
20751            let capabilities_ptr = std::ptr::addr_of_mut!(capabilities_ffi);
20752            let result = unsafe {
20753                ffi::wgpuSurfaceGetCapabilities(
20754                    self.raw,
20755                    adapter.as_raw(),
20756                    capabilities_ptr,
20757                )
20758            };
20759            *capabilities = SurfaceCapabilities::from_ffi(capabilities_ffi);
20760            result.into()
20761        }
20762        pub fn get_current_texture(&self, surface_texture: &mut SurfaceTexture) -> () {
20763            let (mut surface_texture_ffi, _surface_texture_storage) = surface_texture
20764                .to_ffi();
20765            let surface_texture_ptr = std::ptr::addr_of_mut!(surface_texture_ffi);
20766            unsafe { ffi::wgpuSurfaceGetCurrentTexture(self.raw, surface_texture_ptr) };
20767            *surface_texture = SurfaceTexture::from_ffi(surface_texture_ffi);
20768            ()
20769        }
20770        pub fn present(&self) -> Status {
20771            let result = unsafe { ffi::wgpuSurfacePresent(self.raw) };
20772            result.into()
20773        }
20774        pub fn unconfigure(&self) -> () {
20775            unsafe { ffi::wgpuSurfaceUnconfigure(self.raw) };
20776            ()
20777        }
20778        pub fn set_label(&self, label: String) -> () {
20779            let label_ffi = ffi::WGPUStringView {
20780                data: label.as_ptr().cast(),
20781                length: label.len(),
20782            };
20783            unsafe { ffi::wgpuSurfaceSetLabel(self.raw, label_ffi) };
20784            ()
20785        }
20786    }
20787    impl Drop for Surface {
20788        fn drop(&mut self) {
20789            if self.as_raw().is_null() {
20790                return;
20791            }
20792            unsafe { ffi::wgpuSurfaceRelease(self.raw) };
20793        }
20794    }
20795    impl Clone for Surface {
20796        fn clone(&self) -> Self {
20797            unsafe { ffi::wgpuSurfaceAddRef(self.raw) };
20798            Self { raw: self.raw }
20799        }
20800    }
20801    unsafe impl Send for Surface {}
20802    unsafe impl Sync for Surface {}
20803    #[derive(Debug)]
20804    pub struct TexelBufferView {
20805        raw: ffi::WGPUTexelBufferView,
20806    }
20807    impl TexelBufferView {
20808        pub(crate) unsafe fn from_raw(raw: ffi::WGPUTexelBufferView) -> Self {
20809            Self { raw }
20810        }
20811        pub(crate) fn as_raw(&self) -> ffi::WGPUTexelBufferView {
20812            self.raw
20813        }
20814        pub fn set_label(&self, label: String) -> () {
20815            let label_ffi = ffi::WGPUStringView {
20816                data: label.as_ptr().cast(),
20817                length: label.len(),
20818            };
20819            unsafe { ffi::wgpuTexelBufferViewSetLabel(self.raw, label_ffi) };
20820            ()
20821        }
20822    }
20823    impl Drop for TexelBufferView {
20824        fn drop(&mut self) {
20825            if self.as_raw().is_null() {
20826                return;
20827            }
20828            unsafe { ffi::wgpuTexelBufferViewRelease(self.raw) };
20829        }
20830    }
20831    impl Clone for TexelBufferView {
20832        fn clone(&self) -> Self {
20833            unsafe { ffi::wgpuTexelBufferViewAddRef(self.raw) };
20834            Self { raw: self.raw }
20835        }
20836    }
20837    unsafe impl Send for TexelBufferView {}
20838    unsafe impl Sync for TexelBufferView {}
20839    #[derive(Debug)]
20840    pub struct Texture {
20841        raw: ffi::WGPUTexture,
20842    }
20843    impl Texture {
20844        pub(crate) unsafe fn from_raw(raw: ffi::WGPUTexture) -> Self {
20845            Self { raw }
20846        }
20847        pub(crate) fn as_raw(&self) -> ffi::WGPUTexture {
20848            self.raw
20849        }
20850        pub fn create_view(
20851            &self,
20852            descriptor: Option<&TextureViewDescriptor>,
20853        ) -> TextureView {
20854            let mut descriptor_storage = ChainedStructStorage::new();
20855            let mut descriptor_ffi: Option<ffi::WGPUTextureViewDescriptor> = None;
20856            let descriptor_ptr = if let Some(value) = &descriptor {
20857                let (raw, storage) = value.to_ffi();
20858                descriptor_storage = storage;
20859                descriptor_ffi = Some(raw);
20860                if let Some(raw_ref) = descriptor_ffi.as_ref() {
20861                    std::ptr::from_ref(raw_ref)
20862                } else {
20863                    unreachable!(
20864                        "internal error: descriptor_ffi missing after assignment",
20865                    )
20866                }
20867            } else {
20868                std::ptr::null()
20869            };
20870            let result = unsafe { ffi::wgpuTextureCreateView(self.raw, descriptor_ptr) };
20871            unsafe { TextureView::from_raw(result) }
20872        }
20873        pub fn create_error_view(
20874            &self,
20875            descriptor: Option<&TextureViewDescriptor>,
20876        ) -> TextureView {
20877            let mut descriptor_storage = ChainedStructStorage::new();
20878            let mut descriptor_ffi: Option<ffi::WGPUTextureViewDescriptor> = None;
20879            let descriptor_ptr = if let Some(value) = &descriptor {
20880                let (raw, storage) = value.to_ffi();
20881                descriptor_storage = storage;
20882                descriptor_ffi = Some(raw);
20883                if let Some(raw_ref) = descriptor_ffi.as_ref() {
20884                    std::ptr::from_ref(raw_ref)
20885                } else {
20886                    unreachable!(
20887                        "internal error: descriptor_ffi missing after assignment",
20888                    )
20889                }
20890            } else {
20891                std::ptr::null()
20892            };
20893            let result = unsafe {
20894                ffi::wgpuTextureCreateErrorView(self.raw, descriptor_ptr)
20895            };
20896            unsafe { TextureView::from_raw(result) }
20897        }
20898        pub fn set_label(&self, label: String) -> () {
20899            let label_ffi = ffi::WGPUStringView {
20900                data: label.as_ptr().cast(),
20901                length: label.len(),
20902            };
20903            unsafe { ffi::wgpuTextureSetLabel(self.raw, label_ffi) };
20904            ()
20905        }
20906        pub fn get_width(&self) -> u32 {
20907            let result = unsafe { ffi::wgpuTextureGetWidth(self.raw) };
20908            result
20909        }
20910        pub fn get_height(&self) -> u32 {
20911            let result = unsafe { ffi::wgpuTextureGetHeight(self.raw) };
20912            result
20913        }
20914        pub fn get_depth_or_array_layers(&self) -> u32 {
20915            let result = unsafe { ffi::wgpuTextureGetDepthOrArrayLayers(self.raw) };
20916            result
20917        }
20918        pub fn get_mip_level_count(&self) -> u32 {
20919            let result = unsafe { ffi::wgpuTextureGetMipLevelCount(self.raw) };
20920            result
20921        }
20922        pub fn get_sample_count(&self) -> u32 {
20923            let result = unsafe { ffi::wgpuTextureGetSampleCount(self.raw) };
20924            result
20925        }
20926        pub fn get_dimension(&self) -> TextureDimension {
20927            let result = unsafe { ffi::wgpuTextureGetDimension(self.raw) };
20928            result.into()
20929        }
20930        pub fn get_format(&self) -> TextureFormat {
20931            let result = unsafe { ffi::wgpuTextureGetFormat(self.raw) };
20932            result.into()
20933        }
20934        pub fn get_usage(&self) -> TextureUsage {
20935            let result = unsafe { ffi::wgpuTextureGetUsage(self.raw) };
20936            result.into()
20937        }
20938        pub fn get_texture_binding_view_dimension(&self) -> TextureViewDimension {
20939            let result = unsafe {
20940                ffi::wgpuTextureGetTextureBindingViewDimension(self.raw)
20941            };
20942            result.into()
20943        }
20944        pub fn destroy(&self) -> () {
20945            unsafe { ffi::wgpuTextureDestroy(self.raw) };
20946            ()
20947        }
20948        pub fn pin(&self, usage: TextureUsage) -> () {
20949            let usage_ffi: ffi::WGPUTextureUsage = usage.into();
20950            unsafe { ffi::wgpuTexturePin(self.raw, usage_ffi) };
20951            ()
20952        }
20953        pub fn unpin(&self) -> () {
20954            unsafe { ffi::wgpuTextureUnpin(self.raw) };
20955            ()
20956        }
20957        pub fn set_ownership_for_memory_dump(&self, owner_guid: u64) -> () {
20958            unsafe { ffi::wgpuTextureSetOwnershipForMemoryDump(self.raw, owner_guid) };
20959            ()
20960        }
20961    }
20962    impl Drop for Texture {
20963        fn drop(&mut self) {
20964            if self.as_raw().is_null() {
20965                return;
20966            }
20967            unsafe { ffi::wgpuTextureRelease(self.raw) };
20968        }
20969    }
20970    impl Clone for Texture {
20971        fn clone(&self) -> Self {
20972            unsafe { ffi::wgpuTextureAddRef(self.raw) };
20973            Self { raw: self.raw }
20974        }
20975    }
20976    unsafe impl Send for Texture {}
20977    unsafe impl Sync for Texture {}
20978    #[derive(Debug)]
20979    pub struct TextureView {
20980        raw: ffi::WGPUTextureView,
20981    }
20982    impl TextureView {
20983        pub(crate) unsafe fn from_raw(raw: ffi::WGPUTextureView) -> Self {
20984            Self { raw }
20985        }
20986        pub(crate) fn as_raw(&self) -> ffi::WGPUTextureView {
20987            self.raw
20988        }
20989        pub fn set_label(&self, label: String) -> () {
20990            let label_ffi = ffi::WGPUStringView {
20991                data: label.as_ptr().cast(),
20992                length: label.len(),
20993            };
20994            unsafe { ffi::wgpuTextureViewSetLabel(self.raw, label_ffi) };
20995            ()
20996        }
20997    }
20998    impl Drop for TextureView {
20999        fn drop(&mut self) {
21000            if self.as_raw().is_null() {
21001                return;
21002            }
21003            unsafe { ffi::wgpuTextureViewRelease(self.raw) };
21004        }
21005    }
21006    impl Clone for TextureView {
21007        fn clone(&self) -> Self {
21008            unsafe { ffi::wgpuTextureViewAddRef(self.raw) };
21009            Self { raw: self.raw }
21010        }
21011    }
21012    unsafe impl Send for TextureView {}
21013    unsafe impl Sync for TextureView {}
21014}
21015mod callbacks {
21016    #![allow(dead_code, unused_imports)]
21017    use crate::ffi;
21018    use crate::generated::*;
21019    pub type Callback = Option<unsafe extern "C" fn(*mut std::ffi::c_void) -> ()>;
21020    pub type DawnLoadCacheDataFunction = Option<
21021        unsafe extern "C" fn(
21022            *const std::ffi::c_void,
21023            usize,
21024            *mut std::ffi::c_void,
21025            usize,
21026            *mut std::ffi::c_void,
21027        ) -> usize,
21028    >;
21029    pub type DawnStoreCacheDataFunction = Option<
21030        unsafe extern "C" fn(
21031            *const std::ffi::c_void,
21032            usize,
21033            *const std::ffi::c_void,
21034            usize,
21035            *mut std::ffi::c_void,
21036        ) -> (),
21037    >;
21038    pub type Proc = Option<unsafe extern "C" fn() -> ()>;
21039    pub type BufferMapCallback = Box<dyn FnMut(MapAsyncStatus, String) + Send + 'static>;
21040    pub(crate) unsafe extern "C" fn buffer_map_callback_trampoline(
21041        status: ffi::WGPUMapAsyncStatus,
21042        message: ffi::WGPUStringView,
21043        userdata1: *mut std::ffi::c_void,
21044        userdata2: *mut std::ffi::c_void,
21045    ) {
21046        let _ = userdata2;
21047        let status = status.into();
21048        let message = string_view_to_string(message);
21049        let mut callback = unsafe {
21050            Box::from_raw(userdata1.cast::<Option<BufferMapCallback>>())
21051        };
21052        if let Some(mut callback) = callback.take() {
21053            callback(status, message);
21054        }
21055    }
21056    pub type CompilationInfoCallback = Box<
21057        dyn FnMut(CompilationInfoRequestStatus, &CompilationInfo) + Send + 'static,
21058    >;
21059    pub(crate) unsafe extern "C" fn compilation_info_callback_trampoline(
21060        status: ffi::WGPUCompilationInfoRequestStatus,
21061        compilation_info: *const ffi::WGPUCompilationInfo,
21062        userdata1: *mut std::ffi::c_void,
21063        userdata2: *mut std::ffi::c_void,
21064    ) {
21065        let _ = userdata2;
21066        let status = status.into();
21067        let compilation_info = if compilation_info.is_null() {
21068            CompilationInfo::new()
21069        } else {
21070            CompilationInfo::new()
21071        };
21072        let mut callback = unsafe {
21073            Box::from_raw(userdata1.cast::<Option<CompilationInfoCallback>>())
21074        };
21075        if let Some(mut callback) = callback.take() {
21076            callback(status, &compilation_info);
21077        }
21078    }
21079    pub type CreateComputePipelineAsyncCallback = Box<
21080        dyn FnMut(
21081            CreatePipelineAsyncStatus,
21082            Option<ComputePipeline>,
21083            String,
21084        ) + Send + 'static,
21085    >;
21086    pub(crate) unsafe extern "C" fn create_compute_pipeline_async_callback_trampoline(
21087        status: ffi::WGPUCreatePipelineAsyncStatus,
21088        pipeline: ffi::WGPUComputePipeline,
21089        message: ffi::WGPUStringView,
21090        userdata1: *mut std::ffi::c_void,
21091        userdata2: *mut std::ffi::c_void,
21092    ) {
21093        let _ = userdata2;
21094        let status = status.into();
21095        let pipeline = if pipeline.is_null() {
21096            None
21097        } else {
21098            Some(unsafe { ComputePipeline::from_raw(pipeline) })
21099        };
21100        let message = string_view_to_string(message);
21101        let mut callback = unsafe {
21102            Box::from_raw(userdata1.cast::<Option<CreateComputePipelineAsyncCallback>>())
21103        };
21104        if let Some(mut callback) = callback.take() {
21105            callback(status, pipeline, message);
21106        }
21107    }
21108    pub type CreateRenderPipelineAsyncCallback = Box<
21109        dyn FnMut(
21110            CreatePipelineAsyncStatus,
21111            Option<RenderPipeline>,
21112            String,
21113        ) + Send + 'static,
21114    >;
21115    pub(crate) unsafe extern "C" fn create_render_pipeline_async_callback_trampoline(
21116        status: ffi::WGPUCreatePipelineAsyncStatus,
21117        pipeline: ffi::WGPURenderPipeline,
21118        message: ffi::WGPUStringView,
21119        userdata1: *mut std::ffi::c_void,
21120        userdata2: *mut std::ffi::c_void,
21121    ) {
21122        let _ = userdata2;
21123        let status = status.into();
21124        let pipeline = if pipeline.is_null() {
21125            None
21126        } else {
21127            Some(unsafe { RenderPipeline::from_raw(pipeline) })
21128        };
21129        let message = string_view_to_string(message);
21130        let mut callback = unsafe {
21131            Box::from_raw(userdata1.cast::<Option<CreateRenderPipelineAsyncCallback>>())
21132        };
21133        if let Some(mut callback) = callback.take() {
21134            callback(status, pipeline, message);
21135        }
21136    }
21137    pub type DeviceLostCallback = Box<
21138        dyn FnMut(Vec<Device>, DeviceLostReason, String) + Send + 'static,
21139    >;
21140    pub(crate) unsafe extern "C" fn device_lost_callback_trampoline(
21141        device: *const ffi::WGPUDevice,
21142        reason: ffi::WGPUDeviceLostReason,
21143        message: ffi::WGPUStringView,
21144        userdata1: *mut std::ffi::c_void,
21145        userdata2: *mut std::ffi::c_void,
21146    ) {
21147        let _ = userdata2;
21148        let device = if device.is_null() {
21149            Vec::new()
21150        } else {
21151            unsafe { std::slice::from_raw_parts(device, 1) }
21152                .iter()
21153                .map(|raw| unsafe { Device::from_raw(*raw) })
21154                .collect()
21155        };
21156        let reason = reason.into();
21157        let message = string_view_to_string(message);
21158        let mut callback = unsafe {
21159            Box::from_raw(userdata1.cast::<Option<DeviceLostCallback>>())
21160        };
21161        if let Some(mut callback) = callback.take() {
21162            callback(device, reason, message);
21163        }
21164    }
21165    pub type LoggingCallback = Box<dyn FnMut(LoggingType, String) + Send + 'static>;
21166    pub(crate) unsafe extern "C" fn logging_callback_trampoline(
21167        r#type: ffi::WGPULoggingType,
21168        message: ffi::WGPUStringView,
21169        userdata1: *mut std::ffi::c_void,
21170        userdata2: *mut std::ffi::c_void,
21171    ) {
21172        let _ = userdata2;
21173        let r#type = r#type.into();
21174        let message = string_view_to_string(message);
21175        let mut callback = unsafe {
21176            Box::from_raw(userdata1.cast::<Option<LoggingCallback>>())
21177        };
21178        if let Some(mut callback) = callback.take() {
21179            callback(r#type, message);
21180        }
21181    }
21182    pub type PopErrorScopeCallback = Box<
21183        dyn FnMut(PopErrorScopeStatus, ErrorType, String) + Send + 'static,
21184    >;
21185    pub(crate) unsafe extern "C" fn pop_error_scope_callback_trampoline(
21186        status: ffi::WGPUPopErrorScopeStatus,
21187        r#type: ffi::WGPUErrorType,
21188        message: ffi::WGPUStringView,
21189        userdata1: *mut std::ffi::c_void,
21190        userdata2: *mut std::ffi::c_void,
21191    ) {
21192        let _ = userdata2;
21193        let status = status.into();
21194        let r#type = r#type.into();
21195        let message = string_view_to_string(message);
21196        let mut callback = unsafe {
21197            Box::from_raw(userdata1.cast::<Option<PopErrorScopeCallback>>())
21198        };
21199        if let Some(mut callback) = callback.take() {
21200            callback(status, r#type, message);
21201        }
21202    }
21203    pub type QueueWorkDoneCallback = Box<
21204        dyn FnMut(QueueWorkDoneStatus, String) + Send + 'static,
21205    >;
21206    pub(crate) unsafe extern "C" fn queue_work_done_callback_trampoline(
21207        status: ffi::WGPUQueueWorkDoneStatus,
21208        message: ffi::WGPUStringView,
21209        userdata1: *mut std::ffi::c_void,
21210        userdata2: *mut std::ffi::c_void,
21211    ) {
21212        let _ = userdata2;
21213        let status = status.into();
21214        let message = string_view_to_string(message);
21215        let mut callback = unsafe {
21216            Box::from_raw(userdata1.cast::<Option<QueueWorkDoneCallback>>())
21217        };
21218        if let Some(mut callback) = callback.take() {
21219            callback(status, message);
21220        }
21221    }
21222    pub type RequestAdapterCallback = Box<
21223        dyn FnMut(RequestAdapterStatus, Option<Adapter>, String) + Send + 'static,
21224    >;
21225    pub(crate) unsafe extern "C" fn request_adapter_callback_trampoline(
21226        status: ffi::WGPURequestAdapterStatus,
21227        adapter: ffi::WGPUAdapter,
21228        message: ffi::WGPUStringView,
21229        userdata1: *mut std::ffi::c_void,
21230        userdata2: *mut std::ffi::c_void,
21231    ) {
21232        let _ = userdata2;
21233        let status = status.into();
21234        let adapter = if adapter.is_null() {
21235            None
21236        } else {
21237            Some(unsafe { Adapter::from_raw(adapter) })
21238        };
21239        let message = string_view_to_string(message);
21240        let mut callback = unsafe {
21241            Box::from_raw(userdata1.cast::<Option<RequestAdapterCallback>>())
21242        };
21243        if let Some(mut callback) = callback.take() {
21244            callback(status, adapter, message);
21245        }
21246    }
21247    pub type RequestDeviceCallback = Box<
21248        dyn FnMut(RequestDeviceStatus, Option<Device>, String) + Send + 'static,
21249    >;
21250    pub(crate) unsafe extern "C" fn request_device_callback_trampoline(
21251        status: ffi::WGPURequestDeviceStatus,
21252        device: ffi::WGPUDevice,
21253        message: ffi::WGPUStringView,
21254        userdata1: *mut std::ffi::c_void,
21255        userdata2: *mut std::ffi::c_void,
21256    ) {
21257        let _ = userdata2;
21258        let status = status.into();
21259        let device = if device.is_null() {
21260            None
21261        } else {
21262            Some(unsafe { Device::from_raw(device) })
21263        };
21264        let message = string_view_to_string(message);
21265        let mut callback = unsafe {
21266            Box::from_raw(userdata1.cast::<Option<RequestDeviceCallback>>())
21267        };
21268        if let Some(mut callback) = callback.take() {
21269            callback(status, device, message);
21270        }
21271    }
21272    pub type UncapturedErrorCallback = Box<
21273        dyn FnMut(Vec<Device>, ErrorType, String) + Send + 'static,
21274    >;
21275    pub(crate) unsafe extern "C" fn uncaptured_error_callback_trampoline(
21276        device: *const ffi::WGPUDevice,
21277        r#type: ffi::WGPUErrorType,
21278        message: ffi::WGPUStringView,
21279        userdata1: *mut std::ffi::c_void,
21280        userdata2: *mut std::ffi::c_void,
21281    ) {
21282        let _ = userdata2;
21283        let device = if device.is_null() {
21284            Vec::new()
21285        } else {
21286            unsafe { std::slice::from_raw_parts(device, 1) }
21287                .iter()
21288                .map(|raw| unsafe { Device::from_raw(*raw) })
21289                .collect()
21290        };
21291        let r#type = r#type.into();
21292        let message = string_view_to_string(message);
21293        let mut callback = unsafe {
21294            Box::from_raw(userdata1.cast::<Option<UncapturedErrorCallback>>())
21295        };
21296        if let Some(mut callback) = callback.take() {
21297            callback(device, r#type, message);
21298        }
21299    }
21300    pub struct BufferMapCallbackInfo {
21301        pub mode: Option<CallbackMode>,
21302        pub callback: std::cell::RefCell<Option<BufferMapCallback>>,
21303    }
21304    impl Default for BufferMapCallbackInfo {
21305        fn default() -> Self {
21306            Self {
21307                mode: None,
21308                callback: std::cell::RefCell::new(None),
21309            }
21310        }
21311    }
21312    impl BufferMapCallbackInfo {
21313        pub fn new() -> Self {
21314            Self::default()
21315        }
21316    }
21317    pub struct CompilationInfoCallbackInfo {
21318        pub mode: Option<CallbackMode>,
21319        pub callback: std::cell::RefCell<Option<CompilationInfoCallback>>,
21320    }
21321    impl Default for CompilationInfoCallbackInfo {
21322        fn default() -> Self {
21323            Self {
21324                mode: None,
21325                callback: std::cell::RefCell::new(None),
21326            }
21327        }
21328    }
21329    impl CompilationInfoCallbackInfo {
21330        pub fn new() -> Self {
21331            Self::default()
21332        }
21333    }
21334    pub struct CreateComputePipelineAsyncCallbackInfo {
21335        pub mode: Option<CallbackMode>,
21336        pub callback: std::cell::RefCell<Option<CreateComputePipelineAsyncCallback>>,
21337    }
21338    impl Default for CreateComputePipelineAsyncCallbackInfo {
21339        fn default() -> Self {
21340            Self {
21341                mode: None,
21342                callback: std::cell::RefCell::new(None),
21343            }
21344        }
21345    }
21346    impl CreateComputePipelineAsyncCallbackInfo {
21347        pub fn new() -> Self {
21348            Self::default()
21349        }
21350    }
21351    pub struct CreateRenderPipelineAsyncCallbackInfo {
21352        pub mode: Option<CallbackMode>,
21353        pub callback: std::cell::RefCell<Option<CreateRenderPipelineAsyncCallback>>,
21354    }
21355    impl Default for CreateRenderPipelineAsyncCallbackInfo {
21356        fn default() -> Self {
21357            Self {
21358                mode: None,
21359                callback: std::cell::RefCell::new(None),
21360            }
21361        }
21362    }
21363    impl CreateRenderPipelineAsyncCallbackInfo {
21364        pub fn new() -> Self {
21365            Self::default()
21366        }
21367    }
21368    pub struct DeviceLostCallbackInfo {
21369        pub mode: Option<CallbackMode>,
21370        pub callback: std::cell::RefCell<Option<DeviceLostCallback>>,
21371    }
21372    impl Default for DeviceLostCallbackInfo {
21373        fn default() -> Self {
21374            Self {
21375                mode: None,
21376                callback: std::cell::RefCell::new(None),
21377            }
21378        }
21379    }
21380    impl DeviceLostCallbackInfo {
21381        pub fn new() -> Self {
21382            Self::default()
21383        }
21384    }
21385    pub struct LoggingCallbackInfo {
21386        pub callback: std::cell::RefCell<Option<LoggingCallback>>,
21387    }
21388    impl Default for LoggingCallbackInfo {
21389        fn default() -> Self {
21390            Self {
21391                callback: std::cell::RefCell::new(None),
21392            }
21393        }
21394    }
21395    impl LoggingCallbackInfo {
21396        pub fn new() -> Self {
21397            Self::default()
21398        }
21399    }
21400    pub struct PopErrorScopeCallbackInfo {
21401        pub mode: Option<CallbackMode>,
21402        pub callback: std::cell::RefCell<Option<PopErrorScopeCallback>>,
21403    }
21404    impl Default for PopErrorScopeCallbackInfo {
21405        fn default() -> Self {
21406            Self {
21407                mode: None,
21408                callback: std::cell::RefCell::new(None),
21409            }
21410        }
21411    }
21412    impl PopErrorScopeCallbackInfo {
21413        pub fn new() -> Self {
21414            Self::default()
21415        }
21416    }
21417    pub struct QueueWorkDoneCallbackInfo {
21418        pub mode: Option<CallbackMode>,
21419        pub callback: std::cell::RefCell<Option<QueueWorkDoneCallback>>,
21420    }
21421    impl Default for QueueWorkDoneCallbackInfo {
21422        fn default() -> Self {
21423            Self {
21424                mode: None,
21425                callback: std::cell::RefCell::new(None),
21426            }
21427        }
21428    }
21429    impl QueueWorkDoneCallbackInfo {
21430        pub fn new() -> Self {
21431            Self::default()
21432        }
21433    }
21434    pub struct RequestAdapterCallbackInfo {
21435        pub mode: Option<CallbackMode>,
21436        pub callback: std::cell::RefCell<Option<RequestAdapterCallback>>,
21437    }
21438    impl Default for RequestAdapterCallbackInfo {
21439        fn default() -> Self {
21440            Self {
21441                mode: None,
21442                callback: std::cell::RefCell::new(None),
21443            }
21444        }
21445    }
21446    impl RequestAdapterCallbackInfo {
21447        pub fn new() -> Self {
21448            Self::default()
21449        }
21450    }
21451    pub struct RequestDeviceCallbackInfo {
21452        pub mode: Option<CallbackMode>,
21453        pub callback: std::cell::RefCell<Option<RequestDeviceCallback>>,
21454    }
21455    impl Default for RequestDeviceCallbackInfo {
21456        fn default() -> Self {
21457            Self {
21458                mode: None,
21459                callback: std::cell::RefCell::new(None),
21460            }
21461        }
21462    }
21463    impl RequestDeviceCallbackInfo {
21464        pub fn new() -> Self {
21465            Self::default()
21466        }
21467    }
21468    pub struct UncapturedErrorCallbackInfo {
21469        pub callback: std::cell::RefCell<Option<UncapturedErrorCallback>>,
21470    }
21471    impl Default for UncapturedErrorCallbackInfo {
21472        fn default() -> Self {
21473            Self {
21474                callback: std::cell::RefCell::new(None),
21475            }
21476        }
21477    }
21478    impl UncapturedErrorCallbackInfo {
21479        pub fn new() -> Self {
21480            Self::default()
21481        }
21482    }
21483}
21484mod functions {
21485    #![allow(dead_code, unused_imports)]
21486    use crate::generated::*;
21487    use crate::ffi;
21488    pub fn create_instance(descriptor: Option<&InstanceDescriptor>) -> Instance {
21489        let mut descriptor_storage = ChainedStructStorage::new();
21490        let mut descriptor_ffi: Option<ffi::WGPUInstanceDescriptor> = None;
21491        let descriptor_ptr = if let Some(value) = &descriptor {
21492            let (raw, storage) = value.to_ffi();
21493            descriptor_storage = storage;
21494            descriptor_ffi = Some(raw);
21495            if let Some(raw_ref) = descriptor_ffi.as_ref() {
21496                std::ptr::from_ref(raw_ref)
21497            } else {
21498                unreachable!("internal error: descriptor_ffi missing after assignment")
21499            }
21500        } else {
21501            std::ptr::null()
21502        };
21503        let result = unsafe { ffi::wgpuCreateInstance(descriptor_ptr) };
21504        unsafe { Instance::from_raw(result) }
21505    }
21506    pub fn get_instance_features(features: &mut SupportedInstanceFeatures) -> () {
21507        let (mut features_ffi, _features_storage) = features.to_ffi();
21508        let features_ptr = std::ptr::addr_of_mut!(features_ffi);
21509        unsafe { ffi::wgpuGetInstanceFeatures(features_ptr) };
21510        *features = SupportedInstanceFeatures::from_ffi(features_ffi);
21511        ()
21512    }
21513    pub fn get_instance_limits(limits: &mut InstanceLimits) -> Status {
21514        let (mut limits_ffi, _limits_storage) = limits.to_ffi();
21515        let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
21516        let result = unsafe { ffi::wgpuGetInstanceLimits(limits_ptr) };
21517        *limits = InstanceLimits::from_ffi(limits_ffi);
21518        result.into()
21519    }
21520    pub fn get_proc_address(proc_name: String) -> Proc {
21521        let proc_name_ffi = ffi::WGPUStringView {
21522            data: proc_name.as_ptr().cast(),
21523            length: proc_name.len(),
21524        };
21525        let result = unsafe { ffi::wgpuGetProcAddress(proc_name_ffi) };
21526        result
21527    }
21528    pub fn has_instance_feature(feature: InstanceFeatureName) -> bool {
21529        let feature_ffi: ffi::WGPUInstanceFeatureName = feature.into();
21530        let result = unsafe { ffi::wgpuHasInstanceFeature(feature_ffi) };
21531        result != 0
21532    }
21533}
21534mod constants {
21535    #![allow(dead_code, unused_imports)]
21536    use crate::generated::*;
21537    use crate::ffi;
21538    pub const ARRAY_LAYER_COUNT_UNDEFINED: u32 = u32::MAX;
21539    pub const COPY_STRIDE_UNDEFINED: u32 = u32::MAX;
21540    pub const DEPTH_CLEAR_VALUE_UNDEFINED: f32 = f32::NAN;
21541    pub const DEPTH_SLICE_UNDEFINED: u32 = u32::MAX;
21542    pub const INVALID_BINDING: u32 = u32::MAX;
21543    pub const LIMIT_U32_UNDEFINED: u32 = u32::MAX;
21544    pub const LIMIT_U64_UNDEFINED: u64 = u64::MAX;
21545    pub const MIP_LEVEL_COUNT_UNDEFINED: u32 = u32::MAX;
21546    pub const QUERY_SET_INDEX_UNDEFINED: u32 = u32::MAX;
21547    pub const STRLEN: usize = usize::MAX;
21548    pub const WHOLE_MAP_SIZE: usize = usize::MAX;
21549    pub const WHOLE_SIZE: u64 = u64::MAX;
21550}
21551pub use enums::*;
21552pub use structs::*;
21553pub use extensions::*;
21554pub use objects::*;
21555pub use callbacks::*;
21556pub use functions::*;
21557pub use constants::*;