vtgl

terminal emulator implemented in OpenGL
git clone anongit@rnpnr.xyz:vtgl.git
Log | Files | Refs | Feed | LICENSE

Commit: e31764a93ca52b0212fb877560df30e6e0ce10f0
Parent: eba9728f9e5397528ac81c6e6dd09f5444913178
Author: Randy Palamar
Date:   Sun, 29 Sep 2024 09:43:41 -0600

add cyc/cell count to debug overlay

Diffstat:
Mbuild.sh | 4++--
Mdebug.c | 26+++++++++++++++++++++++---
2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/build.sh b/build.sh @@ -15,10 +15,10 @@ testcflags="$cflags -O0 -ggdb -D_DEBUG -Wno-unused-function -Wno-undefined-inter if [ $debug ]; then # Hot Reloading/Debugging - cflags="$cflags -D_DEBUG -Wno-unused-function -Wno-undefined-internal" + cflags="$cflags -ggdb -D_DEBUG -Wno-unused-function -Wno-undefined-internal" #cflags="$cflags -fsanitize=address,undefined" - libcflags="$cflags -ggdb -O0 -fPIC" + libcflags="$cflags -O0 -fPIC" libldflags="$ldflags -shared" ${cc} $libcflags vtgl.c -o vtgl.so $libldflags diff --git a/debug.c b/debug.c @@ -258,9 +258,11 @@ draw_debug_overlay(Term *t, RenderPushBuffer *rpb) v2 ws = t->gl.window_size; s8 buf = s8alloc(&t->arena_for_frame, 128); + static Rect r; - r.pos.x = 0.8 * ws.w; - r.size.x = 0.2 * ws.w; + static f32 max_text_width; + r.pos.x = ws.w - 1.1 * max_text_width; + r.size.x = 1.1 * max_text_width; draw_rectangle(rpb, &t->gl, r, (Colour){.rgba = 0x222222ff}); @@ -273,6 +275,8 @@ draw_debug_overlay(Term *t, RenderPushBuffer *rpb) v2 ts = debug_measure_text(t, &t->debug_font, txt, 1); txt_pos.y = (u32)(txt_pos.y - ts.y - line_pad); debug_draw_text(t, rpb, txt, txt_pos, (Colour){.rgba = 0x1e9e33ff}, 1); + + if (ts.w > max_text_width) max_text_width = ts.w; } for (u32 i = 0; i < CC_LAST; i++) { @@ -284,11 +288,27 @@ draw_debug_overlay(Term *t, RenderPushBuffer *rpb) txt_pos.y = (u32)(txt_pos.y - ts.y - line_pad); debug_draw_text(t, rpb, txt, txt_pos, (Colour){.rgba = 0x1e9e33ff}, 1); + if (ts.w > max_text_width) max_text_width = ts.w; + txt.len = snprintf((char *)txt.data, buf.len, fmts[i].line2, (f32)cycs[i]/(f32)hits[i]); ts = debug_measure_text(t, &t->debug_font, txt, 1); txt_pos.y = (u32)(txt_pos.y - ts.y - line_pad); debug_draw_text(t, rpb, txt, txt_pos, (Colour){.rgba = 0x1e9e33ff}, 1); + + if (ts.w > max_text_width) max_text_width = ts.w; } + + { + s8 txt = buf; + txt.len = snprintf((char *)txt.data, buf.len, "FB cyc/cell: %0.02f", + cycs[CC_RENDER_FRAMEBUFFER] / (f32)(t->size.w * t->size.h)); + v2 ts = debug_measure_text(t, &t->debug_font, txt, 1); + txt_pos.y = (u32)(txt_pos.y - ts.y - line_pad); + debug_draw_text(t, rpb, txt, txt_pos, (Colour){.rgba = 0x1e9e33ff}, 1); + + if (ts.w > max_text_width) max_text_width = ts.w; + } + r.pos.y = txt_pos.y - 2 * line_pad; - r.size.y = ws.h - r.pos.y; + r.size.h = ws.h - r.pos.y; }