it starts at least
This commit is contained in:
@@ -103,6 +103,7 @@ impl RaytracingSceneBindings {
|
||||
&mut self.instances.vertex_buffers.dirty,
|
||||
&mut self.instances.index_buffers.dirty,
|
||||
&mut self.instances.aabb_buffers.dirty,
|
||||
&mut self.instances.tape_metadata_buffers.dirty,
|
||||
&mut self.assets.textures.dirty,
|
||||
] {
|
||||
invalid |= core::mem::replace(dirty, false);
|
||||
@@ -150,6 +151,7 @@ impl RaytracingSceneBindings {
|
||||
let vertex_buffers = buffer_bindings(&self.instances.vertex_buffers, dummy);
|
||||
let index_buffers = buffer_bindings(&self.instances.index_buffers, dummy);
|
||||
let aabb_buffers = buffer_bindings(&self.instances.aabb_buffers, dummy);
|
||||
let tape_metadata_buffers = buffer_bindings(&self.instances.tape_metadata_buffers, dummy);
|
||||
|
||||
let (mut textures, mut samplers): (Vec<_>, Vec<_>) = self
|
||||
.assets
|
||||
@@ -238,6 +240,7 @@ impl RaytracingSceneBindings {
|
||||
vertex_buffers.as_slice(),
|
||||
index_buffers.as_slice(),
|
||||
aabb_buffers.as_slice(),
|
||||
tape_metadata_buffers.as_slice(),
|
||||
textures.as_slice(),
|
||||
samplers.as_slice(),
|
||||
materials,
|
||||
|
||||
@@ -44,9 +44,11 @@ pub struct GpuInstanceGeometryIds {
|
||||
#[derive(Clone, Copy, Default, PartialEq, Pod, Zeroable)]
|
||||
#[repr(C)]
|
||||
pub struct GpuInstanceTapeIds {
|
||||
aabb_buffer_id: u32,
|
||||
aabb_buffer_offset: u32,
|
||||
aabb_count: u32,
|
||||
aabb_buffer_id: u32,
|
||||
aabb_buffer_offset: u32,
|
||||
aabb_count: u32,
|
||||
metadata_buffer_id: u32,
|
||||
metadata_buffer_offset: u32,
|
||||
}
|
||||
|
||||
/// A world-from-local affine transform, stored transposed as three rows.
|
||||
@@ -103,6 +105,7 @@ pub struct InstanceState {
|
||||
pub vertex_buffers: RetainedBindingArray<BufferId, Buffer>,
|
||||
pub index_buffers: RetainedBindingArray<BufferId, Buffer>,
|
||||
pub aabb_buffers: RetainedBindingArray<BufferId, Buffer>,
|
||||
pub tape_metadata_buffers: RetainedBindingArray<BufferId, Buffer>,
|
||||
pub transforms: AtomicSparseBufferVec<GpuTransform>,
|
||||
pub previous_frame_transforms: AtomicSparseBufferVec<GpuTransform>,
|
||||
pub geometry_ids: AtomicSparseBufferVec<GpuInstanceGeometryIds>,
|
||||
@@ -123,6 +126,7 @@ impl InstanceState {
|
||||
vertex_buffers: RetainedBindingArray::new(),
|
||||
index_buffers: RetainedBindingArray::new(),
|
||||
aabb_buffers: RetainedBindingArray::new(),
|
||||
tape_metadata_buffers: RetainedBindingArray::new(),
|
||||
transforms: storage_buffer("solari_transforms"),
|
||||
previous_frame_transforms: storage_buffer("solari_previous_frame_transforms"),
|
||||
geometry_ids: storage_buffer("solari_geometry_ids"),
|
||||
@@ -467,20 +471,32 @@ impl InstanceState {
|
||||
tape_id: AssetId<Tape>,
|
||||
instance: &mut Instance,
|
||||
) -> bool {
|
||||
bevy_log::debug!("Resolving tape instance {tape_id}");
|
||||
bevy_log::info!("Resolving tape instance {tape_id}");
|
||||
let slot = instance.slot;
|
||||
let (Some(aabb_slice), Some(material_slot), Some(blas_address)) = (
|
||||
let (Some(aabb_slice), Some(metadata_slice), Some(material_slot), Some(blas_address)) = (
|
||||
inputs.tape_allocator.tape_aabb_slice(&tape_id),
|
||||
inputs.tape_allocator.tape_metadata_slice(&tape_id),
|
||||
inputs.assets.material_slots.get(&instance.material),
|
||||
inputs.tape_blas_manager.device_address(&tape_id),
|
||||
) else {
|
||||
bevy_log::info!("Deactivating tape instance {tape_id}");
|
||||
self.deactivate_instance(lights, entity, instance);
|
||||
return false;
|
||||
};
|
||||
|
||||
bevy_log::info!("Tape {tape_id} aabb_slice: {:?}", aabb_slice.range);
|
||||
bevy_log::info!("Tape {tape_id} metadata_slice: {:?}", metadata_slice.range);
|
||||
bevy_log::info!("Tape {tape_id} material_slot: {material_slot}");
|
||||
bevy_log::info!("Tape {tape_id} blas_address: {blas_address}");
|
||||
|
||||
let aabb_buffer_key = aabb_slice.buffer.id();
|
||||
let metadata_buffer_key = metadata_slice.buffer.id();
|
||||
let capacity = MAX_TAPE_SLAB_COUNT.get();
|
||||
if !self.aabb_buffers.has_room(&aabb_buffer_key, capacity) {
|
||||
if !self.aabb_buffers.has_room(&aabb_buffer_key, capacity)
|
||||
|| !self
|
||||
.tape_metadata_buffers
|
||||
.has_room(&metadata_buffer_key, capacity)
|
||||
{
|
||||
once!(warn!(
|
||||
"Solari scene needs more than {} tape slabs. Instances past that limit will not \
|
||||
be rendered.",
|
||||
@@ -495,7 +511,13 @@ impl InstanceState {
|
||||
.aabb_buffers
|
||||
.acquire(aabb_buffer_key, capacity, || aabb_slice.buffer.clone())
|
||||
.expect("aabb slab binding array had room but handed out no slot");
|
||||
instance.buffers = Some((aabb_buffer_key, aabb_buffer_key));
|
||||
let metadata_buffer_id = self
|
||||
.tape_metadata_buffers
|
||||
.acquire(metadata_buffer_key, capacity, || {
|
||||
metadata_slice.buffer.clone()
|
||||
})
|
||||
.expect("tape metadata slab binding array had room but handed out no slot");
|
||||
instance.buffers = Some((aabb_buffer_key, metadata_buffer_key));
|
||||
self.release_tape_buffers(previous_buffers);
|
||||
|
||||
let aabb_count = (aabb_slice.range.len()) as u32;
|
||||
@@ -505,6 +527,8 @@ impl InstanceState {
|
||||
aabb_buffer_id,
|
||||
aabb_buffer_offset: aabb_slice.range.start,
|
||||
aabb_count,
|
||||
metadata_buffer_id,
|
||||
metadata_buffer_offset: metadata_slice.range.start,
|
||||
},
|
||||
);
|
||||
self.material_ids.grow_and_set(slot, material_slot);
|
||||
@@ -525,6 +549,8 @@ impl InstanceState {
|
||||
}
|
||||
*/
|
||||
|
||||
bevy_log::info!("Tape {tape_id} resolved");
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
@@ -583,8 +609,9 @@ impl InstanceState {
|
||||
}
|
||||
|
||||
fn release_tape_buffers(&mut self, buffers: Option<(BufferId, BufferId)>) {
|
||||
if let Some((aabb_key, _)) = buffers {
|
||||
if let Some((aabb_key, metadata_key)) = buffers {
|
||||
self.aabb_buffers.release(&aabb_key);
|
||||
self.tape_metadata_buffers.release(&metadata_key);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ use super::{
|
||||
RaytracingMesh3d, Tape3d, extract::StandardMaterialAssets,
|
||||
meshes::blas::BlasManager as MeshBlasManager, tapes::blas::BlasManager as TapeBlasManager,
|
||||
};
|
||||
use crate::scene::binder::instances::MAX_TAPE_SLAB_COUNT;
|
||||
|
||||
/// Insert this resource into the render world to make the raytracing scene
|
||||
/// retain the previous frame's TLAS and the light id translation table that
|
||||
@@ -86,7 +87,8 @@ impl FromWorld for RaytracingSceneBindings {
|
||||
(
|
||||
storage_buffer_read_only_sized(false, None).count(MAX_MESH_SLAB_COUNT),
|
||||
storage_buffer_read_only_sized(false, None).count(MAX_MESH_SLAB_COUNT),
|
||||
storage_buffer_read_only_sized(false, None).count(MAX_MESH_SLAB_COUNT),
|
||||
storage_buffer_read_only_sized(false, None).count(MAX_TAPE_SLAB_COUNT),
|
||||
storage_buffer_read_only_sized(false, None).count(MAX_TAPE_SLAB_COUNT),
|
||||
texture_2d(TextureSampleType::Float { filterable: true })
|
||||
.count(MAX_TEXTURE_COUNT),
|
||||
sampler(SamplerBindingType::Filtering).count(MAX_TEXTURE_COUNT),
|
||||
|
||||
Reference in New Issue
Block a user