xo-imgui wip
This commit is contained in:
parent
f902f93800
commit
7497751192
4 changed files with 233 additions and 26 deletions
|
|
@ -24,7 +24,7 @@ namespace {
|
|||
app_duty_cycle_top(AppState * p_app_state,
|
||||
DrawState * p_draw_state)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
scope log(XO_DEBUG(false));
|
||||
|
||||
log && log(xtag("imgui_cx", (void*)ImGui::GetCurrentContext()));
|
||||
|
||||
|
|
@ -54,6 +54,8 @@ namespace {
|
|||
* that callback captures copy details (per object!) in AppState
|
||||
*/
|
||||
if (p_app_state->gc_->enable_gc_once()) {
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
log && log(xtag("gc-type", (p_app_state->upto_ == generation::tenured) ? "full" : "incremental"));
|
||||
|
||||
p_draw_state->state_type_ = draw_state_type::animate_gc;
|
||||
|
|
@ -83,9 +85,11 @@ namespace {
|
|||
|
||||
return [p_app_state, p_draw_state, p_f, p_counter](ImGuiContext * imgui_cx)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
scope log(XO_DEBUG(false));
|
||||
|
||||
#ifdef TEMPORARILY_REMOVE
|
||||
app_duty_cycle_top(p_app_state, p_draw_state);
|
||||
#endif
|
||||
|
||||
log && log(xtag("imgui_cx", (void*)ImGui::GetCurrentContext()));
|
||||
|
||||
|
|
@ -94,11 +98,12 @@ namespace {
|
|||
ImGui_ImplSDL2_NewFrame();
|
||||
ImGui::NewFrame();
|
||||
|
||||
#ifdef TEMPORARILY_REMOVE
|
||||
log && log("after NewFrame", xtag("imgui_cx", (void*)ImGui::GetCurrentContext()));
|
||||
|
||||
#ifdef NOT_WORKING
|
||||
ImGuiIO & io = ImGui::GetIO(); (void)io;
|
||||
|
||||
# ifdef NOT_WORKING
|
||||
// background
|
||||
ImGui::SetNextWindowPos(ImVec2(0, 0));
|
||||
ImGui::SetNextWindowSize(io.DisplaySize);
|
||||
|
|
@ -107,24 +112,115 @@ namespace {
|
|||
| ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoBringToFrontOnFocus
|
||||
| ImGuiWindowFlags_NoNavFocus | ImGuiWindowFlags_NoDecoration);
|
||||
ImGui::End();
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Create a simple ImGui window
|
||||
// 1. create a simple ImGui window
|
||||
ImGui::Begin("Hello, Vulkan + SDL2!");
|
||||
ImGui::Text("This is a minimal ImGui + Vulkan + SDL2 example!");
|
||||
#ifdef TEMPORARILY_REMOVE
|
||||
ImGui::Text("appl average %.3f ms/frame (%.1f fps)",
|
||||
1000.0f / io.Framerate, io.Framerate);
|
||||
|
||||
ImGui::Checkbox("demo window", &p_draw_state->show_demo_window_);
|
||||
ImGui::SliderFloat("float", p_f, 0.0f, 1.0f);
|
||||
if (ImGui::Button("Button"))
|
||||
++(*p_counter);
|
||||
ImGui::SameLine();
|
||||
ImGui::Text("counter = %d", *p_counter);
|
||||
ImGui::Text("Application average %.3f ms/frame (%.1f FPS)",
|
||||
1000.0f / ImGui::GetIO().Framerate, ImGui::GetIO().Framerate);
|
||||
|
||||
ImGui::SliderInt("alloc/cycle", &p_app_state->alloc_per_cycle_, 1, 100);
|
||||
ImGui::SliderInt("copy animation budget", &p_draw_state->animate_copy_budget_ms_, 10, 10000);
|
||||
ImGui::NewLine();
|
||||
|
||||
/* N\u2080 = N0, N\u2081 = N1 */
|
||||
ImGui::Text("alloc [%lu] avail [%lu] ",
|
||||
p_draw_state->gcstate_.gc_allocated_,
|
||||
p_draw_state->gcstate_.gc_available_);
|
||||
|
||||
ImGui::Text("promoted [%lu] copy animation [%lu / %lu]",
|
||||
p_draw_state->gcstate_.total_promoted_,
|
||||
static_cast<std::size_t>(p_draw_state->animate_copy_hi_pct_
|
||||
* p_app_state->copy_detail_v_.size() / 100),
|
||||
p_app_state->copy_detail_v_.size());
|
||||
|
||||
ImGui::Text("mutation [%lu] mlog [%lu]",
|
||||
p_draw_state->gcstate_.total_n_mutation_,
|
||||
p_draw_state->gcstate_.gc_mlog_size_);
|
||||
|
||||
ImGui::Text("appl average %.3f ms/frame (%.1f fps)",
|
||||
1000.0f / io.Framerate, io.Framerate);
|
||||
|
||||
ImGui::Text("layout:"
|
||||
" nursery-src alloc rect [%.1f %.1f %.1f %.1f]"
|
||||
" nursery-dest alloc rect [%.1f %.1f %.1f %.1f]"
|
||||
" history rect [%.1f %.1f %.1f %.1f]",
|
||||
p_draw_state->gcw_nursery_layout_.to_alloc_rect().x_lo(),
|
||||
p_draw_state->gcw_nursery_layout_.to_alloc_rect().y_lo(),
|
||||
p_draw_state->gcw_nursery_layout_.to_alloc_rect().x_hi(),
|
||||
p_draw_state->gcw_nursery_layout_.to_alloc_rect().y_hi(),
|
||||
p_draw_state->gcw_nursery_layout_.from_alloc_rect().x_lo(),
|
||||
p_draw_state->gcw_nursery_layout_.from_alloc_rect().y_lo(),
|
||||
p_draw_state->gcw_nursery_layout_.from_alloc_rect().x_hi(),
|
||||
p_draw_state->gcw_nursery_layout_.from_alloc_rect().y_hi(),
|
||||
p_draw_state->gcw_history_rect_.x_lo(),
|
||||
p_draw_state->gcw_history_rect_.y_lo(),
|
||||
p_draw_state->gcw_history_rect_.x_hi(),
|
||||
p_draw_state->gcw_history_rect_.y_hi());
|
||||
ImGui::Text("nursery-dest copy offset [%lu] / size [%lu]"
|
||||
" tenured-dest copy offset [%lu] / size [%lu]",
|
||||
p_app_state->copy_detail_max_nursery_dest_offset_,
|
||||
p_app_state->copy_detail_nursery_dest_size_,
|
||||
p_app_state->copy_detail_max_tenured_dest_offset_,
|
||||
p_app_state->copy_detail_tenured_dest_size_);
|
||||
|
||||
ImDrawList * draw_list = ImGui::GetWindowDrawList();
|
||||
|
||||
ImVec2 canvas_p0 = ImGui::GetCursorScreenPos();
|
||||
ImVec2 canvas_sz = ImGui::GetContentRegionAvail();
|
||||
ImVec2 canvas_p1 = ImVec2(canvas_p0.x + canvas_sz.x, canvas_p0.y + canvas_sz.y);
|
||||
|
||||
/* stash so GC copy animation can find it */
|
||||
p_draw_state->gcw_draw_list_ = draw_list;
|
||||
p_draw_state->gcw_canvas_p0_ = canvas_p0;
|
||||
p_draw_state->gcw_canvas_p1_ = canvas_p1;
|
||||
|
||||
DrawState::draw_gc_state(*p_app_state,
|
||||
p_draw_state->gcstate_,
|
||||
ImRect(canvas_p0, canvas_p1),
|
||||
draw_list,
|
||||
&p_draw_state->gcw_nursery_layout_,
|
||||
&p_draw_state->gcw_tenured_layout_,
|
||||
&p_draw_state->gcw_history_rect_);
|
||||
|
||||
if (p_draw_state->state_type_ == draw_state_type::animate_gc) {
|
||||
auto animate_copy_t1 = std::chrono::steady_clock::now();
|
||||
auto animate_dt = animate_copy_t1 - p_draw_state->animate_copy_t0_;
|
||||
float animate_fraction_spent
|
||||
= (std::chrono::duration_cast<std::chrono::milliseconds>(animate_dt).count()
|
||||
/ static_cast<float>(p_draw_state->animate_copy_budget_ms_));
|
||||
|
||||
p_draw_state->animate_copy_hi_pct_ = 100.0 * animate_fraction_spent;
|
||||
|
||||
DrawState::animate_gc_copy(*p_app_state,
|
||||
*p_draw_state,
|
||||
draw_list);
|
||||
|
||||
/* see 25.0 constant in animate_gc_copy() */
|
||||
if (p_draw_state->animate_copy_hi_pct_ >= 114) {
|
||||
p_draw_state->state_type_ = draw_state_type::alloc;
|
||||
p_draw_state->animate_copy_hi_pct_ = 0;
|
||||
p_app_state->copy_detail_v_.clear();
|
||||
p_app_state->copy_detail_max_nursery_dest_offset_ = 0;
|
||||
p_app_state->copy_detail_nursery_dest_size_ = 0;
|
||||
p_app_state->copy_detail_max_tenured_dest_offset_ = 0;
|
||||
p_app_state->copy_detail_tenured_dest_size_ = 0;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
ImGui::End();
|
||||
|
||||
// 1. big demo window
|
||||
#ifdef TEMPORARILY_REMOVE
|
||||
// 2. big demo window
|
||||
if (p_draw_state->show_demo_window_)
|
||||
ImGui::ShowDemoWindow(&p_draw_state->show_demo_window_);
|
||||
#endif
|
||||
|
||||
// Rendering
|
||||
ImGui::Render();
|
||||
|
|
@ -134,7 +230,7 @@ namespace {
|
|||
|
||||
void app_imgui_load_fonts(ImGuiContext * imgui_cx)
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
scope log(XO_DEBUG(false));
|
||||
log && log(xtag("imgui_cx", (void*)ImGui::GetCurrentContext()));
|
||||
|
||||
ImGuiIO & io = ImGui::GetIO(); (void)io;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue