performance counters
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::time::SystemTime;
|
||||
use std::time::Instant;
|
||||
use cgmath::{Deg, Euler, Quaternion, vec3};
|
||||
use glyph_brush::GlyphBrush;
|
||||
use winit::event::Event;
|
||||
@@ -19,6 +19,22 @@ pub mod player;
|
||||
mod level;
|
||||
mod components;
|
||||
|
||||
pub struct GameState {
|
||||
pub paused: bool,
|
||||
pub brush: GlyphBrush<Vec<TextVertex>>,
|
||||
pub test_str: String,
|
||||
}
|
||||
|
||||
impl GameState {
|
||||
fn new() -> GameState {
|
||||
GameState {
|
||||
brush: create_brush(),
|
||||
paused: false,
|
||||
test_str: "".to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestGame {
|
||||
pub input: InputState,
|
||||
pub player: Player,
|
||||
@@ -30,12 +46,6 @@ pub struct TestGame {
|
||||
pub game_state: GameState,
|
||||
}
|
||||
|
||||
pub struct GameState {
|
||||
pub paused: bool,
|
||||
pub brush: GlyphBrush<Vec<TextVertex>>,
|
||||
pub test_str: String,
|
||||
}
|
||||
|
||||
impl Game for TestGame {
|
||||
fn get_game_objects(&self) -> &Vec<GameObject> {
|
||||
&self.game_objects
|
||||
@@ -46,6 +56,8 @@ impl Game for TestGame {
|
||||
}
|
||||
|
||||
fn update(self: &mut Self, renderer: &mut VulkanRenderer) -> ObjectUniformData {
|
||||
let precise_start = Instant::now();
|
||||
|
||||
// Input and timing
|
||||
self.input.frame_start();
|
||||
let time = (renderer.game_data.start_time.elapsed().unwrap().as_micros() as f64 / 1000000.0) as f32;
|
||||
@@ -84,9 +96,7 @@ impl Game for TestGame {
|
||||
}
|
||||
|
||||
if self.input.button_down("print_framerate") {
|
||||
println!("{:.0} ms / {:.0} FPS", frame_time * 1000.0, 1.0 / frame_time);
|
||||
print_quat_as_euler(self.player.camera.rotation);
|
||||
println!();
|
||||
println!("{:?}", renderer.game_data.other_perf_counters);
|
||||
}
|
||||
|
||||
if self.input.button_just_pressed("test") {
|
||||
@@ -107,6 +117,9 @@ impl Game for TestGame {
|
||||
self.last_time = time;
|
||||
self.input.frame_end();
|
||||
|
||||
let precise_duration = precise_start.elapsed().as_micros();
|
||||
renderer.game_data.update_perf_counters[renderer.game_data.performance_counter_index] = precise_duration;
|
||||
|
||||
ObjectUniformData {
|
||||
view: self.player.camera.view.into(),
|
||||
projection: self.player.camera.proj.into(),
|
||||
@@ -132,11 +145,7 @@ impl TestGame {
|
||||
texture_index_counter: 0,
|
||||
last_time: 0.0,
|
||||
components: vec![],
|
||||
game_state: GameState {
|
||||
brush: create_brush(),
|
||||
paused: false,
|
||||
test_str: "".to_string(),
|
||||
}
|
||||
game_state: GameState::new()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,14 +189,14 @@ impl TestGame {
|
||||
}
|
||||
|
||||
for doc_image in document.images() {
|
||||
let texture_start_time = SystemTime::now();
|
||||
let texture_start_time = Instant::now();
|
||||
|
||||
let texture = vulkan::dds::upload_texture_from_file(&format!("models/textures/{}.dds", doc_image.name().unwrap()), renderer).unwrap();
|
||||
renderer.game_data.textures.push(texture);
|
||||
self.texture_index_counter += 1;
|
||||
|
||||
if self.log_config.mesh_load_info {
|
||||
println!("Uploading texture took {:?}ms", texture_start_time.elapsed().unwrap().as_millis());
|
||||
println!("Uploading texture took {:?}ms", texture_start_time.elapsed().as_millis());
|
||||
}
|
||||
}
|
||||
mesh_handles
|
||||
|
||||
Reference in New Issue
Block a user