This commit is contained in:
silverweed 2024-07-15 18:02:55 +02:00
parent 700e76366b
commit 7d44204162
3 changed files with 33 additions and 5 deletions

View file

@ -121,6 +121,23 @@ Viewer_Settings make_viewer_settings()
return settings;
}
internal
void jump_to_page(App_State &app, u64 page_idx)
{
assert(app.rndata.n_pages > 0);
page_idx = (page_idx + app.rndata.n_pages) % app.rndata.n_pages;
// @Speed
Page_Info_Node *page = app.rndata.pages;
for (u64 i = 0; i < page_idx; ++i) {
page = page->next;
assert(page);
}
app.vsettings.base_display_addr = page->range.start;
app.vsettings.latest_page_gone_to = page_idx;
}
internal
void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
{
@ -206,11 +223,18 @@ void update_and_render(Arena *arena, App_State &app, f32 delta_time_ms)
ImGui::ColorEdit3("_Page Start", app.vsettings.col_page_start, flags);
ImGui::SameLine();
if (ImGui::Button("Page Start")) {} // TODO: jump to next page
if (ImGui::Button("Page Start")) jump_to_page(app, 0);
ImGui::ColorEdit3("_Page", app.vsettings.col_page, flags);
ImGui::SameLine();
if (ImGui::Button("Page")) {} // TODO: jump to next page
ImGui::ColorEdit3("Page", app.vsettings.col_page, ImGuiColorEditFlags_NoInputs);
ImGui::SameLine();
{
// TODO: support u64
i32 page_to_go_to = static_cast<i32>(app.vsettings.latest_page_gone_to);
ImGui::PushItemWidth(100.f);
if (ImGui::InputInt("##page_viewed", &page_to_go_to))
jump_to_page(app, page_to_go_to);
ImGui::PopItemWidth();
}
ImGui::Separator();
ImGui::Text("Num pages: %lu", app.rndata.n_pages);

View file

@ -8,6 +8,7 @@ struct Viewer_Settings {
float col_page_start[3];
u64 base_display_addr;
u64 latest_page_gone_to;
};
struct Edit_Bg_Color_Data {

View file

@ -77,6 +77,7 @@ void gather_metadata(Arena *arena, RMicroFileReader &reader, const RNTuple_File_
fprintf(stderr, "Loading pages...\n");
chr::time_point start_t = chr::high_resolution_clock::now();
u64 n_slow = 0;
// for all clusters, gather page metadata
for (const RClusterDescriptor &cluster_desc : descriptor.GetClusterIterable()) {
@ -108,8 +109,10 @@ void gather_metadata(Arena *arena, RMicroFileReader &reader, const RNTuple_File_
last_inserted_pinfo->next = pinfo;
} else for (Page_Info_Node *node = pinfo_head->next, *prev = pinfo_head; node; prev = node, node = node->next) {
if (pinfo->range.end() <= node->range.start) {
printf("inserted 0x%lX - 0x%lX (previous was 0x%lX - 0x%lX)\n", pinfo->range.start, pinfo->range.end(), last_inserted_pinfo->range.start, last_inserted_pinfo->range.end());
prev->next = pinfo;
pinfo->next = node;
++n_slow;
break;
}
}
@ -125,7 +128,7 @@ void gather_metadata(Arena *arena, RMicroFileReader &reader, const RNTuple_File_
chr::time_point end_t = chr::high_resolution_clock::now();
u64 time_spent_ms = chr::duration_cast<chr::milliseconds>(end_t - start_t).count();
fprintf(stderr, "Loaded %lu pages in %lu ms.\nGenerating groups...\n", n_pages, time_spent_ms);
fprintf(stderr, "Loaded %lu pages in %lu ms (%lu took the slow path).\nGenerating groups...\n", n_pages, n_slow, time_spent_ms);
// Create page groups and chunks.
// Each page group is a grouping of GROUP_SIZE page infos whose range is equal to the combined ranges