refactor: Deprecating cache layout for now
This commit is contained in:
@@ -271,6 +271,43 @@ impl AttributesLayout
|
||||
|
||||
hash
|
||||
}
|
||||
|
||||
///
|
||||
/// Produces a wgsl declaration describing this layout :
|
||||
///
|
||||
/// ```wgsl
|
||||
///
|
||||
/// const ATTRIBUTE_COUNT: u32 = /* attribute count */;
|
||||
/// const ATTRIBUTE_WORD_COUNTS: array<u32, ...> = {
|
||||
/// /* word count for attribute 0 */,
|
||||
/// /* word count 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<u32, {}> = array<u32, {}>(",
|
||||
self.attributes.len(),
|
||||
self.attributes.len()
|
||||
);
|
||||
|
||||
for attribute in self.attributes.iter()
|
||||
{
|
||||
decl += &format!(" {},", attribute.word_count);
|
||||
}
|
||||
|
||||
decl += ");";
|
||||
|
||||
decl
|
||||
}
|
||||
}
|
||||
|
||||
fn fnv1a(hash: &mut u64, bytes: &[u8])
|
||||
|
||||
@@ -12,9 +12,9 @@ use wgpu::util::DeviceExt;
|
||||
|
||||
pub struct NonZeroBufferCompactor
|
||||
{
|
||||
size: usize,
|
||||
block_count: usize,
|
||||
reduced_buffer: Buffer,
|
||||
#[allow(unused)]
|
||||
sum_buffer: Buffer,
|
||||
count_buffer_bg_layout: BindGroupLayout,
|
||||
compaction_bg: BindGroup,
|
||||
@@ -178,7 +178,6 @@ impl NonZeroBufferCompactor
|
||||
});
|
||||
|
||||
NonZeroBufferCompactor {
|
||||
size,
|
||||
block_count,
|
||||
reduced_buffer,
|
||||
sum_buffer,
|
||||
@@ -230,7 +229,7 @@ impl NonZeroBufferCompactor
|
||||
},
|
||||
wgpu::BindGroupEntry {
|
||||
binding: 2,
|
||||
resource: compact_buffer.unwrap_or(&count_buffer).as_entire_binding(),
|
||||
resource: compact_buffer.unwrap_or(count_buffer).as_entire_binding(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
//! Provides utility object to manage indirect dispatches workgroup count computations on the GPU
|
||||
|
||||
use wgpu::Buffer;
|
||||
use wgpu::CommandEncoder;
|
||||
|
||||
/// Provides utility object to manage indirect dispatches workgroup count computations on the GPU
|
||||
|
||||
/// Takes in a single u32, and computes the amount of workgroups to dispatch given a workgroup size
|
||||
pub struct IndirectBuffer1D
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ const LOG_SUB_BINS: u32 = SUB_BINS.trailing_zeros();
|
||||
/// Threads per workgroup for the histogram and selection passes.
|
||||
const WORKGROUP_SIZE: u32 = 256;
|
||||
|
||||
const _: () = assert!(BIN_COUNT % 32 == 0);
|
||||
const _: () = assert!(BIN_COUNT.is_multiple_of(32));
|
||||
const _: () = assert!(SUB_BINS.is_power_of_two());
|
||||
|
||||
/// Parameters passed to the shader through immediates.
|
||||
|
||||
@@ -679,7 +679,7 @@ impl Profile
|
||||
painter.with_clip_rect(r).text(
|
||||
r.left_center() + vec2(3.0, 0.0),
|
||||
egui::Align2::LEFT_CENTER,
|
||||
&s.name,
|
||||
s.name,
|
||||
font.clone(),
|
||||
egui::Color32::BLACK,
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
use vxls_attributes::AttributeDescriptor;
|
||||
use vxls_attributes::AttributesLayout;
|
||||
use wgpu::BindGroupLayout;
|
||||
use wgpu::Buffer;
|
||||
use wgpu::BufferUsages;
|
||||
|
||||
use vxls_profiler::memory_profiler;
|
||||
use crate::layout::CacheLayout;
|
||||
|
||||
/// Contains instanciated gpu buffers to hold data for cache attributes
|
||||
pub struct CacheAttributes<const N: usize>
|
||||
@@ -16,9 +16,9 @@ pub struct CacheAttributes<const N: usize>
|
||||
|
||||
impl<const N: usize> CacheAttributes<N>
|
||||
{
|
||||
pub fn from_cache_layout(
|
||||
pub fn from_attribute_layout(
|
||||
device: &mut memory_profiler::Device,
|
||||
layout: &CacheLayout,
|
||||
layout: &AttributesLayout,
|
||||
page_count: usize,
|
||||
) -> Self
|
||||
{
|
||||
@@ -26,11 +26,11 @@ impl<const N: usize> CacheAttributes<N>
|
||||
.attributes
|
||||
.iter()
|
||||
.map(|attribute| {
|
||||
attribute.create_buffer_profiled(
|
||||
create_attributes_buffer_profiled::<N>(
|
||||
device,
|
||||
N * N * N,
|
||||
attribute,
|
||||
page_count,
|
||||
BufferUsages::STORAGE,
|
||||
wgpu::BufferUsages::STORAGE,
|
||||
)
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
@@ -58,8 +58,10 @@ impl<const N: usize> CacheAttributes<N>
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_bind_group_layout(device: &wgpu::Device, layout: &CacheLayout)
|
||||
-> BindGroupLayout
|
||||
pub fn create_bind_group_layout(
|
||||
device: &wgpu::Device,
|
||||
layout: &AttributesLayout,
|
||||
) -> BindGroupLayout
|
||||
{
|
||||
device.create_bind_group_layout(&wgpu::BindGroupLayoutDescriptor {
|
||||
label: Some("CacheAttributes::bind_group_layout"),
|
||||
@@ -94,3 +96,47 @@ impl<const N: usize> CacheAttributes<N>
|
||||
&self.attribute_buffers
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_attributes_buffer_profiled<const N: usize>(
|
||||
device: &mut memory_profiler::Device,
|
||||
attribute_descriptor: &AttributeDescriptor,
|
||||
page_count: usize,
|
||||
usage: wgpu::BufferUsages,
|
||||
) -> wgpu::Buffer
|
||||
{
|
||||
device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some(
|
||||
format!(
|
||||
"VoxelCacheAttribute ({}) {} word(s)",
|
||||
attribute_descriptor.label, attribute_descriptor.word_count
|
||||
)
|
||||
.as_str(),
|
||||
),
|
||||
size: (page_count * attribute_descriptor.word_count as usize * N * N * N * size_of::<u32>())
|
||||
as u64,
|
||||
usage,
|
||||
mapped_at_creation: false,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn create_attributes_buffer<const N: usize>(
|
||||
device: &wgpu::Device,
|
||||
attribute_descriptor: &AttributeDescriptor,
|
||||
page_count: usize,
|
||||
usage: wgpu::BufferUsages,
|
||||
) -> wgpu::Buffer
|
||||
{
|
||||
device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some(
|
||||
format!(
|
||||
"VoxelCacheAttribute ({}) {} word(s)",
|
||||
attribute_descriptor.label, attribute_descriptor.word_count
|
||||
)
|
||||
.as_str(),
|
||||
),
|
||||
size: (page_count * attribute_descriptor.word_count as usize * N * N * N * size_of::<u32>())
|
||||
as u64,
|
||||
usage,
|
||||
mapped_at_creation: false,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
use std::num::NonZero;
|
||||
|
||||
use vxls_attributes::AttributesLayout;
|
||||
use wgpu::BindGroupLayout;
|
||||
use wgpu::BufferUsages;
|
||||
use wgpu::ShaderStages;
|
||||
|
||||
use vxls_attributes::Attributes;
|
||||
|
||||
use crate::layout::CacheAttributeInit;
|
||||
use crate::layout::CacheLayout;
|
||||
use crate::schema::InsertionInformation;
|
||||
use crate::schema::InsertionParent;
|
||||
use crate::schema::LocationPage;
|
||||
@@ -34,7 +33,7 @@ where
|
||||
|
||||
/// Layout the attribute buffers were created from. Kept so attribute
|
||||
/// uploads can validate producer layouts against the cache layout.
|
||||
layout: CacheLayout,
|
||||
layout: AttributesLayout,
|
||||
|
||||
/// Contains the indicies of the page in which the data was written
|
||||
destination_indices: wgpu::Buffer,
|
||||
@@ -61,33 +60,31 @@ pub enum AttributeUploadError
|
||||
/// The slice is not a whole number of pages.
|
||||
NotWholePages
|
||||
{
|
||||
voxel_count: usize,
|
||||
children: usize,
|
||||
voxel_count: usize, children: usize
|
||||
},
|
||||
|
||||
/// The slice does not fit in this insertion batch.
|
||||
TooManyVoxels
|
||||
{
|
||||
voxel_count: usize,
|
||||
capacity: usize,
|
||||
voxel_count: usize, capacity: usize
|
||||
},
|
||||
|
||||
/// The producer declares more attributes than the cache layout has.
|
||||
MissingCacheAttribute
|
||||
{
|
||||
index: usize,
|
||||
index: usize
|
||||
},
|
||||
|
||||
/// The producer attribute index is out of bounds.
|
||||
AttributeIndexOutOfBounds
|
||||
{
|
||||
index: usize,
|
||||
index: usize
|
||||
},
|
||||
|
||||
/// The cache attribute is not `External`, so insertion will not copy it.
|
||||
NotExternal
|
||||
{
|
||||
index: usize,
|
||||
index: usize
|
||||
},
|
||||
|
||||
/// Declared word counts disagree.
|
||||
@@ -115,52 +112,6 @@ pub enum AttributeUploadError
|
||||
},
|
||||
}
|
||||
|
||||
/// Checks that `A::LAYOUT` is a valid prefix of `layout`.
|
||||
///
|
||||
/// Every producer attribute must map to an `External` cache attribute with the
|
||||
/// same word count and (when present) the same label. Extra attributes after
|
||||
/// the producer prefix are allowed; they are meant for GPU-only data.
|
||||
pub fn validate_attribute_layout<A: Attributes>(
|
||||
layout: &CacheLayout,
|
||||
) -> Result<(), AttributeUploadError>
|
||||
{
|
||||
let producer_layout = &A::LAYOUT;
|
||||
|
||||
for (index, descriptor) in producer_layout.attributes.iter().enumerate()
|
||||
{
|
||||
let Some(cache_attribute) = layout.attributes().get(index) else
|
||||
{
|
||||
return Err(AttributeUploadError::MissingCacheAttribute { index });
|
||||
};
|
||||
|
||||
if cache_attribute.init != CacheAttributeInit::External
|
||||
{
|
||||
return Err(AttributeUploadError::NotExternal { index });
|
||||
}
|
||||
|
||||
if cache_attribute.word_count != descriptor.word_count
|
||||
{
|
||||
return Err(AttributeUploadError::WordCountMismatch {
|
||||
index,
|
||||
producer: descriptor.word_count,
|
||||
cache: cache_attribute.word_count,
|
||||
});
|
||||
}
|
||||
|
||||
if let Some(cache_label) = cache_attribute.label
|
||||
&& cache_label != descriptor.label
|
||||
{
|
||||
return Err(AttributeUploadError::LabelMismatch {
|
||||
index,
|
||||
producer: descriptor.label,
|
||||
cache: Some(cache_label),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Checks that a voxel slice is a whole number of pages and fits the batch.
|
||||
pub fn validate_voxel_count(
|
||||
voxel_count: usize,
|
||||
@@ -196,7 +147,8 @@ pub fn collect_attribute_bytes<A: Attributes>(
|
||||
index: usize,
|
||||
) -> Result<Vec<u8>, AttributeUploadError>
|
||||
{
|
||||
let Some(descriptor) = A::LAYOUT.attributes.get(index) else
|
||||
let Some(descriptor) = A::LAYOUT.attributes.get(index)
|
||||
else
|
||||
{
|
||||
return Err(AttributeUploadError::AttributeIndexOutOfBounds { index });
|
||||
};
|
||||
@@ -227,7 +179,7 @@ impl<const N: usize> CacheInsertionData<N>
|
||||
where
|
||||
[(); N * N * N]:,
|
||||
{
|
||||
pub fn new(device: &wgpu::Device, max_page_count: usize, layout: &CacheLayout) -> Self
|
||||
pub fn new(device: &wgpu::Device, max_page_count: usize, layout: &AttributesLayout) -> Self
|
||||
{
|
||||
let page_count_buffer = device.create_buffer(&wgpu::BufferDescriptor {
|
||||
label: Some("CacheInsertionData::page_count_buffer"),
|
||||
@@ -282,9 +234,9 @@ where
|
||||
.attributes
|
||||
.iter()
|
||||
.map(|attribute| {
|
||||
attribute.create_buffer(
|
||||
crate::attributes::create_attributes_buffer::<N>(
|
||||
device,
|
||||
N * N * N,
|
||||
attribute,
|
||||
max_page_count,
|
||||
BufferUsages::STORAGE | BufferUsages::COPY_DST,
|
||||
)
|
||||
@@ -355,7 +307,7 @@ where
|
||||
valid_indices,
|
||||
valid_count,
|
||||
attributes,
|
||||
layout: layout.clone(),
|
||||
layout: *layout,
|
||||
|
||||
bind_group_layout,
|
||||
bind_group,
|
||||
@@ -376,7 +328,7 @@ where
|
||||
///
|
||||
pub fn create_bind_group_layout(
|
||||
device: &wgpu::Device,
|
||||
layout: Option<&CacheLayout>,
|
||||
layout: Option<&AttributesLayout>,
|
||||
) -> BindGroupLayout
|
||||
{
|
||||
let storage_entry = |binding: u32| wgpu::BindGroupLayoutEntry {
|
||||
@@ -476,7 +428,7 @@ where
|
||||
}
|
||||
|
||||
/// The layout this insertion data was created from.
|
||||
pub fn layout(&self) -> &CacheLayout
|
||||
pub fn layout(&self) -> &AttributesLayout
|
||||
{
|
||||
&self.layout
|
||||
}
|
||||
@@ -513,7 +465,14 @@ where
|
||||
voxels: &[A],
|
||||
) -> Result<usize, AttributeUploadError>
|
||||
{
|
||||
validate_attribute_layout::<A>(&self.layout)?;
|
||||
if A::LAYOUT != self.layout
|
||||
{
|
||||
return Err(AttributeUploadError::LabelMismatch {
|
||||
index: 0,
|
||||
producer: "..",
|
||||
cache: None,
|
||||
});
|
||||
}
|
||||
validate_voxel_count(voxels.len(), N * N * N, self.attribute_capacity())?;
|
||||
|
||||
if voxels.is_empty()
|
||||
@@ -540,8 +499,6 @@ mod tests
|
||||
use vxls_attributes::AttributeDescriptor;
|
||||
use vxls_attributes::AttributesLayout;
|
||||
|
||||
use crate::layout::CacheAttribute;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, bytemuck::Pod, bytemuck::Zeroable)]
|
||||
#[repr(C)]
|
||||
struct TestAttributes
|
||||
@@ -562,7 +519,10 @@ mod tests
|
||||
let count = attributes.len() as f32;
|
||||
|
||||
Self {
|
||||
color: (attributes.iter().map(|value| value.color as u64).sum::<u64>()
|
||||
color: (attributes
|
||||
.iter()
|
||||
.map(|value| value.color as u64)
|
||||
.sum::<u64>()
|
||||
/ attributes.len() as u64) as u32,
|
||||
normal: std::array::from_fn(|index| {
|
||||
attributes
|
||||
@@ -708,31 +668,6 @@ mod tests
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn validation_rejects_label_mismatch()
|
||||
{
|
||||
let mut layout = CacheLayout::default();
|
||||
layout.add_attribute(CacheAttribute {
|
||||
label: Some("not-color"),
|
||||
word_count: 1,
|
||||
init: CacheAttributeInit::External,
|
||||
});
|
||||
layout.add_attribute(CacheAttribute {
|
||||
label: Some("normal"),
|
||||
word_count: 3,
|
||||
init: CacheAttributeInit::External,
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
validate_attribute_layout::<TestAttributes>(&layout),
|
||||
Err(AttributeUploadError::LabelMismatch {
|
||||
index: 0,
|
||||
producer: "color",
|
||||
cache: Some("not-color"),
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn voxel_counts_must_be_whole_pages_within_capacity()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
use wgpu::BufferUsages;
|
||||
|
||||
//! 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;
|
||||
|
||||
@@ -185,3 +186,4 @@ impl CacheLayout
|
||||
decl
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
#![allow(incomplete_features)]
|
||||
#![feature(generic_const_exprs)]
|
||||
|
||||
use std::num::NonZero;
|
||||
|
||||
use vxls_attributes::AttributesLayout;
|
||||
use wgpu::CommandEncoder;
|
||||
use wgpu::Device;
|
||||
|
||||
use vxls_gpu::create_multi_buffers_bg_bg_layout;
|
||||
use vxls_gpu::create_multi_buffers_bind_group_layout;
|
||||
use vxls_gpu::radix_sort::RadixSorter;
|
||||
use vxls_profiler;
|
||||
use vxls_profiler::ScopeEncoder;
|
||||
use vxls_profiler::memory_profiler;
|
||||
use vxls_profiler::memory_profiler::MemoryProfile;
|
||||
use crate::attributes::CacheAttributes;
|
||||
use crate::eviction::CacheEvictor;
|
||||
use crate::insertion::CacheInsertionData;
|
||||
@@ -22,21 +17,23 @@ use crate::pipelines::WriteRequestsPass;
|
||||
use crate::requests::CacheRequestBuffer;
|
||||
use crate::requests::CacheRequestHandler;
|
||||
use crate::structure::CacheStructure;
|
||||
use vxls_gpu::create_multi_buffers_bg_bg_layout;
|
||||
use vxls_gpu::create_multi_buffers_bind_group_layout;
|
||||
use vxls_gpu::radix_sort::RadixSorter;
|
||||
use vxls_profiler::ScopeEncoder;
|
||||
use vxls_profiler::memory_profiler;
|
||||
use vxls_profiler::memory_profiler::MemoryProfile;
|
||||
|
||||
pub mod attributes;
|
||||
pub mod eviction;
|
||||
pub mod insertion;
|
||||
pub mod layout;
|
||||
//pub mod layout;
|
||||
pub mod pipelines;
|
||||
pub mod requests;
|
||||
pub mod schema;
|
||||
pub mod structure;
|
||||
pub mod tables;
|
||||
|
||||
pub use layout::CacheAttribute;
|
||||
pub use layout::CacheAttributeInit;
|
||||
pub use layout::CacheLayout;
|
||||
|
||||
/// Stores some ressources that can be reused throughout the modules of the cache
|
||||
struct CacheRessources<const N: usize>
|
||||
{
|
||||
@@ -147,16 +144,16 @@ where
|
||||
device: &Device,
|
||||
page_count: usize,
|
||||
max_requests: usize,
|
||||
layout: &CacheLayout,
|
||||
attributes_layout: &AttributesLayout,
|
||||
) -> Self
|
||||
{
|
||||
let mut cache_memory_profile = MemoryProfile::new("VoxelCache");
|
||||
let mut mem_device = cache_memory_profile.begin(device);
|
||||
|
||||
let structure = CacheStructure::new(&mut mem_device.group("CacheStructure"), page_count);
|
||||
let attributes = CacheAttributes::from_cache_layout(
|
||||
let attributes = CacheAttributes::from_attribute_layout(
|
||||
&mut mem_device.group("CacheAttributes"),
|
||||
layout,
|
||||
attributes_layout,
|
||||
page_count,
|
||||
);
|
||||
let request_handler = CacheRequestHandler::new(
|
||||
@@ -168,10 +165,11 @@ where
|
||||
let common_ressources =
|
||||
CacheRessources::new(&mut mem_device.group("CacheRessources"), page_count);
|
||||
|
||||
let write_requests_pass = WriteRequestsPass::new(device, page_count, layout);
|
||||
let cache_insertion_pass = CacheInsertionPass::new(device, page_count, layout);
|
||||
let cache_invalidation_pass = CacheInvalidationPass::new(device, page_count, layout);
|
||||
let write_pointers_pass = WritePointersPass::new(device, page_count, layout);
|
||||
let write_requests_pass = WriteRequestsPass::new(device, page_count, attributes_layout);
|
||||
let cache_insertion_pass = CacheInsertionPass::new(device, page_count, attributes_layout);
|
||||
let cache_invalidation_pass =
|
||||
CacheInvalidationPass::new(device, page_count, attributes_layout);
|
||||
let write_pointers_pass = WritePointersPass::new(device, page_count, attributes_layout);
|
||||
|
||||
let (raytrace_bind_group_layout, raytrace_bind_group) = Self::create_raytrace_bind_group(
|
||||
device,
|
||||
@@ -182,7 +180,7 @@ where
|
||||
);
|
||||
|
||||
drop(mem_device);
|
||||
let mut root_group = cache_memory_profile.terminate();
|
||||
let root_group = cache_memory_profile.terminate();
|
||||
println!("{}", root_group);
|
||||
|
||||
Self {
|
||||
@@ -322,12 +320,8 @@ where
|
||||
{
|
||||
if let VoxelCacheInsertion::InternalRequest(insertion) = insertion
|
||||
{
|
||||
self.write_pointers_pass.encode(
|
||||
&mut encoder,
|
||||
device,
|
||||
&self.structure,
|
||||
insertion,
|
||||
);
|
||||
self.write_pointers_pass
|
||||
.encode(&mut encoder, device, &self.structure, insertion);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,4 +442,9 @@ where
|
||||
{
|
||||
self.evictor.timestamp_pages_buffer()
|
||||
}
|
||||
|
||||
pub fn size(&self) -> usize
|
||||
{
|
||||
self.page_count
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
use vxls_attributes::AttributesLayout;
|
||||
use wgpu::BufferUsages;
|
||||
use wgpu::CommandEncoder;
|
||||
use wgpu::ComputePipeline;
|
||||
use wgpu::Device;
|
||||
use wgpu::util::DeviceExt;
|
||||
|
||||
use vxls_gpu::indirect_buffer::IndirectBuffer1D;
|
||||
use vxls_profiler;
|
||||
use vxls_profiler::ScopeEncoder;
|
||||
use crate::attributes::CacheAttributes;
|
||||
use crate::create_multi_buffers_bg_bg_layout;
|
||||
use crate::eviction::CacheEvictor;
|
||||
use crate::insertion::CacheInsertionData;
|
||||
use crate::layout::CacheLayout;
|
||||
use crate::requests::CacheRequestBuffer;
|
||||
use crate::requests::CacheRequestHandler;
|
||||
use crate::structure::CacheStructure;
|
||||
use vxls_gpu::indirect_buffer::IndirectBuffer1D;
|
||||
use vxls_profiler;
|
||||
use vxls_profiler::ScopeEncoder;
|
||||
|
||||
macro_rules! programmatic_common_wgsl {
|
||||
($children_count:ident, $page_count:ident, $cache_layout:ident) => {
|
||||
@@ -54,8 +54,6 @@ macro_rules! include_cache_wgsl {
|
||||
}};
|
||||
}
|
||||
|
||||
pub(super) use include_cache_wgsl;
|
||||
|
||||
pub struct WriteRequestsPass<const N: usize>
|
||||
where
|
||||
[(); N * N * N]:,
|
||||
@@ -69,7 +67,7 @@ impl<const N: usize> WriteRequestsPass<N>
|
||||
where
|
||||
[(); N * N * N]:,
|
||||
{
|
||||
pub fn new(device: &Device, page_count: usize, cache_layout: &CacheLayout) -> Self
|
||||
pub fn new(device: &Device, page_count: usize, cache_layout: &AttributesLayout) -> Self
|
||||
{
|
||||
// Binds
|
||||
// - structure
|
||||
@@ -164,6 +162,7 @@ where
|
||||
validate_internal_pipeline: ComputePipeline,
|
||||
|
||||
/// u32 buffer containing amount of inserted data of current pass
|
||||
#[allow(unused)]
|
||||
inserted_count: wgpu::Buffer,
|
||||
inserted_count_bind_group: wgpu::BindGroup,
|
||||
|
||||
@@ -178,7 +177,7 @@ impl<const N: usize> CacheInsertionPass<N>
|
||||
where
|
||||
[(); N * N * N]:,
|
||||
{
|
||||
pub fn new(device: &Device, page_count: usize, layout: &CacheLayout) -> Self
|
||||
pub fn new(device: &Device, page_count: usize, layout: &AttributesLayout) -> Self
|
||||
{
|
||||
// Binds
|
||||
// - structure
|
||||
@@ -363,7 +362,7 @@ impl<const N: usize> CacheInvalidationPass<N>
|
||||
where
|
||||
[(); N * N * N]:,
|
||||
{
|
||||
pub fn new(device: &Device, page_count: usize, layout: &CacheLayout) -> Self
|
||||
pub fn new(device: &Device, page_count: usize, layout: &AttributesLayout) -> Self
|
||||
{
|
||||
// Binds
|
||||
// - structure
|
||||
@@ -444,7 +443,7 @@ impl<const N: usize> WritePointersPass<N>
|
||||
where
|
||||
[(); N * N * N]:,
|
||||
{
|
||||
pub fn new(device: &Device, page_count: usize, layout: &CacheLayout) -> Self
|
||||
pub fn new(device: &Device, page_count: usize, layout: &AttributesLayout) -> Self
|
||||
{
|
||||
let bindings = [
|
||||
// To find where pages are pointing
|
||||
|
||||
@@ -171,11 +171,6 @@ fn insertion(@builtin(global_invocation_id) gid: vec3<u32>)
|
||||
// Copy attributes
|
||||
for(var attribute_index = u32(0); attribute_index < ATTRIBUTE_COUNT; attribute_index ++)
|
||||
{
|
||||
if(!ATTRIBUTE_COPY[attribute_index])
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
var page_stride = CHILDREN_COUNT * ATTRIBUTE_WORD_COUNTS[attribute_index];
|
||||
var dest_offset = page_stride * page_index;
|
||||
var src_offset = page_stride * index;
|
||||
|
||||
@@ -1,50 +0,0 @@
|
||||
use crate::gi_pipeline::sparse_set::GpuSparseSet;
|
||||
use vxls_voxel_cache::VoxelCache;
|
||||
use vxls_voxel_cache::{self};
|
||||
|
||||
mod sparse_set;
|
||||
|
||||
pub struct VoxelGiPipeline<const N: usize>
|
||||
where
|
||||
[(); N * N * N]:,
|
||||
{
|
||||
voxel_cache: VoxelCache<N>,
|
||||
|
||||
/// Keeps a set of the leaves present in the cache.
|
||||
/// Kept in correspondancy with the leaf list attribute within the cache
|
||||
leaf_list: GpuSparseSet,
|
||||
leaf_list_attribute: usize,
|
||||
}
|
||||
|
||||
impl<const N: usize> VoxelGiPipeline<N>
|
||||
where
|
||||
[(); N * N * N]:,
|
||||
{
|
||||
pub fn new(
|
||||
device: &wgpu::Device,
|
||||
cache_size: usize,
|
||||
max_requests: usize,
|
||||
cache_layout: &mut vxls_voxel_cache::CacheLayout,
|
||||
) -> Self
|
||||
{
|
||||
let leaf_list_attribute = cache_layout.add_attribute(vxls_voxel_cache::CacheAttribute {
|
||||
label: Some("VoxelGiPipeline::leaf_list_pointer"),
|
||||
word_count: 1,
|
||||
init: vxls_voxel_cache::CacheAttributeInit::External,
|
||||
});
|
||||
|
||||
cache_layout.add_attribute(vxls_voxel_cache::CacheAttribute {
|
||||
label: Some("VoxelGiPipeline::radiance"),
|
||||
word_count: 3,
|
||||
init: vxls_voxel_cache::CacheAttributeInit::DontTouch,
|
||||
});
|
||||
|
||||
let voxel_cache = VoxelCache::new(device, cache_size, max_requests, cache_layout);
|
||||
|
||||
Self {
|
||||
voxel_cache,
|
||||
leaf_list: GpuSparseSet::new(device, cache_size),
|
||||
leaf_list_attribute,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
// Contains useful facilities to render data streamed in from the host
|
||||
|
||||
// Can produce a voxel given
|
||||
// - Its depth
|
||||
// - Its position within the chunk
|
||||
// - The chunks position
|
||||
pub trait ChunkVoxelProducer
|
||||
{
|
||||
fn produce_voxel(
|
||||
&mut self,
|
||||
depth: usize,
|
||||
chunk_position: (usize, usize, usize),
|
||||
voxel_position: (usize, usize, usize),
|
||||
);
|
||||
}
|
||||
@@ -83,7 +83,6 @@ use vxls_profiler::Frame;
|
||||
use vxls_profiler::Profile;
|
||||
use vxls_profiler::ProfilingEncoder;
|
||||
use vxls_terrain::ToroidalStructureTable;
|
||||
use vxls_voxel_cache::CacheLayout;
|
||||
use vxls_voxel_cache::VoxelCache;
|
||||
use vxls_voxel_cache::VoxelCacheInsertion;
|
||||
use vxls_voxel_cache::insertion::CacheInsertionData;
|
||||
@@ -95,7 +94,6 @@ use vxls_voxel_cache::tables::FixedStructureTable;
|
||||
|
||||
mod camera;
|
||||
mod egui_renderer;
|
||||
mod gi_pipeline;
|
||||
mod producers;
|
||||
mod sparse_tree;
|
||||
|
||||
@@ -377,7 +375,7 @@ impl State
|
||||
*/
|
||||
|
||||
// Load dragon ply
|
||||
let tree: NTree<4> = load_ply("dragon.txt");
|
||||
let tree: NTree<4> = load_ply("../../dragon.txt");
|
||||
// let mut arrays = vec![Color(0., 0., 0., 0.); 256 * 256 * 256];
|
||||
// for ((x, y), z) in (0..256).cartesian_product(0..256).cartesian_product(0..256)
|
||||
// {
|
||||
@@ -397,9 +395,7 @@ impl State
|
||||
|
||||
let egui_renderer = EguiRenderer::new(&device, surface_format, &window);
|
||||
|
||||
let layout =
|
||||
CacheLayout::from_attributes(&crate::producers::VoxelAttributes::LAYOUT, &[]);
|
||||
|
||||
let layout = crate::producers::VoxelAttributes::LAYOUT;
|
||||
let request_buffer = CacheRequestBuffer::new(&device, 1024);
|
||||
let voxel_cache =
|
||||
VoxelCache::<4>::new(&device, 150_000, request_buffer.max_requests, &layout);
|
||||
|
||||
Reference in New Issue
Block a user