Skip to content

Commit 039c9f2

Browse files
committed
[add] command encoder to begin abstracting the command processing away from the render context.
1 parent c9e8162 commit 039c9f2

5 files changed

Lines changed: 786 additions & 21 deletions

File tree

crates/lambda-rs-platform/src/wgpu/command.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ pub struct CommandBuffer {
1717
}
1818

1919
impl CommandBuffer {
20-
pub(crate) fn into_raw(self) -> wgpu::CommandBuffer {
20+
/// Convert to the raw wgpu command buffer.
21+
pub fn into_raw(self) -> wgpu::CommandBuffer {
2122
self.raw
2223
}
2324
}
@@ -32,10 +33,10 @@ impl CommandEncoder {
3233
}
3334

3435
/// Internal helper for beginning a render pass. Used by the render pass builder.
35-
pub(crate) fn begin_render_pass_raw<'view>(
36-
&'view mut self,
37-
desc: &wgpu::RenderPassDescriptor<'view>,
38-
) -> wgpu::RenderPass<'view> {
36+
pub(crate) fn begin_render_pass_raw<'pass>(
37+
&'pass mut self,
38+
desc: &wgpu::RenderPassDescriptor<'pass>,
39+
) -> wgpu::RenderPass<'pass> {
3940
return self.raw.begin_render_pass(desc);
4041
}
4142

crates/lambda-rs-platform/src/wgpu/render_pass.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,7 @@
77
//! `CommandEncoder` and texture view. The returned `RenderPass` borrows the
88
//! encoder and remains valid until dropped.
99
10-
use wgpu::{
11-
self,
12-
RenderPassColorAttachment,
13-
};
10+
use wgpu;
1411

1512
use super::{
1613
bind,
@@ -301,7 +298,11 @@ impl RenderPassBuilder {
301298
}
302299
}
303300

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+
)]
305306
pub fn with_label(mut self, label: &str) -> Self {
306307
self.config.label = Some(label.to_string());
307308
return self;
@@ -337,13 +338,22 @@ impl RenderPassBuilder {
337338
/// Build (begin) the render pass on the provided encoder using the provided
338339
/// color attachments list. The attachments list MUST outlive the returned
339340
/// 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).
340349
pub fn build<'view>(
341-
&'view self,
350+
self,
342351
encoder: &'view mut command::CommandEncoder,
343352
attachments: &'view mut RenderColorAttachments<'view>,
344353
depth_view: Option<crate::wgpu::surface::TextureViewRef<'view>>,
345354
depth_ops: Option<DepthOperations>,
346355
stencil_ops: Option<StencilOperations>,
356+
label: Option<&'view str>,
347357
) -> RenderPass<'view> {
348358
let operations = match self.config.color_operations.load {
349359
ColorLoadOp::Load => wgpu::Operations {
@@ -417,8 +427,8 @@ impl RenderPassBuilder {
417427
}
418428
});
419429

420-
let desc: wgpu::RenderPassDescriptor<'view> = wgpu::RenderPassDescriptor {
421-
label: self.config.label.as_deref(),
430+
let desc = wgpu::RenderPassDescriptor {
431+
label,
422432
color_attachments: attachments.as_slice(),
423433
depth_stencil_attachment,
424434
timestamp_writes: None,

0 commit comments

Comments
 (0)