mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-25 00:03:29 +00:00
remove Arc
s around TempResource
variants
This commit is contained in:
parent
ef909d0a82
commit
7223bfa88d
@ -316,17 +316,17 @@ impl<A: HalApi> LifetimeTracker<A> {
|
||||
TempResource::StagingBuffer(raw) => {
|
||||
last_resources
|
||||
.staging_buffers
|
||||
.insert(raw.tracker_index(), raw);
|
||||
.insert(raw.tracker_index(), Arc::new(raw));
|
||||
}
|
||||
TempResource::DestroyedBuffer(destroyed) => {
|
||||
last_resources
|
||||
.destroyed_buffers
|
||||
.insert(destroyed.tracker_index, destroyed);
|
||||
.insert(destroyed.tracker_index, Arc::new(destroyed));
|
||||
}
|
||||
TempResource::DestroyedTexture(destroyed) => {
|
||||
last_resources
|
||||
.destroyed_textures
|
||||
.insert(destroyed.tracker_index, destroyed);
|
||||
.insert(destroyed.tracker_index, Arc::new(destroyed));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -417,17 +417,19 @@ impl<A: HalApi> LifetimeTracker<A> {
|
||||
if let Some(resources) = resources {
|
||||
match temp_resource {
|
||||
TempResource::StagingBuffer(raw) => {
|
||||
resources.staging_buffers.insert(raw.tracker_index(), raw);
|
||||
resources
|
||||
.staging_buffers
|
||||
.insert(raw.tracker_index(), Arc::new(raw));
|
||||
}
|
||||
TempResource::DestroyedBuffer(destroyed) => {
|
||||
resources
|
||||
.destroyed_buffers
|
||||
.insert(destroyed.tracker_index, destroyed);
|
||||
.insert(destroyed.tracker_index, Arc::new(destroyed));
|
||||
}
|
||||
TempResource::DestroyedTexture(destroyed) => {
|
||||
resources
|
||||
.destroyed_textures
|
||||
.insert(destroyed.tracker_index, destroyed);
|
||||
.insert(destroyed.tracker_index, Arc::new(destroyed));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,9 +145,9 @@ pub struct WrappedSubmissionIndex {
|
||||
/// `maintain` call, no longer used anywhere
|
||||
#[derive(Debug)]
|
||||
pub enum TempResource<A: HalApi> {
|
||||
StagingBuffer(Arc<StagingBuffer<A>>),
|
||||
DestroyedBuffer(Arc<DestroyedBuffer<A>>),
|
||||
DestroyedTexture(Arc<DestroyedTexture<A>>),
|
||||
StagingBuffer(StagingBuffer<A>),
|
||||
DestroyedBuffer(DestroyedBuffer<A>),
|
||||
DestroyedTexture(DestroyedTexture<A>),
|
||||
}
|
||||
|
||||
/// A series of raw [`CommandBuffer`]s that have been submitted to a
|
||||
@ -257,7 +257,7 @@ impl<A: HalApi> PendingWrites<A> {
|
||||
self.temp_resources.push(resource);
|
||||
}
|
||||
|
||||
fn consume(&mut self, buffer: Arc<StagingBuffer<A>>) {
|
||||
fn consume(&mut self, buffer: StagingBuffer<A>) {
|
||||
self.temp_resources
|
||||
.push(TempResource::StagingBuffer(buffer));
|
||||
}
|
||||
@ -453,8 +453,6 @@ impl Global {
|
||||
let mut pending_writes = device.pending_writes.lock();
|
||||
let pending_writes = pending_writes.as_mut().unwrap();
|
||||
|
||||
let staging_buffer = Arc::new(staging_buffer);
|
||||
|
||||
if let Err(flush_error) = unsafe {
|
||||
profiling::scope!("copy");
|
||||
ptr::copy_nonoverlapping(data.as_ptr(), staging_buffer_ptr.as_ptr(), data.len());
|
||||
@ -520,13 +518,12 @@ impl Global {
|
||||
|
||||
let device = &queue.device;
|
||||
|
||||
let staging_buffer = hub.staging_buffers.unregister(staging_buffer_id);
|
||||
if staging_buffer.is_none() {
|
||||
return Err(QueueWriteError::Transfer(TransferError::InvalidBufferId(
|
||||
buffer_id,
|
||||
)));
|
||||
}
|
||||
let staging_buffer = staging_buffer.unwrap();
|
||||
let staging_buffer = hub
|
||||
.staging_buffers
|
||||
.unregister(staging_buffer_id)
|
||||
.and_then(Arc::into_inner)
|
||||
.ok_or_else(|| QueueWriteError::Transfer(TransferError::InvalidBufferId(buffer_id)))?;
|
||||
|
||||
let mut pending_writes = device.pending_writes.lock();
|
||||
let pending_writes = pending_writes.as_mut().unwrap();
|
||||
|
||||
@ -837,8 +834,6 @@ impl Global {
|
||||
let (staging_buffer, staging_buffer_ptr) =
|
||||
prepare_staging_buffer(device, stage_size, device.instance_flags)?;
|
||||
|
||||
let staging_buffer = Arc::new(staging_buffer);
|
||||
|
||||
if stage_bytes_per_row == bytes_per_row {
|
||||
profiling::scope!("copy aligned");
|
||||
// Fast path if the data is already being aligned optimally.
|
||||
|
@ -690,7 +690,7 @@ impl<A: HalApi> Device<A> {
|
||||
buffer.initialization_status.write().drain(0..buffer.size);
|
||||
|
||||
*buffer.map_state.lock() = resource::BufferMapState::Init {
|
||||
staging_buffer: Arc::new(staging_buffer),
|
||||
staging_buffer,
|
||||
ptr: staging_buffer_ptr,
|
||||
};
|
||||
hal::BufferUses::COPY_DST
|
||||
|
@ -260,7 +260,7 @@ pub enum BufferMapAsyncStatus {
|
||||
pub(crate) enum BufferMapState<A: HalApi> {
|
||||
/// Mapped at creation.
|
||||
Init {
|
||||
staging_buffer: Arc<StagingBuffer<A>>,
|
||||
staging_buffer: StagingBuffer<A>,
|
||||
ptr: NonNull<u8>,
|
||||
},
|
||||
/// Waiting for GPU to be done before mapping
|
||||
@ -767,14 +767,14 @@ impl<A: HalApi> Buffer<A> {
|
||||
mem::take(&mut *guard)
|
||||
};
|
||||
|
||||
queue::TempResource::DestroyedBuffer(Arc::new(DestroyedBuffer {
|
||||
queue::TempResource::DestroyedBuffer(DestroyedBuffer {
|
||||
raw: Some(raw),
|
||||
device: Arc::clone(&self.device),
|
||||
submission_index: self.submission_index(),
|
||||
tracker_index: self.tracker_index(),
|
||||
label: self.label().to_owned(),
|
||||
bind_groups,
|
||||
}))
|
||||
})
|
||||
};
|
||||
|
||||
let mut pending_writes = device.pending_writes.lock();
|
||||
@ -1136,7 +1136,7 @@ impl<A: HalApi> Texture<A> {
|
||||
mem::take(&mut *guard)
|
||||
};
|
||||
|
||||
queue::TempResource::DestroyedTexture(Arc::new(DestroyedTexture {
|
||||
queue::TempResource::DestroyedTexture(DestroyedTexture {
|
||||
raw: Some(raw),
|
||||
views,
|
||||
bind_groups,
|
||||
@ -1144,7 +1144,7 @@ impl<A: HalApi> Texture<A> {
|
||||
tracker_index: self.tracker_index(),
|
||||
submission_index: self.submission_index(),
|
||||
label: self.label().to_owned(),
|
||||
}))
|
||||
})
|
||||
};
|
||||
|
||||
let mut pending_writes = device.pending_writes.lock();
|
||||
|
Loading…
Reference in New Issue
Block a user