6#ifndef AVARA3D_RENDER_BACKEND_OPENGL_OGLMEMORYTRACKER_H
7#define AVARA3D_RENDER_BACKEND_OPENGL_OGLMEMORYTRACKER_H
11#include <unordered_map>
13#include "a3d/profile/FrameStats.h"
14#include "a3d/render/backend/opengl/GLTypes.h"
18 class OGLMemoryTracker {
23 enum class ObjectNamespace : std::uint8_t {
30 enum class Source : std::uint8_t {
35 enum class Category : std::uint8_t {
44 struct AllocationKey {
45 ObjectNamespace type {};
48 friend bool operator==(
const AllocationKey&,
const AllocationKey&) =
default;
53 void setAllocation(AllocationKey key,
57 std::string label = {});
59 void removeAllocation(AllocationKey key);
60 void clearSource(Source source);
62 RenderMemoryStats stats()
const;
67 struct AllocationKeyHash {
68 std::size_t operator()(
const AllocationKey& key)
const noexcept;
74 std::uint64_t bytes {};
80 std::uint64_t currentTotalBytes()
const;
84 std::unordered_map<AllocationKey, Entry, AllocationKeyHash> _allocations;
85 std::uint64_t _peakTotalBytes {0};