From c4107c61eaabb65815d16a3df02ce058aeca0c51 Mon Sep 17 00:00:00 2001 From: Jarrod Doyle Date: Tue, 27 Jun 2023 20:31:44 +0100 Subject: [PATCH] GPU Brickgrid dimensions are now defined by the renderer --- src/voxel/brickmap.rs | 7 ++++--- src/voxel/voxel_renderer.rs | 3 ++- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/voxel/brickmap.rs b/src/voxel/brickmap.rs index 8b45eca..0efed78 100644 --- a/src/voxel/brickmap.rs +++ b/src/voxel/brickmap.rs @@ -37,14 +37,15 @@ pub struct BrickmapManager { // - Cyclic brickmap cache with unloading // - Brickworld system impl BrickmapManager { - pub fn new(context: &render::Context) -> Self { + pub fn new(context: &render::Context, brickgrid_dims: glam::UVec3) -> Self { let state_uniform = WorldState { - brickmap_cache_dims: [32, 32, 32], + brickmap_cache_dims: [brickgrid_dims.x, brickgrid_dims.y, brickgrid_dims.z], ..Default::default() }; let brickmap_cache = vec![Brickmap::default(); usize::pow(32, 3)]; - let brickgrid = vec![1u32; usize::pow(32, 3)]; + let brickgrid = + vec![1u32; (brickgrid_dims.x * brickgrid_dims.y * brickgrid_dims.z) as usize]; let device = &context.device; let state_buffer = device.create_buffer_init(&wgpu::util::BufferInitDescriptor { diff --git a/src/voxel/voxel_renderer.rs b/src/voxel/voxel_renderer.rs index 46f95aa..d92def0 100644 --- a/src/voxel/voxel_renderer.rs +++ b/src/voxel/voxel_renderer.rs @@ -60,7 +60,8 @@ impl VoxelRenderer { }); log::info!("Creating brickmap manager..."); - let brickmap_manager = super::brickmap::BrickmapManager::new(context); + let brickgrid_dims = glam::uvec3(64, 64, 64); + let brickmap_manager = super::brickmap::BrickmapManager::new(context, brickgrid_dims); log::info!("Creating compute pipeline..."); let cs_descriptor = wgpu::include_wgsl!("../../assets/shaders/voxel_volume.wgsl");