mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-12 23:31:38 -07:00
radbin: compress sections wide, deduplicate work
This commit is contained in:
+10
-5
@@ -775,7 +775,7 @@ rb_thread_entry_point(void *p)
|
||||
|
||||
//- rjf: bake
|
||||
RDIM_BakeResults bake_results = {0};
|
||||
if(convert_done) ProfScope("bake")
|
||||
ProfScope("bake")
|
||||
{
|
||||
bake_results = rdim_bake(arena, bake_params);
|
||||
}
|
||||
@@ -789,14 +789,19 @@ rb_thread_entry_point(void *p)
|
||||
case OutputKind_RDI:
|
||||
{
|
||||
// rjf: serialize
|
||||
RDIM_SerializedSectionBundle serialized_section_bundle = {0};
|
||||
ProfScope("serialize") serialized_section_bundle = rdim_serialized_section_bundle_from_bake_results(&bake_results);
|
||||
RDIM_SerializedSectionBundle *serialized_section_bundle = 0;
|
||||
ProfScope("serialize") if(lane_idx() == 0)
|
||||
{
|
||||
serialized_section_bundle = push_array(arena, RDIM_SerializedSectionBundle, 1);
|
||||
serialized_section_bundle[0] = rdim_serialized_section_bundle_from_bake_results(&bake_results);
|
||||
}
|
||||
lane_sync_u64(&serialized_section_bundle, 0);
|
||||
|
||||
// rjf: compress
|
||||
RDIM_SerializedSectionBundle serialized_section_bundle__compressed = serialized_section_bundle;
|
||||
RDIM_SerializedSectionBundle serialized_section_bundle__compressed = serialized_section_bundle[0];
|
||||
if(cmd_line_has_flag(cmdline, str8_lit("compress"))) ProfScope("compress")
|
||||
{
|
||||
serialized_section_bundle__compressed = rdim_compress(arena, &serialized_section_bundle);
|
||||
serialized_section_bundle__compressed = rdim_compress(arena, serialized_section_bundle);
|
||||
}
|
||||
|
||||
// rjf: serialize
|
||||
|
||||
@@ -2969,18 +2969,23 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
|
||||
internal RDIM_SerializedSectionBundle
|
||||
rdim_compress(Arena *arena, RDIM_SerializedSectionBundle *in)
|
||||
{
|
||||
RDIM_SerializedSectionBundle out = {0};
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
RDIM_SerializedSectionBundle out_ = {0};
|
||||
RDIM_SerializedSectionBundle *out = &out_;
|
||||
lane_sync_u64(&out, 0);
|
||||
|
||||
//- rjf: set up compression context
|
||||
rr_lzb_simple_context ctx = {0};
|
||||
ctx.m_tableSizeBits = 14;
|
||||
ctx.m_hashTable = push_array(arena, U16, 1<<ctx.m_tableSizeBits);
|
||||
ctx.m_hashTable = push_array(scratch.arena, U16, 1<<ctx.m_tableSizeBits);
|
||||
|
||||
//- rjf: compress, or just copy, all sections
|
||||
for EachEnumVal(RDI_SectionKind, k)
|
||||
Rng1U64 range = lane_range(RDI_SectionKind_COUNT);
|
||||
for EachInRange(idx, range)
|
||||
{
|
||||
RDI_SectionKind k = (RDI_SectionKind)idx;
|
||||
RDIM_SerializedSection *src = &in->sections[k];
|
||||
RDIM_SerializedSection *dst = &out.sections[k];
|
||||
RDIM_SerializedSection *dst = &out->sections[k];
|
||||
MemoryCopyStruct(dst, src);
|
||||
if(src->encoded_size != 0)
|
||||
{
|
||||
@@ -2991,6 +2996,8 @@ rdim_compress(Arena *arena, RDIM_SerializedSectionBundle *in)
|
||||
dst->encoding = RDI_SectionEncoding_LZB;
|
||||
}
|
||||
}
|
||||
lane_sync();
|
||||
|
||||
return out;
|
||||
scratch_end(scratch);
|
||||
return *out;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user