aboutsummaryrefslogtreecommitdiffstats
path: root/src/profiling.c
diff options
context:
space:
mode:
authorBad Diode <bd@badd10de.dev>2023-04-23 15:48:59 +0200
committerBad Diode <bd@badd10de.dev>2023-04-23 15:48:59 +0200
commitff6e784e7c5ebe223666c6c631305397ad358289 (patch)
tree0f87823d48366a6beb8d36d7eea5dc33663d7abd /src/profiling.c
parentdeb9c48fbd3dc5854de4ae3a04dc999029c10ae0 (diff)
downloadstepper-ff6e784e7c5ebe223666c6c631305397ad358289.tar.gz
stepper-ff6e784e7c5ebe223666c6c631305397ad358289.zip
Start decoupling of rendering from update passes
Diffstat (limited to 'src/profiling.c')
-rw-r--r--src/profiling.c39
1 files changed, 16 insertions, 23 deletions
diff --git a/src/profiling.c b/src/profiling.c
index 7a4f4ad..a3b073b 100644
--- a/src/profiling.c
+++ b/src/profiling.c
@@ -41,22 +41,16 @@
41#endif 41#endif
42 42
43static bool profile_show = true; 43static bool profile_show = true;
44static bool profile_bg_show = true;
45 44
46#define PROF_SHOW() \ 45#define PROF_SHOW() \
47 do { \ 46 do { \
48 if (key_tap(KEY_START)) {\ 47 if (key_tap(KEY_START)) {\
49 profile_show ^= 1;\ 48 profile_show ^= 1;\
50 }\ 49 }\
51 if (key_tap(KEY_SELECT)) {\
52 profile_bg_show ^= 1;\
53 }\
54 if (profile_show) {\ 50 if (profile_show) {\
55 txt_color(1);\ 51 txt_color(1);\
56 txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\ 52 txt_position((PROF_SHOW_X), (PROF_SHOW_Y));\
57 if (profile_bg_show) {\ 53 draw_filled_rect((PROF_SHOW_X), (PROF_SHOW_X), 8 * 14, 8 * 10, 0);\
58 draw_filled_rect((PROF_SHOW_X), (PROF_SHOW_X), 8 * 18, 8 * 14, 0);\
59 }\
60 txt_printf("VIDEO\n");\ 54 txt_printf("VIDEO\n");\
61 txt_printf(">CLEAR %.8lu\n", avg_clear_cycles);\ 55 txt_printf(">CLEAR %.8lu\n", avg_clear_cycles);\
62 txt_printf(">FLIP %.8lu\n", avg_flip_cycles);\ 56 txt_printf(">FLIP %.8lu\n", avg_flip_cycles);\
@@ -66,25 +60,24 @@ static bool profile_bg_show = true;
66 txt_printf(">PARAM %.8lu\n", avg_draw_param_cycles);\ 60 txt_printf(">PARAM %.8lu\n", avg_draw_param_cycles);\
67 txt_printf(">PIANO %.8lu\n", avg_draw_piano_cycles);\ 61 txt_printf(">PIANO %.8lu\n", avg_draw_piano_cycles);\
68 txt_printf(">CURSOR %.8lu\n", avg_draw_cursor_cycles);\ 62 txt_printf(">CURSOR %.8lu\n", avg_draw_cursor_cycles);\
69 txt_printf(">RENDER %.8lu\n", avg_render_cycles);\ 63 txt_printf("RENDER %.8lu\n", avg_render_cycles);\
64 txt_printf("INPUT %.8lu\n", avg_input_cycles);\
70 txt_printf("TOTAL %.8lu\n", avg_frame_cycles);\ 65 txt_printf("TOTAL %.8lu\n", avg_frame_cycles);\
71 txt_render();\ 66 txt_render();\
72 }\ 67 }\
73 if (profile_bg_show) {\ 68 u32 frame_time =\
74 u32 frame_time =\ 69 FP_DIV(\
75 FP_DIV(\ 70 FP_NUM(avg_frame_cycles + 1, 2),\
76 FP_NUM(avg_frame_cycles + 1, 2),\ 71 FP_NUM(2809, 2),\
77 FP_NUM(2809, 2),\ 72 2) * 166;\
78 2) * 166;\ 73 u32 fps =\
79 u32 fps =\ 74 FP_DIV(\
80 FP_DIV(\ 75 FP_NUM(280896 * 60, 2),\
81 FP_NUM(280896 * 60, 2),\ 76 FP_NUM(avg_frame_cycles + 1, 2),\
82 FP_NUM(avg_frame_cycles + 1, 2),\ 77 2);\
83 2);\ 78 draw_filled_rect(8 * 18, 0, 239, 16, 0);\
84 draw_filled_rect(8 * 18, 0, 239, 16, 0);\ 79 txt_drawf("TIME: %.6lu", 8 * 18, 0, 1, frame_time >> 2);\
85 txt_drawf("TIME: %.6lu", 8 * 18, 0, 1, frame_time >> 2);\ 80 txt_drawf("MAX FPS: %.4lu", 8 * 18, 8, 1, (fps >> 2) + 1);\
86 txt_drawf("MAX FPS:%.4lu", 8 * 18, 8, 1, (fps >> 2) + 1);\
87 }\
88 } while (0) 81 } while (0)
89 82
90static u32 prof_frame_counter = 0; 83static u32 prof_frame_counter = 0;