raddbg: bitmap cache on ui thread - no win from async. incompatible with gl.

This commit is contained in:
Ryan Fleury committed 2026-09-30 12:28:01 -07:00
1 parent a2988333a5
commit 4195ce4bba
5 files changed
+99 -74

No files matched your search

+2 -2
View File
@@ -49,10 +49,10 @@ commands =
// .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
// .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg debug telemetry", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
// .f1 = { .win = "raddbg_stable --ipc kill_all && build radbin", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
// .f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg telemetry debug", .linux = "./build.sh raddbg", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
.f1 = { .win = "raddbg_stable --ipc kill_all && build raddbg telemetry debug", .linux = "./build.sh raddbg", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
//- rjf: [raddbg wsl]
.f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
// .f1 = { .win = "wsl ./build.sh raddbg", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
//- rjf: [scratch]
// .f2 = { .win = "pushd build && for /l %i in (1, 1, 3) do (radbin --rdi raddbg.exe --out:raddbg_%i.rdi && radbin --dump raddbg_%i.rdi --out:raddbg_%i.dump)", .linux = "", .out = "*compilation*", .footer_panel = true, .save_dirty_files = true, .cursor_at_end = false, },
+29 -3
View File
@@ -11508,7 +11508,7 @@ rd_init(CmdLine *cmdln)
rd_cmd(RD_CmdKind_OpenCrashDump, .file_path = implicit_dmp_arg);
}
// rjf: set up user / project paths
//- rjf: set up user / project paths
{
Temp scratch2 = scratch_begin(&scratch.arena, 1);
@@ -11563,7 +11563,7 @@ rd_init(CmdLine *cmdln)
scratch_end(scratch2);
}
// rjf: unpack icon image data
//- rjf: unpack icon image data
{
Temp scratch = scratch_begin(0, 0);
String8 data = rd_icon_file_bytes;
@@ -11658,7 +11658,13 @@ rd_init(CmdLine *cmdln)
scratch_end(scratch);
}
// rjf: check initial installation status
//- rjf: set up bitmap cache
{
rd_state->bitmap_cache_slots_count = 64;
rd_state->bitmap_cache_slots = push_array(arena, RD_BitmapCacheSlot, rd_state->bitmap_cache_slots_count);
}
//- rjf: check initial installation status
rd_state->installed = sh_install_or_uninstall_self(0, 0);
ProfEnd();
@@ -18585,6 +18591,26 @@ rd_frame(void)
}
}
//////////////////////////////
//- rjf: garbage collect untouched bitmaps
//
{
for EachIndex(slot_idx, rd_state->bitmap_cache_slots_count)
{
RD_BitmapCacheSlot *slot = &rd_state->bitmap_cache_slots[slot_idx];
for(RD_BitmapCacheNode *n = rd_state->bitmap_cache_slots[slot_idx].first, *next = 0; n != 0; n = next)
{
next = n->next;
if(n->last_touched_frame_idx + 100 < rd_state->frame_index)
{
r_tex2d_release(n->texture);
DLLRemove(slot->first, slot->last, n);
SLLStackPush(rd_state->bitmap_cache_free_node, n);
}
}
}
}
//////////////////////////////
//- rjf: simulate lag
//
+30
View File
@@ -360,6 +360,31 @@ struct RD_WindowStateSlot
////////////////////////////////
//~ rjf: Main Per-Process Graphical State
typedef struct RD_BitmapTopology RD_BitmapTopology;
struct RD_BitmapTopology
{
Vec2S16 dim;
R_Tex2DFormat fmt;
};
typedef struct RD_BitmapCacheNode RD_BitmapCacheNode;
struct RD_BitmapCacheNode
{
RD_BitmapCacheNode *next;
RD_BitmapCacheNode *prev;
U64 last_touched_frame_idx;
U128 hash;
RD_BitmapTopology top;
R_Handle texture;
};
typedef struct RD_BitmapCacheSlot RD_BitmapCacheSlot;
struct RD_BitmapCacheSlot
{
RD_BitmapCacheNode *first;
RD_BitmapCacheNode *last;
};
typedef struct RD_LoadedDbgInfoNode RD_LoadedDbgInfoNode;
struct RD_LoadedDbgInfoNode
{
@@ -530,6 +555,11 @@ struct RD_State
// rjf: icon texture
R_Handle icon_texture;
// rjf: bitmap cache
RD_BitmapCacheSlot *bitmap_cache_slots;
U64 bitmap_cache_slots_count;
RD_BitmapCacheNode *bitmap_cache_free_node;
// rjf: fixed ui keys
UI_Key drop_completion_key;
UI_Key ctx_menu_key;
+4 -5
View File
@@ -4,17 +4,14 @@
////////////////////////////////
//~ rjf: linux TODO notes
//
// initial alpha:
// [ ] recycling semaphore files - or alt strat?
// [ ] rendering
// [ ] bitmaps / geometry
//
// post initial alpha:
// [ ] windowing
// [ ] wayland
// [ ] support
// [ ] .eh_frame unwinding without .eh_frame_hdr
// [ ] geometry rendering
//
// [x] recycling semaphore files - or alt strat?
// [x] clipboard
// [x] jai exes - busted call stacks / unwind info / paths?
// [x] statically linked EXEs - busted unwinding
@@ -26,6 +23,8 @@
// [x] control
// [x] stale memory - things evaluating to stale values that are definitely not zero
// [x] thread names
// [x] rendering
// [x] bitmaps
////////////////////////////////
//~ rjf: evaluation system pass TODO notes
+34 -64
View File
@@ -4789,13 +4789,6 @@ EV_EXPAND_RULE_INFO_FUNCTION_DEF(graph)
////////////////////////////////
//~ rjf: bitmap @view_hook_impl
typedef struct RD_BitmapTopology RD_BitmapTopology;
struct RD_BitmapTopology
{
Vec2S16 dim;
R_Tex2DFormat fmt;
};
typedef struct RD_BitmapBoxDrawData RD_BitmapBoxDrawData;
struct RD_BitmapBoxDrawData
{
@@ -4814,46 +4807,6 @@ struct RD_BitmapCanvasBoxDrawData
F32 zoom;
};
internal AC_Artifact
rd_bitmap_artifact_create(String8 key, B32 *cancel_signal, AC_Status *status_out, U64 *gen_out)
{
Access *access = access_open();
//- rjf: unpack key
U128 hash = {0};
RD_BitmapTopology top = {0};
{
U64 key_read_off = 0;
key_read_off += str8_deserial_read_struct(key, key_read_off, &hash);
key_read_off += str8_deserial_read_struct(key, key_read_off, &top);
}
String8 data = c_data_from_hash(access, hash);
//- rjf: create texture
R_Handle texture = {0};
if(top.dim.x > 0 && top.dim.y > 0 &&
data.size >= (U64)top.dim.x*(U64)top.dim.y*(U64)r_tex2d_format_bytes_per_pixel_table[top.fmt])
{
texture = r_tex2d_alloc(R_ResourceKind_Static, v2s32(top.dim.x, top.dim.y), top.fmt, data.str);
}
//- rjf: bundle as artifact
AC_Artifact artifact = {0};
StaticAssert(sizeof(artifact) >= sizeof(texture), tex_artifact_size_check);
MemoryCopy(&artifact, &texture, Min(sizeof(texture), sizeof(artifact)));
access_close(access);
return artifact;
}
internal void
rd_bitmap_artifact_destroy(AC_Artifact artifact)
{
R_Handle texture = {0};
MemoryCopy(&texture, &artifact, Min(sizeof(texture), sizeof(artifact)));
r_tex2d_release(texture);
}
internal Vec2F32
rd_bitmap_screen_from_canvas_pos(Vec2F32 view_center_pos, F32 zoom, Rng2F32 rect, Vec2F32 cvs)
{
@@ -4993,29 +4946,46 @@ RD_VIEW_UI_FUNCTION_DEF(bitmap)
RD_BitmapTopology topology = {v2s16(dim.x, dim.y), fmt};
U128 data_hash = {0};
R_Handle texture = {0};
for EachIndex(rewind_idx, C_KEY_HASH_HISTORY_COUNT)
String8 data = {0};
{
U128 hash = c_hash_from_key(texture_key, rewind_idx);
#pragma pack(push, 1)
struct
data_hash = c_hash_from_key(texture_key, 0);
data = c_data_from_hash(access, data_hash);
U64 slot_idx = data_hash.u64[1]%rd_state->bitmap_cache_slots_count;
RD_BitmapCacheSlot *slot = &rd_state->bitmap_cache_slots[slot_idx];
B32 found = 0;
for(RD_BitmapCacheNode *n = slot->first; n != 0; n = n->next)
{
U128 hash;
RD_BitmapTopology top;
if(u128_match(data_hash, n->hash) && MemoryMatchStruct(&topology, &n->top))
{
texture = n->texture;
found = 1;
n->last_touched_frame_idx = rd_state->frame_index;
break;
}
}
key_data = {hash, topology};
#pragma pack(pop)
String8 key = str8_struct(&key_data);
AC_Artifact artifact = ac_artifact_from_key(access, key, rd_bitmap_artifact_create, rd_bitmap_artifact_destroy, 0);
R_Handle texture_candidate = {0};
MemoryCopy(&texture_candidate, &artifact, Min(sizeof(texture_candidate), sizeof(artifact)));
if(!r_handle_match(texture_candidate, r_handle_zero()))
if(!found)
{
data_hash = hash;
texture = texture_candidate;
break;
RD_BitmapCacheNode *node = rd_state->bitmap_cache_free_node;
if(node)
{
SLLStackPop(rd_state->bitmap_cache_free_node);
}
else
{
node = push_array(rd_state->arena, RD_BitmapCacheNode, 1);
}
DLLPushBack(slot->first, slot->last, node);
node->hash = data_hash;
node->top = topology;
node->last_touched_frame_idx = rd_state->frame_index;
MemoryZeroStruct(&node->texture);
if(topology.dim.x > 0 && topology.dim.y > 0 && data.size >= (U64)topology.dim.x*(U64)topology.dim.y*(U64)r_tex2d_format_bytes_per_pixel_table[topology.fmt])
{
node->texture = r_tex2d_alloc(R_ResourceKind_Static, v2s32(dim.x, dim.y), topology.fmt, data.str);
}
texture = node->texture;
}
}
String8 data = c_data_from_hash(access, data_hash);
//////////////////////////////
//- rjf: equip loading info