diff options
author | Bad Diode <bd@badd10de.dev> | 2023-04-22 13:19:21 +0200 |
---|---|---|
committer | Bad Diode <bd@badd10de.dev> | 2023-04-22 13:19:21 +0200 |
commit | 2359a27c292514c70f28d337adaee346a23c74be (patch) | |
tree | da4e26e3d0b8aa4914c0ad6fcad2b91beb4e65a1 | |
parent | 9fbf9df6c0048082054df18bcd72e5656a324d28 (diff) | |
download | gba-renderers-2359a27c292514c70f28d337adaee346a23c74be.tar.gz gba-renderers-2359a27c292514c70f28d337adaee346a23c74be.zip |
Add FPS and frame timing calculations to profiling
-rw-r--r-- | src/profiling.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/profiling.c b/src/profiling.c index a464372..7477dca 100644 --- a/src/profiling.c +++ b/src/profiling.c | |||
@@ -55,7 +55,7 @@ static bool profile_bg_show = true; | |||
55 | txt_color(1);\ | 55 | txt_color(1);\ |
56 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ | 56 | txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ |
57 | if (profile_bg_show) {\ | 57 | if (profile_bg_show) {\ |
58 | draw_filled_rect((PROF_SHOW_X), (PROF_SHOW_X), 8 * 17, 8 * 14, 0);\ | 58 | draw_filled_rect((PROF_SHOW_X), (PROF_SHOW_X), 8 * 18, 8 * 14, 0);\ |
59 | }\ | 59 | }\ |
60 | txt_printf("VIDEO\n");\ | 60 | txt_printf("VIDEO\n");\ |
61 | txt_printf(">CLEAR %.8lu\n", avg_clear_cycles);\ | 61 | txt_printf(">CLEAR %.8lu\n", avg_clear_cycles);\ |
@@ -73,6 +73,21 @@ static bool profile_bg_show = true; | |||
73 | txt_printf("TOTAL %.8lu\n", avg_frame_cycles);\ | 73 | txt_printf("TOTAL %.8lu\n", avg_frame_cycles);\ |
74 | txt_render();\ | 74 | txt_render();\ |
75 | }\ | 75 | }\ |
76 | if (profile_bg_show) {\ | ||
77 | u32 frame_time =\ | ||
78 | FP_DIV(\ | ||
79 | FP_NUM(avg_frame_cycles + 1, 2) * 166,\ | ||
80 | FP_NUM(280896, 2) / 100,\ | ||
81 | 2);\ | ||
82 | u32 fps =\ | ||
83 | FP_DIV(\ | ||
84 | FP_NUM(280896, 2),\ | ||
85 | FP_NUM(avg_frame_cycles + 1, 2),\ | ||
86 | 2) * 60;\ | ||
87 | draw_filled_rect(8 * 18, 0, 239, 16, 0);\ | ||
88 | txt_drawf("TIME: %.6d", 8 * 18, 0, 1, frame_time >> 2);\ | ||
89 | txt_drawf("MAX FPS:%.4d", 8 * 18, 8, 1, fps >> 2);\ | ||
90 | }\ | ||
76 | } while (0) | 91 | } while (0) |
77 | 92 | ||
78 | static u32 prof_frame_counter = 0; | 93 | static u32 prof_frame_counter = 0; |