|
3416 | 3416 | <a href="#3415" id="3415">3415</a> |
3417 | 3417 | <a href="#3416" id="3416">3416</a> |
3418 | 3418 | <a href="#3417" id="3417">3417</a> |
| 3419 | +<a href="#3418" id="3418">3418</a> |
| 3420 | +<a href="#3419" id="3419">3419</a> |
| 3421 | +<a href="#3420" id="3420">3420</a> |
| 3422 | +<a href="#3421" id="3421">3421</a> |
| 3423 | +<a href="#3422" id="3422">3422</a> |
| 3424 | +<a href="#3423" id="3423">3423</a> |
| 3425 | +<a href="#3424" id="3424">3424</a> |
| 3426 | +<a href="#3425" id="3425">3425</a> |
| 3427 | +<a href="#3426" id="3426">3426</a> |
| 3428 | +<a href="#3427" id="3427">3427</a> |
| 3429 | +<a href="#3428" id="3428">3428</a> |
| 3430 | +<a href="#3429" id="3429">3429</a> |
| 3431 | +<a href="#3430" id="3430">3430</a> |
| 3432 | +<a href="#3431" id="3431">3431</a> |
| 3433 | +<a href="#3432" id="3432">3432</a> |
| 3434 | +<a href="#3433" id="3433">3433</a> |
3419 | 3435 | </pre></div><pre class="rust"><code><span class="kw">use </span><span class="kw">crate</span>::binding_model::BindGroup; |
3420 | 3436 | <span class="kw">use </span><span class="kw">crate</span>::command::{ |
3421 | 3437 | validate_and_begin_occlusion_query, validate_and_begin_pipeline_statistics_query, |
|
3555 | 3571 | } |
3556 | 3572 | } |
3557 | 3573 |
|
3558 | | -<span class="kw">impl</span><V: Copy> PassChannel<V, <span class="prelude-ty">Option</span><LoadOp>, <span class="prelude-ty">Option</span><StoreOp>> { |
| 3574 | +<span class="kw">impl</span><V: Copy + Default> PassChannel<<span class="prelude-ty">Option</span><V>, <span class="prelude-ty">Option</span><LoadOp>, <span class="prelude-ty">Option</span><StoreOp>> { |
3559 | 3575 | <span class="kw">fn </span>resolve(<span class="kw-2">&</span><span class="self">self</span>) -> <span class="prelude-ty">Result</span><PassChannel<V, LoadOp, StoreOp>, AttachmentError> { |
3560 | 3576 | <span class="kw">let </span>load_op = <span class="kw">if </span><span class="self">self</span>.read_only { |
3561 | 3577 | <span class="kw">if </span><span class="self">self</span>.load_op.is_some() { |
|
3578 | 3594 | <span class="prelude-val">Ok</span>(PassChannel { |
3579 | 3595 | load_op, |
3580 | 3596 | store_op, |
3581 | | - clear_value: <span class="self">self</span>.clear_value, |
| 3597 | + clear_value: <span class="self">self</span>.clear_value.unwrap_or_default(), |
3582 | 3598 | read_only: <span class="self">self</span>.read_only, |
3583 | 3599 | }) |
3584 | 3600 | } |
|
3634 | 3650 | <span class="doccomment">/// The view to use as an attachment. |
3635 | 3651 | </span><span class="kw">pub </span>view: id::TextureViewId, |
3636 | 3652 | <span class="doccomment">/// What operations will be performed on the depth part of the attachment. |
3637 | | - </span><span class="kw">pub </span>depth: PassChannel<f32, <span class="prelude-ty">Option</span><LoadOp>, <span class="prelude-ty">Option</span><StoreOp>>, |
| 3653 | + </span><span class="kw">pub </span>depth: PassChannel<<span class="prelude-ty">Option</span><f32>, <span class="prelude-ty">Option</span><LoadOp>, <span class="prelude-ty">Option</span><StoreOp>>, |
3638 | 3654 | <span class="doccomment">/// What operations will be performed on the stencil part of the attachment. |
3639 | | - </span><span class="kw">pub </span>stencil: PassChannel<u32, <span class="prelude-ty">Option</span><LoadOp>, <span class="prelude-ty">Option</span><StoreOp>>, |
| 3655 | + </span><span class="kw">pub </span>stencil: PassChannel<<span class="prelude-ty">Option</span><u32>, <span class="prelude-ty">Option</span><LoadOp>, <span class="prelude-ty">Option</span><StoreOp>>, |
3640 | 3656 | } |
| 3657 | + |
3641 | 3658 | <span class="doccomment">/// Describes a depth/stencil attachment to a render pass. |
3642 | 3659 | </span><span class="attr">#[derive(Debug)] |
3643 | 3660 | </span><span class="kw">pub struct </span>ArcRenderPassDepthStencilAttachment { |
|
4067 | 4084 | </span>NoLoad, |
4068 | 4085 | <span class="attr">#[error(<span class="string">"Attachment without store"</span>)] |
4069 | 4086 | </span>NoStore, |
| 4087 | + <span class="attr">#[error(<span class="string">"LoadOp is `Clear` but no clear value was provided"</span>)] |
| 4088 | + </span>NoClearValue, |
| 4089 | + <span class="attr">#[error(<span class="string">"Clear value ({0}) must be between 0.0 and 1.0, inclusive"</span>)] |
| 4090 | + </span>ClearValueOutOfRange(f32), |
4070 | 4091 | } |
4071 | 4092 |
|
4072 | 4093 | <span class="doccomment">/// Error encountered when performing a render pass. |
|
4891 | 4912 | ))); |
4892 | 4913 | } |
4893 | 4914 |
|
| 4915 | + <span class="comment">// If this.depthLoadOp is "clear", this.depthClearValue must be provided and must be between 0.0 and 1.0, inclusive. |
| 4916 | + </span><span class="kw">if </span>depth_stencil_attachment.depth.load_op == <span class="prelude-val">Some</span>(LoadOp::Clear) { |
| 4917 | + <span class="kw">if let </span><span class="prelude-val">Some</span>(clear_value) = depth_stencil_attachment.depth.clear_value { |
| 4918 | + <span class="kw">if </span>!(<span class="number">0.0</span>..=<span class="number">1.0</span>).contains(<span class="kw-2">&</span>clear_value) { |
| 4919 | + <span class="kw">return </span><span class="prelude-val">Err</span>(CommandEncoderError::InvalidAttachment(AttachmentError::ClearValueOutOfRange(clear_value))); |
| 4920 | + } |
| 4921 | + } <span class="kw">else </span>{ |
| 4922 | + <span class="kw">return </span><span class="prelude-val">Err</span>(CommandEncoderError::InvalidAttachment(AttachmentError::NoClearValue)); |
| 4923 | + } |
| 4924 | + } |
| 4925 | + |
4894 | 4926 | <span class="prelude-val">Some</span>(ArcRenderPassDepthStencilAttachment { |
4895 | 4927 | view, |
4896 | 4928 | depth: <span class="kw">if </span>format.has_depth_aspect() { |
|
0 commit comments