mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
remove LifetimeTracker.future_suspected_{buffers,textures}
This commit is contained in:
parent
61739d9583
commit
3cc6c2743a
@ -433,21 +433,11 @@ impl Global {
|
|||||||
|
|
||||||
let device = buffer.device.clone();
|
let device = buffer.device.clone();
|
||||||
|
|
||||||
if device
|
device
|
||||||
.pending_writes
|
.lock_life()
|
||||||
.lock()
|
.suspected_resources
|
||||||
.as_ref()
|
.buffers
|
||||||
.unwrap()
|
.insert(buffer.tracker_index(), buffer);
|
||||||
.contains_buffer(&buffer)
|
|
||||||
{
|
|
||||||
device.lock_life().future_suspected_buffers.push(buffer);
|
|
||||||
} else {
|
|
||||||
device
|
|
||||||
.lock_life()
|
|
||||||
.suspected_resources
|
|
||||||
.buffers
|
|
||||||
.insert(buffer.tracker_index(), buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if wait {
|
if wait {
|
||||||
match device.wait_for_submit(last_submit_index) {
|
match device.wait_for_submit(last_submit_index) {
|
||||||
@ -626,26 +616,12 @@ impl Global {
|
|||||||
let last_submit_index = texture.submission_index();
|
let last_submit_index = texture.submission_index();
|
||||||
|
|
||||||
let device = &texture.device;
|
let device = &texture.device;
|
||||||
{
|
|
||||||
if device
|
device
|
||||||
.pending_writes
|
.lock_life()
|
||||||
.lock()
|
.suspected_resources
|
||||||
.as_ref()
|
.textures
|
||||||
.unwrap()
|
.insert(texture.tracker_index(), texture.clone());
|
||||||
.contains_texture(&texture)
|
|
||||||
{
|
|
||||||
device
|
|
||||||
.lock_life()
|
|
||||||
.future_suspected_textures
|
|
||||||
.push(texture.clone());
|
|
||||||
} else {
|
|
||||||
device
|
|
||||||
.lock_life()
|
|
||||||
.suspected_resources
|
|
||||||
.textures
|
|
||||||
.insert(texture.tracker_index(), texture.clone());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if wait {
|
if wait {
|
||||||
match device.wait_for_submit(last_submit_index) {
|
match device.wait_for_submit(last_submit_index) {
|
||||||
|
|||||||
@ -230,13 +230,6 @@ pub(crate) struct LifetimeTracker<A: HalApi> {
|
|||||||
/// queue submissions still in flight.
|
/// queue submissions still in flight.
|
||||||
mapped: Vec<Arc<Buffer<A>>>,
|
mapped: Vec<Arc<Buffer<A>>>,
|
||||||
|
|
||||||
/// Buffers can be used in a submission that is yet to be made, by the
|
|
||||||
/// means of `write_buffer()`, so we have a special place for them.
|
|
||||||
pub future_suspected_buffers: Vec<Arc<Buffer<A>>>,
|
|
||||||
|
|
||||||
/// Textures can be used in the upcoming submission by `write_texture`.
|
|
||||||
pub future_suspected_textures: Vec<Arc<Texture<A>>>,
|
|
||||||
|
|
||||||
/// Resources whose user handle has died (i.e. drop/destroy has been called)
|
/// Resources whose user handle has died (i.e. drop/destroy has been called)
|
||||||
/// and will likely be ready for destruction soon.
|
/// and will likely be ready for destruction soon.
|
||||||
pub suspected_resources: ResourceMaps<A>,
|
pub suspected_resources: ResourceMaps<A>,
|
||||||
@ -269,8 +262,6 @@ impl<A: HalApi> LifetimeTracker<A> {
|
|||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {
|
Self {
|
||||||
mapped: Vec::new(),
|
mapped: Vec::new(),
|
||||||
future_suspected_buffers: Vec::new(),
|
|
||||||
future_suspected_textures: Vec::new(),
|
|
||||||
suspected_resources: ResourceMaps::new(),
|
suspected_resources: ResourceMaps::new(),
|
||||||
active: Vec::new(),
|
active: Vec::new(),
|
||||||
ready_to_map: Vec::new(),
|
ready_to_map: Vec::new(),
|
||||||
@ -301,19 +292,6 @@ impl<A: HalApi> LifetimeTracker<A> {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn post_submit(&mut self) {
|
|
||||||
for v in self.future_suspected_buffers.drain(..) {
|
|
||||||
self.suspected_resources
|
|
||||||
.buffers
|
|
||||||
.insert(v.tracker_index(), v);
|
|
||||||
}
|
|
||||||
for v in self.future_suspected_textures.drain(..) {
|
|
||||||
self.suspected_resources
|
|
||||||
.textures
|
|
||||||
.insert(v.tracker_index(), v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn map(&mut self, value: &Arc<Buffer<A>>) {
|
pub(crate) fn map(&mut self, value: &Arc<Buffer<A>>) {
|
||||||
self.mapped.push(value.clone());
|
self.mapped.push(value.clone());
|
||||||
}
|
}
|
||||||
|
|||||||
@ -149,6 +149,11 @@ pub(crate) struct EncoderInFlight<A: HalApi> {
|
|||||||
raw: A::CommandEncoder,
|
raw: A::CommandEncoder,
|
||||||
cmd_buffers: Vec<A::CommandBuffer>,
|
cmd_buffers: Vec<A::CommandBuffer>,
|
||||||
trackers: Tracker<A>,
|
trackers: Tracker<A>,
|
||||||
|
|
||||||
|
/// These are the buffers that have been tracked by `PendingWrites`.
|
||||||
|
pending_buffers: Vec<Arc<Buffer<A>>>,
|
||||||
|
/// These are the textures that have been tracked by `PendingWrites`.
|
||||||
|
pending_textures: Vec<Arc<Texture<A>>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: HalApi> EncoderInFlight<A> {
|
impl<A: HalApi> EncoderInFlight<A> {
|
||||||
@ -163,6 +168,8 @@ impl<A: HalApi> EncoderInFlight<A> {
|
|||||||
// resources, so can be _very_ expensive.
|
// resources, so can be _very_ expensive.
|
||||||
profiling::scope!("drop command buffer trackers");
|
profiling::scope!("drop command buffer trackers");
|
||||||
drop(self.trackers);
|
drop(self.trackers);
|
||||||
|
drop(self.pending_buffers);
|
||||||
|
drop(self.pending_textures);
|
||||||
}
|
}
|
||||||
self.raw
|
self.raw
|
||||||
}
|
}
|
||||||
@ -259,20 +266,26 @@ impl<A: HalApi> PendingWrites<A> {
|
|||||||
device: &A::Device,
|
device: &A::Device,
|
||||||
queue: &A::Queue,
|
queue: &A::Queue,
|
||||||
) -> Result<Option<EncoderInFlight<A>>, DeviceError> {
|
) -> Result<Option<EncoderInFlight<A>>, DeviceError> {
|
||||||
self.dst_buffers.clear();
|
|
||||||
self.dst_textures.clear();
|
|
||||||
if self.is_recording {
|
if self.is_recording {
|
||||||
|
let pending_buffers = self.dst_buffers.drain().map(|(_, b)| b).collect();
|
||||||
|
let pending_textures = self.dst_textures.drain().map(|(_, t)| t).collect();
|
||||||
|
|
||||||
let cmd_buf = unsafe { self.command_encoder.end_encoding()? };
|
let cmd_buf = unsafe { self.command_encoder.end_encoding()? };
|
||||||
self.is_recording = false;
|
self.is_recording = false;
|
||||||
|
|
||||||
let new_encoder = command_allocator.acquire_encoder(device, queue)?;
|
let new_encoder = command_allocator.acquire_encoder(device, queue)?;
|
||||||
|
|
||||||
Ok(Some(EncoderInFlight {
|
let encoder = EncoderInFlight {
|
||||||
raw: mem::replace(&mut self.command_encoder, new_encoder),
|
raw: mem::replace(&mut self.command_encoder, new_encoder),
|
||||||
cmd_buffers: vec![cmd_buf],
|
cmd_buffers: vec![cmd_buf],
|
||||||
trackers: Tracker::new(),
|
trackers: Tracker::new(),
|
||||||
}))
|
pending_buffers,
|
||||||
|
pending_textures,
|
||||||
|
};
|
||||||
|
Ok(Some(encoder))
|
||||||
} else {
|
} else {
|
||||||
|
self.dst_buffers.clear();
|
||||||
|
self.dst_textures.clear();
|
||||||
Ok(None)
|
Ok(None)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1352,6 +1365,8 @@ impl Global {
|
|||||||
raw: baked.encoder,
|
raw: baked.encoder,
|
||||||
cmd_buffers: baked.list,
|
cmd_buffers: baked.list,
|
||||||
trackers: baked.trackers,
|
trackers: baked.trackers,
|
||||||
|
pending_buffers: Vec::new(),
|
||||||
|
pending_textures: Vec::new(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1467,8 +1482,6 @@ impl Global {
|
|||||||
Err(WaitIdleError::WrongSubmissionIndex(..)) => unreachable!(),
|
Err(WaitIdleError::WrongSubmissionIndex(..)) => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
device.lock_life().post_submit();
|
|
||||||
|
|
||||||
(submit_index, closures)
|
(submit_index, closures)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user