Files
Juliet/AgentData/Imgui.md
2026-01-20 22:11:43 -05:00

3.7 KiB

ImGui Integration & Memory Debugger

Task List

  • Preparation

    • Fetch Dear ImGui Source Files (Verified existing submodule)
    • Create External/imgui/Imgui.bff
    • Update fbuild.bff to include Imgui.bff
    • Update Juliet.bff to link ImGui and include paths
    • Update D3D12DescriptorHeap to support ImGui (SRV for Font)
  • Memory Arena Debugging

    • Modify MemoryArena struct to store allocation tags (Debug builds only)
    • Update ArenaPush signature to accept const char* tag
    • Update call sites (default parameter should minimize churn)
  • ImGui Core & TDD

    • Create Core/ImGui/ImGuiService.h/cpp (Wrapper)
    • Create Core/ImGui/ImGuiTests.cpp
    • Implement ImGui::SetAllocatorFunctions using EngineArena
    • Test context creation and IO setup
  • Integration

    • Win32: Integrate WndProc in Win32DisplayEvent.cpp
    • DX12: Initialize/Shutdown in D3D12GraphicsDevice (Implemented in ImGuiRenderer.cpp)
    • DX12: Render Frame in D3D12GraphicsDevice (Fixed Buffer Crash)
  • Memory Debugger

    • Create Engine/Debug/MemoryDebugger.h/cpp
    • Implement DrawMemoryArena(const char* name, MemoryArena* arena) with Allocation Tags
    • Implement Hex View for Arena Data (Allocations list implemented, Hex view pending/skipped)
    • Integrate into Main Loop (Toggle with 'Home' key)
  • Verification

    • Launch and verify ImGui renders
    • Verify Memory Debugger shows allocations and tags

Implementation Plan

Goal Description

Integrate Dear ImGui into the Juliet engine. Implement a specialized Test Driven Development (TDD) approach. Create a Memory Debugger panel to visualize MemoryArena state with allocation tags.

Proposed Changes

Build System

[NEW] Imgui.bff

  • Defines the ImGui library configuration.
  • Includes imgui.cpp, imgui_draw.cpp, imgui_tables.cpp, imgui_widgets.cpp, imgui_demo.cpp.
  • Includes backends: imgui_impl_win32.cpp, imgui_impl_dx12.cpp.

[MODIFY] fbuild.bff

  • Include External/imgui/Imgui.bff.

[MODIFY] Juliet.bff

  • Add ImGui to Juliet library dependencies.
  • Add External/imgui and External/imgui/backends to include paths.

Core/Memory

[MODIFY] MemoryArena.h [MODIFY] MemoryArena.cpp

  • Struct Change: Add AllocationTracking vector (likely std::vector wrapped or fixed size array) in JULIET_DEBUG.
  • Function Change: ArenaPush(..., const char* tag = nullptr).
  • Logic: Store offset + tag on push.

Core/ImGui

[NEW] ImGuiService.h [NEW] ImGuiService.cpp

  • Wrapper for ImGui lifecycle.
  • Uses EngineArena for internal ImGui allocations.

[NEW] ImGuiTests.cpp

  • TDD suite for ImGui service.

Graphics/D3D12

[MODIFY] D3D12GraphicsDevice.cpp

  • ImGui backend initialization and rendering.

Engine/Debug

[NEW] MemoryDebugger.h [NEW] MemoryDebugger.cpp

  • Draw arena usage bar using tracked tags.
  • Draw hex dump.