Skip to content

Commit d8b1c57

Browse files
committed
change Device.create_command_encoder to return an Arc<CommandBuffer<A>
1 parent 9ce1772 commit d8b1c57

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

wgpu-core/src/command/mod.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,7 @@ impl<A: HalApi> Drop for CommandBuffer<A> {
339339
}
340340

341341
impl<A: HalApi> CommandBuffer<A> {
342-
pub(crate) fn new(
343-
encoder: A::CommandEncoder,
344-
device: &Arc<Device<A>>,
345-
#[cfg(feature = "trace")] enable_tracing: bool,
346-
label: &Label,
347-
) -> Self {
342+
pub(crate) fn new(encoder: A::CommandEncoder, device: &Arc<Device<A>>, label: &Label) -> Self {
348343
CommandBuffer {
349344
device: device.clone(),
350345
support_clear_texture: device.features.contains(wgt::Features::CLEAR_TEXTURE),
@@ -364,7 +359,7 @@ impl<A: HalApi> CommandBuffer<A> {
364359
texture_memory_actions: Default::default(),
365360
pending_query_resets: QueryResetMap::new(),
366361
#[cfg(feature = "trace")]
367-
commands: if enable_tracing {
362+
commands: if device.trace.lock().is_some() {
368363
Some(Vec::new())
369364
} else {
370365
None

wgpu-core/src/device/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1100,7 +1100,7 @@ impl Global {
11001100
Err(e) => break 'error e,
11011101
};
11021102

1103-
let id = fid.assign(Arc::new(command_buffer));
1103+
let id = fid.assign(command_buffer);
11041104
api_log!("Device::create_command_encoder -> {id:?}");
11051105
return (id.into_command_encoder_id(), None);
11061106
};

wgpu-core/src/device/resource.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1599,7 +1599,7 @@ impl<A: HalApi> Device<A> {
15991599
pub(crate) fn create_command_encoder(
16001600
self: &Arc<Self>,
16011601
label: &crate::Label,
1602-
) -> Result<command::CommandBuffer<A>, DeviceError> {
1602+
) -> Result<Arc<command::CommandBuffer<A>>, DeviceError> {
16031603
self.check_is_valid()?;
16041604

16051605
let queue = self.get_queue().unwrap();
@@ -1608,13 +1608,11 @@ impl<A: HalApi> Device<A> {
16081608
.command_allocator
16091609
.acquire_encoder(self.raw(), queue.raw())?;
16101610

1611-
Ok(command::CommandBuffer::new(
1612-
encoder,
1613-
self,
1614-
#[cfg(feature = "trace")]
1615-
self.trace.lock().is_some(),
1616-
label,
1617-
))
1611+
let command_buffer = command::CommandBuffer::new(encoder, self, label);
1612+
1613+
let command_buffer = Arc::new(command_buffer);
1614+
1615+
Ok(command_buffer)
16181616
}
16191617

16201618
/// Generate information about late-validated buffer bindings for pipelines.

0 commit comments

Comments
 (0)