mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 15:31:03 +01:00
[wgpu-core] ray tracing: remove acceleration structures from pending writes
The acceleration structures are already being kept alive by the tracker in the command encoder.
This commit is contained in:
1 parent
fb9f91a668
commit
43e0ebde9f
4 files changed
+10
-70
No files matched your search
@@ -1,5 +1,5 @@
|
||||
use crate::{
|
||||
device::{queue::TempResource, Device},
|
||||
device::queue::TempResource,
|
||||
global::Global,
|
||||
hub::Hub,
|
||||
id::CommandEncoderId,
|
||||
@@ -174,7 +174,6 @@ impl Global {
|
||||
build_command_index,
|
||||
&mut buf_storage,
|
||||
hub,
|
||||
device,
|
||||
)?;
|
||||
|
||||
let snatch_guard = device.snatchable_lock.read();
|
||||
@@ -225,9 +224,6 @@ impl Global {
|
||||
|
||||
let tlas = hub.tlas_s.get(entry.tlas_id).get()?;
|
||||
cmd_buf_data.trackers.tlas_s.set_single(tlas.clone());
|
||||
if let Some(queue) = device.get_queue() {
|
||||
queue.pending_writes.lock().insert_tlas(&tlas);
|
||||
}
|
||||
|
||||
cmd_buf_data.tlas_actions.push(TlasAction {
|
||||
tlas: tlas.clone(),
|
||||
@@ -478,7 +474,6 @@ impl Global {
|
||||
build_command_index,
|
||||
&mut buf_storage,
|
||||
hub,
|
||||
device,
|
||||
)?;
|
||||
|
||||
let snatch_guard = device.snatchable_lock.read();
|
||||
@@ -496,9 +491,6 @@ impl Global {
|
||||
|
||||
for package in tlas_iter {
|
||||
let tlas = hub.tlas_s.get(package.tlas_id).get()?;
|
||||
if let Some(queue) = device.get_queue() {
|
||||
queue.pending_writes.lock().insert_tlas(&tlas);
|
||||
}
|
||||
|
||||
cmd_buf_data.trackers.tlas_s.set_single(tlas.clone());
|
||||
|
||||
@@ -833,15 +825,11 @@ fn iter_blas<'a>(
|
||||
build_command_index: NonZeroU64,
|
||||
buf_storage: &mut Vec<TriangleBufferStore<'a>>,
|
||||
hub: &Hub,
|
||||
device: &Device,
|
||||
) -> Result<(), BuildAccelerationStructureError> {
|
||||
let mut temp_buffer = Vec::new();
|
||||
for entry in blas_iter {
|
||||
let blas = hub.blas_s.get(entry.blas_id).get()?;
|
||||
cmd_buf_data.trackers.blas_s.set_single(blas.clone());
|
||||
if let Some(queue) = device.get_queue() {
|
||||
queue.pending_writes.lock().insert_blas(&blas);
|
||||
}
|
||||
|
||||
cmd_buf_data.blas_actions.push(BlasAction {
|
||||
blas: blas.clone(),
|
||||
|
||||
@@ -115,10 +115,6 @@ impl ActiveSubmission {
|
||||
if encoder.trackers.blas_s.contains(blas) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if encoder.pending_blas_s.contains_key(&blas.tracker_index()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
@@ -134,10 +130,6 @@ impl ActiveSubmission {
|
||||
if encoder.trackers.tlas_s.contains(tlas) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if encoder.pending_tlas_s.contains_key(&tlas.tracker_index()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
|
||||
@@ -27,7 +27,7 @@ use crate::{
|
||||
|
||||
use smallvec::SmallVec;
|
||||
|
||||
use crate::resource::{Blas, DestroyedAccelerationStructure, Tlas};
|
||||
use crate::resource::DestroyedAccelerationStructure;
|
||||
use crate::scratch::ScratchBuffer;
|
||||
use std::{
|
||||
iter,
|
||||
@@ -273,10 +273,6 @@ pub(crate) struct EncoderInFlight {
|
||||
pub(crate) pending_buffers: FastHashMap<TrackerIndex, Arc<Buffer>>,
|
||||
/// These are the textures that have been tracked by `PendingWrites`.
|
||||
pub(crate) pending_textures: FastHashMap<TrackerIndex, Arc<Texture>>,
|
||||
/// These are the BLASes that have been tracked by `PendingWrites`.
|
||||
pub(crate) pending_blas_s: FastHashMap<TrackerIndex, Arc<Blas>>,
|
||||
/// These are the TLASes that have been tracked by `PendingWrites`.
|
||||
pub(crate) pending_tlas_s: FastHashMap<TrackerIndex, Arc<Tlas>>,
|
||||
}
|
||||
|
||||
/// A private command encoder for writes made directly on the device
|
||||
@@ -314,8 +310,6 @@ pub(crate) struct PendingWrites {
|
||||
temp_resources: Vec<TempResource>,
|
||||
dst_buffers: FastHashMap<TrackerIndex, Arc<Buffer>>,
|
||||
dst_textures: FastHashMap<TrackerIndex, Arc<Texture>>,
|
||||
dst_blas_s: FastHashMap<TrackerIndex, Arc<Blas>>,
|
||||
dst_tlas_s: FastHashMap<TrackerIndex, Arc<Tlas>>,
|
||||
}
|
||||
|
||||
impl PendingWrites {
|
||||
@@ -326,8 +320,6 @@ impl PendingWrites {
|
||||
temp_resources: Vec::new(),
|
||||
dst_buffers: FastHashMap::default(),
|
||||
dst_textures: FastHashMap::default(),
|
||||
dst_blas_s: FastHashMap::default(),
|
||||
dst_tlas_s: FastHashMap::default(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -349,22 +341,6 @@ impl PendingWrites {
|
||||
self.dst_textures.contains_key(&texture.tracker_index())
|
||||
}
|
||||
|
||||
pub fn insert_blas(&mut self, blas: &Arc<Blas>) {
|
||||
self.dst_blas_s.insert(blas.tracker_index(), blas.clone());
|
||||
}
|
||||
|
||||
pub fn insert_tlas(&mut self, tlas: &Arc<Tlas>) {
|
||||
self.dst_tlas_s.insert(tlas.tracker_index(), tlas.clone());
|
||||
}
|
||||
|
||||
pub fn contains_blas(&mut self, blas: &Arc<Blas>) -> bool {
|
||||
self.dst_blas_s.contains_key(&blas.tracker_index())
|
||||
}
|
||||
|
||||
pub fn contains_tlas(&mut self, tlas: &Arc<Tlas>) -> bool {
|
||||
self.dst_tlas_s.contains_key(&tlas.tracker_index())
|
||||
}
|
||||
|
||||
pub fn consume_temp(&mut self, resource: TempResource) {
|
||||
self.temp_resources.push(resource);
|
||||
}
|
||||
@@ -383,8 +359,6 @@ impl PendingWrites {
|
||||
if self.is_recording {
|
||||
let pending_buffers = mem::take(&mut self.dst_buffers);
|
||||
let pending_textures = mem::take(&mut self.dst_textures);
|
||||
let pending_blas_s = mem::take(&mut self.dst_blas_s);
|
||||
let pending_tlas_s = mem::take(&mut self.dst_tlas_s);
|
||||
|
||||
let cmd_buf = unsafe { self.command_encoder.end_encoding() }
|
||||
.map_err(|e| device.handle_hal_error(e))?;
|
||||
@@ -405,8 +379,6 @@ impl PendingWrites {
|
||||
trackers: Tracker::new(),
|
||||
pending_buffers,
|
||||
pending_textures,
|
||||
pending_blas_s,
|
||||
pending_tlas_s,
|
||||
};
|
||||
Ok(Some(encoder))
|
||||
} else {
|
||||
@@ -1225,8 +1197,6 @@ impl Queue {
|
||||
trackers: baked.trackers,
|
||||
pending_buffers: FastHashMap::default(),
|
||||
pending_textures: FastHashMap::default(),
|
||||
pending_blas_s: FastHashMap::default(),
|
||||
pending_tlas_s: FastHashMap::default(),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1959,15 +1959,10 @@ impl Blas {
|
||||
};
|
||||
|
||||
if let Some(queue) = device.get_queue() {
|
||||
let mut pending_writes = queue.pending_writes.lock();
|
||||
if pending_writes.contains_blas(self) {
|
||||
pending_writes.consume_temp(temp);
|
||||
} else {
|
||||
let mut life_lock = queue.lock_life();
|
||||
let last_submit_index = life_lock.get_blas_latest_submission_index(self);
|
||||
if let Some(last_submit_index) = last_submit_index {
|
||||
life_lock.schedule_resource_destruction(temp, last_submit_index);
|
||||
}
|
||||
let mut life_lock = queue.lock_life();
|
||||
let last_submit_index = life_lock.get_blas_latest_submission_index(self);
|
||||
if let Some(last_submit_index) = last_submit_index {
|
||||
life_lock.schedule_resource_destruction(temp, last_submit_index);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2054,15 +2049,10 @@ impl Tlas {
|
||||
};
|
||||
|
||||
if let Some(queue) = device.get_queue() {
|
||||
let mut pending_writes = queue.pending_writes.lock();
|
||||
if pending_writes.contains_tlas(self) {
|
||||
pending_writes.consume_temp(temp);
|
||||
} else {
|
||||
let mut life_lock = queue.lock_life();
|
||||
let last_submit_index = life_lock.get_tlas_latest_submission_index(self);
|
||||
if let Some(last_submit_index) = last_submit_index {
|
||||
life_lock.schedule_resource_destruction(temp, last_submit_index);
|
||||
}
|
||||
let mut life_lock = queue.lock_life();
|
||||
let last_submit_index = life_lock.get_tlas_latest_submission_index(self);
|
||||
if let Some(last_submit_index) = last_submit_index {
|
||||
life_lock.schedule_resource_destruction(temp, last_submit_index);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user