From 2910314df31fe8cb5af1b83f88e8d01aeba5e2e8 Mon Sep 17 00:00:00 2001 From: Albin Chaboissier Date: Sun, 22 Nov 2026 17:12:21 +0100 Subject: [PATCH] chore: Removing warnings in all but main playground crate --- crates/vxls-bvh/src/debug.rs | 1 - crates/vxls-bvh/src/lib.rs | 3 +- crates/vxls-gpu/src/radix_sort.rs | 12 +- crates/vxls-production/src/request_queue.rs | 15 +- crates/vxls-production/src/sparse_tree.rs | 10 +- crates/vxls-production/tests/attributes.rs | 54 ++---- crates/vxls-profiler/src/lib.rs | 6 +- crates/vxls-profiler/src/memory_profiler.rs | 4 +- crates/vxls-terrain/src/lib.rs | 72 +------- crates/vxls-voxel-cache/src/eviction.rs | 12 +- crates/vxls-voxel-cache/src/insertion.rs | 79 +------- crates/vxls-voxel-cache/src/layout.rs | 189 -------------------- crates/vxls-voxel-cache/src/requests.rs | 24 ++- crates/vxls-voxel-cache/src/structure.rs | 5 +- crates/vxls-voxel-cache/src/tables.rs | 161 ++++++++--------- crates/vxls/src/main.rs | 12 +- 16 files changed, 136 insertions(+), 523 deletions(-) delete mode 100644 crates/vxls-voxel-cache/src/layout.rs diff --git a/crates/vxls-bvh/src/debug.rs b/crates/vxls-bvh/src/debug.rs index c3952d1..7b21631 100644 --- a/crates/vxls-bvh/src/debug.rs +++ b/crates/vxls-bvh/src/debug.rs @@ -1,7 +1,6 @@ //! Contains rendering code to display a debug overlay for the BVH. use glam::Mat4; -use wgpu::BlendState; // debug.wgsl mirrors the GPU structs manually. Keep the array strides in sync: // WGSL rounds structs containing vec3 up to a 16-byte alignment, so a node's diff --git a/crates/vxls-bvh/src/lib.rs b/crates/vxls-bvh/src/lib.rs index 13a39f0..5dd7694 100644 --- a/crates/vxls-bvh/src/lib.rs +++ b/crates/vxls-bvh/src/lib.rs @@ -1,3 +1,4 @@ +#![allow(incomplete_features)] #![feature(generic_const_exprs)] //! This is an implementation of a BVH2 as a top level ray acceleration @@ -14,9 +15,9 @@ use crate::build::BvhPrimitive; use crate::build::build_bvh; use crate::gpu::GpuBvhNode; use crate::gpu::GpuObject; -use vxls_profiler::ScopeEncoder; use vxls_production::ProducerId; use vxls_production::StructureAnchor; +use vxls_profiler::ScopeEncoder; use vxls_voxel_cache::CacheInvalidable; use vxls_voxel_cache::eviction::CacheEvictor; use vxls_voxel_cache::insertion::CacheInsertionData; diff --git a/crates/vxls-gpu/src/radix_sort.rs b/crates/vxls-gpu/src/radix_sort.rs index a6dfa20..94759e2 100644 --- a/crates/vxls-gpu/src/radix_sort.rs +++ b/crates/vxls-gpu/src/radix_sort.rs @@ -1,18 +1,12 @@ -use std::num::NonZero; - -use itertools::Itertools; use wgpu::BindGroup; use wgpu::BindGroupLayout; use wgpu::Buffer; use wgpu::BufferUsages; use wgpu::CommandEncoder; -use wgpu::ComputePass; use wgpu::ComputePipeline; use wgpu::Device; use wgpu::QuerySet; -use wgpu::ShaderStages; use wgpu::include_spirv; -use wgpu::util::DeviceExt; #[derive(Clone, Copy, PartialEq, Eq)] pub enum RadixSortDirection @@ -34,14 +28,16 @@ pub struct RadixSorter { max_size: usize, histogram_count: usize, - histo_block_count: usize, + #[allow(unused)] histograms: Buffer, histograms_bind_group: BindGroup, data_bind_group_layout: BindGroupLayout, + #[allow(unused)] double_buffer_keys: Buffer, + #[allow(unused)] double_buffer_values: Buffer, double_buffer_bind_group: BindGroup, @@ -294,7 +290,6 @@ impl RadixSorter RadixSorter { max_size, - histo_block_count, histogram_count, histograms, histograms_bind_group, @@ -325,6 +320,7 @@ impl RadixSorter /// An indirect count can be passed in `indirect` as a buffer of a single u32 on GPU. /// A CPU side length can be passed in `direct_length` /// `sort_direction` dictates the direction of the sort. + #[allow(clippy::too_many_arguments)] pub fn sort( &self, device: &Device, diff --git a/crates/vxls-production/src/request_queue.rs b/crates/vxls-production/src/request_queue.rs index e06b46b..07bc026 100644 --- a/crates/vxls-production/src/request_queue.rs +++ b/crates/vxls-production/src/request_queue.rs @@ -171,12 +171,7 @@ impl IncomingRequest else { ( - RequestKey::child( - producer_id, - anchor, - request.node_id, - request.children_index, - ), + RequestKey::child(producer_id, anchor, request.node_id, request.children_index), RequestPriority::child(request.demand, meta.depth), ) }; @@ -616,12 +611,10 @@ impl RequestQueue // necessary; the failed job is already admitted, so it is not dropped // just because the queued bound was reached while it was in flight. if self.queued.len() >= self.config.max_queued + && let Some(victim) = self.queued.first().copied() { - if let Some(victim) = self.queued.first().copied() - { - self.remove_job(&victim.key); - self.stats.total_evicted += 1; - } + self.remove_job(&victim.key); + self.stats.total_evicted += 1; } let job = self diff --git a/crates/vxls-production/src/sparse_tree.rs b/crates/vxls-production/src/sparse_tree.rs index d532dae..9cbca27 100644 --- a/crates/vxls-production/src/sparse_tree.rs +++ b/crates/vxls-production/src/sparse_tree.rs @@ -115,12 +115,6 @@ pub struct NTree depth: usize, } -pub struct NTreeIter<'a, const N: usize, T: Attribute> -{ - tree: &'a NTree, - dfs_stack: Vec>, -} - #[derive(Debug, Clone, Copy)] pub struct NTreeNode { @@ -478,7 +472,7 @@ fn base_trailing_zeroes(mut number: usize) -> Option return None; } let mut trailing_zeroes = 0; - while number % N == 0 + while number.is_multiple_of(N) { number /= N; trailing_zeroes += 1; @@ -511,7 +505,9 @@ where mod test { + #[allow(unused_imports)] use crate::sparse_tree::Color; + #[allow(unused_imports)] use crate::sparse_tree::NTree; #[test] diff --git a/crates/vxls-production/tests/attributes.rs b/crates/vxls-production/tests/attributes.rs index 912f6c5..fd34c03 100644 --- a/crates/vxls-production/tests/attributes.rs +++ b/crates/vxls-production/tests/attributes.rs @@ -9,9 +9,6 @@ use vxls_production::Attributes; use vxls_production::AttributesLayout; use vxls_production::LayoutError; use vxls_production::ProducedNode; -use vxls_voxel_cache::CacheAttribute; -use vxls_voxel_cache::CacheAttributeInit; -use vxls_voxel_cache::CacheLayout; use vxls_voxel_cache::schema::ChildInformation; use vxls_voxel_cache::schema::InsertionInformation; @@ -72,7 +69,9 @@ fn get_attr_returns_the_field_bytes() assert!(value.try_get_attr(2).is_none()); let mut value = value; - value.get_attr_mut(0).copy_from_slice(&0xAABB_CCDDu32.to_ne_bytes()); + value + .get_attr_mut(0) + .copy_from_slice(&0xAABB_CCDDu32.to_ne_bytes()); assert_eq!(value.color, 0xAABB_CCDD); assert!(value.try_get_attr_mut(2).is_none()); } @@ -100,38 +99,6 @@ fn average_is_component_wise_and_skips_the_reserved_field() assert_eq!(TestAttributes::average(&[]), TestAttributes::default()); } -#[test] -fn cache_layout_starts_with_external_attributes_then_extras() -{ - let layout = CacheLayout::from_attributes( - &TestAttributes::LAYOUT, - &[CacheAttribute { - label: Some("gi"), - word_count: 2, - init: CacheAttributeInit::DontTouch, - }], - ); - - let attributes = layout.attributes(); - - assert_eq!(attributes.len(), 3); - assert_eq!(attributes[0].label, Some("color")); - assert_eq!(attributes[0].word_count, 1); - assert_eq!(attributes[0].init, CacheAttributeInit::External); - assert_eq!(attributes[1].label, Some("normal")); - assert_eq!(attributes[1].word_count, 3); - assert_eq!(attributes[2].label, Some("gi")); - assert_eq!(attributes[2].word_count, 2); - assert_eq!(attributes[2].init, CacheAttributeInit::DontTouch); - - assert_eq!( - CacheLayout::from_attributes(&TestAttributes::LAYOUT, &[]) - .attributes() - .len(), - 2 - ); -} - #[test] fn validate_rejects_duplicate_labels_and_semantics() { @@ -152,7 +119,10 @@ fn validate_rejects_duplicate_labels_and_semantics() assert_eq!( DUPLICATE_LABELS.validate(), - Err(LayoutError::DuplicateLabel { first: 0, second: 1 }) + Err(LayoutError::DuplicateLabel { + first: 0, + second: 1 + }) ); const DUPLICATE_SEMANTICS: AttributesLayout = AttributesLayout { @@ -164,7 +134,10 @@ fn validate_rejects_duplicate_labels_and_semantics() assert_eq!( DUPLICATE_SEMANTICS.validate(), - Err(LayoutError::DuplicateSemantic { first: 0, second: 1 }) + Err(LayoutError::DuplicateSemantic { + first: 0, + second: 1 + }) ); assert_eq!(AttributesLayout::EMPTY.validate(), Err(LayoutError::Empty)); @@ -190,10 +163,7 @@ fn produced_node_transposes_attributes_for_the_insertion_buffer() node.write_attribute_words(1, &mut words); assert_eq!(words.len(), 64 * 3); - assert_eq!( - &words[..3], - bytemuck::cast_slice::(&value.normal) - ); + assert_eq!(&words[..3], bytemuck::cast_slice::(&value.normal)); node.write_attribute_words(0, &mut words); assert_eq!(words.len(), 64); diff --git a/crates/vxls-profiler/src/lib.rs b/crates/vxls-profiler/src/lib.rs index fab50ee..21341e2 100644 --- a/crates/vxls-profiler/src/lib.rs +++ b/crates/vxls-profiler/src/lib.rs @@ -598,7 +598,9 @@ impl Profile let fspan = full.1 - full.0; let norm: (f64, f64) = ui.data_mut(|d| d.get_temp(id)).unwrap_or((0.0, 1.0)); let mut view = (full.0 + norm.0 * fspan, full.0 + norm.1 * fspan); - if !(view.1 > view.0) || !view.0.is_finite() || !view.1.is_finite() + if !(egui::emath::OrderedFloat(view.1) > egui::emath::OrderedFloat(view.0)) + || !view.0.is_finite() + || !view.1.is_finite() { view = full; } @@ -668,7 +670,7 @@ impl Profile { hovered = Some(i); } - let mut color = color_for(&s.name); + let mut color = color_for(s.name); if is_hovered { color = color.gamma_multiply(1.15); diff --git a/crates/vxls-profiler/src/memory_profiler.rs b/crates/vxls-profiler/src/memory_profiler.rs index da346a3..a8aa738 100644 --- a/crates/vxls-profiler/src/memory_profiler.rs +++ b/crates/vxls-profiler/src/memory_profiler.rs @@ -120,7 +120,7 @@ impl MemoryProfile } } - pub fn begin(&mut self, device: &wgpu::Device) -> Device + pub fn begin(&mut self, device: &wgpu::Device) -> Device<'_> { Device { device: device.clone(), @@ -195,7 +195,7 @@ impl Group } // Print subgroups - for (i, group) in self.sub_groups.iter().enumerate() + for group in self.sub_groups.iter() { group.fmt_with_indent(f, indent + 1)?; } diff --git a/crates/vxls-terrain/src/lib.rs b/crates/vxls-terrain/src/lib.rs index 0374ee5..2f591a8 100644 --- a/crates/vxls-terrain/src/lib.rs +++ b/crates/vxls-terrain/src/lib.rs @@ -1,7 +1,6 @@ +#![allow(incomplete_features)] #![feature(generic_const_exprs)] -use std::iter::FusedIterator; - use bytemuck::Pod; use bytemuck::Zeroable; use glam::Vec3; @@ -9,7 +8,6 @@ use wgpu::CommandEncoder; use wgpu::include_wgsl; use vxls_gpu::create_multi_buffers_bind_group_layout; -use vxls_voxel_cache; use vxls_voxel_cache::schema::StructureAnchor; use vxls_voxel_cache::tables::FixedStructureTable; @@ -282,7 +280,8 @@ where device: &wgpu::Device, encoder: &mut vxls_profiler::ScopeEncoder, insertion: &vxls_voxel_cache::insertion::CacheInsertionData, - ) { + ) + { self.fixed_structure_table .validate_insertion(device, encoder, insertion); } @@ -298,68 +297,3 @@ where .invalidate(encoder, cache_evictor, invalid_timestamp); } } - -pub struct CenterChunkIter -{ - center_chunk: (isize, isize, isize), - extent: (usize, usize, usize), - block_corner: (isize, isize, isize), - current: usize, - length: usize, -} - -impl CenterChunkIter -{ - pub fn new(center_chunk: (isize, isize, isize), extent: (usize, usize, usize)) -> Self - { - let half_extent = (extent.0 / 2, extent.1 / 2, extent.2 / 2); - let block_corner = ( - center_chunk.0 - half_extent.0 as isize, - center_chunk.1 - half_extent.1 as isize, - center_chunk.2 - half_extent.2 as isize, - ); - - Self { - center_chunk, - extent, - block_corner, - current: 0, - length: extent.0 * extent.1 * extent.2, - } - } -} - -impl FusedIterator for CenterChunkIter {} -impl ExactSizeIterator for CenterChunkIter {} - -impl Iterator for CenterChunkIter -{ - type Item = (isize, isize, isize); - - fn next(&mut self) -> Option - { - if self.current >= self.length - { - None - } - else - { - let x = self.current % self.extent.0; - let y = (self.current / self.extent.0) % self.extent.1; - let z = self.current / (self.extent.0 * self.extent.1); - self.current += 1; - - Some(( - x as isize + self.block_corner.0, - y as isize + self.block_corner.1, - z as isize + self.block_corner.2, - )) - } - } - - fn size_hint(&self) -> (usize, Option) - { - let remaining = self.length - self.current; - (remaining, Some(remaining)) - } -} diff --git a/crates/vxls-voxel-cache/src/eviction.rs b/crates/vxls-voxel-cache/src/eviction.rs index c38f772..1d9911d 100644 --- a/crates/vxls-voxel-cache/src/eviction.rs +++ b/crates/vxls-voxel-cache/src/eviction.rs @@ -2,18 +2,16 @@ use wgpu::BindGroup; use wgpu::BindGroupLayout; use wgpu::CommandEncoder; -use wgpu::ComputePipeline; use wgpu::include_wgsl; -use wgpu::util::DeviceExt; +use crate::CacheRessources; +use crate::create_multi_buffers_bind_group_layout; +use crate::structure::CacheStructure; use vxls_gpu::create_multi_buffers_bind_group; use vxls_gpu::radix_sort; use vxls_profiler::ScopeEncoder; use vxls_profiler::memory_profiler; use vxls_profiler::{self}; -use crate::CacheRessources; -use crate::create_multi_buffers_bind_group_layout; -use crate::structure::CacheStructure; /// Retains usage information about pages in the cache under the form of timestamps. /// Produces an eviction order from which the cache can pull pages to recycle. @@ -34,6 +32,7 @@ pub struct CacheEvictor lru_list: wgpu::Buffer, /// When reusing pages, count of lru pages consumed + #[allow(unused)] consumed_count: wgpu::Buffer, /// To reset lru indices between insertions @@ -44,6 +43,7 @@ pub struct CacheEvictor pipelines_dispatch_count: u32, // For external passes + #[allow(unused)] bind_group_layout: BindGroupLayout, bind_group: BindGroup, } @@ -128,7 +128,7 @@ impl CacheEvictor } } - pub fn prepare_eviction_list( + pub(crate) fn prepare_eviction_list( &self, device: &wgpu::Device, ressources: &CacheRessources, diff --git a/crates/vxls-voxel-cache/src/insertion.rs b/crates/vxls-voxel-cache/src/insertion.rs index 629fea2..4852b03 100644 --- a/crates/vxls-voxel-cache/src/insertion.rs +++ b/crates/vxls-voxel-cache/src/insertion.rs @@ -47,6 +47,7 @@ where /// Amount of entries written to [`Self::valid_indices`] valid_count: wgpu::Buffer, + #[allow(unused)] bind_group_layout: wgpu::BindGroupLayout, bind_group: wgpu::BindGroup, bind_group_no_attributes: wgpu::BindGroup, @@ -119,7 +120,7 @@ pub fn validate_voxel_count( capacity: usize, ) -> Result<(), AttributeUploadError> { - if voxel_count % children != 0 + if !voxel_count.is_multiple_of(children) { return Err(AttributeUploadError::NotWholePages { voxel_count, @@ -563,11 +564,6 @@ mod tests } } - fn cache_layout() -> CacheLayout - { - CacheLayout::from_attributes(&TestAttributes::LAYOUT, &[]) - } - #[test] fn collect_attribute_bytes_orders_by_voxel() { @@ -597,77 +593,6 @@ mod tests ); } - #[test] - fn matching_layout_passes_validation() - { - assert_eq!( - validate_attribute_layout::(&cache_layout()), - Ok(()) - ); - } - - #[test] - fn validation_rejects_word_count_mismatch() - { - let mut layout = CacheLayout::default(); - layout.add_attribute(CacheAttribute { - label: Some("color"), - word_count: 2, - init: CacheAttributeInit::External, - }); - layout.add_attribute(CacheAttribute { - label: Some("normal"), - word_count: 3, - init: CacheAttributeInit::External, - }); - - assert_eq!( - validate_attribute_layout::(&layout), - Err(AttributeUploadError::WordCountMismatch { - index: 0, - producer: 1, - cache: 2, - }) - ); - } - - #[test] - fn validation_rejects_non_external_attributes() - { - let mut layout = CacheLayout::default(); - layout.add_attribute(CacheAttribute { - label: Some("color"), - word_count: 1, - init: CacheAttributeInit::DontTouch, - }); - layout.add_attribute(CacheAttribute { - label: Some("normal"), - word_count: 3, - init: CacheAttributeInit::External, - }); - - assert_eq!( - validate_attribute_layout::(&layout), - Err(AttributeUploadError::NotExternal { index: 0 }) - ); - } - - #[test] - fn validation_rejects_missing_attributes() - { - let mut layout = CacheLayout::default(); - layout.add_attribute(CacheAttribute { - label: Some("color"), - word_count: 1, - init: CacheAttributeInit::External, - }); - - assert_eq!( - validate_attribute_layout::(&layout), - Err(AttributeUploadError::MissingCacheAttribute { index: 1 }) - ); - } - #[test] fn voxel_counts_must_be_whole_pages_within_capacity() { diff --git a/crates/vxls-voxel-cache/src/layout.rs b/crates/vxls-voxel-cache/src/layout.rs deleted file mode 100644 index 22f291d..0000000 --- a/crates/vxls-voxel-cache/src/layout.rs +++ /dev/null @@ -1,189 +0,0 @@ -//! Depracted for now, DontTouch attributes will be re-added later -//! when necessary as another bunch of attributes, which allows cleaner separation -/* -use vxls_attributes::AttributesLayout; -use vxls_profiler::memory_profiler; - -/// Defines how a [`VoxelCache`]'s attribute is populated upon populating a page -#[derive(Clone, Copy, Debug, PartialEq, Eq)] -pub enum CacheAttributeInit -{ - /// Attribute is external : it is copied from the insertion operation - External, - - /// Attribute will not be touched by the cache mechanism. It is left to the discrecy of the - /// cache user. - /// - /// Some applications requires pieces of data into the resident data of the cache that are - /// computed on the fly : e.g. global illumination - DontTouch, -} - -/// Describes an attribute of a [`VoxelCache`] -#[derive(Clone, Copy, Debug)] -pub struct CacheAttribute -{ - pub label: Option<&'static str>, - pub word_count: u32, - pub init: CacheAttributeInit, -} - -impl CacheAttribute -{ - pub fn create_buffer_profiled( - &self, - device: &mut memory_profiler::Device, - child_count: usize, - page_count: usize, - usage: wgpu::BufferUsages, - ) -> wgpu::Buffer - { - device.create_buffer(&wgpu::BufferDescriptor { - label: Some( - format!( - "VoxelCacheAttribute ({}) {} word(s)", - self.label.unwrap_or("no-name"), - self.word_count - ) - .as_str(), - ), - size: (self.word_count as usize * page_count * child_count * size_of::()) as u64, - usage, - mapped_at_creation: false, - }) - } - - /// Creates the wgpu buffer necessary to store this attribute in the cache - pub fn create_buffer( - &self, - device: &wgpu::Device, - child_count: usize, - page_count: usize, - usage: wgpu::BufferUsages, - ) -> wgpu::Buffer - { - device.create_buffer(&wgpu::BufferDescriptor { - label: Some( - format!( - "VoxelCacheAttribute ({}) {} word(s)", - self.label.unwrap_or("no-name"), - self.word_count - ) - .as_str(), - ), - size: (self.word_count as usize * page_count * child_count * size_of::()) as u64, - usage, - mapped_at_creation: false, - }) - } -} - -#[derive(Clone, Default)] -pub struct CacheLayout -{ - pub(super) attributes: Vec, -} - -impl CacheLayout -{ - /// Adds a new [`VoxelCacheAttribute`] in the layout - /// - /// Attributes are added starting from 0 counting up - /// - /// Returns the index of the new added attirbute - pub fn add_attribute(&mut self, attribute: CacheAttribute) -> usize - { - let index = self.attributes.len(); - self.attributes.push(attribute); - index - } - - /// Builds a cache layout from producer attributes followed by `extra`. - /// - /// Every attribute of `layout` is inserted from the producer and is - /// therefore [`CacheAttributeInit::External`]. `extra` attributes are - /// appended after them and are meant for GPU-only data - /// ([`CacheAttributeInit::DontTouch`]), which producers never fill. - pub fn from_attributes(layout: &AttributesLayout, extra: &[CacheAttribute]) -> Self - { - let mut cache_layout = Self::default(); - - for attribute in layout.attributes - { - cache_layout.add_attribute(CacheAttribute { - label: Some(attribute.label), - word_count: attribute.word_count, - init: CacheAttributeInit::External, - }); - } - - for attribute in extra - { - cache_layout.add_attribute(*attribute); - } - - cache_layout - } - - /// The attributes of this layout, in binding order - pub fn attributes(&self) -> &[CacheAttribute] - { - &self.attributes - } - - /// Produces a wgsl declaration describing this layout : - /// - /// ```wgsl - /// - /// const ATTRIBUTE_COUNT: u32 = /* attribute count */; - /// const ATTRIBUTE_WORD_COUNTS: array = { - /// /* word count for attribute 0 */, - /// /* word count for attribute 1 */, - /// ... - /// }; - /// - /// const ATTRIBUTE_COPY: array = { - /// /* external? for attribute 0 */, - /// /* external? for attribute 1 */, - /// ... - /// }; - /// - /// ``` - pub fn wgsl_layout_decl(&self) -> String - { - let mut decl = String::new(); - - decl += &format!("const ATTRIBUTE_COUNT: u32 = {};", self.attributes.len()); - - // Word counts - decl += &format!( - "const ATTRIBUTE_WORD_COUNTS: array = array(", - self.attributes.len(), - self.attributes.len() - ); - - for attribute in self.attributes.iter() - { - decl += &format!(" {},", attribute.word_count); - } - - decl += ");"; - - // Copy - decl += &format!( - "const ATTRIBUTE_COPY: array = array(", - self.attributes.len(), - self.attributes.len() - ); - - for attribute in self.attributes.iter() - { - decl += &format!(" {},", attribute.init == CacheAttributeInit::External); - } - - decl += ");"; - - decl - } -} -*/ diff --git a/crates/vxls-voxel-cache/src/requests.rs b/crates/vxls-voxel-cache/src/requests.rs index 7e66bc4..6a81e84 100644 --- a/crates/vxls-voxel-cache/src/requests.rs +++ b/crates/vxls-voxel-cache/src/requests.rs @@ -9,6 +9,11 @@ use wgpu::Device; use wgpu::include_wgsl; use wgpu::util::DeviceExt; +use crate::CacheRessources; +use crate::create_multi_buffers_bg_bg_layout; +use crate::create_multi_buffers_bind_group_layout; +use crate::schema::RequestInformation; +use crate::schema::RequestMeta; use vxls_gpu::create_multi_buffers_bind_group; use vxls_gpu::indirect_buffer::IndirectBuffer1D; use vxls_gpu::radix_sort::{self}; @@ -16,11 +21,6 @@ use vxls_gpu::top_k::TopKSelector; use vxls_profiler::ScopeEncoder; use vxls_profiler::memory_profiler; use vxls_profiler::{self}; -use crate::CacheRessources; -use crate::create_multi_buffers_bg_bg_layout; -use crate::create_multi_buffers_bind_group_layout; -use crate::schema::RequestInformation; -use crate::schema::RequestMeta; /// Records, handles, and produces a list of requested data inside the cache pub struct CacheRequestHandler @@ -52,6 +52,7 @@ pub struct CacheRequestHandler reset_pass_dispatch: u32, // External bind group + #[allow(unused)] bind_group_layout: BindGroupLayout, bind_group: BindGroup, } @@ -70,6 +71,7 @@ pub struct CacheRequestBuffer /// Buffer containing the meta information about the requests, a dense array of [`voxel_cache::schema::RequestMeta`] request_meta: wgpu::Buffer, + #[allow(unused)] bind_group_layout: wgpu::BindGroupLayout, bind_group: wgpu::BindGroup, } @@ -203,7 +205,7 @@ impl CacheRequestHandler /// Uses both the sorter and the scratch buffer in the ressources /// /// The `request_count` buffer will contain the amount of request produced this time. - pub fn sort_requests( + pub(crate) fn sort_requests( &self, device: &wgpu::Device, ressources: &CacheRessources, @@ -443,8 +445,7 @@ impl CacheRequestBuffer &self.request_meta.slice(..), move |buffer| { let mapped_buffer = buffer.expect("Could not map request buffer (meta)."); - let request_metas: Vec = - bytemuck::pod_collect_to_vec(&mapped_buffer); + let request_metas: Vec = bytemuck::pod_collect_to_vec(&mapped_buffer); request_map_state_3 .lock() @@ -477,11 +478,8 @@ impl Re fn try_callback(&mut self) { - if let (Some(request_count), Some(request_infos), Some(request_metas)) = ( - self.request_count, - &self.request_infos, - &self.request_metas, - ) + if let (Some(request_count), Some(request_infos), Some(request_metas)) = + (self.request_count, &self.request_infos, &self.request_metas) { (self.callback)( &request_infos[0..request_count], diff --git a/crates/vxls-voxel-cache/src/structure.rs b/crates/vxls-voxel-cache/src/structure.rs index 5c5d39e..8173b3d 100644 --- a/crates/vxls-voxel-cache/src/structure.rs +++ b/crates/vxls-voxel-cache/src/structure.rs @@ -3,11 +3,11 @@ use wgpu::BindGroupLayout; use wgpu::Buffer; use wgpu::BufferUsages; +use crate::schema::DepthPage; +use crate::schema::StructurePage; use vxls_gpu::create_multi_buffers_bind_group; use vxls_gpu::create_multi_buffers_bind_group_layout; use vxls_profiler::memory_profiler; -use crate::schema::DepthPage; -use crate::schema::StructurePage; /// Contains the instanciated buffers relevant to the structure of the trees pub struct CacheStructure @@ -15,6 +15,7 @@ where [(); N * N * N]:, { pointer_pages: Buffer, + #[allow(unused)] location_pages: Buffer, depth_pages: Buffer, diff --git a/crates/vxls-voxel-cache/src/tables.rs b/crates/vxls-voxel-cache/src/tables.rs index 3d71e2a..76e5aee 100644 --- a/crates/vxls-voxel-cache/src/tables.rs +++ b/crates/vxls-voxel-cache/src/tables.rs @@ -1,11 +1,14 @@ +//! Cache keeps pages from different structures within itself. +//! Pages are pieces of structure pointing to each other. But, in order to start tracing inside the +//! voxels, we must enter the cache from somewhere +//! +//! The structure table is a structure that keeps information about where to find the root node +//! inside the cache, or if it is not preset, emit requests. + use std::collections::HashMap; use wgpu::util::DeviceExt; -use vxls_gpu::create_multi_buffers_bind_group; -use vxls_gpu::indirect_buffer::IndirectBuffer1D; -use vxls_profiler::ScopeEncoder; -use vxls_profiler::memory_profiler::MemoryProfile; use crate::CacheInvalidable; use crate::CacheRessources; use crate::create_multi_buffers_bg_bg_layout; @@ -15,14 +18,10 @@ use crate::requests::CacheRequestBuffer; use crate::requests::CacheRequestHandler; use crate::schema::CachePointer; use crate::schema::StructureAnchor; - -/// Cache keeps pages from different structures within itself. -/// Pages are pieces of structure pointing to each other. But, in order to start tracing inside the -/// voxels, we must enter the cache from somewhere -/// -/// The structure table is a structure that keeps information about where to find the root node -/// inside the cache, or if it is not preset, emit requests. -/// +use vxls_gpu::create_multi_buffers_bind_group; +use vxls_gpu::indirect_buffer::IndirectBuffer1D; +use vxls_profiler::ScopeEncoder; +use vxls_profiler::memory_profiler::MemoryProfile; macro_rules! include_table_wgsl { ($path:literal) => {{ @@ -265,12 +264,11 @@ impl StructureTableCore contents: bytemuck::cast_slice(initial_pointers), }); - let (metadata_bind_group_layout, metadata_bind_group) = - create_multi_buffers_bg_bg_layout( - device, - &[&anchors_buffer], - Some("StructureTableCore::metadata"), - ); + let (metadata_bind_group_layout, metadata_bind_group) = create_multi_buffers_bg_bg_layout( + device, + &[&anchors_buffer], + Some("StructureTableCore::metadata"), + ); let (pointers_bind_group_layout, pointers_bind_group) = create_multi_buffers_bg_bg_layout( device, @@ -714,12 +712,7 @@ impl FixedStructureTable /// Retained for callers that do not move slots; [`Self::new_with_anchors`] /// is the general constructor. #[allow(dead_code)] - pub fn new( - device: &wgpu::Device, - size: usize, - max_requests: usize, - producer_id: u32, - ) -> Self + pub fn new(device: &wgpu::Device, size: usize, max_requests: usize, producer_id: u32) -> Self { let anchors = (0..size) .map(|slot| StructureAnchor { @@ -741,9 +734,8 @@ impl FixedStructureTable assert_eq!(anchors.len(), size); let pointers = vec![CachePointer::new(Some(None)); size]; - let core = StructureTableCore::new( - device, size, max_requests, producer_id, &anchors, &pointers, - ); + let core = + StructureTableCore::new(device, size, max_requests, producer_id, &anchors, &pointers); Self { core, @@ -767,6 +759,7 @@ impl FixedStructureTable let retired = retired_anchors(&self.slot_anchors, new_anchors); + #[allow(clippy::needless_range_loop)] for slot in 0..self.core.size { let anchor = new_anchors[slot]; @@ -876,7 +869,12 @@ impl DynamicStructureTable let anchors = vec![StructureAnchor::ZERO; capacity]; let pointers = vec![CachePointer::new(None); capacity]; let core = StructureTableCore::new( - device, capacity, max_requests, producer_id, &anchors, &pointers, + device, + capacity, + max_requests, + producer_id, + &anchors, + &pointers, ); Self { @@ -922,12 +920,7 @@ impl DynamicStructureTable /// /// Capacity doubles from the current value until it reaches `min_capacity`. /// Must be called between frames. - pub fn reserve( - &mut self, - device: &wgpu::Device, - queue: &wgpu::Queue, - min_capacity: usize, - ) + pub fn reserve(&mut self, device: &wgpu::Device, queue: &wgpu::Queue, min_capacity: usize) { assert!( min_capacity <= u32::MAX as usize, @@ -1058,6 +1051,58 @@ impl DynamicStructureTable } } +impl CacheInvalidable for FixedStructureTable +where + [(); N * N * N]:, +{ + fn validate_insertion( + &mut self, + device: &wgpu::Device, + encoder: &mut ScopeEncoder, + insertion: &CacheInsertionData, + ) + { + self.core.validate_insertion(device, encoder, insertion); + } + + fn invalidate( + &mut self, + encoder: &mut ScopeEncoder, + cache_evictor: &CacheEvictor, + invalid_timestamp: u32, + ) + { + self.core + .invalidate(encoder, cache_evictor, invalid_timestamp); + } +} + +impl CacheInvalidable for DynamicStructureTable +where + [(); N * N * N]:, +{ + fn validate_insertion( + &mut self, + device: &wgpu::Device, + encoder: &mut ScopeEncoder, + insertion: &CacheInsertionData, + ) + { + self.core.validate_insertion(device, encoder, insertion); + } + + fn invalidate( + &mut self, + encoder: &mut ScopeEncoder, + cache_evictor: &CacheEvictor, + invalid_timestamp: u32, + ) + { + self.core + .invalidate(encoder, cache_evictor, invalid_timestamp); + } +} + #[cfg(test)] mod tests { @@ -1190,51 +1235,3 @@ mod tests assert_eq!(allocator.allocate(anchor(4)), None); } } - -impl CacheInvalidable for FixedStructureTable -where - [(); N * N * N]:, -{ - fn validate_insertion( - &mut self, - device: &wgpu::Device, - encoder: &mut ScopeEncoder, - insertion: &CacheInsertionData, - ) { - self.core.validate_insertion(device, encoder, insertion); - } - - fn invalidate( - &mut self, - encoder: &mut ScopeEncoder, - cache_evictor: &CacheEvictor, - invalid_timestamp: u32, - ) - { - self.core.invalidate(encoder, cache_evictor, invalid_timestamp); - } -} - -impl CacheInvalidable for DynamicStructureTable -where - [(); N * N * N]:, -{ - fn validate_insertion( - &mut self, - device: &wgpu::Device, - encoder: &mut ScopeEncoder, - insertion: &CacheInsertionData, - ) { - self.core.validate_insertion(device, encoder, insertion); - } - - fn invalidate( - &mut self, - encoder: &mut ScopeEncoder, - cache_evictor: &CacheEvictor, - invalid_timestamp: u32, - ) - { - self.core.invalidate(encoder, cache_evictor, invalid_timestamp); - } -} diff --git a/crates/vxls/src/main.rs b/crates/vxls/src/main.rs index 217bfe2..620c7f8 100644 --- a/crates/vxls/src/main.rs +++ b/crates/vxls/src/main.rs @@ -1,13 +1,11 @@ +#![allow(incomplete_features)] #![feature(generic_const_exprs)] #![feature(float_algebraic)] -use std::arch::x86_64; -use std::marker::PhantomData; use std::sync::Arc; use std::sync::atomic::AtomicBool; use std::sync::atomic::AtomicU32; use std::sync::mpsc::Sender; -use std::thread::Thread; use std::time::Instant; use bytemuck::Pod; @@ -22,12 +20,10 @@ use glam::Quat; use glam::Vec3; use glam::Vec4; use itertools::Itertools; -use rand::random_bool; use rand::random_range; use rayon::iter::IntoParallelRefIterator; use rayon::iter::ParallelIterator; use wgpu::BindGroupLayout; -use wgpu::Buffer; use wgpu::BufferUsages; use wgpu::ComputePipeline; use wgpu::Device; @@ -56,17 +52,13 @@ use winit::window::WindowId; use crate::camera::Camera; use crate::egui_renderer::EguiRenderer; -use crate::producers::ChunkedProducer; use crate::producers::SdfGenerator; -use crate::sparse_tree::Color; use crate::sparse_tree::NTree; -use crate::sparse_tree::NTreeNode; use crate::sparse_tree::load_ply; use vxls_bvh::BvhHandle; use vxls_bvh::BvhObject; use vxls_bvh::BvhStructureTable; use vxls_bvh::aabb::Aabb; -use vxls_bvh::build::Bvh; use vxls_bvh::debug::BvhDebugPipeline; use vxls_production::Attributes; use vxls_production::ProducerId; @@ -82,7 +74,6 @@ use vxls_production::tree_locator::TreeLocator; use vxls_profiler::Frame; use vxls_profiler::Profile; use vxls_profiler::ProfilingEncoder; -use vxls_terrain::ToroidalStructureTable; use vxls_voxel_cache::VoxelCache; use vxls_voxel_cache::VoxelCacheInsertion; use vxls_voxel_cache::insertion::CacheInsertionData; @@ -90,7 +81,6 @@ use vxls_voxel_cache::requests::CacheRequestBuffer; use vxls_voxel_cache::schema::ChildInformation; use vxls_voxel_cache::schema::InsertionInformation; use vxls_voxel_cache::schema::LocationPage; -use vxls_voxel_cache::tables::FixedStructureTable; mod camera; mod egui_renderer;