quickgpu/builders/
render_bundle_depth_stencil_builder.rs1pub use super::super::Nested;
5pub use std::{borrow::Cow, num::NonZeroU32, ops::Range};
6pub trait Field {}
7pub trait IsOptional {}
8#[doc = "\nBuilder for [`wgpu::RenderBundleDepthStencil`]\n \nSet all required fields and any optional fields, then call `build()`.\n\nBuilder field setters:\n - [format](RenderBundleDepthStencilBuilder::format) Required\n - [depth_read_only](RenderBundleDepthStencilBuilder::depth_read_only) Required\n - [stencil_read_only](RenderBundleDepthStencilBuilder::stencil_read_only) Required\n"]
9pub struct RenderBundleDepthStencilBuilder<CS: State> {
10 format: CS::Format,
11 depth_read_only: CS::DepthReadOnly,
12 stencil_read_only: CS::StencilReadOnly,
13}
14impl RenderBundleDepthStencilBuilder<Empty> {
15 pub fn new() -> RenderBundleDepthStencilBuilder<Empty> {
16 RenderBundleDepthStencilBuilder {
17 format: FormatEmpty,
18 depth_read_only: DepthReadOnlyEmpty,
19 stencil_read_only: StencilReadOnlyEmpty,
20 }
21 }
22}
23#[doc = "\nReturns [RenderBundleDepthStencilBuilder] for building [`wgpu::RenderBundleDepthStencil`]\n \nSet all required fields and any optional fields, then call `build()`.\n\nBuilder field setters:\n - [format](RenderBundleDepthStencilBuilder::format) Required\n - [depth_read_only](RenderBundleDepthStencilBuilder::depth_read_only) Required\n - [stencil_read_only](RenderBundleDepthStencilBuilder::stencil_read_only) Required\n"]
24pub fn render_bundle_depth_stencil() -> RenderBundleDepthStencilBuilder<Empty> {
25 RenderBundleDepthStencilBuilder::new()
26}
27pub struct FormatEmpty;
28impl Field for FormatEmpty {}
29pub trait FormatIsEmpty {}
30impl FormatIsEmpty for FormatEmpty {}
31pub trait IsSetFormat {
32 fn get(self) -> wgpu::TextureFormat;
33}
34pub struct FormatValue(pub wgpu::TextureFormat);
35impl Field for FormatValue {}
36impl IsSetFormat for FormatValue {
37 fn get(self) -> wgpu::TextureFormat {
38 self.0
39 }
40}
41pub struct DepthReadOnlyEmpty;
42impl Field for DepthReadOnlyEmpty {}
43pub trait DepthReadOnlyIsEmpty {}
44impl DepthReadOnlyIsEmpty for DepthReadOnlyEmpty {}
45pub trait IsSetDepthReadOnly {
46 fn get(self) -> bool;
47}
48pub struct DepthReadOnlyValue(pub bool);
49impl Field for DepthReadOnlyValue {}
50impl IsSetDepthReadOnly for DepthReadOnlyValue {
51 fn get(self) -> bool {
52 self.0
53 }
54}
55pub struct StencilReadOnlyEmpty;
56impl Field for StencilReadOnlyEmpty {}
57pub trait StencilReadOnlyIsEmpty {}
58impl StencilReadOnlyIsEmpty for StencilReadOnlyEmpty {}
59pub trait IsSetStencilReadOnly {
60 fn get(self) -> bool;
61}
62pub struct StencilReadOnlyValue(pub bool);
63impl Field for StencilReadOnlyValue {}
64impl IsSetStencilReadOnly for StencilReadOnlyValue {
65 fn get(self) -> bool {
66 self.0
67 }
68}
69pub trait State {
70 type Format: Field;
71 type DepthReadOnly: Field;
72 type StencilReadOnly: Field;
73}
74pub struct Empty;
75impl State for Empty {
76 type Format = FormatEmpty;
77 type DepthReadOnly = DepthReadOnlyEmpty;
78 type StencilReadOnly = StencilReadOnlyEmpty;
79}
80pub struct SetFormat<CS>(CS);
81impl<CS: State> State for SetFormat<CS> {
82 type Format = FormatValue;
83 type DepthReadOnly = CS::DepthReadOnly;
84 type StencilReadOnly = CS::StencilReadOnly;
85}
86pub struct SetDepthReadOnly<CS>(CS);
87impl<CS: State> State for SetDepthReadOnly<CS> {
88 type Format = CS::Format;
89 type DepthReadOnly = DepthReadOnlyValue;
90 type StencilReadOnly = CS::StencilReadOnly;
91}
92pub struct SetStencilReadOnly<CS>(CS);
93impl<CS: State> State for SetStencilReadOnly<CS> {
94 type Format = CS::Format;
95 type DepthReadOnly = CS::DepthReadOnly;
96 type StencilReadOnly = StencilReadOnlyValue;
97}
98impl<CS: State> RenderBundleDepthStencilBuilder<CS> {
99 #[doc = "Setter for [wgpu::RenderBundleDepthStencil::format]. Required.\n"]
100 pub fn format(
101 self,
102 format: wgpu::TextureFormat,
103 ) -> RenderBundleDepthStencilBuilder<SetFormat<CS>>
104 where
105 CS::Format: FormatIsEmpty,
106 {
107 RenderBundleDepthStencilBuilder {
108 format: FormatValue(format),
109 depth_read_only: self.depth_read_only,
110 stencil_read_only: self.stencil_read_only,
111 }
112 }
113 #[doc = "Setter for [wgpu::RenderBundleDepthStencil::depth_read_only]. Required.\n"]
114 pub fn depth_read_only(
115 self,
116 depth_read_only: bool,
117 ) -> RenderBundleDepthStencilBuilder<SetDepthReadOnly<CS>>
118 where
119 CS::DepthReadOnly: DepthReadOnlyIsEmpty,
120 {
121 RenderBundleDepthStencilBuilder {
122 format: self.format,
123 depth_read_only: DepthReadOnlyValue(depth_read_only),
124 stencil_read_only: self.stencil_read_only,
125 }
126 }
127 #[doc = "Setter for [wgpu::RenderBundleDepthStencil::stencil_read_only]. Required.\n"]
128 pub fn stencil_read_only(
129 self,
130 stencil_read_only: bool,
131 ) -> RenderBundleDepthStencilBuilder<SetStencilReadOnly<CS>>
132 where
133 CS::StencilReadOnly: StencilReadOnlyIsEmpty,
134 {
135 RenderBundleDepthStencilBuilder {
136 format: self.format,
137 depth_read_only: self.depth_read_only,
138 stencil_read_only: StencilReadOnlyValue(stencil_read_only),
139 }
140 }
141}
142pub trait Complete:
143 State<Format: IsSetFormat, DepthReadOnly: IsSetDepthReadOnly, StencilReadOnly: IsSetStencilReadOnly>
144{
145}
146impl<
147 CS: State<
148 Format: IsSetFormat,
149 DepthReadOnly: IsSetDepthReadOnly,
150 StencilReadOnly: IsSetStencilReadOnly,
151 >,
152 > Complete for CS
153{
154}
155impl<CS: Complete> RenderBundleDepthStencilBuilder<CS> {
156 pub fn build(self) -> wgpu::RenderBundleDepthStencil {
157 wgpu::RenderBundleDepthStencil {
158 format: IsSetFormat::get(self.format),
159 depth_read_only: IsSetDepthReadOnly::get(self.depth_read_only),
160 stencil_read_only: IsSetStencilReadOnly::get(self.stencil_read_only),
161 }
162 }
163}
164impl Nested<wgpu::RenderBundleDepthStencil> for wgpu::RenderBundleDepthStencil {
165 fn unnest(self) -> wgpu::RenderBundleDepthStencil {
166 self
167 }
168}
169impl<CS: Complete> Nested<wgpu::RenderBundleDepthStencil> for RenderBundleDepthStencilBuilder<CS> {
170 fn unnest(self) -> wgpu::RenderBundleDepthStencil {
171 self.build()
172 }
173}
174#[cfg(test)]
175mod tests {
176 #[allow(unused_imports)]
177 #[allow(unused_imports)]
178 use std::num::NonZeroU32;
179 #[test]
180 pub fn test_default() {}
181}