|
7 | 7 | //! `CommandEncoder` and texture view. The returned `RenderPass` borrows the |
8 | 8 | //! encoder and remains valid until dropped. |
9 | 9 |
|
10 | | -use wgpu::{ |
11 | | - self, |
12 | | - RenderPassColorAttachment, |
13 | | -}; |
| 10 | +use wgpu; |
14 | 11 |
|
15 | 12 | use super::{ |
16 | 13 | bind, |
@@ -301,7 +298,11 @@ impl RenderPassBuilder { |
301 | 298 | } |
302 | 299 | } |
303 | 300 |
|
304 | | - /// Attach a debug label to the render pass. |
| 301 | + /// Attach a debug label to the render pass (used only for debugging during |
| 302 | + /// builder setup, the actual label must be passed to `build`). |
| 303 | + #[deprecated( |
| 304 | + note = "The label must be passed directly to build() for proper lifetime management" |
| 305 | + )] |
305 | 306 | pub fn with_label(mut self, label: &str) -> Self { |
306 | 307 | self.config.label = Some(label.to_string()); |
307 | 308 | return self; |
@@ -337,13 +338,22 @@ impl RenderPassBuilder { |
337 | 338 | /// Build (begin) the render pass on the provided encoder using the provided |
338 | 339 | /// color attachments list. The attachments list MUST outlive the returned |
339 | 340 | /// render pass value. |
| 341 | + /// |
| 342 | + /// # Arguments |
| 343 | + /// * `encoder` - The command encoder to begin the pass on. |
| 344 | + /// * `attachments` - Color attachments for the pass. |
| 345 | + /// * `depth_view` - Optional depth view. |
| 346 | + /// * `depth_ops` - Optional depth operations. |
| 347 | + /// * `stencil_ops` - Optional stencil operations. |
| 348 | + /// * `label` - Optional debug label (must outlive the pass). |
340 | 349 | pub fn build<'view>( |
341 | | - &'view self, |
| 350 | + self, |
342 | 351 | encoder: &'view mut command::CommandEncoder, |
343 | 352 | attachments: &'view mut RenderColorAttachments<'view>, |
344 | 353 | depth_view: Option<crate::wgpu::surface::TextureViewRef<'view>>, |
345 | 354 | depth_ops: Option<DepthOperations>, |
346 | 355 | stencil_ops: Option<StencilOperations>, |
| 356 | + label: Option<&'view str>, |
347 | 357 | ) -> RenderPass<'view> { |
348 | 358 | let operations = match self.config.color_operations.load { |
349 | 359 | ColorLoadOp::Load => wgpu::Operations { |
@@ -417,8 +427,8 @@ impl RenderPassBuilder { |
417 | 427 | } |
418 | 428 | }); |
419 | 429 |
|
420 | | - let desc: wgpu::RenderPassDescriptor<'view> = wgpu::RenderPassDescriptor { |
421 | | - label: self.config.label.as_deref(), |
| 430 | + let desc = wgpu::RenderPassDescriptor { |
| 431 | + label, |
422 | 432 | color_attachments: attachments.as_slice(), |
423 | 433 | depth_stencil_attachment, |
424 | 434 | timestamp_writes: None, |
|
0 commit comments