clean up
This commit is contained in:
parent
2d5777af19
commit
18716074cc
@ -1,7 +1,6 @@
|
|||||||
use crate::model::{Color, HudTileLayer, ScrollableTileLayer, Sprite, TileBank, TileMap, TileSize};
|
|
||||||
use std::mem::size_of;
|
|
||||||
use std::sync::Arc;
|
|
||||||
use crate::hardware::MemoryBanks;
|
use crate::hardware::MemoryBanks;
|
||||||
|
use crate::model::{Color, HudTileLayer, ScrollableTileLayer, Sprite, TileBank, TileMap, TileSize};
|
||||||
|
use std::sync::Arc;
|
||||||
|
|
||||||
/// Blending modes inspired by classic 16-bit hardware.
|
/// Blending modes inspired by classic 16-bit hardware.
|
||||||
/// Defines how source pixels are combined with existing pixels in the framebuffer.
|
/// Defines how source pixels are combined with existing pixels in the framebuffer.
|
||||||
@ -542,46 +541,6 @@ impl Gfx {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the actual memory usage of the graphics structures in bytes.
|
|
||||||
/// Reflects index buffers, palettes, and OAM as per Chapter 10.8.
|
|
||||||
pub fn memory_usage_bytes(&self) -> usize {
|
|
||||||
let mut total = 0;
|
|
||||||
|
|
||||||
// 1. Framebuffers (Front + Back)
|
|
||||||
// Each is Vec<u16>, occupying 2 bytes per pixel.
|
|
||||||
total += self.front.len() * 2;
|
|
||||||
total += self.back.len() * 2;
|
|
||||||
|
|
||||||
// 2. Tile Layers (4 Game Layers)
|
|
||||||
for layer in &self.layers {
|
|
||||||
// Struct size + map data (Vec<Tile>)
|
|
||||||
total += size_of::<ScrollableTileLayer>();
|
|
||||||
total += layer.map.tiles.len() * size_of::<crate::model::Tile>();
|
|
||||||
}
|
|
||||||
|
|
||||||
// 3. HUD Layer
|
|
||||||
total += size_of::<HudTileLayer>();
|
|
||||||
total += self.hud.map.tiles.len() * size_of::<crate::model::Tile>();
|
|
||||||
|
|
||||||
// 4. Tile Banks (Assets and Palettes)
|
|
||||||
let pool = self.memory_banks.gfx.pool.read().unwrap();
|
|
||||||
for bank_opt in pool.iter() {
|
|
||||||
if let Some(bank) = bank_opt {
|
|
||||||
total += size_of::<TileBank>();
|
|
||||||
total += bank.pixel_indices.len();
|
|
||||||
|
|
||||||
// Palette Table: 256 palettes * 16 colors * Color struct size
|
|
||||||
total += 256 * 16 * size_of::<Color>();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 5. Sprites (OAM)
|
|
||||||
// Fixed array of 512 Sprites.
|
|
||||||
total += self.sprites.len() * size_of::<Sprite>();
|
|
||||||
|
|
||||||
total
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn draw_text(&mut self, x: i32, y: i32, text: &str, color: Color) {
|
pub fn draw_text(&mut self, x: i32, y: i32, text: &str, color: Color) {
|
||||||
let mut cx = x;
|
let mut cx = x;
|
||||||
for c in text.chars() {
|
for c in text.chars() {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
|
use prometeu_core::firmware::Firmware;
|
||||||
|
use prometeu_core::Hardware;
|
||||||
use std::time::{Duration, Instant};
|
use std::time::{Duration, Instant};
|
||||||
use winit::window::Window;
|
use winit::window::Window;
|
||||||
use prometeu_core::Hardware;
|
|
||||||
use prometeu_core::firmware::Firmware;
|
|
||||||
|
|
||||||
pub struct HostStats {
|
pub struct HostStats {
|
||||||
pub last_stats_update: Instant,
|
pub last_stats_update: Instant,
|
||||||
@ -31,14 +31,12 @@ impl HostStats {
|
|||||||
self.audio_load_samples += 1;
|
self.audio_load_samples += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn update(&mut self, now: Instant, window: Option<&Window>, hardware: &Hardware, firmware: &Firmware) {
|
pub fn update(&mut self, now: Instant, window: Option<&Window>, _hardware: &Hardware, firmware: &Firmware) {
|
||||||
let stats_elapsed = now.duration_since(self.last_stats_update);
|
let stats_elapsed = now.duration_since(self.last_stats_update);
|
||||||
if stats_elapsed >= Duration::from_secs(1) {
|
if stats_elapsed >= Duration::from_secs(1) {
|
||||||
self.current_fps = self.frames_since_last_update as f64 / stats_elapsed.as_secs_f64();
|
self.current_fps = self.frames_since_last_update as f64 / stats_elapsed.as_secs_f64();
|
||||||
|
|
||||||
if let Some(window) = window {
|
if let Some(window) = window {
|
||||||
let kb = hardware.gfx.memory_usage_bytes() as f64 / 1024.0;
|
|
||||||
|
|
||||||
// Fixed comparison always against 60Hz, keep even when doing CPU stress tests
|
// Fixed comparison always against 60Hz, keep even when doing CPU stress tests
|
||||||
let frame_budget_us = 16666.0;
|
let frame_budget_us = 16666.0;
|
||||||
let cpu_load_core = (firmware.os.last_frame_cpu_time_us as f64 / frame_budget_us) * 100.0;
|
let cpu_load_core = (firmware.os.last_frame_cpu_time_us as f64 / frame_budget_us) * 100.0;
|
||||||
@ -51,7 +49,7 @@ impl HostStats {
|
|||||||
|
|
||||||
let title = format!(
|
let title = format!(
|
||||||
"PROMETEU | GFX: {:.1} KB | FPS: {:.1} | Load: {:.1}% (C) + {:.1}% (A) | Frame: tick {} logical {}",
|
"PROMETEU | GFX: {:.1} KB | FPS: {:.1} | Load: {:.1}% (C) + {:.1}% (A) | Frame: tick {} logical {}",
|
||||||
kb, self.current_fps, cpu_load_core, cpu_load_audio, firmware.os.tick_index, firmware.os.logical_frame_index
|
0, self.current_fps, cpu_load_core, cpu_load_audio, firmware.os.tick_index, firmware.os.logical_frame_index
|
||||||
);
|
);
|
||||||
window.set_title(&title);
|
window.set_title(&title);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user