From a922403acc298b06eac652397108dbecf185bb7e Mon Sep 17 00:00:00 2001 From: jaby Date: Tue, 1 Oct 2024 21:34:51 +0200 Subject: [PATCH] Integrate time measurement --- .../application/src/Overlay/GPUTest/gpu_test.cpp | 11 +++++++++++ include/PSX/System/IOPorts/timer_io.hpp | 1 - 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp b/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp index 122d0509..e4c85c8e 100644 --- a/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp +++ b/examples/PoolBox/application/src/Overlay/GPUTest/gpu_test.cpp @@ -3,6 +3,7 @@ #include #include #include +#include namespace GPUTest { using namespace JabyEngine; @@ -120,7 +121,10 @@ namespace GPUTest { void main() { rect9.concat(rect10); Shared::back_menu.reset(); + HighResTime::enable(); + auto start_time = HighResTime::get_time_stamp(); + auto time_passed = 0; while(true) { // Update Phase Periphery::query_controller(); @@ -128,7 +132,13 @@ namespace GPUTest { break; } + auto cursor = FontWriter::update(Make::PositionI16((GPU::Display::Width - 160)/2, GPU::Display::Height - 32)); + FontWriter::bios_font_writer.write(cursor, "Time: %ims", GPU::Color24::Blue(), time_passed); + GPU::swap_buffers_vsync(1); + const auto end_time = HighResTime::get_time_stamp(); + time_passed = start_time.milliseconds_to(end_time); + start_time = end_time; GPU::render(triangle1); GPU::render(triangle2); @@ -159,5 +169,6 @@ namespace GPUTest { GPU::render(rect9); Shared::back_menu.render(); } + HighResTime::disable(); } } diff --git a/include/PSX/System/IOPorts/timer_io.hpp b/include/PSX/System/IOPorts/timer_io.hpp index 00c30e89..5cda8a83 100644 --- a/include/PSX/System/IOPorts/timer_io.hpp +++ b/include/PSX/System/IOPorts/timer_io.hpp @@ -82,7 +82,6 @@ namespace JabyEngine { return (0x1F801100 + (ID*0x10)); } - // TODO: Improve this to actually use it for measurement - if possible static auto& Counter0 = __declare_io_value(struct Counter0, counter_base_adr(0)); static auto& Counter1 = __declare_io_value(struct Counter1, counter_base_adr(1)); static auto& Counter2 = __declare_io_value(struct Counter2, counter_base_adr(2));