mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-09 19:11:38 -07:00
eliminate more dead code in engine
This commit is contained in:
@@ -137,154 +137,6 @@ d_regs_copy(Arena *arena, D_Regs *src)
|
||||
return dst;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Sparse Tree Expansion State Data Structure
|
||||
|
||||
//- rjf: keys
|
||||
|
||||
internal D_ExpandKey
|
||||
d_expand_key_make(U64 parent_hash, U64 child_num)
|
||||
{
|
||||
D_ExpandKey key;
|
||||
{
|
||||
key.parent_hash = parent_hash;
|
||||
key.child_num = child_num;
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
internal D_ExpandKey
|
||||
d_expand_key_zero(void)
|
||||
{
|
||||
D_ExpandKey key = {0};
|
||||
return key;
|
||||
}
|
||||
|
||||
internal B32
|
||||
d_expand_key_match(D_ExpandKey a, D_ExpandKey b)
|
||||
{
|
||||
return MemoryMatchStruct(&a, &b);
|
||||
}
|
||||
|
||||
internal U64
|
||||
df_hash_from_expand_key(D_ExpandKey key)
|
||||
{
|
||||
U64 data[] =
|
||||
{
|
||||
key.child_num,
|
||||
};
|
||||
U64 hash = d_hash_from_seed_string(key.parent_hash, str8((U8 *)data, sizeof(data)));
|
||||
return hash;
|
||||
}
|
||||
|
||||
//- rjf: table
|
||||
|
||||
internal void
|
||||
d_expand_tree_table_init(Arena *arena, D_ExpandTreeTable *table, U64 slot_count)
|
||||
{
|
||||
MemoryZeroStruct(table);
|
||||
table->slots_count = slot_count;
|
||||
table->slots = push_array(arena, D_ExpandSlot, table->slots_count);
|
||||
}
|
||||
|
||||
internal D_ExpandNode *
|
||||
d_expand_node_from_key(D_ExpandTreeTable *table, D_ExpandKey key)
|
||||
{
|
||||
U64 hash = df_hash_from_expand_key(key);
|
||||
U64 slot_idx = hash%table->slots_count;
|
||||
D_ExpandSlot *slot = &table->slots[slot_idx];
|
||||
D_ExpandNode *node = 0;
|
||||
for(D_ExpandNode *n = slot->first; n != 0; n = n->hash_next)
|
||||
{
|
||||
if(d_expand_key_match(n->key, key))
|
||||
{
|
||||
node = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
internal B32
|
||||
d_expand_key_is_set(D_ExpandTreeTable *table, D_ExpandKey key)
|
||||
{
|
||||
D_ExpandNode *node = d_expand_node_from_key(table, key);
|
||||
return (node != 0 && node->expanded);
|
||||
}
|
||||
|
||||
internal void
|
||||
d_expand_set_expansion(Arena *arena, D_ExpandTreeTable *table, D_ExpandKey parent_key, D_ExpandKey key, B32 expanded)
|
||||
{
|
||||
// rjf: map keys => nodes
|
||||
D_ExpandNode *parent_node = d_expand_node_from_key(table, parent_key);
|
||||
D_ExpandNode *node = d_expand_node_from_key(table, key);
|
||||
|
||||
// rjf: make node if we don't have one, and we need one
|
||||
if(node == 0 && expanded)
|
||||
{
|
||||
node = table->free_node;
|
||||
if(node != 0)
|
||||
{
|
||||
table->free_node = table->free_node->next;
|
||||
MemoryZeroStruct(node);
|
||||
}
|
||||
else
|
||||
{
|
||||
node = push_array(arena, D_ExpandNode, 1);
|
||||
}
|
||||
|
||||
// rjf: link into table
|
||||
U64 hash = df_hash_from_expand_key(key);
|
||||
U64 slot = hash % table->slots_count;
|
||||
DLLPushBack_NP(table->slots[slot].first, table->slots[slot].last, node, hash_next, hash_prev);
|
||||
|
||||
// rjf: link into parent
|
||||
if(parent_node != 0)
|
||||
{
|
||||
D_ExpandNode *prev = 0;
|
||||
for(D_ExpandNode *n = parent_node->first; n != 0; n = n->next)
|
||||
{
|
||||
if(n->key.child_num < key.child_num)
|
||||
{
|
||||
prev = n;
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
DLLInsert_NP(parent_node->first, parent_node->last, prev, node, next, prev);
|
||||
node->parent = parent_node;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: fill
|
||||
if(node != 0)
|
||||
{
|
||||
node->key = key;
|
||||
node->expanded = expanded;
|
||||
}
|
||||
|
||||
// rjf: unlink node & free if we don't need it anymore
|
||||
if(expanded == 0 && node != 0 && node->first == 0)
|
||||
{
|
||||
// rjf: unlink from table
|
||||
U64 hash = df_hash_from_expand_key(key);
|
||||
U64 slot = hash % table->slots_count;
|
||||
DLLRemove_NP(table->slots[slot].first, table->slots[slot].last, node, hash_next, hash_prev);
|
||||
|
||||
// rjf: unlink from tree
|
||||
if(parent_node != 0)
|
||||
{
|
||||
DLLRemove_NP(parent_node->first, parent_node->last, node, next, prev);
|
||||
}
|
||||
|
||||
// rjf: free
|
||||
node->next = table->free_node;
|
||||
table->free_node = node;
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Config Type Functions
|
||||
|
||||
@@ -3336,150 +3188,6 @@ d_whole_range_from_eval_space(E_Space space)
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Views
|
||||
|
||||
#if !defined(BLAKE2_H)
|
||||
#define HAVE_SSE2
|
||||
#include "third_party/blake2/blake2.h"
|
||||
#include "third_party/blake2/blake2b.c"
|
||||
#endif
|
||||
|
||||
internal D_EvalViewKey
|
||||
d_eval_view_key_make(U64 v0, U64 v1)
|
||||
{
|
||||
D_EvalViewKey v = {v0, v1};
|
||||
return v;
|
||||
}
|
||||
|
||||
internal D_EvalViewKey
|
||||
d_eval_view_key_from_string(String8 string)
|
||||
{
|
||||
D_EvalViewKey key = {0};
|
||||
blake2b((U8 *)&key.u64[0], sizeof(key), string.str, string.size, 0, 0);
|
||||
return key;
|
||||
}
|
||||
|
||||
internal D_EvalViewKey
|
||||
d_eval_view_key_from_stringf(char *fmt, ...)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
va_list args;
|
||||
va_start(args, fmt);
|
||||
String8 string = push_str8fv(scratch.arena, fmt, args);
|
||||
va_end(args);
|
||||
D_EvalViewKey key = d_eval_view_key_from_string(string);
|
||||
scratch_end(scratch);
|
||||
return key;
|
||||
}
|
||||
|
||||
internal B32
|
||||
d_eval_view_key_match(D_EvalViewKey a, D_EvalViewKey b)
|
||||
{
|
||||
return MemoryMatchStruct(&a, &b);
|
||||
}
|
||||
|
||||
internal D_EvalView *
|
||||
d_eval_view_from_key(D_EvalViewKey key)
|
||||
{
|
||||
D_EvalView *eval_view = &d_nil_eval_view;
|
||||
{
|
||||
U64 slot_idx = key.u64[1]%d_state->eval_view_cache.slots_count;
|
||||
D_EvalViewSlot *slot = &d_state->eval_view_cache.slots[slot_idx];
|
||||
for(D_EvalView *v = slot->first; v != &d_nil_eval_view && v != 0; v = v->hash_next)
|
||||
{
|
||||
if(d_eval_view_key_match(key, v->key))
|
||||
{
|
||||
eval_view = v;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(eval_view == &d_nil_eval_view)
|
||||
{
|
||||
eval_view = push_array(d_state->arena, D_EvalView, 1);
|
||||
DLLPushBack_NPZ(&d_nil_eval_view, slot->first, slot->last, eval_view, hash_next, hash_prev);
|
||||
eval_view->key = key;
|
||||
eval_view->arena = arena_alloc();
|
||||
d_expand_tree_table_init(eval_view->arena, &eval_view->expand_tree_table, 256);
|
||||
eval_view->view_rule_table.slot_count = 64;
|
||||
eval_view->view_rule_table.slots = push_array(eval_view->arena, D_EvalViewRuleCacheSlot, eval_view->view_rule_table.slot_count);
|
||||
}
|
||||
}
|
||||
return eval_view;
|
||||
}
|
||||
|
||||
//- rjf: key -> view rules
|
||||
|
||||
internal void
|
||||
d_eval_view_set_key_rule(D_EvalView *eval_view, D_ExpandKey key, String8 view_rule_string)
|
||||
{
|
||||
//- rjf: key -> hash * slot idx * slot
|
||||
String8 key_string = str8_struct(&key);
|
||||
U64 hash = d_hash_from_string(key_string);
|
||||
U64 slot_idx = hash%eval_view->view_rule_table.slot_count;
|
||||
D_EvalViewRuleCacheSlot *slot = &eval_view->view_rule_table.slots[slot_idx];
|
||||
|
||||
//- rjf: slot -> existing node
|
||||
D_EvalViewRuleCacheNode *existing_node = 0;
|
||||
for(D_EvalViewRuleCacheNode *n = slot->first; n != 0; n = n->hash_next)
|
||||
{
|
||||
if(d_expand_key_match(n->key, key))
|
||||
{
|
||||
existing_node = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: existing node * new node -> node
|
||||
D_EvalViewRuleCacheNode *node = existing_node;
|
||||
if(node == 0)
|
||||
{
|
||||
node = push_array(eval_view->arena, D_EvalViewRuleCacheNode, 1);
|
||||
DLLPushBack_NP(slot->first, slot->last, node, hash_next, hash_prev);
|
||||
node->key = key;
|
||||
node->buffer_cap = 512;
|
||||
node->buffer = push_array(eval_view->arena, U8, node->buffer_cap);
|
||||
}
|
||||
|
||||
//- rjf: mutate node
|
||||
if(node != 0)
|
||||
{
|
||||
node->buffer_string_size = ClampTop(view_rule_string.size, node->buffer_cap);
|
||||
MemoryCopy(node->buffer, view_rule_string.str, node->buffer_string_size);
|
||||
}
|
||||
}
|
||||
|
||||
internal String8
|
||||
d_eval_view_rule_from_key(D_EvalView *eval_view, D_ExpandKey key)
|
||||
{
|
||||
String8 result = {0};
|
||||
|
||||
//- rjf: key -> hash * slot idx * slot
|
||||
String8 key_string = str8_struct(&key);
|
||||
U64 hash = d_hash_from_string(key_string);
|
||||
U64 slot_idx = hash%eval_view->view_rule_table.slot_count;
|
||||
D_EvalViewRuleCacheSlot *slot = &eval_view->view_rule_table.slots[slot_idx];
|
||||
|
||||
//- rjf: slot -> existing node
|
||||
D_EvalViewRuleCacheNode *existing_node = 0;
|
||||
for(D_EvalViewRuleCacheNode *n = slot->first; n != 0; n = n->hash_next)
|
||||
{
|
||||
if(d_expand_key_match(n->key, key))
|
||||
{
|
||||
existing_node = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: node -> result
|
||||
if(existing_node != 0)
|
||||
{
|
||||
result = str8(existing_node->buffer, existing_node->buffer_string_size);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation View Visualization & Interaction
|
||||
|
||||
@@ -4505,10 +4213,11 @@ d_init(void)
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
internal CTRL_EventList
|
||||
d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_Scope *di_scope, F32 dt)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
CTRL_EventList result = {0};
|
||||
d_state->frame_index += 1;
|
||||
arena_clear(d_frame_arena());
|
||||
d_state->frame_eval_memread_endt_us = os_now_microseconds() + 5000;
|
||||
@@ -4529,9 +4238,11 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
|
||||
U64 new_reg_gen = ctrl_reg_gen();
|
||||
|
||||
//- rjf: consume & process events
|
||||
CTRL_EventList events = ctrl_c2u_pop_events(scratch.arena);
|
||||
ctrl_entity_store_apply_events(d_state->ctrl_entity_store, &events);
|
||||
for(CTRL_EventNode *event_n = events.first; event_n != 0; event_n = event_n->next)
|
||||
result = ctrl_c2u_pop_events(arena);
|
||||
ctrl_entity_store_apply_events(d_state->ctrl_entity_store, &result);
|
||||
for(CTRL_EventNode *event_n = result.first;
|
||||
event_n != 0;
|
||||
event_n = event_n->next)
|
||||
{
|
||||
CTRL_Event *event = &event_n->v;
|
||||
log_infof("ctrl_event:\n{\n");
|
||||
@@ -5759,4 +5470,5 @@ d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_
|
||||
}
|
||||
|
||||
ProfEnd();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#define DBG_ENGINE_CORE_H
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Input State Types
|
||||
//~ rjf: Tick Input Types
|
||||
|
||||
typedef struct D_Target D_Target;
|
||||
struct D_Target
|
||||
@@ -1072,20 +1072,6 @@ internal D_HandleList d_handle_list_copy(Arena *arena, D_HandleList list);
|
||||
internal void d_regs_copy_contents(Arena *arena, D_Regs *dst, D_Regs *src);
|
||||
internal D_Regs *d_regs_copy(Arena *arena, D_Regs *src);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Sparse Tree Expansion State Data Structure
|
||||
|
||||
//- rjf: keys
|
||||
internal D_ExpandKey d_expand_key_make(U64 parent_hash, U64 child_num);
|
||||
internal D_ExpandKey d_expand_key_zero(void);
|
||||
internal B32 d_expand_key_match(D_ExpandKey a, D_ExpandKey b);
|
||||
|
||||
//- rjf: table
|
||||
internal void d_expand_tree_table_init(Arena *arena, D_ExpandTreeTable *table, U64 slot_count);
|
||||
internal D_ExpandNode *d_expand_node_from_key(D_ExpandTreeTable *table, D_ExpandKey key);
|
||||
internal B32 d_expand_key_is_set(D_ExpandTreeTable *table, D_ExpandKey key);
|
||||
internal void d_expand_set_expansion(Arena *arena, D_ExpandTreeTable *table, D_ExpandKey parent_key, D_ExpandKey key, B32 expanded);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Config Type Pure Functions
|
||||
|
||||
@@ -1322,22 +1308,6 @@ internal U128 d_key_from_eval_space_range(E_Space space, Rng1U64 range, B32 zero
|
||||
//- rjf: space -> entire range
|
||||
internal Rng1U64 d_whole_range_from_eval_space(E_Space space);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Views
|
||||
|
||||
//- rjf: keys
|
||||
internal D_EvalViewKey d_eval_view_key_make(U64 v0, U64 v1);
|
||||
internal D_EvalViewKey d_eval_view_key_from_string(String8 string);
|
||||
internal D_EvalViewKey d_eval_view_key_from_stringf(char *fmt, ...);
|
||||
internal B32 d_eval_view_key_match(D_EvalViewKey a, D_EvalViewKey b);
|
||||
|
||||
//- rjf: cache lookup
|
||||
internal D_EvalView *d_eval_view_from_key(D_EvalViewKey key);
|
||||
|
||||
//- rjf: key -> view rules
|
||||
internal void d_eval_view_set_key_rule(D_EvalView *eval_view, D_ExpandKey key, String8 view_rule_string);
|
||||
internal String8 d_eval_view_rule_from_key(D_EvalView *eval_view, D_ExpandKey key);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluation Visualization
|
||||
|
||||
@@ -1432,6 +1402,6 @@ internal B32 d_next_cmd(D_Cmd **cmd);
|
||||
//~ rjf: Main Layer Top-Level Calls
|
||||
|
||||
internal void d_init(void);
|
||||
internal void d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_Scope *di_scope, F32 dt);
|
||||
internal CTRL_EventList d_tick(Arena *arena, D_TargetArray *targets, D_BreakpointArray *breakpoints, DI_Scope *di_scope, F32 dt);
|
||||
|
||||
#endif // DBG_ENGINE_CORE_H
|
||||
|
||||
@@ -2514,15 +2514,15 @@ df_watch_view_build(DF_View *view, DF_WatchViewState *ewv, B32 modifiable, U32 d
|
||||
if(col->view_rule_size != 0)
|
||||
{
|
||||
String8 col_view_rule = str8(col->view_rule_buffer, col->view_rule_size);
|
||||
D_CfgTable col_cfg_table = {0};
|
||||
d_cfg_table_push_unparsed_string(scratch.arena, &col_cfg_table, col_view_rule, D_CfgSrc_User);
|
||||
for(D_CfgVal *val = col_cfg_table.first_val; val != 0 && val != &d_nil_cfg_val; val = val->linear_next)
|
||||
EV_ViewRuleList *view_rules = ev_view_rule_list_from_string(scratch.arena, col_view_rule);
|
||||
for(EV_ViewRuleNode *n = view_rules->first; n != 0; n = n->next)
|
||||
{
|
||||
DF_ViewRuleSpec *spec = df_view_rule_spec_from_string(val->string);
|
||||
EV_ViewRule *vr = &n->v;
|
||||
DF_ViewRuleSpec *spec = df_view_rule_spec_from_string(vr->root->string);
|
||||
if(spec != &df_nil_view_rule_spec && spec->info.flags & DF_ViewRuleSpecInfoFlag_RowUI)
|
||||
{
|
||||
cell_ui_hook = spec->info.row_ui;
|
||||
cell_ui_params = val->last->root;
|
||||
cell_ui_params = vr->root;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user