1pub use super::super::Nested;
5pub use std::{borrow::Cow, num::NonZeroU32, ops::Range};
6pub trait Field {}
7pub trait IsOptional {}
8#[doc = "\nBuilder for [`wgpu::ShaderModuleDescriptorPassthrough`]\n \nSet all required fields and any optional fields, then call `build()`.\n\nBuilder field setters:\n - [entry_point](ShaderModuleDescriptorPassthroughBuilder::entry_point) Optional, defaults to `\"\".into()`\n - [num_workgroups](ShaderModuleDescriptorPassthroughBuilder::num_workgroups) Optional, defaults to `(0,0,0)`\n - [runtime_checks](ShaderModuleDescriptorPassthroughBuilder::runtime_checks) Optional, defaults to [wgpu::ShaderRuntimeChecks::unchecked()]\n - [spirv](ShaderModuleDescriptorPassthroughBuilder::spirv) Optional, defaults to `None`\n - [dxil](ShaderModuleDescriptorPassthroughBuilder::dxil) Optional, defaults to `None`\n - [msl](ShaderModuleDescriptorPassthroughBuilder::msl) Optional, defaults to `None`\n - [hlsl](ShaderModuleDescriptorPassthroughBuilder::hlsl) Optional, defaults to `None`\n - [glsl](ShaderModuleDescriptorPassthroughBuilder::glsl) Optional, defaults to `None`\n - [wgsl](ShaderModuleDescriptorPassthroughBuilder::wgsl) Optional, defaults to `None`\n"]
9pub struct ShaderModuleDescriptorPassthroughBuilder<'a, CS: State<'a>> {
10 entry_point: CS::EntryPoint,
11 label: CS::Label,
12 num_workgroups: CS::NumWorkgroups,
13 runtime_checks: CS::RuntimeChecks,
14 spirv: CS::Spirv,
15 dxil: CS::Dxil,
16 msl: CS::Msl,
17 hlsl: CS::Hlsl,
18 glsl: CS::Glsl,
19 wgsl: CS::Wgsl,
20}
21impl<'a> ShaderModuleDescriptorPassthroughBuilder<'a, Empty> {
22 pub fn new() -> ShaderModuleDescriptorPassthroughBuilder<'a, Empty> {
23 ShaderModuleDescriptorPassthroughBuilder {
24 entry_point: EntryPointEmpty,
25 label: LabelEmpty,
26 num_workgroups: NumWorkgroupsEmpty,
27 runtime_checks: RuntimeChecksEmpty,
28 spirv: SpirvEmpty,
29 dxil: DxilEmpty,
30 msl: MslEmpty,
31 hlsl: HlslEmpty,
32 glsl: GlslEmpty,
33 wgsl: WgslEmpty,
34 }
35 }
36}
37#[doc = "\nReturns [ShaderModuleDescriptorPassthroughBuilder] for building [`wgpu::ShaderModuleDescriptorPassthrough`]\n \nSet all required fields and any optional fields, then call `build()`.\n\nBuilder field setters:\n - [entry_point](ShaderModuleDescriptorPassthroughBuilder::entry_point) Optional, defaults to `\"\".into()`\n - [num_workgroups](ShaderModuleDescriptorPassthroughBuilder::num_workgroups) Optional, defaults to `(0,0,0)`\n - [runtime_checks](ShaderModuleDescriptorPassthroughBuilder::runtime_checks) Optional, defaults to [wgpu::ShaderRuntimeChecks::unchecked()]\n - [spirv](ShaderModuleDescriptorPassthroughBuilder::spirv) Optional, defaults to `None`\n - [dxil](ShaderModuleDescriptorPassthroughBuilder::dxil) Optional, defaults to `None`\n - [msl](ShaderModuleDescriptorPassthroughBuilder::msl) Optional, defaults to `None`\n - [hlsl](ShaderModuleDescriptorPassthroughBuilder::hlsl) Optional, defaults to `None`\n - [glsl](ShaderModuleDescriptorPassthroughBuilder::glsl) Optional, defaults to `None`\n - [wgsl](ShaderModuleDescriptorPassthroughBuilder::wgsl) Optional, defaults to `None`\n"]
38pub fn shader_module_descriptor_passthrough<'a>(
39 label: wgpu::Label<'a>,
40) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetLabel<Empty>> {
41 ShaderModuleDescriptorPassthroughBuilder::new().label(label)
42}
43pub struct EntryPointEmpty;
44impl Field for EntryPointEmpty {}
45pub trait EntryPointIsEmpty {}
46impl EntryPointIsEmpty for EntryPointEmpty {}
47pub trait IsSetEntryPoint {
48 fn get(self) -> String;
49}
50impl IsSetEntryPoint for EntryPointEmpty {
51 fn get(self) -> String {
52 "".into()
53 }
54}
55pub struct EntryPointValue(pub String);
56impl Field for EntryPointValue {}
57impl IsSetEntryPoint for EntryPointValue {
58 fn get(self) -> String {
59 self.0
60 }
61}
62pub struct LabelEmpty;
63impl Field for LabelEmpty {}
64pub trait LabelIsEmpty {}
65impl LabelIsEmpty for LabelEmpty {}
66pub trait IsSetLabel<'a> {
67 fn get(self) -> wgpu::Label<'a>;
68}
69impl<'a> IsSetLabel<'a> for LabelEmpty {
70 fn get(self) -> wgpu::Label<'a> {
71 None
72 }
73}
74pub struct LabelValue<'a>(pub wgpu::Label<'a>);
75impl<'a> Field for LabelValue<'a> {}
76impl<'a> IsSetLabel<'a> for LabelValue<'a> {
77 fn get(self) -> wgpu::Label<'a> {
78 self.0
79 }
80}
81pub struct NumWorkgroupsEmpty;
82impl Field for NumWorkgroupsEmpty {}
83pub trait NumWorkgroupsIsEmpty {}
84impl NumWorkgroupsIsEmpty for NumWorkgroupsEmpty {}
85pub trait IsSetNumWorkgroups {
86 fn get(self) -> (u32, u32, u32);
87}
88impl IsSetNumWorkgroups for NumWorkgroupsEmpty {
89 fn get(self) -> (u32, u32, u32) {
90 (0, 0, 0)
91 }
92}
93pub struct NumWorkgroupsValue(pub (u32, u32, u32));
94impl Field for NumWorkgroupsValue {}
95impl IsSetNumWorkgroups for NumWorkgroupsValue {
96 fn get(self) -> (u32, u32, u32) {
97 self.0
98 }
99}
100pub struct RuntimeChecksEmpty;
101impl Field for RuntimeChecksEmpty {}
102pub trait RuntimeChecksIsEmpty {}
103impl RuntimeChecksIsEmpty for RuntimeChecksEmpty {}
104pub trait IsSetRuntimeChecks {
105 fn get(self) -> wgpu::ShaderRuntimeChecks;
106}
107impl IsSetRuntimeChecks for RuntimeChecksEmpty {
108 fn get(self) -> wgpu::ShaderRuntimeChecks {
109 wgpu::ShaderRuntimeChecks::unchecked()
110 }
111}
112pub struct RuntimeChecksValue(pub wgpu::ShaderRuntimeChecks);
113impl Field for RuntimeChecksValue {}
114impl IsSetRuntimeChecks for RuntimeChecksValue {
115 fn get(self) -> wgpu::ShaderRuntimeChecks {
116 self.0
117 }
118}
119pub struct SpirvEmpty;
120impl Field for SpirvEmpty {}
121pub trait SpirvIsEmpty {}
122impl SpirvIsEmpty for SpirvEmpty {}
123pub trait IsSetSpirv<'a> {
124 fn get(self) -> Option<Cow<'a, [u32]>>;
125}
126impl<'a> IsSetSpirv<'a> for SpirvEmpty {
127 fn get(self) -> Option<Cow<'a, [u32]>> {
128 None
129 }
130}
131pub struct SpirvValue<'a>(pub Option<Cow<'a, [u32]>>);
132impl<'a> Field for SpirvValue<'a> {}
133impl<'a> IsSetSpirv<'a> for SpirvValue<'a> {
134 fn get(self) -> Option<Cow<'a, [u32]>> {
135 self.0
136 }
137}
138pub struct DxilEmpty;
139impl Field for DxilEmpty {}
140pub trait DxilIsEmpty {}
141impl DxilIsEmpty for DxilEmpty {}
142pub trait IsSetDxil<'a> {
143 fn get(self) -> Option<Cow<'a, [u8]>>;
144}
145impl<'a> IsSetDxil<'a> for DxilEmpty {
146 fn get(self) -> Option<Cow<'a, [u8]>> {
147 None
148 }
149}
150pub struct DxilValue<'a>(pub Option<Cow<'a, [u8]>>);
151impl<'a> Field for DxilValue<'a> {}
152impl<'a> IsSetDxil<'a> for DxilValue<'a> {
153 fn get(self) -> Option<Cow<'a, [u8]>> {
154 self.0
155 }
156}
157pub struct MslEmpty;
158impl Field for MslEmpty {}
159pub trait MslIsEmpty {}
160impl MslIsEmpty for MslEmpty {}
161pub trait IsSetMsl<'a> {
162 fn get(self) -> Option<Cow<'a, str>>;
163}
164impl<'a> IsSetMsl<'a> for MslEmpty {
165 fn get(self) -> Option<Cow<'a, str>> {
166 None
167 }
168}
169pub struct MslValue<'a>(pub Option<Cow<'a, str>>);
170impl<'a> Field for MslValue<'a> {}
171impl<'a> IsSetMsl<'a> for MslValue<'a> {
172 fn get(self) -> Option<Cow<'a, str>> {
173 self.0
174 }
175}
176pub struct HlslEmpty;
177impl Field for HlslEmpty {}
178pub trait HlslIsEmpty {}
179impl HlslIsEmpty for HlslEmpty {}
180pub trait IsSetHlsl<'a> {
181 fn get(self) -> Option<Cow<'a, str>>;
182}
183impl<'a> IsSetHlsl<'a> for HlslEmpty {
184 fn get(self) -> Option<Cow<'a, str>> {
185 None
186 }
187}
188pub struct HlslValue<'a>(pub Option<Cow<'a, str>>);
189impl<'a> Field for HlslValue<'a> {}
190impl<'a> IsSetHlsl<'a> for HlslValue<'a> {
191 fn get(self) -> Option<Cow<'a, str>> {
192 self.0
193 }
194}
195pub struct GlslEmpty;
196impl Field for GlslEmpty {}
197pub trait GlslIsEmpty {}
198impl GlslIsEmpty for GlslEmpty {}
199pub trait IsSetGlsl<'a> {
200 fn get(self) -> Option<Cow<'a, str>>;
201}
202impl<'a> IsSetGlsl<'a> for GlslEmpty {
203 fn get(self) -> Option<Cow<'a, str>> {
204 None
205 }
206}
207pub struct GlslValue<'a>(pub Option<Cow<'a, str>>);
208impl<'a> Field for GlslValue<'a> {}
209impl<'a> IsSetGlsl<'a> for GlslValue<'a> {
210 fn get(self) -> Option<Cow<'a, str>> {
211 self.0
212 }
213}
214pub struct WgslEmpty;
215impl Field for WgslEmpty {}
216pub trait WgslIsEmpty {}
217impl WgslIsEmpty for WgslEmpty {}
218pub trait IsSetWgsl<'a> {
219 fn get(self) -> Option<Cow<'a, str>>;
220}
221impl<'a> IsSetWgsl<'a> for WgslEmpty {
222 fn get(self) -> Option<Cow<'a, str>> {
223 None
224 }
225}
226pub struct WgslValue<'a>(pub Option<Cow<'a, str>>);
227impl<'a> Field for WgslValue<'a> {}
228impl<'a> IsSetWgsl<'a> for WgslValue<'a> {
229 fn get(self) -> Option<Cow<'a, str>> {
230 self.0
231 }
232}
233pub trait State<'a> {
234 type EntryPoint: Field;
235 type Label: Field;
236 type NumWorkgroups: Field;
237 type RuntimeChecks: Field;
238 type Spirv: Field;
239 type Dxil: Field;
240 type Msl: Field;
241 type Hlsl: Field;
242 type Glsl: Field;
243 type Wgsl: Field;
244}
245pub struct Empty;
246impl<'a> State<'a> for Empty {
247 type EntryPoint = EntryPointEmpty;
248 type Label = LabelEmpty;
249 type NumWorkgroups = NumWorkgroupsEmpty;
250 type RuntimeChecks = RuntimeChecksEmpty;
251 type Spirv = SpirvEmpty;
252 type Dxil = DxilEmpty;
253 type Msl = MslEmpty;
254 type Hlsl = HlslEmpty;
255 type Glsl = GlslEmpty;
256 type Wgsl = WgslEmpty;
257}
258pub struct SetEntryPoint<CS>(CS);
259impl<'a, CS: State<'a>> State<'a> for SetEntryPoint<CS> {
260 type EntryPoint = EntryPointValue;
261 type Label = CS::Label;
262 type NumWorkgroups = CS::NumWorkgroups;
263 type RuntimeChecks = CS::RuntimeChecks;
264 type Spirv = CS::Spirv;
265 type Dxil = CS::Dxil;
266 type Msl = CS::Msl;
267 type Hlsl = CS::Hlsl;
268 type Glsl = CS::Glsl;
269 type Wgsl = CS::Wgsl;
270}
271pub struct SetLabel<CS>(CS);
272impl<'a, CS: State<'a>> State<'a> for SetLabel<CS> {
273 type EntryPoint = CS::EntryPoint;
274 type Label = LabelValue<'a>;
275 type NumWorkgroups = CS::NumWorkgroups;
276 type RuntimeChecks = CS::RuntimeChecks;
277 type Spirv = CS::Spirv;
278 type Dxil = CS::Dxil;
279 type Msl = CS::Msl;
280 type Hlsl = CS::Hlsl;
281 type Glsl = CS::Glsl;
282 type Wgsl = CS::Wgsl;
283}
284pub struct SetNumWorkgroups<CS>(CS);
285impl<'a, CS: State<'a>> State<'a> for SetNumWorkgroups<CS> {
286 type EntryPoint = CS::EntryPoint;
287 type Label = CS::Label;
288 type NumWorkgroups = NumWorkgroupsValue;
289 type RuntimeChecks = CS::RuntimeChecks;
290 type Spirv = CS::Spirv;
291 type Dxil = CS::Dxil;
292 type Msl = CS::Msl;
293 type Hlsl = CS::Hlsl;
294 type Glsl = CS::Glsl;
295 type Wgsl = CS::Wgsl;
296}
297pub struct SetRuntimeChecks<CS>(CS);
298impl<'a, CS: State<'a>> State<'a> for SetRuntimeChecks<CS> {
299 type EntryPoint = CS::EntryPoint;
300 type Label = CS::Label;
301 type NumWorkgroups = CS::NumWorkgroups;
302 type RuntimeChecks = RuntimeChecksValue;
303 type Spirv = CS::Spirv;
304 type Dxil = CS::Dxil;
305 type Msl = CS::Msl;
306 type Hlsl = CS::Hlsl;
307 type Glsl = CS::Glsl;
308 type Wgsl = CS::Wgsl;
309}
310pub struct SetSpirv<CS>(CS);
311impl<'a, CS: State<'a>> State<'a> for SetSpirv<CS> {
312 type EntryPoint = CS::EntryPoint;
313 type Label = CS::Label;
314 type NumWorkgroups = CS::NumWorkgroups;
315 type RuntimeChecks = CS::RuntimeChecks;
316 type Spirv = SpirvValue<'a>;
317 type Dxil = CS::Dxil;
318 type Msl = CS::Msl;
319 type Hlsl = CS::Hlsl;
320 type Glsl = CS::Glsl;
321 type Wgsl = CS::Wgsl;
322}
323pub struct SetDxil<CS>(CS);
324impl<'a, CS: State<'a>> State<'a> for SetDxil<CS> {
325 type EntryPoint = CS::EntryPoint;
326 type Label = CS::Label;
327 type NumWorkgroups = CS::NumWorkgroups;
328 type RuntimeChecks = CS::RuntimeChecks;
329 type Spirv = CS::Spirv;
330 type Dxil = DxilValue<'a>;
331 type Msl = CS::Msl;
332 type Hlsl = CS::Hlsl;
333 type Glsl = CS::Glsl;
334 type Wgsl = CS::Wgsl;
335}
336pub struct SetMsl<CS>(CS);
337impl<'a, CS: State<'a>> State<'a> for SetMsl<CS> {
338 type EntryPoint = CS::EntryPoint;
339 type Label = CS::Label;
340 type NumWorkgroups = CS::NumWorkgroups;
341 type RuntimeChecks = CS::RuntimeChecks;
342 type Spirv = CS::Spirv;
343 type Dxil = CS::Dxil;
344 type Msl = MslValue<'a>;
345 type Hlsl = CS::Hlsl;
346 type Glsl = CS::Glsl;
347 type Wgsl = CS::Wgsl;
348}
349pub struct SetHlsl<CS>(CS);
350impl<'a, CS: State<'a>> State<'a> for SetHlsl<CS> {
351 type EntryPoint = CS::EntryPoint;
352 type Label = CS::Label;
353 type NumWorkgroups = CS::NumWorkgroups;
354 type RuntimeChecks = CS::RuntimeChecks;
355 type Spirv = CS::Spirv;
356 type Dxil = CS::Dxil;
357 type Msl = CS::Msl;
358 type Hlsl = HlslValue<'a>;
359 type Glsl = CS::Glsl;
360 type Wgsl = CS::Wgsl;
361}
362pub struct SetGlsl<CS>(CS);
363impl<'a, CS: State<'a>> State<'a> for SetGlsl<CS> {
364 type EntryPoint = CS::EntryPoint;
365 type Label = CS::Label;
366 type NumWorkgroups = CS::NumWorkgroups;
367 type RuntimeChecks = CS::RuntimeChecks;
368 type Spirv = CS::Spirv;
369 type Dxil = CS::Dxil;
370 type Msl = CS::Msl;
371 type Hlsl = CS::Hlsl;
372 type Glsl = GlslValue<'a>;
373 type Wgsl = CS::Wgsl;
374}
375pub struct SetWgsl<CS>(CS);
376impl<'a, CS: State<'a>> State<'a> for SetWgsl<CS> {
377 type EntryPoint = CS::EntryPoint;
378 type Label = CS::Label;
379 type NumWorkgroups = CS::NumWorkgroups;
380 type RuntimeChecks = CS::RuntimeChecks;
381 type Spirv = CS::Spirv;
382 type Dxil = CS::Dxil;
383 type Msl = CS::Msl;
384 type Hlsl = CS::Hlsl;
385 type Glsl = CS::Glsl;
386 type Wgsl = WgslValue<'a>;
387}
388impl<'a, CS: State<'a>> ShaderModuleDescriptorPassthroughBuilder<'a, CS> {
389 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::entry_point]. Optional, defaults to `\"\".into()`.\n"]
390 pub fn entry_point(
391 self,
392 entry_point: String,
393 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetEntryPoint<CS>>
394 where
395 CS::EntryPoint: EntryPointIsEmpty,
396 {
397 ShaderModuleDescriptorPassthroughBuilder {
398 entry_point: EntryPointValue(entry_point),
399 label: self.label,
400 num_workgroups: self.num_workgroups,
401 runtime_checks: self.runtime_checks,
402 spirv: self.spirv,
403 dxil: self.dxil,
404 msl: self.msl,
405 hlsl: self.hlsl,
406 glsl: self.glsl,
407 wgsl: self.wgsl,
408 }
409 }
410 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::label]. Optional, defaults to `None`.\n"]
411 pub fn label(
412 self,
413 label: wgpu::Label<'a>,
414 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetLabel<CS>>
415 where
416 CS::Label: LabelIsEmpty,
417 {
418 ShaderModuleDescriptorPassthroughBuilder {
419 entry_point: self.entry_point,
420 label: LabelValue(label),
421 num_workgroups: self.num_workgroups,
422 runtime_checks: self.runtime_checks,
423 spirv: self.spirv,
424 dxil: self.dxil,
425 msl: self.msl,
426 hlsl: self.hlsl,
427 glsl: self.glsl,
428 wgsl: self.wgsl,
429 }
430 }
431 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::num_workgroups]. Optional, defaults to `(0,0,0)`.\n"]
432 pub fn num_workgroups(
433 self,
434 num_workgroups: (u32, u32, u32),
435 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetNumWorkgroups<CS>>
436 where
437 CS::NumWorkgroups: NumWorkgroupsIsEmpty,
438 {
439 ShaderModuleDescriptorPassthroughBuilder {
440 entry_point: self.entry_point,
441 label: self.label,
442 num_workgroups: NumWorkgroupsValue(num_workgroups),
443 runtime_checks: self.runtime_checks,
444 spirv: self.spirv,
445 dxil: self.dxil,
446 msl: self.msl,
447 hlsl: self.hlsl,
448 glsl: self.glsl,
449 wgsl: self.wgsl,
450 }
451 }
452 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::runtime_checks]. Optional, defaults to [wgpu::ShaderRuntimeChecks::unchecked()].\n"]
453 pub fn runtime_checks(
454 self,
455 runtime_checks: impl Nested<wgpu::ShaderRuntimeChecks>,
456 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetRuntimeChecks<CS>>
457 where
458 CS::RuntimeChecks: RuntimeChecksIsEmpty,
459 {
460 ShaderModuleDescriptorPassthroughBuilder {
461 entry_point: self.entry_point,
462 label: self.label,
463 num_workgroups: self.num_workgroups,
464 runtime_checks: RuntimeChecksValue(Nested::unnest(runtime_checks)),
465 spirv: self.spirv,
466 dxil: self.dxil,
467 msl: self.msl,
468 hlsl: self.hlsl,
469 glsl: self.glsl,
470 wgsl: self.wgsl,
471 }
472 }
473 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::spirv]. Optional, defaults to `None`.\n"]
474 pub fn spirv(
475 self,
476 spirv: Cow<'a, [u32]>,
477 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetSpirv<CS>>
478 where
479 CS::Spirv: SpirvIsEmpty,
480 {
481 ShaderModuleDescriptorPassthroughBuilder {
482 entry_point: self.entry_point,
483 label: self.label,
484 num_workgroups: self.num_workgroups,
485 runtime_checks: self.runtime_checks,
486 spirv: SpirvValue(Some(spirv)),
487 dxil: self.dxil,
488 msl: self.msl,
489 hlsl: self.hlsl,
490 glsl: self.glsl,
491 wgsl: self.wgsl,
492 }
493 }
494 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::spirv]. Optional, defaults to `None`.\n"]
495 pub fn maybe_spirv(
496 self,
497 spirv: Option<Cow<'a, [u32]>>,
498 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetSpirv<CS>>
499 where
500 CS::Spirv: SpirvIsEmpty,
501 {
502 ShaderModuleDescriptorPassthroughBuilder {
503 entry_point: self.entry_point,
504 label: self.label,
505 num_workgroups: self.num_workgroups,
506 runtime_checks: self.runtime_checks,
507 spirv: SpirvValue(spirv),
508 dxil: self.dxil,
509 msl: self.msl,
510 hlsl: self.hlsl,
511 glsl: self.glsl,
512 wgsl: self.wgsl,
513 }
514 }
515 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::dxil]. Optional, defaults to `None`.\n"]
516 pub fn dxil(
517 self,
518 dxil: Cow<'a, [u8]>,
519 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetDxil<CS>>
520 where
521 CS::Dxil: DxilIsEmpty,
522 {
523 ShaderModuleDescriptorPassthroughBuilder {
524 entry_point: self.entry_point,
525 label: self.label,
526 num_workgroups: self.num_workgroups,
527 runtime_checks: self.runtime_checks,
528 spirv: self.spirv,
529 dxil: DxilValue(Some(dxil)),
530 msl: self.msl,
531 hlsl: self.hlsl,
532 glsl: self.glsl,
533 wgsl: self.wgsl,
534 }
535 }
536 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::dxil]. Optional, defaults to `None`.\n"]
537 pub fn maybe_dxil(
538 self,
539 dxil: Option<Cow<'a, [u8]>>,
540 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetDxil<CS>>
541 where
542 CS::Dxil: DxilIsEmpty,
543 {
544 ShaderModuleDescriptorPassthroughBuilder {
545 entry_point: self.entry_point,
546 label: self.label,
547 num_workgroups: self.num_workgroups,
548 runtime_checks: self.runtime_checks,
549 spirv: self.spirv,
550 dxil: DxilValue(dxil),
551 msl: self.msl,
552 hlsl: self.hlsl,
553 glsl: self.glsl,
554 wgsl: self.wgsl,
555 }
556 }
557 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::msl]. Optional, defaults to `None`.\n"]
558 pub fn msl(self, msl: Cow<'a, str>) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetMsl<CS>>
559 where
560 CS::Msl: MslIsEmpty,
561 {
562 ShaderModuleDescriptorPassthroughBuilder {
563 entry_point: self.entry_point,
564 label: self.label,
565 num_workgroups: self.num_workgroups,
566 runtime_checks: self.runtime_checks,
567 spirv: self.spirv,
568 dxil: self.dxil,
569 msl: MslValue(Some(msl)),
570 hlsl: self.hlsl,
571 glsl: self.glsl,
572 wgsl: self.wgsl,
573 }
574 }
575 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::msl]. Optional, defaults to `None`.\n"]
576 pub fn maybe_msl(
577 self,
578 msl: Option<Cow<'a, str>>,
579 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetMsl<CS>>
580 where
581 CS::Msl: MslIsEmpty,
582 {
583 ShaderModuleDescriptorPassthroughBuilder {
584 entry_point: self.entry_point,
585 label: self.label,
586 num_workgroups: self.num_workgroups,
587 runtime_checks: self.runtime_checks,
588 spirv: self.spirv,
589 dxil: self.dxil,
590 msl: MslValue(msl),
591 hlsl: self.hlsl,
592 glsl: self.glsl,
593 wgsl: self.wgsl,
594 }
595 }
596 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::hlsl]. Optional, defaults to `None`.\n"]
597 pub fn hlsl(
598 self,
599 hlsl: Cow<'a, str>,
600 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetHlsl<CS>>
601 where
602 CS::Hlsl: HlslIsEmpty,
603 {
604 ShaderModuleDescriptorPassthroughBuilder {
605 entry_point: self.entry_point,
606 label: self.label,
607 num_workgroups: self.num_workgroups,
608 runtime_checks: self.runtime_checks,
609 spirv: self.spirv,
610 dxil: self.dxil,
611 msl: self.msl,
612 hlsl: HlslValue(Some(hlsl)),
613 glsl: self.glsl,
614 wgsl: self.wgsl,
615 }
616 }
617 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::hlsl]. Optional, defaults to `None`.\n"]
618 pub fn maybe_hlsl(
619 self,
620 hlsl: Option<Cow<'a, str>>,
621 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetHlsl<CS>>
622 where
623 CS::Hlsl: HlslIsEmpty,
624 {
625 ShaderModuleDescriptorPassthroughBuilder {
626 entry_point: self.entry_point,
627 label: self.label,
628 num_workgroups: self.num_workgroups,
629 runtime_checks: self.runtime_checks,
630 spirv: self.spirv,
631 dxil: self.dxil,
632 msl: self.msl,
633 hlsl: HlslValue(hlsl),
634 glsl: self.glsl,
635 wgsl: self.wgsl,
636 }
637 }
638 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::glsl]. Optional, defaults to `None`.\n"]
639 pub fn glsl(
640 self,
641 glsl: Cow<'a, str>,
642 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetGlsl<CS>>
643 where
644 CS::Glsl: GlslIsEmpty,
645 {
646 ShaderModuleDescriptorPassthroughBuilder {
647 entry_point: self.entry_point,
648 label: self.label,
649 num_workgroups: self.num_workgroups,
650 runtime_checks: self.runtime_checks,
651 spirv: self.spirv,
652 dxil: self.dxil,
653 msl: self.msl,
654 hlsl: self.hlsl,
655 glsl: GlslValue(Some(glsl)),
656 wgsl: self.wgsl,
657 }
658 }
659 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::glsl]. Optional, defaults to `None`.\n"]
660 pub fn maybe_glsl(
661 self,
662 glsl: Option<Cow<'a, str>>,
663 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetGlsl<CS>>
664 where
665 CS::Glsl: GlslIsEmpty,
666 {
667 ShaderModuleDescriptorPassthroughBuilder {
668 entry_point: self.entry_point,
669 label: self.label,
670 num_workgroups: self.num_workgroups,
671 runtime_checks: self.runtime_checks,
672 spirv: self.spirv,
673 dxil: self.dxil,
674 msl: self.msl,
675 hlsl: self.hlsl,
676 glsl: GlslValue(glsl),
677 wgsl: self.wgsl,
678 }
679 }
680 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::wgsl]. Optional, defaults to `None`.\n"]
681 pub fn wgsl(
682 self,
683 wgsl: Cow<'a, str>,
684 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetWgsl<CS>>
685 where
686 CS::Wgsl: WgslIsEmpty,
687 {
688 ShaderModuleDescriptorPassthroughBuilder {
689 entry_point: self.entry_point,
690 label: self.label,
691 num_workgroups: self.num_workgroups,
692 runtime_checks: self.runtime_checks,
693 spirv: self.spirv,
694 dxil: self.dxil,
695 msl: self.msl,
696 hlsl: self.hlsl,
697 glsl: self.glsl,
698 wgsl: WgslValue(Some(wgsl)),
699 }
700 }
701 #[doc = "Setter for [wgpu::ShaderModuleDescriptorPassthrough::wgsl]. Optional, defaults to `None`.\n"]
702 pub fn maybe_wgsl(
703 self,
704 wgsl: Option<Cow<'a, str>>,
705 ) -> ShaderModuleDescriptorPassthroughBuilder<'a, SetWgsl<CS>>
706 where
707 CS::Wgsl: WgslIsEmpty,
708 {
709 ShaderModuleDescriptorPassthroughBuilder {
710 entry_point: self.entry_point,
711 label: self.label,
712 num_workgroups: self.num_workgroups,
713 runtime_checks: self.runtime_checks,
714 spirv: self.spirv,
715 dxil: self.dxil,
716 msl: self.msl,
717 hlsl: self.hlsl,
718 glsl: self.glsl,
719 wgsl: WgslValue(wgsl),
720 }
721 }
722}
723pub trait Complete<'a>:
724 State<
725 'a,
726 EntryPoint: IsSetEntryPoint,
727 Label: IsSetLabel<'a>,
728 NumWorkgroups: IsSetNumWorkgroups,
729 RuntimeChecks: IsSetRuntimeChecks,
730 Spirv: IsSetSpirv<'a>,
731 Dxil: IsSetDxil<'a>,
732 Msl: IsSetMsl<'a>,
733 Hlsl: IsSetHlsl<'a>,
734 Glsl: IsSetGlsl<'a>,
735 Wgsl: IsSetWgsl<'a>,
736>
737{
738}
739impl<
740 'a,
741 CS: State<
742 'a,
743 EntryPoint: IsSetEntryPoint,
744 Label: IsSetLabel<'a>,
745 NumWorkgroups: IsSetNumWorkgroups,
746 RuntimeChecks: IsSetRuntimeChecks,
747 Spirv: IsSetSpirv<'a>,
748 Dxil: IsSetDxil<'a>,
749 Msl: IsSetMsl<'a>,
750 Hlsl: IsSetHlsl<'a>,
751 Glsl: IsSetGlsl<'a>,
752 Wgsl: IsSetWgsl<'a>,
753 >,
754 > Complete<'a> for CS
755{
756}
757impl<'a, CS: Complete<'a>> ShaderModuleDescriptorPassthroughBuilder<'a, CS> {
758 pub fn build(self) -> wgpu::ShaderModuleDescriptorPassthrough<'a> {
759 wgpu::ShaderModuleDescriptorPassthrough {
760 entry_point: IsSetEntryPoint::get(self.entry_point),
761 label: IsSetLabel::get(self.label),
762 num_workgroups: IsSetNumWorkgroups::get(self.num_workgroups),
763 runtime_checks: IsSetRuntimeChecks::get(self.runtime_checks),
764 spirv: IsSetSpirv::get(self.spirv),
765 dxil: IsSetDxil::get(self.dxil),
766 msl: IsSetMsl::get(self.msl),
767 hlsl: IsSetHlsl::get(self.hlsl),
768 glsl: IsSetGlsl::get(self.glsl),
769 wgsl: IsSetWgsl::get(self.wgsl),
770 }
771 }
772}
773#[cfg(test)]
774mod tests {
775 #[allow(unused_imports)]
776 #[allow(unused_imports)]
777 use std::num::NonZeroU32;
778 #[test]
779 pub fn test_default() {
780 assert_eq!(
781 format!(
782 "{:#?}",
783 super::shader_module_descriptor_passthrough(Option::<&str>::None).build()
784 ),
785 format!("{:#?}", wgpu::ShaderModuleDescriptorPassthrough::default()),
786 );
787 }
788}