Skip to content

Commit

Permalink
gpu: Split “chunks drawn” info into chunk meshes and instances.
Browse files Browse the repository at this point in the history
  • Loading branch information
kpreid committed Dec 27, 2024
1 parent dd67567 commit 5fd8749
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
13 changes: 9 additions & 4 deletions all-is-cubes-gpu/src/common/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,10 @@ pub struct SpaceDrawInfo {
/// the instance buffer).
pub(crate) finalize_time: Duration,

/// Number of chunk meshes drawn.
pub(crate) chunks_drawn: usize,
/// Number of chunk meshes (not instances) drawn.
pub(crate) chunk_meshes_drawn: usize,
/// Number of chunks that contributed instances.
pub(crate) chunks_with_instances_drawn: usize,
/// Number of instanced block meshes drawn.
pub(crate) blocks_drawn: usize,
/// How many squares (quadrilaterals; sets of 2 triangles = 6 vertices) were used
Expand All @@ -281,7 +283,8 @@ impl Fmt<StatusText> for SpaceDrawInfo {
draw_opaque_blocks_time,
draw_transparent_time,
finalize_time,
chunks_drawn,
chunk_meshes_drawn,
chunks_with_instances_drawn,
blocks_drawn,
squares_drawn,
flaws: _, // TODO: include or exclude?
Expand All @@ -303,7 +306,9 @@ impl Fmt<StatusText> for SpaceDrawInfo {
)?;
writeln!(
fmt,
"Chunks drawn: {chunks_drawn:3} Block insts drawn: {blocks_drawn:3} Quads drawn: {squares_drawn:7}",
"Chunk meshes drawn: {chunk_meshes_drawn:3} \
Block insts drawn: {blocks_drawn:3} in {chunks_with_instances_drawn:3} chunks \
Quads drawn: {squares_drawn:7}",
)?;
Ok(())
}
Expand Down
13 changes: 8 additions & 5 deletions all-is-cubes-gpu/src/in_wgpu/space.rs
Original file line number Diff line number Diff line change
Expand Up @@ -490,7 +490,8 @@ impl<I: time::Instant> SpaceRenderer<I> {
draw_transparent_time: Duration::ZERO,
finalize_time: Duration::ZERO,
squares_drawn: 0,
chunks_drawn: 0,
chunk_meshes_drawn: 0,
chunks_with_instances_drawn: 0,
blocks_drawn: 0,
flaws,
};
Expand Down Expand Up @@ -557,7 +558,8 @@ impl<I: time::Instant> SpaceRenderer<I> {
// Opaque geometry before other geometry, in front-to-back order.
// Also collect instances.
let start_opaque_chunk_draw_time = I::now();
let mut chunks_drawn = 0;
let mut chunk_meshes_drawn = 0;
let mut chunks_with_instances_drawn = 0;
let mut blocks_drawn = 0;
let mut squares_drawn = 0;
let mut block_instances = dynamic::InstanceCollector::new(); // TODO: reuse across frames
Expand All @@ -569,9 +571,8 @@ impl<I: time::Instant> SpaceRenderer<I> {
..
} in csm.iter_in_view(camera)
{
chunks_drawn += 1;

if mesh_in_view {
chunk_meshes_drawn += 1;
if let Some(buffers) = &chunk.render_data {
draw_chunk_instance(
chunk.mesh().opaque_range(),
Expand All @@ -587,6 +588,7 @@ impl<I: time::Instant> SpaceRenderer<I> {
flaws |= chunk.mesh().flaws();
}
if instances_in_view {
chunks_with_instances_drawn += 1;
block_instances.extend(chunk.block_instances());
}
}
Expand Down Expand Up @@ -701,7 +703,8 @@ impl<I: time::Instant> SpaceRenderer<I> {
.saturating_duration_since(start_draw_transparent_time),
finalize_time: end_time.saturating_duration_since(start_drop_pass_time),
squares_drawn,
chunks_drawn,
chunk_meshes_drawn,
chunks_with_instances_drawn,
blocks_drawn,
flaws,
}
Expand Down

0 comments on commit 5fd8749

Please sign in to comment.