mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-21 22:33:49 +00:00
use StatelessTracker
for acceleration structures
This commit is contained in:
parent
d997d40fd5
commit
4f6f855335
@ -225,7 +225,7 @@ impl Global {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let tlas = hub.tlas_s.get(entry.tlas_id).get()?;
|
let tlas = hub.tlas_s.get(entry.tlas_id).get()?;
|
||||||
cmd_buf_data.trackers.tlas_s.set_single(tlas.clone());
|
cmd_buf_data.trackers.tlas_s.insert_single(tlas.clone());
|
||||||
|
|
||||||
cmd_buf_data.tlas_actions.push(TlasAction {
|
cmd_buf_data.tlas_actions.push(TlasAction {
|
||||||
tlas: tlas.clone(),
|
tlas: tlas.clone(),
|
||||||
@ -483,7 +483,7 @@ impl Global {
|
|||||||
for package in tlas_iter {
|
for package in tlas_iter {
|
||||||
let tlas = hub.tlas_s.get(package.tlas_id).get()?;
|
let tlas = hub.tlas_s.get(package.tlas_id).get()?;
|
||||||
|
|
||||||
cmd_buf_data.trackers.tlas_s.set_single(tlas.clone());
|
cmd_buf_data.trackers.tlas_s.insert_single(tlas.clone());
|
||||||
|
|
||||||
tlas_lock_store.push((Some(package), tlas))
|
tlas_lock_store.push((Some(package), tlas))
|
||||||
}
|
}
|
||||||
@ -514,7 +514,7 @@ impl Global {
|
|||||||
}
|
}
|
||||||
let blas = hub.blas_s.get(instance.blas_id).get()?;
|
let blas = hub.blas_s.get(instance.blas_id).get()?;
|
||||||
|
|
||||||
cmd_buf_data.trackers.blas_s.set_single(blas.clone());
|
cmd_buf_data.trackers.blas_s.insert_single(blas.clone());
|
||||||
|
|
||||||
instance_buffer_staging_source.extend(tlas_instance_into_bytes(
|
instance_buffer_staging_source.extend(tlas_instance_into_bytes(
|
||||||
&instance,
|
&instance,
|
||||||
@ -795,7 +795,7 @@ fn iter_blas<'a>(
|
|||||||
let mut temp_buffer = Vec::new();
|
let mut temp_buffer = Vec::new();
|
||||||
for entry in blas_iter {
|
for entry in blas_iter {
|
||||||
let blas = hub.blas_s.get(entry.blas_id).get()?;
|
let blas = hub.blas_s.get(entry.blas_id).get()?;
|
||||||
cmd_buf_data.trackers.blas_s.set_single(blas.clone());
|
cmd_buf_data.trackers.blas_s.insert_single(blas.clone());
|
||||||
|
|
||||||
cmd_buf_data.blas_actions.push(BlasAction {
|
cmd_buf_data.blas_actions.push(BlasAction {
|
||||||
blas: blas.clone(),
|
blas: blas.clone(),
|
||||||
|
@ -98,7 +98,6 @@ Device <- CommandBuffer = insert(device.start, device.end, buffer.start, buffer.
|
|||||||
mod buffer;
|
mod buffer;
|
||||||
mod metadata;
|
mod metadata;
|
||||||
mod range;
|
mod range;
|
||||||
mod ray_tracing;
|
|
||||||
mod stateless;
|
mod stateless;
|
||||||
mod texture;
|
mod texture;
|
||||||
|
|
||||||
@ -113,7 +112,6 @@ use crate::{
|
|||||||
use std::{fmt, ops, sync::Arc};
|
use std::{fmt, ops, sync::Arc};
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
use crate::track::ray_tracing::AccelerationStructureTracker;
|
|
||||||
pub(crate) use buffer::{
|
pub(crate) use buffer::{
|
||||||
BufferBindGroupState, BufferTracker, BufferUsageScope, DeviceBufferTracker,
|
BufferBindGroupState, BufferTracker, BufferUsageScope, DeviceBufferTracker,
|
||||||
};
|
};
|
||||||
@ -602,8 +600,8 @@ impl DeviceTracker {
|
|||||||
pub(crate) struct Tracker {
|
pub(crate) struct Tracker {
|
||||||
pub buffers: BufferTracker,
|
pub buffers: BufferTracker,
|
||||||
pub textures: TextureTracker,
|
pub textures: TextureTracker,
|
||||||
pub blas_s: AccelerationStructureTracker<resource::Blas>,
|
pub blas_s: StatelessTracker<resource::Blas>,
|
||||||
pub tlas_s: AccelerationStructureTracker<resource::Tlas>,
|
pub tlas_s: StatelessTracker<resource::Tlas>,
|
||||||
pub views: StatelessTracker<resource::TextureView>,
|
pub views: StatelessTracker<resource::TextureView>,
|
||||||
pub bind_groups: StatelessTracker<binding_model::BindGroup>,
|
pub bind_groups: StatelessTracker<binding_model::BindGroup>,
|
||||||
pub compute_pipelines: StatelessTracker<pipeline::ComputePipeline>,
|
pub compute_pipelines: StatelessTracker<pipeline::ComputePipeline>,
|
||||||
@ -617,8 +615,8 @@ impl Tracker {
|
|||||||
Self {
|
Self {
|
||||||
buffers: BufferTracker::new(),
|
buffers: BufferTracker::new(),
|
||||||
textures: TextureTracker::new(),
|
textures: TextureTracker::new(),
|
||||||
blas_s: AccelerationStructureTracker::new(),
|
blas_s: StatelessTracker::new(),
|
||||||
tlas_s: AccelerationStructureTracker::new(),
|
tlas_s: StatelessTracker::new(),
|
||||||
views: StatelessTracker::new(),
|
views: StatelessTracker::new(),
|
||||||
bind_groups: StatelessTracker::new(),
|
bind_groups: StatelessTracker::new(),
|
||||||
compute_pipelines: StatelessTracker::new(),
|
compute_pipelines: StatelessTracker::new(),
|
||||||
|
@ -1,75 +0,0 @@
|
|||||||
use crate::resource::AccelerationStructure;
|
|
||||||
use crate::track::metadata::ResourceMetadata;
|
|
||||||
use crate::track::ResourceUses;
|
|
||||||
use hal::AccelerationStructureUses;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use wgt::strict_assert;
|
|
||||||
|
|
||||||
pub(crate) struct AccelerationStructureTracker<T: AccelerationStructure> {
|
|
||||||
start: Vec<AccelerationStructureUses>,
|
|
||||||
end: Vec<AccelerationStructureUses>,
|
|
||||||
|
|
||||||
metadata: ResourceMetadata<Arc<T>>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T: AccelerationStructure> AccelerationStructureTracker<T> {
|
|
||||||
pub fn new() -> Self {
|
|
||||||
Self {
|
|
||||||
start: Vec::new(),
|
|
||||||
end: Vec::new(),
|
|
||||||
|
|
||||||
metadata: ResourceMetadata::new(),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn tracker_assert_in_bounds(&self, index: usize) {
|
|
||||||
strict_assert!(index < self.start.len());
|
|
||||||
strict_assert!(index < self.end.len());
|
|
||||||
self.metadata.tracker_assert_in_bounds(index);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Sets the size of all the vectors inside the tracker.
|
|
||||||
///
|
|
||||||
/// Must be called with the highest possible Buffer ID before
|
|
||||||
/// all unsafe functions are called.
|
|
||||||
pub fn set_size(&mut self, size: usize) {
|
|
||||||
self.start.resize(size, AccelerationStructureUses::empty());
|
|
||||||
self.end.resize(size, AccelerationStructureUses::empty());
|
|
||||||
|
|
||||||
self.metadata.set_size(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Extend the vectors to let the given index be valid.
|
|
||||||
fn allow_index(&mut self, index: usize) {
|
|
||||||
if index >= self.start.len() {
|
|
||||||
self.set_size(index + 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Inserts a single resource into the resource tracker.
|
|
||||||
pub fn set_single(&mut self, resource: Arc<T>) {
|
|
||||||
let index: usize = resource.tracker_index().as_usize();
|
|
||||||
|
|
||||||
self.allow_index(index);
|
|
||||||
|
|
||||||
self.tracker_assert_in_bounds(index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ResourceUses for AccelerationStructureUses {
|
|
||||||
const EXCLUSIVE: Self = Self::empty();
|
|
||||||
|
|
||||||
type Selector = ();
|
|
||||||
|
|
||||||
fn bits(self) -> u16 {
|
|
||||||
Self::bits(&self) as u16
|
|
||||||
}
|
|
||||||
|
|
||||||
fn all_ordered(self) -> bool {
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
fn any_exclusive(self) -> bool {
|
|
||||||
self.intersects(Self::EXCLUSIVE)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user