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 ChromiumTestingUnimplemented,
15 ChromiumTestingUnsafeExperimental,
16 ChromiumTestingExperimental,
17 ChromiumTestingShippedWithKillswitch,
18 ChromiumTestingShipped,
19 SizedBindingArray,
20 TexelBuffers,
21 ChromiumPrint,
22 FragmentDepth,
23 ImmediateAddressSpace,
24 SubgroupUniformity,
25 BufferView,
26 FilteringParameters,
27 SwizzleAssignment,
28 LinearIndexing,
29 }
30 impl From<ffi::WGPUWGSLLanguageFeatureName> for WGSLLanguageFeatureName {
31 fn from(value: ffi::WGPUWGSLLanguageFeatureName) -> Self {
32 match value {
33 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures => {
34 WGSLLanguageFeatureName::ReadonlyAndReadwriteStorageTextures
35 }
36 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct => {
37 WGSLLanguageFeatureName::Packed4X8IntegerDotProduct
38 }
39 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters => {
40 WGSLLanguageFeatureName::UnrestrictedPointerParameters
41 }
42 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_PointerCompositeAccess => {
43 WGSLLanguageFeatureName::PointerCompositeAccess
44 }
45 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_UniformBufferStandardLayout => {
46 WGSLLanguageFeatureName::UniformBufferStandardLayout
47 }
48 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SubgroupId => {
49 WGSLLanguageFeatureName::SubgroupId
50 }
51 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TextureAndSamplerLet => {
52 WGSLLanguageFeatureName::TextureAndSamplerLet
53 }
54 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingUnimplemented => {
55 WGSLLanguageFeatureName::ChromiumTestingUnimplemented
56 }
57 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingUnsafeExperimental => {
58 WGSLLanguageFeatureName::ChromiumTestingUnsafeExperimental
59 }
60 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingExperimental => {
61 WGSLLanguageFeatureName::ChromiumTestingExperimental
62 }
63 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingShippedWithKillswitch => {
64 WGSLLanguageFeatureName::ChromiumTestingShippedWithKillswitch
65 }
66 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingShipped => {
67 WGSLLanguageFeatureName::ChromiumTestingShipped
68 }
69 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SizedBindingArray => {
70 WGSLLanguageFeatureName::SizedBindingArray
71 }
72 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TexelBuffers => {
73 WGSLLanguageFeatureName::TexelBuffers
74 }
75 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumPrint => {
76 WGSLLanguageFeatureName::ChromiumPrint
77 }
78 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_FragmentDepth => {
79 WGSLLanguageFeatureName::FragmentDepth
80 }
81 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ImmediateAddressSpace => {
82 WGSLLanguageFeatureName::ImmediateAddressSpace
83 }
84 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SubgroupUniformity => {
85 WGSLLanguageFeatureName::SubgroupUniformity
86 }
87 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_BufferView => {
88 WGSLLanguageFeatureName::BufferView
89 }
90 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_FilteringParameters => {
91 WGSLLanguageFeatureName::FilteringParameters
92 }
93 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SwizzleAssignment => {
94 WGSLLanguageFeatureName::SwizzleAssignment
95 }
96 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_LinearIndexing => {
97 WGSLLanguageFeatureName::LinearIndexing
98 }
99 _ => WGSLLanguageFeatureName::ReadonlyAndReadwriteStorageTextures,
100 }
101 }
102 }
103 impl From<WGSLLanguageFeatureName> for ffi::WGPUWGSLLanguageFeatureName {
104 fn from(value: WGSLLanguageFeatureName) -> Self {
105 match value {
106 WGSLLanguageFeatureName::ReadonlyAndReadwriteStorageTextures => {
107 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ReadonlyAndReadwriteStorageTextures
108 }
109 WGSLLanguageFeatureName::Packed4X8IntegerDotProduct => {
110 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_Packed4x8IntegerDotProduct
111 }
112 WGSLLanguageFeatureName::UnrestrictedPointerParameters => {
113 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_UnrestrictedPointerParameters
114 }
115 WGSLLanguageFeatureName::PointerCompositeAccess => {
116 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_PointerCompositeAccess
117 }
118 WGSLLanguageFeatureName::UniformBufferStandardLayout => {
119 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_UniformBufferStandardLayout
120 }
121 WGSLLanguageFeatureName::SubgroupId => {
122 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SubgroupId
123 }
124 WGSLLanguageFeatureName::TextureAndSamplerLet => {
125 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TextureAndSamplerLet
126 }
127 WGSLLanguageFeatureName::ChromiumTestingUnimplemented => {
128 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingUnimplemented
129 }
130 WGSLLanguageFeatureName::ChromiumTestingUnsafeExperimental => {
131 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingUnsafeExperimental
132 }
133 WGSLLanguageFeatureName::ChromiumTestingExperimental => {
134 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingExperimental
135 }
136 WGSLLanguageFeatureName::ChromiumTestingShippedWithKillswitch => {
137 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingShippedWithKillswitch
138 }
139 WGSLLanguageFeatureName::ChromiumTestingShipped => {
140 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumTestingShipped
141 }
142 WGSLLanguageFeatureName::SizedBindingArray => {
143 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SizedBindingArray
144 }
145 WGSLLanguageFeatureName::TexelBuffers => {
146 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_TexelBuffers
147 }
148 WGSLLanguageFeatureName::ChromiumPrint => {
149 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ChromiumPrint
150 }
151 WGSLLanguageFeatureName::FragmentDepth => {
152 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_FragmentDepth
153 }
154 WGSLLanguageFeatureName::ImmediateAddressSpace => {
155 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_ImmediateAddressSpace
156 }
157 WGSLLanguageFeatureName::SubgroupUniformity => {
158 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SubgroupUniformity
159 }
160 WGSLLanguageFeatureName::BufferView => {
161 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_BufferView
162 }
163 WGSLLanguageFeatureName::FilteringParameters => {
164 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_FilteringParameters
165 }
166 WGSLLanguageFeatureName::SwizzleAssignment => {
167 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_SwizzleAssignment
168 }
169 WGSLLanguageFeatureName::LinearIndexing => {
170 ffi::WGPUWGSLLanguageFeatureName_WGPUWGSLLanguageFeatureName_LinearIndexing
171 }
172 }
173 }
174 }
175 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
176 pub enum AdapterType {
177 DiscreteGpu,
178 IntegratedGpu,
179 Cpu,
180 Unknown,
181 }
182 impl From<ffi::WGPUAdapterType> for AdapterType {
183 fn from(value: ffi::WGPUAdapterType) -> Self {
184 match value {
185 ffi::WGPUAdapterType_WGPUAdapterType_DiscreteGPU => {
186 AdapterType::DiscreteGpu
187 }
188 ffi::WGPUAdapterType_WGPUAdapterType_IntegratedGPU => {
189 AdapterType::IntegratedGpu
190 }
191 ffi::WGPUAdapterType_WGPUAdapterType_CPU => AdapterType::Cpu,
192 ffi::WGPUAdapterType_WGPUAdapterType_Unknown => AdapterType::Unknown,
193 _ => AdapterType::DiscreteGpu,
194 }
195 }
196 }
197 impl From<AdapterType> for ffi::WGPUAdapterType {
198 fn from(value: AdapterType) -> Self {
199 match value {
200 AdapterType::DiscreteGpu => {
201 ffi::WGPUAdapterType_WGPUAdapterType_DiscreteGPU
202 }
203 AdapterType::IntegratedGpu => {
204 ffi::WGPUAdapterType_WGPUAdapterType_IntegratedGPU
205 }
206 AdapterType::Cpu => ffi::WGPUAdapterType_WGPUAdapterType_CPU,
207 AdapterType::Unknown => ffi::WGPUAdapterType_WGPUAdapterType_Unknown,
208 }
209 }
210 }
211 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
212 pub enum AddressMode {
213 Undefined,
214 ClampToEdge,
215 Repeat,
216 MirrorRepeat,
217 }
218 impl From<ffi::WGPUAddressMode> for AddressMode {
219 fn from(value: ffi::WGPUAddressMode) -> Self {
220 match value {
221 ffi::WGPUAddressMode_WGPUAddressMode_Undefined => AddressMode::Undefined,
222 ffi::WGPUAddressMode_WGPUAddressMode_ClampToEdge => {
223 AddressMode::ClampToEdge
224 }
225 ffi::WGPUAddressMode_WGPUAddressMode_Repeat => AddressMode::Repeat,
226 ffi::WGPUAddressMode_WGPUAddressMode_MirrorRepeat => {
227 AddressMode::MirrorRepeat
228 }
229 _ => AddressMode::Undefined,
230 }
231 }
232 }
233 impl From<AddressMode> for ffi::WGPUAddressMode {
234 fn from(value: AddressMode) -> Self {
235 match value {
236 AddressMode::Undefined => ffi::WGPUAddressMode_WGPUAddressMode_Undefined,
237 AddressMode::ClampToEdge => {
238 ffi::WGPUAddressMode_WGPUAddressMode_ClampToEdge
239 }
240 AddressMode::Repeat => ffi::WGPUAddressMode_WGPUAddressMode_Repeat,
241 AddressMode::MirrorRepeat => {
242 ffi::WGPUAddressMode_WGPUAddressMode_MirrorRepeat
243 }
244 }
245 }
246 }
247 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
248 pub enum AlphaMode {
249 Opaque,
250 Premultiplied,
251 Unpremultiplied,
252 }
253 impl From<ffi::WGPUAlphaMode> for AlphaMode {
254 fn from(value: ffi::WGPUAlphaMode) -> Self {
255 match value {
256 ffi::WGPUAlphaMode_WGPUAlphaMode_Opaque => AlphaMode::Opaque,
257 ffi::WGPUAlphaMode_WGPUAlphaMode_Premultiplied => {
258 AlphaMode::Premultiplied
259 }
260 ffi::WGPUAlphaMode_WGPUAlphaMode_Unpremultiplied => {
261 AlphaMode::Unpremultiplied
262 }
263 _ => AlphaMode::Opaque,
264 }
265 }
266 }
267 impl From<AlphaMode> for ffi::WGPUAlphaMode {
268 fn from(value: AlphaMode) -> Self {
269 match value {
270 AlphaMode::Opaque => ffi::WGPUAlphaMode_WGPUAlphaMode_Opaque,
271 AlphaMode::Premultiplied => {
272 ffi::WGPUAlphaMode_WGPUAlphaMode_Premultiplied
273 }
274 AlphaMode::Unpremultiplied => {
275 ffi::WGPUAlphaMode_WGPUAlphaMode_Unpremultiplied
276 }
277 }
278 }
279 }
280 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
281 pub enum BackendType {
282 Undefined,
283 Null,
284 WebGPU,
285 D3D11,
286 D3D12,
287 Metal,
288 Vulkan,
289 OpenGL,
290 OpenGLes,
291 }
292 impl From<ffi::WGPUBackendType> for BackendType {
293 fn from(value: ffi::WGPUBackendType) -> Self {
294 match value {
295 ffi::WGPUBackendType_WGPUBackendType_Undefined => BackendType::Undefined,
296 ffi::WGPUBackendType_WGPUBackendType_Null => BackendType::Null,
297 ffi::WGPUBackendType_WGPUBackendType_WebGPU => BackendType::WebGPU,
298 ffi::WGPUBackendType_WGPUBackendType_D3D11 => BackendType::D3D11,
299 ffi::WGPUBackendType_WGPUBackendType_D3D12 => BackendType::D3D12,
300 ffi::WGPUBackendType_WGPUBackendType_Metal => BackendType::Metal,
301 ffi::WGPUBackendType_WGPUBackendType_Vulkan => BackendType::Vulkan,
302 ffi::WGPUBackendType_WGPUBackendType_OpenGL => BackendType::OpenGL,
303 ffi::WGPUBackendType_WGPUBackendType_OpenGLES => BackendType::OpenGLes,
304 _ => BackendType::Undefined,
305 }
306 }
307 }
308 impl From<BackendType> for ffi::WGPUBackendType {
309 fn from(value: BackendType) -> Self {
310 match value {
311 BackendType::Undefined => ffi::WGPUBackendType_WGPUBackendType_Undefined,
312 BackendType::Null => ffi::WGPUBackendType_WGPUBackendType_Null,
313 BackendType::WebGPU => ffi::WGPUBackendType_WGPUBackendType_WebGPU,
314 BackendType::D3D11 => ffi::WGPUBackendType_WGPUBackendType_D3D11,
315 BackendType::D3D12 => ffi::WGPUBackendType_WGPUBackendType_D3D12,
316 BackendType::Metal => ffi::WGPUBackendType_WGPUBackendType_Metal,
317 BackendType::Vulkan => ffi::WGPUBackendType_WGPUBackendType_Vulkan,
318 BackendType::OpenGL => ffi::WGPUBackendType_WGPUBackendType_OpenGL,
319 BackendType::OpenGLes => ffi::WGPUBackendType_WGPUBackendType_OpenGLES,
320 }
321 }
322 }
323 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
324 pub enum BlendFactor {
325 Undefined,
326 Zero,
327 One,
328 Src,
329 OneMinusSrc,
330 SrcAlpha,
331 OneMinusSrcAlpha,
332 Dst,
333 OneMinusDst,
334 DstAlpha,
335 OneMinusDstAlpha,
336 SrcAlphaSaturated,
337 Constant,
338 OneMinusConstant,
339 Src1,
340 OneMinusSrc1,
341 Src1Alpha,
342 OneMinusSrc1Alpha,
343 }
344 impl From<ffi::WGPUBlendFactor> for BlendFactor {
345 fn from(value: ffi::WGPUBlendFactor) -> Self {
346 match value {
347 ffi::WGPUBlendFactor_WGPUBlendFactor_Undefined => BlendFactor::Undefined,
348 ffi::WGPUBlendFactor_WGPUBlendFactor_Zero => BlendFactor::Zero,
349 ffi::WGPUBlendFactor_WGPUBlendFactor_One => BlendFactor::One,
350 ffi::WGPUBlendFactor_WGPUBlendFactor_Src => BlendFactor::Src,
351 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc => {
352 BlendFactor::OneMinusSrc
353 }
354 ffi::WGPUBlendFactor_WGPUBlendFactor_SrcAlpha => BlendFactor::SrcAlpha,
355 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrcAlpha => {
356 BlendFactor::OneMinusSrcAlpha
357 }
358 ffi::WGPUBlendFactor_WGPUBlendFactor_Dst => BlendFactor::Dst,
359 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusDst => {
360 BlendFactor::OneMinusDst
361 }
362 ffi::WGPUBlendFactor_WGPUBlendFactor_DstAlpha => BlendFactor::DstAlpha,
363 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusDstAlpha => {
364 BlendFactor::OneMinusDstAlpha
365 }
366 ffi::WGPUBlendFactor_WGPUBlendFactor_SrcAlphaSaturated => {
367 BlendFactor::SrcAlphaSaturated
368 }
369 ffi::WGPUBlendFactor_WGPUBlendFactor_Constant => BlendFactor::Constant,
370 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusConstant => {
371 BlendFactor::OneMinusConstant
372 }
373 ffi::WGPUBlendFactor_WGPUBlendFactor_Src1 => BlendFactor::Src1,
374 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc1 => {
375 BlendFactor::OneMinusSrc1
376 }
377 ffi::WGPUBlendFactor_WGPUBlendFactor_Src1Alpha => BlendFactor::Src1Alpha,
378 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc1Alpha => {
379 BlendFactor::OneMinusSrc1Alpha
380 }
381 _ => BlendFactor::Undefined,
382 }
383 }
384 }
385 impl From<BlendFactor> for ffi::WGPUBlendFactor {
386 fn from(value: BlendFactor) -> Self {
387 match value {
388 BlendFactor::Undefined => ffi::WGPUBlendFactor_WGPUBlendFactor_Undefined,
389 BlendFactor::Zero => ffi::WGPUBlendFactor_WGPUBlendFactor_Zero,
390 BlendFactor::One => ffi::WGPUBlendFactor_WGPUBlendFactor_One,
391 BlendFactor::Src => ffi::WGPUBlendFactor_WGPUBlendFactor_Src,
392 BlendFactor::OneMinusSrc => {
393 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc
394 }
395 BlendFactor::SrcAlpha => ffi::WGPUBlendFactor_WGPUBlendFactor_SrcAlpha,
396 BlendFactor::OneMinusSrcAlpha => {
397 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrcAlpha
398 }
399 BlendFactor::Dst => ffi::WGPUBlendFactor_WGPUBlendFactor_Dst,
400 BlendFactor::OneMinusDst => {
401 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusDst
402 }
403 BlendFactor::DstAlpha => ffi::WGPUBlendFactor_WGPUBlendFactor_DstAlpha,
404 BlendFactor::OneMinusDstAlpha => {
405 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusDstAlpha
406 }
407 BlendFactor::SrcAlphaSaturated => {
408 ffi::WGPUBlendFactor_WGPUBlendFactor_SrcAlphaSaturated
409 }
410 BlendFactor::Constant => ffi::WGPUBlendFactor_WGPUBlendFactor_Constant,
411 BlendFactor::OneMinusConstant => {
412 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusConstant
413 }
414 BlendFactor::Src1 => ffi::WGPUBlendFactor_WGPUBlendFactor_Src1,
415 BlendFactor::OneMinusSrc1 => {
416 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc1
417 }
418 BlendFactor::Src1Alpha => ffi::WGPUBlendFactor_WGPUBlendFactor_Src1Alpha,
419 BlendFactor::OneMinusSrc1Alpha => {
420 ffi::WGPUBlendFactor_WGPUBlendFactor_OneMinusSrc1Alpha
421 }
422 }
423 }
424 }
425 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
426 pub enum BlendOperation {
427 Undefined,
428 Add,
429 Subtract,
430 ReverseSubtract,
431 Min,
432 Max,
433 }
434 impl From<ffi::WGPUBlendOperation> for BlendOperation {
435 fn from(value: ffi::WGPUBlendOperation) -> Self {
436 match value {
437 ffi::WGPUBlendOperation_WGPUBlendOperation_Undefined => {
438 BlendOperation::Undefined
439 }
440 ffi::WGPUBlendOperation_WGPUBlendOperation_Add => BlendOperation::Add,
441 ffi::WGPUBlendOperation_WGPUBlendOperation_Subtract => {
442 BlendOperation::Subtract
443 }
444 ffi::WGPUBlendOperation_WGPUBlendOperation_ReverseSubtract => {
445 BlendOperation::ReverseSubtract
446 }
447 ffi::WGPUBlendOperation_WGPUBlendOperation_Min => BlendOperation::Min,
448 ffi::WGPUBlendOperation_WGPUBlendOperation_Max => BlendOperation::Max,
449 _ => BlendOperation::Undefined,
450 }
451 }
452 }
453 impl From<BlendOperation> for ffi::WGPUBlendOperation {
454 fn from(value: BlendOperation) -> Self {
455 match value {
456 BlendOperation::Undefined => {
457 ffi::WGPUBlendOperation_WGPUBlendOperation_Undefined
458 }
459 BlendOperation::Add => ffi::WGPUBlendOperation_WGPUBlendOperation_Add,
460 BlendOperation::Subtract => {
461 ffi::WGPUBlendOperation_WGPUBlendOperation_Subtract
462 }
463 BlendOperation::ReverseSubtract => {
464 ffi::WGPUBlendOperation_WGPUBlendOperation_ReverseSubtract
465 }
466 BlendOperation::Min => ffi::WGPUBlendOperation_WGPUBlendOperation_Min,
467 BlendOperation::Max => ffi::WGPUBlendOperation_WGPUBlendOperation_Max,
468 }
469 }
470 }
471 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
472 pub enum BufferBindingType {
473 BindingNotUsed,
474 Undefined,
475 Uniform,
476 Storage,
477 ReadOnlyStorage,
478 }
479 impl From<ffi::WGPUBufferBindingType> for BufferBindingType {
480 fn from(value: ffi::WGPUBufferBindingType) -> Self {
481 match value {
482 ffi::WGPUBufferBindingType_WGPUBufferBindingType_BindingNotUsed => {
483 BufferBindingType::BindingNotUsed
484 }
485 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Undefined => {
486 BufferBindingType::Undefined
487 }
488 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Uniform => {
489 BufferBindingType::Uniform
490 }
491 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Storage => {
492 BufferBindingType::Storage
493 }
494 ffi::WGPUBufferBindingType_WGPUBufferBindingType_ReadOnlyStorage => {
495 BufferBindingType::ReadOnlyStorage
496 }
497 _ => BufferBindingType::BindingNotUsed,
498 }
499 }
500 }
501 impl From<BufferBindingType> for ffi::WGPUBufferBindingType {
502 fn from(value: BufferBindingType) -> Self {
503 match value {
504 BufferBindingType::BindingNotUsed => {
505 ffi::WGPUBufferBindingType_WGPUBufferBindingType_BindingNotUsed
506 }
507 BufferBindingType::Undefined => {
508 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Undefined
509 }
510 BufferBindingType::Uniform => {
511 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Uniform
512 }
513 BufferBindingType::Storage => {
514 ffi::WGPUBufferBindingType_WGPUBufferBindingType_Storage
515 }
516 BufferBindingType::ReadOnlyStorage => {
517 ffi::WGPUBufferBindingType_WGPUBufferBindingType_ReadOnlyStorage
518 }
519 }
520 }
521 }
522 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
523 pub enum BufferMapState {
524 Unmapped,
525 Pending,
526 Mapped,
527 }
528 impl From<ffi::WGPUBufferMapState> for BufferMapState {
529 fn from(value: ffi::WGPUBufferMapState) -> Self {
530 match value {
531 ffi::WGPUBufferMapState_WGPUBufferMapState_Unmapped => {
532 BufferMapState::Unmapped
533 }
534 ffi::WGPUBufferMapState_WGPUBufferMapState_Pending => {
535 BufferMapState::Pending
536 }
537 ffi::WGPUBufferMapState_WGPUBufferMapState_Mapped => {
538 BufferMapState::Mapped
539 }
540 _ => BufferMapState::Unmapped,
541 }
542 }
543 }
544 impl From<BufferMapState> for ffi::WGPUBufferMapState {
545 fn from(value: BufferMapState) -> Self {
546 match value {
547 BufferMapState::Unmapped => {
548 ffi::WGPUBufferMapState_WGPUBufferMapState_Unmapped
549 }
550 BufferMapState::Pending => {
551 ffi::WGPUBufferMapState_WGPUBufferMapState_Pending
552 }
553 BufferMapState::Mapped => {
554 ffi::WGPUBufferMapState_WGPUBufferMapState_Mapped
555 }
556 }
557 }
558 }
559 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
560 pub enum CallbackMode {
561 WaitAnyOnly,
562 AllowProcessEvents,
563 AllowSpontaneous,
564 }
565 impl From<ffi::WGPUCallbackMode> for CallbackMode {
566 fn from(value: ffi::WGPUCallbackMode) -> Self {
567 match value {
568 ffi::WGPUCallbackMode_WGPUCallbackMode_WaitAnyOnly => {
569 CallbackMode::WaitAnyOnly
570 }
571 ffi::WGPUCallbackMode_WGPUCallbackMode_AllowProcessEvents => {
572 CallbackMode::AllowProcessEvents
573 }
574 ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous => {
575 CallbackMode::AllowSpontaneous
576 }
577 _ => CallbackMode::WaitAnyOnly,
578 }
579 }
580 }
581 impl From<CallbackMode> for ffi::WGPUCallbackMode {
582 fn from(value: CallbackMode) -> Self {
583 match value {
584 CallbackMode::WaitAnyOnly => {
585 ffi::WGPUCallbackMode_WGPUCallbackMode_WaitAnyOnly
586 }
587 CallbackMode::AllowProcessEvents => {
588 ffi::WGPUCallbackMode_WGPUCallbackMode_AllowProcessEvents
589 }
590 CallbackMode::AllowSpontaneous => {
591 ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous
592 }
593 }
594 }
595 }
596 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
597 pub enum CompareFunction {
598 Undefined,
599 Never,
600 Less,
601 Equal,
602 LessEqual,
603 Greater,
604 NotEqual,
605 GreaterEqual,
606 Always,
607 }
608 impl From<ffi::WGPUCompareFunction> for CompareFunction {
609 fn from(value: ffi::WGPUCompareFunction) -> Self {
610 match value {
611 ffi::WGPUCompareFunction_WGPUCompareFunction_Undefined => {
612 CompareFunction::Undefined
613 }
614 ffi::WGPUCompareFunction_WGPUCompareFunction_Never => {
615 CompareFunction::Never
616 }
617 ffi::WGPUCompareFunction_WGPUCompareFunction_Less => {
618 CompareFunction::Less
619 }
620 ffi::WGPUCompareFunction_WGPUCompareFunction_Equal => {
621 CompareFunction::Equal
622 }
623 ffi::WGPUCompareFunction_WGPUCompareFunction_LessEqual => {
624 CompareFunction::LessEqual
625 }
626 ffi::WGPUCompareFunction_WGPUCompareFunction_Greater => {
627 CompareFunction::Greater
628 }
629 ffi::WGPUCompareFunction_WGPUCompareFunction_NotEqual => {
630 CompareFunction::NotEqual
631 }
632 ffi::WGPUCompareFunction_WGPUCompareFunction_GreaterEqual => {
633 CompareFunction::GreaterEqual
634 }
635 ffi::WGPUCompareFunction_WGPUCompareFunction_Always => {
636 CompareFunction::Always
637 }
638 _ => CompareFunction::Undefined,
639 }
640 }
641 }
642 impl From<CompareFunction> for ffi::WGPUCompareFunction {
643 fn from(value: CompareFunction) -> Self {
644 match value {
645 CompareFunction::Undefined => {
646 ffi::WGPUCompareFunction_WGPUCompareFunction_Undefined
647 }
648 CompareFunction::Never => {
649 ffi::WGPUCompareFunction_WGPUCompareFunction_Never
650 }
651 CompareFunction::Less => {
652 ffi::WGPUCompareFunction_WGPUCompareFunction_Less
653 }
654 CompareFunction::Equal => {
655 ffi::WGPUCompareFunction_WGPUCompareFunction_Equal
656 }
657 CompareFunction::LessEqual => {
658 ffi::WGPUCompareFunction_WGPUCompareFunction_LessEqual
659 }
660 CompareFunction::Greater => {
661 ffi::WGPUCompareFunction_WGPUCompareFunction_Greater
662 }
663 CompareFunction::NotEqual => {
664 ffi::WGPUCompareFunction_WGPUCompareFunction_NotEqual
665 }
666 CompareFunction::GreaterEqual => {
667 ffi::WGPUCompareFunction_WGPUCompareFunction_GreaterEqual
668 }
669 CompareFunction::Always => {
670 ffi::WGPUCompareFunction_WGPUCompareFunction_Always
671 }
672 }
673 }
674 }
675 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
676 pub enum CompilationInfoRequestStatus {
677 Success,
678 CallbackCancelled,
679 }
680 impl From<ffi::WGPUCompilationInfoRequestStatus> for CompilationInfoRequestStatus {
681 fn from(value: ffi::WGPUCompilationInfoRequestStatus) -> Self {
682 match value {
683 ffi::WGPUCompilationInfoRequestStatus_WGPUCompilationInfoRequestStatus_Success => {
684 CompilationInfoRequestStatus::Success
685 }
686 ffi::WGPUCompilationInfoRequestStatus_WGPUCompilationInfoRequestStatus_CallbackCancelled => {
687 CompilationInfoRequestStatus::CallbackCancelled
688 }
689 _ => CompilationInfoRequestStatus::Success,
690 }
691 }
692 }
693 impl From<CompilationInfoRequestStatus> for ffi::WGPUCompilationInfoRequestStatus {
694 fn from(value: CompilationInfoRequestStatus) -> Self {
695 match value {
696 CompilationInfoRequestStatus::Success => {
697 ffi::WGPUCompilationInfoRequestStatus_WGPUCompilationInfoRequestStatus_Success
698 }
699 CompilationInfoRequestStatus::CallbackCancelled => {
700 ffi::WGPUCompilationInfoRequestStatus_WGPUCompilationInfoRequestStatus_CallbackCancelled
701 }
702 }
703 }
704 }
705 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
706 pub enum CompilationMessageType {
707 Error,
708 Warning,
709 Info,
710 }
711 impl From<ffi::WGPUCompilationMessageType> for CompilationMessageType {
712 fn from(value: ffi::WGPUCompilationMessageType) -> Self {
713 match value {
714 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Error => {
715 CompilationMessageType::Error
716 }
717 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Warning => {
718 CompilationMessageType::Warning
719 }
720 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Info => {
721 CompilationMessageType::Info
722 }
723 _ => CompilationMessageType::Error,
724 }
725 }
726 }
727 impl From<CompilationMessageType> for ffi::WGPUCompilationMessageType {
728 fn from(value: CompilationMessageType) -> Self {
729 match value {
730 CompilationMessageType::Error => {
731 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Error
732 }
733 CompilationMessageType::Warning => {
734 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Warning
735 }
736 CompilationMessageType::Info => {
737 ffi::WGPUCompilationMessageType_WGPUCompilationMessageType_Info
738 }
739 }
740 }
741 }
742 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
743 pub enum ComponentSwizzle {
744 Undefined,
745 Zero,
746 One,
747 R,
748 G,
749 B,
750 A,
751 }
752 impl From<ffi::WGPUComponentSwizzle> for ComponentSwizzle {
753 fn from(value: ffi::WGPUComponentSwizzle) -> Self {
754 match value {
755 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_Undefined => {
756 ComponentSwizzle::Undefined
757 }
758 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_Zero => {
759 ComponentSwizzle::Zero
760 }
761 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_One => {
762 ComponentSwizzle::One
763 }
764 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_R => ComponentSwizzle::R,
765 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_G => ComponentSwizzle::G,
766 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_B => ComponentSwizzle::B,
767 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_A => ComponentSwizzle::A,
768 _ => ComponentSwizzle::Undefined,
769 }
770 }
771 }
772 impl From<ComponentSwizzle> for ffi::WGPUComponentSwizzle {
773 fn from(value: ComponentSwizzle) -> Self {
774 match value {
775 ComponentSwizzle::Undefined => {
776 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_Undefined
777 }
778 ComponentSwizzle::Zero => {
779 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_Zero
780 }
781 ComponentSwizzle::One => {
782 ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_One
783 }
784 ComponentSwizzle::R => ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_R,
785 ComponentSwizzle::G => ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_G,
786 ComponentSwizzle::B => ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_B,
787 ComponentSwizzle::A => ffi::WGPUComponentSwizzle_WGPUComponentSwizzle_A,
788 }
789 }
790 }
791 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
792 pub enum CompositeAlphaMode {
793 Auto,
794 Opaque,
795 Premultiplied,
796 Unpremultiplied,
797 Inherit,
798 }
799 impl From<ffi::WGPUCompositeAlphaMode> for CompositeAlphaMode {
800 fn from(value: ffi::WGPUCompositeAlphaMode) -> Self {
801 match value {
802 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Auto => {
803 CompositeAlphaMode::Auto
804 }
805 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Opaque => {
806 CompositeAlphaMode::Opaque
807 }
808 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Premultiplied => {
809 CompositeAlphaMode::Premultiplied
810 }
811 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Unpremultiplied => {
812 CompositeAlphaMode::Unpremultiplied
813 }
814 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Inherit => {
815 CompositeAlphaMode::Inherit
816 }
817 _ => CompositeAlphaMode::Auto,
818 }
819 }
820 }
821 impl From<CompositeAlphaMode> for ffi::WGPUCompositeAlphaMode {
822 fn from(value: CompositeAlphaMode) -> Self {
823 match value {
824 CompositeAlphaMode::Auto => {
825 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Auto
826 }
827 CompositeAlphaMode::Opaque => {
828 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Opaque
829 }
830 CompositeAlphaMode::Premultiplied => {
831 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Premultiplied
832 }
833 CompositeAlphaMode::Unpremultiplied => {
834 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Unpremultiplied
835 }
836 CompositeAlphaMode::Inherit => {
837 ffi::WGPUCompositeAlphaMode_WGPUCompositeAlphaMode_Inherit
838 }
839 }
840 }
841 }
842 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
843 pub enum CreatePipelineAsyncStatus {
844 Success,
845 CallbackCancelled,
846 ValidationError,
847 InternalError,
848 }
849 impl From<ffi::WGPUCreatePipelineAsyncStatus> for CreatePipelineAsyncStatus {
850 fn from(value: ffi::WGPUCreatePipelineAsyncStatus) -> Self {
851 match value {
852 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_Success => {
853 CreatePipelineAsyncStatus::Success
854 }
855 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_CallbackCancelled => {
856 CreatePipelineAsyncStatus::CallbackCancelled
857 }
858 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_ValidationError => {
859 CreatePipelineAsyncStatus::ValidationError
860 }
861 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_InternalError => {
862 CreatePipelineAsyncStatus::InternalError
863 }
864 _ => CreatePipelineAsyncStatus::Success,
865 }
866 }
867 }
868 impl From<CreatePipelineAsyncStatus> for ffi::WGPUCreatePipelineAsyncStatus {
869 fn from(value: CreatePipelineAsyncStatus) -> Self {
870 match value {
871 CreatePipelineAsyncStatus::Success => {
872 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_Success
873 }
874 CreatePipelineAsyncStatus::CallbackCancelled => {
875 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_CallbackCancelled
876 }
877 CreatePipelineAsyncStatus::ValidationError => {
878 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_ValidationError
879 }
880 CreatePipelineAsyncStatus::InternalError => {
881 ffi::WGPUCreatePipelineAsyncStatus_WGPUCreatePipelineAsyncStatus_InternalError
882 }
883 }
884 }
885 }
886 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
887 pub enum CullMode {
888 Undefined,
889 None,
890 Front,
891 Back,
892 }
893 impl From<ffi::WGPUCullMode> for CullMode {
894 fn from(value: ffi::WGPUCullMode) -> Self {
895 match value {
896 ffi::WGPUCullMode_WGPUCullMode_Undefined => CullMode::Undefined,
897 ffi::WGPUCullMode_WGPUCullMode_None => CullMode::None,
898 ffi::WGPUCullMode_WGPUCullMode_Front => CullMode::Front,
899 ffi::WGPUCullMode_WGPUCullMode_Back => CullMode::Back,
900 _ => CullMode::Undefined,
901 }
902 }
903 }
904 impl From<CullMode> for ffi::WGPUCullMode {
905 fn from(value: CullMode) -> Self {
906 match value {
907 CullMode::Undefined => ffi::WGPUCullMode_WGPUCullMode_Undefined,
908 CullMode::None => ffi::WGPUCullMode_WGPUCullMode_None,
909 CullMode::Front => ffi::WGPUCullMode_WGPUCullMode_Front,
910 CullMode::Back => ffi::WGPUCullMode_WGPUCullMode_Back,
911 }
912 }
913 }
914 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
915 pub enum DeviceLostReason {
916 Unknown,
917 Destroyed,
918 CallbackCancelled,
919 FailedCreation,
920 }
921 impl From<ffi::WGPUDeviceLostReason> for DeviceLostReason {
922 fn from(value: ffi::WGPUDeviceLostReason) -> Self {
923 match value {
924 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_Unknown => {
925 DeviceLostReason::Unknown
926 }
927 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_Destroyed => {
928 DeviceLostReason::Destroyed
929 }
930 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_CallbackCancelled => {
931 DeviceLostReason::CallbackCancelled
932 }
933 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_FailedCreation => {
934 DeviceLostReason::FailedCreation
935 }
936 _ => DeviceLostReason::Unknown,
937 }
938 }
939 }
940 impl From<DeviceLostReason> for ffi::WGPUDeviceLostReason {
941 fn from(value: DeviceLostReason) -> Self {
942 match value {
943 DeviceLostReason::Unknown => {
944 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_Unknown
945 }
946 DeviceLostReason::Destroyed => {
947 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_Destroyed
948 }
949 DeviceLostReason::CallbackCancelled => {
950 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_CallbackCancelled
951 }
952 DeviceLostReason::FailedCreation => {
953 ffi::WGPUDeviceLostReason_WGPUDeviceLostReason_FailedCreation
954 }
955 }
956 }
957 }
958 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
959 pub enum ErrorFilter {
960 Validation,
961 OutOfMemory,
962 Internal,
963 }
964 impl From<ffi::WGPUErrorFilter> for ErrorFilter {
965 fn from(value: ffi::WGPUErrorFilter) -> Self {
966 match value {
967 ffi::WGPUErrorFilter_WGPUErrorFilter_Validation => {
968 ErrorFilter::Validation
969 }
970 ffi::WGPUErrorFilter_WGPUErrorFilter_OutOfMemory => {
971 ErrorFilter::OutOfMemory
972 }
973 ffi::WGPUErrorFilter_WGPUErrorFilter_Internal => ErrorFilter::Internal,
974 _ => ErrorFilter::Validation,
975 }
976 }
977 }
978 impl From<ErrorFilter> for ffi::WGPUErrorFilter {
979 fn from(value: ErrorFilter) -> Self {
980 match value {
981 ErrorFilter::Validation => {
982 ffi::WGPUErrorFilter_WGPUErrorFilter_Validation
983 }
984 ErrorFilter::OutOfMemory => {
985 ffi::WGPUErrorFilter_WGPUErrorFilter_OutOfMemory
986 }
987 ErrorFilter::Internal => ffi::WGPUErrorFilter_WGPUErrorFilter_Internal,
988 }
989 }
990 }
991 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
992 pub enum ErrorType {
993 NoError,
994 Validation,
995 OutOfMemory,
996 Internal,
997 Unknown,
998 }
999 impl From<ffi::WGPUErrorType> for ErrorType {
1000 fn from(value: ffi::WGPUErrorType) -> Self {
1001 match value {
1002 ffi::WGPUErrorType_WGPUErrorType_NoError => ErrorType::NoError,
1003 ffi::WGPUErrorType_WGPUErrorType_Validation => ErrorType::Validation,
1004 ffi::WGPUErrorType_WGPUErrorType_OutOfMemory => ErrorType::OutOfMemory,
1005 ffi::WGPUErrorType_WGPUErrorType_Internal => ErrorType::Internal,
1006 ffi::WGPUErrorType_WGPUErrorType_Unknown => ErrorType::Unknown,
1007 _ => ErrorType::NoError,
1008 }
1009 }
1010 }
1011 impl From<ErrorType> for ffi::WGPUErrorType {
1012 fn from(value: ErrorType) -> Self {
1013 match value {
1014 ErrorType::NoError => ffi::WGPUErrorType_WGPUErrorType_NoError,
1015 ErrorType::Validation => ffi::WGPUErrorType_WGPUErrorType_Validation,
1016 ErrorType::OutOfMemory => ffi::WGPUErrorType_WGPUErrorType_OutOfMemory,
1017 ErrorType::Internal => ffi::WGPUErrorType_WGPUErrorType_Internal,
1018 ErrorType::Unknown => ffi::WGPUErrorType_WGPUErrorType_Unknown,
1019 }
1020 }
1021 }
1022 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1023 pub enum ExternalTextureRotation {
1024 Rotate0Degrees,
1025 Rotate90Degrees,
1026 Rotate180Degrees,
1027 Rotate270Degrees,
1028 }
1029 impl From<ffi::WGPUExternalTextureRotation> for ExternalTextureRotation {
1030 fn from(value: ffi::WGPUExternalTextureRotation) -> Self {
1031 match value {
1032 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate0Degrees => {
1033 ExternalTextureRotation::Rotate0Degrees
1034 }
1035 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate90Degrees => {
1036 ExternalTextureRotation::Rotate90Degrees
1037 }
1038 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate180Degrees => {
1039 ExternalTextureRotation::Rotate180Degrees
1040 }
1041 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate270Degrees => {
1042 ExternalTextureRotation::Rotate270Degrees
1043 }
1044 _ => ExternalTextureRotation::Rotate0Degrees,
1045 }
1046 }
1047 }
1048 impl From<ExternalTextureRotation> for ffi::WGPUExternalTextureRotation {
1049 fn from(value: ExternalTextureRotation) -> Self {
1050 match value {
1051 ExternalTextureRotation::Rotate0Degrees => {
1052 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate0Degrees
1053 }
1054 ExternalTextureRotation::Rotate90Degrees => {
1055 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate90Degrees
1056 }
1057 ExternalTextureRotation::Rotate180Degrees => {
1058 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate180Degrees
1059 }
1060 ExternalTextureRotation::Rotate270Degrees => {
1061 ffi::WGPUExternalTextureRotation_WGPUExternalTextureRotation_Rotate270Degrees
1062 }
1063 }
1064 }
1065 }
1066 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1067 pub enum FeatureLevel {
1068 Undefined,
1069 Compatibility,
1070 Core,
1071 }
1072 impl From<ffi::WGPUFeatureLevel> for FeatureLevel {
1073 fn from(value: ffi::WGPUFeatureLevel) -> Self {
1074 match value {
1075 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Undefined => {
1076 FeatureLevel::Undefined
1077 }
1078 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Compatibility => {
1079 FeatureLevel::Compatibility
1080 }
1081 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Core => FeatureLevel::Core,
1082 _ => FeatureLevel::Undefined,
1083 }
1084 }
1085 }
1086 impl From<FeatureLevel> for ffi::WGPUFeatureLevel {
1087 fn from(value: FeatureLevel) -> Self {
1088 match value {
1089 FeatureLevel::Undefined => {
1090 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Undefined
1091 }
1092 FeatureLevel::Compatibility => {
1093 ffi::WGPUFeatureLevel_WGPUFeatureLevel_Compatibility
1094 }
1095 FeatureLevel::Core => ffi::WGPUFeatureLevel_WGPUFeatureLevel_Core,
1096 }
1097 }
1098 }
1099 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1100 pub enum FeatureName {
1101 CoreFeaturesAndLimits,
1102 DepthClipControl,
1103 Depth32FloatStencil8,
1104 TextureCompressionBc,
1105 TextureCompressionBcSliced3D,
1106 TextureCompressionEtc2,
1107 TextureCompressionAstc,
1108 TextureCompressionAstcSliced3D,
1109 TimestampQuery,
1110 IndirectFirstInstance,
1111 ShaderF16,
1112 Rg11B10UfloatRenderable,
1113 Bgra8UnormStorage,
1114 Float32Filterable,
1115 Float32Blendable,
1116 ClipDistances,
1117 DualSourceBlending,
1118 Subgroups,
1119 TextureFormatsTier1,
1120 TextureFormatsTier2,
1121 PrimitiveIndex,
1122 TextureComponentSwizzle,
1123 DawnInternalUsages,
1124 DawnMultiPlanarFormats,
1125 DawnNative,
1126 ChromiumExperimentalTimestampQueryInsidePasses,
1127 ImplicitDeviceSynchronization,
1128 TransientAttachments,
1129 MsaaRenderToSingleSampled,
1130 D3D11MultithreadProtected,
1131 AngleTextureSharing,
1132 PixelLocalStorageCoherent,
1133 PixelLocalStorageNonCoherent,
1134 Unorm16TextureFormats,
1135 MultiPlanarFormatExtendedUsages,
1136 MultiPlanarFormatP010,
1137 HostMappedPointer,
1138 MultiPlanarRenderTargets,
1139 MultiPlanarFormatNv12A,
1140 FramebufferFetch,
1141 BufferMapExtendedUsages,
1142 AdapterPropertiesMemoryHeaps,
1143 AdapterPropertiesD3D,
1144 AdapterPropertiesVk,
1145 DawnFormatCapabilities,
1146 DawnDrmFormatCapabilities,
1147 MultiPlanarFormatNv16,
1148 MultiPlanarFormatNv24,
1149 MultiPlanarFormatP210,
1150 MultiPlanarFormatP410,
1151 SharedTextureMemoryVkDedicatedAllocation,
1152 SharedTextureMemoryAHardwareBuffer,
1153 SharedTextureMemoryDmaBuf,
1154 SharedTextureMemoryOpaqueFD,
1155 SharedTextureMemoryZirconHandle,
1156 SharedTextureMemoryDXGISharedHandle,
1157 SharedTextureMemoryD3D11Texture2D,
1158 SharedTextureMemoryIOSurface,
1159 SharedTextureMemoryEGLImage,
1160 SharedFenceVkSemaphoreOpaqueFD,
1161 SharedFenceSyncFD,
1162 SharedFenceVkSemaphoreZirconHandle,
1163 SharedFenceDXGISharedHandle,
1164 SharedFenceMTLSharedEvent,
1165 SharedBufferMemoryD3D12Resource,
1166 StaticSamplers,
1167 YCbCrVulkanSamplers,
1168 ShaderModuleCompilationOptions,
1169 DawnLoadResolveTexture,
1170 DawnPartialLoadResolveTexture,
1171 MultiDrawIndirect,
1172 DawnTexelCopyBufferRowAlignment,
1173 FlexibleTextureViews,
1174 ChromiumExperimentalSubgroupMatrix,
1175 SharedFenceEGLSync,
1176 DawnDeviceAllocatorControl,
1177 AdapterPropertiesWGPU,
1178 SharedBufferMemoryD3D12SharedMemoryFileMappingHandle,
1179 SharedTextureMemoryD3D12Resource,
1180 ChromiumExperimentalSamplingResourceTable,
1181 ChromiumExperimentalSubgroupSizeControl,
1182 AtomicVec2UMinMax,
1183 }
1184 impl From<ffi::WGPUFeatureName> for FeatureName {
1185 fn from(value: ffi::WGPUFeatureName) -> Self {
1186 match value {
1187 ffi::WGPUFeatureName_WGPUFeatureName_CoreFeaturesAndLimits => {
1188 FeatureName::CoreFeaturesAndLimits
1189 }
1190 ffi::WGPUFeatureName_WGPUFeatureName_DepthClipControl => {
1191 FeatureName::DepthClipControl
1192 }
1193 ffi::WGPUFeatureName_WGPUFeatureName_Depth32FloatStencil8 => {
1194 FeatureName::Depth32FloatStencil8
1195 }
1196 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBC => {
1197 FeatureName::TextureCompressionBc
1198 }
1199 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBCSliced3D => {
1200 FeatureName::TextureCompressionBcSliced3D
1201 }
1202 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionETC2 => {
1203 FeatureName::TextureCompressionEtc2
1204 }
1205 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTC => {
1206 FeatureName::TextureCompressionAstc
1207 }
1208 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTCSliced3D => {
1209 FeatureName::TextureCompressionAstcSliced3D
1210 }
1211 ffi::WGPUFeatureName_WGPUFeatureName_TimestampQuery => {
1212 FeatureName::TimestampQuery
1213 }
1214 ffi::WGPUFeatureName_WGPUFeatureName_IndirectFirstInstance => {
1215 FeatureName::IndirectFirstInstance
1216 }
1217 ffi::WGPUFeatureName_WGPUFeatureName_ShaderF16 => FeatureName::ShaderF16,
1218 ffi::WGPUFeatureName_WGPUFeatureName_RG11B10UfloatRenderable => {
1219 FeatureName::Rg11B10UfloatRenderable
1220 }
1221 ffi::WGPUFeatureName_WGPUFeatureName_BGRA8UnormStorage => {
1222 FeatureName::Bgra8UnormStorage
1223 }
1224 ffi::WGPUFeatureName_WGPUFeatureName_Float32Filterable => {
1225 FeatureName::Float32Filterable
1226 }
1227 ffi::WGPUFeatureName_WGPUFeatureName_Float32Blendable => {
1228 FeatureName::Float32Blendable
1229 }
1230 ffi::WGPUFeatureName_WGPUFeatureName_ClipDistances => {
1231 FeatureName::ClipDistances
1232 }
1233 ffi::WGPUFeatureName_WGPUFeatureName_DualSourceBlending => {
1234 FeatureName::DualSourceBlending
1235 }
1236 ffi::WGPUFeatureName_WGPUFeatureName_Subgroups => FeatureName::Subgroups,
1237 ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier1 => {
1238 FeatureName::TextureFormatsTier1
1239 }
1240 ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier2 => {
1241 FeatureName::TextureFormatsTier2
1242 }
1243 ffi::WGPUFeatureName_WGPUFeatureName_PrimitiveIndex => {
1244 FeatureName::PrimitiveIndex
1245 }
1246 ffi::WGPUFeatureName_WGPUFeatureName_TextureComponentSwizzle => {
1247 FeatureName::TextureComponentSwizzle
1248 }
1249 ffi::WGPUFeatureName_WGPUFeatureName_DawnInternalUsages => {
1250 FeatureName::DawnInternalUsages
1251 }
1252 ffi::WGPUFeatureName_WGPUFeatureName_DawnMultiPlanarFormats => {
1253 FeatureName::DawnMultiPlanarFormats
1254 }
1255 ffi::WGPUFeatureName_WGPUFeatureName_DawnNative => {
1256 FeatureName::DawnNative
1257 }
1258 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalTimestampQueryInsidePasses => {
1259 FeatureName::ChromiumExperimentalTimestampQueryInsidePasses
1260 }
1261 ffi::WGPUFeatureName_WGPUFeatureName_ImplicitDeviceSynchronization => {
1262 FeatureName::ImplicitDeviceSynchronization
1263 }
1264 ffi::WGPUFeatureName_WGPUFeatureName_TransientAttachments => {
1265 FeatureName::TransientAttachments
1266 }
1267 ffi::WGPUFeatureName_WGPUFeatureName_MSAARenderToSingleSampled => {
1268 FeatureName::MsaaRenderToSingleSampled
1269 }
1270 ffi::WGPUFeatureName_WGPUFeatureName_D3D11MultithreadProtected => {
1271 FeatureName::D3D11MultithreadProtected
1272 }
1273 ffi::WGPUFeatureName_WGPUFeatureName_ANGLETextureSharing => {
1274 FeatureName::AngleTextureSharing
1275 }
1276 ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageCoherent => {
1277 FeatureName::PixelLocalStorageCoherent
1278 }
1279 ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageNonCoherent => {
1280 FeatureName::PixelLocalStorageNonCoherent
1281 }
1282 ffi::WGPUFeatureName_WGPUFeatureName_Unorm16TextureFormats => {
1283 FeatureName::Unorm16TextureFormats
1284 }
1285 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatExtendedUsages => {
1286 FeatureName::MultiPlanarFormatExtendedUsages
1287 }
1288 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP010 => {
1289 FeatureName::MultiPlanarFormatP010
1290 }
1291 ffi::WGPUFeatureName_WGPUFeatureName_HostMappedPointer => {
1292 FeatureName::HostMappedPointer
1293 }
1294 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarRenderTargets => {
1295 FeatureName::MultiPlanarRenderTargets
1296 }
1297 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv12a => {
1298 FeatureName::MultiPlanarFormatNv12A
1299 }
1300 ffi::WGPUFeatureName_WGPUFeatureName_FramebufferFetch => {
1301 FeatureName::FramebufferFetch
1302 }
1303 ffi::WGPUFeatureName_WGPUFeatureName_BufferMapExtendedUsages => {
1304 FeatureName::BufferMapExtendedUsages
1305 }
1306 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesMemoryHeaps => {
1307 FeatureName::AdapterPropertiesMemoryHeaps
1308 }
1309 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesD3D => {
1310 FeatureName::AdapterPropertiesD3D
1311 }
1312 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesVk => {
1313 FeatureName::AdapterPropertiesVk
1314 }
1315 ffi::WGPUFeatureName_WGPUFeatureName_DawnFormatCapabilities => {
1316 FeatureName::DawnFormatCapabilities
1317 }
1318 ffi::WGPUFeatureName_WGPUFeatureName_DawnDrmFormatCapabilities => {
1319 FeatureName::DawnDrmFormatCapabilities
1320 }
1321 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv16 => {
1322 FeatureName::MultiPlanarFormatNv16
1323 }
1324 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv24 => {
1325 FeatureName::MultiPlanarFormatNv24
1326 }
1327 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP210 => {
1328 FeatureName::MultiPlanarFormatP210
1329 }
1330 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP410 => {
1331 FeatureName::MultiPlanarFormatP410
1332 }
1333 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryVkDedicatedAllocation => {
1334 FeatureName::SharedTextureMemoryVkDedicatedAllocation
1335 }
1336 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryAHardwareBuffer => {
1337 FeatureName::SharedTextureMemoryAHardwareBuffer
1338 }
1339 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDmaBuf => {
1340 FeatureName::SharedTextureMemoryDmaBuf
1341 }
1342 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryOpaqueFD => {
1343 FeatureName::SharedTextureMemoryOpaqueFD
1344 }
1345 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryZirconHandle => {
1346 FeatureName::SharedTextureMemoryZirconHandle
1347 }
1348 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDXGISharedHandle => {
1349 FeatureName::SharedTextureMemoryDXGISharedHandle
1350 }
1351 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D11Texture2D => {
1352 FeatureName::SharedTextureMemoryD3D11Texture2D
1353 }
1354 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryIOSurface => {
1355 FeatureName::SharedTextureMemoryIOSurface
1356 }
1357 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryEGLImage => {
1358 FeatureName::SharedTextureMemoryEGLImage
1359 }
1360 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreOpaqueFD => {
1361 FeatureName::SharedFenceVkSemaphoreOpaqueFD
1362 }
1363 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceSyncFD => {
1364 FeatureName::SharedFenceSyncFD
1365 }
1366 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreZirconHandle => {
1367 FeatureName::SharedFenceVkSemaphoreZirconHandle
1368 }
1369 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceDXGISharedHandle => {
1370 FeatureName::SharedFenceDXGISharedHandle
1371 }
1372 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceMTLSharedEvent => {
1373 FeatureName::SharedFenceMTLSharedEvent
1374 }
1375 ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12Resource => {
1376 FeatureName::SharedBufferMemoryD3D12Resource
1377 }
1378 ffi::WGPUFeatureName_WGPUFeatureName_StaticSamplers => {
1379 FeatureName::StaticSamplers
1380 }
1381 ffi::WGPUFeatureName_WGPUFeatureName_YCbCrVulkanSamplers => {
1382 FeatureName::YCbCrVulkanSamplers
1383 }
1384 ffi::WGPUFeatureName_WGPUFeatureName_ShaderModuleCompilationOptions => {
1385 FeatureName::ShaderModuleCompilationOptions
1386 }
1387 ffi::WGPUFeatureName_WGPUFeatureName_DawnLoadResolveTexture => {
1388 FeatureName::DawnLoadResolveTexture
1389 }
1390 ffi::WGPUFeatureName_WGPUFeatureName_DawnPartialLoadResolveTexture => {
1391 FeatureName::DawnPartialLoadResolveTexture
1392 }
1393 ffi::WGPUFeatureName_WGPUFeatureName_MultiDrawIndirect => {
1394 FeatureName::MultiDrawIndirect
1395 }
1396 ffi::WGPUFeatureName_WGPUFeatureName_DawnTexelCopyBufferRowAlignment => {
1397 FeatureName::DawnTexelCopyBufferRowAlignment
1398 }
1399 ffi::WGPUFeatureName_WGPUFeatureName_FlexibleTextureViews => {
1400 FeatureName::FlexibleTextureViews
1401 }
1402 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupMatrix => {
1403 FeatureName::ChromiumExperimentalSubgroupMatrix
1404 }
1405 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceEGLSync => {
1406 FeatureName::SharedFenceEGLSync
1407 }
1408 ffi::WGPUFeatureName_WGPUFeatureName_DawnDeviceAllocatorControl => {
1409 FeatureName::DawnDeviceAllocatorControl
1410 }
1411 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesWGPU => {
1412 FeatureName::AdapterPropertiesWGPU
1413 }
1414 ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12SharedMemoryFileMappingHandle => {
1415 FeatureName::SharedBufferMemoryD3D12SharedMemoryFileMappingHandle
1416 }
1417 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D12Resource => {
1418 FeatureName::SharedTextureMemoryD3D12Resource
1419 }
1420 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSamplingResourceTable => {
1421 FeatureName::ChromiumExperimentalSamplingResourceTable
1422 }
1423 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupSizeControl => {
1424 FeatureName::ChromiumExperimentalSubgroupSizeControl
1425 }
1426 ffi::WGPUFeatureName_WGPUFeatureName_AtomicVec2uMinMax => {
1427 FeatureName::AtomicVec2UMinMax
1428 }
1429 _ => FeatureName::CoreFeaturesAndLimits,
1430 }
1431 }
1432 }
1433 impl From<FeatureName> for ffi::WGPUFeatureName {
1434 fn from(value: FeatureName) -> Self {
1435 match value {
1436 FeatureName::CoreFeaturesAndLimits => {
1437 ffi::WGPUFeatureName_WGPUFeatureName_CoreFeaturesAndLimits
1438 }
1439 FeatureName::DepthClipControl => {
1440 ffi::WGPUFeatureName_WGPUFeatureName_DepthClipControl
1441 }
1442 FeatureName::Depth32FloatStencil8 => {
1443 ffi::WGPUFeatureName_WGPUFeatureName_Depth32FloatStencil8
1444 }
1445 FeatureName::TextureCompressionBc => {
1446 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBC
1447 }
1448 FeatureName::TextureCompressionBcSliced3D => {
1449 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionBCSliced3D
1450 }
1451 FeatureName::TextureCompressionEtc2 => {
1452 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionETC2
1453 }
1454 FeatureName::TextureCompressionAstc => {
1455 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTC
1456 }
1457 FeatureName::TextureCompressionAstcSliced3D => {
1458 ffi::WGPUFeatureName_WGPUFeatureName_TextureCompressionASTCSliced3D
1459 }
1460 FeatureName::TimestampQuery => {
1461 ffi::WGPUFeatureName_WGPUFeatureName_TimestampQuery
1462 }
1463 FeatureName::IndirectFirstInstance => {
1464 ffi::WGPUFeatureName_WGPUFeatureName_IndirectFirstInstance
1465 }
1466 FeatureName::ShaderF16 => ffi::WGPUFeatureName_WGPUFeatureName_ShaderF16,
1467 FeatureName::Rg11B10UfloatRenderable => {
1468 ffi::WGPUFeatureName_WGPUFeatureName_RG11B10UfloatRenderable
1469 }
1470 FeatureName::Bgra8UnormStorage => {
1471 ffi::WGPUFeatureName_WGPUFeatureName_BGRA8UnormStorage
1472 }
1473 FeatureName::Float32Filterable => {
1474 ffi::WGPUFeatureName_WGPUFeatureName_Float32Filterable
1475 }
1476 FeatureName::Float32Blendable => {
1477 ffi::WGPUFeatureName_WGPUFeatureName_Float32Blendable
1478 }
1479 FeatureName::ClipDistances => {
1480 ffi::WGPUFeatureName_WGPUFeatureName_ClipDistances
1481 }
1482 FeatureName::DualSourceBlending => {
1483 ffi::WGPUFeatureName_WGPUFeatureName_DualSourceBlending
1484 }
1485 FeatureName::Subgroups => ffi::WGPUFeatureName_WGPUFeatureName_Subgroups,
1486 FeatureName::TextureFormatsTier1 => {
1487 ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier1
1488 }
1489 FeatureName::TextureFormatsTier2 => {
1490 ffi::WGPUFeatureName_WGPUFeatureName_TextureFormatsTier2
1491 }
1492 FeatureName::PrimitiveIndex => {
1493 ffi::WGPUFeatureName_WGPUFeatureName_PrimitiveIndex
1494 }
1495 FeatureName::TextureComponentSwizzle => {
1496 ffi::WGPUFeatureName_WGPUFeatureName_TextureComponentSwizzle
1497 }
1498 FeatureName::DawnInternalUsages => {
1499 ffi::WGPUFeatureName_WGPUFeatureName_DawnInternalUsages
1500 }
1501 FeatureName::DawnMultiPlanarFormats => {
1502 ffi::WGPUFeatureName_WGPUFeatureName_DawnMultiPlanarFormats
1503 }
1504 FeatureName::DawnNative => {
1505 ffi::WGPUFeatureName_WGPUFeatureName_DawnNative
1506 }
1507 FeatureName::ChromiumExperimentalTimestampQueryInsidePasses => {
1508 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalTimestampQueryInsidePasses
1509 }
1510 FeatureName::ImplicitDeviceSynchronization => {
1511 ffi::WGPUFeatureName_WGPUFeatureName_ImplicitDeviceSynchronization
1512 }
1513 FeatureName::TransientAttachments => {
1514 ffi::WGPUFeatureName_WGPUFeatureName_TransientAttachments
1515 }
1516 FeatureName::MsaaRenderToSingleSampled => {
1517 ffi::WGPUFeatureName_WGPUFeatureName_MSAARenderToSingleSampled
1518 }
1519 FeatureName::D3D11MultithreadProtected => {
1520 ffi::WGPUFeatureName_WGPUFeatureName_D3D11MultithreadProtected
1521 }
1522 FeatureName::AngleTextureSharing => {
1523 ffi::WGPUFeatureName_WGPUFeatureName_ANGLETextureSharing
1524 }
1525 FeatureName::PixelLocalStorageCoherent => {
1526 ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageCoherent
1527 }
1528 FeatureName::PixelLocalStorageNonCoherent => {
1529 ffi::WGPUFeatureName_WGPUFeatureName_PixelLocalStorageNonCoherent
1530 }
1531 FeatureName::Unorm16TextureFormats => {
1532 ffi::WGPUFeatureName_WGPUFeatureName_Unorm16TextureFormats
1533 }
1534 FeatureName::MultiPlanarFormatExtendedUsages => {
1535 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatExtendedUsages
1536 }
1537 FeatureName::MultiPlanarFormatP010 => {
1538 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP010
1539 }
1540 FeatureName::HostMappedPointer => {
1541 ffi::WGPUFeatureName_WGPUFeatureName_HostMappedPointer
1542 }
1543 FeatureName::MultiPlanarRenderTargets => {
1544 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarRenderTargets
1545 }
1546 FeatureName::MultiPlanarFormatNv12A => {
1547 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv12a
1548 }
1549 FeatureName::FramebufferFetch => {
1550 ffi::WGPUFeatureName_WGPUFeatureName_FramebufferFetch
1551 }
1552 FeatureName::BufferMapExtendedUsages => {
1553 ffi::WGPUFeatureName_WGPUFeatureName_BufferMapExtendedUsages
1554 }
1555 FeatureName::AdapterPropertiesMemoryHeaps => {
1556 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesMemoryHeaps
1557 }
1558 FeatureName::AdapterPropertiesD3D => {
1559 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesD3D
1560 }
1561 FeatureName::AdapterPropertiesVk => {
1562 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesVk
1563 }
1564 FeatureName::DawnFormatCapabilities => {
1565 ffi::WGPUFeatureName_WGPUFeatureName_DawnFormatCapabilities
1566 }
1567 FeatureName::DawnDrmFormatCapabilities => {
1568 ffi::WGPUFeatureName_WGPUFeatureName_DawnDrmFormatCapabilities
1569 }
1570 FeatureName::MultiPlanarFormatNv16 => {
1571 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv16
1572 }
1573 FeatureName::MultiPlanarFormatNv24 => {
1574 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatNv24
1575 }
1576 FeatureName::MultiPlanarFormatP210 => {
1577 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP210
1578 }
1579 FeatureName::MultiPlanarFormatP410 => {
1580 ffi::WGPUFeatureName_WGPUFeatureName_MultiPlanarFormatP410
1581 }
1582 FeatureName::SharedTextureMemoryVkDedicatedAllocation => {
1583 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryVkDedicatedAllocation
1584 }
1585 FeatureName::SharedTextureMemoryAHardwareBuffer => {
1586 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryAHardwareBuffer
1587 }
1588 FeatureName::SharedTextureMemoryDmaBuf => {
1589 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDmaBuf
1590 }
1591 FeatureName::SharedTextureMemoryOpaqueFD => {
1592 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryOpaqueFD
1593 }
1594 FeatureName::SharedTextureMemoryZirconHandle => {
1595 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryZirconHandle
1596 }
1597 FeatureName::SharedTextureMemoryDXGISharedHandle => {
1598 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryDXGISharedHandle
1599 }
1600 FeatureName::SharedTextureMemoryD3D11Texture2D => {
1601 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D11Texture2D
1602 }
1603 FeatureName::SharedTextureMemoryIOSurface => {
1604 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryIOSurface
1605 }
1606 FeatureName::SharedTextureMemoryEGLImage => {
1607 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryEGLImage
1608 }
1609 FeatureName::SharedFenceVkSemaphoreOpaqueFD => {
1610 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreOpaqueFD
1611 }
1612 FeatureName::SharedFenceSyncFD => {
1613 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceSyncFD
1614 }
1615 FeatureName::SharedFenceVkSemaphoreZirconHandle => {
1616 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceVkSemaphoreZirconHandle
1617 }
1618 FeatureName::SharedFenceDXGISharedHandle => {
1619 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceDXGISharedHandle
1620 }
1621 FeatureName::SharedFenceMTLSharedEvent => {
1622 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceMTLSharedEvent
1623 }
1624 FeatureName::SharedBufferMemoryD3D12Resource => {
1625 ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12Resource
1626 }
1627 FeatureName::StaticSamplers => {
1628 ffi::WGPUFeatureName_WGPUFeatureName_StaticSamplers
1629 }
1630 FeatureName::YCbCrVulkanSamplers => {
1631 ffi::WGPUFeatureName_WGPUFeatureName_YCbCrVulkanSamplers
1632 }
1633 FeatureName::ShaderModuleCompilationOptions => {
1634 ffi::WGPUFeatureName_WGPUFeatureName_ShaderModuleCompilationOptions
1635 }
1636 FeatureName::DawnLoadResolveTexture => {
1637 ffi::WGPUFeatureName_WGPUFeatureName_DawnLoadResolveTexture
1638 }
1639 FeatureName::DawnPartialLoadResolveTexture => {
1640 ffi::WGPUFeatureName_WGPUFeatureName_DawnPartialLoadResolveTexture
1641 }
1642 FeatureName::MultiDrawIndirect => {
1643 ffi::WGPUFeatureName_WGPUFeatureName_MultiDrawIndirect
1644 }
1645 FeatureName::DawnTexelCopyBufferRowAlignment => {
1646 ffi::WGPUFeatureName_WGPUFeatureName_DawnTexelCopyBufferRowAlignment
1647 }
1648 FeatureName::FlexibleTextureViews => {
1649 ffi::WGPUFeatureName_WGPUFeatureName_FlexibleTextureViews
1650 }
1651 FeatureName::ChromiumExperimentalSubgroupMatrix => {
1652 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupMatrix
1653 }
1654 FeatureName::SharedFenceEGLSync => {
1655 ffi::WGPUFeatureName_WGPUFeatureName_SharedFenceEGLSync
1656 }
1657 FeatureName::DawnDeviceAllocatorControl => {
1658 ffi::WGPUFeatureName_WGPUFeatureName_DawnDeviceAllocatorControl
1659 }
1660 FeatureName::AdapterPropertiesWGPU => {
1661 ffi::WGPUFeatureName_WGPUFeatureName_AdapterPropertiesWGPU
1662 }
1663 FeatureName::SharedBufferMemoryD3D12SharedMemoryFileMappingHandle => {
1664 ffi::WGPUFeatureName_WGPUFeatureName_SharedBufferMemoryD3D12SharedMemoryFileMappingHandle
1665 }
1666 FeatureName::SharedTextureMemoryD3D12Resource => {
1667 ffi::WGPUFeatureName_WGPUFeatureName_SharedTextureMemoryD3D12Resource
1668 }
1669 FeatureName::ChromiumExperimentalSamplingResourceTable => {
1670 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSamplingResourceTable
1671 }
1672 FeatureName::ChromiumExperimentalSubgroupSizeControl => {
1673 ffi::WGPUFeatureName_WGPUFeatureName_ChromiumExperimentalSubgroupSizeControl
1674 }
1675 FeatureName::AtomicVec2UMinMax => {
1676 ffi::WGPUFeatureName_WGPUFeatureName_AtomicVec2uMinMax
1677 }
1678 }
1679 }
1680 }
1681 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1682 pub enum FilterMode {
1683 Undefined,
1684 Nearest,
1685 Linear,
1686 }
1687 impl From<ffi::WGPUFilterMode> for FilterMode {
1688 fn from(value: ffi::WGPUFilterMode) -> Self {
1689 match value {
1690 ffi::WGPUFilterMode_WGPUFilterMode_Undefined => FilterMode::Undefined,
1691 ffi::WGPUFilterMode_WGPUFilterMode_Nearest => FilterMode::Nearest,
1692 ffi::WGPUFilterMode_WGPUFilterMode_Linear => FilterMode::Linear,
1693 _ => FilterMode::Undefined,
1694 }
1695 }
1696 }
1697 impl From<FilterMode> for ffi::WGPUFilterMode {
1698 fn from(value: FilterMode) -> Self {
1699 match value {
1700 FilterMode::Undefined => ffi::WGPUFilterMode_WGPUFilterMode_Undefined,
1701 FilterMode::Nearest => ffi::WGPUFilterMode_WGPUFilterMode_Nearest,
1702 FilterMode::Linear => ffi::WGPUFilterMode_WGPUFilterMode_Linear,
1703 }
1704 }
1705 }
1706 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1707 pub enum FrontFace {
1708 Undefined,
1709 Ccw,
1710 Cw,
1711 }
1712 impl From<ffi::WGPUFrontFace> for FrontFace {
1713 fn from(value: ffi::WGPUFrontFace) -> Self {
1714 match value {
1715 ffi::WGPUFrontFace_WGPUFrontFace_Undefined => FrontFace::Undefined,
1716 ffi::WGPUFrontFace_WGPUFrontFace_CCW => FrontFace::Ccw,
1717 ffi::WGPUFrontFace_WGPUFrontFace_CW => FrontFace::Cw,
1718 _ => FrontFace::Undefined,
1719 }
1720 }
1721 }
1722 impl From<FrontFace> for ffi::WGPUFrontFace {
1723 fn from(value: FrontFace) -> Self {
1724 match value {
1725 FrontFace::Undefined => ffi::WGPUFrontFace_WGPUFrontFace_Undefined,
1726 FrontFace::Ccw => ffi::WGPUFrontFace_WGPUFrontFace_CCW,
1727 FrontFace::Cw => ffi::WGPUFrontFace_WGPUFrontFace_CW,
1728 }
1729 }
1730 }
1731 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1732 pub enum IndexFormat {
1733 Undefined,
1734 Uint16,
1735 Uint32,
1736 }
1737 impl From<ffi::WGPUIndexFormat> for IndexFormat {
1738 fn from(value: ffi::WGPUIndexFormat) -> Self {
1739 match value {
1740 ffi::WGPUIndexFormat_WGPUIndexFormat_Undefined => IndexFormat::Undefined,
1741 ffi::WGPUIndexFormat_WGPUIndexFormat_Uint16 => IndexFormat::Uint16,
1742 ffi::WGPUIndexFormat_WGPUIndexFormat_Uint32 => IndexFormat::Uint32,
1743 _ => IndexFormat::Undefined,
1744 }
1745 }
1746 }
1747 impl From<IndexFormat> for ffi::WGPUIndexFormat {
1748 fn from(value: IndexFormat) -> Self {
1749 match value {
1750 IndexFormat::Undefined => ffi::WGPUIndexFormat_WGPUIndexFormat_Undefined,
1751 IndexFormat::Uint16 => ffi::WGPUIndexFormat_WGPUIndexFormat_Uint16,
1752 IndexFormat::Uint32 => ffi::WGPUIndexFormat_WGPUIndexFormat_Uint32,
1753 }
1754 }
1755 }
1756 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1757 pub enum InstanceFeatureName {
1758 TimedWaitAny,
1759 ShaderSourceSPIRV,
1760 MultipleDevicesPerAdapter,
1761 }
1762 impl From<ffi::WGPUInstanceFeatureName> for InstanceFeatureName {
1763 fn from(value: ffi::WGPUInstanceFeatureName) -> Self {
1764 match value {
1765 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_TimedWaitAny => {
1766 InstanceFeatureName::TimedWaitAny
1767 }
1768 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_ShaderSourceSPIRV => {
1769 InstanceFeatureName::ShaderSourceSPIRV
1770 }
1771 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_MultipleDevicesPerAdapter => {
1772 InstanceFeatureName::MultipleDevicesPerAdapter
1773 }
1774 _ => InstanceFeatureName::TimedWaitAny,
1775 }
1776 }
1777 }
1778 impl From<InstanceFeatureName> for ffi::WGPUInstanceFeatureName {
1779 fn from(value: InstanceFeatureName) -> Self {
1780 match value {
1781 InstanceFeatureName::TimedWaitAny => {
1782 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_TimedWaitAny
1783 }
1784 InstanceFeatureName::ShaderSourceSPIRV => {
1785 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_ShaderSourceSPIRV
1786 }
1787 InstanceFeatureName::MultipleDevicesPerAdapter => {
1788 ffi::WGPUInstanceFeatureName_WGPUInstanceFeatureName_MultipleDevicesPerAdapter
1789 }
1790 }
1791 }
1792 }
1793 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1794 pub enum LoadOp {
1795 Undefined,
1796 Load,
1797 Clear,
1798 ExpandResolveTexture,
1799 }
1800 impl From<ffi::WGPULoadOp> for LoadOp {
1801 fn from(value: ffi::WGPULoadOp) -> Self {
1802 match value {
1803 ffi::WGPULoadOp_WGPULoadOp_Undefined => LoadOp::Undefined,
1804 ffi::WGPULoadOp_WGPULoadOp_Load => LoadOp::Load,
1805 ffi::WGPULoadOp_WGPULoadOp_Clear => LoadOp::Clear,
1806 ffi::WGPULoadOp_WGPULoadOp_ExpandResolveTexture => {
1807 LoadOp::ExpandResolveTexture
1808 }
1809 _ => LoadOp::Undefined,
1810 }
1811 }
1812 }
1813 impl From<LoadOp> for ffi::WGPULoadOp {
1814 fn from(value: LoadOp) -> Self {
1815 match value {
1816 LoadOp::Undefined => ffi::WGPULoadOp_WGPULoadOp_Undefined,
1817 LoadOp::Load => ffi::WGPULoadOp_WGPULoadOp_Load,
1818 LoadOp::Clear => ffi::WGPULoadOp_WGPULoadOp_Clear,
1819 LoadOp::ExpandResolveTexture => {
1820 ffi::WGPULoadOp_WGPULoadOp_ExpandResolveTexture
1821 }
1822 }
1823 }
1824 }
1825 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1826 pub enum LoggingType {
1827 Verbose,
1828 Info,
1829 Warning,
1830 Error,
1831 }
1832 impl From<ffi::WGPULoggingType> for LoggingType {
1833 fn from(value: ffi::WGPULoggingType) -> Self {
1834 match value {
1835 ffi::WGPULoggingType_WGPULoggingType_Verbose => LoggingType::Verbose,
1836 ffi::WGPULoggingType_WGPULoggingType_Info => LoggingType::Info,
1837 ffi::WGPULoggingType_WGPULoggingType_Warning => LoggingType::Warning,
1838 ffi::WGPULoggingType_WGPULoggingType_Error => LoggingType::Error,
1839 _ => LoggingType::Verbose,
1840 }
1841 }
1842 }
1843 impl From<LoggingType> for ffi::WGPULoggingType {
1844 fn from(value: LoggingType) -> Self {
1845 match value {
1846 LoggingType::Verbose => ffi::WGPULoggingType_WGPULoggingType_Verbose,
1847 LoggingType::Info => ffi::WGPULoggingType_WGPULoggingType_Info,
1848 LoggingType::Warning => ffi::WGPULoggingType_WGPULoggingType_Warning,
1849 LoggingType::Error => ffi::WGPULoggingType_WGPULoggingType_Error,
1850 }
1851 }
1852 }
1853 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1854 pub enum MapAsyncStatus {
1855 Success,
1856 CallbackCancelled,
1857 Error,
1858 Aborted,
1859 }
1860 impl From<ffi::WGPUMapAsyncStatus> for MapAsyncStatus {
1861 fn from(value: ffi::WGPUMapAsyncStatus) -> Self {
1862 match value {
1863 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Success => {
1864 MapAsyncStatus::Success
1865 }
1866 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_CallbackCancelled => {
1867 MapAsyncStatus::CallbackCancelled
1868 }
1869 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Error => MapAsyncStatus::Error,
1870 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Aborted => {
1871 MapAsyncStatus::Aborted
1872 }
1873 _ => MapAsyncStatus::Success,
1874 }
1875 }
1876 }
1877 impl From<MapAsyncStatus> for ffi::WGPUMapAsyncStatus {
1878 fn from(value: MapAsyncStatus) -> Self {
1879 match value {
1880 MapAsyncStatus::Success => {
1881 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Success
1882 }
1883 MapAsyncStatus::CallbackCancelled => {
1884 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_CallbackCancelled
1885 }
1886 MapAsyncStatus::Error => ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Error,
1887 MapAsyncStatus::Aborted => {
1888 ffi::WGPUMapAsyncStatus_WGPUMapAsyncStatus_Aborted
1889 }
1890 }
1891 }
1892 }
1893 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1894 pub enum MipmapFilterMode {
1895 Undefined,
1896 Nearest,
1897 Linear,
1898 }
1899 impl From<ffi::WGPUMipmapFilterMode> for MipmapFilterMode {
1900 fn from(value: ffi::WGPUMipmapFilterMode) -> Self {
1901 match value {
1902 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Undefined => {
1903 MipmapFilterMode::Undefined
1904 }
1905 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Nearest => {
1906 MipmapFilterMode::Nearest
1907 }
1908 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Linear => {
1909 MipmapFilterMode::Linear
1910 }
1911 _ => MipmapFilterMode::Undefined,
1912 }
1913 }
1914 }
1915 impl From<MipmapFilterMode> for ffi::WGPUMipmapFilterMode {
1916 fn from(value: MipmapFilterMode) -> Self {
1917 match value {
1918 MipmapFilterMode::Undefined => {
1919 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Undefined
1920 }
1921 MipmapFilterMode::Nearest => {
1922 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Nearest
1923 }
1924 MipmapFilterMode::Linear => {
1925 ffi::WGPUMipmapFilterMode_WGPUMipmapFilterMode_Linear
1926 }
1927 }
1928 }
1929 }
1930 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1931 pub enum OptionalBool {
1932 False,
1933 True,
1934 Undefined,
1935 }
1936 impl From<ffi::WGPUOptionalBool> for OptionalBool {
1937 fn from(value: ffi::WGPUOptionalBool) -> Self {
1938 match value {
1939 ffi::WGPUOptionalBool_WGPUOptionalBool_False => OptionalBool::False,
1940 ffi::WGPUOptionalBool_WGPUOptionalBool_True => OptionalBool::True,
1941 ffi::WGPUOptionalBool_WGPUOptionalBool_Undefined => {
1942 OptionalBool::Undefined
1943 }
1944 _ => OptionalBool::False,
1945 }
1946 }
1947 }
1948 impl From<OptionalBool> for ffi::WGPUOptionalBool {
1949 fn from(value: OptionalBool) -> Self {
1950 match value {
1951 OptionalBool::False => ffi::WGPUOptionalBool_WGPUOptionalBool_False,
1952 OptionalBool::True => ffi::WGPUOptionalBool_WGPUOptionalBool_True,
1953 OptionalBool::Undefined => {
1954 ffi::WGPUOptionalBool_WGPUOptionalBool_Undefined
1955 }
1956 }
1957 }
1958 }
1959 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1960 pub enum PopErrorScopeStatus {
1961 Success,
1962 CallbackCancelled,
1963 Error,
1964 }
1965 impl From<ffi::WGPUPopErrorScopeStatus> for PopErrorScopeStatus {
1966 fn from(value: ffi::WGPUPopErrorScopeStatus) -> Self {
1967 match value {
1968 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Success => {
1969 PopErrorScopeStatus::Success
1970 }
1971 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_CallbackCancelled => {
1972 PopErrorScopeStatus::CallbackCancelled
1973 }
1974 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Error => {
1975 PopErrorScopeStatus::Error
1976 }
1977 _ => PopErrorScopeStatus::Success,
1978 }
1979 }
1980 }
1981 impl From<PopErrorScopeStatus> for ffi::WGPUPopErrorScopeStatus {
1982 fn from(value: PopErrorScopeStatus) -> Self {
1983 match value {
1984 PopErrorScopeStatus::Success => {
1985 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Success
1986 }
1987 PopErrorScopeStatus::CallbackCancelled => {
1988 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_CallbackCancelled
1989 }
1990 PopErrorScopeStatus::Error => {
1991 ffi::WGPUPopErrorScopeStatus_WGPUPopErrorScopeStatus_Error
1992 }
1993 }
1994 }
1995 }
1996 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
1997 pub enum PowerPreference {
1998 Undefined,
1999 LowPower,
2000 HighPerformance,
2001 }
2002 impl From<ffi::WGPUPowerPreference> for PowerPreference {
2003 fn from(value: ffi::WGPUPowerPreference) -> Self {
2004 match value {
2005 ffi::WGPUPowerPreference_WGPUPowerPreference_Undefined => {
2006 PowerPreference::Undefined
2007 }
2008 ffi::WGPUPowerPreference_WGPUPowerPreference_LowPower => {
2009 PowerPreference::LowPower
2010 }
2011 ffi::WGPUPowerPreference_WGPUPowerPreference_HighPerformance => {
2012 PowerPreference::HighPerformance
2013 }
2014 _ => PowerPreference::Undefined,
2015 }
2016 }
2017 }
2018 impl From<PowerPreference> for ffi::WGPUPowerPreference {
2019 fn from(value: PowerPreference) -> Self {
2020 match value {
2021 PowerPreference::Undefined => {
2022 ffi::WGPUPowerPreference_WGPUPowerPreference_Undefined
2023 }
2024 PowerPreference::LowPower => {
2025 ffi::WGPUPowerPreference_WGPUPowerPreference_LowPower
2026 }
2027 PowerPreference::HighPerformance => {
2028 ffi::WGPUPowerPreference_WGPUPowerPreference_HighPerformance
2029 }
2030 }
2031 }
2032 }
2033 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2034 pub enum PredefinedColorSpace {
2035 SRgb,
2036 DisplayP3,
2037 }
2038 impl From<ffi::WGPUPredefinedColorSpace> for PredefinedColorSpace {
2039 fn from(value: ffi::WGPUPredefinedColorSpace) -> Self {
2040 match value {
2041 ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_SRGB => {
2042 PredefinedColorSpace::SRgb
2043 }
2044 ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_DisplayP3 => {
2045 PredefinedColorSpace::DisplayP3
2046 }
2047 _ => PredefinedColorSpace::SRgb,
2048 }
2049 }
2050 }
2051 impl From<PredefinedColorSpace> for ffi::WGPUPredefinedColorSpace {
2052 fn from(value: PredefinedColorSpace) -> Self {
2053 match value {
2054 PredefinedColorSpace::SRgb => {
2055 ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_SRGB
2056 }
2057 PredefinedColorSpace::DisplayP3 => {
2058 ffi::WGPUPredefinedColorSpace_WGPUPredefinedColorSpace_DisplayP3
2059 }
2060 }
2061 }
2062 }
2063 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2064 pub enum PresentMode {
2065 Undefined,
2066 Fifo,
2067 FifoRelaxed,
2068 Immediate,
2069 Mailbox,
2070 }
2071 impl From<ffi::WGPUPresentMode> for PresentMode {
2072 fn from(value: ffi::WGPUPresentMode) -> Self {
2073 match value {
2074 ffi::WGPUPresentMode_WGPUPresentMode_Undefined => PresentMode::Undefined,
2075 ffi::WGPUPresentMode_WGPUPresentMode_Fifo => PresentMode::Fifo,
2076 ffi::WGPUPresentMode_WGPUPresentMode_FifoRelaxed => {
2077 PresentMode::FifoRelaxed
2078 }
2079 ffi::WGPUPresentMode_WGPUPresentMode_Immediate => PresentMode::Immediate,
2080 ffi::WGPUPresentMode_WGPUPresentMode_Mailbox => PresentMode::Mailbox,
2081 _ => PresentMode::Undefined,
2082 }
2083 }
2084 }
2085 impl From<PresentMode> for ffi::WGPUPresentMode {
2086 fn from(value: PresentMode) -> Self {
2087 match value {
2088 PresentMode::Undefined => ffi::WGPUPresentMode_WGPUPresentMode_Undefined,
2089 PresentMode::Fifo => ffi::WGPUPresentMode_WGPUPresentMode_Fifo,
2090 PresentMode::FifoRelaxed => {
2091 ffi::WGPUPresentMode_WGPUPresentMode_FifoRelaxed
2092 }
2093 PresentMode::Immediate => ffi::WGPUPresentMode_WGPUPresentMode_Immediate,
2094 PresentMode::Mailbox => ffi::WGPUPresentMode_WGPUPresentMode_Mailbox,
2095 }
2096 }
2097 }
2098 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2099 pub enum PrimitiveTopology {
2100 Undefined,
2101 PointList,
2102 LineList,
2103 LineStrip,
2104 TriangleList,
2105 TriangleStrip,
2106 }
2107 impl From<ffi::WGPUPrimitiveTopology> for PrimitiveTopology {
2108 fn from(value: ffi::WGPUPrimitiveTopology) -> Self {
2109 match value {
2110 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_Undefined => {
2111 PrimitiveTopology::Undefined
2112 }
2113 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_PointList => {
2114 PrimitiveTopology::PointList
2115 }
2116 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineList => {
2117 PrimitiveTopology::LineList
2118 }
2119 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineStrip => {
2120 PrimitiveTopology::LineStrip
2121 }
2122 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleList => {
2123 PrimitiveTopology::TriangleList
2124 }
2125 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleStrip => {
2126 PrimitiveTopology::TriangleStrip
2127 }
2128 _ => PrimitiveTopology::Undefined,
2129 }
2130 }
2131 }
2132 impl From<PrimitiveTopology> for ffi::WGPUPrimitiveTopology {
2133 fn from(value: PrimitiveTopology) -> Self {
2134 match value {
2135 PrimitiveTopology::Undefined => {
2136 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_Undefined
2137 }
2138 PrimitiveTopology::PointList => {
2139 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_PointList
2140 }
2141 PrimitiveTopology::LineList => {
2142 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineList
2143 }
2144 PrimitiveTopology::LineStrip => {
2145 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_LineStrip
2146 }
2147 PrimitiveTopology::TriangleList => {
2148 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleList
2149 }
2150 PrimitiveTopology::TriangleStrip => {
2151 ffi::WGPUPrimitiveTopology_WGPUPrimitiveTopology_TriangleStrip
2152 }
2153 }
2154 }
2155 }
2156 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2157 pub enum QueryType {
2158 Occlusion,
2159 Timestamp,
2160 }
2161 impl From<ffi::WGPUQueryType> for QueryType {
2162 fn from(value: ffi::WGPUQueryType) -> Self {
2163 match value {
2164 ffi::WGPUQueryType_WGPUQueryType_Occlusion => QueryType::Occlusion,
2165 ffi::WGPUQueryType_WGPUQueryType_Timestamp => QueryType::Timestamp,
2166 _ => QueryType::Occlusion,
2167 }
2168 }
2169 }
2170 impl From<QueryType> for ffi::WGPUQueryType {
2171 fn from(value: QueryType) -> Self {
2172 match value {
2173 QueryType::Occlusion => ffi::WGPUQueryType_WGPUQueryType_Occlusion,
2174 QueryType::Timestamp => ffi::WGPUQueryType_WGPUQueryType_Timestamp,
2175 }
2176 }
2177 }
2178 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2179 pub enum QueueWorkDoneStatus {
2180 Success,
2181 CallbackCancelled,
2182 Error,
2183 }
2184 impl From<ffi::WGPUQueueWorkDoneStatus> for QueueWorkDoneStatus {
2185 fn from(value: ffi::WGPUQueueWorkDoneStatus) -> Self {
2186 match value {
2187 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Success => {
2188 QueueWorkDoneStatus::Success
2189 }
2190 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_CallbackCancelled => {
2191 QueueWorkDoneStatus::CallbackCancelled
2192 }
2193 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Error => {
2194 QueueWorkDoneStatus::Error
2195 }
2196 _ => QueueWorkDoneStatus::Success,
2197 }
2198 }
2199 }
2200 impl From<QueueWorkDoneStatus> for ffi::WGPUQueueWorkDoneStatus {
2201 fn from(value: QueueWorkDoneStatus) -> Self {
2202 match value {
2203 QueueWorkDoneStatus::Success => {
2204 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Success
2205 }
2206 QueueWorkDoneStatus::CallbackCancelled => {
2207 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_CallbackCancelled
2208 }
2209 QueueWorkDoneStatus::Error => {
2210 ffi::WGPUQueueWorkDoneStatus_WGPUQueueWorkDoneStatus_Error
2211 }
2212 }
2213 }
2214 }
2215 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2216 pub enum RequestAdapterStatus {
2217 Success,
2218 CallbackCancelled,
2219 Unavailable,
2220 Error,
2221 }
2222 impl From<ffi::WGPURequestAdapterStatus> for RequestAdapterStatus {
2223 fn from(value: ffi::WGPURequestAdapterStatus) -> Self {
2224 match value {
2225 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Success => {
2226 RequestAdapterStatus::Success
2227 }
2228 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_CallbackCancelled => {
2229 RequestAdapterStatus::CallbackCancelled
2230 }
2231 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Unavailable => {
2232 RequestAdapterStatus::Unavailable
2233 }
2234 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Error => {
2235 RequestAdapterStatus::Error
2236 }
2237 _ => RequestAdapterStatus::Success,
2238 }
2239 }
2240 }
2241 impl From<RequestAdapterStatus> for ffi::WGPURequestAdapterStatus {
2242 fn from(value: RequestAdapterStatus) -> Self {
2243 match value {
2244 RequestAdapterStatus::Success => {
2245 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Success
2246 }
2247 RequestAdapterStatus::CallbackCancelled => {
2248 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_CallbackCancelled
2249 }
2250 RequestAdapterStatus::Unavailable => {
2251 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Unavailable
2252 }
2253 RequestAdapterStatus::Error => {
2254 ffi::WGPURequestAdapterStatus_WGPURequestAdapterStatus_Error
2255 }
2256 }
2257 }
2258 }
2259 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2260 pub enum RequestDeviceStatus {
2261 Success,
2262 CallbackCancelled,
2263 Error,
2264 }
2265 impl From<ffi::WGPURequestDeviceStatus> for RequestDeviceStatus {
2266 fn from(value: ffi::WGPURequestDeviceStatus) -> Self {
2267 match value {
2268 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Success => {
2269 RequestDeviceStatus::Success
2270 }
2271 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_CallbackCancelled => {
2272 RequestDeviceStatus::CallbackCancelled
2273 }
2274 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Error => {
2275 RequestDeviceStatus::Error
2276 }
2277 _ => RequestDeviceStatus::Success,
2278 }
2279 }
2280 }
2281 impl From<RequestDeviceStatus> for ffi::WGPURequestDeviceStatus {
2282 fn from(value: RequestDeviceStatus) -> Self {
2283 match value {
2284 RequestDeviceStatus::Success => {
2285 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Success
2286 }
2287 RequestDeviceStatus::CallbackCancelled => {
2288 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_CallbackCancelled
2289 }
2290 RequestDeviceStatus::Error => {
2291 ffi::WGPURequestDeviceStatus_WGPURequestDeviceStatus_Error
2292 }
2293 }
2294 }
2295 }
2296 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2297 pub enum SType {
2298 ShaderSourceSPIRV,
2299 ShaderSourceWGSL,
2300 RenderPassMaxDrawCount,
2301 SurfaceSourceMetalLayer,
2302 SurfaceSourceWindowsHWND,
2303 SurfaceSourceXlibWindow,
2304 SurfaceSourceWaylandSurface,
2305 SurfaceSourceAndroidNativeWindow,
2306 SurfaceSourceXCBWindow,
2307 SurfaceColorManagement,
2308 RequestAdapterWebXROptions,
2309 TextureComponentSwizzleDescriptor,
2310 CompatibilityModeLimits,
2311 TextureBindingViewDimensionDescriptor,
2312 EmscriptenSurfaceSourceCanvasHTMLSelector,
2313 SurfaceDescriptorFromWindowsCoreWindow,
2314 ExternalTextureBindingEntry,
2315 ExternalTextureBindingLayout,
2316 SurfaceDescriptorFromWindowsUWPSwapChainPanel,
2317 DawnTextureInternalUsageDescriptor,
2318 DawnEncoderInternalUsageDescriptor,
2319 DawnInstanceDescriptor,
2320 DawnCacheDeviceDescriptor,
2321 DawnAdapterPropertiesPowerPreference,
2322 DawnBufferDescriptorErrorInfoFromWireClient,
2323 DawnTogglesDescriptor,
2324 DawnShaderModuleSPIRVOptionsDescriptor,
2325 RequestAdapterOptionsLuid,
2326 RequestAdapterOptionsGetGlProc,
2327 RequestAdapterOptionsD3D11Device,
2328 DawnRenderPassSampleCount,
2329 RenderPassPixelLocalStorage,
2330 PipelineLayoutPixelLocalStorage,
2331 BufferHostMappedPointer,
2332 AdapterPropertiesMemoryHeaps,
2333 AdapterPropertiesD3D,
2334 AdapterPropertiesVk,
2335 DawnWireWGSLControl,
2336 DawnWGSLBlocklist,
2337 DawnDrmFormatCapabilities,
2338 ShaderModuleCompilationOptions,
2339 ColorTargetStateExpandResolveTextureDawn,
2340 RenderPassDescriptorExpandResolveRect,
2341 SharedTextureMemoryVkDedicatedAllocationDescriptor,
2342 SharedTextureMemoryAHardwareBufferDescriptor,
2343 SharedTextureMemoryDmaBufDescriptor,
2344 SharedTextureMemoryOpaqueFDDescriptor,
2345 SharedTextureMemoryZirconHandleDescriptor,
2346 SharedTextureMemoryDXGISharedHandleDescriptor,
2347 SharedTextureMemoryD3D11Texture2DDescriptor,
2348 SharedTextureMemoryIOSurfaceDescriptor,
2349 SharedTextureMemoryEGLImageDescriptor,
2350 SharedTextureMemoryInitializedBeginState,
2351 SharedTextureMemoryInitializedEndState,
2352 SharedTextureMemoryVkImageLayoutBeginState,
2353 SharedTextureMemoryVkImageLayoutEndState,
2354 SharedTextureMemoryD3DSwapchainBeginState,
2355 SharedFenceVkSemaphoreOpaqueFDDescriptor,
2356 SharedFenceVkSemaphoreOpaqueFDExportInfo,
2357 SharedFenceSyncFDDescriptor,
2358 SharedFenceSyncFDExportInfo,
2359 SharedFenceVkSemaphoreZirconHandleDescriptor,
2360 SharedFenceVkSemaphoreZirconHandleExportInfo,
2361 SharedFenceDXGISharedHandleDescriptor,
2362 SharedFenceDXGISharedHandleExportInfo,
2363 SharedFenceMTLSharedEventDescriptor,
2364 SharedFenceMTLSharedEventExportInfo,
2365 SharedBufferMemoryD3D12ResourceDescriptor,
2366 StaticSamplerBindingLayout,
2367 YCbCrVkDescriptor,
2368 SharedTextureMemoryAHardwareBufferProperties,
2369 AHardwareBufferProperties,
2370 DawnTexelCopyBufferRowAlignmentLimits,
2371 AdapterPropertiesSubgroupMatrixConfigs,
2372 SharedFenceEGLSyncDescriptor,
2373 SharedFenceEGLSyncExportInfo,
2374 DawnInjectedInvalidSType,
2375 DawnCompilationMessageUtf16,
2376 DawnFakeBufferOOMForTesting,
2377 SurfaceDescriptorFromWindowsWinUISwapChainPanel,
2378 DawnDeviceAllocatorControl,
2379 DawnHostMappedPointerLimits,
2380 RenderPassDescriptorResolveRect,
2381 RequestAdapterWebGPUBackendOptions,
2382 DawnFakeDeviceInitializeErrorForTesting,
2383 SharedTextureMemoryD3D11BeginState,
2384 DawnConsumeAdapterDescriptor,
2385 TexelBufferBindingEntry,
2386 TexelBufferBindingLayout,
2387 SharedTextureMemoryMetalEndAccessState,
2388 AdapterPropertiesWGPU,
2389 SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor,
2390 SharedTextureMemoryD3D12ResourceDescriptor,
2391 RequestAdapterOptionsAngleVirtualizationGroup,
2392 PipelineLayoutResourceTable,
2393 AdapterPropertiesExplicitComputeSubgroupSizeConfigs,
2394 }
2395 impl From<ffi::WGPUSType> for SType {
2396 fn from(value: ffi::WGPUSType) -> Self {
2397 match value {
2398 ffi::WGPUSType_WGPUSType_ShaderSourceSPIRV => SType::ShaderSourceSPIRV,
2399 ffi::WGPUSType_WGPUSType_ShaderSourceWGSL => SType::ShaderSourceWGSL,
2400 ffi::WGPUSType_WGPUSType_RenderPassMaxDrawCount => {
2401 SType::RenderPassMaxDrawCount
2402 }
2403 ffi::WGPUSType_WGPUSType_SurfaceSourceMetalLayer => {
2404 SType::SurfaceSourceMetalLayer
2405 }
2406 ffi::WGPUSType_WGPUSType_SurfaceSourceWindowsHWND => {
2407 SType::SurfaceSourceWindowsHWND
2408 }
2409 ffi::WGPUSType_WGPUSType_SurfaceSourceXlibWindow => {
2410 SType::SurfaceSourceXlibWindow
2411 }
2412 ffi::WGPUSType_WGPUSType_SurfaceSourceWaylandSurface => {
2413 SType::SurfaceSourceWaylandSurface
2414 }
2415 ffi::WGPUSType_WGPUSType_SurfaceSourceAndroidNativeWindow => {
2416 SType::SurfaceSourceAndroidNativeWindow
2417 }
2418 ffi::WGPUSType_WGPUSType_SurfaceSourceXCBWindow => {
2419 SType::SurfaceSourceXCBWindow
2420 }
2421 ffi::WGPUSType_WGPUSType_SurfaceColorManagement => {
2422 SType::SurfaceColorManagement
2423 }
2424 ffi::WGPUSType_WGPUSType_RequestAdapterWebXROptions => {
2425 SType::RequestAdapterWebXROptions
2426 }
2427 ffi::WGPUSType_WGPUSType_TextureComponentSwizzleDescriptor => {
2428 SType::TextureComponentSwizzleDescriptor
2429 }
2430 ffi::WGPUSType_WGPUSType_CompatibilityModeLimits => {
2431 SType::CompatibilityModeLimits
2432 }
2433 ffi::WGPUSType_WGPUSType_TextureBindingViewDimensionDescriptor => {
2434 SType::TextureBindingViewDimensionDescriptor
2435 }
2436 ffi::WGPUSType_WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector => {
2437 SType::EmscriptenSurfaceSourceCanvasHTMLSelector
2438 }
2439 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsCoreWindow => {
2440 SType::SurfaceDescriptorFromWindowsCoreWindow
2441 }
2442 ffi::WGPUSType_WGPUSType_ExternalTextureBindingEntry => {
2443 SType::ExternalTextureBindingEntry
2444 }
2445 ffi::WGPUSType_WGPUSType_ExternalTextureBindingLayout => {
2446 SType::ExternalTextureBindingLayout
2447 }
2448 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsUWPSwapChainPanel => {
2449 SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel
2450 }
2451 ffi::WGPUSType_WGPUSType_DawnTextureInternalUsageDescriptor => {
2452 SType::DawnTextureInternalUsageDescriptor
2453 }
2454 ffi::WGPUSType_WGPUSType_DawnEncoderInternalUsageDescriptor => {
2455 SType::DawnEncoderInternalUsageDescriptor
2456 }
2457 ffi::WGPUSType_WGPUSType_DawnInstanceDescriptor => {
2458 SType::DawnInstanceDescriptor
2459 }
2460 ffi::WGPUSType_WGPUSType_DawnCacheDeviceDescriptor => {
2461 SType::DawnCacheDeviceDescriptor
2462 }
2463 ffi::WGPUSType_WGPUSType_DawnAdapterPropertiesPowerPreference => {
2464 SType::DawnAdapterPropertiesPowerPreference
2465 }
2466 ffi::WGPUSType_WGPUSType_DawnBufferDescriptorErrorInfoFromWireClient => {
2467 SType::DawnBufferDescriptorErrorInfoFromWireClient
2468 }
2469 ffi::WGPUSType_WGPUSType_DawnTogglesDescriptor => {
2470 SType::DawnTogglesDescriptor
2471 }
2472 ffi::WGPUSType_WGPUSType_DawnShaderModuleSPIRVOptionsDescriptor => {
2473 SType::DawnShaderModuleSPIRVOptionsDescriptor
2474 }
2475 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsLUID => {
2476 SType::RequestAdapterOptionsLuid
2477 }
2478 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsGetGLProc => {
2479 SType::RequestAdapterOptionsGetGlProc
2480 }
2481 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsD3D11Device => {
2482 SType::RequestAdapterOptionsD3D11Device
2483 }
2484 ffi::WGPUSType_WGPUSType_DawnRenderPassSampleCount => {
2485 SType::DawnRenderPassSampleCount
2486 }
2487 ffi::WGPUSType_WGPUSType_RenderPassPixelLocalStorage => {
2488 SType::RenderPassPixelLocalStorage
2489 }
2490 ffi::WGPUSType_WGPUSType_PipelineLayoutPixelLocalStorage => {
2491 SType::PipelineLayoutPixelLocalStorage
2492 }
2493 ffi::WGPUSType_WGPUSType_BufferHostMappedPointer => {
2494 SType::BufferHostMappedPointer
2495 }
2496 ffi::WGPUSType_WGPUSType_AdapterPropertiesMemoryHeaps => {
2497 SType::AdapterPropertiesMemoryHeaps
2498 }
2499 ffi::WGPUSType_WGPUSType_AdapterPropertiesD3D => {
2500 SType::AdapterPropertiesD3D
2501 }
2502 ffi::WGPUSType_WGPUSType_AdapterPropertiesVk => {
2503 SType::AdapterPropertiesVk
2504 }
2505 ffi::WGPUSType_WGPUSType_DawnWireWGSLControl => {
2506 SType::DawnWireWGSLControl
2507 }
2508 ffi::WGPUSType_WGPUSType_DawnWGSLBlocklist => SType::DawnWGSLBlocklist,
2509 ffi::WGPUSType_WGPUSType_DawnDrmFormatCapabilities => {
2510 SType::DawnDrmFormatCapabilities
2511 }
2512 ffi::WGPUSType_WGPUSType_ShaderModuleCompilationOptions => {
2513 SType::ShaderModuleCompilationOptions
2514 }
2515 ffi::WGPUSType_WGPUSType_ColorTargetStateExpandResolveTextureDawn => {
2516 SType::ColorTargetStateExpandResolveTextureDawn
2517 }
2518 ffi::WGPUSType_WGPUSType_RenderPassDescriptorExpandResolveRect => {
2519 SType::RenderPassDescriptorExpandResolveRect
2520 }
2521 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkDedicatedAllocationDescriptor => {
2522 SType::SharedTextureMemoryVkDedicatedAllocationDescriptor
2523 }
2524 ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferDescriptor => {
2525 SType::SharedTextureMemoryAHardwareBufferDescriptor
2526 }
2527 ffi::WGPUSType_WGPUSType_SharedTextureMemoryDmaBufDescriptor => {
2528 SType::SharedTextureMemoryDmaBufDescriptor
2529 }
2530 ffi::WGPUSType_WGPUSType_SharedTextureMemoryOpaqueFDDescriptor => {
2531 SType::SharedTextureMemoryOpaqueFDDescriptor
2532 }
2533 ffi::WGPUSType_WGPUSType_SharedTextureMemoryZirconHandleDescriptor => {
2534 SType::SharedTextureMemoryZirconHandleDescriptor
2535 }
2536 ffi::WGPUSType_WGPUSType_SharedTextureMemoryDXGISharedHandleDescriptor => {
2537 SType::SharedTextureMemoryDXGISharedHandleDescriptor
2538 }
2539 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11Texture2DDescriptor => {
2540 SType::SharedTextureMemoryD3D11Texture2DDescriptor
2541 }
2542 ffi::WGPUSType_WGPUSType_SharedTextureMemoryIOSurfaceDescriptor => {
2543 SType::SharedTextureMemoryIOSurfaceDescriptor
2544 }
2545 ffi::WGPUSType_WGPUSType_SharedTextureMemoryEGLImageDescriptor => {
2546 SType::SharedTextureMemoryEGLImageDescriptor
2547 }
2548 ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedBeginState => {
2549 SType::SharedTextureMemoryInitializedBeginState
2550 }
2551 ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedEndState => {
2552 SType::SharedTextureMemoryInitializedEndState
2553 }
2554 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutBeginState => {
2555 SType::SharedTextureMemoryVkImageLayoutBeginState
2556 }
2557 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutEndState => {
2558 SType::SharedTextureMemoryVkImageLayoutEndState
2559 }
2560 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3DSwapchainBeginState => {
2561 SType::SharedTextureMemoryD3DSwapchainBeginState
2562 }
2563 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDDescriptor => {
2564 SType::SharedFenceVkSemaphoreOpaqueFDDescriptor
2565 }
2566 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDExportInfo => {
2567 SType::SharedFenceVkSemaphoreOpaqueFDExportInfo
2568 }
2569 ffi::WGPUSType_WGPUSType_SharedFenceSyncFDDescriptor => {
2570 SType::SharedFenceSyncFDDescriptor
2571 }
2572 ffi::WGPUSType_WGPUSType_SharedFenceSyncFDExportInfo => {
2573 SType::SharedFenceSyncFDExportInfo
2574 }
2575 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleDescriptor => {
2576 SType::SharedFenceVkSemaphoreZirconHandleDescriptor
2577 }
2578 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleExportInfo => {
2579 SType::SharedFenceVkSemaphoreZirconHandleExportInfo
2580 }
2581 ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleDescriptor => {
2582 SType::SharedFenceDXGISharedHandleDescriptor
2583 }
2584 ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleExportInfo => {
2585 SType::SharedFenceDXGISharedHandleExportInfo
2586 }
2587 ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventDescriptor => {
2588 SType::SharedFenceMTLSharedEventDescriptor
2589 }
2590 ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventExportInfo => {
2591 SType::SharedFenceMTLSharedEventExportInfo
2592 }
2593 ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor => {
2594 SType::SharedBufferMemoryD3D12ResourceDescriptor
2595 }
2596 ffi::WGPUSType_WGPUSType_StaticSamplerBindingLayout => {
2597 SType::StaticSamplerBindingLayout
2598 }
2599 ffi::WGPUSType_WGPUSType_YCbCrVkDescriptor => SType::YCbCrVkDescriptor,
2600 ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferProperties => {
2601 SType::SharedTextureMemoryAHardwareBufferProperties
2602 }
2603 ffi::WGPUSType_WGPUSType_AHardwareBufferProperties => {
2604 SType::AHardwareBufferProperties
2605 }
2606 ffi::WGPUSType_WGPUSType_DawnTexelCopyBufferRowAlignmentLimits => {
2607 SType::DawnTexelCopyBufferRowAlignmentLimits
2608 }
2609 ffi::WGPUSType_WGPUSType_AdapterPropertiesSubgroupMatrixConfigs => {
2610 SType::AdapterPropertiesSubgroupMatrixConfigs
2611 }
2612 ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncDescriptor => {
2613 SType::SharedFenceEGLSyncDescriptor
2614 }
2615 ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncExportInfo => {
2616 SType::SharedFenceEGLSyncExportInfo
2617 }
2618 ffi::WGPUSType_WGPUSType_DawnInjectedInvalidSType => {
2619 SType::DawnInjectedInvalidSType
2620 }
2621 ffi::WGPUSType_WGPUSType_DawnCompilationMessageUtf16 => {
2622 SType::DawnCompilationMessageUtf16
2623 }
2624 ffi::WGPUSType_WGPUSType_DawnFakeBufferOOMForTesting => {
2625 SType::DawnFakeBufferOOMForTesting
2626 }
2627 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsWinUISwapChainPanel => {
2628 SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel
2629 }
2630 ffi::WGPUSType_WGPUSType_DawnDeviceAllocatorControl => {
2631 SType::DawnDeviceAllocatorControl
2632 }
2633 ffi::WGPUSType_WGPUSType_DawnHostMappedPointerLimits => {
2634 SType::DawnHostMappedPointerLimits
2635 }
2636 ffi::WGPUSType_WGPUSType_RenderPassDescriptorResolveRect => {
2637 SType::RenderPassDescriptorResolveRect
2638 }
2639 ffi::WGPUSType_WGPUSType_RequestAdapterWebGPUBackendOptions => {
2640 SType::RequestAdapterWebGPUBackendOptions
2641 }
2642 ffi::WGPUSType_WGPUSType_DawnFakeDeviceInitializeErrorForTesting => {
2643 SType::DawnFakeDeviceInitializeErrorForTesting
2644 }
2645 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11BeginState => {
2646 SType::SharedTextureMemoryD3D11BeginState
2647 }
2648 ffi::WGPUSType_WGPUSType_DawnConsumeAdapterDescriptor => {
2649 SType::DawnConsumeAdapterDescriptor
2650 }
2651 ffi::WGPUSType_WGPUSType_TexelBufferBindingEntry => {
2652 SType::TexelBufferBindingEntry
2653 }
2654 ffi::WGPUSType_WGPUSType_TexelBufferBindingLayout => {
2655 SType::TexelBufferBindingLayout
2656 }
2657 ffi::WGPUSType_WGPUSType_SharedTextureMemoryMetalEndAccessState => {
2658 SType::SharedTextureMemoryMetalEndAccessState
2659 }
2660 ffi::WGPUSType_WGPUSType_AdapterPropertiesWGPU => {
2661 SType::AdapterPropertiesWGPU
2662 }
2663 ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor => {
2664 SType::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor
2665 }
2666 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D12ResourceDescriptor => {
2667 SType::SharedTextureMemoryD3D12ResourceDescriptor
2668 }
2669 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsAngleVirtualizationGroup => {
2670 SType::RequestAdapterOptionsAngleVirtualizationGroup
2671 }
2672 ffi::WGPUSType_WGPUSType_PipelineLayoutResourceTable => {
2673 SType::PipelineLayoutResourceTable
2674 }
2675 ffi::WGPUSType_WGPUSType_AdapterPropertiesExplicitComputeSubgroupSizeConfigs => {
2676 SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs
2677 }
2678 _ => SType::ShaderSourceSPIRV,
2679 }
2680 }
2681 }
2682 impl From<SType> for ffi::WGPUSType {
2683 fn from(value: SType) -> Self {
2684 match value {
2685 SType::ShaderSourceSPIRV => ffi::WGPUSType_WGPUSType_ShaderSourceSPIRV,
2686 SType::ShaderSourceWGSL => ffi::WGPUSType_WGPUSType_ShaderSourceWGSL,
2687 SType::RenderPassMaxDrawCount => {
2688 ffi::WGPUSType_WGPUSType_RenderPassMaxDrawCount
2689 }
2690 SType::SurfaceSourceMetalLayer => {
2691 ffi::WGPUSType_WGPUSType_SurfaceSourceMetalLayer
2692 }
2693 SType::SurfaceSourceWindowsHWND => {
2694 ffi::WGPUSType_WGPUSType_SurfaceSourceWindowsHWND
2695 }
2696 SType::SurfaceSourceXlibWindow => {
2697 ffi::WGPUSType_WGPUSType_SurfaceSourceXlibWindow
2698 }
2699 SType::SurfaceSourceWaylandSurface => {
2700 ffi::WGPUSType_WGPUSType_SurfaceSourceWaylandSurface
2701 }
2702 SType::SurfaceSourceAndroidNativeWindow => {
2703 ffi::WGPUSType_WGPUSType_SurfaceSourceAndroidNativeWindow
2704 }
2705 SType::SurfaceSourceXCBWindow => {
2706 ffi::WGPUSType_WGPUSType_SurfaceSourceXCBWindow
2707 }
2708 SType::SurfaceColorManagement => {
2709 ffi::WGPUSType_WGPUSType_SurfaceColorManagement
2710 }
2711 SType::RequestAdapterWebXROptions => {
2712 ffi::WGPUSType_WGPUSType_RequestAdapterWebXROptions
2713 }
2714 SType::TextureComponentSwizzleDescriptor => {
2715 ffi::WGPUSType_WGPUSType_TextureComponentSwizzleDescriptor
2716 }
2717 SType::CompatibilityModeLimits => {
2718 ffi::WGPUSType_WGPUSType_CompatibilityModeLimits
2719 }
2720 SType::TextureBindingViewDimensionDescriptor => {
2721 ffi::WGPUSType_WGPUSType_TextureBindingViewDimensionDescriptor
2722 }
2723 SType::EmscriptenSurfaceSourceCanvasHTMLSelector => {
2724 ffi::WGPUSType_WGPUSType_EmscriptenSurfaceSourceCanvasHTMLSelector
2725 }
2726 SType::SurfaceDescriptorFromWindowsCoreWindow => {
2727 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsCoreWindow
2728 }
2729 SType::ExternalTextureBindingEntry => {
2730 ffi::WGPUSType_WGPUSType_ExternalTextureBindingEntry
2731 }
2732 SType::ExternalTextureBindingLayout => {
2733 ffi::WGPUSType_WGPUSType_ExternalTextureBindingLayout
2734 }
2735 SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel => {
2736 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsUWPSwapChainPanel
2737 }
2738 SType::DawnTextureInternalUsageDescriptor => {
2739 ffi::WGPUSType_WGPUSType_DawnTextureInternalUsageDescriptor
2740 }
2741 SType::DawnEncoderInternalUsageDescriptor => {
2742 ffi::WGPUSType_WGPUSType_DawnEncoderInternalUsageDescriptor
2743 }
2744 SType::DawnInstanceDescriptor => {
2745 ffi::WGPUSType_WGPUSType_DawnInstanceDescriptor
2746 }
2747 SType::DawnCacheDeviceDescriptor => {
2748 ffi::WGPUSType_WGPUSType_DawnCacheDeviceDescriptor
2749 }
2750 SType::DawnAdapterPropertiesPowerPreference => {
2751 ffi::WGPUSType_WGPUSType_DawnAdapterPropertiesPowerPreference
2752 }
2753 SType::DawnBufferDescriptorErrorInfoFromWireClient => {
2754 ffi::WGPUSType_WGPUSType_DawnBufferDescriptorErrorInfoFromWireClient
2755 }
2756 SType::DawnTogglesDescriptor => {
2757 ffi::WGPUSType_WGPUSType_DawnTogglesDescriptor
2758 }
2759 SType::DawnShaderModuleSPIRVOptionsDescriptor => {
2760 ffi::WGPUSType_WGPUSType_DawnShaderModuleSPIRVOptionsDescriptor
2761 }
2762 SType::RequestAdapterOptionsLuid => {
2763 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsLUID
2764 }
2765 SType::RequestAdapterOptionsGetGlProc => {
2766 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsGetGLProc
2767 }
2768 SType::RequestAdapterOptionsD3D11Device => {
2769 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsD3D11Device
2770 }
2771 SType::DawnRenderPassSampleCount => {
2772 ffi::WGPUSType_WGPUSType_DawnRenderPassSampleCount
2773 }
2774 SType::RenderPassPixelLocalStorage => {
2775 ffi::WGPUSType_WGPUSType_RenderPassPixelLocalStorage
2776 }
2777 SType::PipelineLayoutPixelLocalStorage => {
2778 ffi::WGPUSType_WGPUSType_PipelineLayoutPixelLocalStorage
2779 }
2780 SType::BufferHostMappedPointer => {
2781 ffi::WGPUSType_WGPUSType_BufferHostMappedPointer
2782 }
2783 SType::AdapterPropertiesMemoryHeaps => {
2784 ffi::WGPUSType_WGPUSType_AdapterPropertiesMemoryHeaps
2785 }
2786 SType::AdapterPropertiesD3D => {
2787 ffi::WGPUSType_WGPUSType_AdapterPropertiesD3D
2788 }
2789 SType::AdapterPropertiesVk => {
2790 ffi::WGPUSType_WGPUSType_AdapterPropertiesVk
2791 }
2792 SType::DawnWireWGSLControl => {
2793 ffi::WGPUSType_WGPUSType_DawnWireWGSLControl
2794 }
2795 SType::DawnWGSLBlocklist => ffi::WGPUSType_WGPUSType_DawnWGSLBlocklist,
2796 SType::DawnDrmFormatCapabilities => {
2797 ffi::WGPUSType_WGPUSType_DawnDrmFormatCapabilities
2798 }
2799 SType::ShaderModuleCompilationOptions => {
2800 ffi::WGPUSType_WGPUSType_ShaderModuleCompilationOptions
2801 }
2802 SType::ColorTargetStateExpandResolveTextureDawn => {
2803 ffi::WGPUSType_WGPUSType_ColorTargetStateExpandResolveTextureDawn
2804 }
2805 SType::RenderPassDescriptorExpandResolveRect => {
2806 ffi::WGPUSType_WGPUSType_RenderPassDescriptorExpandResolveRect
2807 }
2808 SType::SharedTextureMemoryVkDedicatedAllocationDescriptor => {
2809 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkDedicatedAllocationDescriptor
2810 }
2811 SType::SharedTextureMemoryAHardwareBufferDescriptor => {
2812 ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferDescriptor
2813 }
2814 SType::SharedTextureMemoryDmaBufDescriptor => {
2815 ffi::WGPUSType_WGPUSType_SharedTextureMemoryDmaBufDescriptor
2816 }
2817 SType::SharedTextureMemoryOpaqueFDDescriptor => {
2818 ffi::WGPUSType_WGPUSType_SharedTextureMemoryOpaqueFDDescriptor
2819 }
2820 SType::SharedTextureMemoryZirconHandleDescriptor => {
2821 ffi::WGPUSType_WGPUSType_SharedTextureMemoryZirconHandleDescriptor
2822 }
2823 SType::SharedTextureMemoryDXGISharedHandleDescriptor => {
2824 ffi::WGPUSType_WGPUSType_SharedTextureMemoryDXGISharedHandleDescriptor
2825 }
2826 SType::SharedTextureMemoryD3D11Texture2DDescriptor => {
2827 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11Texture2DDescriptor
2828 }
2829 SType::SharedTextureMemoryIOSurfaceDescriptor => {
2830 ffi::WGPUSType_WGPUSType_SharedTextureMemoryIOSurfaceDescriptor
2831 }
2832 SType::SharedTextureMemoryEGLImageDescriptor => {
2833 ffi::WGPUSType_WGPUSType_SharedTextureMemoryEGLImageDescriptor
2834 }
2835 SType::SharedTextureMemoryInitializedBeginState => {
2836 ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedBeginState
2837 }
2838 SType::SharedTextureMemoryInitializedEndState => {
2839 ffi::WGPUSType_WGPUSType_SharedTextureMemoryInitializedEndState
2840 }
2841 SType::SharedTextureMemoryVkImageLayoutBeginState => {
2842 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutBeginState
2843 }
2844 SType::SharedTextureMemoryVkImageLayoutEndState => {
2845 ffi::WGPUSType_WGPUSType_SharedTextureMemoryVkImageLayoutEndState
2846 }
2847 SType::SharedTextureMemoryD3DSwapchainBeginState => {
2848 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3DSwapchainBeginState
2849 }
2850 SType::SharedFenceVkSemaphoreOpaqueFDDescriptor => {
2851 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDDescriptor
2852 }
2853 SType::SharedFenceVkSemaphoreOpaqueFDExportInfo => {
2854 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreOpaqueFDExportInfo
2855 }
2856 SType::SharedFenceSyncFDDescriptor => {
2857 ffi::WGPUSType_WGPUSType_SharedFenceSyncFDDescriptor
2858 }
2859 SType::SharedFenceSyncFDExportInfo => {
2860 ffi::WGPUSType_WGPUSType_SharedFenceSyncFDExportInfo
2861 }
2862 SType::SharedFenceVkSemaphoreZirconHandleDescriptor => {
2863 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleDescriptor
2864 }
2865 SType::SharedFenceVkSemaphoreZirconHandleExportInfo => {
2866 ffi::WGPUSType_WGPUSType_SharedFenceVkSemaphoreZirconHandleExportInfo
2867 }
2868 SType::SharedFenceDXGISharedHandleDescriptor => {
2869 ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleDescriptor
2870 }
2871 SType::SharedFenceDXGISharedHandleExportInfo => {
2872 ffi::WGPUSType_WGPUSType_SharedFenceDXGISharedHandleExportInfo
2873 }
2874 SType::SharedFenceMTLSharedEventDescriptor => {
2875 ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventDescriptor
2876 }
2877 SType::SharedFenceMTLSharedEventExportInfo => {
2878 ffi::WGPUSType_WGPUSType_SharedFenceMTLSharedEventExportInfo
2879 }
2880 SType::SharedBufferMemoryD3D12ResourceDescriptor => {
2881 ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12ResourceDescriptor
2882 }
2883 SType::StaticSamplerBindingLayout => {
2884 ffi::WGPUSType_WGPUSType_StaticSamplerBindingLayout
2885 }
2886 SType::YCbCrVkDescriptor => ffi::WGPUSType_WGPUSType_YCbCrVkDescriptor,
2887 SType::SharedTextureMemoryAHardwareBufferProperties => {
2888 ffi::WGPUSType_WGPUSType_SharedTextureMemoryAHardwareBufferProperties
2889 }
2890 SType::AHardwareBufferProperties => {
2891 ffi::WGPUSType_WGPUSType_AHardwareBufferProperties
2892 }
2893 SType::DawnTexelCopyBufferRowAlignmentLimits => {
2894 ffi::WGPUSType_WGPUSType_DawnTexelCopyBufferRowAlignmentLimits
2895 }
2896 SType::AdapterPropertiesSubgroupMatrixConfigs => {
2897 ffi::WGPUSType_WGPUSType_AdapterPropertiesSubgroupMatrixConfigs
2898 }
2899 SType::SharedFenceEGLSyncDescriptor => {
2900 ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncDescriptor
2901 }
2902 SType::SharedFenceEGLSyncExportInfo => {
2903 ffi::WGPUSType_WGPUSType_SharedFenceEGLSyncExportInfo
2904 }
2905 SType::DawnInjectedInvalidSType => {
2906 ffi::WGPUSType_WGPUSType_DawnInjectedInvalidSType
2907 }
2908 SType::DawnCompilationMessageUtf16 => {
2909 ffi::WGPUSType_WGPUSType_DawnCompilationMessageUtf16
2910 }
2911 SType::DawnFakeBufferOOMForTesting => {
2912 ffi::WGPUSType_WGPUSType_DawnFakeBufferOOMForTesting
2913 }
2914 SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel => {
2915 ffi::WGPUSType_WGPUSType_SurfaceDescriptorFromWindowsWinUISwapChainPanel
2916 }
2917 SType::DawnDeviceAllocatorControl => {
2918 ffi::WGPUSType_WGPUSType_DawnDeviceAllocatorControl
2919 }
2920 SType::DawnHostMappedPointerLimits => {
2921 ffi::WGPUSType_WGPUSType_DawnHostMappedPointerLimits
2922 }
2923 SType::RenderPassDescriptorResolveRect => {
2924 ffi::WGPUSType_WGPUSType_RenderPassDescriptorResolveRect
2925 }
2926 SType::RequestAdapterWebGPUBackendOptions => {
2927 ffi::WGPUSType_WGPUSType_RequestAdapterWebGPUBackendOptions
2928 }
2929 SType::DawnFakeDeviceInitializeErrorForTesting => {
2930 ffi::WGPUSType_WGPUSType_DawnFakeDeviceInitializeErrorForTesting
2931 }
2932 SType::SharedTextureMemoryD3D11BeginState => {
2933 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D11BeginState
2934 }
2935 SType::DawnConsumeAdapterDescriptor => {
2936 ffi::WGPUSType_WGPUSType_DawnConsumeAdapterDescriptor
2937 }
2938 SType::TexelBufferBindingEntry => {
2939 ffi::WGPUSType_WGPUSType_TexelBufferBindingEntry
2940 }
2941 SType::TexelBufferBindingLayout => {
2942 ffi::WGPUSType_WGPUSType_TexelBufferBindingLayout
2943 }
2944 SType::SharedTextureMemoryMetalEndAccessState => {
2945 ffi::WGPUSType_WGPUSType_SharedTextureMemoryMetalEndAccessState
2946 }
2947 SType::AdapterPropertiesWGPU => {
2948 ffi::WGPUSType_WGPUSType_AdapterPropertiesWGPU
2949 }
2950 SType::SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor => {
2951 ffi::WGPUSType_WGPUSType_SharedBufferMemoryD3D12SharedMemoryFileMappingHandleDescriptor
2952 }
2953 SType::SharedTextureMemoryD3D12ResourceDescriptor => {
2954 ffi::WGPUSType_WGPUSType_SharedTextureMemoryD3D12ResourceDescriptor
2955 }
2956 SType::RequestAdapterOptionsAngleVirtualizationGroup => {
2957 ffi::WGPUSType_WGPUSType_RequestAdapterOptionsAngleVirtualizationGroup
2958 }
2959 SType::PipelineLayoutResourceTable => {
2960 ffi::WGPUSType_WGPUSType_PipelineLayoutResourceTable
2961 }
2962 SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs => {
2963 ffi::WGPUSType_WGPUSType_AdapterPropertiesExplicitComputeSubgroupSizeConfigs
2964 }
2965 }
2966 }
2967 }
2968 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
2969 pub enum SamplerBindingType {
2970 BindingNotUsed,
2971 Undefined,
2972 Filtering,
2973 NonFiltering,
2974 Comparison,
2975 }
2976 impl From<ffi::WGPUSamplerBindingType> for SamplerBindingType {
2977 fn from(value: ffi::WGPUSamplerBindingType) -> Self {
2978 match value {
2979 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_BindingNotUsed => {
2980 SamplerBindingType::BindingNotUsed
2981 }
2982 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Undefined => {
2983 SamplerBindingType::Undefined
2984 }
2985 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Filtering => {
2986 SamplerBindingType::Filtering
2987 }
2988 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_NonFiltering => {
2989 SamplerBindingType::NonFiltering
2990 }
2991 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Comparison => {
2992 SamplerBindingType::Comparison
2993 }
2994 _ => SamplerBindingType::BindingNotUsed,
2995 }
2996 }
2997 }
2998 impl From<SamplerBindingType> for ffi::WGPUSamplerBindingType {
2999 fn from(value: SamplerBindingType) -> Self {
3000 match value {
3001 SamplerBindingType::BindingNotUsed => {
3002 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_BindingNotUsed
3003 }
3004 SamplerBindingType::Undefined => {
3005 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Undefined
3006 }
3007 SamplerBindingType::Filtering => {
3008 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Filtering
3009 }
3010 SamplerBindingType::NonFiltering => {
3011 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_NonFiltering
3012 }
3013 SamplerBindingType::Comparison => {
3014 ffi::WGPUSamplerBindingType_WGPUSamplerBindingType_Comparison
3015 }
3016 }
3017 }
3018 }
3019 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3020 pub enum SharedFenceType {
3021 VkSemaphoreOpaqueFD,
3022 SyncFD,
3023 VkSemaphoreZirconHandle,
3024 DXGISharedHandle,
3025 MTLSharedEvent,
3026 EGLSync,
3027 }
3028 impl From<ffi::WGPUSharedFenceType> for SharedFenceType {
3029 fn from(value: ffi::WGPUSharedFenceType) -> Self {
3030 match value {
3031 ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreOpaqueFD => {
3032 SharedFenceType::VkSemaphoreOpaqueFD
3033 }
3034 ffi::WGPUSharedFenceType_WGPUSharedFenceType_SyncFD => {
3035 SharedFenceType::SyncFD
3036 }
3037 ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreZirconHandle => {
3038 SharedFenceType::VkSemaphoreZirconHandle
3039 }
3040 ffi::WGPUSharedFenceType_WGPUSharedFenceType_DXGISharedHandle => {
3041 SharedFenceType::DXGISharedHandle
3042 }
3043 ffi::WGPUSharedFenceType_WGPUSharedFenceType_MTLSharedEvent => {
3044 SharedFenceType::MTLSharedEvent
3045 }
3046 ffi::WGPUSharedFenceType_WGPUSharedFenceType_EGLSync => {
3047 SharedFenceType::EGLSync
3048 }
3049 _ => SharedFenceType::VkSemaphoreOpaqueFD,
3050 }
3051 }
3052 }
3053 impl From<SharedFenceType> for ffi::WGPUSharedFenceType {
3054 fn from(value: SharedFenceType) -> Self {
3055 match value {
3056 SharedFenceType::VkSemaphoreOpaqueFD => {
3057 ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreOpaqueFD
3058 }
3059 SharedFenceType::SyncFD => {
3060 ffi::WGPUSharedFenceType_WGPUSharedFenceType_SyncFD
3061 }
3062 SharedFenceType::VkSemaphoreZirconHandle => {
3063 ffi::WGPUSharedFenceType_WGPUSharedFenceType_VkSemaphoreZirconHandle
3064 }
3065 SharedFenceType::DXGISharedHandle => {
3066 ffi::WGPUSharedFenceType_WGPUSharedFenceType_DXGISharedHandle
3067 }
3068 SharedFenceType::MTLSharedEvent => {
3069 ffi::WGPUSharedFenceType_WGPUSharedFenceType_MTLSharedEvent
3070 }
3071 SharedFenceType::EGLSync => {
3072 ffi::WGPUSharedFenceType_WGPUSharedFenceType_EGLSync
3073 }
3074 }
3075 }
3076 }
3077 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3078 pub enum Status {
3079 Success,
3080 Error,
3081 }
3082 impl From<ffi::WGPUStatus> for Status {
3083 fn from(value: ffi::WGPUStatus) -> Self {
3084 match value {
3085 ffi::WGPUStatus_WGPUStatus_Success => Status::Success,
3086 ffi::WGPUStatus_WGPUStatus_Error => Status::Error,
3087 _ => Status::Success,
3088 }
3089 }
3090 }
3091 impl From<Status> for ffi::WGPUStatus {
3092 fn from(value: Status) -> Self {
3093 match value {
3094 Status::Success => ffi::WGPUStatus_WGPUStatus_Success,
3095 Status::Error => ffi::WGPUStatus_WGPUStatus_Error,
3096 }
3097 }
3098 }
3099 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3100 pub enum StencilOperation {
3101 Undefined,
3102 Keep,
3103 Zero,
3104 Replace,
3105 Invert,
3106 IncrementClamp,
3107 DecrementClamp,
3108 IncrementWrap,
3109 DecrementWrap,
3110 }
3111 impl From<ffi::WGPUStencilOperation> for StencilOperation {
3112 fn from(value: ffi::WGPUStencilOperation) -> Self {
3113 match value {
3114 ffi::WGPUStencilOperation_WGPUStencilOperation_Undefined => {
3115 StencilOperation::Undefined
3116 }
3117 ffi::WGPUStencilOperation_WGPUStencilOperation_Keep => {
3118 StencilOperation::Keep
3119 }
3120 ffi::WGPUStencilOperation_WGPUStencilOperation_Zero => {
3121 StencilOperation::Zero
3122 }
3123 ffi::WGPUStencilOperation_WGPUStencilOperation_Replace => {
3124 StencilOperation::Replace
3125 }
3126 ffi::WGPUStencilOperation_WGPUStencilOperation_Invert => {
3127 StencilOperation::Invert
3128 }
3129 ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementClamp => {
3130 StencilOperation::IncrementClamp
3131 }
3132 ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementClamp => {
3133 StencilOperation::DecrementClamp
3134 }
3135 ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementWrap => {
3136 StencilOperation::IncrementWrap
3137 }
3138 ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementWrap => {
3139 StencilOperation::DecrementWrap
3140 }
3141 _ => StencilOperation::Undefined,
3142 }
3143 }
3144 }
3145 impl From<StencilOperation> for ffi::WGPUStencilOperation {
3146 fn from(value: StencilOperation) -> Self {
3147 match value {
3148 StencilOperation::Undefined => {
3149 ffi::WGPUStencilOperation_WGPUStencilOperation_Undefined
3150 }
3151 StencilOperation::Keep => {
3152 ffi::WGPUStencilOperation_WGPUStencilOperation_Keep
3153 }
3154 StencilOperation::Zero => {
3155 ffi::WGPUStencilOperation_WGPUStencilOperation_Zero
3156 }
3157 StencilOperation::Replace => {
3158 ffi::WGPUStencilOperation_WGPUStencilOperation_Replace
3159 }
3160 StencilOperation::Invert => {
3161 ffi::WGPUStencilOperation_WGPUStencilOperation_Invert
3162 }
3163 StencilOperation::IncrementClamp => {
3164 ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementClamp
3165 }
3166 StencilOperation::DecrementClamp => {
3167 ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementClamp
3168 }
3169 StencilOperation::IncrementWrap => {
3170 ffi::WGPUStencilOperation_WGPUStencilOperation_IncrementWrap
3171 }
3172 StencilOperation::DecrementWrap => {
3173 ffi::WGPUStencilOperation_WGPUStencilOperation_DecrementWrap
3174 }
3175 }
3176 }
3177 }
3178 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3179 pub enum StorageTextureAccess {
3180 BindingNotUsed,
3181 Undefined,
3182 WriteOnly,
3183 ReadOnly,
3184 ReadWrite,
3185 }
3186 impl From<ffi::WGPUStorageTextureAccess> for StorageTextureAccess {
3187 fn from(value: ffi::WGPUStorageTextureAccess) -> Self {
3188 match value {
3189 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_BindingNotUsed => {
3190 StorageTextureAccess::BindingNotUsed
3191 }
3192 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_Undefined => {
3193 StorageTextureAccess::Undefined
3194 }
3195 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_WriteOnly => {
3196 StorageTextureAccess::WriteOnly
3197 }
3198 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadOnly => {
3199 StorageTextureAccess::ReadOnly
3200 }
3201 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadWrite => {
3202 StorageTextureAccess::ReadWrite
3203 }
3204 _ => StorageTextureAccess::BindingNotUsed,
3205 }
3206 }
3207 }
3208 impl From<StorageTextureAccess> for ffi::WGPUStorageTextureAccess {
3209 fn from(value: StorageTextureAccess) -> Self {
3210 match value {
3211 StorageTextureAccess::BindingNotUsed => {
3212 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_BindingNotUsed
3213 }
3214 StorageTextureAccess::Undefined => {
3215 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_Undefined
3216 }
3217 StorageTextureAccess::WriteOnly => {
3218 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_WriteOnly
3219 }
3220 StorageTextureAccess::ReadOnly => {
3221 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadOnly
3222 }
3223 StorageTextureAccess::ReadWrite => {
3224 ffi::WGPUStorageTextureAccess_WGPUStorageTextureAccess_ReadWrite
3225 }
3226 }
3227 }
3228 }
3229 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3230 pub enum StoreOp {
3231 Undefined,
3232 Store,
3233 Discard,
3234 }
3235 impl From<ffi::WGPUStoreOp> for StoreOp {
3236 fn from(value: ffi::WGPUStoreOp) -> Self {
3237 match value {
3238 ffi::WGPUStoreOp_WGPUStoreOp_Undefined => StoreOp::Undefined,
3239 ffi::WGPUStoreOp_WGPUStoreOp_Store => StoreOp::Store,
3240 ffi::WGPUStoreOp_WGPUStoreOp_Discard => StoreOp::Discard,
3241 _ => StoreOp::Undefined,
3242 }
3243 }
3244 }
3245 impl From<StoreOp> for ffi::WGPUStoreOp {
3246 fn from(value: StoreOp) -> Self {
3247 match value {
3248 StoreOp::Undefined => ffi::WGPUStoreOp_WGPUStoreOp_Undefined,
3249 StoreOp::Store => ffi::WGPUStoreOp_WGPUStoreOp_Store,
3250 StoreOp::Discard => ffi::WGPUStoreOp_WGPUStoreOp_Discard,
3251 }
3252 }
3253 }
3254 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3255 pub enum SubgroupMatrixComponentType {
3256 F32,
3257 F16,
3258 U32,
3259 I32,
3260 U8,
3261 I8,
3262 }
3263 impl From<ffi::WGPUSubgroupMatrixComponentType> for SubgroupMatrixComponentType {
3264 fn from(value: ffi::WGPUSubgroupMatrixComponentType) -> Self {
3265 match value {
3266 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F32 => {
3267 SubgroupMatrixComponentType::F32
3268 }
3269 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F16 => {
3270 SubgroupMatrixComponentType::F16
3271 }
3272 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U32 => {
3273 SubgroupMatrixComponentType::U32
3274 }
3275 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I32 => {
3276 SubgroupMatrixComponentType::I32
3277 }
3278 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U8 => {
3279 SubgroupMatrixComponentType::U8
3280 }
3281 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I8 => {
3282 SubgroupMatrixComponentType::I8
3283 }
3284 _ => SubgroupMatrixComponentType::F32,
3285 }
3286 }
3287 }
3288 impl From<SubgroupMatrixComponentType> for ffi::WGPUSubgroupMatrixComponentType {
3289 fn from(value: SubgroupMatrixComponentType) -> Self {
3290 match value {
3291 SubgroupMatrixComponentType::F32 => {
3292 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F32
3293 }
3294 SubgroupMatrixComponentType::F16 => {
3295 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_F16
3296 }
3297 SubgroupMatrixComponentType::U32 => {
3298 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U32
3299 }
3300 SubgroupMatrixComponentType::I32 => {
3301 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I32
3302 }
3303 SubgroupMatrixComponentType::U8 => {
3304 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_U8
3305 }
3306 SubgroupMatrixComponentType::I8 => {
3307 ffi::WGPUSubgroupMatrixComponentType_WGPUSubgroupMatrixComponentType_I8
3308 }
3309 }
3310 }
3311 }
3312 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3313 pub enum SurfaceGetCurrentTextureStatus {
3314 SuccessOptimal,
3315 SuccessSuboptimal,
3316 Timeout,
3317 Outdated,
3318 Lost,
3319 Error,
3320 }
3321 impl From<ffi::WGPUSurfaceGetCurrentTextureStatus>
3322 for SurfaceGetCurrentTextureStatus {
3323 fn from(value: ffi::WGPUSurfaceGetCurrentTextureStatus) -> Self {
3324 match value {
3325 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal => {
3326 SurfaceGetCurrentTextureStatus::SuccessOptimal
3327 }
3328 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal => {
3329 SurfaceGetCurrentTextureStatus::SuccessSuboptimal
3330 }
3331 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Timeout => {
3332 SurfaceGetCurrentTextureStatus::Timeout
3333 }
3334 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Outdated => {
3335 SurfaceGetCurrentTextureStatus::Outdated
3336 }
3337 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Lost => {
3338 SurfaceGetCurrentTextureStatus::Lost
3339 }
3340 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Error => {
3341 SurfaceGetCurrentTextureStatus::Error
3342 }
3343 _ => SurfaceGetCurrentTextureStatus::SuccessOptimal,
3344 }
3345 }
3346 }
3347 impl From<SurfaceGetCurrentTextureStatus>
3348 for ffi::WGPUSurfaceGetCurrentTextureStatus {
3349 fn from(value: SurfaceGetCurrentTextureStatus) -> Self {
3350 match value {
3351 SurfaceGetCurrentTextureStatus::SuccessOptimal => {
3352 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessOptimal
3353 }
3354 SurfaceGetCurrentTextureStatus::SuccessSuboptimal => {
3355 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_SuccessSuboptimal
3356 }
3357 SurfaceGetCurrentTextureStatus::Timeout => {
3358 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Timeout
3359 }
3360 SurfaceGetCurrentTextureStatus::Outdated => {
3361 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Outdated
3362 }
3363 SurfaceGetCurrentTextureStatus::Lost => {
3364 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Lost
3365 }
3366 SurfaceGetCurrentTextureStatus::Error => {
3367 ffi::WGPUSurfaceGetCurrentTextureStatus_WGPUSurfaceGetCurrentTextureStatus_Error
3368 }
3369 }
3370 }
3371 }
3372 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3373 pub enum TexelBufferAccess {
3374 Undefined,
3375 ReadOnly,
3376 ReadWrite,
3377 }
3378 impl From<ffi::WGPUTexelBufferAccess> for TexelBufferAccess {
3379 fn from(value: ffi::WGPUTexelBufferAccess) -> Self {
3380 match value {
3381 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_Undefined => {
3382 TexelBufferAccess::Undefined
3383 }
3384 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadOnly => {
3385 TexelBufferAccess::ReadOnly
3386 }
3387 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadWrite => {
3388 TexelBufferAccess::ReadWrite
3389 }
3390 _ => TexelBufferAccess::Undefined,
3391 }
3392 }
3393 }
3394 impl From<TexelBufferAccess> for ffi::WGPUTexelBufferAccess {
3395 fn from(value: TexelBufferAccess) -> Self {
3396 match value {
3397 TexelBufferAccess::Undefined => {
3398 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_Undefined
3399 }
3400 TexelBufferAccess::ReadOnly => {
3401 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadOnly
3402 }
3403 TexelBufferAccess::ReadWrite => {
3404 ffi::WGPUTexelBufferAccess_WGPUTexelBufferAccess_ReadWrite
3405 }
3406 }
3407 }
3408 }
3409 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3410 pub enum TextureAspect {
3411 Undefined,
3412 All,
3413 StencilOnly,
3414 DepthOnly,
3415 Plane0Only,
3416 Plane1Only,
3417 Plane2Only,
3418 }
3419 impl From<ffi::WGPUTextureAspect> for TextureAspect {
3420 fn from(value: ffi::WGPUTextureAspect) -> Self {
3421 match value {
3422 ffi::WGPUTextureAspect_WGPUTextureAspect_Undefined => {
3423 TextureAspect::Undefined
3424 }
3425 ffi::WGPUTextureAspect_WGPUTextureAspect_All => TextureAspect::All,
3426 ffi::WGPUTextureAspect_WGPUTextureAspect_StencilOnly => {
3427 TextureAspect::StencilOnly
3428 }
3429 ffi::WGPUTextureAspect_WGPUTextureAspect_DepthOnly => {
3430 TextureAspect::DepthOnly
3431 }
3432 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane0Only => {
3433 TextureAspect::Plane0Only
3434 }
3435 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane1Only => {
3436 TextureAspect::Plane1Only
3437 }
3438 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane2Only => {
3439 TextureAspect::Plane2Only
3440 }
3441 _ => TextureAspect::Undefined,
3442 }
3443 }
3444 }
3445 impl From<TextureAspect> for ffi::WGPUTextureAspect {
3446 fn from(value: TextureAspect) -> Self {
3447 match value {
3448 TextureAspect::Undefined => {
3449 ffi::WGPUTextureAspect_WGPUTextureAspect_Undefined
3450 }
3451 TextureAspect::All => ffi::WGPUTextureAspect_WGPUTextureAspect_All,
3452 TextureAspect::StencilOnly => {
3453 ffi::WGPUTextureAspect_WGPUTextureAspect_StencilOnly
3454 }
3455 TextureAspect::DepthOnly => {
3456 ffi::WGPUTextureAspect_WGPUTextureAspect_DepthOnly
3457 }
3458 TextureAspect::Plane0Only => {
3459 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane0Only
3460 }
3461 TextureAspect::Plane1Only => {
3462 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane1Only
3463 }
3464 TextureAspect::Plane2Only => {
3465 ffi::WGPUTextureAspect_WGPUTextureAspect_Plane2Only
3466 }
3467 }
3468 }
3469 }
3470 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3471 pub enum TextureDimension {
3472 Undefined,
3473 D1,
3474 D2,
3475 D3,
3476 }
3477 impl From<ffi::WGPUTextureDimension> for TextureDimension {
3478 fn from(value: ffi::WGPUTextureDimension) -> Self {
3479 match value {
3480 ffi::WGPUTextureDimension_WGPUTextureDimension_Undefined => {
3481 TextureDimension::Undefined
3482 }
3483 ffi::WGPUTextureDimension_WGPUTextureDimension_1D => TextureDimension::D1,
3484 ffi::WGPUTextureDimension_WGPUTextureDimension_2D => TextureDimension::D2,
3485 ffi::WGPUTextureDimension_WGPUTextureDimension_3D => TextureDimension::D3,
3486 _ => TextureDimension::Undefined,
3487 }
3488 }
3489 }
3490 impl From<TextureDimension> for ffi::WGPUTextureDimension {
3491 fn from(value: TextureDimension) -> Self {
3492 match value {
3493 TextureDimension::Undefined => {
3494 ffi::WGPUTextureDimension_WGPUTextureDimension_Undefined
3495 }
3496 TextureDimension::D1 => ffi::WGPUTextureDimension_WGPUTextureDimension_1D,
3497 TextureDimension::D2 => ffi::WGPUTextureDimension_WGPUTextureDimension_2D,
3498 TextureDimension::D3 => ffi::WGPUTextureDimension_WGPUTextureDimension_3D,
3499 }
3500 }
3501 }
3502 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
3503 pub enum TextureFormat {
3504 Undefined,
3505 R8Unorm,
3506 R8Snorm,
3507 R8Uint,
3508 R8Sint,
3509 R16Unorm,
3510 R16Snorm,
3511 R16Uint,
3512 R16Sint,
3513 R16Float,
3514 Rg8Unorm,
3515 Rg8Snorm,
3516 Rg8Uint,
3517 Rg8Sint,
3518 R32Float,
3519 R32Uint,
3520 R32Sint,
3521 Rg16Unorm,
3522 Rg16Snorm,
3523 Rg16Uint,
3524 Rg16Sint,
3525 Rg16Float,
3526 Rgba8Unorm,
3527 Rgba8UnormSrgb,
3528 Rgba8Snorm,
3529 Rgba8Uint,
3530 Rgba8Sint,
3531 Bgra8Unorm,
3532 Bgra8UnormSrgb,
3533 Rgb10A2Uint,
3534 Rgb10A2Unorm,
3535 Rg11B10Ufloat,
3536 Rgb9E5Ufloat,
3537 Rg32Float,
3538 Rg32Uint,
3539 Rg32Sint,
3540 Rgba16Unorm,
3541 Rgba16Snorm,
3542 Rgba16Uint,
3543 Rgba16Sint,
3544 Rgba16Float,
3545 Rgba32Float,
3546 Rgba32Uint,
3547 Rgba32Sint,
3548 Stencil8,
3549 Depth16Unorm,
3550 Depth24Plus,
3551 Depth24PlusStencil8,
3552 Depth32Float,
3553 Depth32FloatStencil8,
3554 Bc1RgbaUnorm,
3555 Bc1RgbaUnormSrgb,
3556 Bc2RgbaUnorm,
3557 Bc2RgbaUnormSrgb,
3558 Bc3RgbaUnorm,
3559 Bc3RgbaUnormSrgb,
3560 Bc4RUnorm,
3561 Bc4RSnorm,
3562 Bc5RgUnorm,
3563 Bc5RgSnorm,
3564 Bc6HRgbUfloat,
3565 Bc6HRgbFloat,
3566 Bc7RgbaUnorm,
3567 Bc7RgbaUnormSrgb,
3568 Etc2Rgb8Unorm,
3569 Etc2Rgb8UnormSrgb,
3570 Etc2Rgb8A1Unorm,
3571 Etc2Rgb8A1UnormSrgb,
3572 Etc2Rgba8Unorm,
3573 Etc2Rgba8UnormSrgb,
3574 EacR11Unorm,
3575 EacR11Snorm,
3576 EacRg11Unorm,
3577 EacRg11Snorm,
3578 Astc4X4Unorm,
3579 Astc4X4UnormSrgb,
3580 Astc5X4Unorm,
3581 Astc5X4UnormSrgb,
3582 Astc5X5Unorm,
3583 Astc5X5UnormSrgb,
3584 Astc6X5Unorm,
3585 Astc6X5UnormSrgb,
3586 Astc6X6Unorm,
3587 Astc6X6UnormSrgb,
3588 Astc8X5Unorm,
3589 Astc8X5UnormSrgb,
3590 Astc8X6Unorm,
3591 Astc8X6UnormSrgb,
3592 Astc8X8Unorm,
3593 Astc8X8UnormSrgb,
3594 Astc10X5Unorm,
3595 Astc10X5UnormSrgb,
3596 Astc10X6Unorm,
3597 Astc10X6UnormSrgb,
3598 Astc10X8Unorm,
3599 Astc10X8UnormSrgb,
3600 Astc10X10Unorm,
3601 Astc10X10UnormSrgb,
3602 Astc12X10Unorm,
3603 Astc12X10UnormSrgb,
3604 Astc12X12Unorm,
3605 Astc12X12UnormSrgb,
3606 R8Bg8Biplanar420Unorm,
3607 R10X6Bg10X6Biplanar420Unorm,
3608 R8Bg8A8Triplanar420Unorm,
3609 R8Bg8Biplanar422Unorm,
3610 R8Bg8Biplanar444Unorm,
3611 R10X6Bg10X6Biplanar422Unorm,
3612 R10X6Bg10X6Biplanar444Unorm,
3613 External,
3614 OpaqueYCbCrAndroid,
3615 }
3616 impl From<ffi::WGPUTextureFormat> for TextureFormat {
3617 fn from(value: ffi::WGPUTextureFormat) -> Self {
3618 match value {
3619 ffi::WGPUTextureFormat_WGPUTextureFormat_Undefined => {
3620 TextureFormat::Undefined
3621 }
3622 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Unorm => {
3623 TextureFormat::R8Unorm
3624 }
3625 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Snorm => {
3626 TextureFormat::R8Snorm
3627 }
3628 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Uint => TextureFormat::R8Uint,
3629 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Sint => TextureFormat::R8Sint,
3630 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Unorm => {
3631 TextureFormat::R16Unorm
3632 }
3633 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Snorm => {
3634 TextureFormat::R16Snorm
3635 }
3636 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Uint => {
3637 TextureFormat::R16Uint
3638 }
3639 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Sint => {
3640 TextureFormat::R16Sint
3641 }
3642 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Float => {
3643 TextureFormat::R16Float
3644 }
3645 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Unorm => {
3646 TextureFormat::Rg8Unorm
3647 }
3648 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Snorm => {
3649 TextureFormat::Rg8Snorm
3650 }
3651 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Uint => {
3652 TextureFormat::Rg8Uint
3653 }
3654 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Sint => {
3655 TextureFormat::Rg8Sint
3656 }
3657 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Float => {
3658 TextureFormat::R32Float
3659 }
3660 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Uint => {
3661 TextureFormat::R32Uint
3662 }
3663 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Sint => {
3664 TextureFormat::R32Sint
3665 }
3666 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Unorm => {
3667 TextureFormat::Rg16Unorm
3668 }
3669 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Snorm => {
3670 TextureFormat::Rg16Snorm
3671 }
3672 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Uint => {
3673 TextureFormat::Rg16Uint
3674 }
3675 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Sint => {
3676 TextureFormat::Rg16Sint
3677 }
3678 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Float => {
3679 TextureFormat::Rg16Float
3680 }
3681 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Unorm => {
3682 TextureFormat::Rgba8Unorm
3683 }
3684 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8UnormSrgb => {
3685 TextureFormat::Rgba8UnormSrgb
3686 }
3687 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Snorm => {
3688 TextureFormat::Rgba8Snorm
3689 }
3690 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Uint => {
3691 TextureFormat::Rgba8Uint
3692 }
3693 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Sint => {
3694 TextureFormat::Rgba8Sint
3695 }
3696 ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8Unorm => {
3697 TextureFormat::Bgra8Unorm
3698 }
3699 ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8UnormSrgb => {
3700 TextureFormat::Bgra8UnormSrgb
3701 }
3702 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Uint => {
3703 TextureFormat::Rgb10A2Uint
3704 }
3705 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Unorm => {
3706 TextureFormat::Rgb10A2Unorm
3707 }
3708 ffi::WGPUTextureFormat_WGPUTextureFormat_RG11B10Ufloat => {
3709 TextureFormat::Rg11B10Ufloat
3710 }
3711 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB9E5Ufloat => {
3712 TextureFormat::Rgb9E5Ufloat
3713 }
3714 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Float => {
3715 TextureFormat::Rg32Float
3716 }
3717 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Uint => {
3718 TextureFormat::Rg32Uint
3719 }
3720 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Sint => {
3721 TextureFormat::Rg32Sint
3722 }
3723 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Unorm => {
3724 TextureFormat::Rgba16Unorm
3725 }
3726 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Snorm => {
3727 TextureFormat::Rgba16Snorm
3728 }
3729 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Uint => {
3730 TextureFormat::Rgba16Uint
3731 }
3732 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Sint => {
3733 TextureFormat::Rgba16Sint
3734 }
3735 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Float => {
3736 TextureFormat::Rgba16Float
3737 }
3738 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Float => {
3739 TextureFormat::Rgba32Float
3740 }
3741 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Uint => {
3742 TextureFormat::Rgba32Uint
3743 }
3744 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Sint => {
3745 TextureFormat::Rgba32Sint
3746 }
3747 ffi::WGPUTextureFormat_WGPUTextureFormat_Stencil8 => {
3748 TextureFormat::Stencil8
3749 }
3750 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth16Unorm => {
3751 TextureFormat::Depth16Unorm
3752 }
3753 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24Plus => {
3754 TextureFormat::Depth24Plus
3755 }
3756 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24PlusStencil8 => {
3757 TextureFormat::Depth24PlusStencil8
3758 }
3759 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32Float => {
3760 TextureFormat::Depth32Float
3761 }
3762 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32FloatStencil8 => {
3763 TextureFormat::Depth32FloatStencil8
3764 }
3765 ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnorm => {
3766 TextureFormat::Bc1RgbaUnorm
3767 }
3768 ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnormSrgb => {
3769 TextureFormat::Bc1RgbaUnormSrgb
3770 }
3771 ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnorm => {
3772 TextureFormat::Bc2RgbaUnorm
3773 }
3774 ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnormSrgb => {
3775 TextureFormat::Bc2RgbaUnormSrgb
3776 }
3777 ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnorm => {
3778 TextureFormat::Bc3RgbaUnorm
3779 }
3780 ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnormSrgb => {
3781 TextureFormat::Bc3RgbaUnormSrgb
3782 }
3783 ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RUnorm => {
3784 TextureFormat::Bc4RUnorm
3785 }
3786 ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RSnorm => {
3787 TextureFormat::Bc4RSnorm
3788 }
3789 ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGUnorm => {
3790 TextureFormat::Bc5RgUnorm
3791 }
3792 ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGSnorm => {
3793 TextureFormat::Bc5RgSnorm
3794 }
3795 ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBUfloat => {
3796 TextureFormat::Bc6HRgbUfloat
3797 }
3798 ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBFloat => {
3799 TextureFormat::Bc6HRgbFloat
3800 }
3801 ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnorm => {
3802 TextureFormat::Bc7RgbaUnorm
3803 }
3804 ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnormSrgb => {
3805 TextureFormat::Bc7RgbaUnormSrgb
3806 }
3807 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8Unorm => {
3808 TextureFormat::Etc2Rgb8Unorm
3809 }
3810 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8UnormSrgb => {
3811 TextureFormat::Etc2Rgb8UnormSrgb
3812 }
3813 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1Unorm => {
3814 TextureFormat::Etc2Rgb8A1Unorm
3815 }
3816 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1UnormSrgb => {
3817 TextureFormat::Etc2Rgb8A1UnormSrgb
3818 }
3819 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8Unorm => {
3820 TextureFormat::Etc2Rgba8Unorm
3821 }
3822 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8UnormSrgb => {
3823 TextureFormat::Etc2Rgba8UnormSrgb
3824 }
3825 ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Unorm => {
3826 TextureFormat::EacR11Unorm
3827 }
3828 ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Snorm => {
3829 TextureFormat::EacR11Snorm
3830 }
3831 ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Unorm => {
3832 TextureFormat::EacRg11Unorm
3833 }
3834 ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Snorm => {
3835 TextureFormat::EacRg11Snorm
3836 }
3837 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4Unorm => {
3838 TextureFormat::Astc4X4Unorm
3839 }
3840 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4UnormSrgb => {
3841 TextureFormat::Astc4X4UnormSrgb
3842 }
3843 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4Unorm => {
3844 TextureFormat::Astc5X4Unorm
3845 }
3846 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4UnormSrgb => {
3847 TextureFormat::Astc5X4UnormSrgb
3848 }
3849 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5Unorm => {
3850 TextureFormat::Astc5X5Unorm
3851 }
3852 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5UnormSrgb => {
3853 TextureFormat::Astc5X5UnormSrgb
3854 }
3855 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5Unorm => {
3856 TextureFormat::Astc6X5Unorm
3857 }
3858 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5UnormSrgb => {
3859 TextureFormat::Astc6X5UnormSrgb
3860 }
3861 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6Unorm => {
3862 TextureFormat::Astc6X6Unorm
3863 }
3864 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6UnormSrgb => {
3865 TextureFormat::Astc6X6UnormSrgb
3866 }
3867 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5Unorm => {
3868 TextureFormat::Astc8X5Unorm
3869 }
3870 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5UnormSrgb => {
3871 TextureFormat::Astc8X5UnormSrgb
3872 }
3873 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6Unorm => {
3874 TextureFormat::Astc8X6Unorm
3875 }
3876 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6UnormSrgb => {
3877 TextureFormat::Astc8X6UnormSrgb
3878 }
3879 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8Unorm => {
3880 TextureFormat::Astc8X8Unorm
3881 }
3882 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8UnormSrgb => {
3883 TextureFormat::Astc8X8UnormSrgb
3884 }
3885 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5Unorm => {
3886 TextureFormat::Astc10X5Unorm
3887 }
3888 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5UnormSrgb => {
3889 TextureFormat::Astc10X5UnormSrgb
3890 }
3891 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6Unorm => {
3892 TextureFormat::Astc10X6Unorm
3893 }
3894 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6UnormSrgb => {
3895 TextureFormat::Astc10X6UnormSrgb
3896 }
3897 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8Unorm => {
3898 TextureFormat::Astc10X8Unorm
3899 }
3900 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8UnormSrgb => {
3901 TextureFormat::Astc10X8UnormSrgb
3902 }
3903 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10Unorm => {
3904 TextureFormat::Astc10X10Unorm
3905 }
3906 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10UnormSrgb => {
3907 TextureFormat::Astc10X10UnormSrgb
3908 }
3909 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10Unorm => {
3910 TextureFormat::Astc12X10Unorm
3911 }
3912 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10UnormSrgb => {
3913 TextureFormat::Astc12X10UnormSrgb
3914 }
3915 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12Unorm => {
3916 TextureFormat::Astc12X12Unorm
3917 }
3918 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12UnormSrgb => {
3919 TextureFormat::Astc12X12UnormSrgb
3920 }
3921 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar420Unorm => {
3922 TextureFormat::R8Bg8Biplanar420Unorm
3923 }
3924 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar420Unorm => {
3925 TextureFormat::R10X6Bg10X6Biplanar420Unorm
3926 }
3927 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8A8Triplanar420Unorm => {
3928 TextureFormat::R8Bg8A8Triplanar420Unorm
3929 }
3930 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar422Unorm => {
3931 TextureFormat::R8Bg8Biplanar422Unorm
3932 }
3933 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar444Unorm => {
3934 TextureFormat::R8Bg8Biplanar444Unorm
3935 }
3936 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar422Unorm => {
3937 TextureFormat::R10X6Bg10X6Biplanar422Unorm
3938 }
3939 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar444Unorm => {
3940 TextureFormat::R10X6Bg10X6Biplanar444Unorm
3941 }
3942 ffi::WGPUTextureFormat_WGPUTextureFormat_External => {
3943 TextureFormat::External
3944 }
3945 ffi::WGPUTextureFormat_WGPUTextureFormat_OpaqueYCbCrAndroid => {
3946 TextureFormat::OpaqueYCbCrAndroid
3947 }
3948 _ => TextureFormat::Undefined,
3949 }
3950 }
3951 }
3952 impl From<TextureFormat> for ffi::WGPUTextureFormat {
3953 fn from(value: TextureFormat) -> Self {
3954 match value {
3955 TextureFormat::Undefined => {
3956 ffi::WGPUTextureFormat_WGPUTextureFormat_Undefined
3957 }
3958 TextureFormat::R8Unorm => {
3959 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Unorm
3960 }
3961 TextureFormat::R8Snorm => {
3962 ffi::WGPUTextureFormat_WGPUTextureFormat_R8Snorm
3963 }
3964 TextureFormat::R8Uint => ffi::WGPUTextureFormat_WGPUTextureFormat_R8Uint,
3965 TextureFormat::R8Sint => ffi::WGPUTextureFormat_WGPUTextureFormat_R8Sint,
3966 TextureFormat::R16Unorm => {
3967 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Unorm
3968 }
3969 TextureFormat::R16Snorm => {
3970 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Snorm
3971 }
3972 TextureFormat::R16Uint => {
3973 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Uint
3974 }
3975 TextureFormat::R16Sint => {
3976 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Sint
3977 }
3978 TextureFormat::R16Float => {
3979 ffi::WGPUTextureFormat_WGPUTextureFormat_R16Float
3980 }
3981 TextureFormat::Rg8Unorm => {
3982 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Unorm
3983 }
3984 TextureFormat::Rg8Snorm => {
3985 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Snorm
3986 }
3987 TextureFormat::Rg8Uint => {
3988 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Uint
3989 }
3990 TextureFormat::Rg8Sint => {
3991 ffi::WGPUTextureFormat_WGPUTextureFormat_RG8Sint
3992 }
3993 TextureFormat::R32Float => {
3994 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Float
3995 }
3996 TextureFormat::R32Uint => {
3997 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Uint
3998 }
3999 TextureFormat::R32Sint => {
4000 ffi::WGPUTextureFormat_WGPUTextureFormat_R32Sint
4001 }
4002 TextureFormat::Rg16Unorm => {
4003 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Unorm
4004 }
4005 TextureFormat::Rg16Snorm => {
4006 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Snorm
4007 }
4008 TextureFormat::Rg16Uint => {
4009 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Uint
4010 }
4011 TextureFormat::Rg16Sint => {
4012 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Sint
4013 }
4014 TextureFormat::Rg16Float => {
4015 ffi::WGPUTextureFormat_WGPUTextureFormat_RG16Float
4016 }
4017 TextureFormat::Rgba8Unorm => {
4018 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Unorm
4019 }
4020 TextureFormat::Rgba8UnormSrgb => {
4021 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8UnormSrgb
4022 }
4023 TextureFormat::Rgba8Snorm => {
4024 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Snorm
4025 }
4026 TextureFormat::Rgba8Uint => {
4027 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Uint
4028 }
4029 TextureFormat::Rgba8Sint => {
4030 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA8Sint
4031 }
4032 TextureFormat::Bgra8Unorm => {
4033 ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8Unorm
4034 }
4035 TextureFormat::Bgra8UnormSrgb => {
4036 ffi::WGPUTextureFormat_WGPUTextureFormat_BGRA8UnormSrgb
4037 }
4038 TextureFormat::Rgb10A2Uint => {
4039 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Uint
4040 }
4041 TextureFormat::Rgb10A2Unorm => {
4042 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB10A2Unorm
4043 }
4044 TextureFormat::Rg11B10Ufloat => {
4045 ffi::WGPUTextureFormat_WGPUTextureFormat_RG11B10Ufloat
4046 }
4047 TextureFormat::Rgb9E5Ufloat => {
4048 ffi::WGPUTextureFormat_WGPUTextureFormat_RGB9E5Ufloat
4049 }
4050 TextureFormat::Rg32Float => {
4051 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Float
4052 }
4053 TextureFormat::Rg32Uint => {
4054 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Uint
4055 }
4056 TextureFormat::Rg32Sint => {
4057 ffi::WGPUTextureFormat_WGPUTextureFormat_RG32Sint
4058 }
4059 TextureFormat::Rgba16Unorm => {
4060 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Unorm
4061 }
4062 TextureFormat::Rgba16Snorm => {
4063 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Snorm
4064 }
4065 TextureFormat::Rgba16Uint => {
4066 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Uint
4067 }
4068 TextureFormat::Rgba16Sint => {
4069 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Sint
4070 }
4071 TextureFormat::Rgba16Float => {
4072 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA16Float
4073 }
4074 TextureFormat::Rgba32Float => {
4075 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Float
4076 }
4077 TextureFormat::Rgba32Uint => {
4078 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Uint
4079 }
4080 TextureFormat::Rgba32Sint => {
4081 ffi::WGPUTextureFormat_WGPUTextureFormat_RGBA32Sint
4082 }
4083 TextureFormat::Stencil8 => {
4084 ffi::WGPUTextureFormat_WGPUTextureFormat_Stencil8
4085 }
4086 TextureFormat::Depth16Unorm => {
4087 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth16Unorm
4088 }
4089 TextureFormat::Depth24Plus => {
4090 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24Plus
4091 }
4092 TextureFormat::Depth24PlusStencil8 => {
4093 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth24PlusStencil8
4094 }
4095 TextureFormat::Depth32Float => {
4096 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32Float
4097 }
4098 TextureFormat::Depth32FloatStencil8 => {
4099 ffi::WGPUTextureFormat_WGPUTextureFormat_Depth32FloatStencil8
4100 }
4101 TextureFormat::Bc1RgbaUnorm => {
4102 ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnorm
4103 }
4104 TextureFormat::Bc1RgbaUnormSrgb => {
4105 ffi::WGPUTextureFormat_WGPUTextureFormat_BC1RGBAUnormSrgb
4106 }
4107 TextureFormat::Bc2RgbaUnorm => {
4108 ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnorm
4109 }
4110 TextureFormat::Bc2RgbaUnormSrgb => {
4111 ffi::WGPUTextureFormat_WGPUTextureFormat_BC2RGBAUnormSrgb
4112 }
4113 TextureFormat::Bc3RgbaUnorm => {
4114 ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnorm
4115 }
4116 TextureFormat::Bc3RgbaUnormSrgb => {
4117 ffi::WGPUTextureFormat_WGPUTextureFormat_BC3RGBAUnormSrgb
4118 }
4119 TextureFormat::Bc4RUnorm => {
4120 ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RUnorm
4121 }
4122 TextureFormat::Bc4RSnorm => {
4123 ffi::WGPUTextureFormat_WGPUTextureFormat_BC4RSnorm
4124 }
4125 TextureFormat::Bc5RgUnorm => {
4126 ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGUnorm
4127 }
4128 TextureFormat::Bc5RgSnorm => {
4129 ffi::WGPUTextureFormat_WGPUTextureFormat_BC5RGSnorm
4130 }
4131 TextureFormat::Bc6HRgbUfloat => {
4132 ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBUfloat
4133 }
4134 TextureFormat::Bc6HRgbFloat => {
4135 ffi::WGPUTextureFormat_WGPUTextureFormat_BC6HRGBFloat
4136 }
4137 TextureFormat::Bc7RgbaUnorm => {
4138 ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnorm
4139 }
4140 TextureFormat::Bc7RgbaUnormSrgb => {
4141 ffi::WGPUTextureFormat_WGPUTextureFormat_BC7RGBAUnormSrgb
4142 }
4143 TextureFormat::Etc2Rgb8Unorm => {
4144 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8Unorm
4145 }
4146 TextureFormat::Etc2Rgb8UnormSrgb => {
4147 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8UnormSrgb
4148 }
4149 TextureFormat::Etc2Rgb8A1Unorm => {
4150 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1Unorm
4151 }
4152 TextureFormat::Etc2Rgb8A1UnormSrgb => {
4153 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGB8A1UnormSrgb
4154 }
4155 TextureFormat::Etc2Rgba8Unorm => {
4156 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8Unorm
4157 }
4158 TextureFormat::Etc2Rgba8UnormSrgb => {
4159 ffi::WGPUTextureFormat_WGPUTextureFormat_ETC2RGBA8UnormSrgb
4160 }
4161 TextureFormat::EacR11Unorm => {
4162 ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Unorm
4163 }
4164 TextureFormat::EacR11Snorm => {
4165 ffi::WGPUTextureFormat_WGPUTextureFormat_EACR11Snorm
4166 }
4167 TextureFormat::EacRg11Unorm => {
4168 ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Unorm
4169 }
4170 TextureFormat::EacRg11Snorm => {
4171 ffi::WGPUTextureFormat_WGPUTextureFormat_EACRG11Snorm
4172 }
4173 TextureFormat::Astc4X4Unorm => {
4174 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4Unorm
4175 }
4176 TextureFormat::Astc4X4UnormSrgb => {
4177 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC4x4UnormSrgb
4178 }
4179 TextureFormat::Astc5X4Unorm => {
4180 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4Unorm
4181 }
4182 TextureFormat::Astc5X4UnormSrgb => {
4183 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x4UnormSrgb
4184 }
4185 TextureFormat::Astc5X5Unorm => {
4186 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5Unorm
4187 }
4188 TextureFormat::Astc5X5UnormSrgb => {
4189 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC5x5UnormSrgb
4190 }
4191 TextureFormat::Astc6X5Unorm => {
4192 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5Unorm
4193 }
4194 TextureFormat::Astc6X5UnormSrgb => {
4195 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x5UnormSrgb
4196 }
4197 TextureFormat::Astc6X6Unorm => {
4198 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6Unorm
4199 }
4200 TextureFormat::Astc6X6UnormSrgb => {
4201 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC6x6UnormSrgb
4202 }
4203 TextureFormat::Astc8X5Unorm => {
4204 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5Unorm
4205 }
4206 TextureFormat::Astc8X5UnormSrgb => {
4207 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x5UnormSrgb
4208 }
4209 TextureFormat::Astc8X6Unorm => {
4210 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6Unorm
4211 }
4212 TextureFormat::Astc8X6UnormSrgb => {
4213 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x6UnormSrgb
4214 }
4215 TextureFormat::Astc8X8Unorm => {
4216 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8Unorm
4217 }
4218 TextureFormat::Astc8X8UnormSrgb => {
4219 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC8x8UnormSrgb
4220 }
4221 TextureFormat::Astc10X5Unorm => {
4222 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5Unorm
4223 }
4224 TextureFormat::Astc10X5UnormSrgb => {
4225 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x5UnormSrgb
4226 }
4227 TextureFormat::Astc10X6Unorm => {
4228 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6Unorm
4229 }
4230 TextureFormat::Astc10X6UnormSrgb => {
4231 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x6UnormSrgb
4232 }
4233 TextureFormat::Astc10X8Unorm => {
4234 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8Unorm
4235 }
4236 TextureFormat::Astc10X8UnormSrgb => {
4237 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x8UnormSrgb
4238 }
4239 TextureFormat::Astc10X10Unorm => {
4240 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10Unorm
4241 }
4242 TextureFormat::Astc10X10UnormSrgb => {
4243 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC10x10UnormSrgb
4244 }
4245 TextureFormat::Astc12X10Unorm => {
4246 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10Unorm
4247 }
4248 TextureFormat::Astc12X10UnormSrgb => {
4249 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x10UnormSrgb
4250 }
4251 TextureFormat::Astc12X12Unorm => {
4252 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12Unorm
4253 }
4254 TextureFormat::Astc12X12UnormSrgb => {
4255 ffi::WGPUTextureFormat_WGPUTextureFormat_ASTC12x12UnormSrgb
4256 }
4257 TextureFormat::R8Bg8Biplanar420Unorm => {
4258 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar420Unorm
4259 }
4260 TextureFormat::R10X6Bg10X6Biplanar420Unorm => {
4261 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar420Unorm
4262 }
4263 TextureFormat::R8Bg8A8Triplanar420Unorm => {
4264 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8A8Triplanar420Unorm
4265 }
4266 TextureFormat::R8Bg8Biplanar422Unorm => {
4267 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar422Unorm
4268 }
4269 TextureFormat::R8Bg8Biplanar444Unorm => {
4270 ffi::WGPUTextureFormat_WGPUTextureFormat_R8BG8Biplanar444Unorm
4271 }
4272 TextureFormat::R10X6Bg10X6Biplanar422Unorm => {
4273 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar422Unorm
4274 }
4275 TextureFormat::R10X6Bg10X6Biplanar444Unorm => {
4276 ffi::WGPUTextureFormat_WGPUTextureFormat_R10X6BG10X6Biplanar444Unorm
4277 }
4278 TextureFormat::External => {
4279 ffi::WGPUTextureFormat_WGPUTextureFormat_External
4280 }
4281 TextureFormat::OpaqueYCbCrAndroid => {
4282 ffi::WGPUTextureFormat_WGPUTextureFormat_OpaqueYCbCrAndroid
4283 }
4284 }
4285 }
4286 }
4287 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4288 pub enum TextureSampleType {
4289 BindingNotUsed,
4290 Undefined,
4291 Float,
4292 UnfilterableFloat,
4293 Depth,
4294 Sint,
4295 Uint,
4296 }
4297 impl From<ffi::WGPUTextureSampleType> for TextureSampleType {
4298 fn from(value: ffi::WGPUTextureSampleType) -> Self {
4299 match value {
4300 ffi::WGPUTextureSampleType_WGPUTextureSampleType_BindingNotUsed => {
4301 TextureSampleType::BindingNotUsed
4302 }
4303 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Undefined => {
4304 TextureSampleType::Undefined
4305 }
4306 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Float => {
4307 TextureSampleType::Float
4308 }
4309 ffi::WGPUTextureSampleType_WGPUTextureSampleType_UnfilterableFloat => {
4310 TextureSampleType::UnfilterableFloat
4311 }
4312 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Depth => {
4313 TextureSampleType::Depth
4314 }
4315 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Sint => {
4316 TextureSampleType::Sint
4317 }
4318 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Uint => {
4319 TextureSampleType::Uint
4320 }
4321 _ => TextureSampleType::BindingNotUsed,
4322 }
4323 }
4324 }
4325 impl From<TextureSampleType> for ffi::WGPUTextureSampleType {
4326 fn from(value: TextureSampleType) -> Self {
4327 match value {
4328 TextureSampleType::BindingNotUsed => {
4329 ffi::WGPUTextureSampleType_WGPUTextureSampleType_BindingNotUsed
4330 }
4331 TextureSampleType::Undefined => {
4332 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Undefined
4333 }
4334 TextureSampleType::Float => {
4335 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Float
4336 }
4337 TextureSampleType::UnfilterableFloat => {
4338 ffi::WGPUTextureSampleType_WGPUTextureSampleType_UnfilterableFloat
4339 }
4340 TextureSampleType::Depth => {
4341 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Depth
4342 }
4343 TextureSampleType::Sint => {
4344 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Sint
4345 }
4346 TextureSampleType::Uint => {
4347 ffi::WGPUTextureSampleType_WGPUTextureSampleType_Uint
4348 }
4349 }
4350 }
4351 }
4352 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4353 pub enum TextureViewDimension {
4354 Undefined,
4355 D1,
4356 D2,
4357 D2Array,
4358 Cube,
4359 CubeArray,
4360 D3,
4361 }
4362 impl From<ffi::WGPUTextureViewDimension> for TextureViewDimension {
4363 fn from(value: ffi::WGPUTextureViewDimension) -> Self {
4364 match value {
4365 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Undefined => {
4366 TextureViewDimension::Undefined
4367 }
4368 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_1D => {
4369 TextureViewDimension::D1
4370 }
4371 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2D => {
4372 TextureViewDimension::D2
4373 }
4374 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2DArray => {
4375 TextureViewDimension::D2Array
4376 }
4377 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Cube => {
4378 TextureViewDimension::Cube
4379 }
4380 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_CubeArray => {
4381 TextureViewDimension::CubeArray
4382 }
4383 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_3D => {
4384 TextureViewDimension::D3
4385 }
4386 _ => TextureViewDimension::Undefined,
4387 }
4388 }
4389 }
4390 impl From<TextureViewDimension> for ffi::WGPUTextureViewDimension {
4391 fn from(value: TextureViewDimension) -> Self {
4392 match value {
4393 TextureViewDimension::Undefined => {
4394 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Undefined
4395 }
4396 TextureViewDimension::D1 => {
4397 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_1D
4398 }
4399 TextureViewDimension::D2 => {
4400 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2D
4401 }
4402 TextureViewDimension::D2Array => {
4403 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_2DArray
4404 }
4405 TextureViewDimension::Cube => {
4406 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_Cube
4407 }
4408 TextureViewDimension::CubeArray => {
4409 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_CubeArray
4410 }
4411 TextureViewDimension::D3 => {
4412 ffi::WGPUTextureViewDimension_WGPUTextureViewDimension_3D
4413 }
4414 }
4415 }
4416 }
4417 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4418 pub enum ToneMappingMode {
4419 Standard,
4420 Extended,
4421 }
4422 impl From<ffi::WGPUToneMappingMode> for ToneMappingMode {
4423 fn from(value: ffi::WGPUToneMappingMode) -> Self {
4424 match value {
4425 ffi::WGPUToneMappingMode_WGPUToneMappingMode_Standard => {
4426 ToneMappingMode::Standard
4427 }
4428 ffi::WGPUToneMappingMode_WGPUToneMappingMode_Extended => {
4429 ToneMappingMode::Extended
4430 }
4431 _ => ToneMappingMode::Standard,
4432 }
4433 }
4434 }
4435 impl From<ToneMappingMode> for ffi::WGPUToneMappingMode {
4436 fn from(value: ToneMappingMode) -> Self {
4437 match value {
4438 ToneMappingMode::Standard => {
4439 ffi::WGPUToneMappingMode_WGPUToneMappingMode_Standard
4440 }
4441 ToneMappingMode::Extended => {
4442 ffi::WGPUToneMappingMode_WGPUToneMappingMode_Extended
4443 }
4444 }
4445 }
4446 }
4447 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4448 pub enum VertexFormat {
4449 Uint8,
4450 Uint8X2,
4451 Uint8X4,
4452 Sint8,
4453 Sint8X2,
4454 Sint8X4,
4455 Unorm8,
4456 Unorm8X2,
4457 Unorm8X4,
4458 Snorm8,
4459 Snorm8X2,
4460 Snorm8X4,
4461 Uint16,
4462 Uint16X2,
4463 Uint16X4,
4464 Sint16,
4465 Sint16X2,
4466 Sint16X4,
4467 Unorm16,
4468 Unorm16X2,
4469 Unorm16X4,
4470 Snorm16,
4471 Snorm16X2,
4472 Snorm16X4,
4473 Float16,
4474 Float16X2,
4475 Float16X4,
4476 Float32,
4477 Float32X2,
4478 Float32X3,
4479 Float32X4,
4480 Uint32,
4481 Uint32X2,
4482 Uint32X3,
4483 Uint32X4,
4484 Sint32,
4485 Sint32X2,
4486 Sint32X3,
4487 Sint32X4,
4488 Unorm1010102,
4489 Unorm8X4Bgra,
4490 }
4491 impl From<ffi::WGPUVertexFormat> for VertexFormat {
4492 fn from(value: ffi::WGPUVertexFormat) -> Self {
4493 match value {
4494 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8 => VertexFormat::Uint8,
4495 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x2 => VertexFormat::Uint8X2,
4496 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x4 => VertexFormat::Uint8X4,
4497 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8 => VertexFormat::Sint8,
4498 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x2 => VertexFormat::Sint8X2,
4499 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x4 => VertexFormat::Sint8X4,
4500 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8 => VertexFormat::Unorm8,
4501 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x2 => VertexFormat::Unorm8X2,
4502 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4 => VertexFormat::Unorm8X4,
4503 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8 => VertexFormat::Snorm8,
4504 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x2 => VertexFormat::Snorm8X2,
4505 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x4 => VertexFormat::Snorm8X4,
4506 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16 => VertexFormat::Uint16,
4507 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x2 => VertexFormat::Uint16X2,
4508 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x4 => VertexFormat::Uint16X4,
4509 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16 => VertexFormat::Sint16,
4510 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x2 => VertexFormat::Sint16X2,
4511 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x4 => VertexFormat::Sint16X4,
4512 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16 => VertexFormat::Unorm16,
4513 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x2 => {
4514 VertexFormat::Unorm16X2
4515 }
4516 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x4 => {
4517 VertexFormat::Unorm16X4
4518 }
4519 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16 => VertexFormat::Snorm16,
4520 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x2 => {
4521 VertexFormat::Snorm16X2
4522 }
4523 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x4 => {
4524 VertexFormat::Snorm16X4
4525 }
4526 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16 => VertexFormat::Float16,
4527 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x2 => {
4528 VertexFormat::Float16X2
4529 }
4530 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x4 => {
4531 VertexFormat::Float16X4
4532 }
4533 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32 => VertexFormat::Float32,
4534 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x2 => {
4535 VertexFormat::Float32X2
4536 }
4537 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x3 => {
4538 VertexFormat::Float32X3
4539 }
4540 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x4 => {
4541 VertexFormat::Float32X4
4542 }
4543 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32 => VertexFormat::Uint32,
4544 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x2 => VertexFormat::Uint32X2,
4545 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x3 => VertexFormat::Uint32X3,
4546 ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x4 => VertexFormat::Uint32X4,
4547 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32 => VertexFormat::Sint32,
4548 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x2 => VertexFormat::Sint32X2,
4549 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x3 => VertexFormat::Sint32X3,
4550 ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x4 => VertexFormat::Sint32X4,
4551 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm10_10_10_2 => {
4552 VertexFormat::Unorm1010102
4553 }
4554 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4BGRA => {
4555 VertexFormat::Unorm8X4Bgra
4556 }
4557 _ => VertexFormat::Uint8,
4558 }
4559 }
4560 }
4561 impl From<VertexFormat> for ffi::WGPUVertexFormat {
4562 fn from(value: VertexFormat) -> Self {
4563 match value {
4564 VertexFormat::Uint8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8,
4565 VertexFormat::Uint8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x2,
4566 VertexFormat::Uint8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint8x4,
4567 VertexFormat::Sint8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8,
4568 VertexFormat::Sint8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x2,
4569 VertexFormat::Sint8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint8x4,
4570 VertexFormat::Unorm8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8,
4571 VertexFormat::Unorm8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x2,
4572 VertexFormat::Unorm8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4,
4573 VertexFormat::Snorm8 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8,
4574 VertexFormat::Snorm8X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x2,
4575 VertexFormat::Snorm8X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm8x4,
4576 VertexFormat::Uint16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16,
4577 VertexFormat::Uint16X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x2,
4578 VertexFormat::Uint16X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint16x4,
4579 VertexFormat::Sint16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16,
4580 VertexFormat::Sint16X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x2,
4581 VertexFormat::Sint16X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint16x4,
4582 VertexFormat::Unorm16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16,
4583 VertexFormat::Unorm16X2 => {
4584 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x2
4585 }
4586 VertexFormat::Unorm16X4 => {
4587 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm16x4
4588 }
4589 VertexFormat::Snorm16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16,
4590 VertexFormat::Snorm16X2 => {
4591 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x2
4592 }
4593 VertexFormat::Snorm16X4 => {
4594 ffi::WGPUVertexFormat_WGPUVertexFormat_Snorm16x4
4595 }
4596 VertexFormat::Float16 => ffi::WGPUVertexFormat_WGPUVertexFormat_Float16,
4597 VertexFormat::Float16X2 => {
4598 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x2
4599 }
4600 VertexFormat::Float16X4 => {
4601 ffi::WGPUVertexFormat_WGPUVertexFormat_Float16x4
4602 }
4603 VertexFormat::Float32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Float32,
4604 VertexFormat::Float32X2 => {
4605 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x2
4606 }
4607 VertexFormat::Float32X3 => {
4608 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x3
4609 }
4610 VertexFormat::Float32X4 => {
4611 ffi::WGPUVertexFormat_WGPUVertexFormat_Float32x4
4612 }
4613 VertexFormat::Uint32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32,
4614 VertexFormat::Uint32X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x2,
4615 VertexFormat::Uint32X3 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x3,
4616 VertexFormat::Uint32X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Uint32x4,
4617 VertexFormat::Sint32 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32,
4618 VertexFormat::Sint32X2 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x2,
4619 VertexFormat::Sint32X3 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x3,
4620 VertexFormat::Sint32X4 => ffi::WGPUVertexFormat_WGPUVertexFormat_Sint32x4,
4621 VertexFormat::Unorm1010102 => {
4622 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm10_10_10_2
4623 }
4624 VertexFormat::Unorm8X4Bgra => {
4625 ffi::WGPUVertexFormat_WGPUVertexFormat_Unorm8x4BGRA
4626 }
4627 }
4628 }
4629 }
4630 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4631 pub enum VertexStepMode {
4632 Undefined,
4633 Vertex,
4634 Instance,
4635 }
4636 impl From<ffi::WGPUVertexStepMode> for VertexStepMode {
4637 fn from(value: ffi::WGPUVertexStepMode) -> Self {
4638 match value {
4639 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Undefined => {
4640 VertexStepMode::Undefined
4641 }
4642 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Vertex => {
4643 VertexStepMode::Vertex
4644 }
4645 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Instance => {
4646 VertexStepMode::Instance
4647 }
4648 _ => VertexStepMode::Undefined,
4649 }
4650 }
4651 }
4652 impl From<VertexStepMode> for ffi::WGPUVertexStepMode {
4653 fn from(value: VertexStepMode) -> Self {
4654 match value {
4655 VertexStepMode::Undefined => {
4656 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Undefined
4657 }
4658 VertexStepMode::Vertex => {
4659 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Vertex
4660 }
4661 VertexStepMode::Instance => {
4662 ffi::WGPUVertexStepMode_WGPUVertexStepMode_Instance
4663 }
4664 }
4665 }
4666 }
4667 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
4668 pub enum WaitStatus {
4669 Success,
4670 TimedOut,
4671 Error,
4672 }
4673 impl From<ffi::WGPUWaitStatus> for WaitStatus {
4674 fn from(value: ffi::WGPUWaitStatus) -> Self {
4675 match value {
4676 ffi::WGPUWaitStatus_WGPUWaitStatus_Success => WaitStatus::Success,
4677 ffi::WGPUWaitStatus_WGPUWaitStatus_TimedOut => WaitStatus::TimedOut,
4678 ffi::WGPUWaitStatus_WGPUWaitStatus_Error => WaitStatus::Error,
4679 _ => WaitStatus::Success,
4680 }
4681 }
4682 }
4683 impl From<WaitStatus> for ffi::WGPUWaitStatus {
4684 fn from(value: WaitStatus) -> Self {
4685 match value {
4686 WaitStatus::Success => ffi::WGPUWaitStatus_WGPUWaitStatus_Success,
4687 WaitStatus::TimedOut => ffi::WGPUWaitStatus_WGPUWaitStatus_TimedOut,
4688 WaitStatus::Error => ffi::WGPUWaitStatus_WGPUWaitStatus_Error,
4689 }
4690 }
4691 }
4692 bitflags! {
4693 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct BufferUsage : u64 {
4694 const NONE = ffi::WGPUBufferUsage_None as u64; const MAP_READ =
4695 ffi::WGPUBufferUsage_MapRead as u64; const MAP_WRITE =
4696 ffi::WGPUBufferUsage_MapWrite as u64; const COPY_SRC =
4697 ffi::WGPUBufferUsage_CopySrc as u64; const COPY_DST =
4698 ffi::WGPUBufferUsage_CopyDst as u64; const INDEX = ffi::WGPUBufferUsage_Index as
4699 u64; const VERTEX = ffi::WGPUBufferUsage_Vertex as u64; const UNIFORM =
4700 ffi::WGPUBufferUsage_Uniform as u64; const STORAGE = ffi::WGPUBufferUsage_Storage
4701 as u64; const INDIRECT = ffi::WGPUBufferUsage_Indirect as u64; const
4702 QUERY_RESOLVE = ffi::WGPUBufferUsage_QueryResolve as u64; const TEXEL_BUFFER =
4703 ffi::WGPUBufferUsage_TexelBuffer as u64; }
4704 }
4705 impl From<ffi::WGPUBufferUsage> for BufferUsage {
4706 fn from(value: ffi::WGPUBufferUsage) -> Self {
4707 BufferUsage::from_bits_truncate(value as u64)
4708 }
4709 }
4710 impl From<BufferUsage> for ffi::WGPUBufferUsage {
4711 fn from(value: BufferUsage) -> Self {
4712 value.bits() as ffi::WGPUBufferUsage
4713 }
4714 }
4715 bitflags! {
4716 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ColorWriteMask :
4717 u64 { const NONE = ffi::WGPUColorWriteMask_None as u64; const RED =
4718 ffi::WGPUColorWriteMask_Red as u64; const GREEN = ffi::WGPUColorWriteMask_Green
4719 as u64; const BLUE = ffi::WGPUColorWriteMask_Blue as u64; const ALPHA =
4720 ffi::WGPUColorWriteMask_Alpha as u64; const ALL = ffi::WGPUColorWriteMask_All as
4721 u64; }
4722 }
4723 impl From<ffi::WGPUColorWriteMask> for ColorWriteMask {
4724 fn from(value: ffi::WGPUColorWriteMask) -> Self {
4725 ColorWriteMask::from_bits_truncate(value as u64)
4726 }
4727 }
4728 impl From<ColorWriteMask> for ffi::WGPUColorWriteMask {
4729 fn from(value: ColorWriteMask) -> Self {
4730 value.bits() as ffi::WGPUColorWriteMask
4731 }
4732 }
4733 bitflags! {
4734 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct HeapProperty : u64
4735 { const NONE = ffi::WGPUHeapProperty_None as u64; const DEVICE_LOCAL =
4736 ffi::WGPUHeapProperty_DeviceLocal as u64; const HOST_VISIBLE =
4737 ffi::WGPUHeapProperty_HostVisible as u64; const HOST_COHERENT =
4738 ffi::WGPUHeapProperty_HostCoherent as u64; const HOST_UNCACHED =
4739 ffi::WGPUHeapProperty_HostUncached as u64; const HOST_CACHED =
4740 ffi::WGPUHeapProperty_HostCached as u64; }
4741 }
4742 impl From<ffi::WGPUHeapProperty> for HeapProperty {
4743 fn from(value: ffi::WGPUHeapProperty) -> Self {
4744 HeapProperty::from_bits_truncate(value as u64)
4745 }
4746 }
4747 impl From<HeapProperty> for ffi::WGPUHeapProperty {
4748 fn from(value: HeapProperty) -> Self {
4749 value.bits() as ffi::WGPUHeapProperty
4750 }
4751 }
4752 bitflags! {
4753 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct MapMode : u64 {
4754 const NONE = ffi::WGPUMapMode_None as u64; const READ = ffi::WGPUMapMode_Read as
4755 u64; const WRITE = ffi::WGPUMapMode_Write as u64; }
4756 }
4757 impl From<ffi::WGPUMapMode> for MapMode {
4758 fn from(value: ffi::WGPUMapMode) -> Self {
4759 MapMode::from_bits_truncate(value as u64)
4760 }
4761 }
4762 impl From<MapMode> for ffi::WGPUMapMode {
4763 fn from(value: MapMode) -> Self {
4764 value.bits() as ffi::WGPUMapMode
4765 }
4766 }
4767 bitflags! {
4768 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct ShaderStage : u64 {
4769 const NONE = ffi::WGPUShaderStage_None as u64; const VERTEX =
4770 ffi::WGPUShaderStage_Vertex as u64; const FRAGMENT =
4771 ffi::WGPUShaderStage_Fragment as u64; const COMPUTE =
4772 ffi::WGPUShaderStage_Compute as u64; }
4773 }
4774 impl From<ffi::WGPUShaderStage> for ShaderStage {
4775 fn from(value: ffi::WGPUShaderStage) -> Self {
4776 ShaderStage::from_bits_truncate(value as u64)
4777 }
4778 }
4779 impl From<ShaderStage> for ffi::WGPUShaderStage {
4780 fn from(value: ShaderStage) -> Self {
4781 value.bits() as ffi::WGPUShaderStage
4782 }
4783 }
4784 bitflags! {
4785 #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] pub struct TextureUsage : u64
4786 { const NONE = ffi::WGPUTextureUsage_None as u64; const COPY_SRC =
4787 ffi::WGPUTextureUsage_CopySrc as u64; const COPY_DST =
4788 ffi::WGPUTextureUsage_CopyDst as u64; const TEXTURE_BINDING =
4789 ffi::WGPUTextureUsage_TextureBinding as u64; const STORAGE_BINDING =
4790 ffi::WGPUTextureUsage_StorageBinding as u64; const RENDER_ATTACHMENT =
4791 ffi::WGPUTextureUsage_RenderAttachment as u64; const TRANSIENT_ATTACHMENT =
4792 ffi::WGPUTextureUsage_TransientAttachment as u64; const STORAGE_ATTACHMENT =
4793 ffi::WGPUTextureUsage_StorageAttachment as u64; }
4794 }
4795 impl From<ffi::WGPUTextureUsage> for TextureUsage {
4796 fn from(value: ffi::WGPUTextureUsage) -> Self {
4797 TextureUsage::from_bits_truncate(value as u64)
4798 }
4799 }
4800 impl From<TextureUsage> for ffi::WGPUTextureUsage {
4801 fn from(value: TextureUsage) -> Self {
4802 value.bits() as ffi::WGPUTextureUsage
4803 }
4804 }
4805}
4806mod structs {
4807 #![allow(dead_code, unused_imports)]
4808 use crate::ffi;
4809 use crate::generated::*;
4810 use std::any::Any;
4811 use std::ffi::CStr;
4812 pub(crate) fn string_view_to_string(view: ffi::WGPUStringView) -> String {
4813 if view.data.is_null() || view.length == 0 {
4814 return String::new();
4815 }
4816 let data = view.data.cast::<u8>();
4817 let slice = unsafe { std::slice::from_raw_parts(data, view.length) };
4818 String::from_utf8_lossy(slice).into_owned()
4819 }
4820 pub struct AHardwareBufferProperties {
4821 pub y_cb_cr_info: Option<YCbCrVkDescriptor>,
4822 }
4823 impl Default for AHardwareBufferProperties {
4824 fn default() -> Self {
4825 Self { y_cb_cr_info: None }
4826 }
4827 }
4828 impl AHardwareBufferProperties {
4829 pub fn new() -> Self {
4830 Self::default()
4831 }
4832 pub(crate) fn to_ffi(
4833 &self,
4834 ) -> (ffi::WGPUAHardwareBufferProperties, ChainedStructStorage) {
4835 let mut storage = ChainedStructStorage::new();
4836 let mut raw: ffi::WGPUAHardwareBufferProperties = unsafe {
4837 std::mem::zeroed()
4838 };
4839 if let Some(value) = &self.y_cb_cr_info {
4840 let (raw_value, storage_value) = value.to_ffi();
4841 raw.yCbCrInfo = raw_value;
4842 storage.push_storage(storage_value);
4843 }
4844 (raw, storage)
4845 }
4846 pub(crate) fn from_ffi(value: ffi::WGPUAHardwareBufferProperties) -> Self {
4847 Self {
4848 y_cb_cr_info: Some(YCbCrVkDescriptor::from_ffi(value.yCbCrInfo)),
4849 }
4850 }
4851 }
4852 pub struct AdapterInfo {
4853 pub(crate) extensions: Vec<AdapterInfoExtension>,
4854 pub vendor: Option<String>,
4855 pub architecture: Option<String>,
4856 pub device: Option<String>,
4857 pub description: Option<String>,
4858 pub backend_type: Option<BackendType>,
4859 pub adapter_type: Option<AdapterType>,
4860 pub vendor_id: Option<u32>,
4861 pub device_id: Option<u32>,
4862 pub subgroup_min_size: Option<u32>,
4863 pub subgroup_max_size: Option<u32>,
4864 #[doc(hidden)]
4865 pub(crate) _free_members: Option<ffi::WGPUAdapterInfo>,
4866 }
4867 impl Default for AdapterInfo {
4868 fn default() -> Self {
4869 Self {
4870 extensions: Vec::new(),
4871 vendor: None,
4872 architecture: None,
4873 device: None,
4874 description: None,
4875 backend_type: None,
4876 adapter_type: None,
4877 vendor_id: None,
4878 device_id: None,
4879 subgroup_min_size: None,
4880 subgroup_max_size: None,
4881 _free_members: None,
4882 }
4883 }
4884 }
4885 impl AdapterInfo {
4886 pub fn new() -> Self {
4887 Self::default()
4888 }
4889 pub(crate) fn to_ffi(&self) -> (ffi::WGPUAdapterInfo, ChainedStructStorage) {
4890 let mut storage = ChainedStructStorage::new();
4891 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
4892 for ext in self.extensions.iter().rev() {
4893 next = ext.push_chain(&mut storage, next);
4894 }
4895 let mut raw: ffi::WGPUAdapterInfo = unsafe { std::mem::zeroed() };
4896 raw.nextInChain = next;
4897 if let Some(value) = &self.vendor {
4898 raw.vendor = ffi::WGPUStringView {
4899 data: value.as_ptr().cast(),
4900 length: value.len(),
4901 };
4902 } else {
4903 raw.vendor = ffi::WGPUStringView {
4904 data: std::ptr::null(),
4905 length: 0,
4906 };
4907 }
4908 if let Some(value) = &self.architecture {
4909 raw.architecture = ffi::WGPUStringView {
4910 data: value.as_ptr().cast(),
4911 length: value.len(),
4912 };
4913 } else {
4914 raw.architecture = ffi::WGPUStringView {
4915 data: std::ptr::null(),
4916 length: 0,
4917 };
4918 }
4919 if let Some(value) = &self.device {
4920 raw.device = ffi::WGPUStringView {
4921 data: value.as_ptr().cast(),
4922 length: value.len(),
4923 };
4924 } else {
4925 raw.device = ffi::WGPUStringView {
4926 data: std::ptr::null(),
4927 length: 0,
4928 };
4929 }
4930 if let Some(value) = &self.description {
4931 raw.description = ffi::WGPUStringView {
4932 data: value.as_ptr().cast(),
4933 length: value.len(),
4934 };
4935 } else {
4936 raw.description = ffi::WGPUStringView {
4937 data: std::ptr::null(),
4938 length: 0,
4939 };
4940 }
4941 if let Some(value) = self.backend_type {
4942 raw.backendType = value.into();
4943 } else {
4944 raw.backendType = 0 as ffi::WGPUBackendType;
4945 }
4946 if let Some(value) = self.adapter_type {
4947 raw.adapterType = value.into();
4948 } else {
4949 raw.adapterType = 0 as ffi::WGPUAdapterType;
4950 }
4951 if let Some(value) = self.vendor_id {
4952 raw.vendorID = value;
4953 }
4954 if let Some(value) = self.device_id {
4955 raw.deviceID = value;
4956 }
4957 if let Some(value) = self.subgroup_min_size {
4958 raw.subgroupMinSize = value;
4959 }
4960 if let Some(value) = self.subgroup_max_size {
4961 raw.subgroupMaxSize = value;
4962 }
4963 (raw, storage)
4964 }
4965 pub fn with_extension(mut self, extension: AdapterInfoExtension) -> Self {
4966 self.extensions.push(extension);
4967 self
4968 }
4969 pub(crate) fn from_ffi(value: ffi::WGPUAdapterInfo) -> Self {
4970 Self {
4971 extensions: Vec::new(),
4972 vendor: Some(string_view_to_string(value.vendor)),
4973 architecture: Some(string_view_to_string(value.architecture)),
4974 device: Some(string_view_to_string(value.device)),
4975 description: Some(string_view_to_string(value.description)),
4976 backend_type: Some(value.backendType.into()),
4977 adapter_type: Some(value.adapterType.into()),
4978 vendor_id: Some(value.vendorID),
4979 device_id: Some(value.deviceID),
4980 subgroup_min_size: Some(value.subgroupMinSize),
4981 subgroup_max_size: Some(value.subgroupMaxSize),
4982 _free_members: Some(value),
4983 }
4984 }
4985 pub(crate) fn free_members(value: ffi::WGPUAdapterInfo) {
4986 unsafe { ffi::wgpuAdapterInfoFreeMembers(value) };
4987 }
4988 }
4989 impl Drop for AdapterInfo {
4990 fn drop(&mut self) {
4991 if let Some(value) = self._free_members.take() {
4992 unsafe { ffi::wgpuAdapterInfoFreeMembers(value) };
4993 }
4994 }
4995 }
4996 pub struct AdapterPropertiesD3D {
4997 pub shader_model: Option<u32>,
4998 }
4999 impl Default for AdapterPropertiesD3D {
5000 fn default() -> Self {
5001 Self { shader_model: None }
5002 }
5003 }
5004 impl AdapterPropertiesD3D {
5005 pub fn new() -> Self {
5006 Self::default()
5007 }
5008 pub(crate) fn to_ffi(
5009 &self,
5010 ) -> (ffi::WGPUAdapterPropertiesD3D, ChainedStructStorage) {
5011 let mut storage = ChainedStructStorage::new();
5012 let mut raw: ffi::WGPUAdapterPropertiesD3D = unsafe { std::mem::zeroed() };
5013 if let Some(value) = self.shader_model {
5014 raw.shaderModel = value;
5015 }
5016 (raw, storage)
5017 }
5018 pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesD3D) -> Self {
5019 Self {
5020 shader_model: Some(value.shaderModel),
5021 }
5022 }
5023 }
5024 pub struct AdapterPropertiesWGPU {
5025 pub backend_type: Option<BackendType>,
5026 }
5027 impl Default for AdapterPropertiesWGPU {
5028 fn default() -> Self {
5029 Self { backend_type: None }
5030 }
5031 }
5032 impl AdapterPropertiesWGPU {
5033 pub fn new() -> Self {
5034 Self::default()
5035 }
5036 pub(crate) fn to_ffi(
5037 &self,
5038 ) -> (ffi::WGPUAdapterPropertiesWGPU, ChainedStructStorage) {
5039 let mut storage = ChainedStructStorage::new();
5040 let mut raw: ffi::WGPUAdapterPropertiesWGPU = unsafe { std::mem::zeroed() };
5041 if let Some(value) = self.backend_type {
5042 raw.backendType = value.into();
5043 } else {
5044 raw.backendType = 0 as ffi::WGPUBackendType;
5045 }
5046 (raw, storage)
5047 }
5048 pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesWGPU) -> Self {
5049 Self {
5050 backend_type: Some(value.backendType.into()),
5051 }
5052 }
5053 }
5054 pub struct AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5055 pub min_explicit_compute_subgroup_size: Option<u32>,
5056 pub max_explicit_compute_subgroup_size: Option<u32>,
5057 pub max_compute_workgroup_subgroups: Option<u32>,
5058 }
5059 impl Default for AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5060 fn default() -> Self {
5061 Self {
5062 min_explicit_compute_subgroup_size: None,
5063 max_explicit_compute_subgroup_size: None,
5064 max_compute_workgroup_subgroups: None,
5065 }
5066 }
5067 }
5068 impl AdapterPropertiesExplicitComputeSubgroupSizeConfigs {
5069 pub fn new() -> Self {
5070 Self::default()
5071 }
5072 pub(crate) fn to_ffi(
5073 &self,
5074 ) -> (
5075 ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs,
5076 ChainedStructStorage,
5077 ) {
5078 let mut storage = ChainedStructStorage::new();
5079 let mut raw: ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs = unsafe {
5080 std::mem::zeroed()
5081 };
5082 if let Some(value) = self.min_explicit_compute_subgroup_size {
5083 raw.minExplicitComputeSubgroupSize = value;
5084 }
5085 if let Some(value) = self.max_explicit_compute_subgroup_size {
5086 raw.maxExplicitComputeSubgroupSize = value;
5087 }
5088 if let Some(value) = self.max_compute_workgroup_subgroups {
5089 raw.maxComputeWorkgroupSubgroups = value;
5090 }
5091 (raw, storage)
5092 }
5093 pub(crate) fn from_ffi(
5094 value: ffi::WGPUAdapterPropertiesExplicitComputeSubgroupSizeConfigs,
5095 ) -> Self {
5096 Self {
5097 min_explicit_compute_subgroup_size: Some(
5098 value.minExplicitComputeSubgroupSize,
5099 ),
5100 max_explicit_compute_subgroup_size: Some(
5101 value.maxExplicitComputeSubgroupSize,
5102 ),
5103 max_compute_workgroup_subgroups: Some(value.maxComputeWorkgroupSubgroups),
5104 }
5105 }
5106 }
5107 pub struct AdapterPropertiesMemoryHeaps {
5108 pub heap_info: Option<Vec<MemoryHeapInfo>>,
5109 #[doc(hidden)]
5110 pub(crate) _free_members: Option<ffi::WGPUAdapterPropertiesMemoryHeaps>,
5111 }
5112 impl Default for AdapterPropertiesMemoryHeaps {
5113 fn default() -> Self {
5114 Self {
5115 heap_info: None,
5116 _free_members: None,
5117 }
5118 }
5119 }
5120 impl AdapterPropertiesMemoryHeaps {
5121 pub fn new() -> Self {
5122 Self::default()
5123 }
5124 pub(crate) fn to_ffi(
5125 &self,
5126 ) -> (ffi::WGPUAdapterPropertiesMemoryHeaps, ChainedStructStorage) {
5127 let mut storage = ChainedStructStorage::new();
5128 let mut raw: ffi::WGPUAdapterPropertiesMemoryHeaps = unsafe {
5129 std::mem::zeroed()
5130 };
5131 raw.heapCount = self.heap_info.as_ref().map(|v| v.len()).unwrap_or(0);
5132 if let Some(values) = &self.heap_info {
5133 let len_value = values.len();
5134 let mut raw_vec: Vec<ffi::WGPUMemoryHeapInfo> = Vec::with_capacity(
5135 values.len(),
5136 );
5137 for item in values.iter() {
5138 let (raw_item, storage_item) = item.to_ffi();
5139 raw_vec.push(raw_item);
5140 storage.push_storage(storage_item);
5141 }
5142 let ptr = storage.push_vec(raw_vec);
5143 raw.heapInfo = ptr;
5144 raw.heapCount = len_value;
5145 } else {
5146 raw.heapInfo = std::ptr::null();
5147 raw.heapCount = 0;
5148 }
5149 (raw, storage)
5150 }
5151 pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesMemoryHeaps) -> Self {
5152 Self {
5153 heap_info: if value.heapInfo.is_null() {
5154 None
5155 } else {
5156 Some(
5157 unsafe {
5158 std::slice::from_raw_parts(
5159 value.heapInfo,
5160 value.heapCount as usize,
5161 )
5162 }
5163 .iter()
5164 .map(|raw| MemoryHeapInfo::from_ffi(*raw))
5165 .collect(),
5166 )
5167 },
5168 _free_members: Some(value),
5169 }
5170 }
5171 pub(crate) fn free_members(value: ffi::WGPUAdapterPropertiesMemoryHeaps) {
5172 unsafe { ffi::wgpuAdapterPropertiesMemoryHeapsFreeMembers(value) };
5173 }
5174 }
5175 impl Drop for AdapterPropertiesMemoryHeaps {
5176 fn drop(&mut self) {
5177 if let Some(value) = self._free_members.take() {
5178 unsafe { ffi::wgpuAdapterPropertiesMemoryHeapsFreeMembers(value) };
5179 }
5180 }
5181 }
5182 pub struct AdapterPropertiesSubgroupMatrixConfigs {
5183 pub configs: Option<Vec<SubgroupMatrixConfig>>,
5184 #[doc(hidden)]
5185 pub(crate) _free_members: Option<
5186 ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5187 >,
5188 }
5189 impl Default for AdapterPropertiesSubgroupMatrixConfigs {
5190 fn default() -> Self {
5191 Self {
5192 configs: None,
5193 _free_members: None,
5194 }
5195 }
5196 }
5197 impl AdapterPropertiesSubgroupMatrixConfigs {
5198 pub fn new() -> Self {
5199 Self::default()
5200 }
5201 pub(crate) fn to_ffi(
5202 &self,
5203 ) -> (ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs, ChainedStructStorage) {
5204 let mut storage = ChainedStructStorage::new();
5205 let mut raw: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs = unsafe {
5206 std::mem::zeroed()
5207 };
5208 raw.configCount = self.configs.as_ref().map(|v| v.len()).unwrap_or(0);
5209 if let Some(values) = &self.configs {
5210 let len_value = values.len();
5211 let mut raw_vec: Vec<ffi::WGPUSubgroupMatrixConfig> = Vec::with_capacity(
5212 values.len(),
5213 );
5214 for item in values.iter() {
5215 let (raw_item, storage_item) = item.to_ffi();
5216 raw_vec.push(raw_item);
5217 storage.push_storage(storage_item);
5218 }
5219 let ptr = storage.push_vec(raw_vec);
5220 raw.configs = ptr;
5221 raw.configCount = len_value;
5222 } else {
5223 raw.configs = std::ptr::null();
5224 raw.configCount = 0;
5225 }
5226 (raw, storage)
5227 }
5228 pub(crate) fn from_ffi(
5229 value: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5230 ) -> Self {
5231 Self {
5232 configs: if value.configs.is_null() {
5233 None
5234 } else {
5235 Some(
5236 unsafe {
5237 std::slice::from_raw_parts(
5238 value.configs,
5239 value.configCount as usize,
5240 )
5241 }
5242 .iter()
5243 .map(|raw| SubgroupMatrixConfig::from_ffi(*raw))
5244 .collect(),
5245 )
5246 },
5247 _free_members: Some(value),
5248 }
5249 }
5250 pub(crate) fn free_members(
5251 value: ffi::WGPUAdapterPropertiesSubgroupMatrixConfigs,
5252 ) {
5253 unsafe { ffi::wgpuAdapterPropertiesSubgroupMatrixConfigsFreeMembers(value) };
5254 }
5255 }
5256 impl Drop for AdapterPropertiesSubgroupMatrixConfigs {
5257 fn drop(&mut self) {
5258 if let Some(value) = self._free_members.take() {
5259 unsafe {
5260 ffi::wgpuAdapterPropertiesSubgroupMatrixConfigsFreeMembers(value)
5261 };
5262 }
5263 }
5264 }
5265 pub struct AdapterPropertiesVk {
5266 pub driver_version: Option<u32>,
5267 }
5268 impl Default for AdapterPropertiesVk {
5269 fn default() -> Self {
5270 Self { driver_version: None }
5271 }
5272 }
5273 impl AdapterPropertiesVk {
5274 pub fn new() -> Self {
5275 Self::default()
5276 }
5277 pub(crate) fn to_ffi(
5278 &self,
5279 ) -> (ffi::WGPUAdapterPropertiesVk, ChainedStructStorage) {
5280 let mut storage = ChainedStructStorage::new();
5281 let mut raw: ffi::WGPUAdapterPropertiesVk = unsafe { std::mem::zeroed() };
5282 if let Some(value) = self.driver_version {
5283 raw.driverVersion = value;
5284 }
5285 (raw, storage)
5286 }
5287 pub(crate) fn from_ffi(value: ffi::WGPUAdapterPropertiesVk) -> Self {
5288 Self {
5289 driver_version: Some(value.driverVersion),
5290 }
5291 }
5292 }
5293 pub struct BindGroupDescriptor {
5294 pub(crate) extensions: Vec<BindGroupDescriptorExtension>,
5295 pub label: Option<String>,
5296 pub layout: Option<BindGroupLayout>,
5297 pub entries: Option<Vec<BindGroupEntry>>,
5298 }
5299 impl Default for BindGroupDescriptor {
5300 fn default() -> Self {
5301 Self {
5302 extensions: Vec::new(),
5303 label: None,
5304 layout: None,
5305 entries: None,
5306 }
5307 }
5308 }
5309 impl BindGroupDescriptor {
5310 pub fn new() -> Self {
5311 Self::default()
5312 }
5313 pub(crate) fn to_ffi(
5314 &self,
5315 ) -> (ffi::WGPUBindGroupDescriptor, ChainedStructStorage) {
5316 let mut storage = ChainedStructStorage::new();
5317 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5318 for ext in self.extensions.iter().rev() {
5319 next = ext.push_chain(&mut storage, next);
5320 }
5321 let mut raw: ffi::WGPUBindGroupDescriptor = unsafe { std::mem::zeroed() };
5322 raw.nextInChain = next;
5323 if let Some(value) = &self.label {
5324 raw.label = ffi::WGPUStringView {
5325 data: value.as_ptr().cast(),
5326 length: value.len(),
5327 };
5328 } else {
5329 raw.label = ffi::WGPUStringView {
5330 data: std::ptr::null(),
5331 length: 0,
5332 };
5333 }
5334 raw.layout = self
5335 .layout
5336 .as_ref()
5337 .map(|v| v.as_raw())
5338 .unwrap_or(std::ptr::null_mut());
5339 raw.entryCount = self.entries.as_ref().map(|v| v.len()).unwrap_or(0);
5340 if let Some(values) = &self.entries {
5341 let len_value = values.len();
5342 let mut raw_vec: Vec<ffi::WGPUBindGroupEntry> = Vec::with_capacity(
5343 values.len(),
5344 );
5345 for item in values.iter() {
5346 let (raw_item, storage_item) = item.to_ffi();
5347 raw_vec.push(raw_item);
5348 storage.push_storage(storage_item);
5349 }
5350 let ptr = storage.push_vec(raw_vec);
5351 raw.entries = ptr;
5352 raw.entryCount = len_value;
5353 } else {
5354 raw.entries = std::ptr::null();
5355 raw.entryCount = 0;
5356 }
5357 (raw, storage)
5358 }
5359 pub fn with_extension(
5360 mut self,
5361 extension: BindGroupDescriptorExtension,
5362 ) -> Self {
5363 self.extensions.push(extension);
5364 self
5365 }
5366 pub(crate) fn from_ffi(value: ffi::WGPUBindGroupDescriptor) -> Self {
5367 Self {
5368 extensions: Vec::new(),
5369 label: if value.label.data.is_null() || value.label.length == 0 {
5370 None
5371 } else {
5372 Some(string_view_to_string(value.label))
5373 },
5374 layout: Some(unsafe { BindGroupLayout::from_raw(value.layout) }),
5375 entries: if value.entries.is_null() {
5376 None
5377 } else {
5378 Some(
5379 unsafe {
5380 std::slice::from_raw_parts(
5381 value.entries,
5382 value.entryCount as usize,
5383 )
5384 }
5385 .iter()
5386 .map(|raw| BindGroupEntry::from_ffi(*raw))
5387 .collect(),
5388 )
5389 },
5390 }
5391 }
5392 }
5393 pub struct BindGroupEntry {
5394 pub(crate) extensions: Vec<BindGroupEntryExtension>,
5395 pub binding: Option<u32>,
5396 pub buffer: Option<Buffer>,
5397 pub offset: Option<u64>,
5398 pub size: Option<u64>,
5399 pub sampler: Option<Sampler>,
5400 pub texture_view: Option<TextureView>,
5401 }
5402 impl Default for BindGroupEntry {
5403 fn default() -> Self {
5404 Self {
5405 extensions: Vec::new(),
5406 binding: None,
5407 buffer: None,
5408 offset: Some(0),
5409 size: Some(WHOLE_SIZE),
5410 sampler: None,
5411 texture_view: None,
5412 }
5413 }
5414 }
5415 impl BindGroupEntry {
5416 pub fn new() -> Self {
5417 Self::default()
5418 }
5419 pub(crate) fn to_ffi(&self) -> (ffi::WGPUBindGroupEntry, ChainedStructStorage) {
5420 let mut storage = ChainedStructStorage::new();
5421 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5422 for ext in self.extensions.iter().rev() {
5423 next = ext.push_chain(&mut storage, next);
5424 }
5425 let mut raw: ffi::WGPUBindGroupEntry = unsafe { std::mem::zeroed() };
5426 raw.nextInChain = next;
5427 if let Some(value) = self.binding {
5428 raw.binding = value;
5429 }
5430 raw.buffer = self
5431 .buffer
5432 .as_ref()
5433 .map(|v| v.as_raw())
5434 .unwrap_or(std::ptr::null_mut());
5435 if let Some(value) = self.offset {
5436 raw.offset = value;
5437 }
5438 if let Some(value) = self.size {
5439 raw.size = value;
5440 }
5441 raw.sampler = self
5442 .sampler
5443 .as_ref()
5444 .map(|v| v.as_raw())
5445 .unwrap_or(std::ptr::null_mut());
5446 raw.textureView = self
5447 .texture_view
5448 .as_ref()
5449 .map(|v| v.as_raw())
5450 .unwrap_or(std::ptr::null_mut());
5451 (raw, storage)
5452 }
5453 pub fn with_extension(mut self, extension: BindGroupEntryExtension) -> Self {
5454 self.extensions.push(extension);
5455 self
5456 }
5457 pub(crate) fn from_ffi(value: ffi::WGPUBindGroupEntry) -> Self {
5458 Self {
5459 extensions: Vec::new(),
5460 binding: Some(value.binding),
5461 buffer: if value.buffer.is_null() {
5462 None
5463 } else {
5464 Some(unsafe { Buffer::from_raw(value.buffer) })
5465 },
5466 offset: Some(value.offset),
5467 size: Some(value.size),
5468 sampler: if value.sampler.is_null() {
5469 None
5470 } else {
5471 Some(unsafe { Sampler::from_raw(value.sampler) })
5472 },
5473 texture_view: if value.textureView.is_null() {
5474 None
5475 } else {
5476 Some(unsafe { TextureView::from_raw(value.textureView) })
5477 },
5478 }
5479 }
5480 }
5481 pub struct BindGroupLayoutDescriptor {
5482 pub(crate) extensions: Vec<BindGroupLayoutDescriptorExtension>,
5483 pub label: Option<String>,
5484 pub entries: Option<Vec<BindGroupLayoutEntry>>,
5485 }
5486 impl Default for BindGroupLayoutDescriptor {
5487 fn default() -> Self {
5488 Self {
5489 extensions: Vec::new(),
5490 label: None,
5491 entries: None,
5492 }
5493 }
5494 }
5495 impl BindGroupLayoutDescriptor {
5496 pub fn new() -> Self {
5497 Self::default()
5498 }
5499 pub(crate) fn to_ffi(
5500 &self,
5501 ) -> (ffi::WGPUBindGroupLayoutDescriptor, ChainedStructStorage) {
5502 let mut storage = ChainedStructStorage::new();
5503 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5504 for ext in self.extensions.iter().rev() {
5505 next = ext.push_chain(&mut storage, next);
5506 }
5507 let mut raw: ffi::WGPUBindGroupLayoutDescriptor = unsafe {
5508 std::mem::zeroed()
5509 };
5510 raw.nextInChain = next;
5511 if let Some(value) = &self.label {
5512 raw.label = ffi::WGPUStringView {
5513 data: value.as_ptr().cast(),
5514 length: value.len(),
5515 };
5516 } else {
5517 raw.label = ffi::WGPUStringView {
5518 data: std::ptr::null(),
5519 length: 0,
5520 };
5521 }
5522 raw.entryCount = self.entries.as_ref().map(|v| v.len()).unwrap_or(0);
5523 if let Some(values) = &self.entries {
5524 let len_value = values.len();
5525 let mut raw_vec: Vec<ffi::WGPUBindGroupLayoutEntry> = Vec::with_capacity(
5526 values.len(),
5527 );
5528 for item in values.iter() {
5529 let (raw_item, storage_item) = item.to_ffi();
5530 raw_vec.push(raw_item);
5531 storage.push_storage(storage_item);
5532 }
5533 let ptr = storage.push_vec(raw_vec);
5534 raw.entries = ptr;
5535 raw.entryCount = len_value;
5536 } else {
5537 raw.entries = std::ptr::null();
5538 raw.entryCount = 0;
5539 }
5540 (raw, storage)
5541 }
5542 pub fn with_extension(
5543 mut self,
5544 extension: BindGroupLayoutDescriptorExtension,
5545 ) -> Self {
5546 self.extensions.push(extension);
5547 self
5548 }
5549 pub(crate) fn from_ffi(value: ffi::WGPUBindGroupLayoutDescriptor) -> Self {
5550 Self {
5551 extensions: Vec::new(),
5552 label: if value.label.data.is_null() || value.label.length == 0 {
5553 None
5554 } else {
5555 Some(string_view_to_string(value.label))
5556 },
5557 entries: if value.entries.is_null() {
5558 None
5559 } else {
5560 Some(
5561 unsafe {
5562 std::slice::from_raw_parts(
5563 value.entries,
5564 value.entryCount as usize,
5565 )
5566 }
5567 .iter()
5568 .map(|raw| BindGroupLayoutEntry::from_ffi(*raw))
5569 .collect(),
5570 )
5571 },
5572 }
5573 }
5574 }
5575 pub struct BindGroupLayoutEntry {
5576 pub(crate) extensions: Vec<BindGroupLayoutEntryExtension>,
5577 pub binding: Option<u32>,
5578 pub visibility: Option<ShaderStage>,
5579 pub binding_array_size: Option<u32>,
5580 pub buffer: Option<BufferBindingLayout>,
5581 pub sampler: Option<SamplerBindingLayout>,
5582 pub texture: Option<TextureBindingLayout>,
5583 pub storage_texture: Option<StorageTextureBindingLayout>,
5584 }
5585 impl Default for BindGroupLayoutEntry {
5586 fn default() -> Self {
5587 Self {
5588 extensions: Vec::new(),
5589 binding: None,
5590 visibility: None,
5591 binding_array_size: Some(0),
5592 buffer: None,
5593 sampler: None,
5594 texture: None,
5595 storage_texture: None,
5596 }
5597 }
5598 }
5599 impl BindGroupLayoutEntry {
5600 pub fn new() -> Self {
5601 Self::default()
5602 }
5603 pub(crate) fn to_ffi(
5604 &self,
5605 ) -> (ffi::WGPUBindGroupLayoutEntry, ChainedStructStorage) {
5606 let mut storage = ChainedStructStorage::new();
5607 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5608 for ext in self.extensions.iter().rev() {
5609 next = ext.push_chain(&mut storage, next);
5610 }
5611 let mut raw: ffi::WGPUBindGroupLayoutEntry = unsafe { std::mem::zeroed() };
5612 raw.nextInChain = next;
5613 if let Some(value) = self.binding {
5614 raw.binding = value;
5615 }
5616 if let Some(value) = self.visibility {
5617 raw.visibility = value.into();
5618 } else {
5619 raw.visibility = 0 as ffi::WGPUShaderStage;
5620 }
5621 if let Some(value) = self.binding_array_size {
5622 raw.bindingArraySize = value;
5623 }
5624 if let Some(value) = &self.buffer {
5625 let (raw_value, storage_value) = value.to_ffi();
5626 raw.buffer = raw_value;
5627 storage.push_storage(storage_value);
5628 }
5629 if let Some(value) = &self.sampler {
5630 let (raw_value, storage_value) = value.to_ffi();
5631 raw.sampler = raw_value;
5632 storage.push_storage(storage_value);
5633 }
5634 if let Some(value) = &self.texture {
5635 let (raw_value, storage_value) = value.to_ffi();
5636 raw.texture = raw_value;
5637 storage.push_storage(storage_value);
5638 }
5639 if let Some(value) = &self.storage_texture {
5640 let (raw_value, storage_value) = value.to_ffi();
5641 raw.storageTexture = raw_value;
5642 storage.push_storage(storage_value);
5643 }
5644 (raw, storage)
5645 }
5646 pub fn with_extension(
5647 mut self,
5648 extension: BindGroupLayoutEntryExtension,
5649 ) -> Self {
5650 self.extensions.push(extension);
5651 self
5652 }
5653 pub(crate) fn from_ffi(value: ffi::WGPUBindGroupLayoutEntry) -> Self {
5654 Self {
5655 extensions: Vec::new(),
5656 binding: Some(value.binding),
5657 visibility: Some(value.visibility.into()),
5658 binding_array_size: Some(value.bindingArraySize),
5659 buffer: Some(BufferBindingLayout::from_ffi(value.buffer)),
5660 sampler: Some(SamplerBindingLayout::from_ffi(value.sampler)),
5661 texture: Some(TextureBindingLayout::from_ffi(value.texture)),
5662 storage_texture: Some(
5663 StorageTextureBindingLayout::from_ffi(value.storageTexture),
5664 ),
5665 }
5666 }
5667 }
5668 pub struct BindingResource {
5669 pub(crate) extensions: Vec<BindingResourceExtension>,
5670 pub buffer: Option<Buffer>,
5671 pub offset: Option<u64>,
5672 pub size: Option<u64>,
5673 pub sampler: Option<Sampler>,
5674 pub texture_view: Option<TextureView>,
5675 }
5676 impl Default for BindingResource {
5677 fn default() -> Self {
5678 Self {
5679 extensions: Vec::new(),
5680 buffer: None,
5681 offset: Some(0),
5682 size: Some(WHOLE_SIZE),
5683 sampler: None,
5684 texture_view: None,
5685 }
5686 }
5687 }
5688 impl BindingResource {
5689 pub fn new() -> Self {
5690 Self::default()
5691 }
5692 pub(crate) fn to_ffi(&self) -> (ffi::WGPUBindingResource, ChainedStructStorage) {
5693 let mut storage = ChainedStructStorage::new();
5694 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5695 for ext in self.extensions.iter().rev() {
5696 next = ext.push_chain(&mut storage, next);
5697 }
5698 let mut raw: ffi::WGPUBindingResource = unsafe { std::mem::zeroed() };
5699 raw.nextInChain = next;
5700 raw.buffer = self
5701 .buffer
5702 .as_ref()
5703 .map(|v| v.as_raw())
5704 .unwrap_or(std::ptr::null_mut());
5705 if let Some(value) = self.offset {
5706 raw.offset = value;
5707 }
5708 if let Some(value) = self.size {
5709 raw.size = value;
5710 }
5711 raw.sampler = self
5712 .sampler
5713 .as_ref()
5714 .map(|v| v.as_raw())
5715 .unwrap_or(std::ptr::null_mut());
5716 raw.textureView = self
5717 .texture_view
5718 .as_ref()
5719 .map(|v| v.as_raw())
5720 .unwrap_or(std::ptr::null_mut());
5721 (raw, storage)
5722 }
5723 pub fn with_extension(mut self, extension: BindingResourceExtension) -> Self {
5724 self.extensions.push(extension);
5725 self
5726 }
5727 pub(crate) fn from_ffi(value: ffi::WGPUBindingResource) -> Self {
5728 Self {
5729 extensions: Vec::new(),
5730 buffer: if value.buffer.is_null() {
5731 None
5732 } else {
5733 Some(unsafe { Buffer::from_raw(value.buffer) })
5734 },
5735 offset: Some(value.offset),
5736 size: Some(value.size),
5737 sampler: if value.sampler.is_null() {
5738 None
5739 } else {
5740 Some(unsafe { Sampler::from_raw(value.sampler) })
5741 },
5742 texture_view: if value.textureView.is_null() {
5743 None
5744 } else {
5745 Some(unsafe { TextureView::from_raw(value.textureView) })
5746 },
5747 }
5748 }
5749 }
5750 pub struct BlendComponent {
5751 pub operation: Option<BlendOperation>,
5752 pub src_factor: Option<BlendFactor>,
5753 pub dst_factor: Option<BlendFactor>,
5754 }
5755 impl Default for BlendComponent {
5756 fn default() -> Self {
5757 Self {
5758 operation: Some(BlendOperation::Add),
5759 src_factor: Some(BlendFactor::One),
5760 dst_factor: Some(BlendFactor::Zero),
5761 }
5762 }
5763 }
5764 impl BlendComponent {
5765 pub fn new() -> Self {
5766 Self::default()
5767 }
5768 pub(crate) fn to_ffi(&self) -> (ffi::WGPUBlendComponent, ChainedStructStorage) {
5769 let mut storage = ChainedStructStorage::new();
5770 let mut raw: ffi::WGPUBlendComponent = unsafe { std::mem::zeroed() };
5771 if let Some(value) = self.operation {
5772 raw.operation = value.into();
5773 } else {
5774 raw.operation = 0 as ffi::WGPUBlendOperation;
5775 }
5776 if let Some(value) = self.src_factor {
5777 raw.srcFactor = value.into();
5778 } else {
5779 raw.srcFactor = 0 as ffi::WGPUBlendFactor;
5780 }
5781 if let Some(value) = self.dst_factor {
5782 raw.dstFactor = value.into();
5783 } else {
5784 raw.dstFactor = 0 as ffi::WGPUBlendFactor;
5785 }
5786 (raw, storage)
5787 }
5788 pub(crate) fn from_ffi(value: ffi::WGPUBlendComponent) -> Self {
5789 Self {
5790 operation: Some(value.operation.into()),
5791 src_factor: Some(value.srcFactor.into()),
5792 dst_factor: Some(value.dstFactor.into()),
5793 }
5794 }
5795 }
5796 pub struct BlendState {
5797 pub color: Option<BlendComponent>,
5798 pub alpha: Option<BlendComponent>,
5799 }
5800 impl Default for BlendState {
5801 fn default() -> Self {
5802 Self { color: None, alpha: None }
5803 }
5804 }
5805 impl BlendState {
5806 pub fn new() -> Self {
5807 Self::default()
5808 }
5809 pub(crate) fn to_ffi(&self) -> (ffi::WGPUBlendState, ChainedStructStorage) {
5810 let mut storage = ChainedStructStorage::new();
5811 let mut raw: ffi::WGPUBlendState = unsafe { std::mem::zeroed() };
5812 if let Some(value) = &self.color {
5813 let (raw_value, storage_value) = value.to_ffi();
5814 raw.color = raw_value;
5815 storage.push_storage(storage_value);
5816 }
5817 if let Some(value) = &self.alpha {
5818 let (raw_value, storage_value) = value.to_ffi();
5819 raw.alpha = raw_value;
5820 storage.push_storage(storage_value);
5821 }
5822 (raw, storage)
5823 }
5824 pub(crate) fn from_ffi(value: ffi::WGPUBlendState) -> Self {
5825 Self {
5826 color: Some(BlendComponent::from_ffi(value.color)),
5827 alpha: Some(BlendComponent::from_ffi(value.alpha)),
5828 }
5829 }
5830 }
5831 pub struct BufferBindingLayout {
5832 pub(crate) extensions: Vec<BufferBindingLayoutExtension>,
5833 pub r#type: Option<BufferBindingType>,
5834 pub has_dynamic_offset: Option<bool>,
5835 pub min_binding_size: Option<u64>,
5836 }
5837 impl Default for BufferBindingLayout {
5838 fn default() -> Self {
5839 Self {
5840 extensions: Vec::new(),
5841 r#type: Some(BufferBindingType::Uniform),
5842 has_dynamic_offset: None,
5843 min_binding_size: Some(0),
5844 }
5845 }
5846 }
5847 impl BufferBindingLayout {
5848 pub fn new() -> Self {
5849 Self::default()
5850 }
5851 pub(crate) fn to_ffi(
5852 &self,
5853 ) -> (ffi::WGPUBufferBindingLayout, ChainedStructStorage) {
5854 let mut storage = ChainedStructStorage::new();
5855 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5856 for ext in self.extensions.iter().rev() {
5857 next = ext.push_chain(&mut storage, next);
5858 }
5859 let mut raw: ffi::WGPUBufferBindingLayout = unsafe { std::mem::zeroed() };
5860 raw.nextInChain = next;
5861 if let Some(value) = self.r#type {
5862 raw.type_ = value.into();
5863 } else {
5864 raw.type_ = 0 as ffi::WGPUBufferBindingType;
5865 }
5866 raw.hasDynamicOffset = if self.has_dynamic_offset.unwrap_or(false) {
5867 1
5868 } else {
5869 0
5870 };
5871 if let Some(value) = self.min_binding_size {
5872 raw.minBindingSize = value;
5873 }
5874 (raw, storage)
5875 }
5876 pub fn with_extension(
5877 mut self,
5878 extension: BufferBindingLayoutExtension,
5879 ) -> Self {
5880 self.extensions.push(extension);
5881 self
5882 }
5883 pub(crate) fn from_ffi(value: ffi::WGPUBufferBindingLayout) -> Self {
5884 Self {
5885 extensions: Vec::new(),
5886 r#type: Some(value.type_.into()),
5887 has_dynamic_offset: Some(value.hasDynamicOffset != 0),
5888 min_binding_size: Some(value.minBindingSize),
5889 }
5890 }
5891 }
5892 pub struct BufferDescriptor {
5893 pub(crate) extensions: Vec<BufferDescriptorExtension>,
5894 pub label: Option<String>,
5895 pub usage: Option<BufferUsage>,
5896 pub size: Option<u64>,
5897 pub mapped_at_creation: Option<bool>,
5898 }
5899 impl Default for BufferDescriptor {
5900 fn default() -> Self {
5901 Self {
5902 extensions: Vec::new(),
5903 label: None,
5904 usage: None,
5905 size: None,
5906 mapped_at_creation: None,
5907 }
5908 }
5909 }
5910 impl BufferDescriptor {
5911 pub fn new() -> Self {
5912 Self::default()
5913 }
5914 pub(crate) fn to_ffi(
5915 &self,
5916 ) -> (ffi::WGPUBufferDescriptor, ChainedStructStorage) {
5917 let mut storage = ChainedStructStorage::new();
5918 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
5919 for ext in self.extensions.iter().rev() {
5920 next = ext.push_chain(&mut storage, next);
5921 }
5922 let mut raw: ffi::WGPUBufferDescriptor = unsafe { std::mem::zeroed() };
5923 raw.nextInChain = next;
5924 if let Some(value) = &self.label {
5925 raw.label = ffi::WGPUStringView {
5926 data: value.as_ptr().cast(),
5927 length: value.len(),
5928 };
5929 } else {
5930 raw.label = ffi::WGPUStringView {
5931 data: std::ptr::null(),
5932 length: 0,
5933 };
5934 }
5935 if let Some(value) = self.usage {
5936 raw.usage = value.into();
5937 } else {
5938 raw.usage = 0 as ffi::WGPUBufferUsage;
5939 }
5940 if let Some(value) = self.size {
5941 raw.size = value;
5942 }
5943 raw.mappedAtCreation = if self.mapped_at_creation.unwrap_or(false) {
5944 1
5945 } else {
5946 0
5947 };
5948 (raw, storage)
5949 }
5950 pub fn with_extension(mut self, extension: BufferDescriptorExtension) -> Self {
5951 self.extensions.push(extension);
5952 self
5953 }
5954 pub(crate) fn from_ffi(value: ffi::WGPUBufferDescriptor) -> Self {
5955 Self {
5956 extensions: Vec::new(),
5957 label: if value.label.data.is_null() || value.label.length == 0 {
5958 None
5959 } else {
5960 Some(string_view_to_string(value.label))
5961 },
5962 usage: Some(value.usage.into()),
5963 size: Some(value.size),
5964 mapped_at_creation: Some(value.mappedAtCreation != 0),
5965 }
5966 }
5967 }
5968 pub struct BufferHostMappedPointer {
5969 pub pointer: Option<*mut std::ffi::c_void>,
5970 pub dispose_callback: Option<Callback>,
5971 pub userdata: Option<*mut std::ffi::c_void>,
5972 }
5973 impl Default for BufferHostMappedPointer {
5974 fn default() -> Self {
5975 Self {
5976 pointer: None,
5977 dispose_callback: None,
5978 userdata: None,
5979 }
5980 }
5981 }
5982 impl BufferHostMappedPointer {
5983 pub fn new() -> Self {
5984 Self::default()
5985 }
5986 pub(crate) fn to_ffi(
5987 &self,
5988 ) -> (ffi::WGPUBufferHostMappedPointer, ChainedStructStorage) {
5989 let mut storage = ChainedStructStorage::new();
5990 let mut raw: ffi::WGPUBufferHostMappedPointer = unsafe {
5991 std::mem::zeroed()
5992 };
5993 if let Some(value) = self.pointer {
5994 raw.pointer = value;
5995 }
5996 if let Some(value) = self.dispose_callback {
5997 raw.disposeCallback = value;
5998 }
5999 if let Some(value) = self.userdata {
6000 raw.userdata = value;
6001 }
6002 (raw, storage)
6003 }
6004 pub(crate) fn from_ffi(value: ffi::WGPUBufferHostMappedPointer) -> Self {
6005 Self {
6006 pointer: Some(value.pointer),
6007 dispose_callback: Some(value.disposeCallback),
6008 userdata: Some(value.userdata),
6009 }
6010 }
6011 }
6012 pub struct Color {
6013 pub r: Option<f64>,
6014 pub g: Option<f64>,
6015 pub b: Option<f64>,
6016 pub a: Option<f64>,
6017 }
6018 impl Default for Color {
6019 fn default() -> Self {
6020 Self {
6021 r: None,
6022 g: None,
6023 b: None,
6024 a: None,
6025 }
6026 }
6027 }
6028 impl Color {
6029 pub fn new() -> Self {
6030 Self::default()
6031 }
6032 pub(crate) fn to_ffi(&self) -> (ffi::WGPUColor, ChainedStructStorage) {
6033 let mut storage = ChainedStructStorage::new();
6034 let mut raw: ffi::WGPUColor = unsafe { std::mem::zeroed() };
6035 if let Some(value) = self.r {
6036 raw.r = value;
6037 }
6038 if let Some(value) = self.g {
6039 raw.g = value;
6040 }
6041 if let Some(value) = self.b {
6042 raw.b = value;
6043 }
6044 if let Some(value) = self.a {
6045 raw.a = value;
6046 }
6047 (raw, storage)
6048 }
6049 pub(crate) fn from_ffi(value: ffi::WGPUColor) -> Self {
6050 Self {
6051 r: Some(value.r),
6052 g: Some(value.g),
6053 b: Some(value.b),
6054 a: Some(value.a),
6055 }
6056 }
6057 }
6058 pub struct ColorTargetState {
6059 pub(crate) extensions: Vec<ColorTargetStateExtension>,
6060 pub format: Option<TextureFormat>,
6061 pub blend: Option<BlendState>,
6062 pub write_mask: Option<ColorWriteMask>,
6063 }
6064 impl Default for ColorTargetState {
6065 fn default() -> Self {
6066 Self {
6067 extensions: Vec::new(),
6068 format: None,
6069 blend: None,
6070 write_mask: Some(ColorWriteMask::ALL),
6071 }
6072 }
6073 }
6074 impl ColorTargetState {
6075 pub fn new() -> Self {
6076 Self::default()
6077 }
6078 pub(crate) fn to_ffi(
6079 &self,
6080 ) -> (ffi::WGPUColorTargetState, ChainedStructStorage) {
6081 let mut storage = ChainedStructStorage::new();
6082 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6083 for ext in self.extensions.iter().rev() {
6084 next = ext.push_chain(&mut storage, next);
6085 }
6086 let mut raw: ffi::WGPUColorTargetState = unsafe { std::mem::zeroed() };
6087 raw.nextInChain = next;
6088 if let Some(value) = self.format {
6089 raw.format = value.into();
6090 } else {
6091 raw.format = 0 as ffi::WGPUTextureFormat;
6092 }
6093 if let Some(value) = &self.blend {
6094 let (raw_value, storage_value) = value.to_ffi();
6095 let ptr = storage.push_value(raw_value);
6096 raw.blend = ptr;
6097 storage.push_storage(storage_value);
6098 } else {
6099 raw.blend = std::ptr::null();
6100 }
6101 if let Some(value) = self.write_mask {
6102 raw.writeMask = value.into();
6103 } else {
6104 raw.writeMask = 0 as ffi::WGPUColorWriteMask;
6105 }
6106 (raw, storage)
6107 }
6108 pub fn with_extension(mut self, extension: ColorTargetStateExtension) -> Self {
6109 self.extensions.push(extension);
6110 self
6111 }
6112 pub(crate) fn from_ffi(value: ffi::WGPUColorTargetState) -> Self {
6113 Self {
6114 extensions: Vec::new(),
6115 format: Some(value.format.into()),
6116 blend: if value.blend.is_null() {
6117 None
6118 } else {
6119 Some(BlendState::from_ffi(unsafe { *value.blend }))
6120 },
6121 write_mask: Some(value.writeMask.into()),
6122 }
6123 }
6124 }
6125 pub struct ColorTargetStateExpandResolveTextureDawn {
6126 pub enabled: Option<bool>,
6127 }
6128 impl Default for ColorTargetStateExpandResolveTextureDawn {
6129 fn default() -> Self {
6130 Self { enabled: None }
6131 }
6132 }
6133 impl ColorTargetStateExpandResolveTextureDawn {
6134 pub fn new() -> Self {
6135 Self::default()
6136 }
6137 pub(crate) fn to_ffi(
6138 &self,
6139 ) -> (ffi::WGPUColorTargetStateExpandResolveTextureDawn, ChainedStructStorage) {
6140 let mut storage = ChainedStructStorage::new();
6141 let mut raw: ffi::WGPUColorTargetStateExpandResolveTextureDawn = unsafe {
6142 std::mem::zeroed()
6143 };
6144 raw.enabled = if self.enabled.unwrap_or(false) { 1 } else { 0 };
6145 (raw, storage)
6146 }
6147 pub(crate) fn from_ffi(
6148 value: ffi::WGPUColorTargetStateExpandResolveTextureDawn,
6149 ) -> Self {
6150 Self {
6151 enabled: Some(value.enabled != 0),
6152 }
6153 }
6154 }
6155 pub struct CommandBufferDescriptor {
6156 pub(crate) extensions: Vec<CommandBufferDescriptorExtension>,
6157 pub label: Option<String>,
6158 }
6159 impl Default for CommandBufferDescriptor {
6160 fn default() -> Self {
6161 Self {
6162 extensions: Vec::new(),
6163 label: None,
6164 }
6165 }
6166 }
6167 impl CommandBufferDescriptor {
6168 pub fn new() -> Self {
6169 Self::default()
6170 }
6171 pub(crate) fn to_ffi(
6172 &self,
6173 ) -> (ffi::WGPUCommandBufferDescriptor, ChainedStructStorage) {
6174 let mut storage = ChainedStructStorage::new();
6175 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6176 for ext in self.extensions.iter().rev() {
6177 next = ext.push_chain(&mut storage, next);
6178 }
6179 let mut raw: ffi::WGPUCommandBufferDescriptor = unsafe {
6180 std::mem::zeroed()
6181 };
6182 raw.nextInChain = next;
6183 if let Some(value) = &self.label {
6184 raw.label = ffi::WGPUStringView {
6185 data: value.as_ptr().cast(),
6186 length: value.len(),
6187 };
6188 } else {
6189 raw.label = ffi::WGPUStringView {
6190 data: std::ptr::null(),
6191 length: 0,
6192 };
6193 }
6194 (raw, storage)
6195 }
6196 pub fn with_extension(
6197 mut self,
6198 extension: CommandBufferDescriptorExtension,
6199 ) -> Self {
6200 self.extensions.push(extension);
6201 self
6202 }
6203 pub(crate) fn from_ffi(value: ffi::WGPUCommandBufferDescriptor) -> Self {
6204 Self {
6205 extensions: Vec::new(),
6206 label: if value.label.data.is_null() || value.label.length == 0 {
6207 None
6208 } else {
6209 Some(string_view_to_string(value.label))
6210 },
6211 }
6212 }
6213 }
6214 pub struct CommandEncoderDescriptor {
6215 pub(crate) extensions: Vec<CommandEncoderDescriptorExtension>,
6216 pub label: Option<String>,
6217 }
6218 impl Default for CommandEncoderDescriptor {
6219 fn default() -> Self {
6220 Self {
6221 extensions: Vec::new(),
6222 label: None,
6223 }
6224 }
6225 }
6226 impl CommandEncoderDescriptor {
6227 pub fn new() -> Self {
6228 Self::default()
6229 }
6230 pub(crate) fn to_ffi(
6231 &self,
6232 ) -> (ffi::WGPUCommandEncoderDescriptor, ChainedStructStorage) {
6233 let mut storage = ChainedStructStorage::new();
6234 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6235 for ext in self.extensions.iter().rev() {
6236 next = ext.push_chain(&mut storage, next);
6237 }
6238 let mut raw: ffi::WGPUCommandEncoderDescriptor = unsafe {
6239 std::mem::zeroed()
6240 };
6241 raw.nextInChain = next;
6242 if let Some(value) = &self.label {
6243 raw.label = ffi::WGPUStringView {
6244 data: value.as_ptr().cast(),
6245 length: value.len(),
6246 };
6247 } else {
6248 raw.label = ffi::WGPUStringView {
6249 data: std::ptr::null(),
6250 length: 0,
6251 };
6252 }
6253 (raw, storage)
6254 }
6255 pub fn with_extension(
6256 mut self,
6257 extension: CommandEncoderDescriptorExtension,
6258 ) -> Self {
6259 self.extensions.push(extension);
6260 self
6261 }
6262 pub(crate) fn from_ffi(value: ffi::WGPUCommandEncoderDescriptor) -> Self {
6263 Self {
6264 extensions: Vec::new(),
6265 label: if value.label.data.is_null() || value.label.length == 0 {
6266 None
6267 } else {
6268 Some(string_view_to_string(value.label))
6269 },
6270 }
6271 }
6272 }
6273 pub struct CompilationInfo {
6274 pub(crate) extensions: Vec<CompilationInfoExtension>,
6275 pub messages: Option<Vec<CompilationMessage>>,
6276 }
6277 impl Default for CompilationInfo {
6278 fn default() -> Self {
6279 Self {
6280 extensions: Vec::new(),
6281 messages: None,
6282 }
6283 }
6284 }
6285 impl CompilationInfo {
6286 pub fn new() -> Self {
6287 Self::default()
6288 }
6289 pub(crate) fn to_ffi(&self) -> (ffi::WGPUCompilationInfo, ChainedStructStorage) {
6290 let mut storage = ChainedStructStorage::new();
6291 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6292 for ext in self.extensions.iter().rev() {
6293 next = ext.push_chain(&mut storage, next);
6294 }
6295 let mut raw: ffi::WGPUCompilationInfo = unsafe { std::mem::zeroed() };
6296 raw.nextInChain = next;
6297 raw.messageCount = self.messages.as_ref().map(|v| v.len()).unwrap_or(0);
6298 if let Some(values) = &self.messages {
6299 let len_value = values.len();
6300 let mut raw_vec: Vec<ffi::WGPUCompilationMessage> = Vec::with_capacity(
6301 values.len(),
6302 );
6303 for item in values.iter() {
6304 let (raw_item, storage_item) = item.to_ffi();
6305 raw_vec.push(raw_item);
6306 storage.push_storage(storage_item);
6307 }
6308 let ptr = storage.push_vec(raw_vec);
6309 raw.messages = ptr;
6310 raw.messageCount = len_value;
6311 } else {
6312 raw.messages = std::ptr::null();
6313 raw.messageCount = 0;
6314 }
6315 (raw, storage)
6316 }
6317 pub fn with_extension(mut self, extension: CompilationInfoExtension) -> Self {
6318 self.extensions.push(extension);
6319 self
6320 }
6321 pub(crate) fn from_ffi(value: ffi::WGPUCompilationInfo) -> Self {
6322 Self {
6323 extensions: Vec::new(),
6324 messages: if value.messages.is_null() {
6325 None
6326 } else {
6327 Some(
6328 unsafe {
6329 std::slice::from_raw_parts(
6330 value.messages,
6331 value.messageCount as usize,
6332 )
6333 }
6334 .iter()
6335 .map(|raw| CompilationMessage::from_ffi(*raw))
6336 .collect(),
6337 )
6338 },
6339 }
6340 }
6341 }
6342 pub struct CompilationMessage {
6343 pub(crate) extensions: Vec<CompilationMessageExtension>,
6344 pub message: Option<String>,
6345 pub r#type: Option<CompilationMessageType>,
6346 pub line_num: Option<u64>,
6347 pub line_pos: Option<u64>,
6348 pub offset: Option<u64>,
6349 pub length: Option<u64>,
6350 }
6351 impl Default for CompilationMessage {
6352 fn default() -> Self {
6353 Self {
6354 extensions: Vec::new(),
6355 message: None,
6356 r#type: None,
6357 line_num: None,
6358 line_pos: None,
6359 offset: None,
6360 length: None,
6361 }
6362 }
6363 }
6364 impl CompilationMessage {
6365 pub fn new() -> Self {
6366 Self::default()
6367 }
6368 pub(crate) fn to_ffi(
6369 &self,
6370 ) -> (ffi::WGPUCompilationMessage, ChainedStructStorage) {
6371 let mut storage = ChainedStructStorage::new();
6372 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6373 for ext in self.extensions.iter().rev() {
6374 next = ext.push_chain(&mut storage, next);
6375 }
6376 let mut raw: ffi::WGPUCompilationMessage = unsafe { std::mem::zeroed() };
6377 raw.nextInChain = next;
6378 if let Some(value) = &self.message {
6379 raw.message = ffi::WGPUStringView {
6380 data: value.as_ptr().cast(),
6381 length: value.len(),
6382 };
6383 } else {
6384 raw.message = ffi::WGPUStringView {
6385 data: std::ptr::null(),
6386 length: 0,
6387 };
6388 }
6389 if let Some(value) = self.r#type {
6390 raw.type_ = value.into();
6391 } else {
6392 raw.type_ = 0 as ffi::WGPUCompilationMessageType;
6393 }
6394 if let Some(value) = self.line_num {
6395 raw.lineNum = value;
6396 }
6397 if let Some(value) = self.line_pos {
6398 raw.linePos = value;
6399 }
6400 if let Some(value) = self.offset {
6401 raw.offset = value;
6402 }
6403 if let Some(value) = self.length {
6404 raw.length = value;
6405 }
6406 (raw, storage)
6407 }
6408 pub fn with_extension(mut self, extension: CompilationMessageExtension) -> Self {
6409 self.extensions.push(extension);
6410 self
6411 }
6412 pub(crate) fn from_ffi(value: ffi::WGPUCompilationMessage) -> Self {
6413 Self {
6414 extensions: Vec::new(),
6415 message: Some(string_view_to_string(value.message)),
6416 r#type: Some(value.type_.into()),
6417 line_num: Some(value.lineNum),
6418 line_pos: Some(value.linePos),
6419 offset: Some(value.offset),
6420 length: Some(value.length),
6421 }
6422 }
6423 }
6424 pub struct ComputePassDescriptor {
6425 pub(crate) extensions: Vec<ComputePassDescriptorExtension>,
6426 pub label: Option<String>,
6427 pub timestamp_writes: Option<PassTimestampWrites>,
6428 }
6429 impl Default for ComputePassDescriptor {
6430 fn default() -> Self {
6431 Self {
6432 extensions: Vec::new(),
6433 label: None,
6434 timestamp_writes: None,
6435 }
6436 }
6437 }
6438 impl ComputePassDescriptor {
6439 pub fn new() -> Self {
6440 Self::default()
6441 }
6442 pub(crate) fn to_ffi(
6443 &self,
6444 ) -> (ffi::WGPUComputePassDescriptor, ChainedStructStorage) {
6445 let mut storage = ChainedStructStorage::new();
6446 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6447 for ext in self.extensions.iter().rev() {
6448 next = ext.push_chain(&mut storage, next);
6449 }
6450 let mut raw: ffi::WGPUComputePassDescriptor = unsafe { std::mem::zeroed() };
6451 raw.nextInChain = next;
6452 if let Some(value) = &self.label {
6453 raw.label = ffi::WGPUStringView {
6454 data: value.as_ptr().cast(),
6455 length: value.len(),
6456 };
6457 } else {
6458 raw.label = ffi::WGPUStringView {
6459 data: std::ptr::null(),
6460 length: 0,
6461 };
6462 }
6463 if let Some(value) = &self.timestamp_writes {
6464 let (raw_value, storage_value) = value.to_ffi();
6465 let ptr = storage.push_value(raw_value);
6466 raw.timestampWrites = ptr;
6467 storage.push_storage(storage_value);
6468 } else {
6469 raw.timestampWrites = std::ptr::null();
6470 }
6471 (raw, storage)
6472 }
6473 pub fn with_extension(
6474 mut self,
6475 extension: ComputePassDescriptorExtension,
6476 ) -> Self {
6477 self.extensions.push(extension);
6478 self
6479 }
6480 pub(crate) fn from_ffi(value: ffi::WGPUComputePassDescriptor) -> Self {
6481 Self {
6482 extensions: Vec::new(),
6483 label: if value.label.data.is_null() || value.label.length == 0 {
6484 None
6485 } else {
6486 Some(string_view_to_string(value.label))
6487 },
6488 timestamp_writes: if value.timestampWrites.is_null() {
6489 None
6490 } else {
6491 Some(
6492 PassTimestampWrites::from_ffi(unsafe { *value.timestampWrites }),
6493 )
6494 },
6495 }
6496 }
6497 }
6498 pub struct ComputePipelineDescriptor {
6499 pub(crate) extensions: Vec<ComputePipelineDescriptorExtension>,
6500 pub label: Option<String>,
6501 pub layout: Option<PipelineLayout>,
6502 pub compute: Option<ComputeState>,
6503 }
6504 impl Default for ComputePipelineDescriptor {
6505 fn default() -> Self {
6506 Self {
6507 extensions: Vec::new(),
6508 label: None,
6509 layout: None,
6510 compute: None,
6511 }
6512 }
6513 }
6514 impl ComputePipelineDescriptor {
6515 pub fn new() -> Self {
6516 Self::default()
6517 }
6518 pub(crate) fn to_ffi(
6519 &self,
6520 ) -> (ffi::WGPUComputePipelineDescriptor, ChainedStructStorage) {
6521 let mut storage = ChainedStructStorage::new();
6522 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6523 for ext in self.extensions.iter().rev() {
6524 next = ext.push_chain(&mut storage, next);
6525 }
6526 let mut raw: ffi::WGPUComputePipelineDescriptor = unsafe {
6527 std::mem::zeroed()
6528 };
6529 raw.nextInChain = next;
6530 if let Some(value) = &self.label {
6531 raw.label = ffi::WGPUStringView {
6532 data: value.as_ptr().cast(),
6533 length: value.len(),
6534 };
6535 } else {
6536 raw.label = ffi::WGPUStringView {
6537 data: std::ptr::null(),
6538 length: 0,
6539 };
6540 }
6541 raw.layout = self
6542 .layout
6543 .as_ref()
6544 .map(|v| v.as_raw())
6545 .unwrap_or(std::ptr::null_mut());
6546 if let Some(value) = &self.compute {
6547 let (raw_value, storage_value) = value.to_ffi();
6548 raw.compute = raw_value;
6549 storage.push_storage(storage_value);
6550 }
6551 (raw, storage)
6552 }
6553 pub fn with_extension(
6554 mut self,
6555 extension: ComputePipelineDescriptorExtension,
6556 ) -> Self {
6557 self.extensions.push(extension);
6558 self
6559 }
6560 pub(crate) fn from_ffi(value: ffi::WGPUComputePipelineDescriptor) -> Self {
6561 Self {
6562 extensions: Vec::new(),
6563 label: if value.label.data.is_null() || value.label.length == 0 {
6564 None
6565 } else {
6566 Some(string_view_to_string(value.label))
6567 },
6568 layout: if value.layout.is_null() {
6569 None
6570 } else {
6571 Some(unsafe { PipelineLayout::from_raw(value.layout) })
6572 },
6573 compute: Some(ComputeState::from_ffi(value.compute)),
6574 }
6575 }
6576 }
6577 pub struct ComputeState {
6578 pub(crate) extensions: Vec<ComputeStateExtension>,
6579 pub module: Option<ShaderModule>,
6580 pub entry_point: Option<String>,
6581 pub constants: Option<Vec<ConstantEntry>>,
6582 }
6583 impl Default for ComputeState {
6584 fn default() -> Self {
6585 Self {
6586 extensions: Vec::new(),
6587 module: None,
6588 entry_point: None,
6589 constants: None,
6590 }
6591 }
6592 }
6593 impl ComputeState {
6594 pub fn new() -> Self {
6595 Self::default()
6596 }
6597 pub(crate) fn to_ffi(&self) -> (ffi::WGPUComputeState, ChainedStructStorage) {
6598 let mut storage = ChainedStructStorage::new();
6599 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6600 for ext in self.extensions.iter().rev() {
6601 next = ext.push_chain(&mut storage, next);
6602 }
6603 let mut raw: ffi::WGPUComputeState = unsafe { std::mem::zeroed() };
6604 raw.nextInChain = next;
6605 raw.module = self
6606 .module
6607 .as_ref()
6608 .map(|v| v.as_raw())
6609 .unwrap_or(std::ptr::null_mut());
6610 if let Some(value) = &self.entry_point {
6611 raw.entryPoint = ffi::WGPUStringView {
6612 data: value.as_ptr().cast(),
6613 length: value.len(),
6614 };
6615 } else {
6616 raw.entryPoint = ffi::WGPUStringView {
6617 data: std::ptr::null(),
6618 length: 0,
6619 };
6620 }
6621 raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
6622 if let Some(values) = &self.constants {
6623 let len_value = values.len();
6624 let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
6625 values.len(),
6626 );
6627 for item in values.iter() {
6628 let (raw_item, storage_item) = item.to_ffi();
6629 raw_vec.push(raw_item);
6630 storage.push_storage(storage_item);
6631 }
6632 let ptr = storage.push_vec(raw_vec);
6633 raw.constants = ptr;
6634 raw.constantCount = len_value;
6635 } else {
6636 raw.constants = std::ptr::null();
6637 raw.constantCount = 0;
6638 }
6639 (raw, storage)
6640 }
6641 pub fn with_extension(mut self, extension: ComputeStateExtension) -> Self {
6642 self.extensions.push(extension);
6643 self
6644 }
6645 pub(crate) fn from_ffi(value: ffi::WGPUComputeState) -> Self {
6646 Self {
6647 extensions: Vec::new(),
6648 module: Some(unsafe { ShaderModule::from_raw(value.module) }),
6649 entry_point: if value.entryPoint.data.is_null()
6650 || value.entryPoint.length == 0
6651 {
6652 None
6653 } else {
6654 Some(string_view_to_string(value.entryPoint))
6655 },
6656 constants: if value.constants.is_null() {
6657 None
6658 } else {
6659 Some(
6660 unsafe {
6661 std::slice::from_raw_parts(
6662 value.constants,
6663 value.constantCount as usize,
6664 )
6665 }
6666 .iter()
6667 .map(|raw| ConstantEntry::from_ffi(*raw))
6668 .collect(),
6669 )
6670 },
6671 }
6672 }
6673 }
6674 pub struct ConstantEntry {
6675 pub(crate) extensions: Vec<ConstantEntryExtension>,
6676 pub key: Option<String>,
6677 pub value: Option<f64>,
6678 }
6679 impl Default for ConstantEntry {
6680 fn default() -> Self {
6681 Self {
6682 extensions: Vec::new(),
6683 key: None,
6684 value: None,
6685 }
6686 }
6687 }
6688 impl ConstantEntry {
6689 pub fn new() -> Self {
6690 Self::default()
6691 }
6692 pub(crate) fn to_ffi(&self) -> (ffi::WGPUConstantEntry, ChainedStructStorage) {
6693 let mut storage = ChainedStructStorage::new();
6694 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6695 for ext in self.extensions.iter().rev() {
6696 next = ext.push_chain(&mut storage, next);
6697 }
6698 let mut raw: ffi::WGPUConstantEntry = unsafe { std::mem::zeroed() };
6699 raw.nextInChain = next;
6700 if let Some(value) = &self.key {
6701 raw.key = ffi::WGPUStringView {
6702 data: value.as_ptr().cast(),
6703 length: value.len(),
6704 };
6705 } else {
6706 raw.key = ffi::WGPUStringView {
6707 data: std::ptr::null(),
6708 length: 0,
6709 };
6710 }
6711 if let Some(value) = self.value {
6712 raw.value = value;
6713 }
6714 (raw, storage)
6715 }
6716 pub fn with_extension(mut self, extension: ConstantEntryExtension) -> Self {
6717 self.extensions.push(extension);
6718 self
6719 }
6720 pub(crate) fn from_ffi(value: ffi::WGPUConstantEntry) -> Self {
6721 Self {
6722 extensions: Vec::new(),
6723 key: Some(string_view_to_string(value.key)),
6724 value: Some(value.value),
6725 }
6726 }
6727 }
6728 pub struct CopyTextureForBrowserOptions {
6729 pub(crate) extensions: Vec<CopyTextureForBrowserOptionsExtension>,
6730 pub flip_y: Option<bool>,
6731 pub needs_color_space_conversion: Option<bool>,
6732 pub src_alpha_mode: Option<AlphaMode>,
6733 pub src_transfer_function_parameters: Option<Vec<f32>>,
6734 pub conversion_matrix: Option<Vec<f32>>,
6735 pub dst_transfer_function_parameters: Option<Vec<f32>>,
6736 pub dst_alpha_mode: Option<AlphaMode>,
6737 pub internal_usage: Option<bool>,
6738 }
6739 impl Default for CopyTextureForBrowserOptions {
6740 fn default() -> Self {
6741 Self {
6742 extensions: Vec::new(),
6743 flip_y: None,
6744 needs_color_space_conversion: None,
6745 src_alpha_mode: Some(AlphaMode::Unpremultiplied),
6746 src_transfer_function_parameters: None,
6747 conversion_matrix: None,
6748 dst_transfer_function_parameters: None,
6749 dst_alpha_mode: Some(AlphaMode::Unpremultiplied),
6750 internal_usage: None,
6751 }
6752 }
6753 }
6754 impl CopyTextureForBrowserOptions {
6755 pub fn new() -> Self {
6756 Self::default()
6757 }
6758 pub(crate) fn to_ffi(
6759 &self,
6760 ) -> (ffi::WGPUCopyTextureForBrowserOptions, ChainedStructStorage) {
6761 let mut storage = ChainedStructStorage::new();
6762 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
6763 for ext in self.extensions.iter().rev() {
6764 next = ext.push_chain(&mut storage, next);
6765 }
6766 let mut raw: ffi::WGPUCopyTextureForBrowserOptions = unsafe {
6767 std::mem::zeroed()
6768 };
6769 raw.nextInChain = next;
6770 raw.flipY = if self.flip_y.unwrap_or(false) { 1 } else { 0 };
6771 raw.needsColorSpaceConversion = if self
6772 .needs_color_space_conversion
6773 .unwrap_or(false)
6774 {
6775 1
6776 } else {
6777 0
6778 };
6779 if let Some(value) = self.src_alpha_mode {
6780 raw.srcAlphaMode = value.into();
6781 } else {
6782 raw.srcAlphaMode = 0 as ffi::WGPUAlphaMode;
6783 }
6784 if let Some(values) = &self.src_transfer_function_parameters {
6785 let len_value = values.len();
6786 let raw_vec = values.to_vec();
6787 let ptr = storage.push_vec(raw_vec);
6788 raw.srcTransferFunctionParameters = ptr;
6789 } else {
6790 raw.srcTransferFunctionParameters = std::ptr::null();
6791 let _ = 0;
6792 }
6793 if let Some(values) = &self.conversion_matrix {
6794 let len_value = values.len();
6795 let raw_vec = values.to_vec();
6796 let ptr = storage.push_vec(raw_vec);
6797 raw.conversionMatrix = ptr;
6798 } else {
6799 raw.conversionMatrix = std::ptr::null();
6800 let _ = 0;
6801 }
6802 if let Some(values) = &self.dst_transfer_function_parameters {
6803 let len_value = values.len();
6804 let raw_vec = values.to_vec();
6805 let ptr = storage.push_vec(raw_vec);
6806 raw.dstTransferFunctionParameters = ptr;
6807 } else {
6808 raw.dstTransferFunctionParameters = std::ptr::null();
6809 let _ = 0;
6810 }
6811 if let Some(value) = self.dst_alpha_mode {
6812 raw.dstAlphaMode = value.into();
6813 } else {
6814 raw.dstAlphaMode = 0 as ffi::WGPUAlphaMode;
6815 }
6816 raw.internalUsage = if self.internal_usage.unwrap_or(false) { 1 } else { 0 };
6817 (raw, storage)
6818 }
6819 pub fn with_extension(
6820 mut self,
6821 extension: CopyTextureForBrowserOptionsExtension,
6822 ) -> Self {
6823 self.extensions.push(extension);
6824 self
6825 }
6826 pub(crate) fn from_ffi(value: ffi::WGPUCopyTextureForBrowserOptions) -> Self {
6827 Self {
6828 extensions: Vec::new(),
6829 flip_y: Some(value.flipY != 0),
6830 needs_color_space_conversion: Some(value.needsColorSpaceConversion != 0),
6831 src_alpha_mode: Some(value.srcAlphaMode.into()),
6832 src_transfer_function_parameters: if value
6833 .srcTransferFunctionParameters
6834 .is_null()
6835 {
6836 None
6837 } else {
6838 Some(
6839 unsafe {
6840 std::slice::from_raw_parts(
6841 value.srcTransferFunctionParameters,
6842 7usize,
6843 )
6844 }
6845 .to_vec(),
6846 )
6847 },
6848 conversion_matrix: if value.conversionMatrix.is_null() {
6849 None
6850 } else {
6851 Some(
6852 unsafe {
6853 std::slice::from_raw_parts(value.conversionMatrix, 9usize)
6854 }
6855 .to_vec(),
6856 )
6857 },
6858 dst_transfer_function_parameters: if value
6859 .dstTransferFunctionParameters
6860 .is_null()
6861 {
6862 None
6863 } else {
6864 Some(
6865 unsafe {
6866 std::slice::from_raw_parts(
6867 value.dstTransferFunctionParameters,
6868 7usize,
6869 )
6870 }
6871 .to_vec(),
6872 )
6873 },
6874 dst_alpha_mode: Some(value.dstAlphaMode.into()),
6875 internal_usage: Some(value.internalUsage != 0),
6876 }
6877 }
6878 }
6879 pub struct DawnWGSLBlocklist {
6880 pub blocklisted_features: Option<Vec<String>>,
6881 }
6882 impl Default for DawnWGSLBlocklist {
6883 fn default() -> Self {
6884 Self { blocklisted_features: None }
6885 }
6886 }
6887 impl DawnWGSLBlocklist {
6888 pub fn new() -> Self {
6889 Self::default()
6890 }
6891 pub(crate) fn to_ffi(
6892 &self,
6893 ) -> (ffi::WGPUDawnWGSLBlocklist, ChainedStructStorage) {
6894 let mut storage = ChainedStructStorage::new();
6895 let mut raw: ffi::WGPUDawnWGSLBlocklist = unsafe { std::mem::zeroed() };
6896 raw.blocklistedFeatureCount = self
6897 .blocklisted_features
6898 .as_ref()
6899 .map(|v| v.len())
6900 .unwrap_or(0);
6901 if let Some(values) = &self.blocklisted_features {
6902 let len_value = values.len();
6903 let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
6904 values.len(),
6905 );
6906 let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
6907 values.len(),
6908 );
6909 for item in values.iter() {
6910 let c_string = std::ffi::CString::new(item.as_str())
6911 .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
6912 ptrs.push(c_string.as_ptr());
6913 c_strings.push(c_string);
6914 }
6915 let ptr = storage.push_vec(ptrs);
6916 storage.push_any(c_strings);
6917 raw.blocklistedFeatures = ptr;
6918 raw.blocklistedFeatureCount = len_value;
6919 } else {
6920 raw.blocklistedFeatures = std::ptr::null();
6921 raw.blocklistedFeatureCount = 0;
6922 }
6923 (raw, storage)
6924 }
6925 pub(crate) fn from_ffi(value: ffi::WGPUDawnWGSLBlocklist) -> Self {
6926 Self {
6927 blocklisted_features: if value.blocklistedFeatures.is_null() {
6928 None
6929 } else {
6930 Some(
6931 unsafe {
6932 std::slice::from_raw_parts(
6933 value.blocklistedFeatures,
6934 value.blocklistedFeatureCount as usize,
6935 )
6936 }
6937 .iter()
6938 .map(|raw| {
6939 if raw.is_null() {
6940 String::new()
6941 } else {
6942 unsafe { CStr::from_ptr(*raw) }
6943 .to_string_lossy()
6944 .into_owned()
6945 }
6946 })
6947 .collect(),
6948 )
6949 },
6950 }
6951 }
6952 }
6953 pub struct DawnAdapterPropertiesPowerPreference {
6954 pub power_preference: Option<PowerPreference>,
6955 }
6956 impl Default for DawnAdapterPropertiesPowerPreference {
6957 fn default() -> Self {
6958 Self { power_preference: None }
6959 }
6960 }
6961 impl DawnAdapterPropertiesPowerPreference {
6962 pub fn new() -> Self {
6963 Self::default()
6964 }
6965 pub(crate) fn to_ffi(
6966 &self,
6967 ) -> (ffi::WGPUDawnAdapterPropertiesPowerPreference, ChainedStructStorage) {
6968 let mut storage = ChainedStructStorage::new();
6969 let mut raw: ffi::WGPUDawnAdapterPropertiesPowerPreference = unsafe {
6970 std::mem::zeroed()
6971 };
6972 if let Some(value) = self.power_preference {
6973 raw.powerPreference = value.into();
6974 } else {
6975 raw.powerPreference = 0 as ffi::WGPUPowerPreference;
6976 }
6977 (raw, storage)
6978 }
6979 pub(crate) fn from_ffi(
6980 value: ffi::WGPUDawnAdapterPropertiesPowerPreference,
6981 ) -> Self {
6982 Self {
6983 power_preference: Some(value.powerPreference.into()),
6984 }
6985 }
6986 }
6987 pub struct DawnBufferDescriptorErrorInfoFromWireClient {
6988 pub out_of_memory: Option<bool>,
6989 }
6990 impl Default for DawnBufferDescriptorErrorInfoFromWireClient {
6991 fn default() -> Self {
6992 Self { out_of_memory: None }
6993 }
6994 }
6995 impl DawnBufferDescriptorErrorInfoFromWireClient {
6996 pub fn new() -> Self {
6997 Self::default()
6998 }
6999 pub(crate) fn to_ffi(
7000 &self,
7001 ) -> (
7002 ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient,
7003 ChainedStructStorage,
7004 ) {
7005 let mut storage = ChainedStructStorage::new();
7006 let mut raw: ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient = unsafe {
7007 std::mem::zeroed()
7008 };
7009 raw.outOfMemory = if self.out_of_memory.unwrap_or(false) { 1 } else { 0 };
7010 (raw, storage)
7011 }
7012 pub(crate) fn from_ffi(
7013 value: ffi::WGPUDawnBufferDescriptorErrorInfoFromWireClient,
7014 ) -> Self {
7015 Self {
7016 out_of_memory: Some(value.outOfMemory != 0),
7017 }
7018 }
7019 }
7020 pub struct DawnCacheDeviceDescriptor {
7021 pub isolation_key: Option<String>,
7022 pub load_data_function: Option<DawnLoadCacheDataFunction>,
7023 pub store_data_function: Option<DawnStoreCacheDataFunction>,
7024 pub function_userdata: Option<*mut std::ffi::c_void>,
7025 }
7026 impl Default for DawnCacheDeviceDescriptor {
7027 fn default() -> Self {
7028 Self {
7029 isolation_key: None,
7030 load_data_function: None,
7031 store_data_function: None,
7032 function_userdata: None,
7033 }
7034 }
7035 }
7036 impl DawnCacheDeviceDescriptor {
7037 pub fn new() -> Self {
7038 Self::default()
7039 }
7040 pub(crate) fn to_ffi(
7041 &self,
7042 ) -> (ffi::WGPUDawnCacheDeviceDescriptor, ChainedStructStorage) {
7043 let mut storage = ChainedStructStorage::new();
7044 let mut raw: ffi::WGPUDawnCacheDeviceDescriptor = unsafe {
7045 std::mem::zeroed()
7046 };
7047 if let Some(value) = &self.isolation_key {
7048 raw.isolationKey = ffi::WGPUStringView {
7049 data: value.as_ptr().cast(),
7050 length: value.len(),
7051 };
7052 } else {
7053 raw.isolationKey = ffi::WGPUStringView {
7054 data: std::ptr::null(),
7055 length: 0,
7056 };
7057 }
7058 if let Some(value) = self.load_data_function {
7059 raw.loadDataFunction = value;
7060 }
7061 if let Some(value) = self.store_data_function {
7062 raw.storeDataFunction = value;
7063 }
7064 if let Some(value) = self.function_userdata {
7065 raw.functionUserdata = value;
7066 }
7067 (raw, storage)
7068 }
7069 pub(crate) fn from_ffi(value: ffi::WGPUDawnCacheDeviceDescriptor) -> Self {
7070 Self {
7071 isolation_key: Some(string_view_to_string(value.isolationKey)),
7072 load_data_function: Some(value.loadDataFunction),
7073 store_data_function: Some(value.storeDataFunction),
7074 function_userdata: Some(value.functionUserdata),
7075 }
7076 }
7077 }
7078 pub struct DawnCompilationMessageUtf16 {
7079 pub line_pos: Option<u64>,
7080 pub offset: Option<u64>,
7081 pub length: Option<u64>,
7082 }
7083 impl Default for DawnCompilationMessageUtf16 {
7084 fn default() -> Self {
7085 Self {
7086 line_pos: None,
7087 offset: None,
7088 length: None,
7089 }
7090 }
7091 }
7092 impl DawnCompilationMessageUtf16 {
7093 pub fn new() -> Self {
7094 Self::default()
7095 }
7096 pub(crate) fn to_ffi(
7097 &self,
7098 ) -> (ffi::WGPUDawnCompilationMessageUtf16, ChainedStructStorage) {
7099 let mut storage = ChainedStructStorage::new();
7100 let mut raw: ffi::WGPUDawnCompilationMessageUtf16 = unsafe {
7101 std::mem::zeroed()
7102 };
7103 if let Some(value) = self.line_pos {
7104 raw.linePos = value;
7105 }
7106 if let Some(value) = self.offset {
7107 raw.offset = value;
7108 }
7109 if let Some(value) = self.length {
7110 raw.length = value;
7111 }
7112 (raw, storage)
7113 }
7114 pub(crate) fn from_ffi(value: ffi::WGPUDawnCompilationMessageUtf16) -> Self {
7115 Self {
7116 line_pos: Some(value.linePos),
7117 offset: Some(value.offset),
7118 length: Some(value.length),
7119 }
7120 }
7121 }
7122 pub struct DawnConsumeAdapterDescriptor {
7123 pub consume_adapter: Option<bool>,
7124 }
7125 impl Default for DawnConsumeAdapterDescriptor {
7126 fn default() -> Self {
7127 Self { consume_adapter: None }
7128 }
7129 }
7130 impl DawnConsumeAdapterDescriptor {
7131 pub fn new() -> Self {
7132 Self::default()
7133 }
7134 pub(crate) fn to_ffi(
7135 &self,
7136 ) -> (ffi::WGPUDawnConsumeAdapterDescriptor, ChainedStructStorage) {
7137 let mut storage = ChainedStructStorage::new();
7138 let mut raw: ffi::WGPUDawnConsumeAdapterDescriptor = unsafe {
7139 std::mem::zeroed()
7140 };
7141 raw.consumeAdapter = if self.consume_adapter.unwrap_or(false) {
7142 1
7143 } else {
7144 0
7145 };
7146 (raw, storage)
7147 }
7148 pub(crate) fn from_ffi(value: ffi::WGPUDawnConsumeAdapterDescriptor) -> Self {
7149 Self {
7150 consume_adapter: Some(value.consumeAdapter != 0),
7151 }
7152 }
7153 }
7154 pub struct DawnDeviceAllocatorControl {
7155 pub allocator_heap_block_size: Option<usize>,
7156 }
7157 impl Default for DawnDeviceAllocatorControl {
7158 fn default() -> Self {
7159 Self {
7160 allocator_heap_block_size: Some(0),
7161 }
7162 }
7163 }
7164 impl DawnDeviceAllocatorControl {
7165 pub fn new() -> Self {
7166 Self::default()
7167 }
7168 pub(crate) fn to_ffi(
7169 &self,
7170 ) -> (ffi::WGPUDawnDeviceAllocatorControl, ChainedStructStorage) {
7171 let mut storage = ChainedStructStorage::new();
7172 let mut raw: ffi::WGPUDawnDeviceAllocatorControl = unsafe {
7173 std::mem::zeroed()
7174 };
7175 if let Some(value) = self.allocator_heap_block_size {
7176 raw.allocatorHeapBlockSize = value;
7177 }
7178 (raw, storage)
7179 }
7180 pub(crate) fn from_ffi(value: ffi::WGPUDawnDeviceAllocatorControl) -> Self {
7181 Self {
7182 allocator_heap_block_size: Some(value.allocatorHeapBlockSize),
7183 }
7184 }
7185 }
7186 pub struct DawnDrmFormatCapabilities {
7187 pub properties: Option<Vec<DawnDrmFormatProperties>>,
7188 #[doc(hidden)]
7189 pub(crate) _free_members: Option<ffi::WGPUDawnDrmFormatCapabilities>,
7190 }
7191 impl Default for DawnDrmFormatCapabilities {
7192 fn default() -> Self {
7193 Self {
7194 properties: None,
7195 _free_members: None,
7196 }
7197 }
7198 }
7199 impl DawnDrmFormatCapabilities {
7200 pub fn new() -> Self {
7201 Self::default()
7202 }
7203 pub(crate) fn to_ffi(
7204 &self,
7205 ) -> (ffi::WGPUDawnDrmFormatCapabilities, ChainedStructStorage) {
7206 let mut storage = ChainedStructStorage::new();
7207 let mut raw: ffi::WGPUDawnDrmFormatCapabilities = unsafe {
7208 std::mem::zeroed()
7209 };
7210 raw.propertiesCount = self.properties.as_ref().map(|v| v.len()).unwrap_or(0);
7211 if let Some(values) = &self.properties {
7212 let len_value = values.len();
7213 let mut raw_vec: Vec<ffi::WGPUDawnDrmFormatProperties> = Vec::with_capacity(
7214 values.len(),
7215 );
7216 for item in values.iter() {
7217 let (raw_item, storage_item) = item.to_ffi();
7218 raw_vec.push(raw_item);
7219 storage.push_storage(storage_item);
7220 }
7221 let ptr = storage.push_vec(raw_vec);
7222 raw.properties = ptr;
7223 raw.propertiesCount = len_value;
7224 } else {
7225 raw.properties = std::ptr::null();
7226 raw.propertiesCount = 0;
7227 }
7228 (raw, storage)
7229 }
7230 pub(crate) fn from_ffi(value: ffi::WGPUDawnDrmFormatCapabilities) -> Self {
7231 Self {
7232 properties: if value.properties.is_null() {
7233 None
7234 } else {
7235 Some(
7236 unsafe {
7237 std::slice::from_raw_parts(
7238 value.properties,
7239 value.propertiesCount as usize,
7240 )
7241 }
7242 .iter()
7243 .map(|raw| DawnDrmFormatProperties::from_ffi(*raw))
7244 .collect(),
7245 )
7246 },
7247 _free_members: Some(value),
7248 }
7249 }
7250 pub(crate) fn free_members(value: ffi::WGPUDawnDrmFormatCapabilities) {
7251 unsafe { ffi::wgpuDawnDrmFormatCapabilitiesFreeMembers(value) };
7252 }
7253 }
7254 impl Drop for DawnDrmFormatCapabilities {
7255 fn drop(&mut self) {
7256 if let Some(value) = self._free_members.take() {
7257 unsafe { ffi::wgpuDawnDrmFormatCapabilitiesFreeMembers(value) };
7258 }
7259 }
7260 }
7261 pub struct DawnDrmFormatProperties {
7262 pub modifier: Option<u64>,
7263 pub modifier_plane_count: Option<u32>,
7264 }
7265 impl Default for DawnDrmFormatProperties {
7266 fn default() -> Self {
7267 Self {
7268 modifier: None,
7269 modifier_plane_count: None,
7270 }
7271 }
7272 }
7273 impl DawnDrmFormatProperties {
7274 pub fn new() -> Self {
7275 Self::default()
7276 }
7277 pub(crate) fn to_ffi(
7278 &self,
7279 ) -> (ffi::WGPUDawnDrmFormatProperties, ChainedStructStorage) {
7280 let mut storage = ChainedStructStorage::new();
7281 let mut raw: ffi::WGPUDawnDrmFormatProperties = unsafe {
7282 std::mem::zeroed()
7283 };
7284 if let Some(value) = self.modifier {
7285 raw.modifier = value;
7286 }
7287 if let Some(value) = self.modifier_plane_count {
7288 raw.modifierPlaneCount = value;
7289 }
7290 (raw, storage)
7291 }
7292 pub(crate) fn from_ffi(value: ffi::WGPUDawnDrmFormatProperties) -> Self {
7293 Self {
7294 modifier: Some(value.modifier),
7295 modifier_plane_count: Some(value.modifierPlaneCount),
7296 }
7297 }
7298 }
7299 pub struct DawnEncoderInternalUsageDescriptor {
7300 pub use_internal_usages: Option<bool>,
7301 }
7302 impl Default for DawnEncoderInternalUsageDescriptor {
7303 fn default() -> Self {
7304 Self { use_internal_usages: None }
7305 }
7306 }
7307 impl DawnEncoderInternalUsageDescriptor {
7308 pub fn new() -> Self {
7309 Self::default()
7310 }
7311 pub(crate) fn to_ffi(
7312 &self,
7313 ) -> (ffi::WGPUDawnEncoderInternalUsageDescriptor, ChainedStructStorage) {
7314 let mut storage = ChainedStructStorage::new();
7315 let mut raw: ffi::WGPUDawnEncoderInternalUsageDescriptor = unsafe {
7316 std::mem::zeroed()
7317 };
7318 raw.useInternalUsages = if self.use_internal_usages.unwrap_or(false) {
7319 1
7320 } else {
7321 0
7322 };
7323 (raw, storage)
7324 }
7325 pub(crate) fn from_ffi(
7326 value: ffi::WGPUDawnEncoderInternalUsageDescriptor,
7327 ) -> Self {
7328 Self {
7329 use_internal_usages: Some(value.useInternalUsages != 0),
7330 }
7331 }
7332 }
7333 pub struct DawnFakeBufferOOMForTesting {
7334 pub fake_oom_at_wire_client_map: Option<bool>,
7335 pub fake_oom_at_native_map: Option<bool>,
7336 pub fake_oom_at_device: Option<bool>,
7337 }
7338 impl Default for DawnFakeBufferOOMForTesting {
7339 fn default() -> Self {
7340 Self {
7341 fake_oom_at_wire_client_map: None,
7342 fake_oom_at_native_map: None,
7343 fake_oom_at_device: None,
7344 }
7345 }
7346 }
7347 impl DawnFakeBufferOOMForTesting {
7348 pub fn new() -> Self {
7349 Self::default()
7350 }
7351 pub(crate) fn to_ffi(
7352 &self,
7353 ) -> (ffi::WGPUDawnFakeBufferOOMForTesting, ChainedStructStorage) {
7354 let mut storage = ChainedStructStorage::new();
7355 let mut raw: ffi::WGPUDawnFakeBufferOOMForTesting = unsafe {
7356 std::mem::zeroed()
7357 };
7358 raw.fakeOOMAtWireClientMap = if self
7359 .fake_oom_at_wire_client_map
7360 .unwrap_or(false)
7361 {
7362 1
7363 } else {
7364 0
7365 };
7366 raw.fakeOOMAtNativeMap = if self.fake_oom_at_native_map.unwrap_or(false) {
7367 1
7368 } else {
7369 0
7370 };
7371 raw.fakeOOMAtDevice = if self.fake_oom_at_device.unwrap_or(false) {
7372 1
7373 } else {
7374 0
7375 };
7376 (raw, storage)
7377 }
7378 pub(crate) fn from_ffi(value: ffi::WGPUDawnFakeBufferOOMForTesting) -> Self {
7379 Self {
7380 fake_oom_at_wire_client_map: Some(value.fakeOOMAtWireClientMap != 0),
7381 fake_oom_at_native_map: Some(value.fakeOOMAtNativeMap != 0),
7382 fake_oom_at_device: Some(value.fakeOOMAtDevice != 0),
7383 }
7384 }
7385 }
7386 pub struct DawnFakeDeviceInitializeErrorForTesting {}
7387 impl Default for DawnFakeDeviceInitializeErrorForTesting {
7388 fn default() -> Self {
7389 Self {}
7390 }
7391 }
7392 impl DawnFakeDeviceInitializeErrorForTesting {
7393 pub fn new() -> Self {
7394 Self::default()
7395 }
7396 pub(crate) fn to_ffi(
7397 &self,
7398 ) -> (ffi::WGPUDawnFakeDeviceInitializeErrorForTesting, ChainedStructStorage) {
7399 let mut storage = ChainedStructStorage::new();
7400 let mut raw: ffi::WGPUDawnFakeDeviceInitializeErrorForTesting = unsafe {
7401 std::mem::zeroed()
7402 };
7403 (raw, storage)
7404 }
7405 pub(crate) fn from_ffi(
7406 value: ffi::WGPUDawnFakeDeviceInitializeErrorForTesting,
7407 ) -> Self {
7408 let _ = value;
7409 Self::default()
7410 }
7411 }
7412 pub struct DawnFormatCapabilities {
7413 pub(crate) extensions: Vec<DawnFormatCapabilitiesExtension>,
7414 }
7415 impl Default for DawnFormatCapabilities {
7416 fn default() -> Self {
7417 Self { extensions: Vec::new() }
7418 }
7419 }
7420 impl DawnFormatCapabilities {
7421 pub fn new() -> Self {
7422 Self::default()
7423 }
7424 pub(crate) fn to_ffi(
7425 &self,
7426 ) -> (ffi::WGPUDawnFormatCapabilities, ChainedStructStorage) {
7427 let mut storage = ChainedStructStorage::new();
7428 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7429 for ext in self.extensions.iter().rev() {
7430 next = ext.push_chain(&mut storage, next);
7431 }
7432 let mut raw: ffi::WGPUDawnFormatCapabilities = unsafe { std::mem::zeroed() };
7433 raw.nextInChain = next;
7434 (raw, storage)
7435 }
7436 pub fn with_extension(
7437 mut self,
7438 extension: DawnFormatCapabilitiesExtension,
7439 ) -> Self {
7440 self.extensions.push(extension);
7441 self
7442 }
7443 pub(crate) fn from_ffi(value: ffi::WGPUDawnFormatCapabilities) -> Self {
7444 Self { extensions: Vec::new() }
7445 }
7446 }
7447 pub struct DawnHostMappedPointerLimits {
7448 pub host_mapped_pointer_alignment: Option<u32>,
7449 }
7450 impl Default for DawnHostMappedPointerLimits {
7451 fn default() -> Self {
7452 Self {
7453 host_mapped_pointer_alignment: Some(LIMIT_U32_UNDEFINED),
7454 }
7455 }
7456 }
7457 impl DawnHostMappedPointerLimits {
7458 pub fn new() -> Self {
7459 Self::default()
7460 }
7461 pub(crate) fn to_ffi(
7462 &self,
7463 ) -> (ffi::WGPUDawnHostMappedPointerLimits, ChainedStructStorage) {
7464 let mut storage = ChainedStructStorage::new();
7465 let mut raw: ffi::WGPUDawnHostMappedPointerLimits = unsafe {
7466 std::mem::zeroed()
7467 };
7468 if let Some(value) = self.host_mapped_pointer_alignment {
7469 raw.hostMappedPointerAlignment = value;
7470 }
7471 (raw, storage)
7472 }
7473 pub(crate) fn from_ffi(value: ffi::WGPUDawnHostMappedPointerLimits) -> Self {
7474 Self {
7475 host_mapped_pointer_alignment: Some(value.hostMappedPointerAlignment),
7476 }
7477 }
7478 }
7479 pub struct DawnInjectedInvalidSType {
7480 pub invalid_s_type: Option<SType>,
7481 }
7482 impl Default for DawnInjectedInvalidSType {
7483 fn default() -> Self {
7484 Self { invalid_s_type: None }
7485 }
7486 }
7487 impl DawnInjectedInvalidSType {
7488 pub fn new() -> Self {
7489 Self::default()
7490 }
7491 pub(crate) fn to_ffi(
7492 &self,
7493 ) -> (ffi::WGPUDawnInjectedInvalidSType, ChainedStructStorage) {
7494 let mut storage = ChainedStructStorage::new();
7495 let mut raw: ffi::WGPUDawnInjectedInvalidSType = unsafe {
7496 std::mem::zeroed()
7497 };
7498 if let Some(value) = self.invalid_s_type {
7499 raw.invalidSType = value.into();
7500 } else {
7501 raw.invalidSType = 0 as ffi::WGPUSType;
7502 }
7503 (raw, storage)
7504 }
7505 pub(crate) fn from_ffi(value: ffi::WGPUDawnInjectedInvalidSType) -> Self {
7506 Self {
7507 invalid_s_type: Some(value.invalidSType.into()),
7508 }
7509 }
7510 }
7511 pub struct DawnRenderPassSampleCount {
7512 pub sample_count: Option<u32>,
7513 }
7514 impl Default for DawnRenderPassSampleCount {
7515 fn default() -> Self {
7516 Self { sample_count: Some(1) }
7517 }
7518 }
7519 impl DawnRenderPassSampleCount {
7520 pub fn new() -> Self {
7521 Self::default()
7522 }
7523 pub(crate) fn to_ffi(
7524 &self,
7525 ) -> (ffi::WGPUDawnRenderPassSampleCount, ChainedStructStorage) {
7526 let mut storage = ChainedStructStorage::new();
7527 let mut raw: ffi::WGPUDawnRenderPassSampleCount = unsafe {
7528 std::mem::zeroed()
7529 };
7530 if let Some(value) = self.sample_count {
7531 raw.sampleCount = value;
7532 }
7533 (raw, storage)
7534 }
7535 pub(crate) fn from_ffi(value: ffi::WGPUDawnRenderPassSampleCount) -> Self {
7536 Self {
7537 sample_count: Some(value.sampleCount),
7538 }
7539 }
7540 }
7541 pub struct DawnShaderModuleSPIRVOptionsDescriptor {
7542 pub allow_non_uniform_derivatives: Option<bool>,
7543 }
7544 impl Default for DawnShaderModuleSPIRVOptionsDescriptor {
7545 fn default() -> Self {
7546 Self {
7547 allow_non_uniform_derivatives: None,
7548 }
7549 }
7550 }
7551 impl DawnShaderModuleSPIRVOptionsDescriptor {
7552 pub fn new() -> Self {
7553 Self::default()
7554 }
7555 pub(crate) fn to_ffi(
7556 &self,
7557 ) -> (ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor, ChainedStructStorage) {
7558 let mut storage = ChainedStructStorage::new();
7559 let mut raw: ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor = unsafe {
7560 std::mem::zeroed()
7561 };
7562 raw.allowNonUniformDerivatives = if self
7563 .allow_non_uniform_derivatives
7564 .unwrap_or(false)
7565 {
7566 1
7567 } else {
7568 0
7569 };
7570 (raw, storage)
7571 }
7572 pub(crate) fn from_ffi(
7573 value: ffi::WGPUDawnShaderModuleSPIRVOptionsDescriptor,
7574 ) -> Self {
7575 Self {
7576 allow_non_uniform_derivatives: Some(
7577 value.allowNonUniformDerivatives != 0,
7578 ),
7579 }
7580 }
7581 }
7582 pub struct DawnTexelCopyBufferRowAlignmentLimits {
7583 pub min_texel_copy_buffer_row_alignment: Option<u32>,
7584 }
7585 impl Default for DawnTexelCopyBufferRowAlignmentLimits {
7586 fn default() -> Self {
7587 Self {
7588 min_texel_copy_buffer_row_alignment: Some(LIMIT_U32_UNDEFINED),
7589 }
7590 }
7591 }
7592 impl DawnTexelCopyBufferRowAlignmentLimits {
7593 pub fn new() -> Self {
7594 Self::default()
7595 }
7596 pub(crate) fn to_ffi(
7597 &self,
7598 ) -> (ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits, ChainedStructStorage) {
7599 let mut storage = ChainedStructStorage::new();
7600 let mut raw: ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits = unsafe {
7601 std::mem::zeroed()
7602 };
7603 if let Some(value) = self.min_texel_copy_buffer_row_alignment {
7604 raw.minTexelCopyBufferRowAlignment = value;
7605 }
7606 (raw, storage)
7607 }
7608 pub(crate) fn from_ffi(
7609 value: ffi::WGPUDawnTexelCopyBufferRowAlignmentLimits,
7610 ) -> Self {
7611 Self {
7612 min_texel_copy_buffer_row_alignment: Some(
7613 value.minTexelCopyBufferRowAlignment,
7614 ),
7615 }
7616 }
7617 }
7618 pub struct DawnTextureInternalUsageDescriptor {
7619 pub internal_usage: Option<TextureUsage>,
7620 }
7621 impl Default for DawnTextureInternalUsageDescriptor {
7622 fn default() -> Self {
7623 Self { internal_usage: None }
7624 }
7625 }
7626 impl DawnTextureInternalUsageDescriptor {
7627 pub fn new() -> Self {
7628 Self::default()
7629 }
7630 pub(crate) fn to_ffi(
7631 &self,
7632 ) -> (ffi::WGPUDawnTextureInternalUsageDescriptor, ChainedStructStorage) {
7633 let mut storage = ChainedStructStorage::new();
7634 let mut raw: ffi::WGPUDawnTextureInternalUsageDescriptor = unsafe {
7635 std::mem::zeroed()
7636 };
7637 if let Some(value) = self.internal_usage {
7638 raw.internalUsage = value.into();
7639 } else {
7640 raw.internalUsage = 0 as ffi::WGPUTextureUsage;
7641 }
7642 (raw, storage)
7643 }
7644 pub(crate) fn from_ffi(
7645 value: ffi::WGPUDawnTextureInternalUsageDescriptor,
7646 ) -> Self {
7647 Self {
7648 internal_usage: Some(value.internalUsage.into()),
7649 }
7650 }
7651 }
7652 pub struct DawnTogglesDescriptor {
7653 pub enabled_toggles: Option<Vec<String>>,
7654 pub disabled_toggles: Option<Vec<String>>,
7655 }
7656 impl Default for DawnTogglesDescriptor {
7657 fn default() -> Self {
7658 Self {
7659 enabled_toggles: None,
7660 disabled_toggles: None,
7661 }
7662 }
7663 }
7664 impl DawnTogglesDescriptor {
7665 pub fn new() -> Self {
7666 Self::default()
7667 }
7668 pub(crate) fn to_ffi(
7669 &self,
7670 ) -> (ffi::WGPUDawnTogglesDescriptor, ChainedStructStorage) {
7671 let mut storage = ChainedStructStorage::new();
7672 let mut raw: ffi::WGPUDawnTogglesDescriptor = unsafe { std::mem::zeroed() };
7673 raw.enabledToggleCount = self
7674 .enabled_toggles
7675 .as_ref()
7676 .map(|v| v.len())
7677 .unwrap_or(0);
7678 if let Some(values) = &self.enabled_toggles {
7679 let len_value = values.len();
7680 let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
7681 values.len(),
7682 );
7683 let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
7684 values.len(),
7685 );
7686 for item in values.iter() {
7687 let c_string = std::ffi::CString::new(item.as_str())
7688 .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
7689 ptrs.push(c_string.as_ptr());
7690 c_strings.push(c_string);
7691 }
7692 let ptr = storage.push_vec(ptrs);
7693 storage.push_any(c_strings);
7694 raw.enabledToggles = ptr;
7695 raw.enabledToggleCount = len_value;
7696 } else {
7697 raw.enabledToggles = std::ptr::null();
7698 raw.enabledToggleCount = 0;
7699 }
7700 raw.disabledToggleCount = self
7701 .disabled_toggles
7702 .as_ref()
7703 .map(|v| v.len())
7704 .unwrap_or(0);
7705 if let Some(values) = &self.disabled_toggles {
7706 let len_value = values.len();
7707 let mut c_strings: Vec<std::ffi::CString> = Vec::with_capacity(
7708 values.len(),
7709 );
7710 let mut ptrs: Vec<*const std::os::raw::c_char> = Vec::with_capacity(
7711 values.len(),
7712 );
7713 for item in values.iter() {
7714 let c_string = std::ffi::CString::new(item.as_str())
7715 .unwrap_or_else(|_| std::ffi::CString::new("").unwrap());
7716 ptrs.push(c_string.as_ptr());
7717 c_strings.push(c_string);
7718 }
7719 let ptr = storage.push_vec(ptrs);
7720 storage.push_any(c_strings);
7721 raw.disabledToggles = ptr;
7722 raw.disabledToggleCount = len_value;
7723 } else {
7724 raw.disabledToggles = std::ptr::null();
7725 raw.disabledToggleCount = 0;
7726 }
7727 (raw, storage)
7728 }
7729 pub(crate) fn from_ffi(value: ffi::WGPUDawnTogglesDescriptor) -> Self {
7730 Self {
7731 enabled_toggles: if value.enabledToggles.is_null() {
7732 None
7733 } else {
7734 Some(
7735 unsafe {
7736 std::slice::from_raw_parts(
7737 value.enabledToggles,
7738 value.enabledToggleCount as usize,
7739 )
7740 }
7741 .iter()
7742 .map(|raw| {
7743 if raw.is_null() {
7744 String::new()
7745 } else {
7746 unsafe { CStr::from_ptr(*raw) }
7747 .to_string_lossy()
7748 .into_owned()
7749 }
7750 })
7751 .collect(),
7752 )
7753 },
7754 disabled_toggles: if value.disabledToggles.is_null() {
7755 None
7756 } else {
7757 Some(
7758 unsafe {
7759 std::slice::from_raw_parts(
7760 value.disabledToggles,
7761 value.disabledToggleCount as usize,
7762 )
7763 }
7764 .iter()
7765 .map(|raw| {
7766 if raw.is_null() {
7767 String::new()
7768 } else {
7769 unsafe { CStr::from_ptr(*raw) }
7770 .to_string_lossy()
7771 .into_owned()
7772 }
7773 })
7774 .collect(),
7775 )
7776 },
7777 }
7778 }
7779 }
7780 pub struct DawnWireWGSLControl {
7781 pub enable_experimental: Option<bool>,
7782 pub enable_unsafe: Option<bool>,
7783 pub enable_testing: Option<bool>,
7784 }
7785 impl Default for DawnWireWGSLControl {
7786 fn default() -> Self {
7787 Self {
7788 enable_experimental: None,
7789 enable_unsafe: None,
7790 enable_testing: None,
7791 }
7792 }
7793 }
7794 impl DawnWireWGSLControl {
7795 pub fn new() -> Self {
7796 Self::default()
7797 }
7798 pub(crate) fn to_ffi(
7799 &self,
7800 ) -> (ffi::WGPUDawnWireWGSLControl, ChainedStructStorage) {
7801 let mut storage = ChainedStructStorage::new();
7802 let mut raw: ffi::WGPUDawnWireWGSLControl = unsafe { std::mem::zeroed() };
7803 raw.enableExperimental = if self.enable_experimental.unwrap_or(false) {
7804 1
7805 } else {
7806 0
7807 };
7808 raw.enableUnsafe = if self.enable_unsafe.unwrap_or(false) { 1 } else { 0 };
7809 raw.enableTesting = if self.enable_testing.unwrap_or(false) { 1 } else { 0 };
7810 (raw, storage)
7811 }
7812 pub(crate) fn from_ffi(value: ffi::WGPUDawnWireWGSLControl) -> Self {
7813 Self {
7814 enable_experimental: Some(value.enableExperimental != 0),
7815 enable_unsafe: Some(value.enableUnsafe != 0),
7816 enable_testing: Some(value.enableTesting != 0),
7817 }
7818 }
7819 }
7820 pub struct DepthStencilState {
7821 pub(crate) extensions: Vec<DepthStencilStateExtension>,
7822 pub format: Option<TextureFormat>,
7823 pub depth_write_enabled: Option<OptionalBool>,
7824 pub depth_compare: Option<CompareFunction>,
7825 pub stencil_front: Option<StencilFaceState>,
7826 pub stencil_back: Option<StencilFaceState>,
7827 pub stencil_read_mask: Option<u32>,
7828 pub stencil_write_mask: Option<u32>,
7829 pub depth_bias: Option<i32>,
7830 pub depth_bias_slope_scale: Option<f32>,
7831 pub depth_bias_clamp: Option<f32>,
7832 }
7833 impl Default for DepthStencilState {
7834 fn default() -> Self {
7835 Self {
7836 extensions: Vec::new(),
7837 format: None,
7838 depth_write_enabled: None,
7839 depth_compare: None,
7840 stencil_front: None,
7841 stencil_back: None,
7842 stencil_read_mask: Some(4294967295),
7843 stencil_write_mask: Some(4294967295),
7844 depth_bias: Some(0),
7845 depth_bias_slope_scale: None,
7846 depth_bias_clamp: None,
7847 }
7848 }
7849 }
7850 impl DepthStencilState {
7851 pub fn new() -> Self {
7852 Self::default()
7853 }
7854 pub(crate) fn to_ffi(
7855 &self,
7856 ) -> (ffi::WGPUDepthStencilState, ChainedStructStorage) {
7857 let mut storage = ChainedStructStorage::new();
7858 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7859 for ext in self.extensions.iter().rev() {
7860 next = ext.push_chain(&mut storage, next);
7861 }
7862 let mut raw: ffi::WGPUDepthStencilState = unsafe { std::mem::zeroed() };
7863 raw.nextInChain = next;
7864 if let Some(value) = self.format {
7865 raw.format = value.into();
7866 } else {
7867 raw.format = 0 as ffi::WGPUTextureFormat;
7868 }
7869 if let Some(value) = self.depth_write_enabled {
7870 raw.depthWriteEnabled = value.into();
7871 } else {
7872 raw.depthWriteEnabled = 0 as ffi::WGPUOptionalBool;
7873 }
7874 if let Some(value) = self.depth_compare {
7875 raw.depthCompare = value.into();
7876 } else {
7877 raw.depthCompare = 0 as ffi::WGPUCompareFunction;
7878 }
7879 if let Some(value) = &self.stencil_front {
7880 let (raw_value, storage_value) = value.to_ffi();
7881 raw.stencilFront = raw_value;
7882 storage.push_storage(storage_value);
7883 }
7884 if let Some(value) = &self.stencil_back {
7885 let (raw_value, storage_value) = value.to_ffi();
7886 raw.stencilBack = raw_value;
7887 storage.push_storage(storage_value);
7888 }
7889 if let Some(value) = self.stencil_read_mask {
7890 raw.stencilReadMask = value;
7891 }
7892 if let Some(value) = self.stencil_write_mask {
7893 raw.stencilWriteMask = value;
7894 }
7895 if let Some(value) = self.depth_bias {
7896 raw.depthBias = value;
7897 }
7898 if let Some(value) = self.depth_bias_slope_scale {
7899 raw.depthBiasSlopeScale = value;
7900 }
7901 if let Some(value) = self.depth_bias_clamp {
7902 raw.depthBiasClamp = value;
7903 }
7904 (raw, storage)
7905 }
7906 pub fn with_extension(mut self, extension: DepthStencilStateExtension) -> Self {
7907 self.extensions.push(extension);
7908 self
7909 }
7910 pub(crate) fn from_ffi(value: ffi::WGPUDepthStencilState) -> Self {
7911 Self {
7912 extensions: Vec::new(),
7913 format: Some(value.format.into()),
7914 depth_write_enabled: Some(value.depthWriteEnabled.into()),
7915 depth_compare: Some(value.depthCompare.into()),
7916 stencil_front: Some(StencilFaceState::from_ffi(value.stencilFront)),
7917 stencil_back: Some(StencilFaceState::from_ffi(value.stencilBack)),
7918 stencil_read_mask: Some(value.stencilReadMask),
7919 stencil_write_mask: Some(value.stencilWriteMask),
7920 depth_bias: Some(value.depthBias),
7921 depth_bias_slope_scale: Some(value.depthBiasSlopeScale),
7922 depth_bias_clamp: Some(value.depthBiasClamp),
7923 }
7924 }
7925 }
7926 pub struct DeviceDescriptor {
7927 pub(crate) extensions: Vec<DeviceDescriptorExtension>,
7928 pub label: Option<String>,
7929 pub required_features: Option<Vec<FeatureName>>,
7930 pub required_limits: Option<Limits>,
7931 pub default_queue: Option<QueueDescriptor>,
7932 pub device_lost_callback_info: Option<DeviceLostCallbackInfo>,
7933 pub uncaptured_error_callback_info: Option<UncapturedErrorCallbackInfo>,
7934 }
7935 impl Default for DeviceDescriptor {
7936 fn default() -> Self {
7937 Self {
7938 extensions: Vec::new(),
7939 label: None,
7940 required_features: None,
7941 required_limits: None,
7942 default_queue: None,
7943 device_lost_callback_info: None,
7944 uncaptured_error_callback_info: None,
7945 }
7946 }
7947 }
7948 impl DeviceDescriptor {
7949 pub fn new() -> Self {
7950 Self::default()
7951 }
7952 pub(crate) fn to_ffi(
7953 &self,
7954 ) -> (ffi::WGPUDeviceDescriptor, ChainedStructStorage) {
7955 let mut storage = ChainedStructStorage::new();
7956 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
7957 for ext in self.extensions.iter().rev() {
7958 next = ext.push_chain(&mut storage, next);
7959 }
7960 let mut raw: ffi::WGPUDeviceDescriptor = unsafe { std::mem::zeroed() };
7961 raw.nextInChain = next;
7962 if let Some(value) = &self.label {
7963 raw.label = ffi::WGPUStringView {
7964 data: value.as_ptr().cast(),
7965 length: value.len(),
7966 };
7967 } else {
7968 raw.label = ffi::WGPUStringView {
7969 data: std::ptr::null(),
7970 length: 0,
7971 };
7972 }
7973 raw.requiredFeatureCount = self
7974 .required_features
7975 .as_ref()
7976 .map(|v| v.len())
7977 .unwrap_or(0);
7978 if let Some(values) = &self.required_features {
7979 let len_value = values.len();
7980 let raw_vec: Vec<ffi::WGPUFeatureName> = values
7981 .iter()
7982 .map(|v| (*v).into())
7983 .collect();
7984 let ptr = storage.push_vec(raw_vec);
7985 raw.requiredFeatures = ptr;
7986 raw.requiredFeatureCount = len_value;
7987 } else {
7988 raw.requiredFeatures = std::ptr::null();
7989 raw.requiredFeatureCount = 0;
7990 }
7991 if let Some(value) = &self.required_limits {
7992 let (raw_value, storage_value) = value.to_ffi();
7993 let ptr = storage.push_value(raw_value);
7994 raw.requiredLimits = ptr;
7995 storage.push_storage(storage_value);
7996 } else {
7997 raw.requiredLimits = std::ptr::null();
7998 }
7999 if let Some(value) = &self.default_queue {
8000 let (raw_value, storage_value) = value.to_ffi();
8001 raw.defaultQueue = raw_value;
8002 storage.push_storage(storage_value);
8003 }
8004 if let Some(info) = &self.device_lost_callback_info {
8005 let mut callback_slot = info.callback.borrow_mut();
8006 let callback = callback_slot.take();
8007 let (
8008 callback_ptr,
8009 userdata1,
8010 ): (ffi::WGPUDeviceLostCallback, *mut std::ffi::c_void) = if let Some(
8011 callback,
8012 ) = callback {
8013 let callback_box: DeviceLostCallback = callback;
8014 let callback_box = Box::new(Some(callback_box));
8015 let userdata = Box::into_raw(callback_box)
8016 .cast::<std::ffi::c_void>();
8017 (Some(device_lost_callback_trampoline), userdata)
8018 } else {
8019 (None, std::ptr::null_mut())
8020 };
8021 let mode = info.mode.unwrap_or(CallbackMode::AllowSpontaneous);
8022 raw.deviceLostCallbackInfo = ffi::WGPUDeviceLostCallbackInfo {
8023 nextInChain: std::ptr::null_mut(),
8024 mode: mode.into(),
8025 callback: callback_ptr,
8026 userdata1,
8027 userdata2: std::ptr::null_mut(),
8028 };
8029 } else {
8030 raw.deviceLostCallbackInfo = ffi::WGPUDeviceLostCallbackInfo {
8031 nextInChain: std::ptr::null_mut(),
8032 mode: CallbackMode::AllowSpontaneous.into(),
8033 callback: None,
8034 userdata1: std::ptr::null_mut(),
8035 userdata2: std::ptr::null_mut(),
8036 };
8037 }
8038 if let Some(info) = &self.uncaptured_error_callback_info {
8039 let mut callback_slot = info.callback.borrow_mut();
8040 let callback = callback_slot.take();
8041 let (
8042 callback_ptr,
8043 userdata1,
8044 ): (ffi::WGPUUncapturedErrorCallback, *mut std::ffi::c_void) = if let Some(
8045 callback,
8046 ) = callback {
8047 let callback_box: UncapturedErrorCallback = callback;
8048 let callback_box = Box::new(Some(callback_box));
8049 let userdata = Box::into_raw(callback_box)
8050 .cast::<std::ffi::c_void>();
8051 (Some(uncaptured_error_callback_trampoline), userdata)
8052 } else {
8053 (None, std::ptr::null_mut())
8054 };
8055 raw.uncapturedErrorCallbackInfo = ffi::WGPUUncapturedErrorCallbackInfo {
8056 nextInChain: std::ptr::null_mut(),
8057 callback: callback_ptr,
8058 userdata1,
8059 userdata2: std::ptr::null_mut(),
8060 };
8061 } else {
8062 raw.uncapturedErrorCallbackInfo = ffi::WGPUUncapturedErrorCallbackInfo {
8063 nextInChain: std::ptr::null_mut(),
8064 callback: None,
8065 userdata1: std::ptr::null_mut(),
8066 userdata2: std::ptr::null_mut(),
8067 };
8068 }
8069 (raw, storage)
8070 }
8071 pub fn with_extension(mut self, extension: DeviceDescriptorExtension) -> Self {
8072 self.extensions.push(extension);
8073 self
8074 }
8075 pub(crate) fn from_ffi(value: ffi::WGPUDeviceDescriptor) -> Self {
8076 Self {
8077 extensions: Vec::new(),
8078 label: if value.label.data.is_null() || value.label.length == 0 {
8079 None
8080 } else {
8081 Some(string_view_to_string(value.label))
8082 },
8083 required_features: if value.requiredFeatures.is_null() {
8084 None
8085 } else {
8086 Some(
8087 unsafe {
8088 std::slice::from_raw_parts(
8089 value.requiredFeatures,
8090 value.requiredFeatureCount as usize,
8091 )
8092 }
8093 .iter()
8094 .map(|raw| FeatureName::from(*raw))
8095 .collect(),
8096 )
8097 },
8098 required_limits: if value.requiredLimits.is_null() {
8099 None
8100 } else {
8101 Some(Limits::from_ffi(unsafe { *value.requiredLimits }))
8102 },
8103 default_queue: Some(QueueDescriptor::from_ffi(value.defaultQueue)),
8104 device_lost_callback_info: None,
8105 uncaptured_error_callback_info: None,
8106 }
8107 }
8108 }
8109 pub struct Extent2D {
8110 pub width: Option<u32>,
8111 pub height: Option<u32>,
8112 }
8113 impl Default for Extent2D {
8114 fn default() -> Self {
8115 Self { width: None, height: None }
8116 }
8117 }
8118 impl Extent2D {
8119 pub fn new() -> Self {
8120 Self::default()
8121 }
8122 pub(crate) fn to_ffi(&self) -> (ffi::WGPUExtent2D, ChainedStructStorage) {
8123 let mut storage = ChainedStructStorage::new();
8124 let mut raw: ffi::WGPUExtent2D = unsafe { std::mem::zeroed() };
8125 if let Some(value) = self.width {
8126 raw.width = value;
8127 }
8128 if let Some(value) = self.height {
8129 raw.height = value;
8130 }
8131 (raw, storage)
8132 }
8133 pub(crate) fn from_ffi(value: ffi::WGPUExtent2D) -> Self {
8134 Self {
8135 width: Some(value.width),
8136 height: Some(value.height),
8137 }
8138 }
8139 }
8140 pub struct Extent3D {
8141 pub width: Option<u32>,
8142 pub height: Option<u32>,
8143 pub depth_or_array_layers: Option<u32>,
8144 }
8145 impl Default for Extent3D {
8146 fn default() -> Self {
8147 Self {
8148 width: None,
8149 height: Some(1),
8150 depth_or_array_layers: Some(1),
8151 }
8152 }
8153 }
8154 impl Extent3D {
8155 pub fn new() -> Self {
8156 Self::default()
8157 }
8158 pub(crate) fn to_ffi(&self) -> (ffi::WGPUExtent3D, ChainedStructStorage) {
8159 let mut storage = ChainedStructStorage::new();
8160 let mut raw: ffi::WGPUExtent3D = unsafe { std::mem::zeroed() };
8161 if let Some(value) = self.width {
8162 raw.width = value;
8163 }
8164 if let Some(value) = self.height {
8165 raw.height = value;
8166 }
8167 if let Some(value) = self.depth_or_array_layers {
8168 raw.depthOrArrayLayers = value;
8169 }
8170 (raw, storage)
8171 }
8172 pub(crate) fn from_ffi(value: ffi::WGPUExtent3D) -> Self {
8173 Self {
8174 width: Some(value.width),
8175 height: Some(value.height),
8176 depth_or_array_layers: Some(value.depthOrArrayLayers),
8177 }
8178 }
8179 }
8180 pub struct ExternalTextureBindingEntry {
8181 pub external_texture: Option<ExternalTexture>,
8182 }
8183 impl Default for ExternalTextureBindingEntry {
8184 fn default() -> Self {
8185 Self { external_texture: None }
8186 }
8187 }
8188 impl ExternalTextureBindingEntry {
8189 pub fn new() -> Self {
8190 Self::default()
8191 }
8192 pub(crate) fn to_ffi(
8193 &self,
8194 ) -> (ffi::WGPUExternalTextureBindingEntry, ChainedStructStorage) {
8195 let mut storage = ChainedStructStorage::new();
8196 let mut raw: ffi::WGPUExternalTextureBindingEntry = unsafe {
8197 std::mem::zeroed()
8198 };
8199 raw.externalTexture = self
8200 .external_texture
8201 .as_ref()
8202 .map(|v| v.as_raw())
8203 .unwrap_or(std::ptr::null_mut());
8204 (raw, storage)
8205 }
8206 pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureBindingEntry) -> Self {
8207 Self {
8208 external_texture: Some(unsafe {
8209 ExternalTexture::from_raw(value.externalTexture)
8210 }),
8211 }
8212 }
8213 }
8214 pub struct ExternalTextureBindingLayout {}
8215 impl Default for ExternalTextureBindingLayout {
8216 fn default() -> Self {
8217 Self {}
8218 }
8219 }
8220 impl ExternalTextureBindingLayout {
8221 pub fn new() -> Self {
8222 Self::default()
8223 }
8224 pub(crate) fn to_ffi(
8225 &self,
8226 ) -> (ffi::WGPUExternalTextureBindingLayout, ChainedStructStorage) {
8227 let mut storage = ChainedStructStorage::new();
8228 let mut raw: ffi::WGPUExternalTextureBindingLayout = unsafe {
8229 std::mem::zeroed()
8230 };
8231 (raw, storage)
8232 }
8233 pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureBindingLayout) -> Self {
8234 let _ = value;
8235 Self::default()
8236 }
8237 }
8238 pub struct ExternalTextureDescriptor {
8239 pub(crate) extensions: Vec<ExternalTextureDescriptorExtension>,
8240 pub label: Option<String>,
8241 pub plane_0: Option<TextureView>,
8242 pub plane_1: Option<TextureView>,
8243 pub crop_origin: Option<Origin2D>,
8244 pub crop_size: Option<Extent2D>,
8245 pub apparent_size: Option<Extent2D>,
8246 pub do_yuv_to_rgb_conversion_only: Option<bool>,
8247 pub yuv_to_rgb_conversion_matrix: Option<Vec<f32>>,
8248 pub src_transfer_function_parameters: Option<Vec<f32>>,
8249 pub dst_transfer_function_parameters: Option<Vec<f32>>,
8250 pub gamut_conversion_matrix: Option<Vec<f32>>,
8251 pub mirrored: Option<bool>,
8252 pub rotation: Option<ExternalTextureRotation>,
8253 }
8254 impl Default for ExternalTextureDescriptor {
8255 fn default() -> Self {
8256 Self {
8257 extensions: Vec::new(),
8258 label: None,
8259 plane_0: None,
8260 plane_1: None,
8261 crop_origin: None,
8262 crop_size: None,
8263 apparent_size: None,
8264 do_yuv_to_rgb_conversion_only: None,
8265 yuv_to_rgb_conversion_matrix: None,
8266 src_transfer_function_parameters: None,
8267 dst_transfer_function_parameters: None,
8268 gamut_conversion_matrix: None,
8269 mirrored: None,
8270 rotation: Some(ExternalTextureRotation::Rotate0Degrees),
8271 }
8272 }
8273 }
8274 impl ExternalTextureDescriptor {
8275 pub fn new() -> Self {
8276 Self::default()
8277 }
8278 pub(crate) fn to_ffi(
8279 &self,
8280 ) -> (ffi::WGPUExternalTextureDescriptor, ChainedStructStorage) {
8281 let mut storage = ChainedStructStorage::new();
8282 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8283 for ext in self.extensions.iter().rev() {
8284 next = ext.push_chain(&mut storage, next);
8285 }
8286 let mut raw: ffi::WGPUExternalTextureDescriptor = unsafe {
8287 std::mem::zeroed()
8288 };
8289 raw.nextInChain = next;
8290 if let Some(value) = &self.label {
8291 raw.label = ffi::WGPUStringView {
8292 data: value.as_ptr().cast(),
8293 length: value.len(),
8294 };
8295 } else {
8296 raw.label = ffi::WGPUStringView {
8297 data: std::ptr::null(),
8298 length: 0,
8299 };
8300 }
8301 raw.plane0 = self
8302 .plane_0
8303 .as_ref()
8304 .map(|v| v.as_raw())
8305 .unwrap_or(std::ptr::null_mut());
8306 raw.plane1 = self
8307 .plane_1
8308 .as_ref()
8309 .map(|v| v.as_raw())
8310 .unwrap_or(std::ptr::null_mut());
8311 if let Some(value) = &self.crop_origin {
8312 let (raw_value, storage_value) = value.to_ffi();
8313 raw.cropOrigin = raw_value;
8314 storage.push_storage(storage_value);
8315 }
8316 if let Some(value) = &self.crop_size {
8317 let (raw_value, storage_value) = value.to_ffi();
8318 raw.cropSize = raw_value;
8319 storage.push_storage(storage_value);
8320 }
8321 if let Some(value) = &self.apparent_size {
8322 let (raw_value, storage_value) = value.to_ffi();
8323 raw.apparentSize = raw_value;
8324 storage.push_storage(storage_value);
8325 }
8326 raw.doYuvToRgbConversionOnly = if self
8327 .do_yuv_to_rgb_conversion_only
8328 .unwrap_or(false)
8329 {
8330 1
8331 } else {
8332 0
8333 };
8334 if let Some(values) = &self.yuv_to_rgb_conversion_matrix {
8335 let len_value = values.len();
8336 let raw_vec = values.to_vec();
8337 let ptr = storage.push_vec(raw_vec);
8338 raw.yuvToRgbConversionMatrix = ptr;
8339 } else {
8340 raw.yuvToRgbConversionMatrix = std::ptr::null();
8341 let _ = 0;
8342 }
8343 if let Some(values) = &self.src_transfer_function_parameters {
8344 let len_value = values.len();
8345 let raw_vec = values.to_vec();
8346 let ptr = storage.push_vec(raw_vec);
8347 raw.srcTransferFunctionParameters = ptr;
8348 } else {
8349 raw.srcTransferFunctionParameters = std::ptr::null();
8350 let _ = 0;
8351 }
8352 if let Some(values) = &self.dst_transfer_function_parameters {
8353 let len_value = values.len();
8354 let raw_vec = values.to_vec();
8355 let ptr = storage.push_vec(raw_vec);
8356 raw.dstTransferFunctionParameters = ptr;
8357 } else {
8358 raw.dstTransferFunctionParameters = std::ptr::null();
8359 let _ = 0;
8360 }
8361 if let Some(values) = &self.gamut_conversion_matrix {
8362 let len_value = values.len();
8363 let raw_vec = values.to_vec();
8364 let ptr = storage.push_vec(raw_vec);
8365 raw.gamutConversionMatrix = ptr;
8366 } else {
8367 raw.gamutConversionMatrix = std::ptr::null();
8368 let _ = 0;
8369 }
8370 raw.mirrored = if self.mirrored.unwrap_or(false) { 1 } else { 0 };
8371 if let Some(value) = self.rotation {
8372 raw.rotation = value.into();
8373 } else {
8374 raw.rotation = 0 as ffi::WGPUExternalTextureRotation;
8375 }
8376 (raw, storage)
8377 }
8378 pub fn with_extension(
8379 mut self,
8380 extension: ExternalTextureDescriptorExtension,
8381 ) -> Self {
8382 self.extensions.push(extension);
8383 self
8384 }
8385 pub(crate) fn from_ffi(value: ffi::WGPUExternalTextureDescriptor) -> Self {
8386 Self {
8387 extensions: Vec::new(),
8388 label: if value.label.data.is_null() || value.label.length == 0 {
8389 None
8390 } else {
8391 Some(string_view_to_string(value.label))
8392 },
8393 plane_0: Some(unsafe { TextureView::from_raw(value.plane0) }),
8394 plane_1: if value.plane1.is_null() {
8395 None
8396 } else {
8397 Some(unsafe { TextureView::from_raw(value.plane1) })
8398 },
8399 crop_origin: Some(Origin2D::from_ffi(value.cropOrigin)),
8400 crop_size: Some(Extent2D::from_ffi(value.cropSize)),
8401 apparent_size: Some(Extent2D::from_ffi(value.apparentSize)),
8402 do_yuv_to_rgb_conversion_only: Some(value.doYuvToRgbConversionOnly != 0),
8403 yuv_to_rgb_conversion_matrix: if value.yuvToRgbConversionMatrix.is_null()
8404 {
8405 None
8406 } else {
8407 Some(
8408 unsafe {
8409 std::slice::from_raw_parts(
8410 value.yuvToRgbConversionMatrix,
8411 12usize,
8412 )
8413 }
8414 .to_vec(),
8415 )
8416 },
8417 src_transfer_function_parameters: if value
8418 .srcTransferFunctionParameters
8419 .is_null()
8420 {
8421 None
8422 } else {
8423 Some(
8424 unsafe {
8425 std::slice::from_raw_parts(
8426 value.srcTransferFunctionParameters,
8427 7usize,
8428 )
8429 }
8430 .to_vec(),
8431 )
8432 },
8433 dst_transfer_function_parameters: if value
8434 .dstTransferFunctionParameters
8435 .is_null()
8436 {
8437 None
8438 } else {
8439 Some(
8440 unsafe {
8441 std::slice::from_raw_parts(
8442 value.dstTransferFunctionParameters,
8443 7usize,
8444 )
8445 }
8446 .to_vec(),
8447 )
8448 },
8449 gamut_conversion_matrix: if value.gamutConversionMatrix.is_null() {
8450 None
8451 } else {
8452 Some(
8453 unsafe {
8454 std::slice::from_raw_parts(
8455 value.gamutConversionMatrix,
8456 9usize,
8457 )
8458 }
8459 .to_vec(),
8460 )
8461 },
8462 mirrored: Some(value.mirrored != 0),
8463 rotation: Some(value.rotation.into()),
8464 }
8465 }
8466 }
8467 pub struct FragmentState {
8468 pub(crate) extensions: Vec<FragmentStateExtension>,
8469 pub module: Option<ShaderModule>,
8470 pub entry_point: Option<String>,
8471 pub constants: Option<Vec<ConstantEntry>>,
8472 pub targets: Option<Vec<ColorTargetState>>,
8473 }
8474 impl Default for FragmentState {
8475 fn default() -> Self {
8476 Self {
8477 extensions: Vec::new(),
8478 module: None,
8479 entry_point: None,
8480 constants: None,
8481 targets: None,
8482 }
8483 }
8484 }
8485 impl FragmentState {
8486 pub fn new() -> Self {
8487 Self::default()
8488 }
8489 pub(crate) fn to_ffi(&self) -> (ffi::WGPUFragmentState, ChainedStructStorage) {
8490 let mut storage = ChainedStructStorage::new();
8491 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8492 for ext in self.extensions.iter().rev() {
8493 next = ext.push_chain(&mut storage, next);
8494 }
8495 let mut raw: ffi::WGPUFragmentState = unsafe { std::mem::zeroed() };
8496 raw.nextInChain = next;
8497 raw.module = self
8498 .module
8499 .as_ref()
8500 .map(|v| v.as_raw())
8501 .unwrap_or(std::ptr::null_mut());
8502 if let Some(value) = &self.entry_point {
8503 raw.entryPoint = ffi::WGPUStringView {
8504 data: value.as_ptr().cast(),
8505 length: value.len(),
8506 };
8507 } else {
8508 raw.entryPoint = ffi::WGPUStringView {
8509 data: std::ptr::null(),
8510 length: 0,
8511 };
8512 }
8513 raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
8514 if let Some(values) = &self.constants {
8515 let len_value = values.len();
8516 let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
8517 values.len(),
8518 );
8519 for item in values.iter() {
8520 let (raw_item, storage_item) = item.to_ffi();
8521 raw_vec.push(raw_item);
8522 storage.push_storage(storage_item);
8523 }
8524 let ptr = storage.push_vec(raw_vec);
8525 raw.constants = ptr;
8526 raw.constantCount = len_value;
8527 } else {
8528 raw.constants = std::ptr::null();
8529 raw.constantCount = 0;
8530 }
8531 raw.targetCount = self.targets.as_ref().map(|v| v.len()).unwrap_or(0);
8532 if let Some(values) = &self.targets {
8533 let len_value = values.len();
8534 let mut raw_vec: Vec<ffi::WGPUColorTargetState> = Vec::with_capacity(
8535 values.len(),
8536 );
8537 for item in values.iter() {
8538 let (raw_item, storage_item) = item.to_ffi();
8539 raw_vec.push(raw_item);
8540 storage.push_storage(storage_item);
8541 }
8542 let ptr = storage.push_vec(raw_vec);
8543 raw.targets = ptr;
8544 raw.targetCount = len_value;
8545 } else {
8546 raw.targets = std::ptr::null();
8547 raw.targetCount = 0;
8548 }
8549 (raw, storage)
8550 }
8551 pub fn with_extension(mut self, extension: FragmentStateExtension) -> Self {
8552 self.extensions.push(extension);
8553 self
8554 }
8555 pub(crate) fn from_ffi(value: ffi::WGPUFragmentState) -> Self {
8556 Self {
8557 extensions: Vec::new(),
8558 module: Some(unsafe { ShaderModule::from_raw(value.module) }),
8559 entry_point: if value.entryPoint.data.is_null()
8560 || value.entryPoint.length == 0
8561 {
8562 None
8563 } else {
8564 Some(string_view_to_string(value.entryPoint))
8565 },
8566 constants: if value.constants.is_null() {
8567 None
8568 } else {
8569 Some(
8570 unsafe {
8571 std::slice::from_raw_parts(
8572 value.constants,
8573 value.constantCount as usize,
8574 )
8575 }
8576 .iter()
8577 .map(|raw| ConstantEntry::from_ffi(*raw))
8578 .collect(),
8579 )
8580 },
8581 targets: if value.targets.is_null() {
8582 None
8583 } else {
8584 Some(
8585 unsafe {
8586 std::slice::from_raw_parts(
8587 value.targets,
8588 value.targetCount as usize,
8589 )
8590 }
8591 .iter()
8592 .map(|raw| ColorTargetState::from_ffi(*raw))
8593 .collect(),
8594 )
8595 },
8596 }
8597 }
8598 }
8599 pub struct Future {
8600 pub id: Option<u64>,
8601 }
8602 impl Default for Future {
8603 fn default() -> Self {
8604 Self { id: None }
8605 }
8606 }
8607 impl Future {
8608 pub fn new() -> Self {
8609 Self::default()
8610 }
8611 pub(crate) fn to_ffi(&self) -> (ffi::WGPUFuture, ChainedStructStorage) {
8612 let mut storage = ChainedStructStorage::new();
8613 let mut raw: ffi::WGPUFuture = unsafe { std::mem::zeroed() };
8614 if let Some(value) = self.id {
8615 raw.id = value;
8616 }
8617 (raw, storage)
8618 }
8619 pub(crate) fn from_ffi(value: ffi::WGPUFuture) -> Self {
8620 Self { id: Some(value.id) }
8621 }
8622 }
8623 pub struct FutureWaitInfo {
8624 pub future: Option<Future>,
8625 pub completed: Option<bool>,
8626 }
8627 impl Default for FutureWaitInfo {
8628 fn default() -> Self {
8629 Self {
8630 future: None,
8631 completed: None,
8632 }
8633 }
8634 }
8635 impl FutureWaitInfo {
8636 pub fn new() -> Self {
8637 Self::default()
8638 }
8639 pub(crate) fn to_ffi(&self) -> (ffi::WGPUFutureWaitInfo, ChainedStructStorage) {
8640 let mut storage = ChainedStructStorage::new();
8641 let mut raw: ffi::WGPUFutureWaitInfo = unsafe { std::mem::zeroed() };
8642 if let Some(value) = &self.future {
8643 let (raw_value, storage_value) = value.to_ffi();
8644 raw.future = raw_value;
8645 storage.push_storage(storage_value);
8646 }
8647 raw.completed = if self.completed.unwrap_or(false) { 1 } else { 0 };
8648 (raw, storage)
8649 }
8650 pub(crate) fn from_ffi(value: ffi::WGPUFutureWaitInfo) -> Self {
8651 Self {
8652 future: Some(Future::from_ffi(value.future)),
8653 completed: Some(value.completed != 0),
8654 }
8655 }
8656 }
8657 pub struct ImageCopyExternalTexture {
8658 pub(crate) extensions: Vec<ImageCopyExternalTextureExtension>,
8659 pub external_texture: Option<ExternalTexture>,
8660 pub origin: Option<Origin3D>,
8661 pub natural_size: Option<Extent2D>,
8662 }
8663 impl Default for ImageCopyExternalTexture {
8664 fn default() -> Self {
8665 Self {
8666 extensions: Vec::new(),
8667 external_texture: None,
8668 origin: None,
8669 natural_size: None,
8670 }
8671 }
8672 }
8673 impl ImageCopyExternalTexture {
8674 pub fn new() -> Self {
8675 Self::default()
8676 }
8677 pub(crate) fn to_ffi(
8678 &self,
8679 ) -> (ffi::WGPUImageCopyExternalTexture, ChainedStructStorage) {
8680 let mut storage = ChainedStructStorage::new();
8681 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8682 for ext in self.extensions.iter().rev() {
8683 next = ext.push_chain(&mut storage, next);
8684 }
8685 let mut raw: ffi::WGPUImageCopyExternalTexture = unsafe {
8686 std::mem::zeroed()
8687 };
8688 raw.nextInChain = next;
8689 raw.externalTexture = self
8690 .external_texture
8691 .as_ref()
8692 .map(|v| v.as_raw())
8693 .unwrap_or(std::ptr::null_mut());
8694 if let Some(value) = &self.origin {
8695 let (raw_value, storage_value) = value.to_ffi();
8696 raw.origin = raw_value;
8697 storage.push_storage(storage_value);
8698 }
8699 if let Some(value) = &self.natural_size {
8700 let (raw_value, storage_value) = value.to_ffi();
8701 raw.naturalSize = raw_value;
8702 storage.push_storage(storage_value);
8703 }
8704 (raw, storage)
8705 }
8706 pub fn with_extension(
8707 mut self,
8708 extension: ImageCopyExternalTextureExtension,
8709 ) -> Self {
8710 self.extensions.push(extension);
8711 self
8712 }
8713 pub(crate) fn from_ffi(value: ffi::WGPUImageCopyExternalTexture) -> Self {
8714 Self {
8715 extensions: Vec::new(),
8716 external_texture: Some(unsafe {
8717 ExternalTexture::from_raw(value.externalTexture)
8718 }),
8719 origin: Some(Origin3D::from_ffi(value.origin)),
8720 natural_size: Some(Extent2D::from_ffi(value.naturalSize)),
8721 }
8722 }
8723 }
8724 pub struct InstanceDescriptor {
8725 pub(crate) extensions: Vec<InstanceDescriptorExtension>,
8726 pub required_features: Option<Vec<InstanceFeatureName>>,
8727 pub required_limits: Option<InstanceLimits>,
8728 }
8729 impl Default for InstanceDescriptor {
8730 fn default() -> Self {
8731 Self {
8732 extensions: Vec::new(),
8733 required_features: None,
8734 required_limits: None,
8735 }
8736 }
8737 }
8738 impl InstanceDescriptor {
8739 pub fn new() -> Self {
8740 Self::default()
8741 }
8742 pub(crate) fn to_ffi(
8743 &self,
8744 ) -> (ffi::WGPUInstanceDescriptor, ChainedStructStorage) {
8745 let mut storage = ChainedStructStorage::new();
8746 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8747 for ext in self.extensions.iter().rev() {
8748 next = ext.push_chain(&mut storage, next);
8749 }
8750 let mut raw: ffi::WGPUInstanceDescriptor = unsafe { std::mem::zeroed() };
8751 raw.nextInChain = next;
8752 raw.requiredFeatureCount = self
8753 .required_features
8754 .as_ref()
8755 .map(|v| v.len())
8756 .unwrap_or(0);
8757 if let Some(values) = &self.required_features {
8758 let len_value = values.len();
8759 let raw_vec: Vec<ffi::WGPUInstanceFeatureName> = values
8760 .iter()
8761 .map(|v| (*v).into())
8762 .collect();
8763 let ptr = storage.push_vec(raw_vec);
8764 raw.requiredFeatures = ptr;
8765 raw.requiredFeatureCount = len_value;
8766 } else {
8767 raw.requiredFeatures = std::ptr::null();
8768 raw.requiredFeatureCount = 0;
8769 }
8770 if let Some(value) = &self.required_limits {
8771 let (raw_value, storage_value) = value.to_ffi();
8772 let ptr = storage.push_value(raw_value);
8773 raw.requiredLimits = ptr;
8774 storage.push_storage(storage_value);
8775 } else {
8776 raw.requiredLimits = std::ptr::null();
8777 }
8778 (raw, storage)
8779 }
8780 pub fn with_extension(mut self, extension: InstanceDescriptorExtension) -> Self {
8781 self.extensions.push(extension);
8782 self
8783 }
8784 pub(crate) fn from_ffi(value: ffi::WGPUInstanceDescriptor) -> Self {
8785 Self {
8786 extensions: Vec::new(),
8787 required_features: if value.requiredFeatures.is_null() {
8788 None
8789 } else {
8790 Some(
8791 unsafe {
8792 std::slice::from_raw_parts(
8793 value.requiredFeatures,
8794 value.requiredFeatureCount as usize,
8795 )
8796 }
8797 .iter()
8798 .map(|raw| InstanceFeatureName::from(*raw))
8799 .collect(),
8800 )
8801 },
8802 required_limits: if value.requiredLimits.is_null() {
8803 None
8804 } else {
8805 Some(InstanceLimits::from_ffi(unsafe { *value.requiredLimits }))
8806 },
8807 }
8808 }
8809 }
8810 pub struct InstanceLimits {
8811 pub(crate) extensions: Vec<InstanceLimitsExtension>,
8812 pub timed_wait_any_max_count: Option<usize>,
8813 }
8814 impl Default for InstanceLimits {
8815 fn default() -> Self {
8816 Self {
8817 extensions: Vec::new(),
8818 timed_wait_any_max_count: Some(0),
8819 }
8820 }
8821 }
8822 impl InstanceLimits {
8823 pub fn new() -> Self {
8824 Self::default()
8825 }
8826 pub(crate) fn to_ffi(&self) -> (ffi::WGPUInstanceLimits, ChainedStructStorage) {
8827 let mut storage = ChainedStructStorage::new();
8828 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8829 for ext in self.extensions.iter().rev() {
8830 next = ext.push_chain(&mut storage, next);
8831 }
8832 let mut raw: ffi::WGPUInstanceLimits = unsafe { std::mem::zeroed() };
8833 raw.nextInChain = next;
8834 if let Some(value) = self.timed_wait_any_max_count {
8835 raw.timedWaitAnyMaxCount = value;
8836 }
8837 (raw, storage)
8838 }
8839 pub fn with_extension(mut self, extension: InstanceLimitsExtension) -> Self {
8840 self.extensions.push(extension);
8841 self
8842 }
8843 pub(crate) fn from_ffi(value: ffi::WGPUInstanceLimits) -> Self {
8844 Self {
8845 extensions: Vec::new(),
8846 timed_wait_any_max_count: Some(value.timedWaitAnyMaxCount),
8847 }
8848 }
8849 }
8850 pub struct Limits {
8851 pub(crate) extensions: Vec<LimitsExtension>,
8852 pub max_texture_dimension_1d: Option<u32>,
8853 pub max_texture_dimension_2d: Option<u32>,
8854 pub max_texture_dimension_3d: Option<u32>,
8855 pub max_texture_array_layers: Option<u32>,
8856 pub max_bind_groups: Option<u32>,
8857 pub max_bind_groups_plus_vertex_buffers: Option<u32>,
8858 pub max_bindings_per_bind_group: Option<u32>,
8859 pub max_dynamic_uniform_buffers_per_pipeline_layout: Option<u32>,
8860 pub max_dynamic_storage_buffers_per_pipeline_layout: Option<u32>,
8861 pub max_sampled_textures_per_shader_stage: Option<u32>,
8862 pub max_samplers_per_shader_stage: Option<u32>,
8863 pub max_storage_buffers_per_shader_stage: Option<u32>,
8864 pub max_storage_textures_per_shader_stage: Option<u32>,
8865 pub max_uniform_buffers_per_shader_stage: Option<u32>,
8866 pub max_uniform_buffer_binding_size: Option<u64>,
8867 pub max_storage_buffer_binding_size: Option<u64>,
8868 pub min_uniform_buffer_offset_alignment: Option<u32>,
8869 pub min_storage_buffer_offset_alignment: Option<u32>,
8870 pub max_vertex_buffers: Option<u32>,
8871 pub max_buffer_size: Option<u64>,
8872 pub max_vertex_attributes: Option<u32>,
8873 pub max_vertex_buffer_array_stride: Option<u32>,
8874 pub max_inter_stage_shader_variables: Option<u32>,
8875 pub max_color_attachments: Option<u32>,
8876 pub max_color_attachment_bytes_per_sample: Option<u32>,
8877 pub max_compute_workgroup_storage_size: Option<u32>,
8878 pub max_compute_invocations_per_workgroup: Option<u32>,
8879 pub max_compute_workgroup_size_x: Option<u32>,
8880 pub max_compute_workgroup_size_y: Option<u32>,
8881 pub max_compute_workgroup_size_z: Option<u32>,
8882 pub max_compute_workgroups_per_dimension: Option<u32>,
8883 pub max_immediate_size: Option<u32>,
8884 }
8885 impl Default for Limits {
8886 fn default() -> Self {
8887 Self {
8888 extensions: Vec::new(),
8889 max_texture_dimension_1d: Some(LIMIT_U32_UNDEFINED),
8890 max_texture_dimension_2d: Some(LIMIT_U32_UNDEFINED),
8891 max_texture_dimension_3d: Some(LIMIT_U32_UNDEFINED),
8892 max_texture_array_layers: Some(LIMIT_U32_UNDEFINED),
8893 max_bind_groups: Some(LIMIT_U32_UNDEFINED),
8894 max_bind_groups_plus_vertex_buffers: Some(LIMIT_U32_UNDEFINED),
8895 max_bindings_per_bind_group: Some(LIMIT_U32_UNDEFINED),
8896 max_dynamic_uniform_buffers_per_pipeline_layout: Some(
8897 LIMIT_U32_UNDEFINED,
8898 ),
8899 max_dynamic_storage_buffers_per_pipeline_layout: Some(
8900 LIMIT_U32_UNDEFINED,
8901 ),
8902 max_sampled_textures_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8903 max_samplers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8904 max_storage_buffers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8905 max_storage_textures_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8906 max_uniform_buffers_per_shader_stage: Some(LIMIT_U32_UNDEFINED),
8907 max_uniform_buffer_binding_size: Some(LIMIT_U64_UNDEFINED),
8908 max_storage_buffer_binding_size: Some(LIMIT_U64_UNDEFINED),
8909 min_uniform_buffer_offset_alignment: Some(LIMIT_U32_UNDEFINED),
8910 min_storage_buffer_offset_alignment: Some(LIMIT_U32_UNDEFINED),
8911 max_vertex_buffers: Some(LIMIT_U32_UNDEFINED),
8912 max_buffer_size: Some(LIMIT_U64_UNDEFINED),
8913 max_vertex_attributes: Some(LIMIT_U32_UNDEFINED),
8914 max_vertex_buffer_array_stride: Some(LIMIT_U32_UNDEFINED),
8915 max_inter_stage_shader_variables: Some(LIMIT_U32_UNDEFINED),
8916 max_color_attachments: Some(LIMIT_U32_UNDEFINED),
8917 max_color_attachment_bytes_per_sample: Some(LIMIT_U32_UNDEFINED),
8918 max_compute_workgroup_storage_size: Some(LIMIT_U32_UNDEFINED),
8919 max_compute_invocations_per_workgroup: Some(LIMIT_U32_UNDEFINED),
8920 max_compute_workgroup_size_x: Some(LIMIT_U32_UNDEFINED),
8921 max_compute_workgroup_size_y: Some(LIMIT_U32_UNDEFINED),
8922 max_compute_workgroup_size_z: Some(LIMIT_U32_UNDEFINED),
8923 max_compute_workgroups_per_dimension: Some(LIMIT_U32_UNDEFINED),
8924 max_immediate_size: Some(LIMIT_U32_UNDEFINED),
8925 }
8926 }
8927 }
8928 impl Limits {
8929 pub fn new() -> Self {
8930 Self::default()
8931 }
8932 pub(crate) fn to_ffi(&self) -> (ffi::WGPULimits, ChainedStructStorage) {
8933 let mut storage = ChainedStructStorage::new();
8934 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
8935 for ext in self.extensions.iter().rev() {
8936 next = ext.push_chain(&mut storage, next);
8937 }
8938 let mut raw: ffi::WGPULimits = unsafe { std::mem::zeroed() };
8939 raw.nextInChain = next;
8940 if let Some(value) = self.max_texture_dimension_1d {
8941 raw.maxTextureDimension1D = value;
8942 }
8943 if let Some(value) = self.max_texture_dimension_2d {
8944 raw.maxTextureDimension2D = value;
8945 }
8946 if let Some(value) = self.max_texture_dimension_3d {
8947 raw.maxTextureDimension3D = value;
8948 }
8949 if let Some(value) = self.max_texture_array_layers {
8950 raw.maxTextureArrayLayers = value;
8951 }
8952 if let Some(value) = self.max_bind_groups {
8953 raw.maxBindGroups = value;
8954 }
8955 if let Some(value) = self.max_bind_groups_plus_vertex_buffers {
8956 raw.maxBindGroupsPlusVertexBuffers = value;
8957 }
8958 if let Some(value) = self.max_bindings_per_bind_group {
8959 raw.maxBindingsPerBindGroup = value;
8960 }
8961 if let Some(value) = self.max_dynamic_uniform_buffers_per_pipeline_layout {
8962 raw.maxDynamicUniformBuffersPerPipelineLayout = value;
8963 }
8964 if let Some(value) = self.max_dynamic_storage_buffers_per_pipeline_layout {
8965 raw.maxDynamicStorageBuffersPerPipelineLayout = value;
8966 }
8967 if let Some(value) = self.max_sampled_textures_per_shader_stage {
8968 raw.maxSampledTexturesPerShaderStage = value;
8969 }
8970 if let Some(value) = self.max_samplers_per_shader_stage {
8971 raw.maxSamplersPerShaderStage = value;
8972 }
8973 if let Some(value) = self.max_storage_buffers_per_shader_stage {
8974 raw.maxStorageBuffersPerShaderStage = value;
8975 }
8976 if let Some(value) = self.max_storage_textures_per_shader_stage {
8977 raw.maxStorageTexturesPerShaderStage = value;
8978 }
8979 if let Some(value) = self.max_uniform_buffers_per_shader_stage {
8980 raw.maxUniformBuffersPerShaderStage = value;
8981 }
8982 if let Some(value) = self.max_uniform_buffer_binding_size {
8983 raw.maxUniformBufferBindingSize = value;
8984 }
8985 if let Some(value) = self.max_storage_buffer_binding_size {
8986 raw.maxStorageBufferBindingSize = value;
8987 }
8988 if let Some(value) = self.min_uniform_buffer_offset_alignment {
8989 raw.minUniformBufferOffsetAlignment = value;
8990 }
8991 if let Some(value) = self.min_storage_buffer_offset_alignment {
8992 raw.minStorageBufferOffsetAlignment = value;
8993 }
8994 if let Some(value) = self.max_vertex_buffers {
8995 raw.maxVertexBuffers = value;
8996 }
8997 if let Some(value) = self.max_buffer_size {
8998 raw.maxBufferSize = value;
8999 }
9000 if let Some(value) = self.max_vertex_attributes {
9001 raw.maxVertexAttributes = value;
9002 }
9003 if let Some(value) = self.max_vertex_buffer_array_stride {
9004 raw.maxVertexBufferArrayStride = value;
9005 }
9006 if let Some(value) = self.max_inter_stage_shader_variables {
9007 raw.maxInterStageShaderVariables = value;
9008 }
9009 if let Some(value) = self.max_color_attachments {
9010 raw.maxColorAttachments = value;
9011 }
9012 if let Some(value) = self.max_color_attachment_bytes_per_sample {
9013 raw.maxColorAttachmentBytesPerSample = value;
9014 }
9015 if let Some(value) = self.max_compute_workgroup_storage_size {
9016 raw.maxComputeWorkgroupStorageSize = value;
9017 }
9018 if let Some(value) = self.max_compute_invocations_per_workgroup {
9019 raw.maxComputeInvocationsPerWorkgroup = value;
9020 }
9021 if let Some(value) = self.max_compute_workgroup_size_x {
9022 raw.maxComputeWorkgroupSizeX = value;
9023 }
9024 if let Some(value) = self.max_compute_workgroup_size_y {
9025 raw.maxComputeWorkgroupSizeY = value;
9026 }
9027 if let Some(value) = self.max_compute_workgroup_size_z {
9028 raw.maxComputeWorkgroupSizeZ = value;
9029 }
9030 if let Some(value) = self.max_compute_workgroups_per_dimension {
9031 raw.maxComputeWorkgroupsPerDimension = value;
9032 }
9033 if let Some(value) = self.max_immediate_size {
9034 raw.maxImmediateSize = value;
9035 }
9036 (raw, storage)
9037 }
9038 pub fn with_extension(mut self, extension: LimitsExtension) -> Self {
9039 self.extensions.push(extension);
9040 self
9041 }
9042 pub(crate) fn from_ffi(value: ffi::WGPULimits) -> Self {
9043 Self {
9044 extensions: Vec::new(),
9045 max_texture_dimension_1d: Some(value.maxTextureDimension1D),
9046 max_texture_dimension_2d: Some(value.maxTextureDimension2D),
9047 max_texture_dimension_3d: Some(value.maxTextureDimension3D),
9048 max_texture_array_layers: Some(value.maxTextureArrayLayers),
9049 max_bind_groups: Some(value.maxBindGroups),
9050 max_bind_groups_plus_vertex_buffers: Some(
9051 value.maxBindGroupsPlusVertexBuffers,
9052 ),
9053 max_bindings_per_bind_group: Some(value.maxBindingsPerBindGroup),
9054 max_dynamic_uniform_buffers_per_pipeline_layout: Some(
9055 value.maxDynamicUniformBuffersPerPipelineLayout,
9056 ),
9057 max_dynamic_storage_buffers_per_pipeline_layout: Some(
9058 value.maxDynamicStorageBuffersPerPipelineLayout,
9059 ),
9060 max_sampled_textures_per_shader_stage: Some(
9061 value.maxSampledTexturesPerShaderStage,
9062 ),
9063 max_samplers_per_shader_stage: Some(value.maxSamplersPerShaderStage),
9064 max_storage_buffers_per_shader_stage: Some(
9065 value.maxStorageBuffersPerShaderStage,
9066 ),
9067 max_storage_textures_per_shader_stage: Some(
9068 value.maxStorageTexturesPerShaderStage,
9069 ),
9070 max_uniform_buffers_per_shader_stage: Some(
9071 value.maxUniformBuffersPerShaderStage,
9072 ),
9073 max_uniform_buffer_binding_size: Some(value.maxUniformBufferBindingSize),
9074 max_storage_buffer_binding_size: Some(value.maxStorageBufferBindingSize),
9075 min_uniform_buffer_offset_alignment: Some(
9076 value.minUniformBufferOffsetAlignment,
9077 ),
9078 min_storage_buffer_offset_alignment: Some(
9079 value.minStorageBufferOffsetAlignment,
9080 ),
9081 max_vertex_buffers: Some(value.maxVertexBuffers),
9082 max_buffer_size: Some(value.maxBufferSize),
9083 max_vertex_attributes: Some(value.maxVertexAttributes),
9084 max_vertex_buffer_array_stride: Some(value.maxVertexBufferArrayStride),
9085 max_inter_stage_shader_variables: Some(
9086 value.maxInterStageShaderVariables,
9087 ),
9088 max_color_attachments: Some(value.maxColorAttachments),
9089 max_color_attachment_bytes_per_sample: Some(
9090 value.maxColorAttachmentBytesPerSample,
9091 ),
9092 max_compute_workgroup_storage_size: Some(
9093 value.maxComputeWorkgroupStorageSize,
9094 ),
9095 max_compute_invocations_per_workgroup: Some(
9096 value.maxComputeInvocationsPerWorkgroup,
9097 ),
9098 max_compute_workgroup_size_x: Some(value.maxComputeWorkgroupSizeX),
9099 max_compute_workgroup_size_y: Some(value.maxComputeWorkgroupSizeY),
9100 max_compute_workgroup_size_z: Some(value.maxComputeWorkgroupSizeZ),
9101 max_compute_workgroups_per_dimension: Some(
9102 value.maxComputeWorkgroupsPerDimension,
9103 ),
9104 max_immediate_size: Some(value.maxImmediateSize),
9105 }
9106 }
9107 }
9108 pub struct MemoryHeapInfo {
9109 pub properties: Option<HeapProperty>,
9110 pub size: Option<u64>,
9111 }
9112 impl Default for MemoryHeapInfo {
9113 fn default() -> Self {
9114 Self {
9115 properties: None,
9116 size: None,
9117 }
9118 }
9119 }
9120 impl MemoryHeapInfo {
9121 pub fn new() -> Self {
9122 Self::default()
9123 }
9124 pub(crate) fn to_ffi(&self) -> (ffi::WGPUMemoryHeapInfo, ChainedStructStorage) {
9125 let mut storage = ChainedStructStorage::new();
9126 let mut raw: ffi::WGPUMemoryHeapInfo = unsafe { std::mem::zeroed() };
9127 if let Some(value) = self.properties {
9128 raw.properties = value.into();
9129 } else {
9130 raw.properties = 0 as ffi::WGPUHeapProperty;
9131 }
9132 if let Some(value) = self.size {
9133 raw.size = value;
9134 }
9135 (raw, storage)
9136 }
9137 pub(crate) fn from_ffi(value: ffi::WGPUMemoryHeapInfo) -> Self {
9138 Self {
9139 properties: Some(value.properties.into()),
9140 size: Some(value.size),
9141 }
9142 }
9143 }
9144 pub struct MultisampleState {
9145 pub(crate) extensions: Vec<MultisampleStateExtension>,
9146 pub count: Option<u32>,
9147 pub mask: Option<u32>,
9148 pub alpha_to_coverage_enabled: Option<bool>,
9149 }
9150 impl Default for MultisampleState {
9151 fn default() -> Self {
9152 Self {
9153 extensions: Vec::new(),
9154 count: Some(1),
9155 mask: Some(4294967295),
9156 alpha_to_coverage_enabled: None,
9157 }
9158 }
9159 }
9160 impl MultisampleState {
9161 pub fn new() -> Self {
9162 Self::default()
9163 }
9164 pub(crate) fn to_ffi(
9165 &self,
9166 ) -> (ffi::WGPUMultisampleState, ChainedStructStorage) {
9167 let mut storage = ChainedStructStorage::new();
9168 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9169 for ext in self.extensions.iter().rev() {
9170 next = ext.push_chain(&mut storage, next);
9171 }
9172 let mut raw: ffi::WGPUMultisampleState = unsafe { std::mem::zeroed() };
9173 raw.nextInChain = next;
9174 if let Some(value) = self.count {
9175 raw.count = value;
9176 }
9177 if let Some(value) = self.mask {
9178 raw.mask = value;
9179 }
9180 raw.alphaToCoverageEnabled = if self
9181 .alpha_to_coverage_enabled
9182 .unwrap_or(false)
9183 {
9184 1
9185 } else {
9186 0
9187 };
9188 (raw, storage)
9189 }
9190 pub fn with_extension(mut self, extension: MultisampleStateExtension) -> Self {
9191 self.extensions.push(extension);
9192 self
9193 }
9194 pub(crate) fn from_ffi(value: ffi::WGPUMultisampleState) -> Self {
9195 Self {
9196 extensions: Vec::new(),
9197 count: Some(value.count),
9198 mask: Some(value.mask),
9199 alpha_to_coverage_enabled: Some(value.alphaToCoverageEnabled != 0),
9200 }
9201 }
9202 }
9203 pub struct Origin2D {
9204 pub x: Option<u32>,
9205 pub y: Option<u32>,
9206 }
9207 impl Default for Origin2D {
9208 fn default() -> Self {
9209 Self { x: Some(0), y: Some(0) }
9210 }
9211 }
9212 impl Origin2D {
9213 pub fn new() -> Self {
9214 Self::default()
9215 }
9216 pub(crate) fn to_ffi(&self) -> (ffi::WGPUOrigin2D, ChainedStructStorage) {
9217 let mut storage = ChainedStructStorage::new();
9218 let mut raw: ffi::WGPUOrigin2D = unsafe { std::mem::zeroed() };
9219 if let Some(value) = self.x {
9220 raw.x = value;
9221 }
9222 if let Some(value) = self.y {
9223 raw.y = value;
9224 }
9225 (raw, storage)
9226 }
9227 pub(crate) fn from_ffi(value: ffi::WGPUOrigin2D) -> Self {
9228 Self {
9229 x: Some(value.x),
9230 y: Some(value.y),
9231 }
9232 }
9233 }
9234 pub struct Origin3D {
9235 pub x: Option<u32>,
9236 pub y: Option<u32>,
9237 pub z: Option<u32>,
9238 }
9239 impl Default for Origin3D {
9240 fn default() -> Self {
9241 Self {
9242 x: Some(0),
9243 y: Some(0),
9244 z: Some(0),
9245 }
9246 }
9247 }
9248 impl Origin3D {
9249 pub fn new() -> Self {
9250 Self::default()
9251 }
9252 pub(crate) fn to_ffi(&self) -> (ffi::WGPUOrigin3D, ChainedStructStorage) {
9253 let mut storage = ChainedStructStorage::new();
9254 let mut raw: ffi::WGPUOrigin3D = unsafe { std::mem::zeroed() };
9255 if let Some(value) = self.x {
9256 raw.x = value;
9257 }
9258 if let Some(value) = self.y {
9259 raw.y = value;
9260 }
9261 if let Some(value) = self.z {
9262 raw.z = value;
9263 }
9264 (raw, storage)
9265 }
9266 pub(crate) fn from_ffi(value: ffi::WGPUOrigin3D) -> Self {
9267 Self {
9268 x: Some(value.x),
9269 y: Some(value.y),
9270 z: Some(value.z),
9271 }
9272 }
9273 }
9274 pub struct PassTimestampWrites {
9275 pub(crate) extensions: Vec<PassTimestampWritesExtension>,
9276 pub query_set: Option<QuerySet>,
9277 pub beginning_of_pass_write_index: Option<u32>,
9278 pub end_of_pass_write_index: Option<u32>,
9279 }
9280 impl Default for PassTimestampWrites {
9281 fn default() -> Self {
9282 Self {
9283 extensions: Vec::new(),
9284 query_set: None,
9285 beginning_of_pass_write_index: Some(QUERY_SET_INDEX_UNDEFINED),
9286 end_of_pass_write_index: Some(QUERY_SET_INDEX_UNDEFINED),
9287 }
9288 }
9289 }
9290 impl PassTimestampWrites {
9291 pub fn new() -> Self {
9292 Self::default()
9293 }
9294 pub(crate) fn to_ffi(
9295 &self,
9296 ) -> (ffi::WGPUPassTimestampWrites, ChainedStructStorage) {
9297 let mut storage = ChainedStructStorage::new();
9298 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9299 for ext in self.extensions.iter().rev() {
9300 next = ext.push_chain(&mut storage, next);
9301 }
9302 let mut raw: ffi::WGPUPassTimestampWrites = unsafe { std::mem::zeroed() };
9303 raw.nextInChain = next;
9304 raw.querySet = self
9305 .query_set
9306 .as_ref()
9307 .map(|v| v.as_raw())
9308 .unwrap_or(std::ptr::null_mut());
9309 if let Some(value) = self.beginning_of_pass_write_index {
9310 raw.beginningOfPassWriteIndex = value;
9311 }
9312 if let Some(value) = self.end_of_pass_write_index {
9313 raw.endOfPassWriteIndex = value;
9314 }
9315 (raw, storage)
9316 }
9317 pub fn with_extension(
9318 mut self,
9319 extension: PassTimestampWritesExtension,
9320 ) -> Self {
9321 self.extensions.push(extension);
9322 self
9323 }
9324 pub(crate) fn from_ffi(value: ffi::WGPUPassTimestampWrites) -> Self {
9325 Self {
9326 extensions: Vec::new(),
9327 query_set: Some(unsafe { QuerySet::from_raw(value.querySet) }),
9328 beginning_of_pass_write_index: Some(value.beginningOfPassWriteIndex),
9329 end_of_pass_write_index: Some(value.endOfPassWriteIndex),
9330 }
9331 }
9332 }
9333 pub struct PipelineLayoutDescriptor {
9334 pub(crate) extensions: Vec<PipelineLayoutDescriptorExtension>,
9335 pub label: Option<String>,
9336 pub bind_group_layouts: Option<Vec<BindGroupLayout>>,
9337 pub immediate_size: Option<u32>,
9338 }
9339 impl Default for PipelineLayoutDescriptor {
9340 fn default() -> Self {
9341 Self {
9342 extensions: Vec::new(),
9343 label: None,
9344 bind_group_layouts: None,
9345 immediate_size: Some(0),
9346 }
9347 }
9348 }
9349 impl PipelineLayoutDescriptor {
9350 pub fn new() -> Self {
9351 Self::default()
9352 }
9353 pub(crate) fn to_ffi(
9354 &self,
9355 ) -> (ffi::WGPUPipelineLayoutDescriptor, ChainedStructStorage) {
9356 let mut storage = ChainedStructStorage::new();
9357 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9358 for ext in self.extensions.iter().rev() {
9359 next = ext.push_chain(&mut storage, next);
9360 }
9361 let mut raw: ffi::WGPUPipelineLayoutDescriptor = unsafe {
9362 std::mem::zeroed()
9363 };
9364 raw.nextInChain = next;
9365 if let Some(value) = &self.label {
9366 raw.label = ffi::WGPUStringView {
9367 data: value.as_ptr().cast(),
9368 length: value.len(),
9369 };
9370 } else {
9371 raw.label = ffi::WGPUStringView {
9372 data: std::ptr::null(),
9373 length: 0,
9374 };
9375 }
9376 raw.bindGroupLayoutCount = self
9377 .bind_group_layouts
9378 .as_ref()
9379 .map(|v| v.len())
9380 .unwrap_or(0);
9381 if let Some(values) = &self.bind_group_layouts {
9382 let len_value = values.len();
9383 let raw_vec: Vec<ffi::WGPUBindGroupLayout> = values
9384 .iter()
9385 .map(|v| v.as_raw())
9386 .collect();
9387 let ptr = storage.push_vec(raw_vec);
9388 raw.bindGroupLayouts = ptr;
9389 raw.bindGroupLayoutCount = len_value;
9390 } else {
9391 raw.bindGroupLayouts = std::ptr::null();
9392 raw.bindGroupLayoutCount = 0;
9393 }
9394 if let Some(value) = self.immediate_size {
9395 raw.immediateSize = value;
9396 }
9397 (raw, storage)
9398 }
9399 pub fn with_extension(
9400 mut self,
9401 extension: PipelineLayoutDescriptorExtension,
9402 ) -> Self {
9403 self.extensions.push(extension);
9404 self
9405 }
9406 pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutDescriptor) -> Self {
9407 Self {
9408 extensions: Vec::new(),
9409 label: if value.label.data.is_null() || value.label.length == 0 {
9410 None
9411 } else {
9412 Some(string_view_to_string(value.label))
9413 },
9414 bind_group_layouts: if value.bindGroupLayouts.is_null() {
9415 None
9416 } else {
9417 Some(
9418 unsafe {
9419 std::slice::from_raw_parts(
9420 value.bindGroupLayouts,
9421 value.bindGroupLayoutCount as usize,
9422 )
9423 }
9424 .iter()
9425 .map(|raw| unsafe { BindGroupLayout::from_raw(*raw) })
9426 .collect(),
9427 )
9428 },
9429 immediate_size: Some(value.immediateSize),
9430 }
9431 }
9432 }
9433 pub struct PipelineLayoutPixelLocalStorage {
9434 pub total_pixel_local_storage_size: Option<u64>,
9435 pub storage_attachments: Option<Vec<PipelineLayoutStorageAttachment>>,
9436 }
9437 impl Default for PipelineLayoutPixelLocalStorage {
9438 fn default() -> Self {
9439 Self {
9440 total_pixel_local_storage_size: None,
9441 storage_attachments: None,
9442 }
9443 }
9444 }
9445 impl PipelineLayoutPixelLocalStorage {
9446 pub fn new() -> Self {
9447 Self::default()
9448 }
9449 pub(crate) fn to_ffi(
9450 &self,
9451 ) -> (ffi::WGPUPipelineLayoutPixelLocalStorage, ChainedStructStorage) {
9452 let mut storage = ChainedStructStorage::new();
9453 let mut raw: ffi::WGPUPipelineLayoutPixelLocalStorage = unsafe {
9454 std::mem::zeroed()
9455 };
9456 if let Some(value) = self.total_pixel_local_storage_size {
9457 raw.totalPixelLocalStorageSize = value;
9458 }
9459 raw.storageAttachmentCount = self
9460 .storage_attachments
9461 .as_ref()
9462 .map(|v| v.len())
9463 .unwrap_or(0);
9464 if let Some(values) = &self.storage_attachments {
9465 let len_value = values.len();
9466 let mut raw_vec: Vec<ffi::WGPUPipelineLayoutStorageAttachment> = Vec::with_capacity(
9467 values.len(),
9468 );
9469 for item in values.iter() {
9470 let (raw_item, storage_item) = item.to_ffi();
9471 raw_vec.push(raw_item);
9472 storage.push_storage(storage_item);
9473 }
9474 let ptr = storage.push_vec(raw_vec);
9475 raw.storageAttachments = ptr;
9476 raw.storageAttachmentCount = len_value;
9477 } else {
9478 raw.storageAttachments = std::ptr::null();
9479 raw.storageAttachmentCount = 0;
9480 }
9481 (raw, storage)
9482 }
9483 pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutPixelLocalStorage) -> Self {
9484 Self {
9485 total_pixel_local_storage_size: Some(value.totalPixelLocalStorageSize),
9486 storage_attachments: if value.storageAttachments.is_null() {
9487 None
9488 } else {
9489 Some(
9490 unsafe {
9491 std::slice::from_raw_parts(
9492 value.storageAttachments,
9493 value.storageAttachmentCount as usize,
9494 )
9495 }
9496 .iter()
9497 .map(|raw| PipelineLayoutStorageAttachment::from_ffi(*raw))
9498 .collect(),
9499 )
9500 },
9501 }
9502 }
9503 }
9504 pub struct PipelineLayoutResourceTable {
9505 pub uses_resource_table: Option<bool>,
9506 }
9507 impl Default for PipelineLayoutResourceTable {
9508 fn default() -> Self {
9509 Self { uses_resource_table: None }
9510 }
9511 }
9512 impl PipelineLayoutResourceTable {
9513 pub fn new() -> Self {
9514 Self::default()
9515 }
9516 pub(crate) fn to_ffi(
9517 &self,
9518 ) -> (ffi::WGPUPipelineLayoutResourceTable, ChainedStructStorage) {
9519 let mut storage = ChainedStructStorage::new();
9520 let mut raw: ffi::WGPUPipelineLayoutResourceTable = unsafe {
9521 std::mem::zeroed()
9522 };
9523 raw.usesResourceTable = if self.uses_resource_table.unwrap_or(false) {
9524 1
9525 } else {
9526 0
9527 };
9528 (raw, storage)
9529 }
9530 pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutResourceTable) -> Self {
9531 Self {
9532 uses_resource_table: Some(value.usesResourceTable != 0),
9533 }
9534 }
9535 }
9536 pub struct PipelineLayoutStorageAttachment {
9537 pub(crate) extensions: Vec<PipelineLayoutStorageAttachmentExtension>,
9538 pub offset: Option<u64>,
9539 pub format: Option<TextureFormat>,
9540 }
9541 impl Default for PipelineLayoutStorageAttachment {
9542 fn default() -> Self {
9543 Self {
9544 extensions: Vec::new(),
9545 offset: Some(0),
9546 format: None,
9547 }
9548 }
9549 }
9550 impl PipelineLayoutStorageAttachment {
9551 pub fn new() -> Self {
9552 Self::default()
9553 }
9554 pub(crate) fn to_ffi(
9555 &self,
9556 ) -> (ffi::WGPUPipelineLayoutStorageAttachment, ChainedStructStorage) {
9557 let mut storage = ChainedStructStorage::new();
9558 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9559 for ext in self.extensions.iter().rev() {
9560 next = ext.push_chain(&mut storage, next);
9561 }
9562 let mut raw: ffi::WGPUPipelineLayoutStorageAttachment = unsafe {
9563 std::mem::zeroed()
9564 };
9565 raw.nextInChain = next;
9566 if let Some(value) = self.offset {
9567 raw.offset = value;
9568 }
9569 if let Some(value) = self.format {
9570 raw.format = value.into();
9571 } else {
9572 raw.format = 0 as ffi::WGPUTextureFormat;
9573 }
9574 (raw, storage)
9575 }
9576 pub fn with_extension(
9577 mut self,
9578 extension: PipelineLayoutStorageAttachmentExtension,
9579 ) -> Self {
9580 self.extensions.push(extension);
9581 self
9582 }
9583 pub(crate) fn from_ffi(value: ffi::WGPUPipelineLayoutStorageAttachment) -> Self {
9584 Self {
9585 extensions: Vec::new(),
9586 offset: Some(value.offset),
9587 format: Some(value.format.into()),
9588 }
9589 }
9590 }
9591 pub struct PrimitiveState {
9592 pub(crate) extensions: Vec<PrimitiveStateExtension>,
9593 pub topology: Option<PrimitiveTopology>,
9594 pub strip_index_format: Option<IndexFormat>,
9595 pub front_face: Option<FrontFace>,
9596 pub cull_mode: Option<CullMode>,
9597 pub unclipped_depth: Option<bool>,
9598 }
9599 impl Default for PrimitiveState {
9600 fn default() -> Self {
9601 Self {
9602 extensions: Vec::new(),
9603 topology: Some(PrimitiveTopology::TriangleList),
9604 strip_index_format: None,
9605 front_face: Some(FrontFace::Ccw),
9606 cull_mode: Some(CullMode::None),
9607 unclipped_depth: None,
9608 }
9609 }
9610 }
9611 impl PrimitiveState {
9612 pub fn new() -> Self {
9613 Self::default()
9614 }
9615 pub(crate) fn to_ffi(&self) -> (ffi::WGPUPrimitiveState, ChainedStructStorage) {
9616 let mut storage = ChainedStructStorage::new();
9617 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9618 for ext in self.extensions.iter().rev() {
9619 next = ext.push_chain(&mut storage, next);
9620 }
9621 let mut raw: ffi::WGPUPrimitiveState = unsafe { std::mem::zeroed() };
9622 raw.nextInChain = next;
9623 if let Some(value) = self.topology {
9624 raw.topology = value.into();
9625 } else {
9626 raw.topology = 0 as ffi::WGPUPrimitiveTopology;
9627 }
9628 if let Some(value) = self.strip_index_format {
9629 raw.stripIndexFormat = value.into();
9630 } else {
9631 raw.stripIndexFormat = 0 as ffi::WGPUIndexFormat;
9632 }
9633 if let Some(value) = self.front_face {
9634 raw.frontFace = value.into();
9635 } else {
9636 raw.frontFace = 0 as ffi::WGPUFrontFace;
9637 }
9638 if let Some(value) = self.cull_mode {
9639 raw.cullMode = value.into();
9640 } else {
9641 raw.cullMode = 0 as ffi::WGPUCullMode;
9642 }
9643 raw.unclippedDepth = if self.unclipped_depth.unwrap_or(false) {
9644 1
9645 } else {
9646 0
9647 };
9648 (raw, storage)
9649 }
9650 pub fn with_extension(mut self, extension: PrimitiveStateExtension) -> Self {
9651 self.extensions.push(extension);
9652 self
9653 }
9654 pub(crate) fn from_ffi(value: ffi::WGPUPrimitiveState) -> Self {
9655 Self {
9656 extensions: Vec::new(),
9657 topology: Some(value.topology.into()),
9658 strip_index_format: Some(value.stripIndexFormat.into()),
9659 front_face: Some(value.frontFace.into()),
9660 cull_mode: Some(value.cullMode.into()),
9661 unclipped_depth: Some(value.unclippedDepth != 0),
9662 }
9663 }
9664 }
9665 pub struct QuerySetDescriptor {
9666 pub(crate) extensions: Vec<QuerySetDescriptorExtension>,
9667 pub label: Option<String>,
9668 pub r#type: Option<QueryType>,
9669 pub count: Option<u32>,
9670 }
9671 impl Default for QuerySetDescriptor {
9672 fn default() -> Self {
9673 Self {
9674 extensions: Vec::new(),
9675 label: None,
9676 r#type: None,
9677 count: None,
9678 }
9679 }
9680 }
9681 impl QuerySetDescriptor {
9682 pub fn new() -> Self {
9683 Self::default()
9684 }
9685 pub(crate) fn to_ffi(
9686 &self,
9687 ) -> (ffi::WGPUQuerySetDescriptor, ChainedStructStorage) {
9688 let mut storage = ChainedStructStorage::new();
9689 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9690 for ext in self.extensions.iter().rev() {
9691 next = ext.push_chain(&mut storage, next);
9692 }
9693 let mut raw: ffi::WGPUQuerySetDescriptor = unsafe { std::mem::zeroed() };
9694 raw.nextInChain = next;
9695 if let Some(value) = &self.label {
9696 raw.label = ffi::WGPUStringView {
9697 data: value.as_ptr().cast(),
9698 length: value.len(),
9699 };
9700 } else {
9701 raw.label = ffi::WGPUStringView {
9702 data: std::ptr::null(),
9703 length: 0,
9704 };
9705 }
9706 if let Some(value) = self.r#type {
9707 raw.type_ = value.into();
9708 } else {
9709 raw.type_ = 0 as ffi::WGPUQueryType;
9710 }
9711 if let Some(value) = self.count {
9712 raw.count = value;
9713 }
9714 (raw, storage)
9715 }
9716 pub fn with_extension(mut self, extension: QuerySetDescriptorExtension) -> Self {
9717 self.extensions.push(extension);
9718 self
9719 }
9720 pub(crate) fn from_ffi(value: ffi::WGPUQuerySetDescriptor) -> Self {
9721 Self {
9722 extensions: Vec::new(),
9723 label: if value.label.data.is_null() || value.label.length == 0 {
9724 None
9725 } else {
9726 Some(string_view_to_string(value.label))
9727 },
9728 r#type: Some(value.type_.into()),
9729 count: Some(value.count),
9730 }
9731 }
9732 }
9733 pub struct QueueDescriptor {
9734 pub(crate) extensions: Vec<QueueDescriptorExtension>,
9735 pub label: Option<String>,
9736 }
9737 impl Default for QueueDescriptor {
9738 fn default() -> Self {
9739 Self {
9740 extensions: Vec::new(),
9741 label: None,
9742 }
9743 }
9744 }
9745 impl QueueDescriptor {
9746 pub fn new() -> Self {
9747 Self::default()
9748 }
9749 pub(crate) fn to_ffi(&self) -> (ffi::WGPUQueueDescriptor, ChainedStructStorage) {
9750 let mut storage = ChainedStructStorage::new();
9751 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9752 for ext in self.extensions.iter().rev() {
9753 next = ext.push_chain(&mut storage, next);
9754 }
9755 let mut raw: ffi::WGPUQueueDescriptor = unsafe { std::mem::zeroed() };
9756 raw.nextInChain = next;
9757 if let Some(value) = &self.label {
9758 raw.label = ffi::WGPUStringView {
9759 data: value.as_ptr().cast(),
9760 length: value.len(),
9761 };
9762 } else {
9763 raw.label = ffi::WGPUStringView {
9764 data: std::ptr::null(),
9765 length: 0,
9766 };
9767 }
9768 (raw, storage)
9769 }
9770 pub fn with_extension(mut self, extension: QueueDescriptorExtension) -> Self {
9771 self.extensions.push(extension);
9772 self
9773 }
9774 pub(crate) fn from_ffi(value: ffi::WGPUQueueDescriptor) -> Self {
9775 Self {
9776 extensions: Vec::new(),
9777 label: if value.label.data.is_null() || value.label.length == 0 {
9778 None
9779 } else {
9780 Some(string_view_to_string(value.label))
9781 },
9782 }
9783 }
9784 }
9785 pub struct RenderBundleDescriptor {
9786 pub(crate) extensions: Vec<RenderBundleDescriptorExtension>,
9787 pub label: Option<String>,
9788 }
9789 impl Default for RenderBundleDescriptor {
9790 fn default() -> Self {
9791 Self {
9792 extensions: Vec::new(),
9793 label: None,
9794 }
9795 }
9796 }
9797 impl RenderBundleDescriptor {
9798 pub fn new() -> Self {
9799 Self::default()
9800 }
9801 pub(crate) fn to_ffi(
9802 &self,
9803 ) -> (ffi::WGPURenderBundleDescriptor, ChainedStructStorage) {
9804 let mut storage = ChainedStructStorage::new();
9805 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9806 for ext in self.extensions.iter().rev() {
9807 next = ext.push_chain(&mut storage, next);
9808 }
9809 let mut raw: ffi::WGPURenderBundleDescriptor = unsafe { std::mem::zeroed() };
9810 raw.nextInChain = next;
9811 if let Some(value) = &self.label {
9812 raw.label = ffi::WGPUStringView {
9813 data: value.as_ptr().cast(),
9814 length: value.len(),
9815 };
9816 } else {
9817 raw.label = ffi::WGPUStringView {
9818 data: std::ptr::null(),
9819 length: 0,
9820 };
9821 }
9822 (raw, storage)
9823 }
9824 pub fn with_extension(
9825 mut self,
9826 extension: RenderBundleDescriptorExtension,
9827 ) -> Self {
9828 self.extensions.push(extension);
9829 self
9830 }
9831 pub(crate) fn from_ffi(value: ffi::WGPURenderBundleDescriptor) -> Self {
9832 Self {
9833 extensions: Vec::new(),
9834 label: if value.label.data.is_null() || value.label.length == 0 {
9835 None
9836 } else {
9837 Some(string_view_to_string(value.label))
9838 },
9839 }
9840 }
9841 }
9842 pub struct RenderBundleEncoderDescriptor {
9843 pub(crate) extensions: Vec<RenderBundleEncoderDescriptorExtension>,
9844 pub label: Option<String>,
9845 pub color_formats: Option<Vec<TextureFormat>>,
9846 pub depth_stencil_format: Option<TextureFormat>,
9847 pub sample_count: Option<u32>,
9848 pub depth_read_only: Option<bool>,
9849 pub stencil_read_only: Option<bool>,
9850 }
9851 impl Default for RenderBundleEncoderDescriptor {
9852 fn default() -> Self {
9853 Self {
9854 extensions: Vec::new(),
9855 label: None,
9856 color_formats: None,
9857 depth_stencil_format: None,
9858 sample_count: Some(1),
9859 depth_read_only: None,
9860 stencil_read_only: None,
9861 }
9862 }
9863 }
9864 impl RenderBundleEncoderDescriptor {
9865 pub fn new() -> Self {
9866 Self::default()
9867 }
9868 pub(crate) fn to_ffi(
9869 &self,
9870 ) -> (ffi::WGPURenderBundleEncoderDescriptor, ChainedStructStorage) {
9871 let mut storage = ChainedStructStorage::new();
9872 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9873 for ext in self.extensions.iter().rev() {
9874 next = ext.push_chain(&mut storage, next);
9875 }
9876 let mut raw: ffi::WGPURenderBundleEncoderDescriptor = unsafe {
9877 std::mem::zeroed()
9878 };
9879 raw.nextInChain = next;
9880 if let Some(value) = &self.label {
9881 raw.label = ffi::WGPUStringView {
9882 data: value.as_ptr().cast(),
9883 length: value.len(),
9884 };
9885 } else {
9886 raw.label = ffi::WGPUStringView {
9887 data: std::ptr::null(),
9888 length: 0,
9889 };
9890 }
9891 raw.colorFormatCount = self
9892 .color_formats
9893 .as_ref()
9894 .map(|v| v.len())
9895 .unwrap_or(0);
9896 if let Some(values) = &self.color_formats {
9897 let len_value = values.len();
9898 let raw_vec: Vec<ffi::WGPUTextureFormat> = values
9899 .iter()
9900 .map(|v| (*v).into())
9901 .collect();
9902 let ptr = storage.push_vec(raw_vec);
9903 raw.colorFormats = ptr;
9904 raw.colorFormatCount = len_value;
9905 } else {
9906 raw.colorFormats = std::ptr::null();
9907 raw.colorFormatCount = 0;
9908 }
9909 if let Some(value) = self.depth_stencil_format {
9910 raw.depthStencilFormat = value.into();
9911 } else {
9912 raw.depthStencilFormat = 0 as ffi::WGPUTextureFormat;
9913 }
9914 if let Some(value) = self.sample_count {
9915 raw.sampleCount = value;
9916 }
9917 raw.depthReadOnly = if self.depth_read_only.unwrap_or(false) {
9918 1
9919 } else {
9920 0
9921 };
9922 raw.stencilReadOnly = if self.stencil_read_only.unwrap_or(false) {
9923 1
9924 } else {
9925 0
9926 };
9927 (raw, storage)
9928 }
9929 pub fn with_extension(
9930 mut self,
9931 extension: RenderBundleEncoderDescriptorExtension,
9932 ) -> Self {
9933 self.extensions.push(extension);
9934 self
9935 }
9936 pub(crate) fn from_ffi(value: ffi::WGPURenderBundleEncoderDescriptor) -> Self {
9937 Self {
9938 extensions: Vec::new(),
9939 label: if value.label.data.is_null() || value.label.length == 0 {
9940 None
9941 } else {
9942 Some(string_view_to_string(value.label))
9943 },
9944 color_formats: if value.colorFormats.is_null() {
9945 None
9946 } else {
9947 Some(
9948 unsafe {
9949 std::slice::from_raw_parts(
9950 value.colorFormats,
9951 value.colorFormatCount as usize,
9952 )
9953 }
9954 .iter()
9955 .map(|raw| TextureFormat::from(*raw))
9956 .collect(),
9957 )
9958 },
9959 depth_stencil_format: Some(value.depthStencilFormat.into()),
9960 sample_count: Some(value.sampleCount),
9961 depth_read_only: Some(value.depthReadOnly != 0),
9962 stencil_read_only: Some(value.stencilReadOnly != 0),
9963 }
9964 }
9965 }
9966 pub struct RenderPassColorAttachment {
9967 pub(crate) extensions: Vec<RenderPassColorAttachmentExtension>,
9968 pub view: Option<TextureView>,
9969 pub depth_slice: Option<u32>,
9970 pub resolve_target: Option<TextureView>,
9971 pub load_op: Option<LoadOp>,
9972 pub store_op: Option<StoreOp>,
9973 pub clear_value: Option<Color>,
9974 }
9975 impl Default for RenderPassColorAttachment {
9976 fn default() -> Self {
9977 Self {
9978 extensions: Vec::new(),
9979 view: None,
9980 depth_slice: Some(DEPTH_SLICE_UNDEFINED),
9981 resolve_target: None,
9982 load_op: None,
9983 store_op: None,
9984 clear_value: None,
9985 }
9986 }
9987 }
9988 impl RenderPassColorAttachment {
9989 pub fn new() -> Self {
9990 Self::default()
9991 }
9992 pub(crate) fn to_ffi(
9993 &self,
9994 ) -> (ffi::WGPURenderPassColorAttachment, ChainedStructStorage) {
9995 let mut storage = ChainedStructStorage::new();
9996 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
9997 for ext in self.extensions.iter().rev() {
9998 next = ext.push_chain(&mut storage, next);
9999 }
10000 let mut raw: ffi::WGPURenderPassColorAttachment = unsafe {
10001 std::mem::zeroed()
10002 };
10003 raw.nextInChain = next;
10004 raw.view = self
10005 .view
10006 .as_ref()
10007 .map(|v| v.as_raw())
10008 .unwrap_or(std::ptr::null_mut());
10009 if let Some(value) = self.depth_slice {
10010 raw.depthSlice = value;
10011 }
10012 raw.resolveTarget = self
10013 .resolve_target
10014 .as_ref()
10015 .map(|v| v.as_raw())
10016 .unwrap_or(std::ptr::null_mut());
10017 if let Some(value) = self.load_op {
10018 raw.loadOp = value.into();
10019 } else {
10020 raw.loadOp = 0 as ffi::WGPULoadOp;
10021 }
10022 if let Some(value) = self.store_op {
10023 raw.storeOp = value.into();
10024 } else {
10025 raw.storeOp = 0 as ffi::WGPUStoreOp;
10026 }
10027 if let Some(value) = &self.clear_value {
10028 let (raw_value, storage_value) = value.to_ffi();
10029 raw.clearValue = raw_value;
10030 storage.push_storage(storage_value);
10031 }
10032 (raw, storage)
10033 }
10034 pub fn with_extension(
10035 mut self,
10036 extension: RenderPassColorAttachmentExtension,
10037 ) -> Self {
10038 self.extensions.push(extension);
10039 self
10040 }
10041 pub(crate) fn from_ffi(value: ffi::WGPURenderPassColorAttachment) -> Self {
10042 Self {
10043 extensions: Vec::new(),
10044 view: if value.view.is_null() {
10045 None
10046 } else {
10047 Some(unsafe { TextureView::from_raw(value.view) })
10048 },
10049 depth_slice: Some(value.depthSlice),
10050 resolve_target: if value.resolveTarget.is_null() {
10051 None
10052 } else {
10053 Some(unsafe { TextureView::from_raw(value.resolveTarget) })
10054 },
10055 load_op: Some(value.loadOp.into()),
10056 store_op: Some(value.storeOp.into()),
10057 clear_value: Some(Color::from_ffi(value.clearValue)),
10058 }
10059 }
10060 }
10061 pub struct RenderPassDepthStencilAttachment {
10062 pub(crate) extensions: Vec<RenderPassDepthStencilAttachmentExtension>,
10063 pub view: Option<TextureView>,
10064 pub depth_load_op: Option<LoadOp>,
10065 pub depth_store_op: Option<StoreOp>,
10066 pub depth_clear_value: Option<f32>,
10067 pub depth_read_only: Option<bool>,
10068 pub stencil_load_op: Option<LoadOp>,
10069 pub stencil_store_op: Option<StoreOp>,
10070 pub stencil_clear_value: Option<u32>,
10071 pub stencil_read_only: Option<bool>,
10072 }
10073 impl Default for RenderPassDepthStencilAttachment {
10074 fn default() -> Self {
10075 Self {
10076 extensions: Vec::new(),
10077 view: None,
10078 depth_load_op: None,
10079 depth_store_op: None,
10080 depth_clear_value: Some(DEPTH_CLEAR_VALUE_UNDEFINED),
10081 depth_read_only: None,
10082 stencil_load_op: None,
10083 stencil_store_op: None,
10084 stencil_clear_value: Some(0),
10085 stencil_read_only: None,
10086 }
10087 }
10088 }
10089 impl RenderPassDepthStencilAttachment {
10090 pub fn new() -> Self {
10091 Self::default()
10092 }
10093 pub(crate) fn to_ffi(
10094 &self,
10095 ) -> (ffi::WGPURenderPassDepthStencilAttachment, ChainedStructStorage) {
10096 let mut storage = ChainedStructStorage::new();
10097 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10098 for ext in self.extensions.iter().rev() {
10099 next = ext.push_chain(&mut storage, next);
10100 }
10101 let mut raw: ffi::WGPURenderPassDepthStencilAttachment = unsafe {
10102 std::mem::zeroed()
10103 };
10104 raw.nextInChain = next;
10105 raw.view = self
10106 .view
10107 .as_ref()
10108 .map(|v| v.as_raw())
10109 .unwrap_or(std::ptr::null_mut());
10110 if let Some(value) = self.depth_load_op {
10111 raw.depthLoadOp = value.into();
10112 } else {
10113 raw.depthLoadOp = 0 as ffi::WGPULoadOp;
10114 }
10115 if let Some(value) = self.depth_store_op {
10116 raw.depthStoreOp = value.into();
10117 } else {
10118 raw.depthStoreOp = 0 as ffi::WGPUStoreOp;
10119 }
10120 if let Some(value) = self.depth_clear_value {
10121 raw.depthClearValue = value;
10122 }
10123 raw.depthReadOnly = if self.depth_read_only.unwrap_or(false) {
10124 1
10125 } else {
10126 0
10127 };
10128 if let Some(value) = self.stencil_load_op {
10129 raw.stencilLoadOp = value.into();
10130 } else {
10131 raw.stencilLoadOp = 0 as ffi::WGPULoadOp;
10132 }
10133 if let Some(value) = self.stencil_store_op {
10134 raw.stencilStoreOp = value.into();
10135 } else {
10136 raw.stencilStoreOp = 0 as ffi::WGPUStoreOp;
10137 }
10138 if let Some(value) = self.stencil_clear_value {
10139 raw.stencilClearValue = value;
10140 }
10141 raw.stencilReadOnly = if self.stencil_read_only.unwrap_or(false) {
10142 1
10143 } else {
10144 0
10145 };
10146 (raw, storage)
10147 }
10148 pub fn with_extension(
10149 mut self,
10150 extension: RenderPassDepthStencilAttachmentExtension,
10151 ) -> Self {
10152 self.extensions.push(extension);
10153 self
10154 }
10155 pub(crate) fn from_ffi(
10156 value: ffi::WGPURenderPassDepthStencilAttachment,
10157 ) -> Self {
10158 Self {
10159 extensions: Vec::new(),
10160 view: Some(unsafe { TextureView::from_raw(value.view) }),
10161 depth_load_op: Some(value.depthLoadOp.into()),
10162 depth_store_op: Some(value.depthStoreOp.into()),
10163 depth_clear_value: Some(value.depthClearValue),
10164 depth_read_only: Some(value.depthReadOnly != 0),
10165 stencil_load_op: Some(value.stencilLoadOp.into()),
10166 stencil_store_op: Some(value.stencilStoreOp.into()),
10167 stencil_clear_value: Some(value.stencilClearValue),
10168 stencil_read_only: Some(value.stencilReadOnly != 0),
10169 }
10170 }
10171 }
10172 pub struct RenderPassDescriptor {
10173 pub(crate) extensions: Vec<RenderPassDescriptorExtension>,
10174 pub label: Option<String>,
10175 pub color_attachments: Option<Vec<RenderPassColorAttachment>>,
10176 pub depth_stencil_attachment: Option<RenderPassDepthStencilAttachment>,
10177 pub occlusion_query_set: Option<QuerySet>,
10178 pub timestamp_writes: Option<PassTimestampWrites>,
10179 }
10180 impl Default for RenderPassDescriptor {
10181 fn default() -> Self {
10182 Self {
10183 extensions: Vec::new(),
10184 label: None,
10185 color_attachments: None,
10186 depth_stencil_attachment: None,
10187 occlusion_query_set: None,
10188 timestamp_writes: None,
10189 }
10190 }
10191 }
10192 impl RenderPassDescriptor {
10193 pub fn new() -> Self {
10194 Self::default()
10195 }
10196 pub(crate) fn to_ffi(
10197 &self,
10198 ) -> (ffi::WGPURenderPassDescriptor, ChainedStructStorage) {
10199 let mut storage = ChainedStructStorage::new();
10200 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10201 for ext in self.extensions.iter().rev() {
10202 next = ext.push_chain(&mut storage, next);
10203 }
10204 let mut raw: ffi::WGPURenderPassDescriptor = unsafe { std::mem::zeroed() };
10205 raw.nextInChain = next;
10206 if let Some(value) = &self.label {
10207 raw.label = ffi::WGPUStringView {
10208 data: value.as_ptr().cast(),
10209 length: value.len(),
10210 };
10211 } else {
10212 raw.label = ffi::WGPUStringView {
10213 data: std::ptr::null(),
10214 length: 0,
10215 };
10216 }
10217 raw.colorAttachmentCount = self
10218 .color_attachments
10219 .as_ref()
10220 .map(|v| v.len())
10221 .unwrap_or(0);
10222 if let Some(values) = &self.color_attachments {
10223 let len_value = values.len();
10224 let mut raw_vec: Vec<ffi::WGPURenderPassColorAttachment> = Vec::with_capacity(
10225 values.len(),
10226 );
10227 for item in values.iter() {
10228 let (raw_item, storage_item) = item.to_ffi();
10229 raw_vec.push(raw_item);
10230 storage.push_storage(storage_item);
10231 }
10232 let ptr = storage.push_vec(raw_vec);
10233 raw.colorAttachments = ptr;
10234 raw.colorAttachmentCount = len_value;
10235 } else {
10236 raw.colorAttachments = std::ptr::null();
10237 raw.colorAttachmentCount = 0;
10238 }
10239 if let Some(value) = &self.depth_stencil_attachment {
10240 let (raw_value, storage_value) = value.to_ffi();
10241 let ptr = storage.push_value(raw_value);
10242 raw.depthStencilAttachment = ptr;
10243 storage.push_storage(storage_value);
10244 } else {
10245 raw.depthStencilAttachment = std::ptr::null();
10246 }
10247 raw.occlusionQuerySet = self
10248 .occlusion_query_set
10249 .as_ref()
10250 .map(|v| v.as_raw())
10251 .unwrap_or(std::ptr::null_mut());
10252 if let Some(value) = &self.timestamp_writes {
10253 let (raw_value, storage_value) = value.to_ffi();
10254 let ptr = storage.push_value(raw_value);
10255 raw.timestampWrites = ptr;
10256 storage.push_storage(storage_value);
10257 } else {
10258 raw.timestampWrites = std::ptr::null();
10259 }
10260 (raw, storage)
10261 }
10262 pub fn with_extension(
10263 mut self,
10264 extension: RenderPassDescriptorExtension,
10265 ) -> Self {
10266 self.extensions.push(extension);
10267 self
10268 }
10269 pub(crate) fn from_ffi(value: ffi::WGPURenderPassDescriptor) -> Self {
10270 Self {
10271 extensions: Vec::new(),
10272 label: if value.label.data.is_null() || value.label.length == 0 {
10273 None
10274 } else {
10275 Some(string_view_to_string(value.label))
10276 },
10277 color_attachments: if value.colorAttachments.is_null() {
10278 None
10279 } else {
10280 Some(
10281 unsafe {
10282 std::slice::from_raw_parts(
10283 value.colorAttachments,
10284 value.colorAttachmentCount as usize,
10285 )
10286 }
10287 .iter()
10288 .map(|raw| RenderPassColorAttachment::from_ffi(*raw))
10289 .collect(),
10290 )
10291 },
10292 depth_stencil_attachment: if value.depthStencilAttachment.is_null() {
10293 None
10294 } else {
10295 Some(
10296 RenderPassDepthStencilAttachment::from_ffi(unsafe {
10297 *value.depthStencilAttachment
10298 }),
10299 )
10300 },
10301 occlusion_query_set: if value.occlusionQuerySet.is_null() {
10302 None
10303 } else {
10304 Some(unsafe { QuerySet::from_raw(value.occlusionQuerySet) })
10305 },
10306 timestamp_writes: if value.timestampWrites.is_null() {
10307 None
10308 } else {
10309 Some(
10310 PassTimestampWrites::from_ffi(unsafe { *value.timestampWrites }),
10311 )
10312 },
10313 }
10314 }
10315 }
10316 pub struct RenderPassDescriptorExpandResolveRect {
10317 pub x: Option<u32>,
10318 pub y: Option<u32>,
10319 pub width: Option<u32>,
10320 pub height: Option<u32>,
10321 }
10322 impl Default for RenderPassDescriptorExpandResolveRect {
10323 fn default() -> Self {
10324 Self {
10325 x: None,
10326 y: None,
10327 width: None,
10328 height: None,
10329 }
10330 }
10331 }
10332 impl RenderPassDescriptorExpandResolveRect {
10333 pub fn new() -> Self {
10334 Self::default()
10335 }
10336 pub(crate) fn to_ffi(
10337 &self,
10338 ) -> (ffi::WGPURenderPassDescriptorExpandResolveRect, ChainedStructStorage) {
10339 let mut storage = ChainedStructStorage::new();
10340 let mut raw: ffi::WGPURenderPassDescriptorExpandResolveRect = unsafe {
10341 std::mem::zeroed()
10342 };
10343 if let Some(value) = self.x {
10344 raw.x = value;
10345 }
10346 if let Some(value) = self.y {
10347 raw.y = value;
10348 }
10349 if let Some(value) = self.width {
10350 raw.width = value;
10351 }
10352 if let Some(value) = self.height {
10353 raw.height = value;
10354 }
10355 (raw, storage)
10356 }
10357 pub(crate) fn from_ffi(
10358 value: ffi::WGPURenderPassDescriptorExpandResolveRect,
10359 ) -> Self {
10360 Self {
10361 x: Some(value.x),
10362 y: Some(value.y),
10363 width: Some(value.width),
10364 height: Some(value.height),
10365 }
10366 }
10367 }
10368 pub struct RenderPassDescriptorResolveRect {
10369 pub color_offset_x: Option<u32>,
10370 pub color_offset_y: Option<u32>,
10371 pub resolve_offset_x: Option<u32>,
10372 pub resolve_offset_y: Option<u32>,
10373 pub width: Option<u32>,
10374 pub height: Option<u32>,
10375 }
10376 impl Default for RenderPassDescriptorResolveRect {
10377 fn default() -> Self {
10378 Self {
10379 color_offset_x: None,
10380 color_offset_y: None,
10381 resolve_offset_x: None,
10382 resolve_offset_y: None,
10383 width: None,
10384 height: None,
10385 }
10386 }
10387 }
10388 impl RenderPassDescriptorResolveRect {
10389 pub fn new() -> Self {
10390 Self::default()
10391 }
10392 pub(crate) fn to_ffi(
10393 &self,
10394 ) -> (ffi::WGPURenderPassDescriptorResolveRect, ChainedStructStorage) {
10395 let mut storage = ChainedStructStorage::new();
10396 let mut raw: ffi::WGPURenderPassDescriptorResolveRect = unsafe {
10397 std::mem::zeroed()
10398 };
10399 if let Some(value) = self.color_offset_x {
10400 raw.colorOffsetX = value;
10401 }
10402 if let Some(value) = self.color_offset_y {
10403 raw.colorOffsetY = value;
10404 }
10405 if let Some(value) = self.resolve_offset_x {
10406 raw.resolveOffsetX = value;
10407 }
10408 if let Some(value) = self.resolve_offset_y {
10409 raw.resolveOffsetY = value;
10410 }
10411 if let Some(value) = self.width {
10412 raw.width = value;
10413 }
10414 if let Some(value) = self.height {
10415 raw.height = value;
10416 }
10417 (raw, storage)
10418 }
10419 pub(crate) fn from_ffi(value: ffi::WGPURenderPassDescriptorResolveRect) -> Self {
10420 Self {
10421 color_offset_x: Some(value.colorOffsetX),
10422 color_offset_y: Some(value.colorOffsetY),
10423 resolve_offset_x: Some(value.resolveOffsetX),
10424 resolve_offset_y: Some(value.resolveOffsetY),
10425 width: Some(value.width),
10426 height: Some(value.height),
10427 }
10428 }
10429 }
10430 pub struct RenderPassMaxDrawCount {
10431 pub max_draw_count: Option<u64>,
10432 }
10433 impl Default for RenderPassMaxDrawCount {
10434 fn default() -> Self {
10435 Self {
10436 max_draw_count: Some(50000000),
10437 }
10438 }
10439 }
10440 impl RenderPassMaxDrawCount {
10441 pub fn new() -> Self {
10442 Self::default()
10443 }
10444 pub(crate) fn to_ffi(
10445 &self,
10446 ) -> (ffi::WGPURenderPassMaxDrawCount, ChainedStructStorage) {
10447 let mut storage = ChainedStructStorage::new();
10448 let mut raw: ffi::WGPURenderPassMaxDrawCount = unsafe { std::mem::zeroed() };
10449 if let Some(value) = self.max_draw_count {
10450 raw.maxDrawCount = value;
10451 }
10452 (raw, storage)
10453 }
10454 pub(crate) fn from_ffi(value: ffi::WGPURenderPassMaxDrawCount) -> Self {
10455 Self {
10456 max_draw_count: Some(value.maxDrawCount),
10457 }
10458 }
10459 }
10460 pub struct RenderPassPixelLocalStorage {
10461 pub total_pixel_local_storage_size: Option<u64>,
10462 pub storage_attachments: Option<Vec<RenderPassStorageAttachment>>,
10463 }
10464 impl Default for RenderPassPixelLocalStorage {
10465 fn default() -> Self {
10466 Self {
10467 total_pixel_local_storage_size: None,
10468 storage_attachments: None,
10469 }
10470 }
10471 }
10472 impl RenderPassPixelLocalStorage {
10473 pub fn new() -> Self {
10474 Self::default()
10475 }
10476 pub(crate) fn to_ffi(
10477 &self,
10478 ) -> (ffi::WGPURenderPassPixelLocalStorage, ChainedStructStorage) {
10479 let mut storage = ChainedStructStorage::new();
10480 let mut raw: ffi::WGPURenderPassPixelLocalStorage = unsafe {
10481 std::mem::zeroed()
10482 };
10483 if let Some(value) = self.total_pixel_local_storage_size {
10484 raw.totalPixelLocalStorageSize = value;
10485 }
10486 raw.storageAttachmentCount = self
10487 .storage_attachments
10488 .as_ref()
10489 .map(|v| v.len())
10490 .unwrap_or(0);
10491 if let Some(values) = &self.storage_attachments {
10492 let len_value = values.len();
10493 let mut raw_vec: Vec<ffi::WGPURenderPassStorageAttachment> = Vec::with_capacity(
10494 values.len(),
10495 );
10496 for item in values.iter() {
10497 let (raw_item, storage_item) = item.to_ffi();
10498 raw_vec.push(raw_item);
10499 storage.push_storage(storage_item);
10500 }
10501 let ptr = storage.push_vec(raw_vec);
10502 raw.storageAttachments = ptr;
10503 raw.storageAttachmentCount = len_value;
10504 } else {
10505 raw.storageAttachments = std::ptr::null();
10506 raw.storageAttachmentCount = 0;
10507 }
10508 (raw, storage)
10509 }
10510 pub(crate) fn from_ffi(value: ffi::WGPURenderPassPixelLocalStorage) -> Self {
10511 Self {
10512 total_pixel_local_storage_size: Some(value.totalPixelLocalStorageSize),
10513 storage_attachments: if value.storageAttachments.is_null() {
10514 None
10515 } else {
10516 Some(
10517 unsafe {
10518 std::slice::from_raw_parts(
10519 value.storageAttachments,
10520 value.storageAttachmentCount as usize,
10521 )
10522 }
10523 .iter()
10524 .map(|raw| RenderPassStorageAttachment::from_ffi(*raw))
10525 .collect(),
10526 )
10527 },
10528 }
10529 }
10530 }
10531 pub struct RenderPassStorageAttachment {
10532 pub(crate) extensions: Vec<RenderPassStorageAttachmentExtension>,
10533 pub offset: Option<u64>,
10534 pub storage: Option<TextureView>,
10535 pub load_op: Option<LoadOp>,
10536 pub store_op: Option<StoreOp>,
10537 pub clear_value: Option<Color>,
10538 }
10539 impl Default for RenderPassStorageAttachment {
10540 fn default() -> Self {
10541 Self {
10542 extensions: Vec::new(),
10543 offset: Some(0),
10544 storage: None,
10545 load_op: None,
10546 store_op: None,
10547 clear_value: None,
10548 }
10549 }
10550 }
10551 impl RenderPassStorageAttachment {
10552 pub fn new() -> Self {
10553 Self::default()
10554 }
10555 pub(crate) fn to_ffi(
10556 &self,
10557 ) -> (ffi::WGPURenderPassStorageAttachment, ChainedStructStorage) {
10558 let mut storage = ChainedStructStorage::new();
10559 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10560 for ext in self.extensions.iter().rev() {
10561 next = ext.push_chain(&mut storage, next);
10562 }
10563 let mut raw: ffi::WGPURenderPassStorageAttachment = unsafe {
10564 std::mem::zeroed()
10565 };
10566 raw.nextInChain = next;
10567 if let Some(value) = self.offset {
10568 raw.offset = value;
10569 }
10570 raw.storage = self
10571 .storage
10572 .as_ref()
10573 .map(|v| v.as_raw())
10574 .unwrap_or(std::ptr::null_mut());
10575 if let Some(value) = self.load_op {
10576 raw.loadOp = value.into();
10577 } else {
10578 raw.loadOp = 0 as ffi::WGPULoadOp;
10579 }
10580 if let Some(value) = self.store_op {
10581 raw.storeOp = value.into();
10582 } else {
10583 raw.storeOp = 0 as ffi::WGPUStoreOp;
10584 }
10585 if let Some(value) = &self.clear_value {
10586 let (raw_value, storage_value) = value.to_ffi();
10587 raw.clearValue = raw_value;
10588 storage.push_storage(storage_value);
10589 }
10590 (raw, storage)
10591 }
10592 pub fn with_extension(
10593 mut self,
10594 extension: RenderPassStorageAttachmentExtension,
10595 ) -> Self {
10596 self.extensions.push(extension);
10597 self
10598 }
10599 pub(crate) fn from_ffi(value: ffi::WGPURenderPassStorageAttachment) -> Self {
10600 Self {
10601 extensions: Vec::new(),
10602 offset: Some(value.offset),
10603 storage: Some(unsafe { TextureView::from_raw(value.storage) }),
10604 load_op: Some(value.loadOp.into()),
10605 store_op: Some(value.storeOp.into()),
10606 clear_value: Some(Color::from_ffi(value.clearValue)),
10607 }
10608 }
10609 }
10610 pub struct RenderPipelineDescriptor {
10611 pub(crate) extensions: Vec<RenderPipelineDescriptorExtension>,
10612 pub label: Option<String>,
10613 pub layout: Option<PipelineLayout>,
10614 pub vertex: Option<VertexState>,
10615 pub primitive: Option<PrimitiveState>,
10616 pub depth_stencil: Option<DepthStencilState>,
10617 pub multisample: Option<MultisampleState>,
10618 pub fragment: Option<FragmentState>,
10619 }
10620 impl Default for RenderPipelineDescriptor {
10621 fn default() -> Self {
10622 Self {
10623 extensions: Vec::new(),
10624 label: None,
10625 layout: None,
10626 vertex: None,
10627 primitive: None,
10628 depth_stencil: None,
10629 multisample: None,
10630 fragment: None,
10631 }
10632 }
10633 }
10634 impl RenderPipelineDescriptor {
10635 pub fn new() -> Self {
10636 Self::default()
10637 }
10638 pub(crate) fn to_ffi(
10639 &self,
10640 ) -> (ffi::WGPURenderPipelineDescriptor, ChainedStructStorage) {
10641 let mut storage = ChainedStructStorage::new();
10642 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10643 for ext in self.extensions.iter().rev() {
10644 next = ext.push_chain(&mut storage, next);
10645 }
10646 let mut raw: ffi::WGPURenderPipelineDescriptor = unsafe {
10647 std::mem::zeroed()
10648 };
10649 raw.nextInChain = next;
10650 if let Some(value) = &self.label {
10651 raw.label = ffi::WGPUStringView {
10652 data: value.as_ptr().cast(),
10653 length: value.len(),
10654 };
10655 } else {
10656 raw.label = ffi::WGPUStringView {
10657 data: std::ptr::null(),
10658 length: 0,
10659 };
10660 }
10661 raw.layout = self
10662 .layout
10663 .as_ref()
10664 .map(|v| v.as_raw())
10665 .unwrap_or(std::ptr::null_mut());
10666 if let Some(value) = &self.vertex {
10667 let (raw_value, storage_value) = value.to_ffi();
10668 raw.vertex = raw_value;
10669 storage.push_storage(storage_value);
10670 }
10671 if let Some(value) = &self.primitive {
10672 let (raw_value, storage_value) = value.to_ffi();
10673 raw.primitive = raw_value;
10674 storage.push_storage(storage_value);
10675 }
10676 if let Some(value) = &self.depth_stencil {
10677 let (raw_value, storage_value) = value.to_ffi();
10678 let ptr = storage.push_value(raw_value);
10679 raw.depthStencil = ptr;
10680 storage.push_storage(storage_value);
10681 } else {
10682 raw.depthStencil = std::ptr::null();
10683 }
10684 if let Some(value) = &self.multisample {
10685 let (raw_value, storage_value) = value.to_ffi();
10686 raw.multisample = raw_value;
10687 storage.push_storage(storage_value);
10688 }
10689 if let Some(value) = &self.fragment {
10690 let (raw_value, storage_value) = value.to_ffi();
10691 let ptr = storage.push_value(raw_value);
10692 raw.fragment = ptr;
10693 storage.push_storage(storage_value);
10694 } else {
10695 raw.fragment = std::ptr::null();
10696 }
10697 (raw, storage)
10698 }
10699 pub fn with_extension(
10700 mut self,
10701 extension: RenderPipelineDescriptorExtension,
10702 ) -> Self {
10703 self.extensions.push(extension);
10704 self
10705 }
10706 pub(crate) fn from_ffi(value: ffi::WGPURenderPipelineDescriptor) -> Self {
10707 Self {
10708 extensions: Vec::new(),
10709 label: if value.label.data.is_null() || value.label.length == 0 {
10710 None
10711 } else {
10712 Some(string_view_to_string(value.label))
10713 },
10714 layout: if value.layout.is_null() {
10715 None
10716 } else {
10717 Some(unsafe { PipelineLayout::from_raw(value.layout) })
10718 },
10719 vertex: Some(VertexState::from_ffi(value.vertex)),
10720 primitive: Some(PrimitiveState::from_ffi(value.primitive)),
10721 depth_stencil: if value.depthStencil.is_null() {
10722 None
10723 } else {
10724 Some(DepthStencilState::from_ffi(unsafe { *value.depthStencil }))
10725 },
10726 multisample: Some(MultisampleState::from_ffi(value.multisample)),
10727 fragment: if value.fragment.is_null() {
10728 None
10729 } else {
10730 Some(FragmentState::from_ffi(unsafe { *value.fragment }))
10731 },
10732 }
10733 }
10734 }
10735 pub struct RequestAdapterWebGPUBackendOptions {}
10736 impl Default for RequestAdapterWebGPUBackendOptions {
10737 fn default() -> Self {
10738 Self {}
10739 }
10740 }
10741 impl RequestAdapterWebGPUBackendOptions {
10742 pub fn new() -> Self {
10743 Self::default()
10744 }
10745 pub(crate) fn to_ffi(
10746 &self,
10747 ) -> (ffi::WGPURequestAdapterWebGPUBackendOptions, ChainedStructStorage) {
10748 let mut storage = ChainedStructStorage::new();
10749 let mut raw: ffi::WGPURequestAdapterWebGPUBackendOptions = unsafe {
10750 std::mem::zeroed()
10751 };
10752 (raw, storage)
10753 }
10754 pub(crate) fn from_ffi(
10755 value: ffi::WGPURequestAdapterWebGPUBackendOptions,
10756 ) -> Self {
10757 let _ = value;
10758 Self::default()
10759 }
10760 }
10761 pub struct RequestAdapterWebXROptions {
10762 pub xr_compatible: Option<bool>,
10763 }
10764 impl Default for RequestAdapterWebXROptions {
10765 fn default() -> Self {
10766 Self { xr_compatible: None }
10767 }
10768 }
10769 impl RequestAdapterWebXROptions {
10770 pub fn new() -> Self {
10771 Self::default()
10772 }
10773 pub(crate) fn to_ffi(
10774 &self,
10775 ) -> (ffi::WGPURequestAdapterWebXROptions, ChainedStructStorage) {
10776 let mut storage = ChainedStructStorage::new();
10777 let mut raw: ffi::WGPURequestAdapterWebXROptions = unsafe {
10778 std::mem::zeroed()
10779 };
10780 raw.xrCompatible = if self.xr_compatible.unwrap_or(false) { 1 } else { 0 };
10781 (raw, storage)
10782 }
10783 pub(crate) fn from_ffi(value: ffi::WGPURequestAdapterWebXROptions) -> Self {
10784 Self {
10785 xr_compatible: Some(value.xrCompatible != 0),
10786 }
10787 }
10788 }
10789 pub struct RequestAdapterOptions {
10790 pub(crate) extensions: Vec<RequestAdapterOptionsExtension>,
10791 pub feature_level: Option<FeatureLevel>,
10792 pub power_preference: Option<PowerPreference>,
10793 pub force_fallback_adapter: Option<bool>,
10794 pub backend_type: Option<BackendType>,
10795 pub compatible_surface: Option<Surface>,
10796 }
10797 impl Default for RequestAdapterOptions {
10798 fn default() -> Self {
10799 Self {
10800 extensions: Vec::new(),
10801 feature_level: Some(FeatureLevel::Core),
10802 power_preference: None,
10803 force_fallback_adapter: None,
10804 backend_type: None,
10805 compatible_surface: None,
10806 }
10807 }
10808 }
10809 impl RequestAdapterOptions {
10810 pub fn new() -> Self {
10811 Self::default()
10812 }
10813 pub(crate) fn to_ffi(
10814 &self,
10815 ) -> (ffi::WGPURequestAdapterOptions, ChainedStructStorage) {
10816 let mut storage = ChainedStructStorage::new();
10817 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10818 for ext in self.extensions.iter().rev() {
10819 next = ext.push_chain(&mut storage, next);
10820 }
10821 let mut raw: ffi::WGPURequestAdapterOptions = unsafe { std::mem::zeroed() };
10822 raw.nextInChain = next;
10823 if let Some(value) = self.feature_level {
10824 raw.featureLevel = value.into();
10825 } else {
10826 raw.featureLevel = 0 as ffi::WGPUFeatureLevel;
10827 }
10828 if let Some(value) = self.power_preference {
10829 raw.powerPreference = value.into();
10830 } else {
10831 raw.powerPreference = 0 as ffi::WGPUPowerPreference;
10832 }
10833 raw.forceFallbackAdapter = if self.force_fallback_adapter.unwrap_or(false) {
10834 1
10835 } else {
10836 0
10837 };
10838 if let Some(value) = self.backend_type {
10839 raw.backendType = value.into();
10840 } else {
10841 raw.backendType = 0 as ffi::WGPUBackendType;
10842 }
10843 raw.compatibleSurface = self
10844 .compatible_surface
10845 .as_ref()
10846 .map(|v| v.as_raw())
10847 .unwrap_or(std::ptr::null_mut());
10848 (raw, storage)
10849 }
10850 pub fn with_extension(
10851 mut self,
10852 extension: RequestAdapterOptionsExtension,
10853 ) -> Self {
10854 self.extensions.push(extension);
10855 self
10856 }
10857 pub(crate) fn from_ffi(value: ffi::WGPURequestAdapterOptions) -> Self {
10858 Self {
10859 extensions: Vec::new(),
10860 feature_level: Some(value.featureLevel.into()),
10861 power_preference: Some(value.powerPreference.into()),
10862 force_fallback_adapter: Some(value.forceFallbackAdapter != 0),
10863 backend_type: Some(value.backendType.into()),
10864 compatible_surface: if value.compatibleSurface.is_null() {
10865 None
10866 } else {
10867 Some(unsafe { Surface::from_raw(value.compatibleSurface) })
10868 },
10869 }
10870 }
10871 }
10872 pub struct ResourceTableDescriptor {
10873 pub(crate) extensions: Vec<ResourceTableDescriptorExtension>,
10874 pub label: Option<String>,
10875 pub size: Option<u32>,
10876 }
10877 impl Default for ResourceTableDescriptor {
10878 fn default() -> Self {
10879 Self {
10880 extensions: Vec::new(),
10881 label: None,
10882 size: None,
10883 }
10884 }
10885 }
10886 impl ResourceTableDescriptor {
10887 pub fn new() -> Self {
10888 Self::default()
10889 }
10890 pub(crate) fn to_ffi(
10891 &self,
10892 ) -> (ffi::WGPUResourceTableDescriptor, ChainedStructStorage) {
10893 let mut storage = ChainedStructStorage::new();
10894 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10895 for ext in self.extensions.iter().rev() {
10896 next = ext.push_chain(&mut storage, next);
10897 }
10898 let mut raw: ffi::WGPUResourceTableDescriptor = unsafe {
10899 std::mem::zeroed()
10900 };
10901 raw.nextInChain = next;
10902 if let Some(value) = &self.label {
10903 raw.label = ffi::WGPUStringView {
10904 data: value.as_ptr().cast(),
10905 length: value.len(),
10906 };
10907 } else {
10908 raw.label = ffi::WGPUStringView {
10909 data: std::ptr::null(),
10910 length: 0,
10911 };
10912 }
10913 if let Some(value) = self.size {
10914 raw.size = value;
10915 }
10916 (raw, storage)
10917 }
10918 pub fn with_extension(
10919 mut self,
10920 extension: ResourceTableDescriptorExtension,
10921 ) -> Self {
10922 self.extensions.push(extension);
10923 self
10924 }
10925 pub(crate) fn from_ffi(value: ffi::WGPUResourceTableDescriptor) -> Self {
10926 Self {
10927 extensions: Vec::new(),
10928 label: if value.label.data.is_null() || value.label.length == 0 {
10929 None
10930 } else {
10931 Some(string_view_to_string(value.label))
10932 },
10933 size: Some(value.size),
10934 }
10935 }
10936 }
10937 pub struct SamplerBindingLayout {
10938 pub(crate) extensions: Vec<SamplerBindingLayoutExtension>,
10939 pub r#type: Option<SamplerBindingType>,
10940 }
10941 impl Default for SamplerBindingLayout {
10942 fn default() -> Self {
10943 Self {
10944 extensions: Vec::new(),
10945 r#type: Some(SamplerBindingType::Filtering),
10946 }
10947 }
10948 }
10949 impl SamplerBindingLayout {
10950 pub fn new() -> Self {
10951 Self::default()
10952 }
10953 pub(crate) fn to_ffi(
10954 &self,
10955 ) -> (ffi::WGPUSamplerBindingLayout, ChainedStructStorage) {
10956 let mut storage = ChainedStructStorage::new();
10957 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
10958 for ext in self.extensions.iter().rev() {
10959 next = ext.push_chain(&mut storage, next);
10960 }
10961 let mut raw: ffi::WGPUSamplerBindingLayout = unsafe { std::mem::zeroed() };
10962 raw.nextInChain = next;
10963 if let Some(value) = self.r#type {
10964 raw.type_ = value.into();
10965 } else {
10966 raw.type_ = 0 as ffi::WGPUSamplerBindingType;
10967 }
10968 (raw, storage)
10969 }
10970 pub fn with_extension(
10971 mut self,
10972 extension: SamplerBindingLayoutExtension,
10973 ) -> Self {
10974 self.extensions.push(extension);
10975 self
10976 }
10977 pub(crate) fn from_ffi(value: ffi::WGPUSamplerBindingLayout) -> Self {
10978 Self {
10979 extensions: Vec::new(),
10980 r#type: Some(value.type_.into()),
10981 }
10982 }
10983 }
10984 pub struct SamplerDescriptor {
10985 pub(crate) extensions: Vec<SamplerDescriptorExtension>,
10986 pub label: Option<String>,
10987 pub address_mode_u: Option<AddressMode>,
10988 pub address_mode_v: Option<AddressMode>,
10989 pub address_mode_w: Option<AddressMode>,
10990 pub mag_filter: Option<FilterMode>,
10991 pub min_filter: Option<FilterMode>,
10992 pub mipmap_filter: Option<MipmapFilterMode>,
10993 pub lod_min_clamp: Option<f32>,
10994 pub lod_max_clamp: Option<f32>,
10995 pub compare: Option<CompareFunction>,
10996 pub max_anisotropy: Option<u16>,
10997 }
10998 impl Default for SamplerDescriptor {
10999 fn default() -> Self {
11000 Self {
11001 extensions: Vec::new(),
11002 label: None,
11003 address_mode_u: Some(AddressMode::ClampToEdge),
11004 address_mode_v: Some(AddressMode::ClampToEdge),
11005 address_mode_w: Some(AddressMode::ClampToEdge),
11006 mag_filter: Some(FilterMode::Nearest),
11007 min_filter: Some(FilterMode::Nearest),
11008 mipmap_filter: Some(MipmapFilterMode::Nearest),
11009 lod_min_clamp: None,
11010 lod_max_clamp: None,
11011 compare: None,
11012 max_anisotropy: Some(1),
11013 }
11014 }
11015 }
11016 impl SamplerDescriptor {
11017 pub fn new() -> Self {
11018 Self::default()
11019 }
11020 pub(crate) fn to_ffi(
11021 &self,
11022 ) -> (ffi::WGPUSamplerDescriptor, ChainedStructStorage) {
11023 let mut storage = ChainedStructStorage::new();
11024 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11025 for ext in self.extensions.iter().rev() {
11026 next = ext.push_chain(&mut storage, next);
11027 }
11028 let mut raw: ffi::WGPUSamplerDescriptor = unsafe { std::mem::zeroed() };
11029 raw.nextInChain = next;
11030 if let Some(value) = &self.label {
11031 raw.label = ffi::WGPUStringView {
11032 data: value.as_ptr().cast(),
11033 length: value.len(),
11034 };
11035 } else {
11036 raw.label = ffi::WGPUStringView {
11037 data: std::ptr::null(),
11038 length: 0,
11039 };
11040 }
11041 if let Some(value) = self.address_mode_u {
11042 raw.addressModeU = value.into();
11043 } else {
11044 raw.addressModeU = 0 as ffi::WGPUAddressMode;
11045 }
11046 if let Some(value) = self.address_mode_v {
11047 raw.addressModeV = value.into();
11048 } else {
11049 raw.addressModeV = 0 as ffi::WGPUAddressMode;
11050 }
11051 if let Some(value) = self.address_mode_w {
11052 raw.addressModeW = value.into();
11053 } else {
11054 raw.addressModeW = 0 as ffi::WGPUAddressMode;
11055 }
11056 if let Some(value) = self.mag_filter {
11057 raw.magFilter = value.into();
11058 } else {
11059 raw.magFilter = 0 as ffi::WGPUFilterMode;
11060 }
11061 if let Some(value) = self.min_filter {
11062 raw.minFilter = value.into();
11063 } else {
11064 raw.minFilter = 0 as ffi::WGPUFilterMode;
11065 }
11066 if let Some(value) = self.mipmap_filter {
11067 raw.mipmapFilter = value.into();
11068 } else {
11069 raw.mipmapFilter = 0 as ffi::WGPUMipmapFilterMode;
11070 }
11071 if let Some(value) = self.lod_min_clamp {
11072 raw.lodMinClamp = value;
11073 }
11074 if let Some(value) = self.lod_max_clamp {
11075 raw.lodMaxClamp = value;
11076 }
11077 if let Some(value) = self.compare {
11078 raw.compare = value.into();
11079 } else {
11080 raw.compare = 0 as ffi::WGPUCompareFunction;
11081 }
11082 if let Some(value) = self.max_anisotropy {
11083 raw.maxAnisotropy = value;
11084 }
11085 (raw, storage)
11086 }
11087 pub fn with_extension(mut self, extension: SamplerDescriptorExtension) -> Self {
11088 self.extensions.push(extension);
11089 self
11090 }
11091 pub(crate) fn from_ffi(value: ffi::WGPUSamplerDescriptor) -> Self {
11092 Self {
11093 extensions: Vec::new(),
11094 label: if value.label.data.is_null() || value.label.length == 0 {
11095 None
11096 } else {
11097 Some(string_view_to_string(value.label))
11098 },
11099 address_mode_u: Some(value.addressModeU.into()),
11100 address_mode_v: Some(value.addressModeV.into()),
11101 address_mode_w: Some(value.addressModeW.into()),
11102 mag_filter: Some(value.magFilter.into()),
11103 min_filter: Some(value.minFilter.into()),
11104 mipmap_filter: Some(value.mipmapFilter.into()),
11105 lod_min_clamp: Some(value.lodMinClamp),
11106 lod_max_clamp: Some(value.lodMaxClamp),
11107 compare: Some(value.compare.into()),
11108 max_anisotropy: Some(value.maxAnisotropy),
11109 }
11110 }
11111 }
11112 pub struct ShaderModuleCompilationOptions {
11113 pub strict_math: Option<bool>,
11114 }
11115 impl Default for ShaderModuleCompilationOptions {
11116 fn default() -> Self {
11117 Self { strict_math: None }
11118 }
11119 }
11120 impl ShaderModuleCompilationOptions {
11121 pub fn new() -> Self {
11122 Self::default()
11123 }
11124 pub(crate) fn to_ffi(
11125 &self,
11126 ) -> (ffi::WGPUShaderModuleCompilationOptions, ChainedStructStorage) {
11127 let mut storage = ChainedStructStorage::new();
11128 let mut raw: ffi::WGPUShaderModuleCompilationOptions = unsafe {
11129 std::mem::zeroed()
11130 };
11131 raw.strictMath = if self.strict_math.unwrap_or(false) { 1 } else { 0 };
11132 (raw, storage)
11133 }
11134 pub(crate) fn from_ffi(value: ffi::WGPUShaderModuleCompilationOptions) -> Self {
11135 Self {
11136 strict_math: Some(value.strictMath != 0),
11137 }
11138 }
11139 }
11140 pub struct ShaderModuleDescriptor {
11141 pub(crate) extensions: Vec<ShaderModuleDescriptorExtension>,
11142 pub label: Option<String>,
11143 }
11144 impl Default for ShaderModuleDescriptor {
11145 fn default() -> Self {
11146 Self {
11147 extensions: Vec::new(),
11148 label: None,
11149 }
11150 }
11151 }
11152 impl ShaderModuleDescriptor {
11153 pub fn new() -> Self {
11154 Self::default()
11155 }
11156 pub(crate) fn to_ffi(
11157 &self,
11158 ) -> (ffi::WGPUShaderModuleDescriptor, ChainedStructStorage) {
11159 let mut storage = ChainedStructStorage::new();
11160 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11161 for ext in self.extensions.iter().rev() {
11162 next = ext.push_chain(&mut storage, next);
11163 }
11164 let mut raw: ffi::WGPUShaderModuleDescriptor = unsafe { std::mem::zeroed() };
11165 raw.nextInChain = next;
11166 if let Some(value) = &self.label {
11167 raw.label = ffi::WGPUStringView {
11168 data: value.as_ptr().cast(),
11169 length: value.len(),
11170 };
11171 } else {
11172 raw.label = ffi::WGPUStringView {
11173 data: std::ptr::null(),
11174 length: 0,
11175 };
11176 }
11177 (raw, storage)
11178 }
11179 pub fn with_extension(
11180 mut self,
11181 extension: ShaderModuleDescriptorExtension,
11182 ) -> Self {
11183 self.extensions.push(extension);
11184 self
11185 }
11186 pub(crate) fn from_ffi(value: ffi::WGPUShaderModuleDescriptor) -> Self {
11187 Self {
11188 extensions: Vec::new(),
11189 label: if value.label.data.is_null() || value.label.length == 0 {
11190 None
11191 } else {
11192 Some(string_view_to_string(value.label))
11193 },
11194 }
11195 }
11196 }
11197 pub struct ShaderSourceSPIRV {
11198 pub code: Option<Vec<u32>>,
11199 }
11200 impl Default for ShaderSourceSPIRV {
11201 fn default() -> Self {
11202 Self { code: None }
11203 }
11204 }
11205 impl ShaderSourceSPIRV {
11206 pub fn new() -> Self {
11207 Self::default()
11208 }
11209 pub(crate) fn to_ffi(
11210 &self,
11211 ) -> (ffi::WGPUShaderSourceSPIRV, ChainedStructStorage) {
11212 let mut storage = ChainedStructStorage::new();
11213 let mut raw: ffi::WGPUShaderSourceSPIRV = unsafe { std::mem::zeroed() };
11214 raw.codeSize = (self.code.as_ref().map(|v| v.len()).unwrap_or(0)) as u32;
11215 if let Some(values) = &self.code {
11216 let len_value = values.len();
11217 let raw_vec = values.to_vec();
11218 let ptr = storage.push_vec(raw_vec);
11219 raw.code = ptr;
11220 raw.codeSize = len_value as u32;
11221 } else {
11222 raw.code = std::ptr::null();
11223 raw.codeSize = 0;
11224 }
11225 (raw, storage)
11226 }
11227 pub(crate) fn from_ffi(value: ffi::WGPUShaderSourceSPIRV) -> Self {
11228 Self {
11229 code: if value.code.is_null() {
11230 None
11231 } else {
11232 Some(
11233 unsafe {
11234 std::slice::from_raw_parts(
11235 value.code,
11236 value.codeSize as usize,
11237 )
11238 }
11239 .to_vec(),
11240 )
11241 },
11242 }
11243 }
11244 }
11245 pub struct ShaderSourceWGSL {
11246 pub code: Option<String>,
11247 }
11248 impl Default for ShaderSourceWGSL {
11249 fn default() -> Self {
11250 Self { code: None }
11251 }
11252 }
11253 impl ShaderSourceWGSL {
11254 pub fn new() -> Self {
11255 Self::default()
11256 }
11257 pub(crate) fn to_ffi(
11258 &self,
11259 ) -> (ffi::WGPUShaderSourceWGSL, ChainedStructStorage) {
11260 let mut storage = ChainedStructStorage::new();
11261 let mut raw: ffi::WGPUShaderSourceWGSL = unsafe { std::mem::zeroed() };
11262 if let Some(value) = &self.code {
11263 raw.code = ffi::WGPUStringView {
11264 data: value.as_ptr().cast(),
11265 length: value.len(),
11266 };
11267 } else {
11268 raw.code = ffi::WGPUStringView {
11269 data: std::ptr::null(),
11270 length: 0,
11271 };
11272 }
11273 (raw, storage)
11274 }
11275 pub(crate) fn from_ffi(value: ffi::WGPUShaderSourceWGSL) -> Self {
11276 Self {
11277 code: Some(string_view_to_string(value.code)),
11278 }
11279 }
11280 }
11281 pub struct SharedBufferMemoryBeginAccessDescriptor {
11282 pub(crate) extensions: Vec<SharedBufferMemoryBeginAccessDescriptorExtension>,
11283 pub initialized: Option<bool>,
11284 pub fences: Option<Vec<SharedFence>>,
11285 pub signaled_values: Option<Vec<u64>>,
11286 }
11287 impl Default for SharedBufferMemoryBeginAccessDescriptor {
11288 fn default() -> Self {
11289 Self {
11290 extensions: Vec::new(),
11291 initialized: None,
11292 fences: None,
11293 signaled_values: None,
11294 }
11295 }
11296 }
11297 impl SharedBufferMemoryBeginAccessDescriptor {
11298 pub fn new() -> Self {
11299 Self::default()
11300 }
11301 pub(crate) fn to_ffi(
11302 &self,
11303 ) -> (ffi::WGPUSharedBufferMemoryBeginAccessDescriptor, ChainedStructStorage) {
11304 let mut storage = ChainedStructStorage::new();
11305 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11306 for ext in self.extensions.iter().rev() {
11307 next = ext.push_chain(&mut storage, next);
11308 }
11309 let mut raw: ffi::WGPUSharedBufferMemoryBeginAccessDescriptor = unsafe {
11310 std::mem::zeroed()
11311 };
11312 raw.nextInChain = next;
11313 raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
11314 raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
11315 if let Some(values) = &self.fences {
11316 let len_value = values.len();
11317 let raw_vec: Vec<ffi::WGPUSharedFence> = values
11318 .iter()
11319 .map(|v| v.as_raw())
11320 .collect();
11321 let ptr = storage.push_vec(raw_vec);
11322 raw.fences = ptr;
11323 raw.fenceCount = len_value;
11324 } else {
11325 raw.fences = std::ptr::null();
11326 raw.fenceCount = 0;
11327 }
11328 if let Some(values) = &self.signaled_values {
11329 let len_value = values.len();
11330 let raw_vec = values.to_vec();
11331 let ptr = storage.push_vec(raw_vec);
11332 raw.signaledValues = ptr;
11333 raw.fenceCount = len_value;
11334 } else {
11335 raw.signaledValues = std::ptr::null();
11336 raw.fenceCount = 0;
11337 }
11338 (raw, storage)
11339 }
11340 pub fn with_extension(
11341 mut self,
11342 extension: SharedBufferMemoryBeginAccessDescriptorExtension,
11343 ) -> Self {
11344 self.extensions.push(extension);
11345 self
11346 }
11347 pub(crate) fn from_ffi(
11348 value: ffi::WGPUSharedBufferMemoryBeginAccessDescriptor,
11349 ) -> Self {
11350 Self {
11351 extensions: Vec::new(),
11352 initialized: Some(value.initialized != 0),
11353 fences: if value.fences.is_null() {
11354 None
11355 } else {
11356 Some(
11357 unsafe {
11358 std::slice::from_raw_parts(
11359 value.fences,
11360 value.fenceCount as usize,
11361 )
11362 }
11363 .iter()
11364 .map(|raw| unsafe { SharedFence::from_raw(*raw) })
11365 .collect(),
11366 )
11367 },
11368 signaled_values: if value.signaledValues.is_null() {
11369 None
11370 } else {
11371 Some(
11372 unsafe {
11373 std::slice::from_raw_parts(
11374 value.signaledValues,
11375 value.fenceCount as usize,
11376 )
11377 }
11378 .to_vec(),
11379 )
11380 },
11381 }
11382 }
11383 }
11384 pub struct SharedBufferMemoryDescriptor {
11385 pub(crate) extensions: Vec<SharedBufferMemoryDescriptorExtension>,
11386 pub label: Option<String>,
11387 }
11388 impl Default for SharedBufferMemoryDescriptor {
11389 fn default() -> Self {
11390 Self {
11391 extensions: Vec::new(),
11392 label: None,
11393 }
11394 }
11395 }
11396 impl SharedBufferMemoryDescriptor {
11397 pub fn new() -> Self {
11398 Self::default()
11399 }
11400 pub(crate) fn to_ffi(
11401 &self,
11402 ) -> (ffi::WGPUSharedBufferMemoryDescriptor, ChainedStructStorage) {
11403 let mut storage = ChainedStructStorage::new();
11404 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11405 for ext in self.extensions.iter().rev() {
11406 next = ext.push_chain(&mut storage, next);
11407 }
11408 let mut raw: ffi::WGPUSharedBufferMemoryDescriptor = unsafe {
11409 std::mem::zeroed()
11410 };
11411 raw.nextInChain = next;
11412 if let Some(value) = &self.label {
11413 raw.label = ffi::WGPUStringView {
11414 data: value.as_ptr().cast(),
11415 length: value.len(),
11416 };
11417 } else {
11418 raw.label = ffi::WGPUStringView {
11419 data: std::ptr::null(),
11420 length: 0,
11421 };
11422 }
11423 (raw, storage)
11424 }
11425 pub fn with_extension(
11426 mut self,
11427 extension: SharedBufferMemoryDescriptorExtension,
11428 ) -> Self {
11429 self.extensions.push(extension);
11430 self
11431 }
11432 pub(crate) fn from_ffi(value: ffi::WGPUSharedBufferMemoryDescriptor) -> Self {
11433 Self {
11434 extensions: Vec::new(),
11435 label: if value.label.data.is_null() || value.label.length == 0 {
11436 None
11437 } else {
11438 Some(string_view_to_string(value.label))
11439 },
11440 }
11441 }
11442 }
11443 pub struct SharedBufferMemoryEndAccessState {
11444 pub(crate) extensions: Vec<SharedBufferMemoryEndAccessStateExtension>,
11445 pub initialized: Option<bool>,
11446 pub fences: Option<Vec<SharedFence>>,
11447 pub signaled_values: Option<Vec<u64>>,
11448 #[doc(hidden)]
11449 pub(crate) _free_members: Option<ffi::WGPUSharedBufferMemoryEndAccessState>,
11450 }
11451 impl Default for SharedBufferMemoryEndAccessState {
11452 fn default() -> Self {
11453 Self {
11454 extensions: Vec::new(),
11455 initialized: None,
11456 fences: None,
11457 signaled_values: None,
11458 _free_members: None,
11459 }
11460 }
11461 }
11462 impl SharedBufferMemoryEndAccessState {
11463 pub fn new() -> Self {
11464 Self::default()
11465 }
11466 pub(crate) fn to_ffi(
11467 &self,
11468 ) -> (ffi::WGPUSharedBufferMemoryEndAccessState, ChainedStructStorage) {
11469 let mut storage = ChainedStructStorage::new();
11470 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11471 for ext in self.extensions.iter().rev() {
11472 next = ext.push_chain(&mut storage, next);
11473 }
11474 let mut raw: ffi::WGPUSharedBufferMemoryEndAccessState = unsafe {
11475 std::mem::zeroed()
11476 };
11477 raw.nextInChain = next;
11478 raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
11479 raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
11480 if let Some(values) = &self.fences {
11481 let len_value = values.len();
11482 let raw_vec: Vec<ffi::WGPUSharedFence> = values
11483 .iter()
11484 .map(|v| v.as_raw())
11485 .collect();
11486 let ptr = storage.push_vec(raw_vec);
11487 raw.fences = ptr;
11488 raw.fenceCount = len_value;
11489 } else {
11490 raw.fences = std::ptr::null();
11491 raw.fenceCount = 0;
11492 }
11493 if let Some(values) = &self.signaled_values {
11494 let len_value = values.len();
11495 let raw_vec = values.to_vec();
11496 let ptr = storage.push_vec(raw_vec);
11497 raw.signaledValues = ptr;
11498 raw.fenceCount = len_value;
11499 } else {
11500 raw.signaledValues = std::ptr::null();
11501 raw.fenceCount = 0;
11502 }
11503 (raw, storage)
11504 }
11505 pub fn with_extension(
11506 mut self,
11507 extension: SharedBufferMemoryEndAccessStateExtension,
11508 ) -> Self {
11509 self.extensions.push(extension);
11510 self
11511 }
11512 pub(crate) fn from_ffi(
11513 value: ffi::WGPUSharedBufferMemoryEndAccessState,
11514 ) -> Self {
11515 Self {
11516 extensions: Vec::new(),
11517 initialized: Some(value.initialized != 0),
11518 fences: if value.fences.is_null() {
11519 None
11520 } else {
11521 Some(
11522 unsafe {
11523 std::slice::from_raw_parts(
11524 value.fences,
11525 value.fenceCount as usize,
11526 )
11527 }
11528 .iter()
11529 .map(|raw| unsafe { SharedFence::from_raw(*raw) })
11530 .collect(),
11531 )
11532 },
11533 signaled_values: if value.signaledValues.is_null() {
11534 None
11535 } else {
11536 Some(
11537 unsafe {
11538 std::slice::from_raw_parts(
11539 value.signaledValues,
11540 value.fenceCount as usize,
11541 )
11542 }
11543 .to_vec(),
11544 )
11545 },
11546 _free_members: Some(value),
11547 }
11548 }
11549 pub(crate) fn free_members(value: ffi::WGPUSharedBufferMemoryEndAccessState) {
11550 unsafe { ffi::wgpuSharedBufferMemoryEndAccessStateFreeMembers(value) };
11551 }
11552 }
11553 impl Drop for SharedBufferMemoryEndAccessState {
11554 fn drop(&mut self) {
11555 if let Some(value) = self._free_members.take() {
11556 unsafe { ffi::wgpuSharedBufferMemoryEndAccessStateFreeMembers(value) };
11557 }
11558 }
11559 }
11560 pub struct SharedBufferMemoryProperties {
11561 pub(crate) extensions: Vec<SharedBufferMemoryPropertiesExtension>,
11562 pub usage: Option<BufferUsage>,
11563 pub size: Option<u64>,
11564 }
11565 impl Default for SharedBufferMemoryProperties {
11566 fn default() -> Self {
11567 Self {
11568 extensions: Vec::new(),
11569 usage: None,
11570 size: None,
11571 }
11572 }
11573 }
11574 impl SharedBufferMemoryProperties {
11575 pub fn new() -> Self {
11576 Self::default()
11577 }
11578 pub(crate) fn to_ffi(
11579 &self,
11580 ) -> (ffi::WGPUSharedBufferMemoryProperties, ChainedStructStorage) {
11581 let mut storage = ChainedStructStorage::new();
11582 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11583 for ext in self.extensions.iter().rev() {
11584 next = ext.push_chain(&mut storage, next);
11585 }
11586 let mut raw: ffi::WGPUSharedBufferMemoryProperties = unsafe {
11587 std::mem::zeroed()
11588 };
11589 raw.nextInChain = next;
11590 if let Some(value) = self.usage {
11591 raw.usage = value.into();
11592 } else {
11593 raw.usage = 0 as ffi::WGPUBufferUsage;
11594 }
11595 if let Some(value) = self.size {
11596 raw.size = value;
11597 }
11598 (raw, storage)
11599 }
11600 pub fn with_extension(
11601 mut self,
11602 extension: SharedBufferMemoryPropertiesExtension,
11603 ) -> Self {
11604 self.extensions.push(extension);
11605 self
11606 }
11607 pub(crate) fn from_ffi(value: ffi::WGPUSharedBufferMemoryProperties) -> Self {
11608 Self {
11609 extensions: Vec::new(),
11610 usage: Some(value.usage.into()),
11611 size: Some(value.size),
11612 }
11613 }
11614 }
11615 pub struct SharedFenceDXGISharedHandleDescriptor {
11616 pub handle: Option<*mut std::ffi::c_void>,
11617 }
11618 impl Default for SharedFenceDXGISharedHandleDescriptor {
11619 fn default() -> Self {
11620 Self { handle: None }
11621 }
11622 }
11623 impl SharedFenceDXGISharedHandleDescriptor {
11624 pub fn new() -> Self {
11625 Self::default()
11626 }
11627 pub(crate) fn to_ffi(
11628 &self,
11629 ) -> (ffi::WGPUSharedFenceDXGISharedHandleDescriptor, ChainedStructStorage) {
11630 let mut storage = ChainedStructStorage::new();
11631 let mut raw: ffi::WGPUSharedFenceDXGISharedHandleDescriptor = unsafe {
11632 std::mem::zeroed()
11633 };
11634 if let Some(value) = self.handle {
11635 raw.handle = value;
11636 }
11637 (raw, storage)
11638 }
11639 pub(crate) fn from_ffi(
11640 value: ffi::WGPUSharedFenceDXGISharedHandleDescriptor,
11641 ) -> Self {
11642 Self { handle: Some(value.handle) }
11643 }
11644 }
11645 pub struct SharedFenceDXGISharedHandleExportInfo {
11646 pub handle: Option<*mut std::ffi::c_void>,
11647 }
11648 impl Default for SharedFenceDXGISharedHandleExportInfo {
11649 fn default() -> Self {
11650 Self { handle: None }
11651 }
11652 }
11653 impl SharedFenceDXGISharedHandleExportInfo {
11654 pub fn new() -> Self {
11655 Self::default()
11656 }
11657 pub(crate) fn to_ffi(
11658 &self,
11659 ) -> (ffi::WGPUSharedFenceDXGISharedHandleExportInfo, ChainedStructStorage) {
11660 let mut storage = ChainedStructStorage::new();
11661 let mut raw: ffi::WGPUSharedFenceDXGISharedHandleExportInfo = unsafe {
11662 std::mem::zeroed()
11663 };
11664 if let Some(value) = self.handle {
11665 raw.handle = value;
11666 }
11667 (raw, storage)
11668 }
11669 pub(crate) fn from_ffi(
11670 value: ffi::WGPUSharedFenceDXGISharedHandleExportInfo,
11671 ) -> Self {
11672 Self { handle: Some(value.handle) }
11673 }
11674 }
11675 pub struct SharedFenceEGLSyncDescriptor {
11676 pub sync: Option<*mut std::ffi::c_void>,
11677 }
11678 impl Default for SharedFenceEGLSyncDescriptor {
11679 fn default() -> Self {
11680 Self { sync: None }
11681 }
11682 }
11683 impl SharedFenceEGLSyncDescriptor {
11684 pub fn new() -> Self {
11685 Self::default()
11686 }
11687 pub(crate) fn to_ffi(
11688 &self,
11689 ) -> (ffi::WGPUSharedFenceEGLSyncDescriptor, ChainedStructStorage) {
11690 let mut storage = ChainedStructStorage::new();
11691 let mut raw: ffi::WGPUSharedFenceEGLSyncDescriptor = unsafe {
11692 std::mem::zeroed()
11693 };
11694 if let Some(value) = self.sync {
11695 raw.sync = value;
11696 }
11697 (raw, storage)
11698 }
11699 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceEGLSyncDescriptor) -> Self {
11700 Self { sync: Some(value.sync) }
11701 }
11702 }
11703 pub struct SharedFenceEGLSyncExportInfo {
11704 pub sync: Option<*mut std::ffi::c_void>,
11705 }
11706 impl Default for SharedFenceEGLSyncExportInfo {
11707 fn default() -> Self {
11708 Self { sync: None }
11709 }
11710 }
11711 impl SharedFenceEGLSyncExportInfo {
11712 pub fn new() -> Self {
11713 Self::default()
11714 }
11715 pub(crate) fn to_ffi(
11716 &self,
11717 ) -> (ffi::WGPUSharedFenceEGLSyncExportInfo, ChainedStructStorage) {
11718 let mut storage = ChainedStructStorage::new();
11719 let mut raw: ffi::WGPUSharedFenceEGLSyncExportInfo = unsafe {
11720 std::mem::zeroed()
11721 };
11722 if let Some(value) = self.sync {
11723 raw.sync = value;
11724 }
11725 (raw, storage)
11726 }
11727 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceEGLSyncExportInfo) -> Self {
11728 Self { sync: Some(value.sync) }
11729 }
11730 }
11731 pub struct SharedFenceMTLSharedEventDescriptor {
11732 pub shared_event: Option<*mut std::ffi::c_void>,
11733 }
11734 impl Default for SharedFenceMTLSharedEventDescriptor {
11735 fn default() -> Self {
11736 Self { shared_event: None }
11737 }
11738 }
11739 impl SharedFenceMTLSharedEventDescriptor {
11740 pub fn new() -> Self {
11741 Self::default()
11742 }
11743 pub(crate) fn to_ffi(
11744 &self,
11745 ) -> (ffi::WGPUSharedFenceMTLSharedEventDescriptor, ChainedStructStorage) {
11746 let mut storage = ChainedStructStorage::new();
11747 let mut raw: ffi::WGPUSharedFenceMTLSharedEventDescriptor = unsafe {
11748 std::mem::zeroed()
11749 };
11750 if let Some(value) = self.shared_event {
11751 raw.sharedEvent = value;
11752 }
11753 (raw, storage)
11754 }
11755 pub(crate) fn from_ffi(
11756 value: ffi::WGPUSharedFenceMTLSharedEventDescriptor,
11757 ) -> Self {
11758 Self {
11759 shared_event: Some(value.sharedEvent),
11760 }
11761 }
11762 }
11763 pub struct SharedFenceMTLSharedEventExportInfo {
11764 pub shared_event: Option<*mut std::ffi::c_void>,
11765 }
11766 impl Default for SharedFenceMTLSharedEventExportInfo {
11767 fn default() -> Self {
11768 Self { shared_event: None }
11769 }
11770 }
11771 impl SharedFenceMTLSharedEventExportInfo {
11772 pub fn new() -> Self {
11773 Self::default()
11774 }
11775 pub(crate) fn to_ffi(
11776 &self,
11777 ) -> (ffi::WGPUSharedFenceMTLSharedEventExportInfo, ChainedStructStorage) {
11778 let mut storage = ChainedStructStorage::new();
11779 let mut raw: ffi::WGPUSharedFenceMTLSharedEventExportInfo = unsafe {
11780 std::mem::zeroed()
11781 };
11782 if let Some(value) = self.shared_event {
11783 raw.sharedEvent = value;
11784 }
11785 (raw, storage)
11786 }
11787 pub(crate) fn from_ffi(
11788 value: ffi::WGPUSharedFenceMTLSharedEventExportInfo,
11789 ) -> Self {
11790 Self {
11791 shared_event: Some(value.sharedEvent),
11792 }
11793 }
11794 }
11795 pub struct SharedFenceDescriptor {
11796 pub(crate) extensions: Vec<SharedFenceDescriptorExtension>,
11797 pub label: Option<String>,
11798 }
11799 impl Default for SharedFenceDescriptor {
11800 fn default() -> Self {
11801 Self {
11802 extensions: Vec::new(),
11803 label: None,
11804 }
11805 }
11806 }
11807 impl SharedFenceDescriptor {
11808 pub fn new() -> Self {
11809 Self::default()
11810 }
11811 pub(crate) fn to_ffi(
11812 &self,
11813 ) -> (ffi::WGPUSharedFenceDescriptor, ChainedStructStorage) {
11814 let mut storage = ChainedStructStorage::new();
11815 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11816 for ext in self.extensions.iter().rev() {
11817 next = ext.push_chain(&mut storage, next);
11818 }
11819 let mut raw: ffi::WGPUSharedFenceDescriptor = unsafe { std::mem::zeroed() };
11820 raw.nextInChain = next;
11821 if let Some(value) = &self.label {
11822 raw.label = ffi::WGPUStringView {
11823 data: value.as_ptr().cast(),
11824 length: value.len(),
11825 };
11826 } else {
11827 raw.label = ffi::WGPUStringView {
11828 data: std::ptr::null(),
11829 length: 0,
11830 };
11831 }
11832 (raw, storage)
11833 }
11834 pub fn with_extension(
11835 mut self,
11836 extension: SharedFenceDescriptorExtension,
11837 ) -> Self {
11838 self.extensions.push(extension);
11839 self
11840 }
11841 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceDescriptor) -> Self {
11842 Self {
11843 extensions: Vec::new(),
11844 label: if value.label.data.is_null() || value.label.length == 0 {
11845 None
11846 } else {
11847 Some(string_view_to_string(value.label))
11848 },
11849 }
11850 }
11851 }
11852 pub struct SharedFenceExportInfo {
11853 pub(crate) extensions: Vec<SharedFenceExportInfoExtension>,
11854 pub r#type: Option<SharedFenceType>,
11855 }
11856 impl Default for SharedFenceExportInfo {
11857 fn default() -> Self {
11858 Self {
11859 extensions: Vec::new(),
11860 r#type: None,
11861 }
11862 }
11863 }
11864 impl SharedFenceExportInfo {
11865 pub fn new() -> Self {
11866 Self::default()
11867 }
11868 pub(crate) fn to_ffi(
11869 &self,
11870 ) -> (ffi::WGPUSharedFenceExportInfo, ChainedStructStorage) {
11871 let mut storage = ChainedStructStorage::new();
11872 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
11873 for ext in self.extensions.iter().rev() {
11874 next = ext.push_chain(&mut storage, next);
11875 }
11876 let mut raw: ffi::WGPUSharedFenceExportInfo = unsafe { std::mem::zeroed() };
11877 raw.nextInChain = next;
11878 if let Some(value) = self.r#type {
11879 raw.type_ = value.into();
11880 } else {
11881 raw.type_ = 0 as ffi::WGPUSharedFenceType;
11882 }
11883 (raw, storage)
11884 }
11885 pub fn with_extension(
11886 mut self,
11887 extension: SharedFenceExportInfoExtension,
11888 ) -> Self {
11889 self.extensions.push(extension);
11890 self
11891 }
11892 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceExportInfo) -> Self {
11893 Self {
11894 extensions: Vec::new(),
11895 r#type: Some(value.type_.into()),
11896 }
11897 }
11898 }
11899 pub struct SharedFenceSyncFDDescriptor {
11900 pub handle: Option<i32>,
11901 }
11902 impl Default for SharedFenceSyncFDDescriptor {
11903 fn default() -> Self {
11904 Self { handle: None }
11905 }
11906 }
11907 impl SharedFenceSyncFDDescriptor {
11908 pub fn new() -> Self {
11909 Self::default()
11910 }
11911 pub(crate) fn to_ffi(
11912 &self,
11913 ) -> (ffi::WGPUSharedFenceSyncFDDescriptor, ChainedStructStorage) {
11914 let mut storage = ChainedStructStorage::new();
11915 let mut raw: ffi::WGPUSharedFenceSyncFDDescriptor = unsafe {
11916 std::mem::zeroed()
11917 };
11918 if let Some(value) = self.handle {
11919 raw.handle = value;
11920 }
11921 (raw, storage)
11922 }
11923 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceSyncFDDescriptor) -> Self {
11924 Self { handle: Some(value.handle) }
11925 }
11926 }
11927 pub struct SharedFenceSyncFDExportInfo {
11928 pub handle: Option<i32>,
11929 }
11930 impl Default for SharedFenceSyncFDExportInfo {
11931 fn default() -> Self {
11932 Self { handle: None }
11933 }
11934 }
11935 impl SharedFenceSyncFDExportInfo {
11936 pub fn new() -> Self {
11937 Self::default()
11938 }
11939 pub(crate) fn to_ffi(
11940 &self,
11941 ) -> (ffi::WGPUSharedFenceSyncFDExportInfo, ChainedStructStorage) {
11942 let mut storage = ChainedStructStorage::new();
11943 let mut raw: ffi::WGPUSharedFenceSyncFDExportInfo = unsafe {
11944 std::mem::zeroed()
11945 };
11946 if let Some(value) = self.handle {
11947 raw.handle = value;
11948 }
11949 (raw, storage)
11950 }
11951 pub(crate) fn from_ffi(value: ffi::WGPUSharedFenceSyncFDExportInfo) -> Self {
11952 Self { handle: Some(value.handle) }
11953 }
11954 }
11955 pub struct SharedFenceVkSemaphoreOpaqueFDDescriptor {
11956 pub handle: Option<i32>,
11957 }
11958 impl Default for SharedFenceVkSemaphoreOpaqueFDDescriptor {
11959 fn default() -> Self {
11960 Self { handle: None }
11961 }
11962 }
11963 impl SharedFenceVkSemaphoreOpaqueFDDescriptor {
11964 pub fn new() -> Self {
11965 Self::default()
11966 }
11967 pub(crate) fn to_ffi(
11968 &self,
11969 ) -> (ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor, ChainedStructStorage) {
11970 let mut storage = ChainedStructStorage::new();
11971 let mut raw: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor = unsafe {
11972 std::mem::zeroed()
11973 };
11974 if let Some(value) = self.handle {
11975 raw.handle = value;
11976 }
11977 (raw, storage)
11978 }
11979 pub(crate) fn from_ffi(
11980 value: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDDescriptor,
11981 ) -> Self {
11982 Self { handle: Some(value.handle) }
11983 }
11984 }
11985 pub struct SharedFenceVkSemaphoreOpaqueFDExportInfo {
11986 pub handle: Option<i32>,
11987 }
11988 impl Default for SharedFenceVkSemaphoreOpaqueFDExportInfo {
11989 fn default() -> Self {
11990 Self { handle: None }
11991 }
11992 }
11993 impl SharedFenceVkSemaphoreOpaqueFDExportInfo {
11994 pub fn new() -> Self {
11995 Self::default()
11996 }
11997 pub(crate) fn to_ffi(
11998 &self,
11999 ) -> (ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo, ChainedStructStorage) {
12000 let mut storage = ChainedStructStorage::new();
12001 let mut raw: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo = unsafe {
12002 std::mem::zeroed()
12003 };
12004 if let Some(value) = self.handle {
12005 raw.handle = value;
12006 }
12007 (raw, storage)
12008 }
12009 pub(crate) fn from_ffi(
12010 value: ffi::WGPUSharedFenceVkSemaphoreOpaqueFDExportInfo,
12011 ) -> Self {
12012 Self { handle: Some(value.handle) }
12013 }
12014 }
12015 pub struct SharedFenceVkSemaphoreZirconHandleDescriptor {
12016 pub handle: Option<u32>,
12017 }
12018 impl Default for SharedFenceVkSemaphoreZirconHandleDescriptor {
12019 fn default() -> Self {
12020 Self { handle: None }
12021 }
12022 }
12023 impl SharedFenceVkSemaphoreZirconHandleDescriptor {
12024 pub fn new() -> Self {
12025 Self::default()
12026 }
12027 pub(crate) fn to_ffi(
12028 &self,
12029 ) -> (
12030 ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor,
12031 ChainedStructStorage,
12032 ) {
12033 let mut storage = ChainedStructStorage::new();
12034 let mut raw: ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor = unsafe {
12035 std::mem::zeroed()
12036 };
12037 if let Some(value) = self.handle {
12038 raw.handle = value;
12039 }
12040 (raw, storage)
12041 }
12042 pub(crate) fn from_ffi(
12043 value: ffi::WGPUSharedFenceVkSemaphoreZirconHandleDescriptor,
12044 ) -> Self {
12045 Self { handle: Some(value.handle) }
12046 }
12047 }
12048 pub struct SharedFenceVkSemaphoreZirconHandleExportInfo {
12049 pub handle: Option<u32>,
12050 }
12051 impl Default for SharedFenceVkSemaphoreZirconHandleExportInfo {
12052 fn default() -> Self {
12053 Self { handle: None }
12054 }
12055 }
12056 impl SharedFenceVkSemaphoreZirconHandleExportInfo {
12057 pub fn new() -> Self {
12058 Self::default()
12059 }
12060 pub(crate) fn to_ffi(
12061 &self,
12062 ) -> (
12063 ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo,
12064 ChainedStructStorage,
12065 ) {
12066 let mut storage = ChainedStructStorage::new();
12067 let mut raw: ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo = unsafe {
12068 std::mem::zeroed()
12069 };
12070 if let Some(value) = self.handle {
12071 raw.handle = value;
12072 }
12073 (raw, storage)
12074 }
12075 pub(crate) fn from_ffi(
12076 value: ffi::WGPUSharedFenceVkSemaphoreZirconHandleExportInfo,
12077 ) -> Self {
12078 Self { handle: Some(value.handle) }
12079 }
12080 }
12081 pub struct SharedTextureMemoryD3DSwapchainBeginState {
12082 pub is_swapchain: Option<bool>,
12083 }
12084 impl Default for SharedTextureMemoryD3DSwapchainBeginState {
12085 fn default() -> Self {
12086 Self { is_swapchain: None }
12087 }
12088 }
12089 impl SharedTextureMemoryD3DSwapchainBeginState {
12090 pub fn new() -> Self {
12091 Self::default()
12092 }
12093 pub(crate) fn to_ffi(
12094 &self,
12095 ) -> (ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState, ChainedStructStorage) {
12096 let mut storage = ChainedStructStorage::new();
12097 let mut raw: ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState = unsafe {
12098 std::mem::zeroed()
12099 };
12100 raw.isSwapchain = if self.is_swapchain.unwrap_or(false) { 1 } else { 0 };
12101 (raw, storage)
12102 }
12103 pub(crate) fn from_ffi(
12104 value: ffi::WGPUSharedTextureMemoryD3DSwapchainBeginState,
12105 ) -> Self {
12106 Self {
12107 is_swapchain: Some(value.isSwapchain != 0),
12108 }
12109 }
12110 }
12111 pub struct SharedTextureMemoryD3D11BeginState {
12112 pub requires_end_access_fence: Option<bool>,
12113 }
12114 impl Default for SharedTextureMemoryD3D11BeginState {
12115 fn default() -> Self {
12116 Self {
12117 requires_end_access_fence: None,
12118 }
12119 }
12120 }
12121 impl SharedTextureMemoryD3D11BeginState {
12122 pub fn new() -> Self {
12123 Self::default()
12124 }
12125 pub(crate) fn to_ffi(
12126 &self,
12127 ) -> (ffi::WGPUSharedTextureMemoryD3D11BeginState, ChainedStructStorage) {
12128 let mut storage = ChainedStructStorage::new();
12129 let mut raw: ffi::WGPUSharedTextureMemoryD3D11BeginState = unsafe {
12130 std::mem::zeroed()
12131 };
12132 raw.requiresEndAccessFence = if self
12133 .requires_end_access_fence
12134 .unwrap_or(false)
12135 {
12136 1
12137 } else {
12138 0
12139 };
12140 (raw, storage)
12141 }
12142 pub(crate) fn from_ffi(
12143 value: ffi::WGPUSharedTextureMemoryD3D11BeginState,
12144 ) -> Self {
12145 Self {
12146 requires_end_access_fence: Some(value.requiresEndAccessFence != 0),
12147 }
12148 }
12149 }
12150 pub struct SharedTextureMemoryDXGISharedHandleDescriptor {
12151 pub handle: Option<*mut std::ffi::c_void>,
12152 pub use_keyed_mutex: Option<bool>,
12153 }
12154 impl Default for SharedTextureMemoryDXGISharedHandleDescriptor {
12155 fn default() -> Self {
12156 Self {
12157 handle: None,
12158 use_keyed_mutex: None,
12159 }
12160 }
12161 }
12162 impl SharedTextureMemoryDXGISharedHandleDescriptor {
12163 pub fn new() -> Self {
12164 Self::default()
12165 }
12166 pub(crate) fn to_ffi(
12167 &self,
12168 ) -> (
12169 ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor,
12170 ChainedStructStorage,
12171 ) {
12172 let mut storage = ChainedStructStorage::new();
12173 let mut raw: ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor = unsafe {
12174 std::mem::zeroed()
12175 };
12176 if let Some(value) = self.handle {
12177 raw.handle = value;
12178 }
12179 raw.useKeyedMutex = if self.use_keyed_mutex.unwrap_or(false) {
12180 1
12181 } else {
12182 0
12183 };
12184 (raw, storage)
12185 }
12186 pub(crate) fn from_ffi(
12187 value: ffi::WGPUSharedTextureMemoryDXGISharedHandleDescriptor,
12188 ) -> Self {
12189 Self {
12190 handle: Some(value.handle),
12191 use_keyed_mutex: Some(value.useKeyedMutex != 0),
12192 }
12193 }
12194 }
12195 pub struct SharedTextureMemoryEGLImageDescriptor {
12196 pub image: Option<*mut std::ffi::c_void>,
12197 }
12198 impl Default for SharedTextureMemoryEGLImageDescriptor {
12199 fn default() -> Self {
12200 Self { image: None }
12201 }
12202 }
12203 impl SharedTextureMemoryEGLImageDescriptor {
12204 pub fn new() -> Self {
12205 Self::default()
12206 }
12207 pub(crate) fn to_ffi(
12208 &self,
12209 ) -> (ffi::WGPUSharedTextureMemoryEGLImageDescriptor, ChainedStructStorage) {
12210 let mut storage = ChainedStructStorage::new();
12211 let mut raw: ffi::WGPUSharedTextureMemoryEGLImageDescriptor = unsafe {
12212 std::mem::zeroed()
12213 };
12214 if let Some(value) = self.image {
12215 raw.image = value;
12216 }
12217 (raw, storage)
12218 }
12219 pub(crate) fn from_ffi(
12220 value: ffi::WGPUSharedTextureMemoryEGLImageDescriptor,
12221 ) -> Self {
12222 Self { image: Some(value.image) }
12223 }
12224 }
12225 pub struct SharedTextureMemoryIOSurfaceDescriptor {
12226 pub io_surface: Option<*mut std::ffi::c_void>,
12227 pub allow_storage_binding: Option<bool>,
12228 }
12229 impl Default for SharedTextureMemoryIOSurfaceDescriptor {
12230 fn default() -> Self {
12231 Self {
12232 io_surface: None,
12233 allow_storage_binding: None,
12234 }
12235 }
12236 }
12237 impl SharedTextureMemoryIOSurfaceDescriptor {
12238 pub fn new() -> Self {
12239 Self::default()
12240 }
12241 pub(crate) fn to_ffi(
12242 &self,
12243 ) -> (ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor, ChainedStructStorage) {
12244 let mut storage = ChainedStructStorage::new();
12245 let mut raw: ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor = unsafe {
12246 std::mem::zeroed()
12247 };
12248 if let Some(value) = self.io_surface {
12249 raw.ioSurface = value;
12250 }
12251 raw.allowStorageBinding = if self.allow_storage_binding.unwrap_or(false) {
12252 1
12253 } else {
12254 0
12255 };
12256 (raw, storage)
12257 }
12258 pub(crate) fn from_ffi(
12259 value: ffi::WGPUSharedTextureMemoryIOSurfaceDescriptor,
12260 ) -> Self {
12261 Self {
12262 io_surface: Some(value.ioSurface),
12263 allow_storage_binding: Some(value.allowStorageBinding != 0),
12264 }
12265 }
12266 }
12267 pub struct SharedTextureMemoryAHardwareBufferDescriptor {
12268 pub handle: Option<*mut std::ffi::c_void>,
12269 pub use_external_format: Option<bool>,
12270 }
12271 impl Default for SharedTextureMemoryAHardwareBufferDescriptor {
12272 fn default() -> Self {
12273 Self {
12274 handle: None,
12275 use_external_format: None,
12276 }
12277 }
12278 }
12279 impl SharedTextureMemoryAHardwareBufferDescriptor {
12280 pub fn new() -> Self {
12281 Self::default()
12282 }
12283 pub(crate) fn to_ffi(
12284 &self,
12285 ) -> (
12286 ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor,
12287 ChainedStructStorage,
12288 ) {
12289 let mut storage = ChainedStructStorage::new();
12290 let mut raw: ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor = unsafe {
12291 std::mem::zeroed()
12292 };
12293 if let Some(value) = self.handle {
12294 raw.handle = value;
12295 }
12296 raw.useExternalFormat = if self.use_external_format.unwrap_or(false) {
12297 1
12298 } else {
12299 0
12300 };
12301 (raw, storage)
12302 }
12303 pub(crate) fn from_ffi(
12304 value: ffi::WGPUSharedTextureMemoryAHardwareBufferDescriptor,
12305 ) -> Self {
12306 Self {
12307 handle: Some(value.handle),
12308 use_external_format: Some(value.useExternalFormat != 0),
12309 }
12310 }
12311 }
12312 pub struct SharedTextureMemoryAHardwareBufferProperties {
12313 pub y_cb_cr_info: Option<YCbCrVkDescriptor>,
12314 }
12315 impl Default for SharedTextureMemoryAHardwareBufferProperties {
12316 fn default() -> Self {
12317 Self { y_cb_cr_info: None }
12318 }
12319 }
12320 impl SharedTextureMemoryAHardwareBufferProperties {
12321 pub fn new() -> Self {
12322 Self::default()
12323 }
12324 pub(crate) fn to_ffi(
12325 &self,
12326 ) -> (
12327 ffi::WGPUSharedTextureMemoryAHardwareBufferProperties,
12328 ChainedStructStorage,
12329 ) {
12330 let mut storage = ChainedStructStorage::new();
12331 let mut raw: ffi::WGPUSharedTextureMemoryAHardwareBufferProperties = unsafe {
12332 std::mem::zeroed()
12333 };
12334 if let Some(value) = &self.y_cb_cr_info {
12335 let (raw_value, storage_value) = value.to_ffi();
12336 raw.yCbCrInfo = raw_value;
12337 storage.push_storage(storage_value);
12338 }
12339 (raw, storage)
12340 }
12341 pub(crate) fn from_ffi(
12342 value: ffi::WGPUSharedTextureMemoryAHardwareBufferProperties,
12343 ) -> Self {
12344 Self {
12345 y_cb_cr_info: Some(YCbCrVkDescriptor::from_ffi(value.yCbCrInfo)),
12346 }
12347 }
12348 }
12349 pub struct SharedTextureMemoryBeginAccessDescriptor {
12350 pub(crate) extensions: Vec<SharedTextureMemoryBeginAccessDescriptorExtension>,
12351 pub concurrent_read: Option<bool>,
12352 pub initialized: Option<bool>,
12353 pub fences: Option<Vec<SharedFence>>,
12354 pub signaled_values: Option<Vec<u64>>,
12355 }
12356 impl Default for SharedTextureMemoryBeginAccessDescriptor {
12357 fn default() -> Self {
12358 Self {
12359 extensions: Vec::new(),
12360 concurrent_read: None,
12361 initialized: None,
12362 fences: None,
12363 signaled_values: None,
12364 }
12365 }
12366 }
12367 impl SharedTextureMemoryBeginAccessDescriptor {
12368 pub fn new() -> Self {
12369 Self::default()
12370 }
12371 pub(crate) fn to_ffi(
12372 &self,
12373 ) -> (ffi::WGPUSharedTextureMemoryBeginAccessDescriptor, ChainedStructStorage) {
12374 let mut storage = ChainedStructStorage::new();
12375 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12376 for ext in self.extensions.iter().rev() {
12377 next = ext.push_chain(&mut storage, next);
12378 }
12379 let mut raw: ffi::WGPUSharedTextureMemoryBeginAccessDescriptor = unsafe {
12380 std::mem::zeroed()
12381 };
12382 raw.nextInChain = next;
12383 raw.concurrentRead = if self.concurrent_read.unwrap_or(false) {
12384 1
12385 } else {
12386 0
12387 };
12388 raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
12389 raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
12390 if let Some(values) = &self.fences {
12391 let len_value = values.len();
12392 let raw_vec: Vec<ffi::WGPUSharedFence> = values
12393 .iter()
12394 .map(|v| v.as_raw())
12395 .collect();
12396 let ptr = storage.push_vec(raw_vec);
12397 raw.fences = ptr;
12398 raw.fenceCount = len_value;
12399 } else {
12400 raw.fences = std::ptr::null();
12401 raw.fenceCount = 0;
12402 }
12403 if let Some(values) = &self.signaled_values {
12404 let len_value = values.len();
12405 let raw_vec = values.to_vec();
12406 let ptr = storage.push_vec(raw_vec);
12407 raw.signaledValues = ptr;
12408 raw.fenceCount = len_value;
12409 } else {
12410 raw.signaledValues = std::ptr::null();
12411 raw.fenceCount = 0;
12412 }
12413 (raw, storage)
12414 }
12415 pub fn with_extension(
12416 mut self,
12417 extension: SharedTextureMemoryBeginAccessDescriptorExtension,
12418 ) -> Self {
12419 self.extensions.push(extension);
12420 self
12421 }
12422 pub(crate) fn from_ffi(
12423 value: ffi::WGPUSharedTextureMemoryBeginAccessDescriptor,
12424 ) -> Self {
12425 Self {
12426 extensions: Vec::new(),
12427 concurrent_read: Some(value.concurrentRead != 0),
12428 initialized: Some(value.initialized != 0),
12429 fences: if value.fences.is_null() {
12430 None
12431 } else {
12432 Some(
12433 unsafe {
12434 std::slice::from_raw_parts(
12435 value.fences,
12436 value.fenceCount as usize,
12437 )
12438 }
12439 .iter()
12440 .map(|raw| unsafe { SharedFence::from_raw(*raw) })
12441 .collect(),
12442 )
12443 },
12444 signaled_values: if value.signaledValues.is_null() {
12445 None
12446 } else {
12447 Some(
12448 unsafe {
12449 std::slice::from_raw_parts(
12450 value.signaledValues,
12451 value.fenceCount as usize,
12452 )
12453 }
12454 .to_vec(),
12455 )
12456 },
12457 }
12458 }
12459 }
12460 pub struct SharedTextureMemoryDescriptor {
12461 pub(crate) extensions: Vec<SharedTextureMemoryDescriptorExtension>,
12462 pub label: Option<String>,
12463 }
12464 impl Default for SharedTextureMemoryDescriptor {
12465 fn default() -> Self {
12466 Self {
12467 extensions: Vec::new(),
12468 label: None,
12469 }
12470 }
12471 }
12472 impl SharedTextureMemoryDescriptor {
12473 pub fn new() -> Self {
12474 Self::default()
12475 }
12476 pub(crate) fn to_ffi(
12477 &self,
12478 ) -> (ffi::WGPUSharedTextureMemoryDescriptor, ChainedStructStorage) {
12479 let mut storage = ChainedStructStorage::new();
12480 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12481 for ext in self.extensions.iter().rev() {
12482 next = ext.push_chain(&mut storage, next);
12483 }
12484 let mut raw: ffi::WGPUSharedTextureMemoryDescriptor = unsafe {
12485 std::mem::zeroed()
12486 };
12487 raw.nextInChain = next;
12488 if let Some(value) = &self.label {
12489 raw.label = ffi::WGPUStringView {
12490 data: value.as_ptr().cast(),
12491 length: value.len(),
12492 };
12493 } else {
12494 raw.label = ffi::WGPUStringView {
12495 data: std::ptr::null(),
12496 length: 0,
12497 };
12498 }
12499 (raw, storage)
12500 }
12501 pub fn with_extension(
12502 mut self,
12503 extension: SharedTextureMemoryDescriptorExtension,
12504 ) -> Self {
12505 self.extensions.push(extension);
12506 self
12507 }
12508 pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryDescriptor) -> Self {
12509 Self {
12510 extensions: Vec::new(),
12511 label: if value.label.data.is_null() || value.label.length == 0 {
12512 None
12513 } else {
12514 Some(string_view_to_string(value.label))
12515 },
12516 }
12517 }
12518 }
12519 pub struct SharedTextureMemoryDmaBufDescriptor {
12520 pub size: Option<Extent3D>,
12521 pub drm_format: Option<u32>,
12522 pub drm_modifier: Option<u64>,
12523 pub planes: Option<Vec<SharedTextureMemoryDmaBufPlane>>,
12524 }
12525 impl Default for SharedTextureMemoryDmaBufDescriptor {
12526 fn default() -> Self {
12527 Self {
12528 size: None,
12529 drm_format: None,
12530 drm_modifier: None,
12531 planes: None,
12532 }
12533 }
12534 }
12535 impl SharedTextureMemoryDmaBufDescriptor {
12536 pub fn new() -> Self {
12537 Self::default()
12538 }
12539 pub(crate) fn to_ffi(
12540 &self,
12541 ) -> (ffi::WGPUSharedTextureMemoryDmaBufDescriptor, ChainedStructStorage) {
12542 let mut storage = ChainedStructStorage::new();
12543 let mut raw: ffi::WGPUSharedTextureMemoryDmaBufDescriptor = unsafe {
12544 std::mem::zeroed()
12545 };
12546 if let Some(value) = &self.size {
12547 let (raw_value, storage_value) = value.to_ffi();
12548 raw.size = raw_value;
12549 storage.push_storage(storage_value);
12550 }
12551 if let Some(value) = self.drm_format {
12552 raw.drmFormat = value;
12553 }
12554 if let Some(value) = self.drm_modifier {
12555 raw.drmModifier = value;
12556 }
12557 raw.planeCount = self.planes.as_ref().map(|v| v.len()).unwrap_or(0);
12558 if let Some(values) = &self.planes {
12559 let len_value = values.len();
12560 let mut raw_vec: Vec<ffi::WGPUSharedTextureMemoryDmaBufPlane> = Vec::with_capacity(
12561 values.len(),
12562 );
12563 for item in values.iter() {
12564 let (raw_item, storage_item) = item.to_ffi();
12565 raw_vec.push(raw_item);
12566 storage.push_storage(storage_item);
12567 }
12568 let ptr = storage.push_vec(raw_vec);
12569 raw.planes = ptr;
12570 raw.planeCount = len_value;
12571 } else {
12572 raw.planes = std::ptr::null();
12573 raw.planeCount = 0;
12574 }
12575 (raw, storage)
12576 }
12577 pub(crate) fn from_ffi(
12578 value: ffi::WGPUSharedTextureMemoryDmaBufDescriptor,
12579 ) -> Self {
12580 Self {
12581 size: Some(Extent3D::from_ffi(value.size)),
12582 drm_format: Some(value.drmFormat),
12583 drm_modifier: Some(value.drmModifier),
12584 planes: if value.planes.is_null() {
12585 None
12586 } else {
12587 Some(
12588 unsafe {
12589 std::slice::from_raw_parts(
12590 value.planes,
12591 value.planeCount as usize,
12592 )
12593 }
12594 .iter()
12595 .map(|raw| SharedTextureMemoryDmaBufPlane::from_ffi(*raw))
12596 .collect(),
12597 )
12598 },
12599 }
12600 }
12601 }
12602 pub struct SharedTextureMemoryDmaBufPlane {
12603 pub fd: Option<i32>,
12604 pub offset: Option<u64>,
12605 pub stride: Option<u32>,
12606 }
12607 impl Default for SharedTextureMemoryDmaBufPlane {
12608 fn default() -> Self {
12609 Self {
12610 fd: None,
12611 offset: None,
12612 stride: None,
12613 }
12614 }
12615 }
12616 impl SharedTextureMemoryDmaBufPlane {
12617 pub fn new() -> Self {
12618 Self::default()
12619 }
12620 pub(crate) fn to_ffi(
12621 &self,
12622 ) -> (ffi::WGPUSharedTextureMemoryDmaBufPlane, ChainedStructStorage) {
12623 let mut storage = ChainedStructStorage::new();
12624 let mut raw: ffi::WGPUSharedTextureMemoryDmaBufPlane = unsafe {
12625 std::mem::zeroed()
12626 };
12627 if let Some(value) = self.fd {
12628 raw.fd = value;
12629 }
12630 if let Some(value) = self.offset {
12631 raw.offset = value;
12632 }
12633 if let Some(value) = self.stride {
12634 raw.stride = value;
12635 }
12636 (raw, storage)
12637 }
12638 pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryDmaBufPlane) -> Self {
12639 Self {
12640 fd: Some(value.fd),
12641 offset: Some(value.offset),
12642 stride: Some(value.stride),
12643 }
12644 }
12645 }
12646 pub struct SharedTextureMemoryEndAccessState {
12647 pub(crate) extensions: Vec<SharedTextureMemoryEndAccessStateExtension>,
12648 pub initialized: Option<bool>,
12649 pub fences: Option<Vec<SharedFence>>,
12650 pub signaled_values: Option<Vec<u64>>,
12651 #[doc(hidden)]
12652 pub(crate) _free_members: Option<ffi::WGPUSharedTextureMemoryEndAccessState>,
12653 }
12654 impl Default for SharedTextureMemoryEndAccessState {
12655 fn default() -> Self {
12656 Self {
12657 extensions: Vec::new(),
12658 initialized: None,
12659 fences: None,
12660 signaled_values: None,
12661 _free_members: None,
12662 }
12663 }
12664 }
12665 impl SharedTextureMemoryEndAccessState {
12666 pub fn new() -> Self {
12667 Self::default()
12668 }
12669 pub(crate) fn to_ffi(
12670 &self,
12671 ) -> (ffi::WGPUSharedTextureMemoryEndAccessState, ChainedStructStorage) {
12672 let mut storage = ChainedStructStorage::new();
12673 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12674 for ext in self.extensions.iter().rev() {
12675 next = ext.push_chain(&mut storage, next);
12676 }
12677 let mut raw: ffi::WGPUSharedTextureMemoryEndAccessState = unsafe {
12678 std::mem::zeroed()
12679 };
12680 raw.nextInChain = next;
12681 raw.initialized = if self.initialized.unwrap_or(false) { 1 } else { 0 };
12682 raw.fenceCount = self.signaled_values.as_ref().map(|v| v.len()).unwrap_or(0);
12683 if let Some(values) = &self.fences {
12684 let len_value = values.len();
12685 let raw_vec: Vec<ffi::WGPUSharedFence> = values
12686 .iter()
12687 .map(|v| v.as_raw())
12688 .collect();
12689 let ptr = storage.push_vec(raw_vec);
12690 raw.fences = ptr;
12691 raw.fenceCount = len_value;
12692 } else {
12693 raw.fences = std::ptr::null();
12694 raw.fenceCount = 0;
12695 }
12696 if let Some(values) = &self.signaled_values {
12697 let len_value = values.len();
12698 let raw_vec = values.to_vec();
12699 let ptr = storage.push_vec(raw_vec);
12700 raw.signaledValues = ptr;
12701 raw.fenceCount = len_value;
12702 } else {
12703 raw.signaledValues = std::ptr::null();
12704 raw.fenceCount = 0;
12705 }
12706 (raw, storage)
12707 }
12708 pub fn with_extension(
12709 mut self,
12710 extension: SharedTextureMemoryEndAccessStateExtension,
12711 ) -> Self {
12712 self.extensions.push(extension);
12713 self
12714 }
12715 pub(crate) fn from_ffi(
12716 value: ffi::WGPUSharedTextureMemoryEndAccessState,
12717 ) -> Self {
12718 Self {
12719 extensions: Vec::new(),
12720 initialized: Some(value.initialized != 0),
12721 fences: if value.fences.is_null() {
12722 None
12723 } else {
12724 Some(
12725 unsafe {
12726 std::slice::from_raw_parts(
12727 value.fences,
12728 value.fenceCount as usize,
12729 )
12730 }
12731 .iter()
12732 .map(|raw| unsafe { SharedFence::from_raw(*raw) })
12733 .collect(),
12734 )
12735 },
12736 signaled_values: if value.signaledValues.is_null() {
12737 None
12738 } else {
12739 Some(
12740 unsafe {
12741 std::slice::from_raw_parts(
12742 value.signaledValues,
12743 value.fenceCount as usize,
12744 )
12745 }
12746 .to_vec(),
12747 )
12748 },
12749 _free_members: Some(value),
12750 }
12751 }
12752 pub(crate) fn free_members(value: ffi::WGPUSharedTextureMemoryEndAccessState) {
12753 unsafe { ffi::wgpuSharedTextureMemoryEndAccessStateFreeMembers(value) };
12754 }
12755 }
12756 impl Drop for SharedTextureMemoryEndAccessState {
12757 fn drop(&mut self) {
12758 if let Some(value) = self._free_members.take() {
12759 unsafe { ffi::wgpuSharedTextureMemoryEndAccessStateFreeMembers(value) };
12760 }
12761 }
12762 }
12763 pub struct SharedTextureMemoryMetalEndAccessState {
12764 pub commands_scheduled_future: Option<Future>,
12765 }
12766 impl Default for SharedTextureMemoryMetalEndAccessState {
12767 fn default() -> Self {
12768 Self {
12769 commands_scheduled_future: None,
12770 }
12771 }
12772 }
12773 impl SharedTextureMemoryMetalEndAccessState {
12774 pub fn new() -> Self {
12775 Self::default()
12776 }
12777 pub(crate) fn to_ffi(
12778 &self,
12779 ) -> (ffi::WGPUSharedTextureMemoryMetalEndAccessState, ChainedStructStorage) {
12780 let mut storage = ChainedStructStorage::new();
12781 let mut raw: ffi::WGPUSharedTextureMemoryMetalEndAccessState = unsafe {
12782 std::mem::zeroed()
12783 };
12784 if let Some(value) = &self.commands_scheduled_future {
12785 let (raw_value, storage_value) = value.to_ffi();
12786 raw.commandsScheduledFuture = raw_value;
12787 storage.push_storage(storage_value);
12788 }
12789 (raw, storage)
12790 }
12791 pub(crate) fn from_ffi(
12792 value: ffi::WGPUSharedTextureMemoryMetalEndAccessState,
12793 ) -> Self {
12794 Self {
12795 commands_scheduled_future: Some(
12796 Future::from_ffi(value.commandsScheduledFuture),
12797 ),
12798 }
12799 }
12800 }
12801 pub struct SharedTextureMemoryOpaqueFDDescriptor {
12802 pub vk_image_create_info: Option<*const std::ffi::c_void>,
12803 pub memory_fd: Option<i32>,
12804 pub memory_type_index: Option<u32>,
12805 pub allocation_size: Option<u64>,
12806 pub dedicated_allocation: Option<bool>,
12807 }
12808 impl Default for SharedTextureMemoryOpaqueFDDescriptor {
12809 fn default() -> Self {
12810 Self {
12811 vk_image_create_info: None,
12812 memory_fd: None,
12813 memory_type_index: None,
12814 allocation_size: None,
12815 dedicated_allocation: None,
12816 }
12817 }
12818 }
12819 impl SharedTextureMemoryOpaqueFDDescriptor {
12820 pub fn new() -> Self {
12821 Self::default()
12822 }
12823 pub(crate) fn to_ffi(
12824 &self,
12825 ) -> (ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor, ChainedStructStorage) {
12826 let mut storage = ChainedStructStorage::new();
12827 let mut raw: ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor = unsafe {
12828 std::mem::zeroed()
12829 };
12830 if let Some(value) = self.vk_image_create_info {
12831 raw.vkImageCreateInfo = value;
12832 }
12833 if let Some(value) = self.memory_fd {
12834 raw.memoryFD = value;
12835 }
12836 if let Some(value) = self.memory_type_index {
12837 raw.memoryTypeIndex = value;
12838 }
12839 if let Some(value) = self.allocation_size {
12840 raw.allocationSize = value;
12841 }
12842 raw.dedicatedAllocation = if self.dedicated_allocation.unwrap_or(false) {
12843 1
12844 } else {
12845 0
12846 };
12847 (raw, storage)
12848 }
12849 pub(crate) fn from_ffi(
12850 value: ffi::WGPUSharedTextureMemoryOpaqueFDDescriptor,
12851 ) -> Self {
12852 Self {
12853 vk_image_create_info: Some(value.vkImageCreateInfo),
12854 memory_fd: Some(value.memoryFD),
12855 memory_type_index: Some(value.memoryTypeIndex),
12856 allocation_size: Some(value.allocationSize),
12857 dedicated_allocation: Some(value.dedicatedAllocation != 0),
12858 }
12859 }
12860 }
12861 pub struct SharedTextureMemoryProperties {
12862 pub(crate) extensions: Vec<SharedTextureMemoryPropertiesExtension>,
12863 pub usage: Option<TextureUsage>,
12864 pub size: Option<Extent3D>,
12865 pub format: Option<TextureFormat>,
12866 }
12867 impl Default for SharedTextureMemoryProperties {
12868 fn default() -> Self {
12869 Self {
12870 extensions: Vec::new(),
12871 usage: None,
12872 size: None,
12873 format: None,
12874 }
12875 }
12876 }
12877 impl SharedTextureMemoryProperties {
12878 pub fn new() -> Self {
12879 Self::default()
12880 }
12881 pub(crate) fn to_ffi(
12882 &self,
12883 ) -> (ffi::WGPUSharedTextureMemoryProperties, ChainedStructStorage) {
12884 let mut storage = ChainedStructStorage::new();
12885 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
12886 for ext in self.extensions.iter().rev() {
12887 next = ext.push_chain(&mut storage, next);
12888 }
12889 let mut raw: ffi::WGPUSharedTextureMemoryProperties = unsafe {
12890 std::mem::zeroed()
12891 };
12892 raw.nextInChain = next;
12893 if let Some(value) = self.usage {
12894 raw.usage = value.into();
12895 } else {
12896 raw.usage = 0 as ffi::WGPUTextureUsage;
12897 }
12898 if let Some(value) = &self.size {
12899 let (raw_value, storage_value) = value.to_ffi();
12900 raw.size = raw_value;
12901 storage.push_storage(storage_value);
12902 }
12903 if let Some(value) = self.format {
12904 raw.format = value.into();
12905 } else {
12906 raw.format = 0 as ffi::WGPUTextureFormat;
12907 }
12908 (raw, storage)
12909 }
12910 pub fn with_extension(
12911 mut self,
12912 extension: SharedTextureMemoryPropertiesExtension,
12913 ) -> Self {
12914 self.extensions.push(extension);
12915 self
12916 }
12917 pub(crate) fn from_ffi(value: ffi::WGPUSharedTextureMemoryProperties) -> Self {
12918 Self {
12919 extensions: Vec::new(),
12920 usage: Some(value.usage.into()),
12921 size: Some(Extent3D::from_ffi(value.size)),
12922 format: Some(value.format.into()),
12923 }
12924 }
12925 }
12926 pub struct SharedTextureMemoryVkDedicatedAllocationDescriptor {
12927 pub dedicated_allocation: Option<bool>,
12928 }
12929 impl Default for SharedTextureMemoryVkDedicatedAllocationDescriptor {
12930 fn default() -> Self {
12931 Self { dedicated_allocation: None }
12932 }
12933 }
12934 impl SharedTextureMemoryVkDedicatedAllocationDescriptor {
12935 pub fn new() -> Self {
12936 Self::default()
12937 }
12938 pub(crate) fn to_ffi(
12939 &self,
12940 ) -> (
12941 ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor,
12942 ChainedStructStorage,
12943 ) {
12944 let mut storage = ChainedStructStorage::new();
12945 let mut raw: ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor = unsafe {
12946 std::mem::zeroed()
12947 };
12948 raw.dedicatedAllocation = if self.dedicated_allocation.unwrap_or(false) {
12949 1
12950 } else {
12951 0
12952 };
12953 (raw, storage)
12954 }
12955 pub(crate) fn from_ffi(
12956 value: ffi::WGPUSharedTextureMemoryVkDedicatedAllocationDescriptor,
12957 ) -> Self {
12958 Self {
12959 dedicated_allocation: Some(value.dedicatedAllocation != 0),
12960 }
12961 }
12962 }
12963 pub struct SharedTextureMemoryVkImageLayoutBeginState {
12964 pub old_layout: Option<i32>,
12965 pub new_layout: Option<i32>,
12966 }
12967 impl Default for SharedTextureMemoryVkImageLayoutBeginState {
12968 fn default() -> Self {
12969 Self {
12970 old_layout: None,
12971 new_layout: None,
12972 }
12973 }
12974 }
12975 impl SharedTextureMemoryVkImageLayoutBeginState {
12976 pub fn new() -> Self {
12977 Self::default()
12978 }
12979 pub(crate) fn to_ffi(
12980 &self,
12981 ) -> (
12982 ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState,
12983 ChainedStructStorage,
12984 ) {
12985 let mut storage = ChainedStructStorage::new();
12986 let mut raw: ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState = unsafe {
12987 std::mem::zeroed()
12988 };
12989 if let Some(value) = self.old_layout {
12990 raw.oldLayout = value;
12991 }
12992 if let Some(value) = self.new_layout {
12993 raw.newLayout = value;
12994 }
12995 (raw, storage)
12996 }
12997 pub(crate) fn from_ffi(
12998 value: ffi::WGPUSharedTextureMemoryVkImageLayoutBeginState,
12999 ) -> Self {
13000 Self {
13001 old_layout: Some(value.oldLayout),
13002 new_layout: Some(value.newLayout),
13003 }
13004 }
13005 }
13006 pub struct SharedTextureMemoryVkImageLayoutEndState {
13007 pub old_layout: Option<i32>,
13008 pub new_layout: Option<i32>,
13009 }
13010 impl Default for SharedTextureMemoryVkImageLayoutEndState {
13011 fn default() -> Self {
13012 Self {
13013 old_layout: None,
13014 new_layout: None,
13015 }
13016 }
13017 }
13018 impl SharedTextureMemoryVkImageLayoutEndState {
13019 pub fn new() -> Self {
13020 Self::default()
13021 }
13022 pub(crate) fn to_ffi(
13023 &self,
13024 ) -> (ffi::WGPUSharedTextureMemoryVkImageLayoutEndState, ChainedStructStorage) {
13025 let mut storage = ChainedStructStorage::new();
13026 let mut raw: ffi::WGPUSharedTextureMemoryVkImageLayoutEndState = unsafe {
13027 std::mem::zeroed()
13028 };
13029 if let Some(value) = self.old_layout {
13030 raw.oldLayout = value;
13031 }
13032 if let Some(value) = self.new_layout {
13033 raw.newLayout = value;
13034 }
13035 (raw, storage)
13036 }
13037 pub(crate) fn from_ffi(
13038 value: ffi::WGPUSharedTextureMemoryVkImageLayoutEndState,
13039 ) -> Self {
13040 Self {
13041 old_layout: Some(value.oldLayout),
13042 new_layout: Some(value.newLayout),
13043 }
13044 }
13045 }
13046 pub struct SharedTextureMemoryZirconHandleDescriptor {
13047 pub memory_fd: Option<u32>,
13048 pub allocation_size: Option<u64>,
13049 }
13050 impl Default for SharedTextureMemoryZirconHandleDescriptor {
13051 fn default() -> Self {
13052 Self {
13053 memory_fd: None,
13054 allocation_size: None,
13055 }
13056 }
13057 }
13058 impl SharedTextureMemoryZirconHandleDescriptor {
13059 pub fn new() -> Self {
13060 Self::default()
13061 }
13062 pub(crate) fn to_ffi(
13063 &self,
13064 ) -> (ffi::WGPUSharedTextureMemoryZirconHandleDescriptor, ChainedStructStorage) {
13065 let mut storage = ChainedStructStorage::new();
13066 let mut raw: ffi::WGPUSharedTextureMemoryZirconHandleDescriptor = unsafe {
13067 std::mem::zeroed()
13068 };
13069 if let Some(value) = self.memory_fd {
13070 raw.memoryFD = value;
13071 }
13072 if let Some(value) = self.allocation_size {
13073 raw.allocationSize = value;
13074 }
13075 (raw, storage)
13076 }
13077 pub(crate) fn from_ffi(
13078 value: ffi::WGPUSharedTextureMemoryZirconHandleDescriptor,
13079 ) -> Self {
13080 Self {
13081 memory_fd: Some(value.memoryFD),
13082 allocation_size: Some(value.allocationSize),
13083 }
13084 }
13085 }
13086 pub struct StaticSamplerBindingLayout {
13087 pub sampler: Option<Sampler>,
13088 pub sampled_texture_binding: Option<u32>,
13089 }
13090 impl Default for StaticSamplerBindingLayout {
13091 fn default() -> Self {
13092 Self {
13093 sampler: None,
13094 sampled_texture_binding: Some(LIMIT_U32_UNDEFINED),
13095 }
13096 }
13097 }
13098 impl StaticSamplerBindingLayout {
13099 pub fn new() -> Self {
13100 Self::default()
13101 }
13102 pub(crate) fn to_ffi(
13103 &self,
13104 ) -> (ffi::WGPUStaticSamplerBindingLayout, ChainedStructStorage) {
13105 let mut storage = ChainedStructStorage::new();
13106 let mut raw: ffi::WGPUStaticSamplerBindingLayout = unsafe {
13107 std::mem::zeroed()
13108 };
13109 raw.sampler = self
13110 .sampler
13111 .as_ref()
13112 .map(|v| v.as_raw())
13113 .unwrap_or(std::ptr::null_mut());
13114 if let Some(value) = self.sampled_texture_binding {
13115 raw.sampledTextureBinding = value;
13116 }
13117 (raw, storage)
13118 }
13119 pub(crate) fn from_ffi(value: ffi::WGPUStaticSamplerBindingLayout) -> Self {
13120 Self {
13121 sampler: Some(unsafe { Sampler::from_raw(value.sampler) }),
13122 sampled_texture_binding: Some(value.sampledTextureBinding),
13123 }
13124 }
13125 }
13126 pub struct StencilFaceState {
13127 pub compare: Option<CompareFunction>,
13128 pub fail_op: Option<StencilOperation>,
13129 pub depth_fail_op: Option<StencilOperation>,
13130 pub pass_op: Option<StencilOperation>,
13131 }
13132 impl Default for StencilFaceState {
13133 fn default() -> Self {
13134 Self {
13135 compare: Some(CompareFunction::Always),
13136 fail_op: Some(StencilOperation::Keep),
13137 depth_fail_op: Some(StencilOperation::Keep),
13138 pass_op: Some(StencilOperation::Keep),
13139 }
13140 }
13141 }
13142 impl StencilFaceState {
13143 pub fn new() -> Self {
13144 Self::default()
13145 }
13146 pub(crate) fn to_ffi(
13147 &self,
13148 ) -> (ffi::WGPUStencilFaceState, ChainedStructStorage) {
13149 let mut storage = ChainedStructStorage::new();
13150 let mut raw: ffi::WGPUStencilFaceState = unsafe { std::mem::zeroed() };
13151 if let Some(value) = self.compare {
13152 raw.compare = value.into();
13153 } else {
13154 raw.compare = 0 as ffi::WGPUCompareFunction;
13155 }
13156 if let Some(value) = self.fail_op {
13157 raw.failOp = value.into();
13158 } else {
13159 raw.failOp = 0 as ffi::WGPUStencilOperation;
13160 }
13161 if let Some(value) = self.depth_fail_op {
13162 raw.depthFailOp = value.into();
13163 } else {
13164 raw.depthFailOp = 0 as ffi::WGPUStencilOperation;
13165 }
13166 if let Some(value) = self.pass_op {
13167 raw.passOp = value.into();
13168 } else {
13169 raw.passOp = 0 as ffi::WGPUStencilOperation;
13170 }
13171 (raw, storage)
13172 }
13173 pub(crate) fn from_ffi(value: ffi::WGPUStencilFaceState) -> Self {
13174 Self {
13175 compare: Some(value.compare.into()),
13176 fail_op: Some(value.failOp.into()),
13177 depth_fail_op: Some(value.depthFailOp.into()),
13178 pass_op: Some(value.passOp.into()),
13179 }
13180 }
13181 }
13182 pub struct StorageTextureBindingLayout {
13183 pub(crate) extensions: Vec<StorageTextureBindingLayoutExtension>,
13184 pub access: Option<StorageTextureAccess>,
13185 pub format: Option<TextureFormat>,
13186 pub view_dimension: Option<TextureViewDimension>,
13187 }
13188 impl Default for StorageTextureBindingLayout {
13189 fn default() -> Self {
13190 Self {
13191 extensions: Vec::new(),
13192 access: Some(StorageTextureAccess::WriteOnly),
13193 format: None,
13194 view_dimension: Some(TextureViewDimension::D2),
13195 }
13196 }
13197 }
13198 impl StorageTextureBindingLayout {
13199 pub fn new() -> Self {
13200 Self::default()
13201 }
13202 pub(crate) fn to_ffi(
13203 &self,
13204 ) -> (ffi::WGPUStorageTextureBindingLayout, ChainedStructStorage) {
13205 let mut storage = ChainedStructStorage::new();
13206 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13207 for ext in self.extensions.iter().rev() {
13208 next = ext.push_chain(&mut storage, next);
13209 }
13210 let mut raw: ffi::WGPUStorageTextureBindingLayout = unsafe {
13211 std::mem::zeroed()
13212 };
13213 raw.nextInChain = next;
13214 if let Some(value) = self.access {
13215 raw.access = value.into();
13216 } else {
13217 raw.access = 0 as ffi::WGPUStorageTextureAccess;
13218 }
13219 if let Some(value) = self.format {
13220 raw.format = value.into();
13221 } else {
13222 raw.format = 0 as ffi::WGPUTextureFormat;
13223 }
13224 if let Some(value) = self.view_dimension {
13225 raw.viewDimension = value.into();
13226 } else {
13227 raw.viewDimension = 0 as ffi::WGPUTextureViewDimension;
13228 }
13229 (raw, storage)
13230 }
13231 pub fn with_extension(
13232 mut self,
13233 extension: StorageTextureBindingLayoutExtension,
13234 ) -> Self {
13235 self.extensions.push(extension);
13236 self
13237 }
13238 pub(crate) fn from_ffi(value: ffi::WGPUStorageTextureBindingLayout) -> Self {
13239 Self {
13240 extensions: Vec::new(),
13241 access: Some(value.access.into()),
13242 format: Some(value.format.into()),
13243 view_dimension: Some(value.viewDimension.into()),
13244 }
13245 }
13246 }
13247 pub struct StringView {
13248 pub data: Option<*const std::os::raw::c_char>,
13249 pub length: Option<usize>,
13250 }
13251 impl Default for StringView {
13252 fn default() -> Self {
13253 Self {
13254 data: None,
13255 length: Some(STRLEN),
13256 }
13257 }
13258 }
13259 impl StringView {
13260 pub fn new() -> Self {
13261 Self::default()
13262 }
13263 pub(crate) fn to_ffi(&self) -> (ffi::WGPUStringView, ChainedStructStorage) {
13264 let mut storage = ChainedStructStorage::new();
13265 let mut raw: ffi::WGPUStringView = unsafe { std::mem::zeroed() };
13266 if let Some(value) = self.data {
13267 raw.data = value;
13268 }
13269 if let Some(value) = self.length {
13270 raw.length = value;
13271 }
13272 (raw, storage)
13273 }
13274 pub(crate) fn from_ffi(value: ffi::WGPUStringView) -> Self {
13275 Self {
13276 data: Some(value.data),
13277 length: Some(value.length),
13278 }
13279 }
13280 }
13281 pub struct SubgroupMatrixConfig {
13282 pub component_type: Option<SubgroupMatrixComponentType>,
13283 pub result_component_type: Option<SubgroupMatrixComponentType>,
13284 pub m: Option<u32>,
13285 pub n: Option<u32>,
13286 pub k: Option<u32>,
13287 }
13288 impl Default for SubgroupMatrixConfig {
13289 fn default() -> Self {
13290 Self {
13291 component_type: None,
13292 result_component_type: None,
13293 m: None,
13294 n: None,
13295 k: None,
13296 }
13297 }
13298 }
13299 impl SubgroupMatrixConfig {
13300 pub fn new() -> Self {
13301 Self::default()
13302 }
13303 pub(crate) fn to_ffi(
13304 &self,
13305 ) -> (ffi::WGPUSubgroupMatrixConfig, ChainedStructStorage) {
13306 let mut storage = ChainedStructStorage::new();
13307 let mut raw: ffi::WGPUSubgroupMatrixConfig = unsafe { std::mem::zeroed() };
13308 if let Some(value) = self.component_type {
13309 raw.componentType = value.into();
13310 } else {
13311 raw.componentType = 0 as ffi::WGPUSubgroupMatrixComponentType;
13312 }
13313 if let Some(value) = self.result_component_type {
13314 raw.resultComponentType = value.into();
13315 } else {
13316 raw.resultComponentType = 0 as ffi::WGPUSubgroupMatrixComponentType;
13317 }
13318 if let Some(value) = self.m {
13319 raw.M = value;
13320 }
13321 if let Some(value) = self.n {
13322 raw.N = value;
13323 }
13324 if let Some(value) = self.k {
13325 raw.K = value;
13326 }
13327 (raw, storage)
13328 }
13329 pub(crate) fn from_ffi(value: ffi::WGPUSubgroupMatrixConfig) -> Self {
13330 Self {
13331 component_type: Some(value.componentType.into()),
13332 result_component_type: Some(value.resultComponentType.into()),
13333 m: Some(value.M),
13334 n: Some(value.N),
13335 k: Some(value.K),
13336 }
13337 }
13338 }
13339 pub struct SupportedWGSLLanguageFeatures {
13340 pub features: Option<Vec<WGSLLanguageFeatureName>>,
13341 #[doc(hidden)]
13342 pub(crate) _free_members: Option<ffi::WGPUSupportedWGSLLanguageFeatures>,
13343 }
13344 impl Default for SupportedWGSLLanguageFeatures {
13345 fn default() -> Self {
13346 Self {
13347 features: None,
13348 _free_members: None,
13349 }
13350 }
13351 }
13352 impl SupportedWGSLLanguageFeatures {
13353 pub fn new() -> Self {
13354 Self::default()
13355 }
13356 pub(crate) fn to_ffi(
13357 &self,
13358 ) -> (ffi::WGPUSupportedWGSLLanguageFeatures, ChainedStructStorage) {
13359 let mut storage = ChainedStructStorage::new();
13360 let mut raw: ffi::WGPUSupportedWGSLLanguageFeatures = unsafe {
13361 std::mem::zeroed()
13362 };
13363 raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13364 if let Some(values) = &self.features {
13365 let len_value = values.len();
13366 let raw_vec: Vec<ffi::WGPUWGSLLanguageFeatureName> = values
13367 .iter()
13368 .map(|v| (*v).into())
13369 .collect();
13370 let ptr = storage.push_vec(raw_vec);
13371 raw.features = ptr;
13372 raw.featureCount = len_value;
13373 } else {
13374 raw.features = std::ptr::null();
13375 raw.featureCount = 0;
13376 }
13377 (raw, storage)
13378 }
13379 pub(crate) fn from_ffi(value: ffi::WGPUSupportedWGSLLanguageFeatures) -> Self {
13380 Self {
13381 features: if value.features.is_null() {
13382 None
13383 } else {
13384 Some(
13385 unsafe {
13386 std::slice::from_raw_parts(
13387 value.features,
13388 value.featureCount as usize,
13389 )
13390 }
13391 .iter()
13392 .map(|raw| WGSLLanguageFeatureName::from(*raw))
13393 .collect(),
13394 )
13395 },
13396 _free_members: Some(value),
13397 }
13398 }
13399 pub(crate) fn free_members(value: ffi::WGPUSupportedWGSLLanguageFeatures) {
13400 unsafe { ffi::wgpuSupportedWGSLLanguageFeaturesFreeMembers(value) };
13401 }
13402 }
13403 impl Drop for SupportedWGSLLanguageFeatures {
13404 fn drop(&mut self) {
13405 if let Some(value) = self._free_members.take() {
13406 unsafe { ffi::wgpuSupportedWGSLLanguageFeaturesFreeMembers(value) };
13407 }
13408 }
13409 }
13410 pub struct SupportedFeatures {
13411 pub features: Option<Vec<FeatureName>>,
13412 #[doc(hidden)]
13413 pub(crate) _free_members: Option<ffi::WGPUSupportedFeatures>,
13414 }
13415 impl Default for SupportedFeatures {
13416 fn default() -> Self {
13417 Self {
13418 features: None,
13419 _free_members: None,
13420 }
13421 }
13422 }
13423 impl SupportedFeatures {
13424 pub fn new() -> Self {
13425 Self::default()
13426 }
13427 pub(crate) fn to_ffi(
13428 &self,
13429 ) -> (ffi::WGPUSupportedFeatures, ChainedStructStorage) {
13430 let mut storage = ChainedStructStorage::new();
13431 let mut raw: ffi::WGPUSupportedFeatures = unsafe { std::mem::zeroed() };
13432 raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13433 if let Some(values) = &self.features {
13434 let len_value = values.len();
13435 let raw_vec: Vec<ffi::WGPUFeatureName> = values
13436 .iter()
13437 .map(|v| (*v).into())
13438 .collect();
13439 let ptr = storage.push_vec(raw_vec);
13440 raw.features = ptr;
13441 raw.featureCount = len_value;
13442 } else {
13443 raw.features = std::ptr::null();
13444 raw.featureCount = 0;
13445 }
13446 (raw, storage)
13447 }
13448 pub(crate) fn from_ffi(value: ffi::WGPUSupportedFeatures) -> Self {
13449 Self {
13450 features: if value.features.is_null() {
13451 None
13452 } else {
13453 Some(
13454 unsafe {
13455 std::slice::from_raw_parts(
13456 value.features,
13457 value.featureCount as usize,
13458 )
13459 }
13460 .iter()
13461 .map(|raw| FeatureName::from(*raw))
13462 .collect(),
13463 )
13464 },
13465 _free_members: Some(value),
13466 }
13467 }
13468 pub(crate) fn free_members(value: ffi::WGPUSupportedFeatures) {
13469 unsafe { ffi::wgpuSupportedFeaturesFreeMembers(value) };
13470 }
13471 }
13472 impl Drop for SupportedFeatures {
13473 fn drop(&mut self) {
13474 if let Some(value) = self._free_members.take() {
13475 unsafe { ffi::wgpuSupportedFeaturesFreeMembers(value) };
13476 }
13477 }
13478 }
13479 pub struct SupportedInstanceFeatures {
13480 pub features: Option<Vec<InstanceFeatureName>>,
13481 #[doc(hidden)]
13482 pub(crate) _free_members: Option<ffi::WGPUSupportedInstanceFeatures>,
13483 }
13484 impl Default for SupportedInstanceFeatures {
13485 fn default() -> Self {
13486 Self {
13487 features: None,
13488 _free_members: None,
13489 }
13490 }
13491 }
13492 impl SupportedInstanceFeatures {
13493 pub fn new() -> Self {
13494 Self::default()
13495 }
13496 pub(crate) fn to_ffi(
13497 &self,
13498 ) -> (ffi::WGPUSupportedInstanceFeatures, ChainedStructStorage) {
13499 let mut storage = ChainedStructStorage::new();
13500 let mut raw: ffi::WGPUSupportedInstanceFeatures = unsafe {
13501 std::mem::zeroed()
13502 };
13503 raw.featureCount = self.features.as_ref().map(|v| v.len()).unwrap_or(0);
13504 if let Some(values) = &self.features {
13505 let len_value = values.len();
13506 let raw_vec: Vec<ffi::WGPUInstanceFeatureName> = values
13507 .iter()
13508 .map(|v| (*v).into())
13509 .collect();
13510 let ptr = storage.push_vec(raw_vec);
13511 raw.features = ptr;
13512 raw.featureCount = len_value;
13513 } else {
13514 raw.features = std::ptr::null();
13515 raw.featureCount = 0;
13516 }
13517 (raw, storage)
13518 }
13519 pub(crate) fn from_ffi(value: ffi::WGPUSupportedInstanceFeatures) -> Self {
13520 Self {
13521 features: if value.features.is_null() {
13522 None
13523 } else {
13524 Some(
13525 unsafe {
13526 std::slice::from_raw_parts(
13527 value.features,
13528 value.featureCount as usize,
13529 )
13530 }
13531 .iter()
13532 .map(|raw| InstanceFeatureName::from(*raw))
13533 .collect(),
13534 )
13535 },
13536 _free_members: Some(value),
13537 }
13538 }
13539 pub(crate) fn free_members(value: ffi::WGPUSupportedInstanceFeatures) {
13540 unsafe { ffi::wgpuSupportedInstanceFeaturesFreeMembers(value) };
13541 }
13542 }
13543 impl Drop for SupportedInstanceFeatures {
13544 fn drop(&mut self) {
13545 if let Some(value) = self._free_members.take() {
13546 unsafe { ffi::wgpuSupportedInstanceFeaturesFreeMembers(value) };
13547 }
13548 }
13549 }
13550 pub struct SurfaceCapabilities {
13551 pub(crate) extensions: Vec<SurfaceCapabilitiesExtension>,
13552 pub usages: Option<TextureUsage>,
13553 pub formats: Option<Vec<TextureFormat>>,
13554 pub present_modes: Option<Vec<PresentMode>>,
13555 pub alpha_modes: Option<Vec<CompositeAlphaMode>>,
13556 #[doc(hidden)]
13557 pub(crate) _free_members: Option<ffi::WGPUSurfaceCapabilities>,
13558 }
13559 impl Default for SurfaceCapabilities {
13560 fn default() -> Self {
13561 Self {
13562 extensions: Vec::new(),
13563 usages: None,
13564 formats: None,
13565 present_modes: None,
13566 alpha_modes: None,
13567 _free_members: None,
13568 }
13569 }
13570 }
13571 impl SurfaceCapabilities {
13572 pub fn new() -> Self {
13573 Self::default()
13574 }
13575 pub(crate) fn to_ffi(
13576 &self,
13577 ) -> (ffi::WGPUSurfaceCapabilities, ChainedStructStorage) {
13578 let mut storage = ChainedStructStorage::new();
13579 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13580 for ext in self.extensions.iter().rev() {
13581 next = ext.push_chain(&mut storage, next);
13582 }
13583 let mut raw: ffi::WGPUSurfaceCapabilities = unsafe { std::mem::zeroed() };
13584 raw.nextInChain = next;
13585 if let Some(value) = self.usages {
13586 raw.usages = value.into();
13587 } else {
13588 raw.usages = 0 as ffi::WGPUTextureUsage;
13589 }
13590 raw.formatCount = self.formats.as_ref().map(|v| v.len()).unwrap_or(0);
13591 if let Some(values) = &self.formats {
13592 let len_value = values.len();
13593 let raw_vec: Vec<ffi::WGPUTextureFormat> = values
13594 .iter()
13595 .map(|v| (*v).into())
13596 .collect();
13597 let ptr = storage.push_vec(raw_vec);
13598 raw.formats = ptr;
13599 raw.formatCount = len_value;
13600 } else {
13601 raw.formats = std::ptr::null();
13602 raw.formatCount = 0;
13603 }
13604 raw.presentModeCount = self
13605 .present_modes
13606 .as_ref()
13607 .map(|v| v.len())
13608 .unwrap_or(0);
13609 if let Some(values) = &self.present_modes {
13610 let len_value = values.len();
13611 let raw_vec: Vec<ffi::WGPUPresentMode> = values
13612 .iter()
13613 .map(|v| (*v).into())
13614 .collect();
13615 let ptr = storage.push_vec(raw_vec);
13616 raw.presentModes = ptr;
13617 raw.presentModeCount = len_value;
13618 } else {
13619 raw.presentModes = std::ptr::null();
13620 raw.presentModeCount = 0;
13621 }
13622 raw.alphaModeCount = self.alpha_modes.as_ref().map(|v| v.len()).unwrap_or(0);
13623 if let Some(values) = &self.alpha_modes {
13624 let len_value = values.len();
13625 let raw_vec: Vec<ffi::WGPUCompositeAlphaMode> = values
13626 .iter()
13627 .map(|v| (*v).into())
13628 .collect();
13629 let ptr = storage.push_vec(raw_vec);
13630 raw.alphaModes = ptr;
13631 raw.alphaModeCount = len_value;
13632 } else {
13633 raw.alphaModes = std::ptr::null();
13634 raw.alphaModeCount = 0;
13635 }
13636 (raw, storage)
13637 }
13638 pub fn with_extension(
13639 mut self,
13640 extension: SurfaceCapabilitiesExtension,
13641 ) -> Self {
13642 self.extensions.push(extension);
13643 self
13644 }
13645 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceCapabilities) -> Self {
13646 Self {
13647 extensions: Vec::new(),
13648 usages: Some(value.usages.into()),
13649 formats: if value.formats.is_null() {
13650 None
13651 } else {
13652 Some(
13653 unsafe {
13654 std::slice::from_raw_parts(
13655 value.formats,
13656 value.formatCount as usize,
13657 )
13658 }
13659 .iter()
13660 .map(|raw| TextureFormat::from(*raw))
13661 .collect(),
13662 )
13663 },
13664 present_modes: if value.presentModes.is_null() {
13665 None
13666 } else {
13667 Some(
13668 unsafe {
13669 std::slice::from_raw_parts(
13670 value.presentModes,
13671 value.presentModeCount as usize,
13672 )
13673 }
13674 .iter()
13675 .map(|raw| PresentMode::from(*raw))
13676 .collect(),
13677 )
13678 },
13679 alpha_modes: if value.alphaModes.is_null() {
13680 None
13681 } else {
13682 Some(
13683 unsafe {
13684 std::slice::from_raw_parts(
13685 value.alphaModes,
13686 value.alphaModeCount as usize,
13687 )
13688 }
13689 .iter()
13690 .map(|raw| CompositeAlphaMode::from(*raw))
13691 .collect(),
13692 )
13693 },
13694 _free_members: Some(value),
13695 }
13696 }
13697 pub(crate) fn free_members(value: ffi::WGPUSurfaceCapabilities) {
13698 unsafe { ffi::wgpuSurfaceCapabilitiesFreeMembers(value) };
13699 }
13700 }
13701 impl Drop for SurfaceCapabilities {
13702 fn drop(&mut self) {
13703 if let Some(value) = self._free_members.take() {
13704 unsafe { ffi::wgpuSurfaceCapabilitiesFreeMembers(value) };
13705 }
13706 }
13707 }
13708 pub struct SurfaceColorManagement {
13709 pub color_space: Option<PredefinedColorSpace>,
13710 pub tone_mapping_mode: Option<ToneMappingMode>,
13711 }
13712 impl Default for SurfaceColorManagement {
13713 fn default() -> Self {
13714 Self {
13715 color_space: None,
13716 tone_mapping_mode: None,
13717 }
13718 }
13719 }
13720 impl SurfaceColorManagement {
13721 pub fn new() -> Self {
13722 Self::default()
13723 }
13724 pub(crate) fn to_ffi(
13725 &self,
13726 ) -> (ffi::WGPUSurfaceColorManagement, ChainedStructStorage) {
13727 let mut storage = ChainedStructStorage::new();
13728 let mut raw: ffi::WGPUSurfaceColorManagement = unsafe { std::mem::zeroed() };
13729 if let Some(value) = self.color_space {
13730 raw.colorSpace = value.into();
13731 } else {
13732 raw.colorSpace = 0 as ffi::WGPUPredefinedColorSpace;
13733 }
13734 if let Some(value) = self.tone_mapping_mode {
13735 raw.toneMappingMode = value.into();
13736 } else {
13737 raw.toneMappingMode = 0 as ffi::WGPUToneMappingMode;
13738 }
13739 (raw, storage)
13740 }
13741 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceColorManagement) -> Self {
13742 Self {
13743 color_space: Some(value.colorSpace.into()),
13744 tone_mapping_mode: Some(value.toneMappingMode.into()),
13745 }
13746 }
13747 }
13748 pub struct SurfaceConfiguration {
13749 pub(crate) extensions: Vec<SurfaceConfigurationExtension>,
13750 pub device: Option<Device>,
13751 pub format: Option<TextureFormat>,
13752 pub usage: Option<TextureUsage>,
13753 pub width: Option<u32>,
13754 pub height: Option<u32>,
13755 pub view_formats: Option<Vec<TextureFormat>>,
13756 pub alpha_mode: Option<CompositeAlphaMode>,
13757 pub present_mode: Option<PresentMode>,
13758 }
13759 impl Default for SurfaceConfiguration {
13760 fn default() -> Self {
13761 Self {
13762 extensions: Vec::new(),
13763 device: None,
13764 format: None,
13765 usage: Some(TextureUsage::RENDER_ATTACHMENT),
13766 width: None,
13767 height: None,
13768 view_formats: None,
13769 alpha_mode: Some(CompositeAlphaMode::Auto),
13770 present_mode: Some(PresentMode::Fifo),
13771 }
13772 }
13773 }
13774 impl SurfaceConfiguration {
13775 pub fn new() -> Self {
13776 Self::default()
13777 }
13778 pub(crate) fn to_ffi(
13779 &self,
13780 ) -> (ffi::WGPUSurfaceConfiguration, ChainedStructStorage) {
13781 let mut storage = ChainedStructStorage::new();
13782 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13783 for ext in self.extensions.iter().rev() {
13784 next = ext.push_chain(&mut storage, next);
13785 }
13786 let mut raw: ffi::WGPUSurfaceConfiguration = unsafe { std::mem::zeroed() };
13787 raw.nextInChain = next;
13788 raw.device = self
13789 .device
13790 .as_ref()
13791 .map(|v| v.as_raw())
13792 .unwrap_or(std::ptr::null_mut());
13793 if let Some(value) = self.format {
13794 raw.format = value.into();
13795 } else {
13796 raw.format = 0 as ffi::WGPUTextureFormat;
13797 }
13798 if let Some(value) = self.usage {
13799 raw.usage = value.into();
13800 } else {
13801 raw.usage = 0 as ffi::WGPUTextureUsage;
13802 }
13803 if let Some(value) = self.width {
13804 raw.width = value;
13805 }
13806 if let Some(value) = self.height {
13807 raw.height = value;
13808 }
13809 raw.viewFormatCount = self
13810 .view_formats
13811 .as_ref()
13812 .map(|v| v.len())
13813 .unwrap_or(0);
13814 if let Some(values) = &self.view_formats {
13815 let len_value = values.len();
13816 let raw_vec: Vec<ffi::WGPUTextureFormat> = values
13817 .iter()
13818 .map(|v| (*v).into())
13819 .collect();
13820 let ptr = storage.push_vec(raw_vec);
13821 raw.viewFormats = ptr;
13822 raw.viewFormatCount = len_value;
13823 } else {
13824 raw.viewFormats = std::ptr::null();
13825 raw.viewFormatCount = 0;
13826 }
13827 if let Some(value) = self.alpha_mode {
13828 raw.alphaMode = value.into();
13829 } else {
13830 raw.alphaMode = 0 as ffi::WGPUCompositeAlphaMode;
13831 }
13832 if let Some(value) = self.present_mode {
13833 raw.presentMode = value.into();
13834 } else {
13835 raw.presentMode = 0 as ffi::WGPUPresentMode;
13836 }
13837 (raw, storage)
13838 }
13839 pub fn with_extension(
13840 mut self,
13841 extension: SurfaceConfigurationExtension,
13842 ) -> Self {
13843 self.extensions.push(extension);
13844 self
13845 }
13846 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceConfiguration) -> Self {
13847 Self {
13848 extensions: Vec::new(),
13849 device: Some(unsafe { Device::from_raw(value.device) }),
13850 format: Some(value.format.into()),
13851 usage: Some(value.usage.into()),
13852 width: Some(value.width),
13853 height: Some(value.height),
13854 view_formats: if value.viewFormats.is_null() {
13855 None
13856 } else {
13857 Some(
13858 unsafe {
13859 std::slice::from_raw_parts(
13860 value.viewFormats,
13861 value.viewFormatCount as usize,
13862 )
13863 }
13864 .iter()
13865 .map(|raw| TextureFormat::from(*raw))
13866 .collect(),
13867 )
13868 },
13869 alpha_mode: Some(value.alphaMode.into()),
13870 present_mode: Some(value.presentMode.into()),
13871 }
13872 }
13873 }
13874 pub struct SurfaceDescriptor {
13875 pub(crate) extensions: Vec<SurfaceDescriptorExtension>,
13876 pub label: Option<String>,
13877 }
13878 impl Default for SurfaceDescriptor {
13879 fn default() -> Self {
13880 Self {
13881 extensions: Vec::new(),
13882 label: None,
13883 }
13884 }
13885 }
13886 impl SurfaceDescriptor {
13887 pub fn new() -> Self {
13888 Self::default()
13889 }
13890 pub(crate) fn to_ffi(
13891 &self,
13892 ) -> (ffi::WGPUSurfaceDescriptor, ChainedStructStorage) {
13893 let mut storage = ChainedStructStorage::new();
13894 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
13895 for ext in self.extensions.iter().rev() {
13896 next = ext.push_chain(&mut storage, next);
13897 }
13898 let mut raw: ffi::WGPUSurfaceDescriptor = unsafe { std::mem::zeroed() };
13899 raw.nextInChain = next;
13900 if let Some(value) = &self.label {
13901 raw.label = ffi::WGPUStringView {
13902 data: value.as_ptr().cast(),
13903 length: value.len(),
13904 };
13905 } else {
13906 raw.label = ffi::WGPUStringView {
13907 data: std::ptr::null(),
13908 length: 0,
13909 };
13910 }
13911 (raw, storage)
13912 }
13913 pub fn with_extension(mut self, extension: SurfaceDescriptorExtension) -> Self {
13914 self.extensions.push(extension);
13915 self
13916 }
13917 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceDescriptor) -> Self {
13918 Self {
13919 extensions: Vec::new(),
13920 label: if value.label.data.is_null() || value.label.length == 0 {
13921 None
13922 } else {
13923 Some(string_view_to_string(value.label))
13924 },
13925 }
13926 }
13927 }
13928 pub struct SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13929 pub swap_chain_panel: Option<*mut std::ffi::c_void>,
13930 }
13931 impl Default for SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13932 fn default() -> Self {
13933 Self { swap_chain_panel: None }
13934 }
13935 }
13936 impl SurfaceDescriptorFromWindowsUWPSwapChainPanel {
13937 pub fn new() -> Self {
13938 Self::default()
13939 }
13940 pub(crate) fn to_ffi(
13941 &self,
13942 ) -> (
13943 ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel,
13944 ChainedStructStorage,
13945 ) {
13946 let mut storage = ChainedStructStorage::new();
13947 let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel = unsafe {
13948 std::mem::zeroed()
13949 };
13950 if let Some(value) = self.swap_chain_panel {
13951 raw.swapChainPanel = value;
13952 }
13953 (raw, storage)
13954 }
13955 pub(crate) fn from_ffi(
13956 value: ffi::WGPUSurfaceDescriptorFromWindowsUWPSwapChainPanel,
13957 ) -> Self {
13958 Self {
13959 swap_chain_panel: Some(value.swapChainPanel),
13960 }
13961 }
13962 }
13963 pub struct SurfaceDescriptorFromWindowsWinUISwapChainPanel {
13964 pub swap_chain_panel: Option<*mut std::ffi::c_void>,
13965 }
13966 impl Default for SurfaceDescriptorFromWindowsWinUISwapChainPanel {
13967 fn default() -> Self {
13968 Self { swap_chain_panel: None }
13969 }
13970 }
13971 impl SurfaceDescriptorFromWindowsWinUISwapChainPanel {
13972 pub fn new() -> Self {
13973 Self::default()
13974 }
13975 pub(crate) fn to_ffi(
13976 &self,
13977 ) -> (
13978 ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel,
13979 ChainedStructStorage,
13980 ) {
13981 let mut storage = ChainedStructStorage::new();
13982 let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel = unsafe {
13983 std::mem::zeroed()
13984 };
13985 if let Some(value) = self.swap_chain_panel {
13986 raw.swapChainPanel = value;
13987 }
13988 (raw, storage)
13989 }
13990 pub(crate) fn from_ffi(
13991 value: ffi::WGPUSurfaceDescriptorFromWindowsWinUISwapChainPanel,
13992 ) -> Self {
13993 Self {
13994 swap_chain_panel: Some(value.swapChainPanel),
13995 }
13996 }
13997 }
13998 pub struct SurfaceDescriptorFromWindowsCoreWindow {
13999 pub core_window: Option<*mut std::ffi::c_void>,
14000 }
14001 impl Default for SurfaceDescriptorFromWindowsCoreWindow {
14002 fn default() -> Self {
14003 Self { core_window: None }
14004 }
14005 }
14006 impl SurfaceDescriptorFromWindowsCoreWindow {
14007 pub fn new() -> Self {
14008 Self::default()
14009 }
14010 pub(crate) fn to_ffi(
14011 &self,
14012 ) -> (ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow, ChainedStructStorage) {
14013 let mut storage = ChainedStructStorage::new();
14014 let mut raw: ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow = unsafe {
14015 std::mem::zeroed()
14016 };
14017 if let Some(value) = self.core_window {
14018 raw.coreWindow = value;
14019 }
14020 (raw, storage)
14021 }
14022 pub(crate) fn from_ffi(
14023 value: ffi::WGPUSurfaceDescriptorFromWindowsCoreWindow,
14024 ) -> Self {
14025 Self {
14026 core_window: Some(value.coreWindow),
14027 }
14028 }
14029 }
14030 pub struct SurfaceSourceXCBWindow {
14031 pub connection: Option<*mut std::ffi::c_void>,
14032 pub window: Option<u32>,
14033 }
14034 impl Default for SurfaceSourceXCBWindow {
14035 fn default() -> Self {
14036 Self {
14037 connection: None,
14038 window: None,
14039 }
14040 }
14041 }
14042 impl SurfaceSourceXCBWindow {
14043 pub fn new() -> Self {
14044 Self::default()
14045 }
14046 pub(crate) fn to_ffi(
14047 &self,
14048 ) -> (ffi::WGPUSurfaceSourceXCBWindow, ChainedStructStorage) {
14049 let mut storage = ChainedStructStorage::new();
14050 let mut raw: ffi::WGPUSurfaceSourceXCBWindow = unsafe { std::mem::zeroed() };
14051 if let Some(value) = self.connection {
14052 raw.connection = value;
14053 }
14054 if let Some(value) = self.window {
14055 raw.window = value;
14056 }
14057 (raw, storage)
14058 }
14059 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceXCBWindow) -> Self {
14060 Self {
14061 connection: Some(value.connection),
14062 window: Some(value.window),
14063 }
14064 }
14065 }
14066 pub struct SurfaceSourceAndroidNativeWindow {
14067 pub window: Option<*mut std::ffi::c_void>,
14068 }
14069 impl Default for SurfaceSourceAndroidNativeWindow {
14070 fn default() -> Self {
14071 Self { window: None }
14072 }
14073 }
14074 impl SurfaceSourceAndroidNativeWindow {
14075 pub fn new() -> Self {
14076 Self::default()
14077 }
14078 pub(crate) fn to_ffi(
14079 &self,
14080 ) -> (ffi::WGPUSurfaceSourceAndroidNativeWindow, ChainedStructStorage) {
14081 let mut storage = ChainedStructStorage::new();
14082 let mut raw: ffi::WGPUSurfaceSourceAndroidNativeWindow = unsafe {
14083 std::mem::zeroed()
14084 };
14085 if let Some(value) = self.window {
14086 raw.window = value;
14087 }
14088 (raw, storage)
14089 }
14090 pub(crate) fn from_ffi(
14091 value: ffi::WGPUSurfaceSourceAndroidNativeWindow,
14092 ) -> Self {
14093 Self { window: Some(value.window) }
14094 }
14095 }
14096 pub struct SurfaceSourceMetalLayer {
14097 pub layer: Option<*mut std::ffi::c_void>,
14098 }
14099 impl Default for SurfaceSourceMetalLayer {
14100 fn default() -> Self {
14101 Self { layer: None }
14102 }
14103 }
14104 impl SurfaceSourceMetalLayer {
14105 pub fn new() -> Self {
14106 Self::default()
14107 }
14108 pub(crate) fn to_ffi(
14109 &self,
14110 ) -> (ffi::WGPUSurfaceSourceMetalLayer, ChainedStructStorage) {
14111 let mut storage = ChainedStructStorage::new();
14112 let mut raw: ffi::WGPUSurfaceSourceMetalLayer = unsafe {
14113 std::mem::zeroed()
14114 };
14115 if let Some(value) = self.layer {
14116 raw.layer = value;
14117 }
14118 (raw, storage)
14119 }
14120 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceMetalLayer) -> Self {
14121 Self { layer: Some(value.layer) }
14122 }
14123 }
14124 pub struct SurfaceSourceWaylandSurface {
14125 pub display: Option<*mut std::ffi::c_void>,
14126 pub surface: Option<*mut std::ffi::c_void>,
14127 }
14128 impl Default for SurfaceSourceWaylandSurface {
14129 fn default() -> Self {
14130 Self {
14131 display: None,
14132 surface: None,
14133 }
14134 }
14135 }
14136 impl SurfaceSourceWaylandSurface {
14137 pub fn new() -> Self {
14138 Self::default()
14139 }
14140 pub(crate) fn to_ffi(
14141 &self,
14142 ) -> (ffi::WGPUSurfaceSourceWaylandSurface, ChainedStructStorage) {
14143 let mut storage = ChainedStructStorage::new();
14144 let mut raw: ffi::WGPUSurfaceSourceWaylandSurface = unsafe {
14145 std::mem::zeroed()
14146 };
14147 if let Some(value) = self.display {
14148 raw.display = value;
14149 }
14150 if let Some(value) = self.surface {
14151 raw.surface = value;
14152 }
14153 (raw, storage)
14154 }
14155 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceWaylandSurface) -> Self {
14156 Self {
14157 display: Some(value.display),
14158 surface: Some(value.surface),
14159 }
14160 }
14161 }
14162 pub struct SurfaceSourceWindowsHWND {
14163 pub hinstance: Option<*mut std::ffi::c_void>,
14164 pub hwnd: Option<*mut std::ffi::c_void>,
14165 }
14166 impl Default for SurfaceSourceWindowsHWND {
14167 fn default() -> Self {
14168 Self {
14169 hinstance: None,
14170 hwnd: None,
14171 }
14172 }
14173 }
14174 impl SurfaceSourceWindowsHWND {
14175 pub fn new() -> Self {
14176 Self::default()
14177 }
14178 pub(crate) fn to_ffi(
14179 &self,
14180 ) -> (ffi::WGPUSurfaceSourceWindowsHWND, ChainedStructStorage) {
14181 let mut storage = ChainedStructStorage::new();
14182 let mut raw: ffi::WGPUSurfaceSourceWindowsHWND = unsafe {
14183 std::mem::zeroed()
14184 };
14185 if let Some(value) = self.hinstance {
14186 raw.hinstance = value;
14187 }
14188 if let Some(value) = self.hwnd {
14189 raw.hwnd = value;
14190 }
14191 (raw, storage)
14192 }
14193 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceWindowsHWND) -> Self {
14194 Self {
14195 hinstance: Some(value.hinstance),
14196 hwnd: Some(value.hwnd),
14197 }
14198 }
14199 }
14200 pub struct SurfaceSourceXlibWindow {
14201 pub display: Option<*mut std::ffi::c_void>,
14202 pub window: Option<u64>,
14203 }
14204 impl Default for SurfaceSourceXlibWindow {
14205 fn default() -> Self {
14206 Self {
14207 display: None,
14208 window: None,
14209 }
14210 }
14211 }
14212 impl SurfaceSourceXlibWindow {
14213 pub fn new() -> Self {
14214 Self::default()
14215 }
14216 pub(crate) fn to_ffi(
14217 &self,
14218 ) -> (ffi::WGPUSurfaceSourceXlibWindow, ChainedStructStorage) {
14219 let mut storage = ChainedStructStorage::new();
14220 let mut raw: ffi::WGPUSurfaceSourceXlibWindow = unsafe {
14221 std::mem::zeroed()
14222 };
14223 if let Some(value) = self.display {
14224 raw.display = value;
14225 }
14226 if let Some(value) = self.window {
14227 raw.window = value;
14228 }
14229 (raw, storage)
14230 }
14231 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceSourceXlibWindow) -> Self {
14232 Self {
14233 display: Some(value.display),
14234 window: Some(value.window),
14235 }
14236 }
14237 }
14238 pub struct SurfaceTexture {
14239 pub(crate) extensions: Vec<SurfaceTextureExtension>,
14240 pub texture: Option<Texture>,
14241 pub status: Option<SurfaceGetCurrentTextureStatus>,
14242 }
14243 impl Default for SurfaceTexture {
14244 fn default() -> Self {
14245 Self {
14246 extensions: Vec::new(),
14247 texture: None,
14248 status: None,
14249 }
14250 }
14251 }
14252 impl SurfaceTexture {
14253 pub fn new() -> Self {
14254 Self::default()
14255 }
14256 pub(crate) fn to_ffi(&self) -> (ffi::WGPUSurfaceTexture, ChainedStructStorage) {
14257 let mut storage = ChainedStructStorage::new();
14258 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14259 for ext in self.extensions.iter().rev() {
14260 next = ext.push_chain(&mut storage, next);
14261 }
14262 let mut raw: ffi::WGPUSurfaceTexture = unsafe { std::mem::zeroed() };
14263 raw.nextInChain = next;
14264 raw.texture = self
14265 .texture
14266 .as_ref()
14267 .map(|v| v.as_raw())
14268 .unwrap_or(std::ptr::null_mut());
14269 if let Some(value) = self.status {
14270 raw.status = value.into();
14271 } else {
14272 raw.status = 0 as ffi::WGPUSurfaceGetCurrentTextureStatus;
14273 }
14274 (raw, storage)
14275 }
14276 pub fn with_extension(mut self, extension: SurfaceTextureExtension) -> Self {
14277 self.extensions.push(extension);
14278 self
14279 }
14280 pub(crate) fn from_ffi(value: ffi::WGPUSurfaceTexture) -> Self {
14281 Self {
14282 extensions: Vec::new(),
14283 texture: Some(unsafe { Texture::from_raw(value.texture) }),
14284 status: Some(value.status.into()),
14285 }
14286 }
14287 }
14288 pub struct TexelBufferBindingEntry {
14289 pub texel_buffer_view: Option<TexelBufferView>,
14290 }
14291 impl Default for TexelBufferBindingEntry {
14292 fn default() -> Self {
14293 Self { texel_buffer_view: None }
14294 }
14295 }
14296 impl TexelBufferBindingEntry {
14297 pub fn new() -> Self {
14298 Self::default()
14299 }
14300 pub(crate) fn to_ffi(
14301 &self,
14302 ) -> (ffi::WGPUTexelBufferBindingEntry, ChainedStructStorage) {
14303 let mut storage = ChainedStructStorage::new();
14304 let mut raw: ffi::WGPUTexelBufferBindingEntry = unsafe {
14305 std::mem::zeroed()
14306 };
14307 raw.texelBufferView = self
14308 .texel_buffer_view
14309 .as_ref()
14310 .map(|v| v.as_raw())
14311 .unwrap_or(std::ptr::null_mut());
14312 (raw, storage)
14313 }
14314 pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferBindingEntry) -> Self {
14315 Self {
14316 texel_buffer_view: Some(unsafe {
14317 TexelBufferView::from_raw(value.texelBufferView)
14318 }),
14319 }
14320 }
14321 }
14322 pub struct TexelBufferBindingLayout {
14323 pub access: Option<TexelBufferAccess>,
14324 pub format: Option<TextureFormat>,
14325 }
14326 impl Default for TexelBufferBindingLayout {
14327 fn default() -> Self {
14328 Self {
14329 access: Some(TexelBufferAccess::ReadWrite),
14330 format: None,
14331 }
14332 }
14333 }
14334 impl TexelBufferBindingLayout {
14335 pub fn new() -> Self {
14336 Self::default()
14337 }
14338 pub(crate) fn to_ffi(
14339 &self,
14340 ) -> (ffi::WGPUTexelBufferBindingLayout, ChainedStructStorage) {
14341 let mut storage = ChainedStructStorage::new();
14342 let mut raw: ffi::WGPUTexelBufferBindingLayout = unsafe {
14343 std::mem::zeroed()
14344 };
14345 if let Some(value) = self.access {
14346 raw.access = value.into();
14347 } else {
14348 raw.access = 0 as ffi::WGPUTexelBufferAccess;
14349 }
14350 if let Some(value) = self.format {
14351 raw.format = value.into();
14352 } else {
14353 raw.format = 0 as ffi::WGPUTextureFormat;
14354 }
14355 (raw, storage)
14356 }
14357 pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferBindingLayout) -> Self {
14358 Self {
14359 access: Some(value.access.into()),
14360 format: Some(value.format.into()),
14361 }
14362 }
14363 }
14364 pub struct TexelBufferViewDescriptor {
14365 pub(crate) extensions: Vec<TexelBufferViewDescriptorExtension>,
14366 pub label: Option<String>,
14367 pub format: Option<TextureFormat>,
14368 pub offset: Option<u64>,
14369 pub size: Option<u64>,
14370 }
14371 impl Default for TexelBufferViewDescriptor {
14372 fn default() -> Self {
14373 Self {
14374 extensions: Vec::new(),
14375 label: None,
14376 format: None,
14377 offset: Some(0),
14378 size: Some(WHOLE_SIZE),
14379 }
14380 }
14381 }
14382 impl TexelBufferViewDescriptor {
14383 pub fn new() -> Self {
14384 Self::default()
14385 }
14386 pub(crate) fn to_ffi(
14387 &self,
14388 ) -> (ffi::WGPUTexelBufferViewDescriptor, ChainedStructStorage) {
14389 let mut storage = ChainedStructStorage::new();
14390 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14391 for ext in self.extensions.iter().rev() {
14392 next = ext.push_chain(&mut storage, next);
14393 }
14394 let mut raw: ffi::WGPUTexelBufferViewDescriptor = unsafe {
14395 std::mem::zeroed()
14396 };
14397 raw.nextInChain = next;
14398 if let Some(value) = &self.label {
14399 raw.label = ffi::WGPUStringView {
14400 data: value.as_ptr().cast(),
14401 length: value.len(),
14402 };
14403 } else {
14404 raw.label = ffi::WGPUStringView {
14405 data: std::ptr::null(),
14406 length: 0,
14407 };
14408 }
14409 if let Some(value) = self.format {
14410 raw.format = value.into();
14411 } else {
14412 raw.format = 0 as ffi::WGPUTextureFormat;
14413 }
14414 if let Some(value) = self.offset {
14415 raw.offset = value;
14416 }
14417 if let Some(value) = self.size {
14418 raw.size = value;
14419 }
14420 (raw, storage)
14421 }
14422 pub fn with_extension(
14423 mut self,
14424 extension: TexelBufferViewDescriptorExtension,
14425 ) -> Self {
14426 self.extensions.push(extension);
14427 self
14428 }
14429 pub(crate) fn from_ffi(value: ffi::WGPUTexelBufferViewDescriptor) -> Self {
14430 Self {
14431 extensions: Vec::new(),
14432 label: if value.label.data.is_null() || value.label.length == 0 {
14433 None
14434 } else {
14435 Some(string_view_to_string(value.label))
14436 },
14437 format: Some(value.format.into()),
14438 offset: Some(value.offset),
14439 size: Some(value.size),
14440 }
14441 }
14442 }
14443 pub struct TexelCopyBufferInfo {
14444 pub layout: Option<TexelCopyBufferLayout>,
14445 pub buffer: Option<Buffer>,
14446 }
14447 impl Default for TexelCopyBufferInfo {
14448 fn default() -> Self {
14449 Self { layout: None, buffer: None }
14450 }
14451 }
14452 impl TexelCopyBufferInfo {
14453 pub fn new() -> Self {
14454 Self::default()
14455 }
14456 pub(crate) fn to_ffi(
14457 &self,
14458 ) -> (ffi::WGPUTexelCopyBufferInfo, ChainedStructStorage) {
14459 let mut storage = ChainedStructStorage::new();
14460 let mut raw: ffi::WGPUTexelCopyBufferInfo = unsafe { std::mem::zeroed() };
14461 if let Some(value) = &self.layout {
14462 let (raw_value, storage_value) = value.to_ffi();
14463 raw.layout = raw_value;
14464 storage.push_storage(storage_value);
14465 }
14466 raw.buffer = self
14467 .buffer
14468 .as_ref()
14469 .map(|v| v.as_raw())
14470 .unwrap_or(std::ptr::null_mut());
14471 (raw, storage)
14472 }
14473 pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyBufferInfo) -> Self {
14474 Self {
14475 layout: Some(TexelCopyBufferLayout::from_ffi(value.layout)),
14476 buffer: Some(unsafe { Buffer::from_raw(value.buffer) }),
14477 }
14478 }
14479 }
14480 pub struct TexelCopyBufferLayout {
14481 pub offset: Option<u64>,
14482 pub bytes_per_row: Option<u32>,
14483 pub rows_per_image: Option<u32>,
14484 }
14485 impl Default for TexelCopyBufferLayout {
14486 fn default() -> Self {
14487 Self {
14488 offset: Some(0),
14489 bytes_per_row: Some(COPY_STRIDE_UNDEFINED),
14490 rows_per_image: Some(COPY_STRIDE_UNDEFINED),
14491 }
14492 }
14493 }
14494 impl TexelCopyBufferLayout {
14495 pub fn new() -> Self {
14496 Self::default()
14497 }
14498 pub(crate) fn to_ffi(
14499 &self,
14500 ) -> (ffi::WGPUTexelCopyBufferLayout, ChainedStructStorage) {
14501 let mut storage = ChainedStructStorage::new();
14502 let mut raw: ffi::WGPUTexelCopyBufferLayout = unsafe { std::mem::zeroed() };
14503 if let Some(value) = self.offset {
14504 raw.offset = value;
14505 }
14506 if let Some(value) = self.bytes_per_row {
14507 raw.bytesPerRow = value;
14508 }
14509 if let Some(value) = self.rows_per_image {
14510 raw.rowsPerImage = value;
14511 }
14512 (raw, storage)
14513 }
14514 pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyBufferLayout) -> Self {
14515 Self {
14516 offset: Some(value.offset),
14517 bytes_per_row: Some(value.bytesPerRow),
14518 rows_per_image: Some(value.rowsPerImage),
14519 }
14520 }
14521 }
14522 pub struct TexelCopyTextureInfo {
14523 pub texture: Option<Texture>,
14524 pub mip_level: Option<u32>,
14525 pub origin: Option<Origin3D>,
14526 pub aspect: Option<TextureAspect>,
14527 }
14528 impl Default for TexelCopyTextureInfo {
14529 fn default() -> Self {
14530 Self {
14531 texture: None,
14532 mip_level: Some(0),
14533 origin: None,
14534 aspect: Some(TextureAspect::All),
14535 }
14536 }
14537 }
14538 impl TexelCopyTextureInfo {
14539 pub fn new() -> Self {
14540 Self::default()
14541 }
14542 pub(crate) fn to_ffi(
14543 &self,
14544 ) -> (ffi::WGPUTexelCopyTextureInfo, ChainedStructStorage) {
14545 let mut storage = ChainedStructStorage::new();
14546 let mut raw: ffi::WGPUTexelCopyTextureInfo = unsafe { std::mem::zeroed() };
14547 raw.texture = self
14548 .texture
14549 .as_ref()
14550 .map(|v| v.as_raw())
14551 .unwrap_or(std::ptr::null_mut());
14552 if let Some(value) = self.mip_level {
14553 raw.mipLevel = value;
14554 }
14555 if let Some(value) = &self.origin {
14556 let (raw_value, storage_value) = value.to_ffi();
14557 raw.origin = raw_value;
14558 storage.push_storage(storage_value);
14559 }
14560 if let Some(value) = self.aspect {
14561 raw.aspect = value.into();
14562 } else {
14563 raw.aspect = 0 as ffi::WGPUTextureAspect;
14564 }
14565 (raw, storage)
14566 }
14567 pub(crate) fn from_ffi(value: ffi::WGPUTexelCopyTextureInfo) -> Self {
14568 Self {
14569 texture: Some(unsafe { Texture::from_raw(value.texture) }),
14570 mip_level: Some(value.mipLevel),
14571 origin: Some(Origin3D::from_ffi(value.origin)),
14572 aspect: Some(value.aspect.into()),
14573 }
14574 }
14575 }
14576 pub struct TextureBindingLayout {
14577 pub(crate) extensions: Vec<TextureBindingLayoutExtension>,
14578 pub sample_type: Option<TextureSampleType>,
14579 pub view_dimension: Option<TextureViewDimension>,
14580 pub multisampled: Option<bool>,
14581 }
14582 impl Default for TextureBindingLayout {
14583 fn default() -> Self {
14584 Self {
14585 extensions: Vec::new(),
14586 sample_type: Some(TextureSampleType::Float),
14587 view_dimension: Some(TextureViewDimension::D2),
14588 multisampled: None,
14589 }
14590 }
14591 }
14592 impl TextureBindingLayout {
14593 pub fn new() -> Self {
14594 Self::default()
14595 }
14596 pub(crate) fn to_ffi(
14597 &self,
14598 ) -> (ffi::WGPUTextureBindingLayout, ChainedStructStorage) {
14599 let mut storage = ChainedStructStorage::new();
14600 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14601 for ext in self.extensions.iter().rev() {
14602 next = ext.push_chain(&mut storage, next);
14603 }
14604 let mut raw: ffi::WGPUTextureBindingLayout = unsafe { std::mem::zeroed() };
14605 raw.nextInChain = next;
14606 if let Some(value) = self.sample_type {
14607 raw.sampleType = value.into();
14608 } else {
14609 raw.sampleType = 0 as ffi::WGPUTextureSampleType;
14610 }
14611 if let Some(value) = self.view_dimension {
14612 raw.viewDimension = value.into();
14613 } else {
14614 raw.viewDimension = 0 as ffi::WGPUTextureViewDimension;
14615 }
14616 raw.multisampled = if self.multisampled.unwrap_or(false) { 1 } else { 0 };
14617 (raw, storage)
14618 }
14619 pub fn with_extension(
14620 mut self,
14621 extension: TextureBindingLayoutExtension,
14622 ) -> Self {
14623 self.extensions.push(extension);
14624 self
14625 }
14626 pub(crate) fn from_ffi(value: ffi::WGPUTextureBindingLayout) -> Self {
14627 Self {
14628 extensions: Vec::new(),
14629 sample_type: Some(value.sampleType.into()),
14630 view_dimension: Some(value.viewDimension.into()),
14631 multisampled: Some(value.multisampled != 0),
14632 }
14633 }
14634 }
14635 pub struct TextureComponentSwizzle {
14636 pub r: Option<ComponentSwizzle>,
14637 pub g: Option<ComponentSwizzle>,
14638 pub b: Option<ComponentSwizzle>,
14639 pub a: Option<ComponentSwizzle>,
14640 }
14641 impl Default for TextureComponentSwizzle {
14642 fn default() -> Self {
14643 Self {
14644 r: Some(ComponentSwizzle::R),
14645 g: Some(ComponentSwizzle::G),
14646 b: Some(ComponentSwizzle::B),
14647 a: Some(ComponentSwizzle::A),
14648 }
14649 }
14650 }
14651 impl TextureComponentSwizzle {
14652 pub fn new() -> Self {
14653 Self::default()
14654 }
14655 pub(crate) fn to_ffi(
14656 &self,
14657 ) -> (ffi::WGPUTextureComponentSwizzle, ChainedStructStorage) {
14658 let mut storage = ChainedStructStorage::new();
14659 let mut raw: ffi::WGPUTextureComponentSwizzle = unsafe {
14660 std::mem::zeroed()
14661 };
14662 if let Some(value) = self.r {
14663 raw.r = value.into();
14664 } else {
14665 raw.r = 0 as ffi::WGPUComponentSwizzle;
14666 }
14667 if let Some(value) = self.g {
14668 raw.g = value.into();
14669 } else {
14670 raw.g = 0 as ffi::WGPUComponentSwizzle;
14671 }
14672 if let Some(value) = self.b {
14673 raw.b = value.into();
14674 } else {
14675 raw.b = 0 as ffi::WGPUComponentSwizzle;
14676 }
14677 if let Some(value) = self.a {
14678 raw.a = value.into();
14679 } else {
14680 raw.a = 0 as ffi::WGPUComponentSwizzle;
14681 }
14682 (raw, storage)
14683 }
14684 pub(crate) fn from_ffi(value: ffi::WGPUTextureComponentSwizzle) -> Self {
14685 Self {
14686 r: Some(value.r.into()),
14687 g: Some(value.g.into()),
14688 b: Some(value.b.into()),
14689 a: Some(value.a.into()),
14690 }
14691 }
14692 }
14693 pub struct TextureComponentSwizzleDescriptor {
14694 pub swizzle: Option<TextureComponentSwizzle>,
14695 }
14696 impl Default for TextureComponentSwizzleDescriptor {
14697 fn default() -> Self {
14698 Self { swizzle: None }
14699 }
14700 }
14701 impl TextureComponentSwizzleDescriptor {
14702 pub fn new() -> Self {
14703 Self::default()
14704 }
14705 pub(crate) fn to_ffi(
14706 &self,
14707 ) -> (ffi::WGPUTextureComponentSwizzleDescriptor, ChainedStructStorage) {
14708 let mut storage = ChainedStructStorage::new();
14709 let mut raw: ffi::WGPUTextureComponentSwizzleDescriptor = unsafe {
14710 std::mem::zeroed()
14711 };
14712 if let Some(value) = &self.swizzle {
14713 let (raw_value, storage_value) = value.to_ffi();
14714 raw.swizzle = raw_value;
14715 storage.push_storage(storage_value);
14716 }
14717 (raw, storage)
14718 }
14719 pub(crate) fn from_ffi(
14720 value: ffi::WGPUTextureComponentSwizzleDescriptor,
14721 ) -> Self {
14722 Self {
14723 swizzle: Some(TextureComponentSwizzle::from_ffi(value.swizzle)),
14724 }
14725 }
14726 }
14727 pub struct TextureDescriptor {
14728 pub(crate) extensions: Vec<TextureDescriptorExtension>,
14729 pub label: Option<String>,
14730 pub usage: Option<TextureUsage>,
14731 pub dimension: Option<TextureDimension>,
14732 pub size: Option<Extent3D>,
14733 pub format: Option<TextureFormat>,
14734 pub mip_level_count: Option<u32>,
14735 pub sample_count: Option<u32>,
14736 pub view_formats: Option<Vec<TextureFormat>>,
14737 }
14738 impl Default for TextureDescriptor {
14739 fn default() -> Self {
14740 Self {
14741 extensions: Vec::new(),
14742 label: None,
14743 usage: None,
14744 dimension: Some(TextureDimension::D2),
14745 size: None,
14746 format: None,
14747 mip_level_count: Some(1),
14748 sample_count: Some(1),
14749 view_formats: None,
14750 }
14751 }
14752 }
14753 impl TextureDescriptor {
14754 pub fn new() -> Self {
14755 Self::default()
14756 }
14757 pub(crate) fn to_ffi(
14758 &self,
14759 ) -> (ffi::WGPUTextureDescriptor, ChainedStructStorage) {
14760 let mut storage = ChainedStructStorage::new();
14761 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14762 for ext in self.extensions.iter().rev() {
14763 next = ext.push_chain(&mut storage, next);
14764 }
14765 let mut raw: ffi::WGPUTextureDescriptor = unsafe { std::mem::zeroed() };
14766 raw.nextInChain = next;
14767 if let Some(value) = &self.label {
14768 raw.label = ffi::WGPUStringView {
14769 data: value.as_ptr().cast(),
14770 length: value.len(),
14771 };
14772 } else {
14773 raw.label = ffi::WGPUStringView {
14774 data: std::ptr::null(),
14775 length: 0,
14776 };
14777 }
14778 if let Some(value) = self.usage {
14779 raw.usage = value.into();
14780 } else {
14781 raw.usage = 0 as ffi::WGPUTextureUsage;
14782 }
14783 if let Some(value) = self.dimension {
14784 raw.dimension = value.into();
14785 } else {
14786 raw.dimension = 0 as ffi::WGPUTextureDimension;
14787 }
14788 if let Some(value) = &self.size {
14789 let (raw_value, storage_value) = value.to_ffi();
14790 raw.size = raw_value;
14791 storage.push_storage(storage_value);
14792 }
14793 if let Some(value) = self.format {
14794 raw.format = value.into();
14795 } else {
14796 raw.format = 0 as ffi::WGPUTextureFormat;
14797 }
14798 if let Some(value) = self.mip_level_count {
14799 raw.mipLevelCount = value;
14800 }
14801 if let Some(value) = self.sample_count {
14802 raw.sampleCount = value;
14803 }
14804 raw.viewFormatCount = self
14805 .view_formats
14806 .as_ref()
14807 .map(|v| v.len())
14808 .unwrap_or(0);
14809 if let Some(values) = &self.view_formats {
14810 let len_value = values.len();
14811 let raw_vec: Vec<ffi::WGPUTextureFormat> = values
14812 .iter()
14813 .map(|v| (*v).into())
14814 .collect();
14815 let ptr = storage.push_vec(raw_vec);
14816 raw.viewFormats = ptr;
14817 raw.viewFormatCount = len_value;
14818 } else {
14819 raw.viewFormats = std::ptr::null();
14820 raw.viewFormatCount = 0;
14821 }
14822 (raw, storage)
14823 }
14824 pub fn with_extension(mut self, extension: TextureDescriptorExtension) -> Self {
14825 self.extensions.push(extension);
14826 self
14827 }
14828 pub(crate) fn from_ffi(value: ffi::WGPUTextureDescriptor) -> Self {
14829 Self {
14830 extensions: Vec::new(),
14831 label: if value.label.data.is_null() || value.label.length == 0 {
14832 None
14833 } else {
14834 Some(string_view_to_string(value.label))
14835 },
14836 usage: Some(value.usage.into()),
14837 dimension: Some(value.dimension.into()),
14838 size: Some(Extent3D::from_ffi(value.size)),
14839 format: Some(value.format.into()),
14840 mip_level_count: Some(value.mipLevelCount),
14841 sample_count: Some(value.sampleCount),
14842 view_formats: if value.viewFormats.is_null() {
14843 None
14844 } else {
14845 Some(
14846 unsafe {
14847 std::slice::from_raw_parts(
14848 value.viewFormats,
14849 value.viewFormatCount as usize,
14850 )
14851 }
14852 .iter()
14853 .map(|raw| TextureFormat::from(*raw))
14854 .collect(),
14855 )
14856 },
14857 }
14858 }
14859 }
14860 pub struct TextureViewDescriptor {
14861 pub(crate) extensions: Vec<TextureViewDescriptorExtension>,
14862 pub label: Option<String>,
14863 pub format: Option<TextureFormat>,
14864 pub dimension: Option<TextureViewDimension>,
14865 pub base_mip_level: Option<u32>,
14866 pub mip_level_count: Option<u32>,
14867 pub base_array_layer: Option<u32>,
14868 pub array_layer_count: Option<u32>,
14869 pub aspect: Option<TextureAspect>,
14870 pub usage: Option<TextureUsage>,
14871 }
14872 impl Default for TextureViewDescriptor {
14873 fn default() -> Self {
14874 Self {
14875 extensions: Vec::new(),
14876 label: None,
14877 format: None,
14878 dimension: None,
14879 base_mip_level: Some(0),
14880 mip_level_count: Some(MIP_LEVEL_COUNT_UNDEFINED),
14881 base_array_layer: Some(0),
14882 array_layer_count: Some(ARRAY_LAYER_COUNT_UNDEFINED),
14883 aspect: Some(TextureAspect::All),
14884 usage: Some(TextureUsage::NONE),
14885 }
14886 }
14887 }
14888 impl TextureViewDescriptor {
14889 pub fn new() -> Self {
14890 Self::default()
14891 }
14892 pub(crate) fn to_ffi(
14893 &self,
14894 ) -> (ffi::WGPUTextureViewDescriptor, ChainedStructStorage) {
14895 let mut storage = ChainedStructStorage::new();
14896 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14897 for ext in self.extensions.iter().rev() {
14898 next = ext.push_chain(&mut storage, next);
14899 }
14900 let mut raw: ffi::WGPUTextureViewDescriptor = unsafe { std::mem::zeroed() };
14901 raw.nextInChain = next;
14902 if let Some(value) = &self.label {
14903 raw.label = ffi::WGPUStringView {
14904 data: value.as_ptr().cast(),
14905 length: value.len(),
14906 };
14907 } else {
14908 raw.label = ffi::WGPUStringView {
14909 data: std::ptr::null(),
14910 length: 0,
14911 };
14912 }
14913 if let Some(value) = self.format {
14914 raw.format = value.into();
14915 } else {
14916 raw.format = 0 as ffi::WGPUTextureFormat;
14917 }
14918 if let Some(value) = self.dimension {
14919 raw.dimension = value.into();
14920 } else {
14921 raw.dimension = 0 as ffi::WGPUTextureViewDimension;
14922 }
14923 if let Some(value) = self.base_mip_level {
14924 raw.baseMipLevel = value;
14925 }
14926 if let Some(value) = self.mip_level_count {
14927 raw.mipLevelCount = value;
14928 }
14929 if let Some(value) = self.base_array_layer {
14930 raw.baseArrayLayer = value;
14931 }
14932 if let Some(value) = self.array_layer_count {
14933 raw.arrayLayerCount = value;
14934 }
14935 if let Some(value) = self.aspect {
14936 raw.aspect = value.into();
14937 } else {
14938 raw.aspect = 0 as ffi::WGPUTextureAspect;
14939 }
14940 if let Some(value) = self.usage {
14941 raw.usage = value.into();
14942 } else {
14943 raw.usage = 0 as ffi::WGPUTextureUsage;
14944 }
14945 (raw, storage)
14946 }
14947 pub fn with_extension(
14948 mut self,
14949 extension: TextureViewDescriptorExtension,
14950 ) -> Self {
14951 self.extensions.push(extension);
14952 self
14953 }
14954 pub(crate) fn from_ffi(value: ffi::WGPUTextureViewDescriptor) -> Self {
14955 Self {
14956 extensions: Vec::new(),
14957 label: if value.label.data.is_null() || value.label.length == 0 {
14958 None
14959 } else {
14960 Some(string_view_to_string(value.label))
14961 },
14962 format: Some(value.format.into()),
14963 dimension: Some(value.dimension.into()),
14964 base_mip_level: Some(value.baseMipLevel),
14965 mip_level_count: Some(value.mipLevelCount),
14966 base_array_layer: Some(value.baseArrayLayer),
14967 array_layer_count: Some(value.arrayLayerCount),
14968 aspect: Some(value.aspect.into()),
14969 usage: Some(value.usage.into()),
14970 }
14971 }
14972 }
14973 pub struct VertexAttribute {
14974 pub(crate) extensions: Vec<VertexAttributeExtension>,
14975 pub format: Option<VertexFormat>,
14976 pub offset: Option<u64>,
14977 pub shader_location: Option<u32>,
14978 }
14979 impl Default for VertexAttribute {
14980 fn default() -> Self {
14981 Self {
14982 extensions: Vec::new(),
14983 format: None,
14984 offset: None,
14985 shader_location: None,
14986 }
14987 }
14988 }
14989 impl VertexAttribute {
14990 pub fn new() -> Self {
14991 Self::default()
14992 }
14993 pub(crate) fn to_ffi(&self) -> (ffi::WGPUVertexAttribute, ChainedStructStorage) {
14994 let mut storage = ChainedStructStorage::new();
14995 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
14996 for ext in self.extensions.iter().rev() {
14997 next = ext.push_chain(&mut storage, next);
14998 }
14999 let mut raw: ffi::WGPUVertexAttribute = unsafe { std::mem::zeroed() };
15000 raw.nextInChain = next;
15001 if let Some(value) = self.format {
15002 raw.format = value.into();
15003 } else {
15004 raw.format = 0 as ffi::WGPUVertexFormat;
15005 }
15006 if let Some(value) = self.offset {
15007 raw.offset = value;
15008 }
15009 if let Some(value) = self.shader_location {
15010 raw.shaderLocation = value;
15011 }
15012 (raw, storage)
15013 }
15014 pub fn with_extension(mut self, extension: VertexAttributeExtension) -> Self {
15015 self.extensions.push(extension);
15016 self
15017 }
15018 pub(crate) fn from_ffi(value: ffi::WGPUVertexAttribute) -> Self {
15019 Self {
15020 extensions: Vec::new(),
15021 format: Some(value.format.into()),
15022 offset: Some(value.offset),
15023 shader_location: Some(value.shaderLocation),
15024 }
15025 }
15026 }
15027 pub struct VertexBufferLayout {
15028 pub(crate) extensions: Vec<VertexBufferLayoutExtension>,
15029 pub step_mode: Option<VertexStepMode>,
15030 pub array_stride: Option<u64>,
15031 pub attributes: Option<Vec<VertexAttribute>>,
15032 }
15033 impl Default for VertexBufferLayout {
15034 fn default() -> Self {
15035 Self {
15036 extensions: Vec::new(),
15037 step_mode: None,
15038 array_stride: None,
15039 attributes: None,
15040 }
15041 }
15042 }
15043 impl VertexBufferLayout {
15044 pub fn new() -> Self {
15045 Self::default()
15046 }
15047 pub(crate) fn to_ffi(
15048 &self,
15049 ) -> (ffi::WGPUVertexBufferLayout, ChainedStructStorage) {
15050 let mut storage = ChainedStructStorage::new();
15051 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15052 for ext in self.extensions.iter().rev() {
15053 next = ext.push_chain(&mut storage, next);
15054 }
15055 let mut raw: ffi::WGPUVertexBufferLayout = unsafe { std::mem::zeroed() };
15056 raw.nextInChain = next;
15057 if let Some(value) = self.step_mode {
15058 raw.stepMode = value.into();
15059 } else {
15060 raw.stepMode = 0 as ffi::WGPUVertexStepMode;
15061 }
15062 if let Some(value) = self.array_stride {
15063 raw.arrayStride = value;
15064 }
15065 raw.attributeCount = self.attributes.as_ref().map(|v| v.len()).unwrap_or(0);
15066 if let Some(values) = &self.attributes {
15067 let len_value = values.len();
15068 let mut raw_vec: Vec<ffi::WGPUVertexAttribute> = Vec::with_capacity(
15069 values.len(),
15070 );
15071 for item in values.iter() {
15072 let (raw_item, storage_item) = item.to_ffi();
15073 raw_vec.push(raw_item);
15074 storage.push_storage(storage_item);
15075 }
15076 let ptr = storage.push_vec(raw_vec);
15077 raw.attributes = ptr;
15078 raw.attributeCount = len_value;
15079 } else {
15080 raw.attributes = std::ptr::null();
15081 raw.attributeCount = 0;
15082 }
15083 (raw, storage)
15084 }
15085 pub fn with_extension(mut self, extension: VertexBufferLayoutExtension) -> Self {
15086 self.extensions.push(extension);
15087 self
15088 }
15089 pub(crate) fn from_ffi(value: ffi::WGPUVertexBufferLayout) -> Self {
15090 Self {
15091 extensions: Vec::new(),
15092 step_mode: Some(value.stepMode.into()),
15093 array_stride: Some(value.arrayStride),
15094 attributes: if value.attributes.is_null() {
15095 None
15096 } else {
15097 Some(
15098 unsafe {
15099 std::slice::from_raw_parts(
15100 value.attributes,
15101 value.attributeCount as usize,
15102 )
15103 }
15104 .iter()
15105 .map(|raw| VertexAttribute::from_ffi(*raw))
15106 .collect(),
15107 )
15108 },
15109 }
15110 }
15111 }
15112 pub struct VertexState {
15113 pub(crate) extensions: Vec<VertexStateExtension>,
15114 pub module: Option<ShaderModule>,
15115 pub entry_point: Option<String>,
15116 pub constants: Option<Vec<ConstantEntry>>,
15117 pub buffers: Option<Vec<VertexBufferLayout>>,
15118 }
15119 impl Default for VertexState {
15120 fn default() -> Self {
15121 Self {
15122 extensions: Vec::new(),
15123 module: None,
15124 entry_point: None,
15125 constants: None,
15126 buffers: None,
15127 }
15128 }
15129 }
15130 impl VertexState {
15131 pub fn new() -> Self {
15132 Self::default()
15133 }
15134 pub(crate) fn to_ffi(&self) -> (ffi::WGPUVertexState, ChainedStructStorage) {
15135 let mut storage = ChainedStructStorage::new();
15136 let mut next: *mut ffi::WGPUChainedStruct = std::ptr::null_mut();
15137 for ext in self.extensions.iter().rev() {
15138 next = ext.push_chain(&mut storage, next);
15139 }
15140 let mut raw: ffi::WGPUVertexState = unsafe { std::mem::zeroed() };
15141 raw.nextInChain = next;
15142 raw.module = self
15143 .module
15144 .as_ref()
15145 .map(|v| v.as_raw())
15146 .unwrap_or(std::ptr::null_mut());
15147 if let Some(value) = &self.entry_point {
15148 raw.entryPoint = ffi::WGPUStringView {
15149 data: value.as_ptr().cast(),
15150 length: value.len(),
15151 };
15152 } else {
15153 raw.entryPoint = ffi::WGPUStringView {
15154 data: std::ptr::null(),
15155 length: 0,
15156 };
15157 }
15158 raw.constantCount = self.constants.as_ref().map(|v| v.len()).unwrap_or(0);
15159 if let Some(values) = &self.constants {
15160 let len_value = values.len();
15161 let mut raw_vec: Vec<ffi::WGPUConstantEntry> = Vec::with_capacity(
15162 values.len(),
15163 );
15164 for item in values.iter() {
15165 let (raw_item, storage_item) = item.to_ffi();
15166 raw_vec.push(raw_item);
15167 storage.push_storage(storage_item);
15168 }
15169 let ptr = storage.push_vec(raw_vec);
15170 raw.constants = ptr;
15171 raw.constantCount = len_value;
15172 } else {
15173 raw.constants = std::ptr::null();
15174 raw.constantCount = 0;
15175 }
15176 raw.bufferCount = self.buffers.as_ref().map(|v| v.len()).unwrap_or(0);
15177 if let Some(values) = &self.buffers {
15178 let len_value = values.len();
15179 let mut raw_vec: Vec<ffi::WGPUVertexBufferLayout> = Vec::with_capacity(
15180 values.len(),
15181 );
15182 for item in values.iter() {
15183 let (raw_item, storage_item) = item.to_ffi();
15184 raw_vec.push(raw_item);
15185 storage.push_storage(storage_item);
15186 }
15187 let ptr = storage.push_vec(raw_vec);
15188 raw.buffers = ptr;
15189 raw.bufferCount = len_value;
15190 } else {
15191 raw.buffers = std::ptr::null();
15192 raw.bufferCount = 0;
15193 }
15194 (raw, storage)
15195 }
15196 pub fn with_extension(mut self, extension: VertexStateExtension) -> Self {
15197 self.extensions.push(extension);
15198 self
15199 }
15200 pub(crate) fn from_ffi(value: ffi::WGPUVertexState) -> Self {
15201 Self {
15202 extensions: Vec::new(),
15203 module: Some(unsafe { ShaderModule::from_raw(value.module) }),
15204 entry_point: if value.entryPoint.data.is_null()
15205 || value.entryPoint.length == 0
15206 {
15207 None
15208 } else {
15209 Some(string_view_to_string(value.entryPoint))
15210 },
15211 constants: if value.constants.is_null() {
15212 None
15213 } else {
15214 Some(
15215 unsafe {
15216 std::slice::from_raw_parts(
15217 value.constants,
15218 value.constantCount as usize,
15219 )
15220 }
15221 .iter()
15222 .map(|raw| ConstantEntry::from_ffi(*raw))
15223 .collect(),
15224 )
15225 },
15226 buffers: if value.buffers.is_null() {
15227 None
15228 } else {
15229 Some(
15230 unsafe {
15231 std::slice::from_raw_parts(
15232 value.buffers,
15233 value.bufferCount as usize,
15234 )
15235 }
15236 .iter()
15237 .map(|raw| VertexBufferLayout::from_ffi(*raw))
15238 .collect(),
15239 )
15240 },
15241 }
15242 }
15243 }
15244 pub struct YCbCrVkDescriptor {
15245 pub vk_format: Option<u32>,
15246 pub vk_y_cb_cr_model: Option<u32>,
15247 pub vk_y_cb_cr_range: Option<u32>,
15248 pub vk_component_swizzle_red: Option<u32>,
15249 pub vk_component_swizzle_green: Option<u32>,
15250 pub vk_component_swizzle_blue: Option<u32>,
15251 pub vk_component_swizzle_alpha: Option<u32>,
15252 pub vk_x_chroma_offset: Option<u32>,
15253 pub vk_y_chroma_offset: Option<u32>,
15254 pub vk_chroma_filter: Option<FilterMode>,
15255 pub force_explicit_reconstruction: Option<bool>,
15256 pub external_format: Option<u64>,
15257 }
15258 impl Default for YCbCrVkDescriptor {
15259 fn default() -> Self {
15260 Self {
15261 vk_format: Some(0),
15262 vk_y_cb_cr_model: Some(0),
15263 vk_y_cb_cr_range: Some(0),
15264 vk_component_swizzle_red: Some(0),
15265 vk_component_swizzle_green: Some(0),
15266 vk_component_swizzle_blue: Some(0),
15267 vk_component_swizzle_alpha: Some(0),
15268 vk_x_chroma_offset: Some(0),
15269 vk_y_chroma_offset: Some(0),
15270 vk_chroma_filter: Some(FilterMode::Nearest),
15271 force_explicit_reconstruction: None,
15272 external_format: Some(0),
15273 }
15274 }
15275 }
15276 impl YCbCrVkDescriptor {
15277 pub fn new() -> Self {
15278 Self::default()
15279 }
15280 pub(crate) fn to_ffi(
15281 &self,
15282 ) -> (ffi::WGPUYCbCrVkDescriptor, ChainedStructStorage) {
15283 let mut storage = ChainedStructStorage::new();
15284 let mut raw: ffi::WGPUYCbCrVkDescriptor = unsafe { std::mem::zeroed() };
15285 if let Some(value) = self.vk_format {
15286 raw.vkFormat = value;
15287 }
15288 if let Some(value) = self.vk_y_cb_cr_model {
15289 raw.vkYCbCrModel = value;
15290 }
15291 if let Some(value) = self.vk_y_cb_cr_range {
15292 raw.vkYCbCrRange = value;
15293 }
15294 if let Some(value) = self.vk_component_swizzle_red {
15295 raw.vkComponentSwizzleRed = value;
15296 }
15297 if let Some(value) = self.vk_component_swizzle_green {
15298 raw.vkComponentSwizzleGreen = value;
15299 }
15300 if let Some(value) = self.vk_component_swizzle_blue {
15301 raw.vkComponentSwizzleBlue = value;
15302 }
15303 if let Some(value) = self.vk_component_swizzle_alpha {
15304 raw.vkComponentSwizzleAlpha = value;
15305 }
15306 if let Some(value) = self.vk_x_chroma_offset {
15307 raw.vkXChromaOffset = value;
15308 }
15309 if let Some(value) = self.vk_y_chroma_offset {
15310 raw.vkYChromaOffset = value;
15311 }
15312 if let Some(value) = self.vk_chroma_filter {
15313 raw.vkChromaFilter = value.into();
15314 } else {
15315 raw.vkChromaFilter = 0 as ffi::WGPUFilterMode;
15316 }
15317 raw.forceExplicitReconstruction = if self
15318 .force_explicit_reconstruction
15319 .unwrap_or(false)
15320 {
15321 1
15322 } else {
15323 0
15324 };
15325 if let Some(value) = self.external_format {
15326 raw.externalFormat = value;
15327 }
15328 (raw, storage)
15329 }
15330 pub(crate) fn from_ffi(value: ffi::WGPUYCbCrVkDescriptor) -> Self {
15331 Self {
15332 vk_format: Some(value.vkFormat),
15333 vk_y_cb_cr_model: Some(value.vkYCbCrModel),
15334 vk_y_cb_cr_range: Some(value.vkYCbCrRange),
15335 vk_component_swizzle_red: Some(value.vkComponentSwizzleRed),
15336 vk_component_swizzle_green: Some(value.vkComponentSwizzleGreen),
15337 vk_component_swizzle_blue: Some(value.vkComponentSwizzleBlue),
15338 vk_component_swizzle_alpha: Some(value.vkComponentSwizzleAlpha),
15339 vk_x_chroma_offset: Some(value.vkXChromaOffset),
15340 vk_y_chroma_offset: Some(value.vkYChromaOffset),
15341 vk_chroma_filter: Some(value.vkChromaFilter.into()),
15342 force_explicit_reconstruction: Some(
15343 value.forceExplicitReconstruction != 0,
15344 ),
15345 external_format: Some(value.externalFormat),
15346 }
15347 }
15348 }
15349}
15350mod extensions {
15351 #![allow(dead_code, unused_imports)]
15352 use crate::ffi;
15353 use crate::generated::*;
15354 use std::any::Any;
15355 pub(crate) struct ChainedStructStorage {
15356 entries: Vec<Box<ffi::WGPUChainedStruct>>,
15357 buffers: Vec<Box<dyn Any>>,
15358 nested: Vec<ChainedStructStorage>,
15359 }
15360 impl ChainedStructStorage {
15361 pub(crate) fn new() -> Self {
15362 Self {
15363 entries: Vec::new(),
15364 buffers: Vec::new(),
15365 nested: Vec::new(),
15366 }
15367 }
15368 pub(crate) fn push(
15369 &mut self,
15370 s_type: ffi::WGPUSType,
15371 next: *mut ffi::WGPUChainedStruct,
15372 ) -> *mut ffi::WGPUChainedStruct {
15373 let mut node = Box::new(ffi::WGPUChainedStruct {
15374 next,
15375 sType: s_type,
15376 });
15377 let ptr = std::ptr::from_mut(node.as_mut());
15378 self.entries.push(node);
15379 ptr
15380 }
15381 pub(crate) fn push_value<T: 'static>(&mut self, value: T) -> *const T {
15382 let boxed = Box::new(value);
15383 let ptr = std::ptr::from_ref(boxed.as_ref());
15384 self.buffers.push(boxed);
15385 ptr
15386 }
15387 pub(crate) fn push_value_mut<T: 'static>(&mut self, value: T) -> *mut T {
15388 let mut boxed = Box::new(value);
15389 let ptr = std::ptr::from_mut(boxed.as_mut());
15390 self.buffers.push(boxed);
15391 ptr
15392 }
15393 pub(crate) fn push_vec<T: 'static>(&mut self, value: Vec<T>) -> *const T {
15394 let ptr = value.as_ptr();
15395 self.buffers.push(Box::new(value));
15396 ptr
15397 }
15398 pub(crate) fn push_vec_mut<T: 'static>(&mut self, value: Vec<T>) -> *mut T {
15399 let mut value = value;
15400 let ptr = value.as_mut_ptr();
15401 self.buffers.push(Box::new(value));
15402 ptr
15403 }
15404 pub(crate) fn push_any<T: 'static>(&mut self, value: T) {
15405 self.buffers.push(Box::new(value));
15406 }
15407 pub(crate) fn push_storage(&mut self, storage: ChainedStructStorage) {
15408 self.nested.push(storage);
15409 }
15410 }
15411 #[allow(dead_code)]
15412 pub enum AdapterInfoExtension {
15413 AdapterPropertiesD3D(AdapterPropertiesD3D),
15414 AdapterPropertiesWGPU(AdapterPropertiesWGPU),
15415 AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15416 AdapterPropertiesExplicitComputeSubgroupSizeConfigs,
15417 ),
15418 AdapterPropertiesMemoryHeaps(AdapterPropertiesMemoryHeaps),
15419 AdapterPropertiesSubgroupMatrixConfigs(AdapterPropertiesSubgroupMatrixConfigs),
15420 AdapterPropertiesVk(AdapterPropertiesVk),
15421 DawnAdapterPropertiesPowerPreference(DawnAdapterPropertiesPowerPreference),
15422 }
15423 impl std::convert::From<AdapterPropertiesD3D> for AdapterInfoExtension {
15424 fn from(ext: AdapterPropertiesD3D) -> Self {
15425 AdapterInfoExtension::AdapterPropertiesD3D(ext)
15426 }
15427 }
15428 impl std::convert::From<AdapterPropertiesWGPU> for AdapterInfoExtension {
15429 fn from(ext: AdapterPropertiesWGPU) -> Self {
15430 AdapterInfoExtension::AdapterPropertiesWGPU(ext)
15431 }
15432 }
15433 impl std::convert::From<AdapterPropertiesExplicitComputeSubgroupSizeConfigs>
15434 for AdapterInfoExtension {
15435 fn from(ext: AdapterPropertiesExplicitComputeSubgroupSizeConfigs) -> Self {
15436 AdapterInfoExtension::AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15437 ext,
15438 )
15439 }
15440 }
15441 impl std::convert::From<AdapterPropertiesMemoryHeaps> for AdapterInfoExtension {
15442 fn from(ext: AdapterPropertiesMemoryHeaps) -> Self {
15443 AdapterInfoExtension::AdapterPropertiesMemoryHeaps(ext)
15444 }
15445 }
15446 impl std::convert::From<AdapterPropertiesSubgroupMatrixConfigs>
15447 for AdapterInfoExtension {
15448 fn from(ext: AdapterPropertiesSubgroupMatrixConfigs) -> Self {
15449 AdapterInfoExtension::AdapterPropertiesSubgroupMatrixConfigs(ext)
15450 }
15451 }
15452 impl std::convert::From<AdapterPropertiesVk> for AdapterInfoExtension {
15453 fn from(ext: AdapterPropertiesVk) -> Self {
15454 AdapterInfoExtension::AdapterPropertiesVk(ext)
15455 }
15456 }
15457 impl std::convert::From<DawnAdapterPropertiesPowerPreference>
15458 for AdapterInfoExtension {
15459 fn from(ext: DawnAdapterPropertiesPowerPreference) -> Self {
15460 AdapterInfoExtension::DawnAdapterPropertiesPowerPreference(ext)
15461 }
15462 }
15463 impl AdapterInfoExtension {
15464 pub(crate) fn push_chain(
15465 &self,
15466 storage: &mut ChainedStructStorage,
15467 next: *mut ffi::WGPUChainedStruct,
15468 ) -> *mut ffi::WGPUChainedStruct {
15469 match self {
15470 AdapterInfoExtension::AdapterPropertiesD3D(value) => {
15471 let (mut raw, storage_value) = value.to_ffi();
15472 raw.chain.sType = SType::AdapterPropertiesD3D.into();
15473 raw.chain.next = next;
15474 storage.push_storage(storage_value);
15475 let raw_ptr = storage.push_value_mut(raw);
15476 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15477 }
15478 AdapterInfoExtension::AdapterPropertiesWGPU(value) => {
15479 let (mut raw, storage_value) = value.to_ffi();
15480 raw.chain.sType = SType::AdapterPropertiesWGPU.into();
15481 raw.chain.next = next;
15482 storage.push_storage(storage_value);
15483 let raw_ptr = storage.push_value_mut(raw);
15484 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15485 }
15486 AdapterInfoExtension::AdapterPropertiesExplicitComputeSubgroupSizeConfigs(
15487 value,
15488 ) => {
15489 let (mut raw, storage_value) = value.to_ffi();
15490 raw.chain.sType = SType::AdapterPropertiesExplicitComputeSubgroupSizeConfigs
15491 .into();
15492 raw.chain.next = next;
15493 storage.push_storage(storage_value);
15494 let raw_ptr = storage.push_value_mut(raw);
15495 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15496 }
15497 AdapterInfoExtension::AdapterPropertiesMemoryHeaps(value) => {
15498 let (mut raw, storage_value) = value.to_ffi();
15499 raw.chain.sType = SType::AdapterPropertiesMemoryHeaps.into();
15500 raw.chain.next = next;
15501 storage.push_storage(storage_value);
15502 let raw_ptr = storage.push_value_mut(raw);
15503 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15504 }
15505 AdapterInfoExtension::AdapterPropertiesSubgroupMatrixConfigs(value) => {
15506 let (mut raw, storage_value) = value.to_ffi();
15507 raw.chain.sType = SType::AdapterPropertiesSubgroupMatrixConfigs
15508 .into();
15509 raw.chain.next = next;
15510 storage.push_storage(storage_value);
15511 let raw_ptr = storage.push_value_mut(raw);
15512 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15513 }
15514 AdapterInfoExtension::AdapterPropertiesVk(value) => {
15515 let (mut raw, storage_value) = value.to_ffi();
15516 raw.chain.sType = SType::AdapterPropertiesVk.into();
15517 raw.chain.next = next;
15518 storage.push_storage(storage_value);
15519 let raw_ptr = storage.push_value_mut(raw);
15520 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15521 }
15522 AdapterInfoExtension::DawnAdapterPropertiesPowerPreference(value) => {
15523 let (mut raw, storage_value) = value.to_ffi();
15524 raw.chain.sType = SType::DawnAdapterPropertiesPowerPreference.into();
15525 raw.chain.next = next;
15526 storage.push_storage(storage_value);
15527 let raw_ptr = storage.push_value_mut(raw);
15528 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15529 }
15530 }
15531 }
15532 }
15533 #[allow(dead_code)]
15534 pub enum BindGroupDescriptorExtension {}
15535 impl BindGroupDescriptorExtension {
15536 pub(crate) fn push_chain(
15537 &self,
15538 storage: &mut ChainedStructStorage,
15539 next: *mut ffi::WGPUChainedStruct,
15540 ) -> *mut ffi::WGPUChainedStruct {
15541 let _ = self;
15542 let _ = storage;
15543 next
15544 }
15545 }
15546 #[allow(dead_code)]
15547 pub enum BindGroupEntryExtension {
15548 ExternalTextureBindingEntry(ExternalTextureBindingEntry),
15549 TexelBufferBindingEntry(TexelBufferBindingEntry),
15550 }
15551 impl std::convert::From<ExternalTextureBindingEntry> for BindGroupEntryExtension {
15552 fn from(ext: ExternalTextureBindingEntry) -> Self {
15553 BindGroupEntryExtension::ExternalTextureBindingEntry(ext)
15554 }
15555 }
15556 impl std::convert::From<TexelBufferBindingEntry> for BindGroupEntryExtension {
15557 fn from(ext: TexelBufferBindingEntry) -> Self {
15558 BindGroupEntryExtension::TexelBufferBindingEntry(ext)
15559 }
15560 }
15561 impl BindGroupEntryExtension {
15562 pub(crate) fn push_chain(
15563 &self,
15564 storage: &mut ChainedStructStorage,
15565 next: *mut ffi::WGPUChainedStruct,
15566 ) -> *mut ffi::WGPUChainedStruct {
15567 match self {
15568 BindGroupEntryExtension::ExternalTextureBindingEntry(value) => {
15569 let (mut raw, storage_value) = value.to_ffi();
15570 raw.chain.sType = SType::ExternalTextureBindingEntry.into();
15571 raw.chain.next = next;
15572 storage.push_storage(storage_value);
15573 let raw_ptr = storage.push_value_mut(raw);
15574 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15575 }
15576 BindGroupEntryExtension::TexelBufferBindingEntry(value) => {
15577 let (mut raw, storage_value) = value.to_ffi();
15578 raw.chain.sType = SType::TexelBufferBindingEntry.into();
15579 raw.chain.next = next;
15580 storage.push_storage(storage_value);
15581 let raw_ptr = storage.push_value_mut(raw);
15582 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15583 }
15584 }
15585 }
15586 }
15587 #[allow(dead_code)]
15588 pub enum BindGroupLayoutDescriptorExtension {}
15589 impl BindGroupLayoutDescriptorExtension {
15590 pub(crate) fn push_chain(
15591 &self,
15592 storage: &mut ChainedStructStorage,
15593 next: *mut ffi::WGPUChainedStruct,
15594 ) -> *mut ffi::WGPUChainedStruct {
15595 let _ = self;
15596 let _ = storage;
15597 next
15598 }
15599 }
15600 #[allow(dead_code)]
15601 pub enum BindGroupLayoutEntryExtension {
15602 ExternalTextureBindingLayout(ExternalTextureBindingLayout),
15603 StaticSamplerBindingLayout(StaticSamplerBindingLayout),
15604 TexelBufferBindingLayout(TexelBufferBindingLayout),
15605 }
15606 impl std::convert::From<ExternalTextureBindingLayout>
15607 for BindGroupLayoutEntryExtension {
15608 fn from(ext: ExternalTextureBindingLayout) -> Self {
15609 BindGroupLayoutEntryExtension::ExternalTextureBindingLayout(ext)
15610 }
15611 }
15612 impl std::convert::From<StaticSamplerBindingLayout>
15613 for BindGroupLayoutEntryExtension {
15614 fn from(ext: StaticSamplerBindingLayout) -> Self {
15615 BindGroupLayoutEntryExtension::StaticSamplerBindingLayout(ext)
15616 }
15617 }
15618 impl std::convert::From<TexelBufferBindingLayout> for BindGroupLayoutEntryExtension {
15619 fn from(ext: TexelBufferBindingLayout) -> Self {
15620 BindGroupLayoutEntryExtension::TexelBufferBindingLayout(ext)
15621 }
15622 }
15623 impl BindGroupLayoutEntryExtension {
15624 pub(crate) fn push_chain(
15625 &self,
15626 storage: &mut ChainedStructStorage,
15627 next: *mut ffi::WGPUChainedStruct,
15628 ) -> *mut ffi::WGPUChainedStruct {
15629 match self {
15630 BindGroupLayoutEntryExtension::ExternalTextureBindingLayout(value) => {
15631 let (mut raw, storage_value) = value.to_ffi();
15632 raw.chain.sType = SType::ExternalTextureBindingLayout.into();
15633 raw.chain.next = next;
15634 storage.push_storage(storage_value);
15635 let raw_ptr = storage.push_value_mut(raw);
15636 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15637 }
15638 BindGroupLayoutEntryExtension::StaticSamplerBindingLayout(value) => {
15639 let (mut raw, storage_value) = value.to_ffi();
15640 raw.chain.sType = SType::StaticSamplerBindingLayout.into();
15641 raw.chain.next = next;
15642 storage.push_storage(storage_value);
15643 let raw_ptr = storage.push_value_mut(raw);
15644 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15645 }
15646 BindGroupLayoutEntryExtension::TexelBufferBindingLayout(value) => {
15647 let (mut raw, storage_value) = value.to_ffi();
15648 raw.chain.sType = SType::TexelBufferBindingLayout.into();
15649 raw.chain.next = next;
15650 storage.push_storage(storage_value);
15651 let raw_ptr = storage.push_value_mut(raw);
15652 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15653 }
15654 }
15655 }
15656 }
15657 #[allow(dead_code)]
15658 pub enum BindingResourceExtension {}
15659 impl BindingResourceExtension {
15660 pub(crate) fn push_chain(
15661 &self,
15662 storage: &mut ChainedStructStorage,
15663 next: *mut ffi::WGPUChainedStruct,
15664 ) -> *mut ffi::WGPUChainedStruct {
15665 let _ = self;
15666 let _ = storage;
15667 next
15668 }
15669 }
15670 #[allow(dead_code)]
15671 pub enum BufferBindingLayoutExtension {}
15672 impl BufferBindingLayoutExtension {
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 BufferDescriptorExtension {
15685 BufferHostMappedPointer(BufferHostMappedPointer),
15686 DawnBufferDescriptorErrorInfoFromWireClient(
15687 DawnBufferDescriptorErrorInfoFromWireClient,
15688 ),
15689 DawnFakeBufferOOMForTesting(DawnFakeBufferOOMForTesting),
15690 }
15691 impl std::convert::From<BufferHostMappedPointer> for BufferDescriptorExtension {
15692 fn from(ext: BufferHostMappedPointer) -> Self {
15693 BufferDescriptorExtension::BufferHostMappedPointer(ext)
15694 }
15695 }
15696 impl std::convert::From<DawnBufferDescriptorErrorInfoFromWireClient>
15697 for BufferDescriptorExtension {
15698 fn from(ext: DawnBufferDescriptorErrorInfoFromWireClient) -> Self {
15699 BufferDescriptorExtension::DawnBufferDescriptorErrorInfoFromWireClient(ext)
15700 }
15701 }
15702 impl std::convert::From<DawnFakeBufferOOMForTesting> for BufferDescriptorExtension {
15703 fn from(ext: DawnFakeBufferOOMForTesting) -> Self {
15704 BufferDescriptorExtension::DawnFakeBufferOOMForTesting(ext)
15705 }
15706 }
15707 impl BufferDescriptorExtension {
15708 pub(crate) fn push_chain(
15709 &self,
15710 storage: &mut ChainedStructStorage,
15711 next: *mut ffi::WGPUChainedStruct,
15712 ) -> *mut ffi::WGPUChainedStruct {
15713 match self {
15714 BufferDescriptorExtension::BufferHostMappedPointer(value) => {
15715 let (mut raw, storage_value) = value.to_ffi();
15716 raw.chain.sType = SType::BufferHostMappedPointer.into();
15717 raw.chain.next = next;
15718 storage.push_storage(storage_value);
15719 let raw_ptr = storage.push_value_mut(raw);
15720 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15721 }
15722 BufferDescriptorExtension::DawnBufferDescriptorErrorInfoFromWireClient(
15723 value,
15724 ) => {
15725 let (mut raw, storage_value) = value.to_ffi();
15726 raw.chain.sType = SType::DawnBufferDescriptorErrorInfoFromWireClient
15727 .into();
15728 raw.chain.next = next;
15729 storage.push_storage(storage_value);
15730 let raw_ptr = storage.push_value_mut(raw);
15731 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15732 }
15733 BufferDescriptorExtension::DawnFakeBufferOOMForTesting(value) => {
15734 let (mut raw, storage_value) = value.to_ffi();
15735 raw.chain.sType = SType::DawnFakeBufferOOMForTesting.into();
15736 raw.chain.next = next;
15737 storage.push_storage(storage_value);
15738 let raw_ptr = storage.push_value_mut(raw);
15739 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15740 }
15741 }
15742 }
15743 }
15744 #[allow(dead_code)]
15745 pub enum ColorTargetStateExtension {
15746 ColorTargetStateExpandResolveTextureDawn(
15747 ColorTargetStateExpandResolveTextureDawn,
15748 ),
15749 }
15750 impl std::convert::From<ColorTargetStateExpandResolveTextureDawn>
15751 for ColorTargetStateExtension {
15752 fn from(ext: ColorTargetStateExpandResolveTextureDawn) -> Self {
15753 ColorTargetStateExtension::ColorTargetStateExpandResolveTextureDawn(ext)
15754 }
15755 }
15756 impl ColorTargetStateExtension {
15757 pub(crate) fn push_chain(
15758 &self,
15759 storage: &mut ChainedStructStorage,
15760 next: *mut ffi::WGPUChainedStruct,
15761 ) -> *mut ffi::WGPUChainedStruct {
15762 match self {
15763 ColorTargetStateExtension::ColorTargetStateExpandResolveTextureDawn(
15764 value,
15765 ) => {
15766 let (mut raw, storage_value) = value.to_ffi();
15767 raw.chain.sType = SType::ColorTargetStateExpandResolveTextureDawn
15768 .into();
15769 raw.chain.next = next;
15770 storage.push_storage(storage_value);
15771 let raw_ptr = storage.push_value_mut(raw);
15772 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15773 }
15774 }
15775 }
15776 }
15777 #[allow(dead_code)]
15778 pub enum CommandBufferDescriptorExtension {}
15779 impl CommandBufferDescriptorExtension {
15780 pub(crate) fn push_chain(
15781 &self,
15782 storage: &mut ChainedStructStorage,
15783 next: *mut ffi::WGPUChainedStruct,
15784 ) -> *mut ffi::WGPUChainedStruct {
15785 let _ = self;
15786 let _ = storage;
15787 next
15788 }
15789 }
15790 #[allow(dead_code)]
15791 pub enum CommandEncoderDescriptorExtension {
15792 DawnEncoderInternalUsageDescriptor(DawnEncoderInternalUsageDescriptor),
15793 }
15794 impl std::convert::From<DawnEncoderInternalUsageDescriptor>
15795 for CommandEncoderDescriptorExtension {
15796 fn from(ext: DawnEncoderInternalUsageDescriptor) -> Self {
15797 CommandEncoderDescriptorExtension::DawnEncoderInternalUsageDescriptor(ext)
15798 }
15799 }
15800 impl CommandEncoderDescriptorExtension {
15801 pub(crate) fn push_chain(
15802 &self,
15803 storage: &mut ChainedStructStorage,
15804 next: *mut ffi::WGPUChainedStruct,
15805 ) -> *mut ffi::WGPUChainedStruct {
15806 match self {
15807 CommandEncoderDescriptorExtension::DawnEncoderInternalUsageDescriptor(
15808 value,
15809 ) => {
15810 let (mut raw, storage_value) = value.to_ffi();
15811 raw.chain.sType = SType::DawnEncoderInternalUsageDescriptor.into();
15812 raw.chain.next = next;
15813 storage.push_storage(storage_value);
15814 let raw_ptr = storage.push_value_mut(raw);
15815 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15816 }
15817 }
15818 }
15819 }
15820 #[allow(dead_code)]
15821 pub enum CompilationInfoExtension {}
15822 impl CompilationInfoExtension {
15823 pub(crate) fn push_chain(
15824 &self,
15825 storage: &mut ChainedStructStorage,
15826 next: *mut ffi::WGPUChainedStruct,
15827 ) -> *mut ffi::WGPUChainedStruct {
15828 let _ = self;
15829 let _ = storage;
15830 next
15831 }
15832 }
15833 #[allow(dead_code)]
15834 pub enum CompilationMessageExtension {
15835 DawnCompilationMessageUtf16(DawnCompilationMessageUtf16),
15836 }
15837 impl std::convert::From<DawnCompilationMessageUtf16>
15838 for CompilationMessageExtension {
15839 fn from(ext: DawnCompilationMessageUtf16) -> Self {
15840 CompilationMessageExtension::DawnCompilationMessageUtf16(ext)
15841 }
15842 }
15843 impl CompilationMessageExtension {
15844 pub(crate) fn push_chain(
15845 &self,
15846 storage: &mut ChainedStructStorage,
15847 next: *mut ffi::WGPUChainedStruct,
15848 ) -> *mut ffi::WGPUChainedStruct {
15849 match self {
15850 CompilationMessageExtension::DawnCompilationMessageUtf16(value) => {
15851 let (mut raw, storage_value) = value.to_ffi();
15852 raw.chain.sType = SType::DawnCompilationMessageUtf16.into();
15853 raw.chain.next = next;
15854 storage.push_storage(storage_value);
15855 let raw_ptr = storage.push_value_mut(raw);
15856 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15857 }
15858 }
15859 }
15860 }
15861 #[allow(dead_code)]
15862 pub enum ComputePassDescriptorExtension {}
15863 impl ComputePassDescriptorExtension {
15864 pub(crate) fn push_chain(
15865 &self,
15866 storage: &mut ChainedStructStorage,
15867 next: *mut ffi::WGPUChainedStruct,
15868 ) -> *mut ffi::WGPUChainedStruct {
15869 let _ = self;
15870 let _ = storage;
15871 next
15872 }
15873 }
15874 #[allow(dead_code)]
15875 pub enum ComputePipelineDescriptorExtension {}
15876 impl ComputePipelineDescriptorExtension {
15877 pub(crate) fn push_chain(
15878 &self,
15879 storage: &mut ChainedStructStorage,
15880 next: *mut ffi::WGPUChainedStruct,
15881 ) -> *mut ffi::WGPUChainedStruct {
15882 let _ = self;
15883 let _ = storage;
15884 next
15885 }
15886 }
15887 #[allow(dead_code)]
15888 pub enum ComputeStateExtension {}
15889 impl ComputeStateExtension {
15890 pub(crate) fn push_chain(
15891 &self,
15892 storage: &mut ChainedStructStorage,
15893 next: *mut ffi::WGPUChainedStruct,
15894 ) -> *mut ffi::WGPUChainedStruct {
15895 let _ = self;
15896 let _ = storage;
15897 next
15898 }
15899 }
15900 #[allow(dead_code)]
15901 pub enum ConstantEntryExtension {}
15902 impl ConstantEntryExtension {
15903 pub(crate) fn push_chain(
15904 &self,
15905 storage: &mut ChainedStructStorage,
15906 next: *mut ffi::WGPUChainedStruct,
15907 ) -> *mut ffi::WGPUChainedStruct {
15908 let _ = self;
15909 let _ = storage;
15910 next
15911 }
15912 }
15913 #[allow(dead_code)]
15914 pub enum CopyTextureForBrowserOptionsExtension {}
15915 impl CopyTextureForBrowserOptionsExtension {
15916 pub(crate) fn push_chain(
15917 &self,
15918 storage: &mut ChainedStructStorage,
15919 next: *mut ffi::WGPUChainedStruct,
15920 ) -> *mut ffi::WGPUChainedStruct {
15921 let _ = self;
15922 let _ = storage;
15923 next
15924 }
15925 }
15926 #[allow(dead_code)]
15927 pub enum DawnFormatCapabilitiesExtension {
15928 DawnDrmFormatCapabilities(DawnDrmFormatCapabilities),
15929 }
15930 impl std::convert::From<DawnDrmFormatCapabilities>
15931 for DawnFormatCapabilitiesExtension {
15932 fn from(ext: DawnDrmFormatCapabilities) -> Self {
15933 DawnFormatCapabilitiesExtension::DawnDrmFormatCapabilities(ext)
15934 }
15935 }
15936 impl DawnFormatCapabilitiesExtension {
15937 pub(crate) fn push_chain(
15938 &self,
15939 storage: &mut ChainedStructStorage,
15940 next: *mut ffi::WGPUChainedStruct,
15941 ) -> *mut ffi::WGPUChainedStruct {
15942 match self {
15943 DawnFormatCapabilitiesExtension::DawnDrmFormatCapabilities(value) => {
15944 let (mut raw, storage_value) = value.to_ffi();
15945 raw.chain.sType = SType::DawnDrmFormatCapabilities.into();
15946 raw.chain.next = next;
15947 storage.push_storage(storage_value);
15948 let raw_ptr = storage.push_value_mut(raw);
15949 raw_ptr.cast::<ffi::WGPUChainedStruct>()
15950 }
15951 }
15952 }
15953 }
15954 #[allow(dead_code)]
15955 pub enum DepthStencilStateExtension {}
15956 impl DepthStencilStateExtension {
15957 pub(crate) fn push_chain(
15958 &self,
15959 storage: &mut ChainedStructStorage,
15960 next: *mut ffi::WGPUChainedStruct,
15961 ) -> *mut ffi::WGPUChainedStruct {
15962 let _ = self;
15963 let _ = storage;
15964 next
15965 }
15966 }
15967 #[allow(dead_code)]
15968 pub enum DeviceDescriptorExtension {
15969 DawnCacheDeviceDescriptor(DawnCacheDeviceDescriptor),
15970 DawnConsumeAdapterDescriptor(DawnConsumeAdapterDescriptor),
15971 DawnDeviceAllocatorControl(DawnDeviceAllocatorControl),
15972 DawnFakeDeviceInitializeErrorForTesting(DawnFakeDeviceInitializeErrorForTesting),
15973 DawnTogglesDescriptor(DawnTogglesDescriptor),
15974 }
15975 impl std::convert::From<DawnCacheDeviceDescriptor> for DeviceDescriptorExtension {
15976 fn from(ext: DawnCacheDeviceDescriptor) -> Self {
15977 DeviceDescriptorExtension::DawnCacheDeviceDescriptor(ext)
15978 }
15979 }
15980 impl std::convert::From<DawnConsumeAdapterDescriptor> for DeviceDescriptorExtension {
15981 fn from(ext: DawnConsumeAdapterDescriptor) -> Self {
15982 DeviceDescriptorExtension::DawnConsumeAdapterDescriptor(ext)
15983 }
15984 }
15985 impl std::convert::From<DawnDeviceAllocatorControl> for DeviceDescriptorExtension {
15986 fn from(ext: DawnDeviceAllocatorControl) -> Self {
15987 DeviceDescriptorExtension::DawnDeviceAllocatorControl(ext)
15988 }
15989 }
15990 impl std::convert::From<DawnFakeDeviceInitializeErrorForTesting>
15991 for DeviceDescriptorExtension {
15992 fn from(ext: DawnFakeDeviceInitializeErrorForTesting) -> Self {
15993 DeviceDescriptorExtension::DawnFakeDeviceInitializeErrorForTesting(ext)
15994 }
15995 }
15996 impl std::convert::From<DawnTogglesDescriptor> for DeviceDescriptorExtension {
15997 fn from(ext: DawnTogglesDescriptor) -> Self {
15998 DeviceDescriptorExtension::DawnTogglesDescriptor(ext)
15999 }
16000 }
16001 impl DeviceDescriptorExtension {
16002 pub(crate) fn push_chain(
16003 &self,
16004 storage: &mut ChainedStructStorage,
16005 next: *mut ffi::WGPUChainedStruct,
16006 ) -> *mut ffi::WGPUChainedStruct {
16007 match self {
16008 DeviceDescriptorExtension::DawnCacheDeviceDescriptor(value) => {
16009 let (mut raw, storage_value) = value.to_ffi();
16010 raw.chain.sType = SType::DawnCacheDeviceDescriptor.into();
16011 raw.chain.next = next;
16012 storage.push_storage(storage_value);
16013 let raw_ptr = storage.push_value_mut(raw);
16014 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16015 }
16016 DeviceDescriptorExtension::DawnConsumeAdapterDescriptor(value) => {
16017 let (mut raw, storage_value) = value.to_ffi();
16018 raw.chain.sType = SType::DawnConsumeAdapterDescriptor.into();
16019 raw.chain.next = next;
16020 storage.push_storage(storage_value);
16021 let raw_ptr = storage.push_value_mut(raw);
16022 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16023 }
16024 DeviceDescriptorExtension::DawnDeviceAllocatorControl(value) => {
16025 let (mut raw, storage_value) = value.to_ffi();
16026 raw.chain.sType = SType::DawnDeviceAllocatorControl.into();
16027 raw.chain.next = next;
16028 storage.push_storage(storage_value);
16029 let raw_ptr = storage.push_value_mut(raw);
16030 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16031 }
16032 DeviceDescriptorExtension::DawnFakeDeviceInitializeErrorForTesting(
16033 value,
16034 ) => {
16035 let (mut raw, storage_value) = value.to_ffi();
16036 raw.chain.sType = SType::DawnFakeDeviceInitializeErrorForTesting
16037 .into();
16038 raw.chain.next = next;
16039 storage.push_storage(storage_value);
16040 let raw_ptr = storage.push_value_mut(raw);
16041 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16042 }
16043 DeviceDescriptorExtension::DawnTogglesDescriptor(value) => {
16044 let (mut raw, storage_value) = value.to_ffi();
16045 raw.chain.sType = SType::DawnTogglesDescriptor.into();
16046 raw.chain.next = next;
16047 storage.push_storage(storage_value);
16048 let raw_ptr = storage.push_value_mut(raw);
16049 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16050 }
16051 }
16052 }
16053 }
16054 #[allow(dead_code)]
16055 pub enum ExternalTextureDescriptorExtension {}
16056 impl ExternalTextureDescriptorExtension {
16057 pub(crate) fn push_chain(
16058 &self,
16059 storage: &mut ChainedStructStorage,
16060 next: *mut ffi::WGPUChainedStruct,
16061 ) -> *mut ffi::WGPUChainedStruct {
16062 let _ = self;
16063 let _ = storage;
16064 next
16065 }
16066 }
16067 #[allow(dead_code)]
16068 pub enum FragmentStateExtension {}
16069 impl FragmentStateExtension {
16070 pub(crate) fn push_chain(
16071 &self,
16072 storage: &mut ChainedStructStorage,
16073 next: *mut ffi::WGPUChainedStruct,
16074 ) -> *mut ffi::WGPUChainedStruct {
16075 let _ = self;
16076 let _ = storage;
16077 next
16078 }
16079 }
16080 #[allow(dead_code)]
16081 pub enum ImageCopyExternalTextureExtension {}
16082 impl ImageCopyExternalTextureExtension {
16083 pub(crate) fn push_chain(
16084 &self,
16085 storage: &mut ChainedStructStorage,
16086 next: *mut ffi::WGPUChainedStruct,
16087 ) -> *mut ffi::WGPUChainedStruct {
16088 let _ = self;
16089 let _ = storage;
16090 next
16091 }
16092 }
16093 #[allow(dead_code)]
16094 pub enum InstanceDescriptorExtension {
16095 DawnWGSLBlocklist(DawnWGSLBlocklist),
16096 DawnTogglesDescriptor(DawnTogglesDescriptor),
16097 DawnWireWGSLControl(DawnWireWGSLControl),
16098 }
16099 impl std::convert::From<DawnWGSLBlocklist> for InstanceDescriptorExtension {
16100 fn from(ext: DawnWGSLBlocklist) -> Self {
16101 InstanceDescriptorExtension::DawnWGSLBlocklist(ext)
16102 }
16103 }
16104 impl std::convert::From<DawnTogglesDescriptor> for InstanceDescriptorExtension {
16105 fn from(ext: DawnTogglesDescriptor) -> Self {
16106 InstanceDescriptorExtension::DawnTogglesDescriptor(ext)
16107 }
16108 }
16109 impl std::convert::From<DawnWireWGSLControl> for InstanceDescriptorExtension {
16110 fn from(ext: DawnWireWGSLControl) -> Self {
16111 InstanceDescriptorExtension::DawnWireWGSLControl(ext)
16112 }
16113 }
16114 impl InstanceDescriptorExtension {
16115 pub(crate) fn push_chain(
16116 &self,
16117 storage: &mut ChainedStructStorage,
16118 next: *mut ffi::WGPUChainedStruct,
16119 ) -> *mut ffi::WGPUChainedStruct {
16120 match self {
16121 InstanceDescriptorExtension::DawnWGSLBlocklist(value) => {
16122 let (mut raw, storage_value) = value.to_ffi();
16123 raw.chain.sType = SType::DawnWGSLBlocklist.into();
16124 raw.chain.next = next;
16125 storage.push_storage(storage_value);
16126 let raw_ptr = storage.push_value_mut(raw);
16127 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16128 }
16129 InstanceDescriptorExtension::DawnTogglesDescriptor(value) => {
16130 let (mut raw, storage_value) = value.to_ffi();
16131 raw.chain.sType = SType::DawnTogglesDescriptor.into();
16132 raw.chain.next = next;
16133 storage.push_storage(storage_value);
16134 let raw_ptr = storage.push_value_mut(raw);
16135 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16136 }
16137 InstanceDescriptorExtension::DawnWireWGSLControl(value) => {
16138 let (mut raw, storage_value) = value.to_ffi();
16139 raw.chain.sType = SType::DawnWireWGSLControl.into();
16140 raw.chain.next = next;
16141 storage.push_storage(storage_value);
16142 let raw_ptr = storage.push_value_mut(raw);
16143 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16144 }
16145 }
16146 }
16147 }
16148 #[allow(dead_code)]
16149 pub enum InstanceLimitsExtension {}
16150 impl InstanceLimitsExtension {
16151 pub(crate) fn push_chain(
16152 &self,
16153 storage: &mut ChainedStructStorage,
16154 next: *mut ffi::WGPUChainedStruct,
16155 ) -> *mut ffi::WGPUChainedStruct {
16156 let _ = self;
16157 let _ = storage;
16158 next
16159 }
16160 }
16161 #[allow(dead_code)]
16162 pub enum LimitsExtension {
16163 DawnHostMappedPointerLimits(DawnHostMappedPointerLimits),
16164 DawnTexelCopyBufferRowAlignmentLimits(DawnTexelCopyBufferRowAlignmentLimits),
16165 }
16166 impl std::convert::From<DawnHostMappedPointerLimits> for LimitsExtension {
16167 fn from(ext: DawnHostMappedPointerLimits) -> Self {
16168 LimitsExtension::DawnHostMappedPointerLimits(ext)
16169 }
16170 }
16171 impl std::convert::From<DawnTexelCopyBufferRowAlignmentLimits> for LimitsExtension {
16172 fn from(ext: DawnTexelCopyBufferRowAlignmentLimits) -> Self {
16173 LimitsExtension::DawnTexelCopyBufferRowAlignmentLimits(ext)
16174 }
16175 }
16176 impl LimitsExtension {
16177 pub(crate) fn push_chain(
16178 &self,
16179 storage: &mut ChainedStructStorage,
16180 next: *mut ffi::WGPUChainedStruct,
16181 ) -> *mut ffi::WGPUChainedStruct {
16182 match self {
16183 LimitsExtension::DawnHostMappedPointerLimits(value) => {
16184 let (mut raw, storage_value) = value.to_ffi();
16185 raw.chain.sType = SType::DawnHostMappedPointerLimits.into();
16186 raw.chain.next = next;
16187 storage.push_storage(storage_value);
16188 let raw_ptr = storage.push_value_mut(raw);
16189 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16190 }
16191 LimitsExtension::DawnTexelCopyBufferRowAlignmentLimits(value) => {
16192 let (mut raw, storage_value) = value.to_ffi();
16193 raw.chain.sType = SType::DawnTexelCopyBufferRowAlignmentLimits
16194 .into();
16195 raw.chain.next = next;
16196 storage.push_storage(storage_value);
16197 let raw_ptr = storage.push_value_mut(raw);
16198 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16199 }
16200 }
16201 }
16202 }
16203 #[allow(dead_code)]
16204 pub enum MultisampleStateExtension {}
16205 impl MultisampleStateExtension {
16206 pub(crate) fn push_chain(
16207 &self,
16208 storage: &mut ChainedStructStorage,
16209 next: *mut ffi::WGPUChainedStruct,
16210 ) -> *mut ffi::WGPUChainedStruct {
16211 let _ = self;
16212 let _ = storage;
16213 next
16214 }
16215 }
16216 #[allow(dead_code)]
16217 pub enum PassTimestampWritesExtension {}
16218 impl PassTimestampWritesExtension {
16219 pub(crate) fn push_chain(
16220 &self,
16221 storage: &mut ChainedStructStorage,
16222 next: *mut ffi::WGPUChainedStruct,
16223 ) -> *mut ffi::WGPUChainedStruct {
16224 let _ = self;
16225 let _ = storage;
16226 next
16227 }
16228 }
16229 #[allow(dead_code)]
16230 pub enum PipelineLayoutDescriptorExtension {
16231 PipelineLayoutPixelLocalStorage(PipelineLayoutPixelLocalStorage),
16232 PipelineLayoutResourceTable(PipelineLayoutResourceTable),
16233 }
16234 impl std::convert::From<PipelineLayoutPixelLocalStorage>
16235 for PipelineLayoutDescriptorExtension {
16236 fn from(ext: PipelineLayoutPixelLocalStorage) -> Self {
16237 PipelineLayoutDescriptorExtension::PipelineLayoutPixelLocalStorage(ext)
16238 }
16239 }
16240 impl std::convert::From<PipelineLayoutResourceTable>
16241 for PipelineLayoutDescriptorExtension {
16242 fn from(ext: PipelineLayoutResourceTable) -> Self {
16243 PipelineLayoutDescriptorExtension::PipelineLayoutResourceTable(ext)
16244 }
16245 }
16246 impl PipelineLayoutDescriptorExtension {
16247 pub(crate) fn push_chain(
16248 &self,
16249 storage: &mut ChainedStructStorage,
16250 next: *mut ffi::WGPUChainedStruct,
16251 ) -> *mut ffi::WGPUChainedStruct {
16252 match self {
16253 PipelineLayoutDescriptorExtension::PipelineLayoutPixelLocalStorage(
16254 value,
16255 ) => {
16256 let (mut raw, storage_value) = value.to_ffi();
16257 raw.chain.sType = SType::PipelineLayoutPixelLocalStorage.into();
16258 raw.chain.next = next;
16259 storage.push_storage(storage_value);
16260 let raw_ptr = storage.push_value_mut(raw);
16261 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16262 }
16263 PipelineLayoutDescriptorExtension::PipelineLayoutResourceTable(
16264 value,
16265 ) => {
16266 let (mut raw, storage_value) = value.to_ffi();
16267 raw.chain.sType = SType::PipelineLayoutResourceTable.into();
16268 raw.chain.next = next;
16269 storage.push_storage(storage_value);
16270 let raw_ptr = storage.push_value_mut(raw);
16271 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16272 }
16273 }
16274 }
16275 }
16276 #[allow(dead_code)]
16277 pub enum PipelineLayoutStorageAttachmentExtension {}
16278 impl PipelineLayoutStorageAttachmentExtension {
16279 pub(crate) fn push_chain(
16280 &self,
16281 storage: &mut ChainedStructStorage,
16282 next: *mut ffi::WGPUChainedStruct,
16283 ) -> *mut ffi::WGPUChainedStruct {
16284 let _ = self;
16285 let _ = storage;
16286 next
16287 }
16288 }
16289 #[allow(dead_code)]
16290 pub enum PrimitiveStateExtension {}
16291 impl PrimitiveStateExtension {
16292 pub(crate) fn push_chain(
16293 &self,
16294 storage: &mut ChainedStructStorage,
16295 next: *mut ffi::WGPUChainedStruct,
16296 ) -> *mut ffi::WGPUChainedStruct {
16297 let _ = self;
16298 let _ = storage;
16299 next
16300 }
16301 }
16302 #[allow(dead_code)]
16303 pub enum QuerySetDescriptorExtension {}
16304 impl QuerySetDescriptorExtension {
16305 pub(crate) fn push_chain(
16306 &self,
16307 storage: &mut ChainedStructStorage,
16308 next: *mut ffi::WGPUChainedStruct,
16309 ) -> *mut ffi::WGPUChainedStruct {
16310 let _ = self;
16311 let _ = storage;
16312 next
16313 }
16314 }
16315 #[allow(dead_code)]
16316 pub enum QueueDescriptorExtension {}
16317 impl QueueDescriptorExtension {
16318 pub(crate) fn push_chain(
16319 &self,
16320 storage: &mut ChainedStructStorage,
16321 next: *mut ffi::WGPUChainedStruct,
16322 ) -> *mut ffi::WGPUChainedStruct {
16323 let _ = self;
16324 let _ = storage;
16325 next
16326 }
16327 }
16328 #[allow(dead_code)]
16329 pub enum RenderBundleDescriptorExtension {}
16330 impl RenderBundleDescriptorExtension {
16331 pub(crate) fn push_chain(
16332 &self,
16333 storage: &mut ChainedStructStorage,
16334 next: *mut ffi::WGPUChainedStruct,
16335 ) -> *mut ffi::WGPUChainedStruct {
16336 let _ = self;
16337 let _ = storage;
16338 next
16339 }
16340 }
16341 #[allow(dead_code)]
16342 pub enum RenderBundleEncoderDescriptorExtension {}
16343 impl RenderBundleEncoderDescriptorExtension {
16344 pub(crate) fn push_chain(
16345 &self,
16346 storage: &mut ChainedStructStorage,
16347 next: *mut ffi::WGPUChainedStruct,
16348 ) -> *mut ffi::WGPUChainedStruct {
16349 let _ = self;
16350 let _ = storage;
16351 next
16352 }
16353 }
16354 #[allow(dead_code)]
16355 pub enum RenderPassColorAttachmentExtension {}
16356 impl RenderPassColorAttachmentExtension {
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 RenderPassDepthStencilAttachmentExtension {}
16369 impl RenderPassDepthStencilAttachmentExtension {
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 RenderPassDescriptorExtension {
16382 DawnRenderPassSampleCount(DawnRenderPassSampleCount),
16383 RenderPassDescriptorExpandResolveRect(RenderPassDescriptorExpandResolveRect),
16384 RenderPassDescriptorResolveRect(RenderPassDescriptorResolveRect),
16385 RenderPassMaxDrawCount(RenderPassMaxDrawCount),
16386 RenderPassPixelLocalStorage(RenderPassPixelLocalStorage),
16387 }
16388 impl std::convert::From<DawnRenderPassSampleCount>
16389 for RenderPassDescriptorExtension {
16390 fn from(ext: DawnRenderPassSampleCount) -> Self {
16391 RenderPassDescriptorExtension::DawnRenderPassSampleCount(ext)
16392 }
16393 }
16394 impl std::convert::From<RenderPassDescriptorExpandResolveRect>
16395 for RenderPassDescriptorExtension {
16396 fn from(ext: RenderPassDescriptorExpandResolveRect) -> Self {
16397 RenderPassDescriptorExtension::RenderPassDescriptorExpandResolveRect(ext)
16398 }
16399 }
16400 impl std::convert::From<RenderPassDescriptorResolveRect>
16401 for RenderPassDescriptorExtension {
16402 fn from(ext: RenderPassDescriptorResolveRect) -> Self {
16403 RenderPassDescriptorExtension::RenderPassDescriptorResolveRect(ext)
16404 }
16405 }
16406 impl std::convert::From<RenderPassMaxDrawCount> for RenderPassDescriptorExtension {
16407 fn from(ext: RenderPassMaxDrawCount) -> Self {
16408 RenderPassDescriptorExtension::RenderPassMaxDrawCount(ext)
16409 }
16410 }
16411 impl std::convert::From<RenderPassPixelLocalStorage>
16412 for RenderPassDescriptorExtension {
16413 fn from(ext: RenderPassPixelLocalStorage) -> Self {
16414 RenderPassDescriptorExtension::RenderPassPixelLocalStorage(ext)
16415 }
16416 }
16417 impl RenderPassDescriptorExtension {
16418 pub(crate) fn push_chain(
16419 &self,
16420 storage: &mut ChainedStructStorage,
16421 next: *mut ffi::WGPUChainedStruct,
16422 ) -> *mut ffi::WGPUChainedStruct {
16423 match self {
16424 RenderPassDescriptorExtension::DawnRenderPassSampleCount(value) => {
16425 let (mut raw, storage_value) = value.to_ffi();
16426 raw.chain.sType = SType::DawnRenderPassSampleCount.into();
16427 raw.chain.next = next;
16428 storage.push_storage(storage_value);
16429 let raw_ptr = storage.push_value_mut(raw);
16430 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16431 }
16432 RenderPassDescriptorExtension::RenderPassDescriptorExpandResolveRect(
16433 value,
16434 ) => {
16435 let (mut raw, storage_value) = value.to_ffi();
16436 raw.chain.sType = SType::RenderPassDescriptorExpandResolveRect
16437 .into();
16438 raw.chain.next = next;
16439 storage.push_storage(storage_value);
16440 let raw_ptr = storage.push_value_mut(raw);
16441 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16442 }
16443 RenderPassDescriptorExtension::RenderPassDescriptorResolveRect(
16444 value,
16445 ) => {
16446 let (mut raw, storage_value) = value.to_ffi();
16447 raw.chain.sType = SType::RenderPassDescriptorResolveRect.into();
16448 raw.chain.next = next;
16449 storage.push_storage(storage_value);
16450 let raw_ptr = storage.push_value_mut(raw);
16451 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16452 }
16453 RenderPassDescriptorExtension::RenderPassMaxDrawCount(value) => {
16454 let (mut raw, storage_value) = value.to_ffi();
16455 raw.chain.sType = SType::RenderPassMaxDrawCount.into();
16456 raw.chain.next = next;
16457 storage.push_storage(storage_value);
16458 let raw_ptr = storage.push_value_mut(raw);
16459 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16460 }
16461 RenderPassDescriptorExtension::RenderPassPixelLocalStorage(value) => {
16462 let (mut raw, storage_value) = value.to_ffi();
16463 raw.chain.sType = SType::RenderPassPixelLocalStorage.into();
16464 raw.chain.next = next;
16465 storage.push_storage(storage_value);
16466 let raw_ptr = storage.push_value_mut(raw);
16467 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16468 }
16469 }
16470 }
16471 }
16472 #[allow(dead_code)]
16473 pub enum RenderPassStorageAttachmentExtension {}
16474 impl RenderPassStorageAttachmentExtension {
16475 pub(crate) fn push_chain(
16476 &self,
16477 storage: &mut ChainedStructStorage,
16478 next: *mut ffi::WGPUChainedStruct,
16479 ) -> *mut ffi::WGPUChainedStruct {
16480 let _ = self;
16481 let _ = storage;
16482 next
16483 }
16484 }
16485 #[allow(dead_code)]
16486 pub enum RenderPipelineDescriptorExtension {}
16487 impl RenderPipelineDescriptorExtension {
16488 pub(crate) fn push_chain(
16489 &self,
16490 storage: &mut ChainedStructStorage,
16491 next: *mut ffi::WGPUChainedStruct,
16492 ) -> *mut ffi::WGPUChainedStruct {
16493 let _ = self;
16494 let _ = storage;
16495 next
16496 }
16497 }
16498 #[allow(dead_code)]
16499 pub enum RequestAdapterOptionsExtension {
16500 DawnTogglesDescriptor(DawnTogglesDescriptor),
16501 RequestAdapterWebGPUBackendOptions(RequestAdapterWebGPUBackendOptions),
16502 RequestAdapterWebXROptions(RequestAdapterWebXROptions),
16503 }
16504 impl std::convert::From<DawnTogglesDescriptor> for RequestAdapterOptionsExtension {
16505 fn from(ext: DawnTogglesDescriptor) -> Self {
16506 RequestAdapterOptionsExtension::DawnTogglesDescriptor(ext)
16507 }
16508 }
16509 impl std::convert::From<RequestAdapterWebGPUBackendOptions>
16510 for RequestAdapterOptionsExtension {
16511 fn from(ext: RequestAdapterWebGPUBackendOptions) -> Self {
16512 RequestAdapterOptionsExtension::RequestAdapterWebGPUBackendOptions(ext)
16513 }
16514 }
16515 impl std::convert::From<RequestAdapterWebXROptions>
16516 for RequestAdapterOptionsExtension {
16517 fn from(ext: RequestAdapterWebXROptions) -> Self {
16518 RequestAdapterOptionsExtension::RequestAdapterWebXROptions(ext)
16519 }
16520 }
16521 impl RequestAdapterOptionsExtension {
16522 pub(crate) fn push_chain(
16523 &self,
16524 storage: &mut ChainedStructStorage,
16525 next: *mut ffi::WGPUChainedStruct,
16526 ) -> *mut ffi::WGPUChainedStruct {
16527 match self {
16528 RequestAdapterOptionsExtension::DawnTogglesDescriptor(value) => {
16529 let (mut raw, storage_value) = value.to_ffi();
16530 raw.chain.sType = SType::DawnTogglesDescriptor.into();
16531 raw.chain.next = next;
16532 storage.push_storage(storage_value);
16533 let raw_ptr = storage.push_value_mut(raw);
16534 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16535 }
16536 RequestAdapterOptionsExtension::RequestAdapterWebGPUBackendOptions(
16537 value,
16538 ) => {
16539 let (mut raw, storage_value) = value.to_ffi();
16540 raw.chain.sType = SType::RequestAdapterWebGPUBackendOptions.into();
16541 raw.chain.next = next;
16542 storage.push_storage(storage_value);
16543 let raw_ptr = storage.push_value_mut(raw);
16544 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16545 }
16546 RequestAdapterOptionsExtension::RequestAdapterWebXROptions(value) => {
16547 let (mut raw, storage_value) = value.to_ffi();
16548 raw.chain.sType = SType::RequestAdapterWebXROptions.into();
16549 raw.chain.next = next;
16550 storage.push_storage(storage_value);
16551 let raw_ptr = storage.push_value_mut(raw);
16552 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16553 }
16554 }
16555 }
16556 }
16557 #[allow(dead_code)]
16558 pub enum ResourceTableDescriptorExtension {}
16559 impl ResourceTableDescriptorExtension {
16560 pub(crate) fn push_chain(
16561 &self,
16562 storage: &mut ChainedStructStorage,
16563 next: *mut ffi::WGPUChainedStruct,
16564 ) -> *mut ffi::WGPUChainedStruct {
16565 let _ = self;
16566 let _ = storage;
16567 next
16568 }
16569 }
16570 #[allow(dead_code)]
16571 pub enum SamplerBindingLayoutExtension {}
16572 impl SamplerBindingLayoutExtension {
16573 pub(crate) fn push_chain(
16574 &self,
16575 storage: &mut ChainedStructStorage,
16576 next: *mut ffi::WGPUChainedStruct,
16577 ) -> *mut ffi::WGPUChainedStruct {
16578 let _ = self;
16579 let _ = storage;
16580 next
16581 }
16582 }
16583 #[allow(dead_code)]
16584 pub enum SamplerDescriptorExtension {
16585 YCbCrVkDescriptor(YCbCrVkDescriptor),
16586 }
16587 impl std::convert::From<YCbCrVkDescriptor> for SamplerDescriptorExtension {
16588 fn from(ext: YCbCrVkDescriptor) -> Self {
16589 SamplerDescriptorExtension::YCbCrVkDescriptor(ext)
16590 }
16591 }
16592 impl SamplerDescriptorExtension {
16593 pub(crate) fn push_chain(
16594 &self,
16595 storage: &mut ChainedStructStorage,
16596 next: *mut ffi::WGPUChainedStruct,
16597 ) -> *mut ffi::WGPUChainedStruct {
16598 match self {
16599 SamplerDescriptorExtension::YCbCrVkDescriptor(value) => {
16600 let (mut raw, storage_value) = value.to_ffi();
16601 raw.chain.sType = SType::YCbCrVkDescriptor.into();
16602 raw.chain.next = next;
16603 storage.push_storage(storage_value);
16604 let raw_ptr = storage.push_value_mut(raw);
16605 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16606 }
16607 }
16608 }
16609 }
16610 #[allow(dead_code)]
16611 pub enum ShaderModuleDescriptorExtension {
16612 DawnShaderModuleSPIRVOptionsDescriptor(DawnShaderModuleSPIRVOptionsDescriptor),
16613 ShaderModuleCompilationOptions(ShaderModuleCompilationOptions),
16614 ShaderSourceSPIRV(ShaderSourceSPIRV),
16615 ShaderSourceWGSL(ShaderSourceWGSL),
16616 }
16617 impl std::convert::From<DawnShaderModuleSPIRVOptionsDescriptor>
16618 for ShaderModuleDescriptorExtension {
16619 fn from(ext: DawnShaderModuleSPIRVOptionsDescriptor) -> Self {
16620 ShaderModuleDescriptorExtension::DawnShaderModuleSPIRVOptionsDescriptor(ext)
16621 }
16622 }
16623 impl std::convert::From<ShaderModuleCompilationOptions>
16624 for ShaderModuleDescriptorExtension {
16625 fn from(ext: ShaderModuleCompilationOptions) -> Self {
16626 ShaderModuleDescriptorExtension::ShaderModuleCompilationOptions(ext)
16627 }
16628 }
16629 impl std::convert::From<ShaderSourceSPIRV> for ShaderModuleDescriptorExtension {
16630 fn from(ext: ShaderSourceSPIRV) -> Self {
16631 ShaderModuleDescriptorExtension::ShaderSourceSPIRV(ext)
16632 }
16633 }
16634 impl std::convert::From<ShaderSourceWGSL> for ShaderModuleDescriptorExtension {
16635 fn from(ext: ShaderSourceWGSL) -> Self {
16636 ShaderModuleDescriptorExtension::ShaderSourceWGSL(ext)
16637 }
16638 }
16639 impl ShaderModuleDescriptorExtension {
16640 pub(crate) fn push_chain(
16641 &self,
16642 storage: &mut ChainedStructStorage,
16643 next: *mut ffi::WGPUChainedStruct,
16644 ) -> *mut ffi::WGPUChainedStruct {
16645 match self {
16646 ShaderModuleDescriptorExtension::DawnShaderModuleSPIRVOptionsDescriptor(
16647 value,
16648 ) => {
16649 let (mut raw, storage_value) = value.to_ffi();
16650 raw.chain.sType = SType::DawnShaderModuleSPIRVOptionsDescriptor
16651 .into();
16652 raw.chain.next = next;
16653 storage.push_storage(storage_value);
16654 let raw_ptr = storage.push_value_mut(raw);
16655 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16656 }
16657 ShaderModuleDescriptorExtension::ShaderModuleCompilationOptions(
16658 value,
16659 ) => {
16660 let (mut raw, storage_value) = value.to_ffi();
16661 raw.chain.sType = SType::ShaderModuleCompilationOptions.into();
16662 raw.chain.next = next;
16663 storage.push_storage(storage_value);
16664 let raw_ptr = storage.push_value_mut(raw);
16665 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16666 }
16667 ShaderModuleDescriptorExtension::ShaderSourceSPIRV(value) => {
16668 let (mut raw, storage_value) = value.to_ffi();
16669 raw.chain.sType = SType::ShaderSourceSPIRV.into();
16670 raw.chain.next = next;
16671 storage.push_storage(storage_value);
16672 let raw_ptr = storage.push_value_mut(raw);
16673 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16674 }
16675 ShaderModuleDescriptorExtension::ShaderSourceWGSL(value) => {
16676 let (mut raw, storage_value) = value.to_ffi();
16677 raw.chain.sType = SType::ShaderSourceWGSL.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 }
16684 }
16685 }
16686 #[allow(dead_code)]
16687 pub enum SharedBufferMemoryBeginAccessDescriptorExtension {}
16688 impl SharedBufferMemoryBeginAccessDescriptorExtension {
16689 pub(crate) fn push_chain(
16690 &self,
16691 storage: &mut ChainedStructStorage,
16692 next: *mut ffi::WGPUChainedStruct,
16693 ) -> *mut ffi::WGPUChainedStruct {
16694 let _ = self;
16695 let _ = storage;
16696 next
16697 }
16698 }
16699 #[allow(dead_code)]
16700 pub enum SharedBufferMemoryDescriptorExtension {}
16701 impl SharedBufferMemoryDescriptorExtension {
16702 pub(crate) fn push_chain(
16703 &self,
16704 storage: &mut ChainedStructStorage,
16705 next: *mut ffi::WGPUChainedStruct,
16706 ) -> *mut ffi::WGPUChainedStruct {
16707 let _ = self;
16708 let _ = storage;
16709 next
16710 }
16711 }
16712 #[allow(dead_code)]
16713 pub enum SharedBufferMemoryEndAccessStateExtension {}
16714 impl SharedBufferMemoryEndAccessStateExtension {
16715 pub(crate) fn push_chain(
16716 &self,
16717 storage: &mut ChainedStructStorage,
16718 next: *mut ffi::WGPUChainedStruct,
16719 ) -> *mut ffi::WGPUChainedStruct {
16720 let _ = self;
16721 let _ = storage;
16722 next
16723 }
16724 }
16725 #[allow(dead_code)]
16726 pub enum SharedBufferMemoryPropertiesExtension {}
16727 impl SharedBufferMemoryPropertiesExtension {
16728 pub(crate) fn push_chain(
16729 &self,
16730 storage: &mut ChainedStructStorage,
16731 next: *mut ffi::WGPUChainedStruct,
16732 ) -> *mut ffi::WGPUChainedStruct {
16733 let _ = self;
16734 let _ = storage;
16735 next
16736 }
16737 }
16738 #[allow(dead_code)]
16739 pub enum SharedFenceDescriptorExtension {
16740 SharedFenceDXGISharedHandleDescriptor(SharedFenceDXGISharedHandleDescriptor),
16741 SharedFenceEGLSyncDescriptor(SharedFenceEGLSyncDescriptor),
16742 SharedFenceMTLSharedEventDescriptor(SharedFenceMTLSharedEventDescriptor),
16743 SharedFenceSyncFDDescriptor(SharedFenceSyncFDDescriptor),
16744 SharedFenceVkSemaphoreOpaqueFDDescriptor(
16745 SharedFenceVkSemaphoreOpaqueFDDescriptor,
16746 ),
16747 SharedFenceVkSemaphoreZirconHandleDescriptor(
16748 SharedFenceVkSemaphoreZirconHandleDescriptor,
16749 ),
16750 }
16751 impl std::convert::From<SharedFenceDXGISharedHandleDescriptor>
16752 for SharedFenceDescriptorExtension {
16753 fn from(ext: SharedFenceDXGISharedHandleDescriptor) -> Self {
16754 SharedFenceDescriptorExtension::SharedFenceDXGISharedHandleDescriptor(ext)
16755 }
16756 }
16757 impl std::convert::From<SharedFenceEGLSyncDescriptor>
16758 for SharedFenceDescriptorExtension {
16759 fn from(ext: SharedFenceEGLSyncDescriptor) -> Self {
16760 SharedFenceDescriptorExtension::SharedFenceEGLSyncDescriptor(ext)
16761 }
16762 }
16763 impl std::convert::From<SharedFenceMTLSharedEventDescriptor>
16764 for SharedFenceDescriptorExtension {
16765 fn from(ext: SharedFenceMTLSharedEventDescriptor) -> Self {
16766 SharedFenceDescriptorExtension::SharedFenceMTLSharedEventDescriptor(ext)
16767 }
16768 }
16769 impl std::convert::From<SharedFenceSyncFDDescriptor>
16770 for SharedFenceDescriptorExtension {
16771 fn from(ext: SharedFenceSyncFDDescriptor) -> Self {
16772 SharedFenceDescriptorExtension::SharedFenceSyncFDDescriptor(ext)
16773 }
16774 }
16775 impl std::convert::From<SharedFenceVkSemaphoreOpaqueFDDescriptor>
16776 for SharedFenceDescriptorExtension {
16777 fn from(ext: SharedFenceVkSemaphoreOpaqueFDDescriptor) -> Self {
16778 SharedFenceDescriptorExtension::SharedFenceVkSemaphoreOpaqueFDDescriptor(ext)
16779 }
16780 }
16781 impl std::convert::From<SharedFenceVkSemaphoreZirconHandleDescriptor>
16782 for SharedFenceDescriptorExtension {
16783 fn from(ext: SharedFenceVkSemaphoreZirconHandleDescriptor) -> Self {
16784 SharedFenceDescriptorExtension::SharedFenceVkSemaphoreZirconHandleDescriptor(
16785 ext,
16786 )
16787 }
16788 }
16789 impl SharedFenceDescriptorExtension {
16790 pub(crate) fn push_chain(
16791 &self,
16792 storage: &mut ChainedStructStorage,
16793 next: *mut ffi::WGPUChainedStruct,
16794 ) -> *mut ffi::WGPUChainedStruct {
16795 match self {
16796 SharedFenceDescriptorExtension::SharedFenceDXGISharedHandleDescriptor(
16797 value,
16798 ) => {
16799 let (mut raw, storage_value) = value.to_ffi();
16800 raw.chain.sType = SType::SharedFenceDXGISharedHandleDescriptor
16801 .into();
16802 raw.chain.next = next;
16803 storage.push_storage(storage_value);
16804 let raw_ptr = storage.push_value_mut(raw);
16805 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16806 }
16807 SharedFenceDescriptorExtension::SharedFenceEGLSyncDescriptor(value) => {
16808 let (mut raw, storage_value) = value.to_ffi();
16809 raw.chain.sType = SType::SharedFenceEGLSyncDescriptor.into();
16810 raw.chain.next = next;
16811 storage.push_storage(storage_value);
16812 let raw_ptr = storage.push_value_mut(raw);
16813 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16814 }
16815 SharedFenceDescriptorExtension::SharedFenceMTLSharedEventDescriptor(
16816 value,
16817 ) => {
16818 let (mut raw, storage_value) = value.to_ffi();
16819 raw.chain.sType = SType::SharedFenceMTLSharedEventDescriptor.into();
16820 raw.chain.next = next;
16821 storage.push_storage(storage_value);
16822 let raw_ptr = storage.push_value_mut(raw);
16823 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16824 }
16825 SharedFenceDescriptorExtension::SharedFenceSyncFDDescriptor(value) => {
16826 let (mut raw, storage_value) = value.to_ffi();
16827 raw.chain.sType = SType::SharedFenceSyncFDDescriptor.into();
16828 raw.chain.next = next;
16829 storage.push_storage(storage_value);
16830 let raw_ptr = storage.push_value_mut(raw);
16831 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16832 }
16833 SharedFenceDescriptorExtension::SharedFenceVkSemaphoreOpaqueFDDescriptor(
16834 value,
16835 ) => {
16836 let (mut raw, storage_value) = value.to_ffi();
16837 raw.chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDDescriptor
16838 .into();
16839 raw.chain.next = next;
16840 storage.push_storage(storage_value);
16841 let raw_ptr = storage.push_value_mut(raw);
16842 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16843 }
16844 SharedFenceDescriptorExtension::SharedFenceVkSemaphoreZirconHandleDescriptor(
16845 value,
16846 ) => {
16847 let (mut raw, storage_value) = value.to_ffi();
16848 raw.chain.sType = SType::SharedFenceVkSemaphoreZirconHandleDescriptor
16849 .into();
16850 raw.chain.next = next;
16851 storage.push_storage(storage_value);
16852 let raw_ptr = storage.push_value_mut(raw);
16853 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16854 }
16855 }
16856 }
16857 }
16858 #[allow(dead_code)]
16859 pub enum SharedFenceExportInfoExtension {
16860 SharedFenceDXGISharedHandleExportInfo(SharedFenceDXGISharedHandleExportInfo),
16861 SharedFenceEGLSyncExportInfo(SharedFenceEGLSyncExportInfo),
16862 SharedFenceMTLSharedEventExportInfo(SharedFenceMTLSharedEventExportInfo),
16863 SharedFenceSyncFDExportInfo(SharedFenceSyncFDExportInfo),
16864 SharedFenceVkSemaphoreOpaqueFDExportInfo(
16865 SharedFenceVkSemaphoreOpaqueFDExportInfo,
16866 ),
16867 SharedFenceVkSemaphoreZirconHandleExportInfo(
16868 SharedFenceVkSemaphoreZirconHandleExportInfo,
16869 ),
16870 }
16871 impl std::convert::From<SharedFenceDXGISharedHandleExportInfo>
16872 for SharedFenceExportInfoExtension {
16873 fn from(ext: SharedFenceDXGISharedHandleExportInfo) -> Self {
16874 SharedFenceExportInfoExtension::SharedFenceDXGISharedHandleExportInfo(ext)
16875 }
16876 }
16877 impl std::convert::From<SharedFenceEGLSyncExportInfo>
16878 for SharedFenceExportInfoExtension {
16879 fn from(ext: SharedFenceEGLSyncExportInfo) -> Self {
16880 SharedFenceExportInfoExtension::SharedFenceEGLSyncExportInfo(ext)
16881 }
16882 }
16883 impl std::convert::From<SharedFenceMTLSharedEventExportInfo>
16884 for SharedFenceExportInfoExtension {
16885 fn from(ext: SharedFenceMTLSharedEventExportInfo) -> Self {
16886 SharedFenceExportInfoExtension::SharedFenceMTLSharedEventExportInfo(ext)
16887 }
16888 }
16889 impl std::convert::From<SharedFenceSyncFDExportInfo>
16890 for SharedFenceExportInfoExtension {
16891 fn from(ext: SharedFenceSyncFDExportInfo) -> Self {
16892 SharedFenceExportInfoExtension::SharedFenceSyncFDExportInfo(ext)
16893 }
16894 }
16895 impl std::convert::From<SharedFenceVkSemaphoreOpaqueFDExportInfo>
16896 for SharedFenceExportInfoExtension {
16897 fn from(ext: SharedFenceVkSemaphoreOpaqueFDExportInfo) -> Self {
16898 SharedFenceExportInfoExtension::SharedFenceVkSemaphoreOpaqueFDExportInfo(ext)
16899 }
16900 }
16901 impl std::convert::From<SharedFenceVkSemaphoreZirconHandleExportInfo>
16902 for SharedFenceExportInfoExtension {
16903 fn from(ext: SharedFenceVkSemaphoreZirconHandleExportInfo) -> Self {
16904 SharedFenceExportInfoExtension::SharedFenceVkSemaphoreZirconHandleExportInfo(
16905 ext,
16906 )
16907 }
16908 }
16909 impl SharedFenceExportInfoExtension {
16910 pub(crate) fn push_chain(
16911 &self,
16912 storage: &mut ChainedStructStorage,
16913 next: *mut ffi::WGPUChainedStruct,
16914 ) -> *mut ffi::WGPUChainedStruct {
16915 match self {
16916 SharedFenceExportInfoExtension::SharedFenceDXGISharedHandleExportInfo(
16917 value,
16918 ) => {
16919 let (mut raw, storage_value) = value.to_ffi();
16920 raw.chain.sType = SType::SharedFenceDXGISharedHandleExportInfo
16921 .into();
16922 raw.chain.next = next;
16923 storage.push_storage(storage_value);
16924 let raw_ptr = storage.push_value_mut(raw);
16925 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16926 }
16927 SharedFenceExportInfoExtension::SharedFenceEGLSyncExportInfo(value) => {
16928 let (mut raw, storage_value) = value.to_ffi();
16929 raw.chain.sType = SType::SharedFenceEGLSyncExportInfo.into();
16930 raw.chain.next = next;
16931 storage.push_storage(storage_value);
16932 let raw_ptr = storage.push_value_mut(raw);
16933 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16934 }
16935 SharedFenceExportInfoExtension::SharedFenceMTLSharedEventExportInfo(
16936 value,
16937 ) => {
16938 let (mut raw, storage_value) = value.to_ffi();
16939 raw.chain.sType = SType::SharedFenceMTLSharedEventExportInfo.into();
16940 raw.chain.next = next;
16941 storage.push_storage(storage_value);
16942 let raw_ptr = storage.push_value_mut(raw);
16943 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16944 }
16945 SharedFenceExportInfoExtension::SharedFenceSyncFDExportInfo(value) => {
16946 let (mut raw, storage_value) = value.to_ffi();
16947 raw.chain.sType = SType::SharedFenceSyncFDExportInfo.into();
16948 raw.chain.next = next;
16949 storage.push_storage(storage_value);
16950 let raw_ptr = storage.push_value_mut(raw);
16951 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16952 }
16953 SharedFenceExportInfoExtension::SharedFenceVkSemaphoreOpaqueFDExportInfo(
16954 value,
16955 ) => {
16956 let (mut raw, storage_value) = value.to_ffi();
16957 raw.chain.sType = SType::SharedFenceVkSemaphoreOpaqueFDExportInfo
16958 .into();
16959 raw.chain.next = next;
16960 storage.push_storage(storage_value);
16961 let raw_ptr = storage.push_value_mut(raw);
16962 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16963 }
16964 SharedFenceExportInfoExtension::SharedFenceVkSemaphoreZirconHandleExportInfo(
16965 value,
16966 ) => {
16967 let (mut raw, storage_value) = value.to_ffi();
16968 raw.chain.sType = SType::SharedFenceVkSemaphoreZirconHandleExportInfo
16969 .into();
16970 raw.chain.next = next;
16971 storage.push_storage(storage_value);
16972 let raw_ptr = storage.push_value_mut(raw);
16973 raw_ptr.cast::<ffi::WGPUChainedStruct>()
16974 }
16975 }
16976 }
16977 }
16978 #[allow(dead_code)]
16979 pub enum SharedTextureMemoryBeginAccessDescriptorExtension {
16980 SharedTextureMemoryD3DSwapchainBeginState(
16981 SharedTextureMemoryD3DSwapchainBeginState,
16982 ),
16983 SharedTextureMemoryD3D11BeginState(SharedTextureMemoryD3D11BeginState),
16984 SharedTextureMemoryVkImageLayoutBeginState(
16985 SharedTextureMemoryVkImageLayoutBeginState,
16986 ),
16987 }
16988 impl std::convert::From<SharedTextureMemoryD3DSwapchainBeginState>
16989 for SharedTextureMemoryBeginAccessDescriptorExtension {
16990 fn from(ext: SharedTextureMemoryD3DSwapchainBeginState) -> Self {
16991 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3DSwapchainBeginState(
16992 ext,
16993 )
16994 }
16995 }
16996 impl std::convert::From<SharedTextureMemoryD3D11BeginState>
16997 for SharedTextureMemoryBeginAccessDescriptorExtension {
16998 fn from(ext: SharedTextureMemoryD3D11BeginState) -> Self {
16999 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3D11BeginState(
17000 ext,
17001 )
17002 }
17003 }
17004 impl std::convert::From<SharedTextureMemoryVkImageLayoutBeginState>
17005 for SharedTextureMemoryBeginAccessDescriptorExtension {
17006 fn from(ext: SharedTextureMemoryVkImageLayoutBeginState) -> Self {
17007 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryVkImageLayoutBeginState(
17008 ext,
17009 )
17010 }
17011 }
17012 impl SharedTextureMemoryBeginAccessDescriptorExtension {
17013 pub(crate) fn push_chain(
17014 &self,
17015 storage: &mut ChainedStructStorage,
17016 next: *mut ffi::WGPUChainedStruct,
17017 ) -> *mut ffi::WGPUChainedStruct {
17018 match self {
17019 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3DSwapchainBeginState(
17020 value,
17021 ) => {
17022 let (mut raw, storage_value) = value.to_ffi();
17023 raw.chain.sType = SType::SharedTextureMemoryD3DSwapchainBeginState
17024 .into();
17025 raw.chain.next = next;
17026 storage.push_storage(storage_value);
17027 let raw_ptr = storage.push_value_mut(raw);
17028 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17029 }
17030 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryD3D11BeginState(
17031 value,
17032 ) => {
17033 let (mut raw, storage_value) = value.to_ffi();
17034 raw.chain.sType = SType::SharedTextureMemoryD3D11BeginState.into();
17035 raw.chain.next = next;
17036 storage.push_storage(storage_value);
17037 let raw_ptr = storage.push_value_mut(raw);
17038 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17039 }
17040 SharedTextureMemoryBeginAccessDescriptorExtension::SharedTextureMemoryVkImageLayoutBeginState(
17041 value,
17042 ) => {
17043 let (mut raw, storage_value) = value.to_ffi();
17044 raw.chain.sType = SType::SharedTextureMemoryVkImageLayoutBeginState
17045 .into();
17046 raw.chain.next = next;
17047 storage.push_storage(storage_value);
17048 let raw_ptr = storage.push_value_mut(raw);
17049 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17050 }
17051 }
17052 }
17053 }
17054 #[allow(dead_code)]
17055 pub enum SharedTextureMemoryDescriptorExtension {
17056 SharedTextureMemoryDXGISharedHandleDescriptor(
17057 SharedTextureMemoryDXGISharedHandleDescriptor,
17058 ),
17059 SharedTextureMemoryEGLImageDescriptor(SharedTextureMemoryEGLImageDescriptor),
17060 SharedTextureMemoryIOSurfaceDescriptor(SharedTextureMemoryIOSurfaceDescriptor),
17061 SharedTextureMemoryAHardwareBufferDescriptor(
17062 SharedTextureMemoryAHardwareBufferDescriptor,
17063 ),
17064 SharedTextureMemoryDmaBufDescriptor(SharedTextureMemoryDmaBufDescriptor),
17065 SharedTextureMemoryOpaqueFDDescriptor(SharedTextureMemoryOpaqueFDDescriptor),
17066 SharedTextureMemoryVkDedicatedAllocationDescriptor(
17067 SharedTextureMemoryVkDedicatedAllocationDescriptor,
17068 ),
17069 SharedTextureMemoryZirconHandleDescriptor(
17070 SharedTextureMemoryZirconHandleDescriptor,
17071 ),
17072 }
17073 impl std::convert::From<SharedTextureMemoryDXGISharedHandleDescriptor>
17074 for SharedTextureMemoryDescriptorExtension {
17075 fn from(ext: SharedTextureMemoryDXGISharedHandleDescriptor) -> Self {
17076 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDXGISharedHandleDescriptor(
17077 ext,
17078 )
17079 }
17080 }
17081 impl std::convert::From<SharedTextureMemoryEGLImageDescriptor>
17082 for SharedTextureMemoryDescriptorExtension {
17083 fn from(ext: SharedTextureMemoryEGLImageDescriptor) -> Self {
17084 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryEGLImageDescriptor(
17085 ext,
17086 )
17087 }
17088 }
17089 impl std::convert::From<SharedTextureMemoryIOSurfaceDescriptor>
17090 for SharedTextureMemoryDescriptorExtension {
17091 fn from(ext: SharedTextureMemoryIOSurfaceDescriptor) -> Self {
17092 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryIOSurfaceDescriptor(
17093 ext,
17094 )
17095 }
17096 }
17097 impl std::convert::From<SharedTextureMemoryAHardwareBufferDescriptor>
17098 for SharedTextureMemoryDescriptorExtension {
17099 fn from(ext: SharedTextureMemoryAHardwareBufferDescriptor) -> Self {
17100 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryAHardwareBufferDescriptor(
17101 ext,
17102 )
17103 }
17104 }
17105 impl std::convert::From<SharedTextureMemoryDmaBufDescriptor>
17106 for SharedTextureMemoryDescriptorExtension {
17107 fn from(ext: SharedTextureMemoryDmaBufDescriptor) -> Self {
17108 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDmaBufDescriptor(
17109 ext,
17110 )
17111 }
17112 }
17113 impl std::convert::From<SharedTextureMemoryOpaqueFDDescriptor>
17114 for SharedTextureMemoryDescriptorExtension {
17115 fn from(ext: SharedTextureMemoryOpaqueFDDescriptor) -> Self {
17116 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryOpaqueFDDescriptor(
17117 ext,
17118 )
17119 }
17120 }
17121 impl std::convert::From<SharedTextureMemoryVkDedicatedAllocationDescriptor>
17122 for SharedTextureMemoryDescriptorExtension {
17123 fn from(ext: SharedTextureMemoryVkDedicatedAllocationDescriptor) -> Self {
17124 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryVkDedicatedAllocationDescriptor(
17125 ext,
17126 )
17127 }
17128 }
17129 impl std::convert::From<SharedTextureMemoryZirconHandleDescriptor>
17130 for SharedTextureMemoryDescriptorExtension {
17131 fn from(ext: SharedTextureMemoryZirconHandleDescriptor) -> Self {
17132 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryZirconHandleDescriptor(
17133 ext,
17134 )
17135 }
17136 }
17137 impl SharedTextureMemoryDescriptorExtension {
17138 pub(crate) fn push_chain(
17139 &self,
17140 storage: &mut ChainedStructStorage,
17141 next: *mut ffi::WGPUChainedStruct,
17142 ) -> *mut ffi::WGPUChainedStruct {
17143 match self {
17144 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDXGISharedHandleDescriptor(
17145 value,
17146 ) => {
17147 let (mut raw, storage_value) = value.to_ffi();
17148 raw.chain.sType = SType::SharedTextureMemoryDXGISharedHandleDescriptor
17149 .into();
17150 raw.chain.next = next;
17151 storage.push_storage(storage_value);
17152 let raw_ptr = storage.push_value_mut(raw);
17153 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17154 }
17155 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryEGLImageDescriptor(
17156 value,
17157 ) => {
17158 let (mut raw, storage_value) = value.to_ffi();
17159 raw.chain.sType = SType::SharedTextureMemoryEGLImageDescriptor
17160 .into();
17161 raw.chain.next = next;
17162 storage.push_storage(storage_value);
17163 let raw_ptr = storage.push_value_mut(raw);
17164 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17165 }
17166 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryIOSurfaceDescriptor(
17167 value,
17168 ) => {
17169 let (mut raw, storage_value) = value.to_ffi();
17170 raw.chain.sType = SType::SharedTextureMemoryIOSurfaceDescriptor
17171 .into();
17172 raw.chain.next = next;
17173 storage.push_storage(storage_value);
17174 let raw_ptr = storage.push_value_mut(raw);
17175 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17176 }
17177 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryAHardwareBufferDescriptor(
17178 value,
17179 ) => {
17180 let (mut raw, storage_value) = value.to_ffi();
17181 raw.chain.sType = SType::SharedTextureMemoryAHardwareBufferDescriptor
17182 .into();
17183 raw.chain.next = next;
17184 storage.push_storage(storage_value);
17185 let raw_ptr = storage.push_value_mut(raw);
17186 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17187 }
17188 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryDmaBufDescriptor(
17189 value,
17190 ) => {
17191 let (mut raw, storage_value) = value.to_ffi();
17192 raw.chain.sType = SType::SharedTextureMemoryDmaBufDescriptor.into();
17193 raw.chain.next = next;
17194 storage.push_storage(storage_value);
17195 let raw_ptr = storage.push_value_mut(raw);
17196 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17197 }
17198 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryOpaqueFDDescriptor(
17199 value,
17200 ) => {
17201 let (mut raw, storage_value) = value.to_ffi();
17202 raw.chain.sType = SType::SharedTextureMemoryOpaqueFDDescriptor
17203 .into();
17204 raw.chain.next = next;
17205 storage.push_storage(storage_value);
17206 let raw_ptr = storage.push_value_mut(raw);
17207 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17208 }
17209 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryVkDedicatedAllocationDescriptor(
17210 value,
17211 ) => {
17212 let (mut raw, storage_value) = value.to_ffi();
17213 raw.chain.sType = SType::SharedTextureMemoryVkDedicatedAllocationDescriptor
17214 .into();
17215 raw.chain.next = next;
17216 storage.push_storage(storage_value);
17217 let raw_ptr = storage.push_value_mut(raw);
17218 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17219 }
17220 SharedTextureMemoryDescriptorExtension::SharedTextureMemoryZirconHandleDescriptor(
17221 value,
17222 ) => {
17223 let (mut raw, storage_value) = value.to_ffi();
17224 raw.chain.sType = SType::SharedTextureMemoryZirconHandleDescriptor
17225 .into();
17226 raw.chain.next = next;
17227 storage.push_storage(storage_value);
17228 let raw_ptr = storage.push_value_mut(raw);
17229 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17230 }
17231 }
17232 }
17233 }
17234 #[allow(dead_code)]
17235 pub enum SharedTextureMemoryEndAccessStateExtension {
17236 SharedTextureMemoryMetalEndAccessState(SharedTextureMemoryMetalEndAccessState),
17237 SharedTextureMemoryVkImageLayoutEndState(
17238 SharedTextureMemoryVkImageLayoutEndState,
17239 ),
17240 }
17241 impl std::convert::From<SharedTextureMemoryMetalEndAccessState>
17242 for SharedTextureMemoryEndAccessStateExtension {
17243 fn from(ext: SharedTextureMemoryMetalEndAccessState) -> Self {
17244 SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryMetalEndAccessState(
17245 ext,
17246 )
17247 }
17248 }
17249 impl std::convert::From<SharedTextureMemoryVkImageLayoutEndState>
17250 for SharedTextureMemoryEndAccessStateExtension {
17251 fn from(ext: SharedTextureMemoryVkImageLayoutEndState) -> Self {
17252 SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryVkImageLayoutEndState(
17253 ext,
17254 )
17255 }
17256 }
17257 impl SharedTextureMemoryEndAccessStateExtension {
17258 pub(crate) fn push_chain(
17259 &self,
17260 storage: &mut ChainedStructStorage,
17261 next: *mut ffi::WGPUChainedStruct,
17262 ) -> *mut ffi::WGPUChainedStruct {
17263 match self {
17264 SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryMetalEndAccessState(
17265 value,
17266 ) => {
17267 let (mut raw, storage_value) = value.to_ffi();
17268 raw.chain.sType = SType::SharedTextureMemoryMetalEndAccessState
17269 .into();
17270 raw.chain.next = next;
17271 storage.push_storage(storage_value);
17272 let raw_ptr = storage.push_value_mut(raw);
17273 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17274 }
17275 SharedTextureMemoryEndAccessStateExtension::SharedTextureMemoryVkImageLayoutEndState(
17276 value,
17277 ) => {
17278 let (mut raw, storage_value) = value.to_ffi();
17279 raw.chain.sType = SType::SharedTextureMemoryVkImageLayoutEndState
17280 .into();
17281 raw.chain.next = next;
17282 storage.push_storage(storage_value);
17283 let raw_ptr = storage.push_value_mut(raw);
17284 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17285 }
17286 }
17287 }
17288 }
17289 #[allow(dead_code)]
17290 pub enum SharedTextureMemoryPropertiesExtension {
17291 SharedTextureMemoryAHardwareBufferProperties(
17292 SharedTextureMemoryAHardwareBufferProperties,
17293 ),
17294 }
17295 impl std::convert::From<SharedTextureMemoryAHardwareBufferProperties>
17296 for SharedTextureMemoryPropertiesExtension {
17297 fn from(ext: SharedTextureMemoryAHardwareBufferProperties) -> Self {
17298 SharedTextureMemoryPropertiesExtension::SharedTextureMemoryAHardwareBufferProperties(
17299 ext,
17300 )
17301 }
17302 }
17303 impl SharedTextureMemoryPropertiesExtension {
17304 pub(crate) fn push_chain(
17305 &self,
17306 storage: &mut ChainedStructStorage,
17307 next: *mut ffi::WGPUChainedStruct,
17308 ) -> *mut ffi::WGPUChainedStruct {
17309 match self {
17310 SharedTextureMemoryPropertiesExtension::SharedTextureMemoryAHardwareBufferProperties(
17311 value,
17312 ) => {
17313 let (mut raw, storage_value) = value.to_ffi();
17314 raw.chain.sType = SType::SharedTextureMemoryAHardwareBufferProperties
17315 .into();
17316 raw.chain.next = next;
17317 storage.push_storage(storage_value);
17318 let raw_ptr = storage.push_value_mut(raw);
17319 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17320 }
17321 }
17322 }
17323 }
17324 #[allow(dead_code)]
17325 pub enum StorageTextureBindingLayoutExtension {}
17326 impl StorageTextureBindingLayoutExtension {
17327 pub(crate) fn push_chain(
17328 &self,
17329 storage: &mut ChainedStructStorage,
17330 next: *mut ffi::WGPUChainedStruct,
17331 ) -> *mut ffi::WGPUChainedStruct {
17332 let _ = self;
17333 let _ = storage;
17334 next
17335 }
17336 }
17337 #[allow(dead_code)]
17338 pub enum SurfaceCapabilitiesExtension {}
17339 impl SurfaceCapabilitiesExtension {
17340 pub(crate) fn push_chain(
17341 &self,
17342 storage: &mut ChainedStructStorage,
17343 next: *mut ffi::WGPUChainedStruct,
17344 ) -> *mut ffi::WGPUChainedStruct {
17345 let _ = self;
17346 let _ = storage;
17347 next
17348 }
17349 }
17350 #[allow(dead_code)]
17351 pub enum SurfaceConfigurationExtension {}
17352 impl SurfaceConfigurationExtension {
17353 pub(crate) fn push_chain(
17354 &self,
17355 storage: &mut ChainedStructStorage,
17356 next: *mut ffi::WGPUChainedStruct,
17357 ) -> *mut ffi::WGPUChainedStruct {
17358 let _ = self;
17359 let _ = storage;
17360 next
17361 }
17362 }
17363 #[allow(dead_code)]
17364 pub enum SurfaceDescriptorExtension {
17365 SurfaceColorManagement(SurfaceColorManagement),
17366 SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17367 SurfaceDescriptorFromWindowsUWPSwapChainPanel,
17368 ),
17369 SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17370 SurfaceDescriptorFromWindowsWinUISwapChainPanel,
17371 ),
17372 SurfaceDescriptorFromWindowsCoreWindow(SurfaceDescriptorFromWindowsCoreWindow),
17373 SurfaceSourceXCBWindow(SurfaceSourceXCBWindow),
17374 SurfaceSourceAndroidNativeWindow(SurfaceSourceAndroidNativeWindow),
17375 SurfaceSourceMetalLayer(SurfaceSourceMetalLayer),
17376 SurfaceSourceWaylandSurface(SurfaceSourceWaylandSurface),
17377 SurfaceSourceWindowsHWND(SurfaceSourceWindowsHWND),
17378 SurfaceSourceXlibWindow(SurfaceSourceXlibWindow),
17379 }
17380 impl std::convert::From<SurfaceColorManagement> for SurfaceDescriptorExtension {
17381 fn from(ext: SurfaceColorManagement) -> Self {
17382 SurfaceDescriptorExtension::SurfaceColorManagement(ext)
17383 }
17384 }
17385 impl std::convert::From<SurfaceDescriptorFromWindowsUWPSwapChainPanel>
17386 for SurfaceDescriptorExtension {
17387 fn from(ext: SurfaceDescriptorFromWindowsUWPSwapChainPanel) -> Self {
17388 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17389 ext,
17390 )
17391 }
17392 }
17393 impl std::convert::From<SurfaceDescriptorFromWindowsWinUISwapChainPanel>
17394 for SurfaceDescriptorExtension {
17395 fn from(ext: SurfaceDescriptorFromWindowsWinUISwapChainPanel) -> Self {
17396 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17397 ext,
17398 )
17399 }
17400 }
17401 impl std::convert::From<SurfaceDescriptorFromWindowsCoreWindow>
17402 for SurfaceDescriptorExtension {
17403 fn from(ext: SurfaceDescriptorFromWindowsCoreWindow) -> Self {
17404 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsCoreWindow(ext)
17405 }
17406 }
17407 impl std::convert::From<SurfaceSourceXCBWindow> for SurfaceDescriptorExtension {
17408 fn from(ext: SurfaceSourceXCBWindow) -> Self {
17409 SurfaceDescriptorExtension::SurfaceSourceXCBWindow(ext)
17410 }
17411 }
17412 impl std::convert::From<SurfaceSourceAndroidNativeWindow>
17413 for SurfaceDescriptorExtension {
17414 fn from(ext: SurfaceSourceAndroidNativeWindow) -> Self {
17415 SurfaceDescriptorExtension::SurfaceSourceAndroidNativeWindow(ext)
17416 }
17417 }
17418 impl std::convert::From<SurfaceSourceMetalLayer> for SurfaceDescriptorExtension {
17419 fn from(ext: SurfaceSourceMetalLayer) -> Self {
17420 SurfaceDescriptorExtension::SurfaceSourceMetalLayer(ext)
17421 }
17422 }
17423 impl std::convert::From<SurfaceSourceWaylandSurface> for SurfaceDescriptorExtension {
17424 fn from(ext: SurfaceSourceWaylandSurface) -> Self {
17425 SurfaceDescriptorExtension::SurfaceSourceWaylandSurface(ext)
17426 }
17427 }
17428 impl std::convert::From<SurfaceSourceWindowsHWND> for SurfaceDescriptorExtension {
17429 fn from(ext: SurfaceSourceWindowsHWND) -> Self {
17430 SurfaceDescriptorExtension::SurfaceSourceWindowsHWND(ext)
17431 }
17432 }
17433 impl std::convert::From<SurfaceSourceXlibWindow> for SurfaceDescriptorExtension {
17434 fn from(ext: SurfaceSourceXlibWindow) -> Self {
17435 SurfaceDescriptorExtension::SurfaceSourceXlibWindow(ext)
17436 }
17437 }
17438 impl SurfaceDescriptorExtension {
17439 pub(crate) fn push_chain(
17440 &self,
17441 storage: &mut ChainedStructStorage,
17442 next: *mut ffi::WGPUChainedStruct,
17443 ) -> *mut ffi::WGPUChainedStruct {
17444 match self {
17445 SurfaceDescriptorExtension::SurfaceColorManagement(value) => {
17446 let (mut raw, storage_value) = value.to_ffi();
17447 raw.chain.sType = SType::SurfaceColorManagement.into();
17448 raw.chain.next = next;
17449 storage.push_storage(storage_value);
17450 let raw_ptr = storage.push_value_mut(raw);
17451 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17452 }
17453 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsUWPSwapChainPanel(
17454 value,
17455 ) => {
17456 let (mut raw, storage_value) = value.to_ffi();
17457 raw.chain.sType = SType::SurfaceDescriptorFromWindowsUWPSwapChainPanel
17458 .into();
17459 raw.chain.next = next;
17460 storage.push_storage(storage_value);
17461 let raw_ptr = storage.push_value_mut(raw);
17462 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17463 }
17464 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsWinUISwapChainPanel(
17465 value,
17466 ) => {
17467 let (mut raw, storage_value) = value.to_ffi();
17468 raw.chain.sType = SType::SurfaceDescriptorFromWindowsWinUISwapChainPanel
17469 .into();
17470 raw.chain.next = next;
17471 storage.push_storage(storage_value);
17472 let raw_ptr = storage.push_value_mut(raw);
17473 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17474 }
17475 SurfaceDescriptorExtension::SurfaceDescriptorFromWindowsCoreWindow(
17476 value,
17477 ) => {
17478 let (mut raw, storage_value) = value.to_ffi();
17479 raw.chain.sType = SType::SurfaceDescriptorFromWindowsCoreWindow
17480 .into();
17481 raw.chain.next = next;
17482 storage.push_storage(storage_value);
17483 let raw_ptr = storage.push_value_mut(raw);
17484 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17485 }
17486 SurfaceDescriptorExtension::SurfaceSourceXCBWindow(value) => {
17487 let (mut raw, storage_value) = value.to_ffi();
17488 raw.chain.sType = SType::SurfaceSourceXCBWindow.into();
17489 raw.chain.next = next;
17490 storage.push_storage(storage_value);
17491 let raw_ptr = storage.push_value_mut(raw);
17492 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17493 }
17494 SurfaceDescriptorExtension::SurfaceSourceAndroidNativeWindow(value) => {
17495 let (mut raw, storage_value) = value.to_ffi();
17496 raw.chain.sType = SType::SurfaceSourceAndroidNativeWindow.into();
17497 raw.chain.next = next;
17498 storage.push_storage(storage_value);
17499 let raw_ptr = storage.push_value_mut(raw);
17500 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17501 }
17502 SurfaceDescriptorExtension::SurfaceSourceMetalLayer(value) => {
17503 let (mut raw, storage_value) = value.to_ffi();
17504 raw.chain.sType = SType::SurfaceSourceMetalLayer.into();
17505 raw.chain.next = next;
17506 storage.push_storage(storage_value);
17507 let raw_ptr = storage.push_value_mut(raw);
17508 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17509 }
17510 SurfaceDescriptorExtension::SurfaceSourceWaylandSurface(value) => {
17511 let (mut raw, storage_value) = value.to_ffi();
17512 raw.chain.sType = SType::SurfaceSourceWaylandSurface.into();
17513 raw.chain.next = next;
17514 storage.push_storage(storage_value);
17515 let raw_ptr = storage.push_value_mut(raw);
17516 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17517 }
17518 SurfaceDescriptorExtension::SurfaceSourceWindowsHWND(value) => {
17519 let (mut raw, storage_value) = value.to_ffi();
17520 raw.chain.sType = SType::SurfaceSourceWindowsHWND.into();
17521 raw.chain.next = next;
17522 storage.push_storage(storage_value);
17523 let raw_ptr = storage.push_value_mut(raw);
17524 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17525 }
17526 SurfaceDescriptorExtension::SurfaceSourceXlibWindow(value) => {
17527 let (mut raw, storage_value) = value.to_ffi();
17528 raw.chain.sType = SType::SurfaceSourceXlibWindow.into();
17529 raw.chain.next = next;
17530 storage.push_storage(storage_value);
17531 let raw_ptr = storage.push_value_mut(raw);
17532 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17533 }
17534 }
17535 }
17536 }
17537 #[allow(dead_code)]
17538 pub enum SurfaceTextureExtension {}
17539 impl SurfaceTextureExtension {
17540 pub(crate) fn push_chain(
17541 &self,
17542 storage: &mut ChainedStructStorage,
17543 next: *mut ffi::WGPUChainedStruct,
17544 ) -> *mut ffi::WGPUChainedStruct {
17545 let _ = self;
17546 let _ = storage;
17547 next
17548 }
17549 }
17550 #[allow(dead_code)]
17551 pub enum TexelBufferViewDescriptorExtension {}
17552 impl TexelBufferViewDescriptorExtension {
17553 pub(crate) fn push_chain(
17554 &self,
17555 storage: &mut ChainedStructStorage,
17556 next: *mut ffi::WGPUChainedStruct,
17557 ) -> *mut ffi::WGPUChainedStruct {
17558 let _ = self;
17559 let _ = storage;
17560 next
17561 }
17562 }
17563 #[allow(dead_code)]
17564 pub enum TextureBindingLayoutExtension {}
17565 impl TextureBindingLayoutExtension {
17566 pub(crate) fn push_chain(
17567 &self,
17568 storage: &mut ChainedStructStorage,
17569 next: *mut ffi::WGPUChainedStruct,
17570 ) -> *mut ffi::WGPUChainedStruct {
17571 let _ = self;
17572 let _ = storage;
17573 next
17574 }
17575 }
17576 #[allow(dead_code)]
17577 pub enum TextureDescriptorExtension {
17578 DawnTextureInternalUsageDescriptor(DawnTextureInternalUsageDescriptor),
17579 }
17580 impl std::convert::From<DawnTextureInternalUsageDescriptor>
17581 for TextureDescriptorExtension {
17582 fn from(ext: DawnTextureInternalUsageDescriptor) -> Self {
17583 TextureDescriptorExtension::DawnTextureInternalUsageDescriptor(ext)
17584 }
17585 }
17586 impl TextureDescriptorExtension {
17587 pub(crate) fn push_chain(
17588 &self,
17589 storage: &mut ChainedStructStorage,
17590 next: *mut ffi::WGPUChainedStruct,
17591 ) -> *mut ffi::WGPUChainedStruct {
17592 match self {
17593 TextureDescriptorExtension::DawnTextureInternalUsageDescriptor(
17594 value,
17595 ) => {
17596 let (mut raw, storage_value) = value.to_ffi();
17597 raw.chain.sType = SType::DawnTextureInternalUsageDescriptor.into();
17598 raw.chain.next = next;
17599 storage.push_storage(storage_value);
17600 let raw_ptr = storage.push_value_mut(raw);
17601 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17602 }
17603 }
17604 }
17605 }
17606 #[allow(dead_code)]
17607 pub enum TextureViewDescriptorExtension {
17608 TextureComponentSwizzleDescriptor(TextureComponentSwizzleDescriptor),
17609 YCbCrVkDescriptor(YCbCrVkDescriptor),
17610 }
17611 impl std::convert::From<TextureComponentSwizzleDescriptor>
17612 for TextureViewDescriptorExtension {
17613 fn from(ext: TextureComponentSwizzleDescriptor) -> Self {
17614 TextureViewDescriptorExtension::TextureComponentSwizzleDescriptor(ext)
17615 }
17616 }
17617 impl std::convert::From<YCbCrVkDescriptor> for TextureViewDescriptorExtension {
17618 fn from(ext: YCbCrVkDescriptor) -> Self {
17619 TextureViewDescriptorExtension::YCbCrVkDescriptor(ext)
17620 }
17621 }
17622 impl TextureViewDescriptorExtension {
17623 pub(crate) fn push_chain(
17624 &self,
17625 storage: &mut ChainedStructStorage,
17626 next: *mut ffi::WGPUChainedStruct,
17627 ) -> *mut ffi::WGPUChainedStruct {
17628 match self {
17629 TextureViewDescriptorExtension::TextureComponentSwizzleDescriptor(
17630 value,
17631 ) => {
17632 let (mut raw, storage_value) = value.to_ffi();
17633 raw.chain.sType = SType::TextureComponentSwizzleDescriptor.into();
17634 raw.chain.next = next;
17635 storage.push_storage(storage_value);
17636 let raw_ptr = storage.push_value_mut(raw);
17637 raw_ptr.cast::<ffi::WGPUChainedStruct>()
17638 }
17639 TextureViewDescriptorExtension::YCbCrVkDescriptor(value) => {
17640 let (mut raw, storage_value) = value.to_ffi();
17641 raw.chain.sType = SType::YCbCrVkDescriptor.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 }
17648 }
17649 }
17650 #[allow(dead_code)]
17651 pub enum VertexAttributeExtension {}
17652 impl VertexAttributeExtension {
17653 pub(crate) fn push_chain(
17654 &self,
17655 storage: &mut ChainedStructStorage,
17656 next: *mut ffi::WGPUChainedStruct,
17657 ) -> *mut ffi::WGPUChainedStruct {
17658 let _ = self;
17659 let _ = storage;
17660 next
17661 }
17662 }
17663 #[allow(dead_code)]
17664 pub enum VertexBufferLayoutExtension {}
17665 impl VertexBufferLayoutExtension {
17666 pub(crate) fn push_chain(
17667 &self,
17668 storage: &mut ChainedStructStorage,
17669 next: *mut ffi::WGPUChainedStruct,
17670 ) -> *mut ffi::WGPUChainedStruct {
17671 let _ = self;
17672 let _ = storage;
17673 next
17674 }
17675 }
17676 #[allow(dead_code)]
17677 pub enum VertexStateExtension {}
17678 impl VertexStateExtension {
17679 pub(crate) fn push_chain(
17680 &self,
17681 storage: &mut ChainedStructStorage,
17682 next: *mut ffi::WGPUChainedStruct,
17683 ) -> *mut ffi::WGPUChainedStruct {
17684 let _ = self;
17685 let _ = storage;
17686 next
17687 }
17688 }
17689}
17690mod objects {
17691 #![allow(dead_code, unused_imports)]
17692 use crate::generated::*;
17693 use crate::ffi;
17694 #[derive(Debug)]
17695 pub struct Adapter {
17696 raw: ffi::WGPUAdapter,
17697 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
17698 }
17699 impl Adapter {
17700 pub(crate) unsafe fn from_raw(raw: ffi::WGPUAdapter) -> Self {
17701 Self {
17702 raw,
17703 _not_sync: std::marker::PhantomData,
17704 }
17705 }
17706 pub fn as_raw(&self) -> ffi::WGPUAdapter {
17707 self.raw
17708 }
17709 pub fn get_instance(&self) -> Instance {
17710 let result = unsafe { ffi::wgpuAdapterGetInstance(self.raw) };
17711 unsafe { Instance::from_raw(result) }
17712 }
17713 pub fn get_limits(&self, limits: &mut Limits) -> Status {
17714 let (mut limits_ffi, _limits_storage) = limits.to_ffi();
17715 let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
17716 let result = unsafe { ffi::wgpuAdapterGetLimits(self.raw, limits_ptr) };
17717 *limits = Limits::from_ffi(limits_ffi);
17718 result.into()
17719 }
17720 pub fn get_info(&self, info: &mut AdapterInfo) -> Status {
17721 let (mut info_ffi, _info_storage) = info.to_ffi();
17722 let info_ptr = std::ptr::addr_of_mut!(info_ffi);
17723 let result = unsafe { ffi::wgpuAdapterGetInfo(self.raw, info_ptr) };
17724 *info = AdapterInfo::from_ffi(info_ffi);
17725 result.into()
17726 }
17727 pub fn has_feature(&self, feature: FeatureName) -> bool {
17728 let feature_ffi: ffi::WGPUFeatureName = feature.into();
17729 let result = unsafe { ffi::wgpuAdapterHasFeature(self.raw, feature_ffi) };
17730 result != 0
17731 }
17732 pub fn get_features(&self, features: &mut SupportedFeatures) -> () {
17733 let (mut features_ffi, _features_storage) = features.to_ffi();
17734 let features_ptr = std::ptr::addr_of_mut!(features_ffi);
17735 unsafe { ffi::wgpuAdapterGetFeatures(self.raw, features_ptr) };
17736 *features = SupportedFeatures::from_ffi(features_ffi);
17737 ()
17738 }
17739 pub fn request_device(
17740 &self,
17741 descriptor: Option<&DeviceDescriptor>,
17742 callback: impl FnMut(
17743 RequestDeviceStatus,
17744 Option<Device>,
17745 String,
17746 ) + Send + 'static,
17747 ) -> Future {
17748 let mut descriptor_storage = ChainedStructStorage::new();
17749 let descriptor_ptr = if let Some(value) = &descriptor {
17750 let (descriptor_ffi, storage) = value.to_ffi();
17751 descriptor_storage = storage;
17752 std::ptr::addr_of!(descriptor_ffi)
17753 } else {
17754 std::ptr::null()
17755 };
17756 let callback_box: RequestDeviceCallback = Box::new(callback);
17757 let callback_box = Box::new(Some(callback_box));
17758 let callback_userdata = Box::into_raw(callback_box)
17759 .cast::<std::ffi::c_void>();
17760 let callback_info_ffi = ffi::WGPURequestDeviceCallbackInfo {
17761 nextInChain: std::ptr::null_mut(),
17762 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
17763 callback: Some(request_device_callback_trampoline),
17764 userdata1: callback_userdata,
17765 userdata2: std::ptr::null_mut(),
17766 };
17767 let result = unsafe {
17768 ffi::wgpuAdapterRequestDevice(
17769 self.raw,
17770 descriptor_ptr,
17771 callback_info_ffi,
17772 )
17773 };
17774 Future::from_ffi(result)
17775 }
17776 pub fn create_device(&self, descriptor: Option<&DeviceDescriptor>) -> Device {
17777 let mut descriptor_storage = ChainedStructStorage::new();
17778 let descriptor_ptr = if let Some(value) = &descriptor {
17779 let (descriptor_ffi, storage) = value.to_ffi();
17780 descriptor_storage = storage;
17781 std::ptr::addr_of!(descriptor_ffi)
17782 } else {
17783 std::ptr::null()
17784 };
17785 let result = unsafe {
17786 ffi::wgpuAdapterCreateDevice(self.raw, descriptor_ptr)
17787 };
17788 unsafe { Device::from_raw(result) }
17789 }
17790 pub fn get_format_capabilities(
17791 &self,
17792 format: TextureFormat,
17793 capabilities: &mut DawnFormatCapabilities,
17794 ) -> Status {
17795 let format_ffi: ffi::WGPUTextureFormat = format.into();
17796 let (mut capabilities_ffi, _capabilities_storage) = capabilities.to_ffi();
17797 let capabilities_ptr = std::ptr::addr_of_mut!(capabilities_ffi);
17798 let result = unsafe {
17799 ffi::wgpuAdapterGetFormatCapabilities(
17800 self.raw,
17801 format_ffi,
17802 capabilities_ptr,
17803 )
17804 };
17805 *capabilities = DawnFormatCapabilities::from_ffi(capabilities_ffi);
17806 result.into()
17807 }
17808 }
17809 impl Drop for Adapter {
17810 fn drop(&mut self) {
17811 if self.as_raw().is_null() {
17812 return;
17813 }
17814 unsafe { ffi::wgpuAdapterRelease(self.raw) };
17815 }
17816 }
17817 impl Clone for Adapter {
17818 fn clone(&self) -> Self {
17819 unsafe { ffi::wgpuAdapterAddRef(self.raw) };
17820 Self {
17821 raw: self.raw,
17822 _not_sync: std::marker::PhantomData,
17823 }
17824 }
17825 }
17826 unsafe impl Send for Adapter {}
17827 #[derive(Debug)]
17828 pub struct BindGroup {
17829 raw: ffi::WGPUBindGroup,
17830 }
17831 impl BindGroup {
17832 pub(crate) unsafe fn from_raw(raw: ffi::WGPUBindGroup) -> Self {
17833 Self { raw }
17834 }
17835 pub fn as_raw(&self) -> ffi::WGPUBindGroup {
17836 self.raw
17837 }
17838 pub fn set_label(&self, label: String) -> () {
17839 let label_ffi = ffi::WGPUStringView {
17840 data: label.as_ptr().cast(),
17841 length: label.len(),
17842 };
17843 unsafe { ffi::wgpuBindGroupSetLabel(self.raw, label_ffi) };
17844 ()
17845 }
17846 }
17847 impl Drop for BindGroup {
17848 fn drop(&mut self) {
17849 if self.as_raw().is_null() {
17850 return;
17851 }
17852 unsafe { ffi::wgpuBindGroupRelease(self.raw) };
17853 }
17854 }
17855 impl Clone for BindGroup {
17856 fn clone(&self) -> Self {
17857 unsafe { ffi::wgpuBindGroupAddRef(self.raw) };
17858 Self { raw: self.raw }
17859 }
17860 }
17861 unsafe impl Send for BindGroup {}
17862 unsafe impl Sync for BindGroup {}
17863 #[derive(Debug)]
17864 pub struct BindGroupLayout {
17865 raw: ffi::WGPUBindGroupLayout,
17866 }
17867 impl BindGroupLayout {
17868 pub(crate) unsafe fn from_raw(raw: ffi::WGPUBindGroupLayout) -> Self {
17869 Self { raw }
17870 }
17871 pub fn as_raw(&self) -> ffi::WGPUBindGroupLayout {
17872 self.raw
17873 }
17874 pub fn set_label(&self, label: String) -> () {
17875 let label_ffi = ffi::WGPUStringView {
17876 data: label.as_ptr().cast(),
17877 length: label.len(),
17878 };
17879 unsafe { ffi::wgpuBindGroupLayoutSetLabel(self.raw, label_ffi) };
17880 ()
17881 }
17882 }
17883 impl Drop for BindGroupLayout {
17884 fn drop(&mut self) {
17885 if self.as_raw().is_null() {
17886 return;
17887 }
17888 unsafe { ffi::wgpuBindGroupLayoutRelease(self.raw) };
17889 }
17890 }
17891 impl Clone for BindGroupLayout {
17892 fn clone(&self) -> Self {
17893 unsafe { ffi::wgpuBindGroupLayoutAddRef(self.raw) };
17894 Self { raw: self.raw }
17895 }
17896 }
17897 unsafe impl Send for BindGroupLayout {}
17898 unsafe impl Sync for BindGroupLayout {}
17899 #[derive(Debug)]
17900 pub struct Buffer {
17901 raw: ffi::WGPUBuffer,
17902 }
17903 impl Buffer {
17904 pub(crate) unsafe fn from_raw(raw: ffi::WGPUBuffer) -> Self {
17905 Self { raw }
17906 }
17907 pub fn as_raw(&self) -> ffi::WGPUBuffer {
17908 self.raw
17909 }
17910 pub fn map_async(
17911 &self,
17912 mode: MapMode,
17913 offset: usize,
17914 size: usize,
17915 callback: impl FnMut(MapAsyncStatus, String) + Send + 'static,
17916 ) -> Future {
17917 let mode_ffi: ffi::WGPUMapMode = mode.into();
17918 let callback_box: BufferMapCallback = Box::new(callback);
17919 let callback_box = Box::new(Some(callback_box));
17920 let callback_userdata = Box::into_raw(callback_box)
17921 .cast::<std::ffi::c_void>();
17922 let callback_info_ffi = ffi::WGPUBufferMapCallbackInfo {
17923 nextInChain: std::ptr::null_mut(),
17924 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
17925 callback: Some(buffer_map_callback_trampoline),
17926 userdata1: callback_userdata,
17927 userdata2: std::ptr::null_mut(),
17928 };
17929 let result = unsafe {
17930 ffi::wgpuBufferMapAsync(
17931 self.raw,
17932 mode_ffi,
17933 offset,
17934 size,
17935 callback_info_ffi,
17936 )
17937 };
17938 Future::from_ffi(result)
17939 }
17940 pub fn get_mapped_range(
17941 &self,
17942 offset: usize,
17943 size: usize,
17944 ) -> *mut std::ffi::c_void {
17945 let result = unsafe {
17946 ffi::wgpuBufferGetMappedRange(self.raw, offset, size)
17947 };
17948 result
17949 }
17950 pub fn get_const_mapped_range(
17951 &self,
17952 offset: usize,
17953 size: usize,
17954 ) -> *const std::ffi::c_void {
17955 let result = unsafe {
17956 ffi::wgpuBufferGetConstMappedRange(self.raw, offset, size)
17957 };
17958 result
17959 }
17960 pub fn write_mapped_range(
17961 &self,
17962 offset: usize,
17963 data: &[std::ffi::c_void],
17964 ) -> Status {
17965 let data_ptr = data.as_ptr();
17966 let result = unsafe {
17967 ffi::wgpuBufferWriteMappedRange(self.raw, offset, data_ptr, data.len())
17968 };
17969 result.into()
17970 }
17971 pub fn read_mapped_range(
17972 &self,
17973 offset: usize,
17974 mut data: &mut [std::ffi::c_void],
17975 ) -> Status {
17976 let data_ptr = data.as_mut_ptr();
17977 let result = unsafe {
17978 ffi::wgpuBufferReadMappedRange(self.raw, offset, data_ptr, data.len())
17979 };
17980 result.into()
17981 }
17982 pub fn create_texel_view(
17983 &self,
17984 descriptor: &TexelBufferViewDescriptor,
17985 ) -> TexelBufferView {
17986 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
17987 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
17988 let result = unsafe {
17989 ffi::wgpuBufferCreateTexelView(self.raw, descriptor_ptr)
17990 };
17991 unsafe { TexelBufferView::from_raw(result) }
17992 }
17993 pub fn set_label(&self, label: String) -> () {
17994 let label_ffi = ffi::WGPUStringView {
17995 data: label.as_ptr().cast(),
17996 length: label.len(),
17997 };
17998 unsafe { ffi::wgpuBufferSetLabel(self.raw, label_ffi) };
17999 ()
18000 }
18001 pub fn get_usage(&self) -> BufferUsage {
18002 let result = unsafe { ffi::wgpuBufferGetUsage(self.raw) };
18003 result.into()
18004 }
18005 pub fn get_size(&self) -> u64 {
18006 let result = unsafe { ffi::wgpuBufferGetSize(self.raw) };
18007 result
18008 }
18009 pub fn get_map_state(&self) -> BufferMapState {
18010 let result = unsafe { ffi::wgpuBufferGetMapState(self.raw) };
18011 result.into()
18012 }
18013 pub fn unmap(&self) -> () {
18014 unsafe { ffi::wgpuBufferUnmap(self.raw) };
18015 ()
18016 }
18017 pub fn destroy(&self) -> () {
18018 unsafe { ffi::wgpuBufferDestroy(self.raw) };
18019 ()
18020 }
18021 }
18022 impl Drop for Buffer {
18023 fn drop(&mut self) {
18024 if self.as_raw().is_null() {
18025 return;
18026 }
18027 unsafe { ffi::wgpuBufferRelease(self.raw) };
18028 }
18029 }
18030 impl Clone for Buffer {
18031 fn clone(&self) -> Self {
18032 unsafe { ffi::wgpuBufferAddRef(self.raw) };
18033 Self { raw: self.raw }
18034 }
18035 }
18036 unsafe impl Send for Buffer {}
18037 unsafe impl Sync for Buffer {}
18038 #[derive(Debug)]
18039 pub struct CommandBuffer {
18040 raw: ffi::WGPUCommandBuffer,
18041 }
18042 impl CommandBuffer {
18043 pub(crate) unsafe fn from_raw(raw: ffi::WGPUCommandBuffer) -> Self {
18044 Self { raw }
18045 }
18046 pub fn as_raw(&self) -> ffi::WGPUCommandBuffer {
18047 self.raw
18048 }
18049 pub fn set_label(&self, label: String) -> () {
18050 let label_ffi = ffi::WGPUStringView {
18051 data: label.as_ptr().cast(),
18052 length: label.len(),
18053 };
18054 unsafe { ffi::wgpuCommandBufferSetLabel(self.raw, label_ffi) };
18055 ()
18056 }
18057 }
18058 impl Drop for CommandBuffer {
18059 fn drop(&mut self) {
18060 if self.as_raw().is_null() {
18061 return;
18062 }
18063 unsafe { ffi::wgpuCommandBufferRelease(self.raw) };
18064 }
18065 }
18066 impl Clone for CommandBuffer {
18067 fn clone(&self) -> Self {
18068 unsafe { ffi::wgpuCommandBufferAddRef(self.raw) };
18069 Self { raw: self.raw }
18070 }
18071 }
18072 unsafe impl Send for CommandBuffer {}
18073 unsafe impl Sync for CommandBuffer {}
18074 #[derive(Debug)]
18075 pub struct CommandEncoder {
18076 raw: ffi::WGPUCommandEncoder,
18077 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
18078 }
18079 impl CommandEncoder {
18080 pub(crate) unsafe fn from_raw(raw: ffi::WGPUCommandEncoder) -> Self {
18081 Self {
18082 raw,
18083 _not_sync: std::marker::PhantomData,
18084 }
18085 }
18086 pub fn as_raw(&self) -> ffi::WGPUCommandEncoder {
18087 self.raw
18088 }
18089 pub fn finish(
18090 &self,
18091 descriptor: Option<&CommandBufferDescriptor>,
18092 ) -> CommandBuffer {
18093 let mut descriptor_storage = ChainedStructStorage::new();
18094 let descriptor_ptr = if let Some(value) = &descriptor {
18095 let (descriptor_ffi, storage) = value.to_ffi();
18096 descriptor_storage = storage;
18097 std::ptr::addr_of!(descriptor_ffi)
18098 } else {
18099 std::ptr::null()
18100 };
18101 let result = unsafe {
18102 ffi::wgpuCommandEncoderFinish(self.raw, descriptor_ptr)
18103 };
18104 unsafe { CommandBuffer::from_raw(result) }
18105 }
18106 pub fn begin_compute_pass(
18107 &self,
18108 descriptor: Option<&ComputePassDescriptor>,
18109 ) -> ComputePassEncoder {
18110 let mut descriptor_storage = ChainedStructStorage::new();
18111 let descriptor_ptr = if let Some(value) = &descriptor {
18112 let (descriptor_ffi, storage) = value.to_ffi();
18113 descriptor_storage = storage;
18114 std::ptr::addr_of!(descriptor_ffi)
18115 } else {
18116 std::ptr::null()
18117 };
18118 let result = unsafe {
18119 ffi::wgpuCommandEncoderBeginComputePass(self.raw, descriptor_ptr)
18120 };
18121 unsafe { ComputePassEncoder::from_raw(result) }
18122 }
18123 pub fn begin_render_pass(
18124 &self,
18125 descriptor: &RenderPassDescriptor,
18126 ) -> RenderPassEncoder {
18127 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18128 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18129 let result = unsafe {
18130 ffi::wgpuCommandEncoderBeginRenderPass(self.raw, descriptor_ptr)
18131 };
18132 unsafe { RenderPassEncoder::from_raw(result) }
18133 }
18134 pub fn copy_buffer_to_buffer(
18135 &self,
18136 source: Buffer,
18137 source_offset: u64,
18138 destination: Buffer,
18139 destination_offset: u64,
18140 size: u64,
18141 ) -> () {
18142 unsafe {
18143 ffi::wgpuCommandEncoderCopyBufferToBuffer(
18144 self.raw,
18145 source.as_raw(),
18146 source_offset,
18147 destination.as_raw(),
18148 destination_offset,
18149 size,
18150 )
18151 };
18152 ()
18153 }
18154 pub fn copy_buffer_to_texture(
18155 &self,
18156 source: &TexelCopyBufferInfo,
18157 destination: &TexelCopyTextureInfo,
18158 copy_size: &Extent3D,
18159 ) -> () {
18160 let (source_ffi, _source_storage) = source.to_ffi();
18161 let source_ptr = std::ptr::addr_of!(source_ffi);
18162 let (destination_ffi, _destination_storage) = destination.to_ffi();
18163 let destination_ptr = std::ptr::addr_of!(destination_ffi);
18164 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18165 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18166 unsafe {
18167 ffi::wgpuCommandEncoderCopyBufferToTexture(
18168 self.raw,
18169 source_ptr,
18170 destination_ptr,
18171 copy_size_ptr,
18172 )
18173 };
18174 ()
18175 }
18176 pub fn copy_texture_to_buffer(
18177 &self,
18178 source: &TexelCopyTextureInfo,
18179 destination: &TexelCopyBufferInfo,
18180 copy_size: &Extent3D,
18181 ) -> () {
18182 let (source_ffi, _source_storage) = source.to_ffi();
18183 let source_ptr = std::ptr::addr_of!(source_ffi);
18184 let (destination_ffi, _destination_storage) = destination.to_ffi();
18185 let destination_ptr = std::ptr::addr_of!(destination_ffi);
18186 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18187 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18188 unsafe {
18189 ffi::wgpuCommandEncoderCopyTextureToBuffer(
18190 self.raw,
18191 source_ptr,
18192 destination_ptr,
18193 copy_size_ptr,
18194 )
18195 };
18196 ()
18197 }
18198 pub fn copy_texture_to_texture(
18199 &self,
18200 source: &TexelCopyTextureInfo,
18201 destination: &TexelCopyTextureInfo,
18202 copy_size: &Extent3D,
18203 ) -> () {
18204 let (source_ffi, _source_storage) = source.to_ffi();
18205 let source_ptr = std::ptr::addr_of!(source_ffi);
18206 let (destination_ffi, _destination_storage) = destination.to_ffi();
18207 let destination_ptr = std::ptr::addr_of!(destination_ffi);
18208 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
18209 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
18210 unsafe {
18211 ffi::wgpuCommandEncoderCopyTextureToTexture(
18212 self.raw,
18213 source_ptr,
18214 destination_ptr,
18215 copy_size_ptr,
18216 )
18217 };
18218 ()
18219 }
18220 pub fn clear_buffer(&self, buffer: Buffer, offset: u64, size: u64) -> () {
18221 unsafe {
18222 ffi::wgpuCommandEncoderClearBuffer(
18223 self.raw,
18224 buffer.as_raw(),
18225 offset,
18226 size,
18227 )
18228 };
18229 ()
18230 }
18231 pub fn inject_validation_error(&self, message: String) -> () {
18232 let message_ffi = ffi::WGPUStringView {
18233 data: message.as_ptr().cast(),
18234 length: message.len(),
18235 };
18236 unsafe {
18237 ffi::wgpuCommandEncoderInjectValidationError(self.raw, message_ffi)
18238 };
18239 ()
18240 }
18241 pub fn insert_debug_marker(&self, marker_label: String) -> () {
18242 let marker_label_ffi = ffi::WGPUStringView {
18243 data: marker_label.as_ptr().cast(),
18244 length: marker_label.len(),
18245 };
18246 unsafe {
18247 ffi::wgpuCommandEncoderInsertDebugMarker(self.raw, marker_label_ffi)
18248 };
18249 ()
18250 }
18251 pub fn pop_debug_group(&self) -> () {
18252 unsafe { ffi::wgpuCommandEncoderPopDebugGroup(self.raw) };
18253 ()
18254 }
18255 pub fn push_debug_group(&self, group_label: String) -> () {
18256 let group_label_ffi = ffi::WGPUStringView {
18257 data: group_label.as_ptr().cast(),
18258 length: group_label.len(),
18259 };
18260 unsafe { ffi::wgpuCommandEncoderPushDebugGroup(self.raw, group_label_ffi) };
18261 ()
18262 }
18263 pub fn resolve_query_set(
18264 &self,
18265 query_set: QuerySet,
18266 first_query: u32,
18267 query_count: u32,
18268 destination: Buffer,
18269 destination_offset: u64,
18270 ) -> () {
18271 unsafe {
18272 ffi::wgpuCommandEncoderResolveQuerySet(
18273 self.raw,
18274 query_set.as_raw(),
18275 first_query,
18276 query_count,
18277 destination.as_raw(),
18278 destination_offset,
18279 )
18280 };
18281 ()
18282 }
18283 pub fn write_buffer(
18284 &self,
18285 buffer: Buffer,
18286 buffer_offset: u64,
18287 data: &[u8],
18288 ) -> () {
18289 let data_ptr = data.as_ptr();
18290 unsafe {
18291 ffi::wgpuCommandEncoderWriteBuffer(
18292 self.raw,
18293 buffer.as_raw(),
18294 buffer_offset,
18295 data_ptr,
18296 (data.len()) as u64,
18297 )
18298 };
18299 ()
18300 }
18301 pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
18302 unsafe {
18303 ffi::wgpuCommandEncoderWriteTimestamp(
18304 self.raw,
18305 query_set.as_raw(),
18306 query_index,
18307 )
18308 };
18309 ()
18310 }
18311 pub fn set_label(&self, label: String) -> () {
18312 let label_ffi = ffi::WGPUStringView {
18313 data: label.as_ptr().cast(),
18314 length: label.len(),
18315 };
18316 unsafe { ffi::wgpuCommandEncoderSetLabel(self.raw, label_ffi) };
18317 ()
18318 }
18319 }
18320 impl Drop for CommandEncoder {
18321 fn drop(&mut self) {
18322 if self.as_raw().is_null() {
18323 return;
18324 }
18325 unsafe { ffi::wgpuCommandEncoderRelease(self.raw) };
18326 }
18327 }
18328 impl Clone for CommandEncoder {
18329 fn clone(&self) -> Self {
18330 unsafe { ffi::wgpuCommandEncoderAddRef(self.raw) };
18331 Self {
18332 raw: self.raw,
18333 _not_sync: std::marker::PhantomData,
18334 }
18335 }
18336 }
18337 unsafe impl Send for CommandEncoder {}
18338 #[derive(Debug)]
18339 pub struct ComputePassEncoder {
18340 raw: ffi::WGPUComputePassEncoder,
18341 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
18342 }
18343 impl ComputePassEncoder {
18344 pub(crate) unsafe fn from_raw(raw: ffi::WGPUComputePassEncoder) -> Self {
18345 Self {
18346 raw,
18347 _not_sync: std::marker::PhantomData,
18348 }
18349 }
18350 pub fn as_raw(&self) -> ffi::WGPUComputePassEncoder {
18351 self.raw
18352 }
18353 pub fn insert_debug_marker(&self, marker_label: String) -> () {
18354 let marker_label_ffi = ffi::WGPUStringView {
18355 data: marker_label.as_ptr().cast(),
18356 length: marker_label.len(),
18357 };
18358 unsafe {
18359 ffi::wgpuComputePassEncoderInsertDebugMarker(self.raw, marker_label_ffi)
18360 };
18361 ()
18362 }
18363 pub fn pop_debug_group(&self) -> () {
18364 unsafe { ffi::wgpuComputePassEncoderPopDebugGroup(self.raw) };
18365 ()
18366 }
18367 pub fn push_debug_group(&self, group_label: String) -> () {
18368 let group_label_ffi = ffi::WGPUStringView {
18369 data: group_label.as_ptr().cast(),
18370 length: group_label.len(),
18371 };
18372 unsafe {
18373 ffi::wgpuComputePassEncoderPushDebugGroup(self.raw, group_label_ffi)
18374 };
18375 ()
18376 }
18377 pub fn set_pipeline(&self, pipeline: ComputePipeline) -> () {
18378 unsafe {
18379 ffi::wgpuComputePassEncoderSetPipeline(self.raw, pipeline.as_raw())
18380 };
18381 ()
18382 }
18383 pub fn set_bind_group(
18384 &self,
18385 group_index: u32,
18386 group: Option<BindGroup>,
18387 dynamic_offsets: &[u32],
18388 ) -> () {
18389 let group_raw = group
18390 .as_ref()
18391 .map(|v| v.as_raw())
18392 .unwrap_or(std::ptr::null_mut());
18393 let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
18394 unsafe {
18395 ffi::wgpuComputePassEncoderSetBindGroup(
18396 self.raw,
18397 group_index,
18398 group_raw,
18399 dynamic_offsets.len(),
18400 dynamic_offsets_ptr,
18401 )
18402 };
18403 ()
18404 }
18405 pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
18406 unsafe {
18407 ffi::wgpuComputePassEncoderWriteTimestamp(
18408 self.raw,
18409 query_set.as_raw(),
18410 query_index,
18411 )
18412 };
18413 ()
18414 }
18415 pub fn dispatch_workgroups(
18416 &self,
18417 workgroup_count_x: u32,
18418 workgroup_count_y: u32,
18419 workgroup_count_z: u32,
18420 ) -> () {
18421 unsafe {
18422 ffi::wgpuComputePassEncoderDispatchWorkgroups(
18423 self.raw,
18424 workgroup_count_x,
18425 workgroup_count_y,
18426 workgroup_count_z,
18427 )
18428 };
18429 ()
18430 }
18431 pub fn dispatch_workgroups_indirect(
18432 &self,
18433 indirect_buffer: Buffer,
18434 indirect_offset: u64,
18435 ) -> () {
18436 unsafe {
18437 ffi::wgpuComputePassEncoderDispatchWorkgroupsIndirect(
18438 self.raw,
18439 indirect_buffer.as_raw(),
18440 indirect_offset,
18441 )
18442 };
18443 ()
18444 }
18445 pub fn end(&self) -> () {
18446 unsafe { ffi::wgpuComputePassEncoderEnd(self.raw) };
18447 ()
18448 }
18449 pub fn set_label(&self, label: String) -> () {
18450 let label_ffi = ffi::WGPUStringView {
18451 data: label.as_ptr().cast(),
18452 length: label.len(),
18453 };
18454 unsafe { ffi::wgpuComputePassEncoderSetLabel(self.raw, label_ffi) };
18455 ()
18456 }
18457 pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
18458 let data_ptr = data.as_ptr();
18459 unsafe {
18460 ffi::wgpuComputePassEncoderSetImmediates(
18461 self.raw,
18462 offset,
18463 data_ptr,
18464 data.len(),
18465 )
18466 };
18467 ()
18468 }
18469 pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
18470 let table_raw = table
18471 .as_ref()
18472 .map(|v| v.as_raw())
18473 .unwrap_or(std::ptr::null_mut());
18474 unsafe { ffi::wgpuComputePassEncoderSetResourceTable(self.raw, table_raw) };
18475 ()
18476 }
18477 }
18478 impl Drop for ComputePassEncoder {
18479 fn drop(&mut self) {
18480 if self.as_raw().is_null() {
18481 return;
18482 }
18483 unsafe { ffi::wgpuComputePassEncoderRelease(self.raw) };
18484 }
18485 }
18486 impl Clone for ComputePassEncoder {
18487 fn clone(&self) -> Self {
18488 unsafe { ffi::wgpuComputePassEncoderAddRef(self.raw) };
18489 Self {
18490 raw: self.raw,
18491 _not_sync: std::marker::PhantomData,
18492 }
18493 }
18494 }
18495 unsafe impl Send for ComputePassEncoder {}
18496 #[derive(Debug)]
18497 pub struct ComputePipeline {
18498 raw: ffi::WGPUComputePipeline,
18499 }
18500 impl ComputePipeline {
18501 pub(crate) unsafe fn from_raw(raw: ffi::WGPUComputePipeline) -> Self {
18502 Self { raw }
18503 }
18504 pub fn as_raw(&self) -> ffi::WGPUComputePipeline {
18505 self.raw
18506 }
18507 pub fn get_bind_group_layout(&self, group_index: u32) -> BindGroupLayout {
18508 let result = unsafe {
18509 ffi::wgpuComputePipelineGetBindGroupLayout(self.raw, group_index)
18510 };
18511 unsafe { BindGroupLayout::from_raw(result) }
18512 }
18513 pub fn set_label(&self, label: String) -> () {
18514 let label_ffi = ffi::WGPUStringView {
18515 data: label.as_ptr().cast(),
18516 length: label.len(),
18517 };
18518 unsafe { ffi::wgpuComputePipelineSetLabel(self.raw, label_ffi) };
18519 ()
18520 }
18521 }
18522 impl Drop for ComputePipeline {
18523 fn drop(&mut self) {
18524 if self.as_raw().is_null() {
18525 return;
18526 }
18527 unsafe { ffi::wgpuComputePipelineRelease(self.raw) };
18528 }
18529 }
18530 impl Clone for ComputePipeline {
18531 fn clone(&self) -> Self {
18532 unsafe { ffi::wgpuComputePipelineAddRef(self.raw) };
18533 Self { raw: self.raw }
18534 }
18535 }
18536 unsafe impl Send for ComputePipeline {}
18537 unsafe impl Sync for ComputePipeline {}
18538 #[derive(Debug)]
18539 pub struct Device {
18540 raw: ffi::WGPUDevice,
18541 }
18542 impl Device {
18543 pub(crate) unsafe fn from_raw(raw: ffi::WGPUDevice) -> Self {
18544 Self { raw }
18545 }
18546 pub fn as_raw(&self) -> ffi::WGPUDevice {
18547 self.raw
18548 }
18549 pub fn create_bind_group(&self, descriptor: &BindGroupDescriptor) -> BindGroup {
18550 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18551 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18552 let result = unsafe {
18553 ffi::wgpuDeviceCreateBindGroup(self.raw, descriptor_ptr)
18554 };
18555 unsafe { BindGroup::from_raw(result) }
18556 }
18557 pub fn create_bind_group_layout(
18558 &self,
18559 descriptor: &BindGroupLayoutDescriptor,
18560 ) -> BindGroupLayout {
18561 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18562 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18563 let result = unsafe {
18564 ffi::wgpuDeviceCreateBindGroupLayout(self.raw, descriptor_ptr)
18565 };
18566 unsafe { BindGroupLayout::from_raw(result) }
18567 }
18568 pub fn create_buffer(&self, descriptor: &BufferDescriptor) -> Option<Buffer> {
18569 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18570 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18571 let result = unsafe {
18572 ffi::wgpuDeviceCreateBuffer(self.raw, descriptor_ptr)
18573 };
18574 if result.is_null() {
18575 None
18576 } else {
18577 Some(unsafe { Buffer::from_raw(result) })
18578 }
18579 }
18580 pub fn create_error_buffer(&self, descriptor: &BufferDescriptor) -> Buffer {
18581 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18582 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18583 let result = unsafe {
18584 ffi::wgpuDeviceCreateErrorBuffer(self.raw, descriptor_ptr)
18585 };
18586 unsafe { Buffer::from_raw(result) }
18587 }
18588 pub fn create_command_encoder(
18589 &self,
18590 descriptor: Option<&CommandEncoderDescriptor>,
18591 ) -> CommandEncoder {
18592 let mut descriptor_storage = ChainedStructStorage::new();
18593 let descriptor_ptr = if let Some(value) = &descriptor {
18594 let (descriptor_ffi, storage) = value.to_ffi();
18595 descriptor_storage = storage;
18596 std::ptr::addr_of!(descriptor_ffi)
18597 } else {
18598 std::ptr::null()
18599 };
18600 let result = unsafe {
18601 ffi::wgpuDeviceCreateCommandEncoder(self.raw, descriptor_ptr)
18602 };
18603 unsafe { CommandEncoder::from_raw(result) }
18604 }
18605 pub fn create_compute_pipeline(
18606 &self,
18607 descriptor: &ComputePipelineDescriptor,
18608 ) -> ComputePipeline {
18609 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18610 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18611 let result = unsafe {
18612 ffi::wgpuDeviceCreateComputePipeline(self.raw, descriptor_ptr)
18613 };
18614 unsafe { ComputePipeline::from_raw(result) }
18615 }
18616 pub fn create_compute_pipeline_async(
18617 &self,
18618 descriptor: &ComputePipelineDescriptor,
18619 callback: impl FnMut(
18620 CreatePipelineAsyncStatus,
18621 Option<ComputePipeline>,
18622 String,
18623 ) + Send + 'static,
18624 ) -> Future {
18625 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18626 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18627 let callback_box: CreateComputePipelineAsyncCallback = Box::new(callback);
18628 let callback_box = Box::new(Some(callback_box));
18629 let callback_userdata = Box::into_raw(callback_box)
18630 .cast::<std::ffi::c_void>();
18631 let callback_info_ffi = ffi::WGPUCreateComputePipelineAsyncCallbackInfo {
18632 nextInChain: std::ptr::null_mut(),
18633 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18634 callback: Some(create_compute_pipeline_async_callback_trampoline),
18635 userdata1: callback_userdata,
18636 userdata2: std::ptr::null_mut(),
18637 };
18638 let result = unsafe {
18639 ffi::wgpuDeviceCreateComputePipelineAsync(
18640 self.raw,
18641 descriptor_ptr,
18642 callback_info_ffi,
18643 )
18644 };
18645 Future::from_ffi(result)
18646 }
18647 pub fn create_external_texture(
18648 &self,
18649 external_texture_descriptor: &ExternalTextureDescriptor,
18650 ) -> ExternalTexture {
18651 let (
18652 external_texture_descriptor_ffi,
18653 _external_texture_descriptor_storage,
18654 ) = external_texture_descriptor.to_ffi();
18655 let external_texture_descriptor_ptr = std::ptr::addr_of!(
18656 external_texture_descriptor_ffi
18657 );
18658 let result = unsafe {
18659 ffi::wgpuDeviceCreateExternalTexture(
18660 self.raw,
18661 external_texture_descriptor_ptr,
18662 )
18663 };
18664 unsafe { ExternalTexture::from_raw(result) }
18665 }
18666 pub fn create_error_external_texture(&self) -> ExternalTexture {
18667 let result = unsafe { ffi::wgpuDeviceCreateErrorExternalTexture(self.raw) };
18668 unsafe { ExternalTexture::from_raw(result) }
18669 }
18670 pub fn create_pipeline_layout(
18671 &self,
18672 descriptor: &PipelineLayoutDescriptor,
18673 ) -> PipelineLayout {
18674 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18675 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18676 let result = unsafe {
18677 ffi::wgpuDeviceCreatePipelineLayout(self.raw, descriptor_ptr)
18678 };
18679 unsafe { PipelineLayout::from_raw(result) }
18680 }
18681 pub fn create_query_set(&self, descriptor: &QuerySetDescriptor) -> QuerySet {
18682 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18683 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18684 let result = unsafe {
18685 ffi::wgpuDeviceCreateQuerySet(self.raw, descriptor_ptr)
18686 };
18687 unsafe { QuerySet::from_raw(result) }
18688 }
18689 pub fn create_render_pipeline_async(
18690 &self,
18691 descriptor: &RenderPipelineDescriptor,
18692 callback: impl FnMut(
18693 CreatePipelineAsyncStatus,
18694 Option<RenderPipeline>,
18695 String,
18696 ) + Send + 'static,
18697 ) -> Future {
18698 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18699 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18700 let callback_box: CreateRenderPipelineAsyncCallback = Box::new(callback);
18701 let callback_box = Box::new(Some(callback_box));
18702 let callback_userdata = Box::into_raw(callback_box)
18703 .cast::<std::ffi::c_void>();
18704 let callback_info_ffi = ffi::WGPUCreateRenderPipelineAsyncCallbackInfo {
18705 nextInChain: std::ptr::null_mut(),
18706 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18707 callback: Some(create_render_pipeline_async_callback_trampoline),
18708 userdata1: callback_userdata,
18709 userdata2: std::ptr::null_mut(),
18710 };
18711 let result = unsafe {
18712 ffi::wgpuDeviceCreateRenderPipelineAsync(
18713 self.raw,
18714 descriptor_ptr,
18715 callback_info_ffi,
18716 )
18717 };
18718 Future::from_ffi(result)
18719 }
18720 pub fn create_render_bundle_encoder(
18721 &self,
18722 descriptor: &RenderBundleEncoderDescriptor,
18723 ) -> RenderBundleEncoder {
18724 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18725 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18726 let result = unsafe {
18727 ffi::wgpuDeviceCreateRenderBundleEncoder(self.raw, descriptor_ptr)
18728 };
18729 unsafe { RenderBundleEncoder::from_raw(result) }
18730 }
18731 pub fn create_render_pipeline(
18732 &self,
18733 descriptor: &RenderPipelineDescriptor,
18734 ) -> RenderPipeline {
18735 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18736 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18737 let result = unsafe {
18738 ffi::wgpuDeviceCreateRenderPipeline(self.raw, descriptor_ptr)
18739 };
18740 unsafe { RenderPipeline::from_raw(result) }
18741 }
18742 pub fn create_sampler(&self, descriptor: Option<&SamplerDescriptor>) -> Sampler {
18743 let mut descriptor_storage = ChainedStructStorage::new();
18744 let descriptor_ptr = if let Some(value) = &descriptor {
18745 let (descriptor_ffi, storage) = value.to_ffi();
18746 descriptor_storage = storage;
18747 std::ptr::addr_of!(descriptor_ffi)
18748 } else {
18749 std::ptr::null()
18750 };
18751 let result = unsafe {
18752 ffi::wgpuDeviceCreateSampler(self.raw, descriptor_ptr)
18753 };
18754 unsafe { Sampler::from_raw(result) }
18755 }
18756 pub fn create_shader_module(
18757 &self,
18758 descriptor: &ShaderModuleDescriptor,
18759 ) -> ShaderModule {
18760 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18761 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18762 let result = unsafe {
18763 ffi::wgpuDeviceCreateShaderModule(self.raw, descriptor_ptr)
18764 };
18765 unsafe { ShaderModule::from_raw(result) }
18766 }
18767 pub fn create_error_shader_module(
18768 &self,
18769 descriptor: &ShaderModuleDescriptor,
18770 error_message: String,
18771 ) -> ShaderModule {
18772 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18773 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18774 let error_message_ffi = ffi::WGPUStringView {
18775 data: error_message.as_ptr().cast(),
18776 length: error_message.len(),
18777 };
18778 let result = unsafe {
18779 ffi::wgpuDeviceCreateErrorShaderModule(
18780 self.raw,
18781 descriptor_ptr,
18782 error_message_ffi,
18783 )
18784 };
18785 unsafe { ShaderModule::from_raw(result) }
18786 }
18787 pub fn create_texture(&self, descriptor: &TextureDescriptor) -> Texture {
18788 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18789 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18790 let result = unsafe {
18791 ffi::wgpuDeviceCreateTexture(self.raw, descriptor_ptr)
18792 };
18793 unsafe { Texture::from_raw(result) }
18794 }
18795 pub fn create_resource_table(
18796 &self,
18797 descriptor: &ResourceTableDescriptor,
18798 ) -> ResourceTable {
18799 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18800 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18801 let result = unsafe {
18802 ffi::wgpuDeviceCreateResourceTable(self.raw, descriptor_ptr)
18803 };
18804 unsafe { ResourceTable::from_raw(result) }
18805 }
18806 pub fn import_shared_buffer_memory(
18807 &self,
18808 descriptor: &SharedBufferMemoryDescriptor,
18809 ) -> SharedBufferMemory {
18810 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18811 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18812 let result = unsafe {
18813 ffi::wgpuDeviceImportSharedBufferMemory(self.raw, descriptor_ptr)
18814 };
18815 unsafe { SharedBufferMemory::from_raw(result) }
18816 }
18817 pub fn import_shared_texture_memory(
18818 &self,
18819 descriptor: &SharedTextureMemoryDescriptor,
18820 ) -> SharedTextureMemory {
18821 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18822 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18823 let result = unsafe {
18824 ffi::wgpuDeviceImportSharedTextureMemory(self.raw, descriptor_ptr)
18825 };
18826 unsafe { SharedTextureMemory::from_raw(result) }
18827 }
18828 pub fn import_shared_fence(
18829 &self,
18830 descriptor: &SharedFenceDescriptor,
18831 ) -> SharedFence {
18832 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18833 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18834 let result = unsafe {
18835 ffi::wgpuDeviceImportSharedFence(self.raw, descriptor_ptr)
18836 };
18837 unsafe { SharedFence::from_raw(result) }
18838 }
18839 pub fn create_error_texture(&self, descriptor: &TextureDescriptor) -> Texture {
18840 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18841 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18842 let result = unsafe {
18843 ffi::wgpuDeviceCreateErrorTexture(self.raw, descriptor_ptr)
18844 };
18845 unsafe { Texture::from_raw(result) }
18846 }
18847 pub fn destroy(&self) -> () {
18848 unsafe { ffi::wgpuDeviceDestroy(self.raw) };
18849 ()
18850 }
18851 pub fn get_a_hardware_buffer_properties(
18852 &self,
18853 handle: *mut std::ffi::c_void,
18854 properties: &mut AHardwareBufferProperties,
18855 ) -> Status {
18856 let (mut properties_ffi, _properties_storage) = properties.to_ffi();
18857 let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
18858 let result = unsafe {
18859 ffi::wgpuDeviceGetAHardwareBufferProperties(
18860 self.raw,
18861 handle,
18862 properties_ptr,
18863 )
18864 };
18865 *properties = AHardwareBufferProperties::from_ffi(properties_ffi);
18866 result.into()
18867 }
18868 pub fn get_limits(&self, limits: &mut Limits) -> Status {
18869 let (mut limits_ffi, _limits_storage) = limits.to_ffi();
18870 let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
18871 let result = unsafe { ffi::wgpuDeviceGetLimits(self.raw, limits_ptr) };
18872 *limits = Limits::from_ffi(limits_ffi);
18873 result.into()
18874 }
18875 pub fn get_lost_future(&self) -> Future {
18876 let result = unsafe { ffi::wgpuDeviceGetLostFuture(self.raw) };
18877 Future::from_ffi(result)
18878 }
18879 pub fn has_feature(&self, feature: FeatureName) -> bool {
18880 let feature_ffi: ffi::WGPUFeatureName = feature.into();
18881 let result = unsafe { ffi::wgpuDeviceHasFeature(self.raw, feature_ffi) };
18882 result != 0
18883 }
18884 pub fn get_features(&self, features: &mut SupportedFeatures) -> () {
18885 let (mut features_ffi, _features_storage) = features.to_ffi();
18886 let features_ptr = std::ptr::addr_of_mut!(features_ffi);
18887 unsafe { ffi::wgpuDeviceGetFeatures(self.raw, features_ptr) };
18888 *features = SupportedFeatures::from_ffi(features_ffi);
18889 ()
18890 }
18891 pub fn get_adapter_info(&self, adapter_info: &mut AdapterInfo) -> Status {
18892 let (mut adapter_info_ffi, _adapter_info_storage) = adapter_info.to_ffi();
18893 let adapter_info_ptr = std::ptr::addr_of_mut!(adapter_info_ffi);
18894 let result = unsafe {
18895 ffi::wgpuDeviceGetAdapterInfo(self.raw, adapter_info_ptr)
18896 };
18897 *adapter_info = AdapterInfo::from_ffi(adapter_info_ffi);
18898 result.into()
18899 }
18900 pub fn get_adapter(&self) -> Adapter {
18901 let result = unsafe { ffi::wgpuDeviceGetAdapter(self.raw) };
18902 unsafe { Adapter::from_raw(result) }
18903 }
18904 pub fn get_queue(&self) -> Queue {
18905 let result = unsafe { ffi::wgpuDeviceGetQueue(self.raw) };
18906 unsafe { Queue::from_raw(result) }
18907 }
18908 pub fn inject_error(&self, r#type: ErrorType, message: String) -> () {
18909 let r#type_ffi: ffi::WGPUErrorType = r#type.into();
18910 let message_ffi = ffi::WGPUStringView {
18911 data: message.as_ptr().cast(),
18912 length: message.len(),
18913 };
18914 unsafe { ffi::wgpuDeviceInjectError(self.raw, r#type_ffi, message_ffi) };
18915 ()
18916 }
18917 pub fn force_loss(&self, r#type: DeviceLostReason, message: String) -> () {
18918 let r#type_ffi: ffi::WGPUDeviceLostReason = r#type.into();
18919 let message_ffi = ffi::WGPUStringView {
18920 data: message.as_ptr().cast(),
18921 length: message.len(),
18922 };
18923 unsafe { ffi::wgpuDeviceForceLoss(self.raw, r#type_ffi, message_ffi) };
18924 ()
18925 }
18926 pub fn tick(&self) -> () {
18927 unsafe { ffi::wgpuDeviceTick(self.raw) };
18928 ()
18929 }
18930 pub fn set_logging_callback(
18931 &self,
18932 callback: impl FnMut(LoggingType, String) + Send + 'static,
18933 ) -> () {
18934 let callback_box: LoggingCallback = Box::new(callback);
18935 let callback_box = Box::new(Some(callback_box));
18936 let callback_userdata = Box::into_raw(callback_box)
18937 .cast::<std::ffi::c_void>();
18938 let callback_info_ffi = ffi::WGPULoggingCallbackInfo {
18939 nextInChain: std::ptr::null_mut(),
18940 callback: Some(logging_callback_trampoline),
18941 userdata1: callback_userdata,
18942 userdata2: std::ptr::null_mut(),
18943 };
18944 unsafe { ffi::wgpuDeviceSetLoggingCallback(self.raw, callback_info_ffi) };
18945 ()
18946 }
18947 pub fn push_error_scope(&self, filter: ErrorFilter) -> () {
18948 let filter_ffi: ffi::WGPUErrorFilter = filter.into();
18949 unsafe { ffi::wgpuDevicePushErrorScope(self.raw, filter_ffi) };
18950 ()
18951 }
18952 pub fn pop_error_scope(
18953 &self,
18954 callback: impl FnMut(PopErrorScopeStatus, ErrorType, String) + Send + 'static,
18955 ) -> Future {
18956 let callback_box: PopErrorScopeCallback = Box::new(callback);
18957 let callback_box = Box::new(Some(callback_box));
18958 let callback_userdata = Box::into_raw(callback_box)
18959 .cast::<std::ffi::c_void>();
18960 let callback_info_ffi = ffi::WGPUPopErrorScopeCallbackInfo {
18961 nextInChain: std::ptr::null_mut(),
18962 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
18963 callback: Some(pop_error_scope_callback_trampoline),
18964 userdata1: callback_userdata,
18965 userdata2: std::ptr::null_mut(),
18966 };
18967 let result = unsafe {
18968 ffi::wgpuDevicePopErrorScope(self.raw, callback_info_ffi)
18969 };
18970 Future::from_ffi(result)
18971 }
18972 pub fn set_label(&self, label: String) -> () {
18973 let label_ffi = ffi::WGPUStringView {
18974 data: label.as_ptr().cast(),
18975 length: label.len(),
18976 };
18977 unsafe { ffi::wgpuDeviceSetLabel(self.raw, label_ffi) };
18978 ()
18979 }
18980 pub fn validate_texture_descriptor(&self, descriptor: &TextureDescriptor) -> () {
18981 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
18982 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
18983 unsafe {
18984 ffi::wgpuDeviceValidateTextureDescriptor(self.raw, descriptor_ptr)
18985 };
18986 ()
18987 }
18988 }
18989 impl Drop for Device {
18990 fn drop(&mut self) {
18991 if self.as_raw().is_null() {
18992 return;
18993 }
18994 unsafe { ffi::wgpuDeviceRelease(self.raw) };
18995 }
18996 }
18997 impl Clone for Device {
18998 fn clone(&self) -> Self {
18999 unsafe { ffi::wgpuDeviceAddRef(self.raw) };
19000 Self { raw: self.raw }
19001 }
19002 }
19003 unsafe impl Send for Device {}
19004 unsafe impl Sync for Device {}
19005 #[derive(Debug)]
19006 pub struct ExternalTexture {
19007 raw: ffi::WGPUExternalTexture,
19008 }
19009 impl ExternalTexture {
19010 pub(crate) unsafe fn from_raw(raw: ffi::WGPUExternalTexture) -> Self {
19011 Self { raw }
19012 }
19013 pub fn as_raw(&self) -> ffi::WGPUExternalTexture {
19014 self.raw
19015 }
19016 pub fn set_label(&self, label: String) -> () {
19017 let label_ffi = ffi::WGPUStringView {
19018 data: label.as_ptr().cast(),
19019 length: label.len(),
19020 };
19021 unsafe { ffi::wgpuExternalTextureSetLabel(self.raw, label_ffi) };
19022 ()
19023 }
19024 pub fn destroy(&self) -> () {
19025 unsafe { ffi::wgpuExternalTextureDestroy(self.raw) };
19026 ()
19027 }
19028 pub fn expire(&self) -> () {
19029 unsafe { ffi::wgpuExternalTextureExpire(self.raw) };
19030 ()
19031 }
19032 pub fn refresh(&self) -> () {
19033 unsafe { ffi::wgpuExternalTextureRefresh(self.raw) };
19034 ()
19035 }
19036 }
19037 impl Drop for ExternalTexture {
19038 fn drop(&mut self) {
19039 if self.as_raw().is_null() {
19040 return;
19041 }
19042 unsafe { ffi::wgpuExternalTextureRelease(self.raw) };
19043 }
19044 }
19045 impl Clone for ExternalTexture {
19046 fn clone(&self) -> Self {
19047 unsafe { ffi::wgpuExternalTextureAddRef(self.raw) };
19048 Self { raw: self.raw }
19049 }
19050 }
19051 unsafe impl Send for ExternalTexture {}
19052 unsafe impl Sync for ExternalTexture {}
19053 #[derive(Debug)]
19054 pub struct Instance {
19055 raw: ffi::WGPUInstance,
19056 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
19057 }
19058 impl Instance {
19059 pub(crate) unsafe fn from_raw(raw: ffi::WGPUInstance) -> Self {
19060 Self {
19061 raw,
19062 _not_sync: std::marker::PhantomData,
19063 }
19064 }
19065 pub fn as_raw(&self) -> ffi::WGPUInstance {
19066 self.raw
19067 }
19068 pub fn new(descriptor: Option<&InstanceDescriptor>) -> Self {
19069 let mut descriptor_storage = ChainedStructStorage::new();
19070 let descriptor_ptr = if let Some(value) = &descriptor {
19071 let (descriptor_ffi, storage) = value.to_ffi();
19072 descriptor_storage = storage;
19073 std::ptr::addr_of!(descriptor_ffi)
19074 } else {
19075 std::ptr::null()
19076 };
19077 let result = unsafe { ffi::wgpuCreateInstance(descriptor_ptr) };
19078 unsafe { Instance::from_raw(result) }
19079 }
19080 pub fn create_surface(&self, descriptor: &SurfaceDescriptor) -> Surface {
19081 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
19082 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
19083 let result = unsafe {
19084 ffi::wgpuInstanceCreateSurface(self.raw, descriptor_ptr)
19085 };
19086 unsafe { Surface::from_raw(result) }
19087 }
19088 pub fn process_events(&self) -> () {
19089 unsafe { ffi::wgpuInstanceProcessEvents(self.raw) };
19090 ()
19091 }
19092 pub fn wait_any(
19093 &self,
19094 mut futures: Option<&mut [FutureWaitInfo]>,
19095 timeout_ns: u64,
19096 ) -> WaitStatus {
19097 let mut futures_raw: Vec<ffi::WGPUFutureWaitInfo> = Vec::new();
19098 let mut futures_storage: Vec<ChainedStructStorage> = Vec::new();
19099 let futures_ptr = if let Some(value) = futures.as_deref() {
19100 for item in value {
19101 let (raw, storage) = item.to_ffi();
19102 futures_raw.push(raw);
19103 futures_storage.push(storage);
19104 }
19105 futures_raw.as_mut_ptr()
19106 } else {
19107 std::ptr::null_mut()
19108 };
19109 let result = unsafe {
19110 ffi::wgpuInstanceWaitAny(
19111 self.raw,
19112 futures.as_deref().map(|v| v.len()).unwrap_or(0),
19113 futures_ptr,
19114 timeout_ns,
19115 )
19116 };
19117 result.into()
19118 }
19119 pub fn request_adapter(
19120 &self,
19121 options: Option<&RequestAdapterOptions>,
19122 callback: impl FnMut(
19123 RequestAdapterStatus,
19124 Option<Adapter>,
19125 String,
19126 ) + Send + 'static,
19127 ) -> Future {
19128 let mut options_storage = ChainedStructStorage::new();
19129 let options_ptr = if let Some(value) = &options {
19130 let (options_ffi, storage) = value.to_ffi();
19131 options_storage = storage;
19132 std::ptr::addr_of!(options_ffi)
19133 } else {
19134 std::ptr::null()
19135 };
19136 let callback_box: RequestAdapterCallback = Box::new(callback);
19137 let callback_box = Box::new(Some(callback_box));
19138 let callback_userdata = Box::into_raw(callback_box)
19139 .cast::<std::ffi::c_void>();
19140 let callback_info_ffi = ffi::WGPURequestAdapterCallbackInfo {
19141 nextInChain: std::ptr::null_mut(),
19142 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19143 callback: Some(request_adapter_callback_trampoline),
19144 userdata1: callback_userdata,
19145 userdata2: std::ptr::null_mut(),
19146 };
19147 let result = unsafe {
19148 ffi::wgpuInstanceRequestAdapter(self.raw, options_ptr, callback_info_ffi)
19149 };
19150 Future::from_ffi(result)
19151 }
19152 pub fn has_wgsl_language_feature(
19153 &self,
19154 feature: WGSLLanguageFeatureName,
19155 ) -> bool {
19156 let feature_ffi: ffi::WGPUWGSLLanguageFeatureName = feature.into();
19157 let result = unsafe {
19158 ffi::wgpuInstanceHasWGSLLanguageFeature(self.raw, feature_ffi)
19159 };
19160 result != 0
19161 }
19162 pub fn get_wgsl_language_features(
19163 &self,
19164 features: &mut SupportedWGSLLanguageFeatures,
19165 ) -> () {
19166 let (mut features_ffi, _features_storage) = features.to_ffi();
19167 let features_ptr = std::ptr::addr_of_mut!(features_ffi);
19168 unsafe { ffi::wgpuInstanceGetWGSLLanguageFeatures(self.raw, features_ptr) };
19169 *features = SupportedWGSLLanguageFeatures::from_ffi(features_ffi);
19170 ()
19171 }
19172 }
19173 impl Drop for Instance {
19174 fn drop(&mut self) {
19175 if self.as_raw().is_null() {
19176 return;
19177 }
19178 unsafe { ffi::wgpuInstanceRelease(self.raw) };
19179 }
19180 }
19181 impl Clone for Instance {
19182 fn clone(&self) -> Self {
19183 unsafe { ffi::wgpuInstanceAddRef(self.raw) };
19184 Self {
19185 raw: self.raw,
19186 _not_sync: std::marker::PhantomData,
19187 }
19188 }
19189 }
19190 unsafe impl Send for Instance {}
19191 #[derive(Debug)]
19192 pub struct PipelineLayout {
19193 raw: ffi::WGPUPipelineLayout,
19194 }
19195 impl PipelineLayout {
19196 pub(crate) unsafe fn from_raw(raw: ffi::WGPUPipelineLayout) -> Self {
19197 Self { raw }
19198 }
19199 pub fn as_raw(&self) -> ffi::WGPUPipelineLayout {
19200 self.raw
19201 }
19202 pub fn set_label(&self, label: String) -> () {
19203 let label_ffi = ffi::WGPUStringView {
19204 data: label.as_ptr().cast(),
19205 length: label.len(),
19206 };
19207 unsafe { ffi::wgpuPipelineLayoutSetLabel(self.raw, label_ffi) };
19208 ()
19209 }
19210 }
19211 impl Drop for PipelineLayout {
19212 fn drop(&mut self) {
19213 if self.as_raw().is_null() {
19214 return;
19215 }
19216 unsafe { ffi::wgpuPipelineLayoutRelease(self.raw) };
19217 }
19218 }
19219 impl Clone for PipelineLayout {
19220 fn clone(&self) -> Self {
19221 unsafe { ffi::wgpuPipelineLayoutAddRef(self.raw) };
19222 Self { raw: self.raw }
19223 }
19224 }
19225 unsafe impl Send for PipelineLayout {}
19226 unsafe impl Sync for PipelineLayout {}
19227 #[derive(Debug)]
19228 pub struct QuerySet {
19229 raw: ffi::WGPUQuerySet,
19230 }
19231 impl QuerySet {
19232 pub(crate) unsafe fn from_raw(raw: ffi::WGPUQuerySet) -> Self {
19233 Self { raw }
19234 }
19235 pub fn as_raw(&self) -> ffi::WGPUQuerySet {
19236 self.raw
19237 }
19238 pub fn set_label(&self, label: String) -> () {
19239 let label_ffi = ffi::WGPUStringView {
19240 data: label.as_ptr().cast(),
19241 length: label.len(),
19242 };
19243 unsafe { ffi::wgpuQuerySetSetLabel(self.raw, label_ffi) };
19244 ()
19245 }
19246 pub fn get_type(&self) -> QueryType {
19247 let result = unsafe { ffi::wgpuQuerySetGetType(self.raw) };
19248 result.into()
19249 }
19250 pub fn get_count(&self) -> u32 {
19251 let result = unsafe { ffi::wgpuQuerySetGetCount(self.raw) };
19252 result
19253 }
19254 pub fn destroy(&self) -> () {
19255 unsafe { ffi::wgpuQuerySetDestroy(self.raw) };
19256 ()
19257 }
19258 }
19259 impl Drop for QuerySet {
19260 fn drop(&mut self) {
19261 if self.as_raw().is_null() {
19262 return;
19263 }
19264 unsafe { ffi::wgpuQuerySetRelease(self.raw) };
19265 }
19266 }
19267 impl Clone for QuerySet {
19268 fn clone(&self) -> Self {
19269 unsafe { ffi::wgpuQuerySetAddRef(self.raw) };
19270 Self { raw: self.raw }
19271 }
19272 }
19273 unsafe impl Send for QuerySet {}
19274 unsafe impl Sync for QuerySet {}
19275 #[derive(Debug)]
19276 pub struct Queue {
19277 raw: ffi::WGPUQueue,
19278 }
19279 impl Queue {
19280 pub(crate) unsafe fn from_raw(raw: ffi::WGPUQueue) -> Self {
19281 Self { raw }
19282 }
19283 pub fn as_raw(&self) -> ffi::WGPUQueue {
19284 self.raw
19285 }
19286 pub fn submit(&self, commands: &[CommandBuffer]) -> () {
19287 let mut commands_raw: Vec<ffi::WGPUCommandBuffer> = commands
19288 .iter()
19289 .map(|v| v.as_raw())
19290 .collect();
19291 let commands_ptr = commands_raw.as_ptr();
19292 unsafe { ffi::wgpuQueueSubmit(self.raw, commands.len(), commands_ptr) };
19293 ()
19294 }
19295 pub fn on_submitted_work_done(
19296 &self,
19297 callback: impl FnMut(QueueWorkDoneStatus, String) + Send + 'static,
19298 ) -> Future {
19299 let callback_box: QueueWorkDoneCallback = Box::new(callback);
19300 let callback_box = Box::new(Some(callback_box));
19301 let callback_userdata = Box::into_raw(callback_box)
19302 .cast::<std::ffi::c_void>();
19303 let callback_info_ffi = ffi::WGPUQueueWorkDoneCallbackInfo {
19304 nextInChain: std::ptr::null_mut(),
19305 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
19306 callback: Some(queue_work_done_callback_trampoline),
19307 userdata1: callback_userdata,
19308 userdata2: std::ptr::null_mut(),
19309 };
19310 let result = unsafe {
19311 ffi::wgpuQueueOnSubmittedWorkDone(self.raw, callback_info_ffi)
19312 };
19313 Future::from_ffi(result)
19314 }
19315 pub fn write_buffer(
19316 &self,
19317 buffer: Buffer,
19318 buffer_offset: u64,
19319 data: &[std::ffi::c_void],
19320 ) -> () {
19321 let data_ptr = data.as_ptr();
19322 unsafe {
19323 ffi::wgpuQueueWriteBuffer(
19324 self.raw,
19325 buffer.as_raw(),
19326 buffer_offset,
19327 data_ptr,
19328 data.len(),
19329 )
19330 };
19331 ()
19332 }
19333 pub fn write_texture(
19334 &self,
19335 destination: &TexelCopyTextureInfo,
19336 data: &[std::ffi::c_void],
19337 data_layout: &TexelCopyBufferLayout,
19338 write_size: &Extent3D,
19339 ) -> () {
19340 let (destination_ffi, _destination_storage) = destination.to_ffi();
19341 let destination_ptr = std::ptr::addr_of!(destination_ffi);
19342 let data_ptr = data.as_ptr();
19343 let (data_layout_ffi, _data_layout_storage) = data_layout.to_ffi();
19344 let data_layout_ptr = std::ptr::addr_of!(data_layout_ffi);
19345 let (write_size_ffi, _write_size_storage) = write_size.to_ffi();
19346 let write_size_ptr = std::ptr::addr_of!(write_size_ffi);
19347 unsafe {
19348 ffi::wgpuQueueWriteTexture(
19349 self.raw,
19350 destination_ptr,
19351 data_ptr,
19352 data.len(),
19353 data_layout_ptr,
19354 write_size_ptr,
19355 )
19356 };
19357 ()
19358 }
19359 pub fn copy_texture_for_browser(
19360 &self,
19361 source: &TexelCopyTextureInfo,
19362 destination: &TexelCopyTextureInfo,
19363 copy_size: &Extent3D,
19364 options: &CopyTextureForBrowserOptions,
19365 ) -> () {
19366 let (source_ffi, _source_storage) = source.to_ffi();
19367 let source_ptr = std::ptr::addr_of!(source_ffi);
19368 let (destination_ffi, _destination_storage) = destination.to_ffi();
19369 let destination_ptr = std::ptr::addr_of!(destination_ffi);
19370 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
19371 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
19372 let (options_ffi, _options_storage) = options.to_ffi();
19373 let options_ptr = std::ptr::addr_of!(options_ffi);
19374 unsafe {
19375 ffi::wgpuQueueCopyTextureForBrowser(
19376 self.raw,
19377 source_ptr,
19378 destination_ptr,
19379 copy_size_ptr,
19380 options_ptr,
19381 )
19382 };
19383 ()
19384 }
19385 pub fn copy_external_texture_for_browser(
19386 &self,
19387 source: &ImageCopyExternalTexture,
19388 destination: &TexelCopyTextureInfo,
19389 copy_size: &Extent3D,
19390 options: &CopyTextureForBrowserOptions,
19391 ) -> () {
19392 let (source_ffi, _source_storage) = source.to_ffi();
19393 let source_ptr = std::ptr::addr_of!(source_ffi);
19394 let (destination_ffi, _destination_storage) = destination.to_ffi();
19395 let destination_ptr = std::ptr::addr_of!(destination_ffi);
19396 let (copy_size_ffi, _copy_size_storage) = copy_size.to_ffi();
19397 let copy_size_ptr = std::ptr::addr_of!(copy_size_ffi);
19398 let (options_ffi, _options_storage) = options.to_ffi();
19399 let options_ptr = std::ptr::addr_of!(options_ffi);
19400 unsafe {
19401 ffi::wgpuQueueCopyExternalTextureForBrowser(
19402 self.raw,
19403 source_ptr,
19404 destination_ptr,
19405 copy_size_ptr,
19406 options_ptr,
19407 )
19408 };
19409 ()
19410 }
19411 pub fn set_label(&self, label: String) -> () {
19412 let label_ffi = ffi::WGPUStringView {
19413 data: label.as_ptr().cast(),
19414 length: label.len(),
19415 };
19416 unsafe { ffi::wgpuQueueSetLabel(self.raw, label_ffi) };
19417 ()
19418 }
19419 }
19420 impl Drop for Queue {
19421 fn drop(&mut self) {
19422 if self.as_raw().is_null() {
19423 return;
19424 }
19425 unsafe { ffi::wgpuQueueRelease(self.raw) };
19426 }
19427 }
19428 impl Clone for Queue {
19429 fn clone(&self) -> Self {
19430 unsafe { ffi::wgpuQueueAddRef(self.raw) };
19431 Self { raw: self.raw }
19432 }
19433 }
19434 unsafe impl Send for Queue {}
19435 unsafe impl Sync for Queue {}
19436 #[derive(Debug)]
19437 pub struct RenderBundle {
19438 raw: ffi::WGPURenderBundle,
19439 }
19440 impl RenderBundle {
19441 pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderBundle) -> Self {
19442 Self { raw }
19443 }
19444 pub fn as_raw(&self) -> ffi::WGPURenderBundle {
19445 self.raw
19446 }
19447 pub fn set_label(&self, label: String) -> () {
19448 let label_ffi = ffi::WGPUStringView {
19449 data: label.as_ptr().cast(),
19450 length: label.len(),
19451 };
19452 unsafe { ffi::wgpuRenderBundleSetLabel(self.raw, label_ffi) };
19453 ()
19454 }
19455 }
19456 impl Drop for RenderBundle {
19457 fn drop(&mut self) {
19458 if self.as_raw().is_null() {
19459 return;
19460 }
19461 unsafe { ffi::wgpuRenderBundleRelease(self.raw) };
19462 }
19463 }
19464 impl Clone for RenderBundle {
19465 fn clone(&self) -> Self {
19466 unsafe { ffi::wgpuRenderBundleAddRef(self.raw) };
19467 Self { raw: self.raw }
19468 }
19469 }
19470 unsafe impl Send for RenderBundle {}
19471 unsafe impl Sync for RenderBundle {}
19472 #[derive(Debug)]
19473 pub struct RenderBundleEncoder {
19474 raw: ffi::WGPURenderBundleEncoder,
19475 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
19476 }
19477 impl RenderBundleEncoder {
19478 pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderBundleEncoder) -> Self {
19479 Self {
19480 raw,
19481 _not_sync: std::marker::PhantomData,
19482 }
19483 }
19484 pub fn as_raw(&self) -> ffi::WGPURenderBundleEncoder {
19485 self.raw
19486 }
19487 pub fn set_pipeline(&self, pipeline: RenderPipeline) -> () {
19488 unsafe {
19489 ffi::wgpuRenderBundleEncoderSetPipeline(self.raw, pipeline.as_raw())
19490 };
19491 ()
19492 }
19493 pub fn set_bind_group(
19494 &self,
19495 group_index: u32,
19496 group: Option<BindGroup>,
19497 dynamic_offsets: &[u32],
19498 ) -> () {
19499 let group_raw = group
19500 .as_ref()
19501 .map(|v| v.as_raw())
19502 .unwrap_or(std::ptr::null_mut());
19503 let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
19504 unsafe {
19505 ffi::wgpuRenderBundleEncoderSetBindGroup(
19506 self.raw,
19507 group_index,
19508 group_raw,
19509 dynamic_offsets.len(),
19510 dynamic_offsets_ptr,
19511 )
19512 };
19513 ()
19514 }
19515 pub fn draw(
19516 &self,
19517 vertex_count: u32,
19518 instance_count: u32,
19519 first_vertex: u32,
19520 first_instance: u32,
19521 ) -> () {
19522 unsafe {
19523 ffi::wgpuRenderBundleEncoderDraw(
19524 self.raw,
19525 vertex_count,
19526 instance_count,
19527 first_vertex,
19528 first_instance,
19529 )
19530 };
19531 ()
19532 }
19533 pub fn draw_indexed(
19534 &self,
19535 index_count: u32,
19536 instance_count: u32,
19537 first_index: u32,
19538 base_vertex: i32,
19539 first_instance: u32,
19540 ) -> () {
19541 unsafe {
19542 ffi::wgpuRenderBundleEncoderDrawIndexed(
19543 self.raw,
19544 index_count,
19545 instance_count,
19546 first_index,
19547 base_vertex,
19548 first_instance,
19549 )
19550 };
19551 ()
19552 }
19553 pub fn draw_indirect(
19554 &self,
19555 indirect_buffer: Buffer,
19556 indirect_offset: u64,
19557 ) -> () {
19558 unsafe {
19559 ffi::wgpuRenderBundleEncoderDrawIndirect(
19560 self.raw,
19561 indirect_buffer.as_raw(),
19562 indirect_offset,
19563 )
19564 };
19565 ()
19566 }
19567 pub fn draw_indexed_indirect(
19568 &self,
19569 indirect_buffer: Buffer,
19570 indirect_offset: u64,
19571 ) -> () {
19572 unsafe {
19573 ffi::wgpuRenderBundleEncoderDrawIndexedIndirect(
19574 self.raw,
19575 indirect_buffer.as_raw(),
19576 indirect_offset,
19577 )
19578 };
19579 ()
19580 }
19581 pub fn insert_debug_marker(&self, marker_label: String) -> () {
19582 let marker_label_ffi = ffi::WGPUStringView {
19583 data: marker_label.as_ptr().cast(),
19584 length: marker_label.len(),
19585 };
19586 unsafe {
19587 ffi::wgpuRenderBundleEncoderInsertDebugMarker(self.raw, marker_label_ffi)
19588 };
19589 ()
19590 }
19591 pub fn pop_debug_group(&self) -> () {
19592 unsafe { ffi::wgpuRenderBundleEncoderPopDebugGroup(self.raw) };
19593 ()
19594 }
19595 pub fn push_debug_group(&self, group_label: String) -> () {
19596 let group_label_ffi = ffi::WGPUStringView {
19597 data: group_label.as_ptr().cast(),
19598 length: group_label.len(),
19599 };
19600 unsafe {
19601 ffi::wgpuRenderBundleEncoderPushDebugGroup(self.raw, group_label_ffi)
19602 };
19603 ()
19604 }
19605 pub fn set_vertex_buffer(
19606 &self,
19607 slot: u32,
19608 buffer: Option<Buffer>,
19609 offset: u64,
19610 size: u64,
19611 ) -> () {
19612 let buffer_raw = buffer
19613 .as_ref()
19614 .map(|v| v.as_raw())
19615 .unwrap_or(std::ptr::null_mut());
19616 unsafe {
19617 ffi::wgpuRenderBundleEncoderSetVertexBuffer(
19618 self.raw,
19619 slot,
19620 buffer_raw,
19621 offset,
19622 size,
19623 )
19624 };
19625 ()
19626 }
19627 pub fn set_index_buffer(
19628 &self,
19629 buffer: Buffer,
19630 format: IndexFormat,
19631 offset: u64,
19632 size: u64,
19633 ) -> () {
19634 let format_ffi: ffi::WGPUIndexFormat = format.into();
19635 unsafe {
19636 ffi::wgpuRenderBundleEncoderSetIndexBuffer(
19637 self.raw,
19638 buffer.as_raw(),
19639 format_ffi,
19640 offset,
19641 size,
19642 )
19643 };
19644 ()
19645 }
19646 pub fn finish(
19647 &self,
19648 descriptor: Option<&RenderBundleDescriptor>,
19649 ) -> RenderBundle {
19650 let mut descriptor_storage = ChainedStructStorage::new();
19651 let descriptor_ptr = if let Some(value) = &descriptor {
19652 let (descriptor_ffi, storage) = value.to_ffi();
19653 descriptor_storage = storage;
19654 std::ptr::addr_of!(descriptor_ffi)
19655 } else {
19656 std::ptr::null()
19657 };
19658 let result = unsafe {
19659 ffi::wgpuRenderBundleEncoderFinish(self.raw, descriptor_ptr)
19660 };
19661 unsafe { RenderBundle::from_raw(result) }
19662 }
19663 pub fn set_label(&self, label: String) -> () {
19664 let label_ffi = ffi::WGPUStringView {
19665 data: label.as_ptr().cast(),
19666 length: label.len(),
19667 };
19668 unsafe { ffi::wgpuRenderBundleEncoderSetLabel(self.raw, label_ffi) };
19669 ()
19670 }
19671 pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
19672 let data_ptr = data.as_ptr();
19673 unsafe {
19674 ffi::wgpuRenderBundleEncoderSetImmediates(
19675 self.raw,
19676 offset,
19677 data_ptr,
19678 data.len(),
19679 )
19680 };
19681 ()
19682 }
19683 pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
19684 let table_raw = table
19685 .as_ref()
19686 .map(|v| v.as_raw())
19687 .unwrap_or(std::ptr::null_mut());
19688 unsafe { ffi::wgpuRenderBundleEncoderSetResourceTable(self.raw, table_raw) };
19689 ()
19690 }
19691 }
19692 impl Drop for RenderBundleEncoder {
19693 fn drop(&mut self) {
19694 if self.as_raw().is_null() {
19695 return;
19696 }
19697 unsafe { ffi::wgpuRenderBundleEncoderRelease(self.raw) };
19698 }
19699 }
19700 impl Clone for RenderBundleEncoder {
19701 fn clone(&self) -> Self {
19702 unsafe { ffi::wgpuRenderBundleEncoderAddRef(self.raw) };
19703 Self {
19704 raw: self.raw,
19705 _not_sync: std::marker::PhantomData,
19706 }
19707 }
19708 }
19709 unsafe impl Send for RenderBundleEncoder {}
19710 #[derive(Debug)]
19711 pub struct RenderPassEncoder {
19712 raw: ffi::WGPURenderPassEncoder,
19713 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
19714 }
19715 impl RenderPassEncoder {
19716 pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderPassEncoder) -> Self {
19717 Self {
19718 raw,
19719 _not_sync: std::marker::PhantomData,
19720 }
19721 }
19722 pub fn as_raw(&self) -> ffi::WGPURenderPassEncoder {
19723 self.raw
19724 }
19725 pub fn set_pipeline(&self, pipeline: RenderPipeline) -> () {
19726 unsafe {
19727 ffi::wgpuRenderPassEncoderSetPipeline(self.raw, pipeline.as_raw())
19728 };
19729 ()
19730 }
19731 pub fn set_bind_group(
19732 &self,
19733 group_index: u32,
19734 group: Option<BindGroup>,
19735 dynamic_offsets: &[u32],
19736 ) -> () {
19737 let group_raw = group
19738 .as_ref()
19739 .map(|v| v.as_raw())
19740 .unwrap_or(std::ptr::null_mut());
19741 let dynamic_offsets_ptr = dynamic_offsets.as_ptr();
19742 unsafe {
19743 ffi::wgpuRenderPassEncoderSetBindGroup(
19744 self.raw,
19745 group_index,
19746 group_raw,
19747 dynamic_offsets.len(),
19748 dynamic_offsets_ptr,
19749 )
19750 };
19751 ()
19752 }
19753 pub fn draw(
19754 &self,
19755 vertex_count: u32,
19756 instance_count: u32,
19757 first_vertex: u32,
19758 first_instance: u32,
19759 ) -> () {
19760 unsafe {
19761 ffi::wgpuRenderPassEncoderDraw(
19762 self.raw,
19763 vertex_count,
19764 instance_count,
19765 first_vertex,
19766 first_instance,
19767 )
19768 };
19769 ()
19770 }
19771 pub fn draw_indexed(
19772 &self,
19773 index_count: u32,
19774 instance_count: u32,
19775 first_index: u32,
19776 base_vertex: i32,
19777 first_instance: u32,
19778 ) -> () {
19779 unsafe {
19780 ffi::wgpuRenderPassEncoderDrawIndexed(
19781 self.raw,
19782 index_count,
19783 instance_count,
19784 first_index,
19785 base_vertex,
19786 first_instance,
19787 )
19788 };
19789 ()
19790 }
19791 pub fn draw_indirect(
19792 &self,
19793 indirect_buffer: Buffer,
19794 indirect_offset: u64,
19795 ) -> () {
19796 unsafe {
19797 ffi::wgpuRenderPassEncoderDrawIndirect(
19798 self.raw,
19799 indirect_buffer.as_raw(),
19800 indirect_offset,
19801 )
19802 };
19803 ()
19804 }
19805 pub fn draw_indexed_indirect(
19806 &self,
19807 indirect_buffer: Buffer,
19808 indirect_offset: u64,
19809 ) -> () {
19810 unsafe {
19811 ffi::wgpuRenderPassEncoderDrawIndexedIndirect(
19812 self.raw,
19813 indirect_buffer.as_raw(),
19814 indirect_offset,
19815 )
19816 };
19817 ()
19818 }
19819 pub fn multi_draw_indirect(
19820 &self,
19821 indirect_buffer: Buffer,
19822 indirect_offset: u64,
19823 max_draw_count: u32,
19824 draw_count_buffer: Option<Buffer>,
19825 draw_count_buffer_offset: u64,
19826 ) -> () {
19827 let draw_count_buffer_raw = draw_count_buffer
19828 .as_ref()
19829 .map(|v| v.as_raw())
19830 .unwrap_or(std::ptr::null_mut());
19831 unsafe {
19832 ffi::wgpuRenderPassEncoderMultiDrawIndirect(
19833 self.raw,
19834 indirect_buffer.as_raw(),
19835 indirect_offset,
19836 max_draw_count,
19837 draw_count_buffer_raw,
19838 draw_count_buffer_offset,
19839 )
19840 };
19841 ()
19842 }
19843 pub fn multi_draw_indexed_indirect(
19844 &self,
19845 indirect_buffer: Buffer,
19846 indirect_offset: u64,
19847 max_draw_count: u32,
19848 draw_count_buffer: Option<Buffer>,
19849 draw_count_buffer_offset: u64,
19850 ) -> () {
19851 let draw_count_buffer_raw = draw_count_buffer
19852 .as_ref()
19853 .map(|v| v.as_raw())
19854 .unwrap_or(std::ptr::null_mut());
19855 unsafe {
19856 ffi::wgpuRenderPassEncoderMultiDrawIndexedIndirect(
19857 self.raw,
19858 indirect_buffer.as_raw(),
19859 indirect_offset,
19860 max_draw_count,
19861 draw_count_buffer_raw,
19862 draw_count_buffer_offset,
19863 )
19864 };
19865 ()
19866 }
19867 pub fn execute_bundles(&self, bundles: &[RenderBundle]) -> () {
19868 let mut bundles_raw: Vec<ffi::WGPURenderBundle> = bundles
19869 .iter()
19870 .map(|v| v.as_raw())
19871 .collect();
19872 let bundles_ptr = bundles_raw.as_ptr();
19873 unsafe {
19874 ffi::wgpuRenderPassEncoderExecuteBundles(
19875 self.raw,
19876 bundles.len(),
19877 bundles_ptr,
19878 )
19879 };
19880 ()
19881 }
19882 pub fn insert_debug_marker(&self, marker_label: String) -> () {
19883 let marker_label_ffi = ffi::WGPUStringView {
19884 data: marker_label.as_ptr().cast(),
19885 length: marker_label.len(),
19886 };
19887 unsafe {
19888 ffi::wgpuRenderPassEncoderInsertDebugMarker(self.raw, marker_label_ffi)
19889 };
19890 ()
19891 }
19892 pub fn pop_debug_group(&self) -> () {
19893 unsafe { ffi::wgpuRenderPassEncoderPopDebugGroup(self.raw) };
19894 ()
19895 }
19896 pub fn push_debug_group(&self, group_label: String) -> () {
19897 let group_label_ffi = ffi::WGPUStringView {
19898 data: group_label.as_ptr().cast(),
19899 length: group_label.len(),
19900 };
19901 unsafe {
19902 ffi::wgpuRenderPassEncoderPushDebugGroup(self.raw, group_label_ffi)
19903 };
19904 ()
19905 }
19906 pub fn set_stencil_reference(&self, reference: u32) -> () {
19907 unsafe {
19908 ffi::wgpuRenderPassEncoderSetStencilReference(self.raw, reference)
19909 };
19910 ()
19911 }
19912 pub fn set_blend_constant(&self, color: &Color) -> () {
19913 let (color_ffi, _color_storage) = color.to_ffi();
19914 let color_ptr = std::ptr::addr_of!(color_ffi);
19915 unsafe { ffi::wgpuRenderPassEncoderSetBlendConstant(self.raw, color_ptr) };
19916 ()
19917 }
19918 pub fn set_viewport(
19919 &self,
19920 x: f32,
19921 y: f32,
19922 width: f32,
19923 height: f32,
19924 min_depth: f32,
19925 max_depth: f32,
19926 ) -> () {
19927 unsafe {
19928 ffi::wgpuRenderPassEncoderSetViewport(
19929 self.raw,
19930 x,
19931 y,
19932 width,
19933 height,
19934 min_depth,
19935 max_depth,
19936 )
19937 };
19938 ()
19939 }
19940 pub fn set_scissor_rect(&self, x: u32, y: u32, width: u32, height: u32) -> () {
19941 unsafe {
19942 ffi::wgpuRenderPassEncoderSetScissorRect(self.raw, x, y, width, height)
19943 };
19944 ()
19945 }
19946 pub fn set_vertex_buffer(
19947 &self,
19948 slot: u32,
19949 buffer: Option<Buffer>,
19950 offset: u64,
19951 size: u64,
19952 ) -> () {
19953 let buffer_raw = buffer
19954 .as_ref()
19955 .map(|v| v.as_raw())
19956 .unwrap_or(std::ptr::null_mut());
19957 unsafe {
19958 ffi::wgpuRenderPassEncoderSetVertexBuffer(
19959 self.raw,
19960 slot,
19961 buffer_raw,
19962 offset,
19963 size,
19964 )
19965 };
19966 ()
19967 }
19968 pub fn set_index_buffer(
19969 &self,
19970 buffer: Buffer,
19971 format: IndexFormat,
19972 offset: u64,
19973 size: u64,
19974 ) -> () {
19975 let format_ffi: ffi::WGPUIndexFormat = format.into();
19976 unsafe {
19977 ffi::wgpuRenderPassEncoderSetIndexBuffer(
19978 self.raw,
19979 buffer.as_raw(),
19980 format_ffi,
19981 offset,
19982 size,
19983 )
19984 };
19985 ()
19986 }
19987 pub fn begin_occlusion_query(&self, query_index: u32) -> () {
19988 unsafe {
19989 ffi::wgpuRenderPassEncoderBeginOcclusionQuery(self.raw, query_index)
19990 };
19991 ()
19992 }
19993 pub fn end_occlusion_query(&self) -> () {
19994 unsafe { ffi::wgpuRenderPassEncoderEndOcclusionQuery(self.raw) };
19995 ()
19996 }
19997 pub fn write_timestamp(&self, query_set: QuerySet, query_index: u32) -> () {
19998 unsafe {
19999 ffi::wgpuRenderPassEncoderWriteTimestamp(
20000 self.raw,
20001 query_set.as_raw(),
20002 query_index,
20003 )
20004 };
20005 ()
20006 }
20007 pub fn pixel_local_storage_barrier(&self) -> () {
20008 unsafe { ffi::wgpuRenderPassEncoderPixelLocalStorageBarrier(self.raw) };
20009 ()
20010 }
20011 pub fn end(&self) -> () {
20012 unsafe { ffi::wgpuRenderPassEncoderEnd(self.raw) };
20013 ()
20014 }
20015 pub fn set_label(&self, label: String) -> () {
20016 let label_ffi = ffi::WGPUStringView {
20017 data: label.as_ptr().cast(),
20018 length: label.len(),
20019 };
20020 unsafe { ffi::wgpuRenderPassEncoderSetLabel(self.raw, label_ffi) };
20021 ()
20022 }
20023 pub fn set_immediates(&self, offset: u32, data: &[std::ffi::c_void]) -> () {
20024 let data_ptr = data.as_ptr();
20025 unsafe {
20026 ffi::wgpuRenderPassEncoderSetImmediates(
20027 self.raw,
20028 offset,
20029 data_ptr,
20030 data.len(),
20031 )
20032 };
20033 ()
20034 }
20035 pub fn set_resource_table(&self, table: Option<ResourceTable>) -> () {
20036 let table_raw = table
20037 .as_ref()
20038 .map(|v| v.as_raw())
20039 .unwrap_or(std::ptr::null_mut());
20040 unsafe { ffi::wgpuRenderPassEncoderSetResourceTable(self.raw, table_raw) };
20041 ()
20042 }
20043 }
20044 impl Drop for RenderPassEncoder {
20045 fn drop(&mut self) {
20046 if self.as_raw().is_null() {
20047 return;
20048 }
20049 unsafe { ffi::wgpuRenderPassEncoderRelease(self.raw) };
20050 }
20051 }
20052 impl Clone for RenderPassEncoder {
20053 fn clone(&self) -> Self {
20054 unsafe { ffi::wgpuRenderPassEncoderAddRef(self.raw) };
20055 Self {
20056 raw: self.raw,
20057 _not_sync: std::marker::PhantomData,
20058 }
20059 }
20060 }
20061 unsafe impl Send for RenderPassEncoder {}
20062 #[derive(Debug)]
20063 pub struct RenderPipeline {
20064 raw: ffi::WGPURenderPipeline,
20065 }
20066 impl RenderPipeline {
20067 pub(crate) unsafe fn from_raw(raw: ffi::WGPURenderPipeline) -> Self {
20068 Self { raw }
20069 }
20070 pub fn as_raw(&self) -> ffi::WGPURenderPipeline {
20071 self.raw
20072 }
20073 pub fn get_bind_group_layout(&self, group_index: u32) -> BindGroupLayout {
20074 let result = unsafe {
20075 ffi::wgpuRenderPipelineGetBindGroupLayout(self.raw, group_index)
20076 };
20077 unsafe { BindGroupLayout::from_raw(result) }
20078 }
20079 pub fn set_label(&self, label: String) -> () {
20080 let label_ffi = ffi::WGPUStringView {
20081 data: label.as_ptr().cast(),
20082 length: label.len(),
20083 };
20084 unsafe { ffi::wgpuRenderPipelineSetLabel(self.raw, label_ffi) };
20085 ()
20086 }
20087 }
20088 impl Drop for RenderPipeline {
20089 fn drop(&mut self) {
20090 if self.as_raw().is_null() {
20091 return;
20092 }
20093 unsafe { ffi::wgpuRenderPipelineRelease(self.raw) };
20094 }
20095 }
20096 impl Clone for RenderPipeline {
20097 fn clone(&self) -> Self {
20098 unsafe { ffi::wgpuRenderPipelineAddRef(self.raw) };
20099 Self { raw: self.raw }
20100 }
20101 }
20102 unsafe impl Send for RenderPipeline {}
20103 unsafe impl Sync for RenderPipeline {}
20104 #[derive(Debug)]
20105 pub struct ResourceTable {
20106 raw: ffi::WGPUResourceTable,
20107 }
20108 impl ResourceTable {
20109 pub(crate) unsafe fn from_raw(raw: ffi::WGPUResourceTable) -> Self {
20110 Self { raw }
20111 }
20112 pub fn as_raw(&self) -> ffi::WGPUResourceTable {
20113 self.raw
20114 }
20115 pub fn get_size(&self) -> u32 {
20116 let result = unsafe { ffi::wgpuResourceTableGetSize(self.raw) };
20117 result
20118 }
20119 pub fn destroy(&self) -> () {
20120 unsafe { ffi::wgpuResourceTableDestroy(self.raw) };
20121 ()
20122 }
20123 pub fn update(&self, slot: u32, resource: &BindingResource) -> Status {
20124 let (resource_ffi, _resource_storage) = resource.to_ffi();
20125 let resource_ptr = std::ptr::addr_of!(resource_ffi);
20126 let result = unsafe {
20127 ffi::wgpuResourceTableUpdate(self.raw, slot, resource_ptr)
20128 };
20129 result.into()
20130 }
20131 pub fn insert_binding(&self, resource: &BindingResource) -> u32 {
20132 let (resource_ffi, _resource_storage) = resource.to_ffi();
20133 let resource_ptr = std::ptr::addr_of!(resource_ffi);
20134 let result = unsafe {
20135 ffi::wgpuResourceTableInsertBinding(self.raw, resource_ptr)
20136 };
20137 result
20138 }
20139 pub fn remove_binding(&self, slot: u32) -> Status {
20140 let result = unsafe { ffi::wgpuResourceTableRemoveBinding(self.raw, slot) };
20141 result.into()
20142 }
20143 }
20144 impl Drop for ResourceTable {
20145 fn drop(&mut self) {
20146 if self.as_raw().is_null() {
20147 return;
20148 }
20149 unsafe { ffi::wgpuResourceTableRelease(self.raw) };
20150 }
20151 }
20152 impl Clone for ResourceTable {
20153 fn clone(&self) -> Self {
20154 unsafe { ffi::wgpuResourceTableAddRef(self.raw) };
20155 Self { raw: self.raw }
20156 }
20157 }
20158 unsafe impl Send for ResourceTable {}
20159 unsafe impl Sync for ResourceTable {}
20160 #[derive(Debug)]
20161 pub struct Sampler {
20162 raw: ffi::WGPUSampler,
20163 }
20164 impl Sampler {
20165 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSampler) -> Self {
20166 Self { raw }
20167 }
20168 pub fn as_raw(&self) -> ffi::WGPUSampler {
20169 self.raw
20170 }
20171 pub fn set_label(&self, label: String) -> () {
20172 let label_ffi = ffi::WGPUStringView {
20173 data: label.as_ptr().cast(),
20174 length: label.len(),
20175 };
20176 unsafe { ffi::wgpuSamplerSetLabel(self.raw, label_ffi) };
20177 ()
20178 }
20179 }
20180 impl Drop for Sampler {
20181 fn drop(&mut self) {
20182 if self.as_raw().is_null() {
20183 return;
20184 }
20185 unsafe { ffi::wgpuSamplerRelease(self.raw) };
20186 }
20187 }
20188 impl Clone for Sampler {
20189 fn clone(&self) -> Self {
20190 unsafe { ffi::wgpuSamplerAddRef(self.raw) };
20191 Self { raw: self.raw }
20192 }
20193 }
20194 unsafe impl Send for Sampler {}
20195 unsafe impl Sync for Sampler {}
20196 #[derive(Debug)]
20197 pub struct ShaderModule {
20198 raw: ffi::WGPUShaderModule,
20199 }
20200 impl ShaderModule {
20201 pub(crate) unsafe fn from_raw(raw: ffi::WGPUShaderModule) -> Self {
20202 Self { raw }
20203 }
20204 pub fn as_raw(&self) -> ffi::WGPUShaderModule {
20205 self.raw
20206 }
20207 pub fn get_compilation_info(
20208 &self,
20209 callback: impl FnMut(
20210 CompilationInfoRequestStatus,
20211 &CompilationInfo,
20212 ) + Send + 'static,
20213 ) -> Future {
20214 let callback_box: CompilationInfoCallback = Box::new(callback);
20215 let callback_box = Box::new(Some(callback_box));
20216 let callback_userdata = Box::into_raw(callback_box)
20217 .cast::<std::ffi::c_void>();
20218 let callback_info_ffi = ffi::WGPUCompilationInfoCallbackInfo {
20219 nextInChain: std::ptr::null_mut(),
20220 mode: ffi::WGPUCallbackMode_WGPUCallbackMode_AllowSpontaneous,
20221 callback: Some(compilation_info_callback_trampoline),
20222 userdata1: callback_userdata,
20223 userdata2: std::ptr::null_mut(),
20224 };
20225 let result = unsafe {
20226 ffi::wgpuShaderModuleGetCompilationInfo(self.raw, callback_info_ffi)
20227 };
20228 Future::from_ffi(result)
20229 }
20230 pub fn set_label(&self, label: String) -> () {
20231 let label_ffi = ffi::WGPUStringView {
20232 data: label.as_ptr().cast(),
20233 length: label.len(),
20234 };
20235 unsafe { ffi::wgpuShaderModuleSetLabel(self.raw, label_ffi) };
20236 ()
20237 }
20238 }
20239 impl Drop for ShaderModule {
20240 fn drop(&mut self) {
20241 if self.as_raw().is_null() {
20242 return;
20243 }
20244 unsafe { ffi::wgpuShaderModuleRelease(self.raw) };
20245 }
20246 }
20247 impl Clone for ShaderModule {
20248 fn clone(&self) -> Self {
20249 unsafe { ffi::wgpuShaderModuleAddRef(self.raw) };
20250 Self { raw: self.raw }
20251 }
20252 }
20253 unsafe impl Send for ShaderModule {}
20254 unsafe impl Sync for ShaderModule {}
20255 #[derive(Debug)]
20256 pub struct SharedBufferMemory {
20257 raw: ffi::WGPUSharedBufferMemory,
20258 }
20259 impl SharedBufferMemory {
20260 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedBufferMemory) -> Self {
20261 Self { raw }
20262 }
20263 pub fn as_raw(&self) -> ffi::WGPUSharedBufferMemory {
20264 self.raw
20265 }
20266 pub fn set_label(&self, label: String) -> () {
20267 let label_ffi = ffi::WGPUStringView {
20268 data: label.as_ptr().cast(),
20269 length: label.len(),
20270 };
20271 unsafe { ffi::wgpuSharedBufferMemorySetLabel(self.raw, label_ffi) };
20272 ()
20273 }
20274 pub fn get_properties(
20275 &self,
20276 properties: &mut SharedBufferMemoryProperties,
20277 ) -> Status {
20278 let (mut properties_ffi, _properties_storage) = properties.to_ffi();
20279 let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
20280 let result = unsafe {
20281 ffi::wgpuSharedBufferMemoryGetProperties(self.raw, properties_ptr)
20282 };
20283 *properties = SharedBufferMemoryProperties::from_ffi(properties_ffi);
20284 result.into()
20285 }
20286 pub fn create_buffer(&self, descriptor: Option<&BufferDescriptor>) -> Buffer {
20287 let mut descriptor_storage = ChainedStructStorage::new();
20288 let descriptor_ptr = if let Some(value) = &descriptor {
20289 let (descriptor_ffi, storage) = value.to_ffi();
20290 descriptor_storage = storage;
20291 std::ptr::addr_of!(descriptor_ffi)
20292 } else {
20293 std::ptr::null()
20294 };
20295 let result = unsafe {
20296 ffi::wgpuSharedBufferMemoryCreateBuffer(self.raw, descriptor_ptr)
20297 };
20298 unsafe { Buffer::from_raw(result) }
20299 }
20300 pub fn begin_access(
20301 &self,
20302 buffer: Buffer,
20303 descriptor: &SharedBufferMemoryBeginAccessDescriptor,
20304 ) -> Status {
20305 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20306 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
20307 let result = unsafe {
20308 ffi::wgpuSharedBufferMemoryBeginAccess(
20309 self.raw,
20310 buffer.as_raw(),
20311 descriptor_ptr,
20312 )
20313 };
20314 result.into()
20315 }
20316 pub fn end_access(
20317 &self,
20318 buffer: Buffer,
20319 descriptor: &mut SharedBufferMemoryEndAccessState,
20320 ) -> Status {
20321 let (mut descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20322 let descriptor_ptr = std::ptr::addr_of_mut!(descriptor_ffi);
20323 let result = unsafe {
20324 ffi::wgpuSharedBufferMemoryEndAccess(
20325 self.raw,
20326 buffer.as_raw(),
20327 descriptor_ptr,
20328 )
20329 };
20330 *descriptor = SharedBufferMemoryEndAccessState::from_ffi(descriptor_ffi);
20331 result.into()
20332 }
20333 pub fn is_device_lost(&self) -> bool {
20334 let result = unsafe { ffi::wgpuSharedBufferMemoryIsDeviceLost(self.raw) };
20335 result != 0
20336 }
20337 }
20338 impl Drop for SharedBufferMemory {
20339 fn drop(&mut self) {
20340 if self.as_raw().is_null() {
20341 return;
20342 }
20343 unsafe { ffi::wgpuSharedBufferMemoryRelease(self.raw) };
20344 }
20345 }
20346 impl Clone for SharedBufferMemory {
20347 fn clone(&self) -> Self {
20348 unsafe { ffi::wgpuSharedBufferMemoryAddRef(self.raw) };
20349 Self { raw: self.raw }
20350 }
20351 }
20352 unsafe impl Send for SharedBufferMemory {}
20353 unsafe impl Sync for SharedBufferMemory {}
20354 #[derive(Debug)]
20355 pub struct SharedFence {
20356 raw: ffi::WGPUSharedFence,
20357 }
20358 impl SharedFence {
20359 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedFence) -> Self {
20360 Self { raw }
20361 }
20362 pub fn as_raw(&self) -> ffi::WGPUSharedFence {
20363 self.raw
20364 }
20365 pub fn export_info(&self, info: &mut SharedFenceExportInfo) -> () {
20366 let (mut info_ffi, _info_storage) = info.to_ffi();
20367 let info_ptr = std::ptr::addr_of_mut!(info_ffi);
20368 unsafe { ffi::wgpuSharedFenceExportInfo(self.raw, info_ptr) };
20369 *info = SharedFenceExportInfo::from_ffi(info_ffi);
20370 ()
20371 }
20372 }
20373 impl Drop for SharedFence {
20374 fn drop(&mut self) {
20375 if self.as_raw().is_null() {
20376 return;
20377 }
20378 unsafe { ffi::wgpuSharedFenceRelease(self.raw) };
20379 }
20380 }
20381 impl Clone for SharedFence {
20382 fn clone(&self) -> Self {
20383 unsafe { ffi::wgpuSharedFenceAddRef(self.raw) };
20384 Self { raw: self.raw }
20385 }
20386 }
20387 unsafe impl Send for SharedFence {}
20388 unsafe impl Sync for SharedFence {}
20389 #[derive(Debug)]
20390 pub struct SharedTextureMemory {
20391 raw: ffi::WGPUSharedTextureMemory,
20392 }
20393 impl SharedTextureMemory {
20394 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSharedTextureMemory) -> Self {
20395 Self { raw }
20396 }
20397 pub fn as_raw(&self) -> ffi::WGPUSharedTextureMemory {
20398 self.raw
20399 }
20400 pub fn set_label(&self, label: String) -> () {
20401 let label_ffi = ffi::WGPUStringView {
20402 data: label.as_ptr().cast(),
20403 length: label.len(),
20404 };
20405 unsafe { ffi::wgpuSharedTextureMemorySetLabel(self.raw, label_ffi) };
20406 ()
20407 }
20408 pub fn get_properties(
20409 &self,
20410 properties: &mut SharedTextureMemoryProperties,
20411 ) -> Status {
20412 let (mut properties_ffi, _properties_storage) = properties.to_ffi();
20413 let properties_ptr = std::ptr::addr_of_mut!(properties_ffi);
20414 let result = unsafe {
20415 ffi::wgpuSharedTextureMemoryGetProperties(self.raw, properties_ptr)
20416 };
20417 *properties = SharedTextureMemoryProperties::from_ffi(properties_ffi);
20418 result.into()
20419 }
20420 pub fn create_texture(&self, descriptor: Option<&TextureDescriptor>) -> Texture {
20421 let mut descriptor_storage = ChainedStructStorage::new();
20422 let descriptor_ptr = if let Some(value) = &descriptor {
20423 let (descriptor_ffi, storage) = value.to_ffi();
20424 descriptor_storage = storage;
20425 std::ptr::addr_of!(descriptor_ffi)
20426 } else {
20427 std::ptr::null()
20428 };
20429 let result = unsafe {
20430 ffi::wgpuSharedTextureMemoryCreateTexture(self.raw, descriptor_ptr)
20431 };
20432 unsafe { Texture::from_raw(result) }
20433 }
20434 pub fn begin_access(
20435 &self,
20436 texture: Texture,
20437 descriptor: &SharedTextureMemoryBeginAccessDescriptor,
20438 ) -> Status {
20439 let (descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20440 let descriptor_ptr = std::ptr::addr_of!(descriptor_ffi);
20441 let result = unsafe {
20442 ffi::wgpuSharedTextureMemoryBeginAccess(
20443 self.raw,
20444 texture.as_raw(),
20445 descriptor_ptr,
20446 )
20447 };
20448 result.into()
20449 }
20450 pub fn end_access(
20451 &self,
20452 texture: Texture,
20453 descriptor: &mut SharedTextureMemoryEndAccessState,
20454 ) -> Status {
20455 let (mut descriptor_ffi, _descriptor_storage) = descriptor.to_ffi();
20456 let descriptor_ptr = std::ptr::addr_of_mut!(descriptor_ffi);
20457 let result = unsafe {
20458 ffi::wgpuSharedTextureMemoryEndAccess(
20459 self.raw,
20460 texture.as_raw(),
20461 descriptor_ptr,
20462 )
20463 };
20464 *descriptor = SharedTextureMemoryEndAccessState::from_ffi(descriptor_ffi);
20465 result.into()
20466 }
20467 pub fn is_device_lost(&self) -> bool {
20468 let result = unsafe { ffi::wgpuSharedTextureMemoryIsDeviceLost(self.raw) };
20469 result != 0
20470 }
20471 }
20472 impl Drop for SharedTextureMemory {
20473 fn drop(&mut self) {
20474 if self.as_raw().is_null() {
20475 return;
20476 }
20477 unsafe { ffi::wgpuSharedTextureMemoryRelease(self.raw) };
20478 }
20479 }
20480 impl Clone for SharedTextureMemory {
20481 fn clone(&self) -> Self {
20482 unsafe { ffi::wgpuSharedTextureMemoryAddRef(self.raw) };
20483 Self { raw: self.raw }
20484 }
20485 }
20486 unsafe impl Send for SharedTextureMemory {}
20487 unsafe impl Sync for SharedTextureMemory {}
20488 #[derive(Debug)]
20489 pub struct Surface {
20490 raw: ffi::WGPUSurface,
20491 _not_sync: std::marker::PhantomData<std::cell::Cell<()>>,
20492 }
20493 impl Surface {
20494 pub(crate) unsafe fn from_raw(raw: ffi::WGPUSurface) -> Self {
20495 Self {
20496 raw,
20497 _not_sync: std::marker::PhantomData,
20498 }
20499 }
20500 pub fn as_raw(&self) -> ffi::WGPUSurface {
20501 self.raw
20502 }
20503 pub fn configure(&self, config: &SurfaceConfiguration) -> () {
20504 let (config_ffi, _config_storage) = config.to_ffi();
20505 let config_ptr = std::ptr::addr_of!(config_ffi);
20506 unsafe { ffi::wgpuSurfaceConfigure(self.raw, config_ptr) };
20507 ()
20508 }
20509 pub fn get_capabilities(
20510 &self,
20511 adapter: Adapter,
20512 capabilities: &mut SurfaceCapabilities,
20513 ) -> Status {
20514 let (mut capabilities_ffi, _capabilities_storage) = capabilities.to_ffi();
20515 let capabilities_ptr = std::ptr::addr_of_mut!(capabilities_ffi);
20516 let result = unsafe {
20517 ffi::wgpuSurfaceGetCapabilities(
20518 self.raw,
20519 adapter.as_raw(),
20520 capabilities_ptr,
20521 )
20522 };
20523 *capabilities = SurfaceCapabilities::from_ffi(capabilities_ffi);
20524 result.into()
20525 }
20526 pub fn get_current_texture(&self, surface_texture: &mut SurfaceTexture) -> () {
20527 let (mut surface_texture_ffi, _surface_texture_storage) = surface_texture
20528 .to_ffi();
20529 let surface_texture_ptr = std::ptr::addr_of_mut!(surface_texture_ffi);
20530 unsafe { ffi::wgpuSurfaceGetCurrentTexture(self.raw, surface_texture_ptr) };
20531 *surface_texture = SurfaceTexture::from_ffi(surface_texture_ffi);
20532 ()
20533 }
20534 pub fn present(&self) -> Status {
20535 let result = unsafe { ffi::wgpuSurfacePresent(self.raw) };
20536 result.into()
20537 }
20538 pub fn unconfigure(&self) -> () {
20539 unsafe { ffi::wgpuSurfaceUnconfigure(self.raw) };
20540 ()
20541 }
20542 pub fn set_label(&self, label: String) -> () {
20543 let label_ffi = ffi::WGPUStringView {
20544 data: label.as_ptr().cast(),
20545 length: label.len(),
20546 };
20547 unsafe { ffi::wgpuSurfaceSetLabel(self.raw, label_ffi) };
20548 ()
20549 }
20550 }
20551 impl Drop for Surface {
20552 fn drop(&mut self) {
20553 if self.as_raw().is_null() {
20554 return;
20555 }
20556 unsafe { ffi::wgpuSurfaceRelease(self.raw) };
20557 }
20558 }
20559 impl Clone for Surface {
20560 fn clone(&self) -> Self {
20561 unsafe { ffi::wgpuSurfaceAddRef(self.raw) };
20562 Self {
20563 raw: self.raw,
20564 _not_sync: std::marker::PhantomData,
20565 }
20566 }
20567 }
20568 unsafe impl Send for Surface {}
20569 #[derive(Debug)]
20570 pub struct TexelBufferView {
20571 raw: ffi::WGPUTexelBufferView,
20572 }
20573 impl TexelBufferView {
20574 pub(crate) unsafe fn from_raw(raw: ffi::WGPUTexelBufferView) -> Self {
20575 Self { raw }
20576 }
20577 pub fn as_raw(&self) -> ffi::WGPUTexelBufferView {
20578 self.raw
20579 }
20580 pub fn set_label(&self, label: String) -> () {
20581 let label_ffi = ffi::WGPUStringView {
20582 data: label.as_ptr().cast(),
20583 length: label.len(),
20584 };
20585 unsafe { ffi::wgpuTexelBufferViewSetLabel(self.raw, label_ffi) };
20586 ()
20587 }
20588 }
20589 impl Drop for TexelBufferView {
20590 fn drop(&mut self) {
20591 if self.as_raw().is_null() {
20592 return;
20593 }
20594 unsafe { ffi::wgpuTexelBufferViewRelease(self.raw) };
20595 }
20596 }
20597 impl Clone for TexelBufferView {
20598 fn clone(&self) -> Self {
20599 unsafe { ffi::wgpuTexelBufferViewAddRef(self.raw) };
20600 Self { raw: self.raw }
20601 }
20602 }
20603 unsafe impl Send for TexelBufferView {}
20604 unsafe impl Sync for TexelBufferView {}
20605 #[derive(Debug)]
20606 pub struct Texture {
20607 raw: ffi::WGPUTexture,
20608 }
20609 impl Texture {
20610 pub(crate) unsafe fn from_raw(raw: ffi::WGPUTexture) -> Self {
20611 Self { raw }
20612 }
20613 pub fn as_raw(&self) -> ffi::WGPUTexture {
20614 self.raw
20615 }
20616 pub fn create_view(
20617 &self,
20618 descriptor: Option<&TextureViewDescriptor>,
20619 ) -> TextureView {
20620 let mut descriptor_storage = ChainedStructStorage::new();
20621 let descriptor_ptr = if let Some(value) = &descriptor {
20622 let (descriptor_ffi, storage) = value.to_ffi();
20623 descriptor_storage = storage;
20624 std::ptr::addr_of!(descriptor_ffi)
20625 } else {
20626 std::ptr::null()
20627 };
20628 let result = unsafe { ffi::wgpuTextureCreateView(self.raw, descriptor_ptr) };
20629 unsafe { TextureView::from_raw(result) }
20630 }
20631 pub fn create_error_view(
20632 &self,
20633 descriptor: Option<&TextureViewDescriptor>,
20634 ) -> TextureView {
20635 let mut descriptor_storage = ChainedStructStorage::new();
20636 let descriptor_ptr = if let Some(value) = &descriptor {
20637 let (descriptor_ffi, storage) = value.to_ffi();
20638 descriptor_storage = storage;
20639 std::ptr::addr_of!(descriptor_ffi)
20640 } else {
20641 std::ptr::null()
20642 };
20643 let result = unsafe {
20644 ffi::wgpuTextureCreateErrorView(self.raw, descriptor_ptr)
20645 };
20646 unsafe { TextureView::from_raw(result) }
20647 }
20648 pub fn set_label(&self, label: String) -> () {
20649 let label_ffi = ffi::WGPUStringView {
20650 data: label.as_ptr().cast(),
20651 length: label.len(),
20652 };
20653 unsafe { ffi::wgpuTextureSetLabel(self.raw, label_ffi) };
20654 ()
20655 }
20656 pub fn get_width(&self) -> u32 {
20657 let result = unsafe { ffi::wgpuTextureGetWidth(self.raw) };
20658 result
20659 }
20660 pub fn get_height(&self) -> u32 {
20661 let result = unsafe { ffi::wgpuTextureGetHeight(self.raw) };
20662 result
20663 }
20664 pub fn get_depth_or_array_layers(&self) -> u32 {
20665 let result = unsafe { ffi::wgpuTextureGetDepthOrArrayLayers(self.raw) };
20666 result
20667 }
20668 pub fn get_mip_level_count(&self) -> u32 {
20669 let result = unsafe { ffi::wgpuTextureGetMipLevelCount(self.raw) };
20670 result
20671 }
20672 pub fn get_sample_count(&self) -> u32 {
20673 let result = unsafe { ffi::wgpuTextureGetSampleCount(self.raw) };
20674 result
20675 }
20676 pub fn get_dimension(&self) -> TextureDimension {
20677 let result = unsafe { ffi::wgpuTextureGetDimension(self.raw) };
20678 result.into()
20679 }
20680 pub fn get_format(&self) -> TextureFormat {
20681 let result = unsafe { ffi::wgpuTextureGetFormat(self.raw) };
20682 result.into()
20683 }
20684 pub fn get_usage(&self) -> TextureUsage {
20685 let result = unsafe { ffi::wgpuTextureGetUsage(self.raw) };
20686 result.into()
20687 }
20688 pub fn get_texture_binding_view_dimension(&self) -> TextureViewDimension {
20689 let result = unsafe {
20690 ffi::wgpuTextureGetTextureBindingViewDimension(self.raw)
20691 };
20692 result.into()
20693 }
20694 pub fn destroy(&self) -> () {
20695 unsafe { ffi::wgpuTextureDestroy(self.raw) };
20696 ()
20697 }
20698 pub fn pin(&self, usage: TextureUsage) -> () {
20699 let usage_ffi: ffi::WGPUTextureUsage = usage.into();
20700 unsafe { ffi::wgpuTexturePin(self.raw, usage_ffi) };
20701 ()
20702 }
20703 pub fn unpin(&self) -> () {
20704 unsafe { ffi::wgpuTextureUnpin(self.raw) };
20705 ()
20706 }
20707 pub fn set_ownership_for_memory_dump(&self, owner_guid: u64) -> () {
20708 unsafe { ffi::wgpuTextureSetOwnershipForMemoryDump(self.raw, owner_guid) };
20709 ()
20710 }
20711 }
20712 impl Drop for Texture {
20713 fn drop(&mut self) {
20714 if self.as_raw().is_null() {
20715 return;
20716 }
20717 unsafe { ffi::wgpuTextureRelease(self.raw) };
20718 }
20719 }
20720 impl Clone for Texture {
20721 fn clone(&self) -> Self {
20722 unsafe { ffi::wgpuTextureAddRef(self.raw) };
20723 Self { raw: self.raw }
20724 }
20725 }
20726 unsafe impl Send for Texture {}
20727 unsafe impl Sync for Texture {}
20728 #[derive(Debug)]
20729 pub struct TextureView {
20730 raw: ffi::WGPUTextureView,
20731 }
20732 impl TextureView {
20733 pub(crate) unsafe fn from_raw(raw: ffi::WGPUTextureView) -> Self {
20734 Self { raw }
20735 }
20736 pub fn as_raw(&self) -> ffi::WGPUTextureView {
20737 self.raw
20738 }
20739 pub fn set_label(&self, label: String) -> () {
20740 let label_ffi = ffi::WGPUStringView {
20741 data: label.as_ptr().cast(),
20742 length: label.len(),
20743 };
20744 unsafe { ffi::wgpuTextureViewSetLabel(self.raw, label_ffi) };
20745 ()
20746 }
20747 }
20748 impl Drop for TextureView {
20749 fn drop(&mut self) {
20750 if self.as_raw().is_null() {
20751 return;
20752 }
20753 unsafe { ffi::wgpuTextureViewRelease(self.raw) };
20754 }
20755 }
20756 impl Clone for TextureView {
20757 fn clone(&self) -> Self {
20758 unsafe { ffi::wgpuTextureViewAddRef(self.raw) };
20759 Self { raw: self.raw }
20760 }
20761 }
20762 unsafe impl Send for TextureView {}
20763 unsafe impl Sync for TextureView {}
20764}
20765mod callbacks {
20766 #![allow(dead_code, unused_imports)]
20767 use crate::ffi;
20768 use crate::generated::*;
20769 pub type Callback = Option<unsafe extern "C" fn(*mut std::ffi::c_void) -> ()>;
20770 pub type DawnLoadCacheDataFunction = Option<
20771 unsafe extern "C" fn(
20772 *const std::ffi::c_void,
20773 usize,
20774 *mut std::ffi::c_void,
20775 usize,
20776 *mut std::ffi::c_void,
20777 ) -> usize,
20778 >;
20779 pub type DawnStoreCacheDataFunction = Option<
20780 unsafe extern "C" fn(
20781 *const std::ffi::c_void,
20782 usize,
20783 *const std::ffi::c_void,
20784 usize,
20785 *mut std::ffi::c_void,
20786 ) -> (),
20787 >;
20788 pub type Proc = Option<unsafe extern "C" fn() -> ()>;
20789 pub type BufferMapCallback = Box<dyn FnMut(MapAsyncStatus, String) + Send + 'static>;
20790 pub(crate) unsafe extern "C" fn buffer_map_callback_trampoline(
20791 status: ffi::WGPUMapAsyncStatus,
20792 message: ffi::WGPUStringView,
20793 userdata1: *mut std::ffi::c_void,
20794 userdata2: *mut std::ffi::c_void,
20795 ) {
20796 let _ = userdata2;
20797 let status = status.into();
20798 let message = string_view_to_string(message);
20799 let mut callback = unsafe {
20800 Box::from_raw(userdata1.cast::<Option<BufferMapCallback>>())
20801 };
20802 if let Some(mut callback) = callback.take() {
20803 callback(status, message);
20804 }
20805 }
20806 pub type CompilationInfoCallback = Box<
20807 dyn FnMut(CompilationInfoRequestStatus, &CompilationInfo) + Send + 'static,
20808 >;
20809 pub(crate) unsafe extern "C" fn compilation_info_callback_trampoline(
20810 status: ffi::WGPUCompilationInfoRequestStatus,
20811 compilation_info: *const ffi::WGPUCompilationInfo,
20812 userdata1: *mut std::ffi::c_void,
20813 userdata2: *mut std::ffi::c_void,
20814 ) {
20815 let _ = userdata2;
20816 let status = status.into();
20817 let compilation_info = if compilation_info.is_null() {
20818 CompilationInfo::new()
20819 } else {
20820 CompilationInfo::new()
20821 };
20822 let mut callback = unsafe {
20823 Box::from_raw(userdata1.cast::<Option<CompilationInfoCallback>>())
20824 };
20825 if let Some(mut callback) = callback.take() {
20826 callback(status, &compilation_info);
20827 }
20828 }
20829 pub type CreateComputePipelineAsyncCallback = Box<
20830 dyn FnMut(
20831 CreatePipelineAsyncStatus,
20832 Option<ComputePipeline>,
20833 String,
20834 ) + Send + 'static,
20835 >;
20836 pub(crate) unsafe extern "C" fn create_compute_pipeline_async_callback_trampoline(
20837 status: ffi::WGPUCreatePipelineAsyncStatus,
20838 pipeline: ffi::WGPUComputePipeline,
20839 message: ffi::WGPUStringView,
20840 userdata1: *mut std::ffi::c_void,
20841 userdata2: *mut std::ffi::c_void,
20842 ) {
20843 let _ = userdata2;
20844 let status = status.into();
20845 let pipeline = if pipeline.is_null() {
20846 None
20847 } else {
20848 Some(unsafe { ComputePipeline::from_raw(pipeline) })
20849 };
20850 let message = string_view_to_string(message);
20851 let mut callback = unsafe {
20852 Box::from_raw(userdata1.cast::<Option<CreateComputePipelineAsyncCallback>>())
20853 };
20854 if let Some(mut callback) = callback.take() {
20855 callback(status, pipeline, message);
20856 }
20857 }
20858 pub type CreateRenderPipelineAsyncCallback = Box<
20859 dyn FnMut(
20860 CreatePipelineAsyncStatus,
20861 Option<RenderPipeline>,
20862 String,
20863 ) + Send + 'static,
20864 >;
20865 pub(crate) unsafe extern "C" fn create_render_pipeline_async_callback_trampoline(
20866 status: ffi::WGPUCreatePipelineAsyncStatus,
20867 pipeline: ffi::WGPURenderPipeline,
20868 message: ffi::WGPUStringView,
20869 userdata1: *mut std::ffi::c_void,
20870 userdata2: *mut std::ffi::c_void,
20871 ) {
20872 let _ = userdata2;
20873 let status = status.into();
20874 let pipeline = if pipeline.is_null() {
20875 None
20876 } else {
20877 Some(unsafe { RenderPipeline::from_raw(pipeline) })
20878 };
20879 let message = string_view_to_string(message);
20880 let mut callback = unsafe {
20881 Box::from_raw(userdata1.cast::<Option<CreateRenderPipelineAsyncCallback>>())
20882 };
20883 if let Some(mut callback) = callback.take() {
20884 callback(status, pipeline, message);
20885 }
20886 }
20887 pub type DeviceLostCallback = Box<
20888 dyn FnMut(Vec<Device>, DeviceLostReason, String) + Send + 'static,
20889 >;
20890 pub(crate) unsafe extern "C" fn device_lost_callback_trampoline(
20891 device: *const ffi::WGPUDevice,
20892 reason: ffi::WGPUDeviceLostReason,
20893 message: ffi::WGPUStringView,
20894 userdata1: *mut std::ffi::c_void,
20895 userdata2: *mut std::ffi::c_void,
20896 ) {
20897 let _ = userdata2;
20898 let device = if device.is_null() {
20899 Vec::new()
20900 } else {
20901 unsafe { std::slice::from_raw_parts(device, 1) }
20902 .iter()
20903 .map(|raw| unsafe { Device::from_raw(*raw) })
20904 .collect()
20905 };
20906 let reason = reason.into();
20907 let message = string_view_to_string(message);
20908 let mut callback = unsafe {
20909 Box::from_raw(userdata1.cast::<Option<DeviceLostCallback>>())
20910 };
20911 if let Some(mut callback) = callback.take() {
20912 callback(device, reason, message);
20913 }
20914 }
20915 pub type LoggingCallback = Box<dyn FnMut(LoggingType, String) + Send + 'static>;
20916 pub(crate) unsafe extern "C" fn logging_callback_trampoline(
20917 r#type: ffi::WGPULoggingType,
20918 message: ffi::WGPUStringView,
20919 userdata1: *mut std::ffi::c_void,
20920 userdata2: *mut std::ffi::c_void,
20921 ) {
20922 let _ = userdata2;
20923 let r#type = r#type.into();
20924 let message = string_view_to_string(message);
20925 let mut callback = unsafe {
20926 Box::from_raw(userdata1.cast::<Option<LoggingCallback>>())
20927 };
20928 if let Some(mut callback) = callback.take() {
20929 callback(r#type, message);
20930 }
20931 }
20932 pub type PopErrorScopeCallback = Box<
20933 dyn FnMut(PopErrorScopeStatus, ErrorType, String) + Send + 'static,
20934 >;
20935 pub(crate) unsafe extern "C" fn pop_error_scope_callback_trampoline(
20936 status: ffi::WGPUPopErrorScopeStatus,
20937 r#type: ffi::WGPUErrorType,
20938 message: ffi::WGPUStringView,
20939 userdata1: *mut std::ffi::c_void,
20940 userdata2: *mut std::ffi::c_void,
20941 ) {
20942 let _ = userdata2;
20943 let status = status.into();
20944 let r#type = r#type.into();
20945 let message = string_view_to_string(message);
20946 let mut callback = unsafe {
20947 Box::from_raw(userdata1.cast::<Option<PopErrorScopeCallback>>())
20948 };
20949 if let Some(mut callback) = callback.take() {
20950 callback(status, r#type, message);
20951 }
20952 }
20953 pub type QueueWorkDoneCallback = Box<
20954 dyn FnMut(QueueWorkDoneStatus, String) + Send + 'static,
20955 >;
20956 pub(crate) unsafe extern "C" fn queue_work_done_callback_trampoline(
20957 status: ffi::WGPUQueueWorkDoneStatus,
20958 message: ffi::WGPUStringView,
20959 userdata1: *mut std::ffi::c_void,
20960 userdata2: *mut std::ffi::c_void,
20961 ) {
20962 let _ = userdata2;
20963 let status = status.into();
20964 let message = string_view_to_string(message);
20965 let mut callback = unsafe {
20966 Box::from_raw(userdata1.cast::<Option<QueueWorkDoneCallback>>())
20967 };
20968 if let Some(mut callback) = callback.take() {
20969 callback(status, message);
20970 }
20971 }
20972 pub type RequestAdapterCallback = Box<
20973 dyn FnMut(RequestAdapterStatus, Option<Adapter>, String) + Send + 'static,
20974 >;
20975 pub(crate) unsafe extern "C" fn request_adapter_callback_trampoline(
20976 status: ffi::WGPURequestAdapterStatus,
20977 adapter: ffi::WGPUAdapter,
20978 message: ffi::WGPUStringView,
20979 userdata1: *mut std::ffi::c_void,
20980 userdata2: *mut std::ffi::c_void,
20981 ) {
20982 let _ = userdata2;
20983 let status = status.into();
20984 let adapter = if adapter.is_null() {
20985 None
20986 } else {
20987 Some(unsafe { Adapter::from_raw(adapter) })
20988 };
20989 let message = string_view_to_string(message);
20990 let mut callback = unsafe {
20991 Box::from_raw(userdata1.cast::<Option<RequestAdapterCallback>>())
20992 };
20993 if let Some(mut callback) = callback.take() {
20994 callback(status, adapter, message);
20995 }
20996 }
20997 pub type RequestDeviceCallback = Box<
20998 dyn FnMut(RequestDeviceStatus, Option<Device>, String) + Send + 'static,
20999 >;
21000 pub(crate) unsafe extern "C" fn request_device_callback_trampoline(
21001 status: ffi::WGPURequestDeviceStatus,
21002 device: ffi::WGPUDevice,
21003 message: ffi::WGPUStringView,
21004 userdata1: *mut std::ffi::c_void,
21005 userdata2: *mut std::ffi::c_void,
21006 ) {
21007 let _ = userdata2;
21008 let status = status.into();
21009 let device = if device.is_null() {
21010 None
21011 } else {
21012 Some(unsafe { Device::from_raw(device) })
21013 };
21014 let message = string_view_to_string(message);
21015 let mut callback = unsafe {
21016 Box::from_raw(userdata1.cast::<Option<RequestDeviceCallback>>())
21017 };
21018 if let Some(mut callback) = callback.take() {
21019 callback(status, device, message);
21020 }
21021 }
21022 pub type UncapturedErrorCallback = Box<
21023 dyn FnMut(Vec<Device>, ErrorType, String) + Send + 'static,
21024 >;
21025 pub(crate) unsafe extern "C" fn uncaptured_error_callback_trampoline(
21026 device: *const ffi::WGPUDevice,
21027 r#type: ffi::WGPUErrorType,
21028 message: ffi::WGPUStringView,
21029 userdata1: *mut std::ffi::c_void,
21030 userdata2: *mut std::ffi::c_void,
21031 ) {
21032 let _ = userdata2;
21033 let device = if device.is_null() {
21034 Vec::new()
21035 } else {
21036 unsafe { std::slice::from_raw_parts(device, 1) }
21037 .iter()
21038 .map(|raw| unsafe { Device::from_raw(*raw) })
21039 .collect()
21040 };
21041 let r#type = r#type.into();
21042 let message = string_view_to_string(message);
21043 let mut callback = unsafe {
21044 Box::from_raw(userdata1.cast::<Option<UncapturedErrorCallback>>())
21045 };
21046 if let Some(mut callback) = callback.take() {
21047 callback(device, r#type, message);
21048 }
21049 }
21050 pub struct BufferMapCallbackInfo {
21051 pub mode: Option<CallbackMode>,
21052 pub callback: std::cell::RefCell<Option<BufferMapCallback>>,
21053 }
21054 impl Default for BufferMapCallbackInfo {
21055 fn default() -> Self {
21056 Self {
21057 mode: None,
21058 callback: std::cell::RefCell::new(None),
21059 }
21060 }
21061 }
21062 impl BufferMapCallbackInfo {
21063 pub fn new() -> Self {
21064 Self::default()
21065 }
21066 }
21067 pub struct CompilationInfoCallbackInfo {
21068 pub mode: Option<CallbackMode>,
21069 pub callback: std::cell::RefCell<Option<CompilationInfoCallback>>,
21070 }
21071 impl Default for CompilationInfoCallbackInfo {
21072 fn default() -> Self {
21073 Self {
21074 mode: None,
21075 callback: std::cell::RefCell::new(None),
21076 }
21077 }
21078 }
21079 impl CompilationInfoCallbackInfo {
21080 pub fn new() -> Self {
21081 Self::default()
21082 }
21083 }
21084 pub struct CreateComputePipelineAsyncCallbackInfo {
21085 pub mode: Option<CallbackMode>,
21086 pub callback: std::cell::RefCell<Option<CreateComputePipelineAsyncCallback>>,
21087 }
21088 impl Default for CreateComputePipelineAsyncCallbackInfo {
21089 fn default() -> Self {
21090 Self {
21091 mode: None,
21092 callback: std::cell::RefCell::new(None),
21093 }
21094 }
21095 }
21096 impl CreateComputePipelineAsyncCallbackInfo {
21097 pub fn new() -> Self {
21098 Self::default()
21099 }
21100 }
21101 pub struct CreateRenderPipelineAsyncCallbackInfo {
21102 pub mode: Option<CallbackMode>,
21103 pub callback: std::cell::RefCell<Option<CreateRenderPipelineAsyncCallback>>,
21104 }
21105 impl Default for CreateRenderPipelineAsyncCallbackInfo {
21106 fn default() -> Self {
21107 Self {
21108 mode: None,
21109 callback: std::cell::RefCell::new(None),
21110 }
21111 }
21112 }
21113 impl CreateRenderPipelineAsyncCallbackInfo {
21114 pub fn new() -> Self {
21115 Self::default()
21116 }
21117 }
21118 pub struct DeviceLostCallbackInfo {
21119 pub mode: Option<CallbackMode>,
21120 pub callback: std::cell::RefCell<Option<DeviceLostCallback>>,
21121 }
21122 impl Default for DeviceLostCallbackInfo {
21123 fn default() -> Self {
21124 Self {
21125 mode: None,
21126 callback: std::cell::RefCell::new(None),
21127 }
21128 }
21129 }
21130 impl DeviceLostCallbackInfo {
21131 pub fn new() -> Self {
21132 Self::default()
21133 }
21134 }
21135 pub struct LoggingCallbackInfo {
21136 pub callback: std::cell::RefCell<Option<LoggingCallback>>,
21137 }
21138 impl Default for LoggingCallbackInfo {
21139 fn default() -> Self {
21140 Self {
21141 callback: std::cell::RefCell::new(None),
21142 }
21143 }
21144 }
21145 impl LoggingCallbackInfo {
21146 pub fn new() -> Self {
21147 Self::default()
21148 }
21149 }
21150 pub struct PopErrorScopeCallbackInfo {
21151 pub mode: Option<CallbackMode>,
21152 pub callback: std::cell::RefCell<Option<PopErrorScopeCallback>>,
21153 }
21154 impl Default for PopErrorScopeCallbackInfo {
21155 fn default() -> Self {
21156 Self {
21157 mode: None,
21158 callback: std::cell::RefCell::new(None),
21159 }
21160 }
21161 }
21162 impl PopErrorScopeCallbackInfo {
21163 pub fn new() -> Self {
21164 Self::default()
21165 }
21166 }
21167 pub struct QueueWorkDoneCallbackInfo {
21168 pub mode: Option<CallbackMode>,
21169 pub callback: std::cell::RefCell<Option<QueueWorkDoneCallback>>,
21170 }
21171 impl Default for QueueWorkDoneCallbackInfo {
21172 fn default() -> Self {
21173 Self {
21174 mode: None,
21175 callback: std::cell::RefCell::new(None),
21176 }
21177 }
21178 }
21179 impl QueueWorkDoneCallbackInfo {
21180 pub fn new() -> Self {
21181 Self::default()
21182 }
21183 }
21184 pub struct RequestAdapterCallbackInfo {
21185 pub mode: Option<CallbackMode>,
21186 pub callback: std::cell::RefCell<Option<RequestAdapterCallback>>,
21187 }
21188 impl Default for RequestAdapterCallbackInfo {
21189 fn default() -> Self {
21190 Self {
21191 mode: None,
21192 callback: std::cell::RefCell::new(None),
21193 }
21194 }
21195 }
21196 impl RequestAdapterCallbackInfo {
21197 pub fn new() -> Self {
21198 Self::default()
21199 }
21200 }
21201 pub struct RequestDeviceCallbackInfo {
21202 pub mode: Option<CallbackMode>,
21203 pub callback: std::cell::RefCell<Option<RequestDeviceCallback>>,
21204 }
21205 impl Default for RequestDeviceCallbackInfo {
21206 fn default() -> Self {
21207 Self {
21208 mode: None,
21209 callback: std::cell::RefCell::new(None),
21210 }
21211 }
21212 }
21213 impl RequestDeviceCallbackInfo {
21214 pub fn new() -> Self {
21215 Self::default()
21216 }
21217 }
21218 pub struct UncapturedErrorCallbackInfo {
21219 pub callback: std::cell::RefCell<Option<UncapturedErrorCallback>>,
21220 }
21221 impl Default for UncapturedErrorCallbackInfo {
21222 fn default() -> Self {
21223 Self {
21224 callback: std::cell::RefCell::new(None),
21225 }
21226 }
21227 }
21228 impl UncapturedErrorCallbackInfo {
21229 pub fn new() -> Self {
21230 Self::default()
21231 }
21232 }
21233}
21234mod functions {
21235 #![allow(dead_code, unused_imports)]
21236 use crate::generated::*;
21237 use crate::ffi;
21238 pub fn create_instance(descriptor: Option<&InstanceDescriptor>) -> Instance {
21239 let mut descriptor_storage = ChainedStructStorage::new();
21240 let descriptor_ptr = if let Some(value) = &descriptor {
21241 let (descriptor_ffi, storage) = value.to_ffi();
21242 descriptor_storage = storage;
21243 std::ptr::addr_of!(descriptor_ffi)
21244 } else {
21245 std::ptr::null()
21246 };
21247 let result = unsafe { ffi::wgpuCreateInstance(descriptor_ptr) };
21248 unsafe { Instance::from_raw(result) }
21249 }
21250 pub fn get_instance_features(features: &mut SupportedInstanceFeatures) -> () {
21251 let (mut features_ffi, _features_storage) = features.to_ffi();
21252 let features_ptr = std::ptr::addr_of_mut!(features_ffi);
21253 unsafe { ffi::wgpuGetInstanceFeatures(features_ptr) };
21254 *features = SupportedInstanceFeatures::from_ffi(features_ffi);
21255 ()
21256 }
21257 pub fn get_instance_limits(limits: &mut InstanceLimits) -> Status {
21258 let (mut limits_ffi, _limits_storage) = limits.to_ffi();
21259 let limits_ptr = std::ptr::addr_of_mut!(limits_ffi);
21260 let result = unsafe { ffi::wgpuGetInstanceLimits(limits_ptr) };
21261 *limits = InstanceLimits::from_ffi(limits_ffi);
21262 result.into()
21263 }
21264 pub fn get_proc_address(proc_name: String) -> Proc {
21265 let proc_name_ffi = ffi::WGPUStringView {
21266 data: proc_name.as_ptr().cast(),
21267 length: proc_name.len(),
21268 };
21269 let result = unsafe { ffi::wgpuGetProcAddress(proc_name_ffi) };
21270 result
21271 }
21272 pub fn has_instance_feature(feature: InstanceFeatureName) -> bool {
21273 let feature_ffi: ffi::WGPUInstanceFeatureName = feature.into();
21274 let result = unsafe { ffi::wgpuHasInstanceFeature(feature_ffi) };
21275 result != 0
21276 }
21277}
21278mod constants {
21279 #![allow(dead_code, unused_imports)]
21280 use crate::generated::*;
21281 use crate::ffi;
21282 pub const ARRAY_LAYER_COUNT_UNDEFINED: u32 = u32::MAX;
21283 pub const COPY_STRIDE_UNDEFINED: u32 = u32::MAX;
21284 pub const DEPTH_CLEAR_VALUE_UNDEFINED: f32 = f32::NAN;
21285 pub const DEPTH_SLICE_UNDEFINED: u32 = u32::MAX;
21286 pub const INVALID_BINDING: u32 = u32::MAX;
21287 pub const LIMIT_U32_UNDEFINED: u32 = u32::MAX;
21288 pub const LIMIT_U64_UNDEFINED: u64 = u64::MAX;
21289 pub const MIP_LEVEL_COUNT_UNDEFINED: u32 = u32::MAX;
21290 pub const QUERY_SET_INDEX_UNDEFINED: u32 = u32::MAX;
21291 pub const STRLEN: usize = usize::MAX;
21292 pub const WHOLE_MAP_SIZE: usize = usize::MAX;
21293 pub const WHOLE_SIZE: u64 = u64::MAX;
21294}
21295pub use enums::*;
21296pub use structs::*;
21297pub use extensions::*;
21298pub use objects::*;
21299pub use callbacks::*;
21300pub use functions::*;
21301pub use constants::*;