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