From 15e239a0dceda41828a00a495a0cf224e8ac3abf Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 2 Feb 2024 12:47:51 -0800 Subject: [PATCH] cache line boundary visualization --- src/df/gfx/df_views.c | 31 +++++++++++++++++++++++++++++++ src/ui/ui_basic_widgets.c | 13 ++++++++++--- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index aa710ee5..b1dfba97 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -1180,6 +1180,37 @@ df_eval_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_EvalW } UI_NamedTableVectorF("row_%I64x_%I64x_%I64x", row_hash, expr_hash, ewv->root_count) { + //- rjf: draw start of cache lines in expansions + if((row->eval.mode == EVAL_EvalMode_Addr || row->eval.mode == EVAL_EvalMode_NULL) && + row->eval.errors.count == 0 && + row->eval.offset%64 == 0 && row->depth > 0) + { + ui_set_next_fixed_x(0); + ui_set_next_fixed_y(0); + ui_set_next_fixed_height(ui_top_font_size()*0.1f); + ui_set_next_background_color(df_rgba_from_theme_color(DF_ThemeColor_Highlight0)); + ui_build_box_from_key(UI_BoxFlag_Floating|UI_BoxFlag_DrawBackground, ui_key_zero()); + } + + //- rjf: draw mid-row cache line boundaries in expansions + if((row->eval.mode == EVAL_EvalMode_Addr || row->eval.mode == EVAL_EvalMode_NULL) && + row->eval.errors.count == 0 && + row->eval.offset%64 != 0 && + row->depth > 0) + { + U64 next_off = (row->eval.offset + tg_byte_size_from_graph_raddbg_key(parse_ctx.type_graph, parse_ctx.rdbg, row->eval.type_key)); + if(next_off%64 != 0 && row->eval.offset/64 < next_off/64) + { + ui_set_next_fixed_x(0); + ui_set_next_fixed_y(scroll_list_params.row_height_px - ui_top_font_size()*0.5f); + ui_set_next_fixed_height(ui_top_font_size()*1.f); + Vec4F32 boundary_color = df_rgba_from_theme_color(DF_ThemeColor_Highlight0); + boundary_color.w *= 0.25f; + ui_set_next_background_color(boundary_color); + ui_build_box_from_key(UI_BoxFlag_Floating|UI_BoxFlag_DrawBackground, ui_key_zero()); + } + } + //- rjf: expression ProfScope("expr") { diff --git a/src/ui/ui_basic_widgets.c b/src/ui/ui_basic_widgets.c index 4a4bec92..63b5e64d 100644 --- a/src/ui/ui_basic_widgets.c +++ b/src/ui/ui_basic_widgets.c @@ -846,6 +846,8 @@ ui_pane_end(void) thread_static U64 ui_ts_col_pct_count = 0; thread_static F32 *ui_ts_col_pcts_stable = 0; +thread_static U64 ui_ts_vector_idx = 0; +thread_static U64 ui_ts_cell_idx = 0; internal void ui_table_begin(U64 column_pct_count, F32 **column_pcts, String8 string) @@ -957,6 +959,8 @@ ui_table_begin(U64 column_pct_count, F32 **column_pcts, String8 string) { ui_ts_col_pcts_stable[idx] = *column_pcts[idx]; } + + ui_ts_vector_idx = 0; } internal void @@ -983,6 +987,8 @@ ui_named_table_vector_begin(String8 string) ui_set_next_pref_width(ui_pct(1, 0)); ui_set_next_child_layout_axis(Axis2_X); UI_Box *vector = ui_build_box_from_string(UI_BoxFlag_DrawSideBottom, string); + ui_ts_vector_idx += 1; + ui_ts_cell_idx = 0; ui_push_parent(vector); return vector; } @@ -1004,7 +1010,7 @@ internal UI_Box * ui_table_vector_begin(void) { UI_Box *table = ui_top_parent(); - UI_Box *vector = ui_named_table_vector_beginf("###tbl_vec_%p_%I64u", table, table->child_count); + UI_Box *vector = ui_named_table_vector_beginf("###tbl_vec_%p_%I64u", table, ui_ts_vector_idx); return vector; } @@ -1019,7 +1025,7 @@ internal UI_Box * ui_table_cell_begin(void) { UI_Box *vector = ui_top_parent(); - U64 column_idx = vector->child_count; + U64 column_idx = ui_ts_cell_idx; F32 width_pct = column_idx < ui_ts_col_pct_count ? ui_ts_col_pcts_stable[column_idx] : 1.f; return ui_table_cell_sized_begin(ui_pct(width_pct, 0)); } @@ -1035,7 +1041,8 @@ internal UI_Box * ui_table_cell_sized_begin(UI_Size size) { UI_Box *vector = ui_top_parent(); - U64 column_idx = vector->child_count; + U64 column_idx = ui_ts_cell_idx; + ui_ts_cell_idx += 1; ui_set_next_pref_width(size); ui_set_next_child_layout_axis(Axis2_X); UI_Box *cell = ui_build_box_from_stringf((column_idx > 0 ? UI_BoxFlag_DrawSideLeft : 0), "###tbl_cell_%p_%I64u", vector, vector->child_count);