GPU Brickgrid dimensions are now defined by the renderer

This commit is contained in:
Jarrod Doyle 2023-06-27 20:31:44 +01:00
parent 0e1b844f96
commit c4107c61ea
Signed by: Jayrude
GPG Key ID: 38B57B16E7C0ADF7
2 changed files with 6 additions and 4 deletions

View File

@ -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 {

View File

@ -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");