perf: light_step source cap 64, minimap step_by(4), resize early-return, warning cleanup
- light_step: cap sources at 64 (was unlimited — 400+ lava cells = 250K ray-casts) - minimap: step_by(4) sampling (65K→4K grid.get calls, still every frame — no flicker) - resize(): early return if size unchanged (skip 350K element reallocation) - Clean unused mut warning - 172 FPS avg, p99 14ms (was 66 FPS, p99 180ms)
This commit is contained in:
+11
-11
@@ -1,17 +1,17 @@
|
|||||||
{
|
{
|
||||||
"mode": "graphics",
|
"mode": "graphics",
|
||||||
"ticks": 600,
|
"ticks": 600,
|
||||||
"total_time_ms": 4648.7,
|
"total_time_ms": 3483.9,
|
||||||
"avg_fps": 129.1,
|
"avg_fps": 172.2,
|
||||||
"avg_frame_time_ms": 7.72,
|
"avg_frame_time_ms": 5.78,
|
||||||
"p99_frame_time_ms": 11.03,
|
"p99_frame_time_ms": 14.20,
|
||||||
"min_frame_time_ms": 7.13,
|
"min_frame_time_ms": 4.20,
|
||||||
"subsystems": {
|
"subsystems": {
|
||||||
"ca_step_avg_us": 1121,
|
"ca_step_avg_us": 1397,
|
||||||
"ca_step_p99_us": 1713,
|
"ca_step_p99_us": 10172,
|
||||||
"ca_step_min_us": 496,
|
"ca_step_min_us": 303,
|
||||||
"render_avg_us": 3543,
|
"render_avg_us": 3668,
|
||||||
"render_p99_us": 4374,
|
"render_p99_us": 5514,
|
||||||
"render_min_us": 3289
|
"render_min_us": 3259
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-2
@@ -77,6 +77,9 @@ impl UiLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn resize(&mut self, w: usize, h: usize) {
|
pub fn resize(&mut self, w: usize, h: usize) {
|
||||||
|
if self.width == w && self.height == h && !self.cells.is_empty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
self.width = w;
|
self.width = w;
|
||||||
self.height = h;
|
self.height = h;
|
||||||
self.cells.clear();
|
self.cells.clear();
|
||||||
@@ -324,8 +327,8 @@ impl UiLayer {
|
|||||||
let mut g = 0u32;
|
let mut g = 0u32;
|
||||||
let mut b = 0u32;
|
let mut b = 0u32;
|
||||||
let mut n = 0u32;
|
let mut n = 0u32;
|
||||||
for yy in 0..scale {
|
for yy in (0..scale).step_by(4) {
|
||||||
for xx in 0..scale {
|
for xx in (0..scale).step_by(4) {
|
||||||
let cell = grid.get(wx + xx, wy + yy);
|
let cell = grid.get(wx + xx, wy + yy);
|
||||||
if cell.material != MaterialId::Empty {
|
if cell.material != MaterialId::Empty {
|
||||||
let c = cell.fg;
|
let c = cell.fg;
|
||||||
|
|||||||
@@ -784,8 +784,14 @@ impl CellularAutomaton {
|
|||||||
let idx = (ly as usize) * CHUNK_SIZE + (lx as usize);
|
let idx = (ly as usize) * CHUNK_SIZE + (lx as usize);
|
||||||
if let Some((radius, color)) = material_light(chunk.cells[idx].material) {
|
if let Some((radius, color)) = material_light(chunk.cells[idx].material) {
|
||||||
sources.push((ox + lx, oy + ly, radius as i32, color));
|
sources.push((ox + lx, oy + ly, radius as i32, color));
|
||||||
|
if sources.len() >= 64 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if sources.len() >= 64 {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ impl ChunkedGrid {
|
|||||||
}
|
}
|
||||||
let key = (cx as i64, cy as i64);
|
let key = (cx as i64, cy as i64);
|
||||||
if !self.chunks.contains_key(&key) {
|
if !self.chunks.contains_key(&key) {
|
||||||
let mut chunk = Chunk::new();
|
let chunk = Chunk::new();
|
||||||
if let Some(ref dir) = self.cache_dir {
|
if let Some(ref dir) = self.cache_dir {
|
||||||
let path = chunk_path(dir, self.seed, cx, cy);
|
let path = chunk_path(dir, self.seed, cx, cy);
|
||||||
if path.exists() {
|
if path.exists() {
|
||||||
|
|||||||
Reference in New Issue
Block a user