#include "adapters/windows/rendering/RenderDiagnostics.h"

#include "foundation/diagnostics/Metrics.h"

namespace ta::adapters::windows::rendering::diagnostics
{
    namespace
    {
        ta::foundation::diagnostics::Counter present_hits;
        ta::foundation::diagnostics::Flag imgui_initialized;
        ta::foundation::diagnostics::TimingMetric overlay_frame_timing;
    }

    void reset() noexcept
    {
        present_hits.reset();
        imgui_initialized.reset();
        overlay_frame_timing.reset();
    }

    void mark_present() noexcept { present_hits.increment(); }
    void set_imgui_initialized(const bool initialized) noexcept { imgui_initialized.set(initialized); }
    void record_overlay_frame_duration(const std::uint64_t nanoseconds) noexcept
    {
        overlay_frame_timing.record(nanoseconds);
    }

    ta::application::diagnostics::RenderDiagnosticsSnapshot snapshot() noexcept
    {
        return {present_hits.value(), imgui_initialized.value(), overlay_frame_timing.snapshot()};
    }
}
