larger block buffer

This commit is contained in:
Piotrek
2021-05-10 22:07:07 +02:00
parent a09f446ecd
commit e110e99053
5 changed files with 39 additions and 8 deletions
+26 -1
View File
@@ -4,10 +4,22 @@ use std::convert::TryInto;
use cgmath::Point3;
use crate::game::world::block::WorldBlock;
//note: remember to update in main.frag
pub const BLOCK_SIZE : usize = 32; // 32x32x32 block size
pub const BLOCK_TEX_SIZE : usize = 64; // 64x64 blocks in texture
pub const BLOCK_TEX_SIZE : usize = 256; // 128x128 blocks in texture
pub const NODE_TEX_SIZE: usize = 128; // 32x32x32 nodes in texture
const BLOCK_SIZE_QB: usize = BLOCK_SIZE*BLOCK_SIZE*BLOCK_SIZE;
const BLOCK_TEX_SIZE_SQ: usize = BLOCK_TEX_SIZE*BLOCK_TEX_SIZE;
const NODE_TEX_SIZE_SQ: usize = NODE_TEX_SIZE*NODE_TEX_SIZE;
const NODE_TEX_SIZE_QB: usize = NODE_TEX_SIZE*NODE_TEX_SIZE*NODE_TEX_SIZE;
pub struct ContentStats {
pub node_tex_size: f64, // MB
pub block_tex_size: f64, // MB
pub block_tex_used: f64, // MB
pub block_count: u64, // amount
pub block_used: u64, // amount
}
pub struct Content {
node_buffer: Box<[u32]>,
@@ -73,6 +85,19 @@ impl Content {
Self { node_buffer, node_dirty: false, node_texture, block_freeidx, block_texture, bind_layout, bind_group }
}
pub fn stats(&self) -> ContentStats {
const TO_MB: f64 = 1.0 / (1024.0 * 1024.0);
let block_used = self.block_freeidx as u64;
let block_count = BLOCK_TEX_SIZE_SQ as u64;
let node_tex_size = (NODE_TEX_SIZE_QB*4) as f64 * TO_MB;
let block_tex_used = (block_used * BLOCK_SIZE_QB as u64) as f64 * TO_MB;
let block_tex_size = (BLOCK_TEX_SIZE_SQ*BLOCK_SIZE_QB) as f64 * TO_MB;
ContentStats { node_tex_size, block_tex_size, block_tex_used, block_count, block_used }
}
#[allow(unused)]
pub fn write(&mut self, queue: &wgpu::Queue, block_pos: &Point3<u32>, block: &WorldBlock) {