feat: GPU optimization — lighting, viewport CA, benchmark mode, 531 FPS

- Resolution: 8x8 world cells, 2x2 UI cells (UI_SCALE=4)
- GPU lighting: vertex-shader computed, light source list buffer (max 64)
  instead of O(N×R²) grid scan, O(N×S) per cell
- Viewport-aware CA: iterate only active chunks, not all 250×250
- Flat array entity/item/shadow maps instead of HashMaps
- Flat 128-entry ASCII atlas array instead of HashMap lookup
- Partial grid upload: viewport + 30-cell margin only
- Pre-allocated viewport arrays in renderer structs (zero alloc/frame)
- Skip CPU lighting for GPU modes (pass None)
- Benchmark mode: --mode benchmark with per-subsystem timing
- GpuLightSource struct, light_count in push constants
- gather_sources_in_range() for viewport-scoped source gathering

Benchmark (600 ticks, release):
  Graphics: 531 FPS (was 386, +38%), render 1013us (was 1699us, -40%)
  ASCII:    402 FPS (was 313, +28%), render 1502us (was 2346us, -36%)

All 171 tests + 14 scenarios pass.
This commit is contained in:
Emil
2026-06-21 16:09:45 +03:00
parent c25cae9a32
commit 357db17c2f
53 changed files with 6362 additions and 651 deletions
+16 -2
View File
@@ -1,9 +1,13 @@
use crate::entity::entity::{Entity, EntityKind, EntityManager, EntityId};
use crate::entity::entity::{Entity, EntityId, EntityKind, EntityManager};
use crate::entity::item::Item;
pub struct Player {
pub entity_id: EntityId,
pub move_speed: f32,
pub jump_force: f32,
pub inventory: Vec<Item>,
pub weapon: Option<Item>,
pub armor: Option<Item>,
}
impl Player {
@@ -13,6 +17,9 @@ impl Player {
entity_id: id,
move_speed: 0.5,
jump_force: 1.5,
inventory: Vec::new(),
weapon: None,
armor: None,
}
}
@@ -52,7 +59,14 @@ impl Player {
manager.get(self.entity_id)
}
pub fn entity_mut<'a>(&self, manager: &'a mut EntityManager) -> Option<&'a mut Entity> {
manager.get_mut(self.entity_id)
}
pub fn center(&self, manager: &EntityManager) -> (f32, f32) {
manager.get(self.entity_id).map(|e| e.center()).unwrap_or((0.0, 0.0))
manager
.get(self.entity_id)
.map(|e| e.center())
.unwrap_or((0.0, 0.0))
}
}