mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
change Device.create_command_encoder
to return an Arc<CommandBuffer<A>
This commit is contained in:
parent
9ce1772f8e
commit
d8b1c5788a
@ -339,12 +339,7 @@ impl<A: HalApi> Drop for CommandBuffer<A> {
|
||||
}
|
||||
|
||||
impl<A: HalApi> CommandBuffer<A> {
|
||||
pub(crate) fn new(
|
||||
encoder: A::CommandEncoder,
|
||||
device: &Arc<Device<A>>,
|
||||
#[cfg(feature = "trace")] enable_tracing: bool,
|
||||
label: &Label,
|
||||
) -> Self {
|
||||
pub(crate) fn new(encoder: A::CommandEncoder, device: &Arc<Device<A>>, label: &Label) -> Self {
|
||||
CommandBuffer {
|
||||
device: device.clone(),
|
||||
support_clear_texture: device.features.contains(wgt::Features::CLEAR_TEXTURE),
|
||||
@ -364,7 +359,7 @@ impl<A: HalApi> CommandBuffer<A> {
|
||||
texture_memory_actions: Default::default(),
|
||||
pending_query_resets: QueryResetMap::new(),
|
||||
#[cfg(feature = "trace")]
|
||||
commands: if enable_tracing {
|
||||
commands: if device.trace.lock().is_some() {
|
||||
Some(Vec::new())
|
||||
} else {
|
||||
None
|
||||
|
@ -1100,7 +1100,7 @@ impl Global {
|
||||
Err(e) => break 'error e,
|
||||
};
|
||||
|
||||
let id = fid.assign(Arc::new(command_buffer));
|
||||
let id = fid.assign(command_buffer);
|
||||
api_log!("Device::create_command_encoder -> {id:?}");
|
||||
return (id.into_command_encoder_id(), None);
|
||||
};
|
||||
|
@ -1599,7 +1599,7 @@ impl<A: HalApi> Device<A> {
|
||||
pub(crate) fn create_command_encoder(
|
||||
self: &Arc<Self>,
|
||||
label: &crate::Label,
|
||||
) -> Result<command::CommandBuffer<A>, DeviceError> {
|
||||
) -> Result<Arc<command::CommandBuffer<A>>, DeviceError> {
|
||||
self.check_is_valid()?;
|
||||
|
||||
let queue = self.get_queue().unwrap();
|
||||
@ -1608,13 +1608,11 @@ impl<A: HalApi> Device<A> {
|
||||
.command_allocator
|
||||
.acquire_encoder(self.raw(), queue.raw())?;
|
||||
|
||||
Ok(command::CommandBuffer::new(
|
||||
encoder,
|
||||
self,
|
||||
#[cfg(feature = "trace")]
|
||||
self.trace.lock().is_some(),
|
||||
label,
|
||||
))
|
||||
let command_buffer = command::CommandBuffer::new(encoder, self, label);
|
||||
|
||||
let command_buffer = Arc::new(command_buffer);
|
||||
|
||||
Ok(command_buffer)
|
||||
}
|
||||
|
||||
/// Generate information about late-validated buffer bindings for pipelines.
|
||||
|
Loading…
Reference in New Issue
Block a user