larger block buffer
This commit is contained in:
+2
-2
@@ -40,8 +40,8 @@ impl Game {
|
||||
// Generate new world
|
||||
else {
|
||||
let timer = Instant::now();
|
||||
for x in 0..32 {
|
||||
for z in 0..32 {
|
||||
for x in 0..128 {
|
||||
for z in 0..128 {
|
||||
let pos = &Point3{x,y:0,z};
|
||||
let block = app.world.gen_block(pos);
|
||||
content.write(pos, block);
|
||||
|
||||
@@ -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) {
|
||||
|
||||
|
||||
+8
-2
@@ -128,17 +128,23 @@ impl Renderer {
|
||||
self.ui.set_text(3, format!("Swapchain get frame: {}ms", timer.elapsed().as_micros() as f64 / 1000.0));
|
||||
|
||||
// Create encoder that will build command buffer for us
|
||||
let timer = Instant::now();
|
||||
let mut encoder = self.device.create_command_encoder(&wgpu::CommandEncoderDescriptor { label: Some("Render Encoder"),});
|
||||
self.raytrace_pass.render(&mut encoder, &mut self.buffers, &self.texture);//&frame.view);
|
||||
self.postprocess_pass.render(&mut encoder, &frame.view);
|
||||
self.ui.render(&self.device, &mut encoder, &frame.view, 1280, 720);
|
||||
self.ui.set_text(4, format!("Build renderpass: {}ms", timer.elapsed().as_micros() as f64 / 1000.0));
|
||||
|
||||
// Submit encoder (command buffer)
|
||||
let timer = Instant::now();
|
||||
self.queue.submit(std::iter::once(encoder.finish()));
|
||||
self.ui.set_text(4, format!("Submit queue: {}ms", timer.elapsed().as_micros() as f64 / 1000.0));
|
||||
|
||||
self.ui.recall();
|
||||
self.ui.set_text(5, format!("Submit queue: {}ms", timer.elapsed().as_micros() as f64 / 1000.0));
|
||||
|
||||
// Stats
|
||||
let content_stats = self.buffers.content.stats();
|
||||
self.ui.set_text(7, format!("Nodes: {}MB", content_stats.node_tex_size));
|
||||
self.ui.set_text(8, format!("Blocks: {} / {} MB ({}/{})", content_stats.block_tex_used, content_stats.block_tex_size, content_stats.block_used, content_stats.block_count));
|
||||
|
||||
// Return ok
|
||||
Ok(())
|
||||
|
||||
Binary file not shown.
@@ -21,8 +21,8 @@ layout(set=2, binding=0) uniform Materials { Material _Materials[256]; };
|
||||
// Defines
|
||||
#define EPSILON 0.00000001
|
||||
#define SCALE 1.0
|
||||
#define NODE_TEX_SIZE 48
|
||||
#define BLOCK_TEX_SIZE 64
|
||||
#define NODE_TEX_SIZE 128
|
||||
#define BLOCK_TEX_SIZE 256
|
||||
#define BLOCK_SIZE 32
|
||||
|
||||
// Includes
|
||||
|
||||
Reference in New Issue
Block a user