mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +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();
|
||||
|
||||
if device
|
||||
.pending_writes
|
||||
.lock()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.contains_buffer(&buffer)
|
||||
{
|
||||
device.lock_life().future_suspected_buffers.push(buffer);
|
||||
} else {
|
||||
device
|
||||
.lock_life()
|
||||
.suspected_resources
|
||||
.buffers
|
||||
.insert(buffer.tracker_index(), buffer);
|
||||
}
|
||||
device
|
||||
.lock_life()
|
||||
.suspected_resources
|
||||
.buffers
|
||||
.insert(buffer.tracker_index(), buffer);
|
||||
|
||||
if wait {
|
||||
match device.wait_for_submit(last_submit_index) {
|
||||
@ -626,26 +616,12 @@ impl Global {
|
||||
let last_submit_index = texture.submission_index();
|
||||
|
||||
let device = &texture.device;
|
||||
{
|
||||
if device
|
||||
.pending_writes
|
||||
.lock()
|
||||
.as_ref()
|
||||
.unwrap()
|
||||
.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());
|
||||
}
|
||||
}
|
||||
|
||||
device
|
||||
.lock_life()
|
||||
.suspected_resources
|
||||
.textures
|
||||
.insert(texture.tracker_index(), texture.clone());
|
||||
|
||||
if wait {
|
||||
match device.wait_for_submit(last_submit_index) {
|
||||
|
@ -230,13 +230,6 @@ pub(crate) struct LifetimeTracker<A: HalApi> {
|
||||
/// queue submissions still in flight.
|
||||
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)
|
||||
/// and will likely be ready for destruction soon.
|
||||
pub suspected_resources: ResourceMaps<A>,
|
||||
@ -269,8 +262,6 @@ impl<A: HalApi> LifetimeTracker<A> {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
mapped: Vec::new(),
|
||||
future_suspected_buffers: Vec::new(),
|
||||
future_suspected_textures: Vec::new(),
|
||||
suspected_resources: ResourceMaps::new(),
|
||||
active: 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>>) {
|
||||
self.mapped.push(value.clone());
|
||||
}
|
||||
|
@ -149,6 +149,11 @@ pub(crate) struct EncoderInFlight<A: HalApi> {
|
||||
raw: A::CommandEncoder,
|
||||
cmd_buffers: Vec<A::CommandBuffer>,
|
||||
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> {
|
||||
@ -163,6 +168,8 @@ impl<A: HalApi> EncoderInFlight<A> {
|
||||
// resources, so can be _very_ expensive.
|
||||
profiling::scope!("drop command buffer trackers");
|
||||
drop(self.trackers);
|
||||
drop(self.pending_buffers);
|
||||
drop(self.pending_textures);
|
||||
}
|
||||
self.raw
|
||||
}
|
||||
@ -259,20 +266,26 @@ impl<A: HalApi> PendingWrites<A> {
|
||||
device: &A::Device,
|
||||
queue: &A::Queue,
|
||||
) -> Result<Option<EncoderInFlight<A>>, DeviceError> {
|
||||
self.dst_buffers.clear();
|
||||
self.dst_textures.clear();
|
||||
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()? };
|
||||
self.is_recording = false;
|
||||
|
||||
let new_encoder = command_allocator.acquire_encoder(device, queue)?;
|
||||
|
||||
Ok(Some(EncoderInFlight {
|
||||
let encoder = EncoderInFlight {
|
||||
raw: mem::replace(&mut self.command_encoder, new_encoder),
|
||||
cmd_buffers: vec![cmd_buf],
|
||||
trackers: Tracker::new(),
|
||||
}))
|
||||
pending_buffers,
|
||||
pending_textures,
|
||||
};
|
||||
Ok(Some(encoder))
|
||||
} else {
|
||||
self.dst_buffers.clear();
|
||||
self.dst_textures.clear();
|
||||
Ok(None)
|
||||
}
|
||||
}
|
||||
@ -1352,6 +1365,8 @@ impl Global {
|
||||
raw: baked.encoder,
|
||||
cmd_buffers: baked.list,
|
||||
trackers: baked.trackers,
|
||||
pending_buffers: Vec::new(),
|
||||
pending_textures: Vec::new(),
|
||||
});
|
||||
}
|
||||
|
||||
@ -1467,8 +1482,6 @@ impl Global {
|
||||
Err(WaitIdleError::WrongSubmissionIndex(..)) => unreachable!(),
|
||||
};
|
||||
|
||||
device.lock_life().post_submit();
|
||||
|
||||
(submit_index, closures)
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user