Polyphase Game Engine
Loading...
Searching...
No Matches
MemorySnapshot.h
Go to the documentation of this file.
1#pragma once
2
3#if EDITOR
4
5#include <cstdint>
6#include <string>
7#include <vector>
8
9// On-disk snapshot format version. Independent from ASSET_VERSION_CURRENT --
10// snapshots are loose Debug/ artifacts, not registered assets. Bump when the
11// serialized layout in MemorySnapshotProfiler changes and gate the load path.
12static const uint32_t kSnapshotVersion = 1;
13
14// Four-byte magic at the head of a DebugSnapshot_*.oct file ("PSNP").
15static const uint32_t kSnapshotMagic = 0x504e5350;
16
17enum class SnapshotCategory : uint8_t
18{
19 Geometry, // StaticMesh / SkeletalMesh vertex + index data
20 Textures, // Texture pixel data (referenced directly or via materials/fonts)
21 Audio, // SoundWave PCM
22 Scripts, // Lua source referenced by node Script components
23 Materials, // Material shader parameters
24 Fonts, // Font glyph metadata (atlas texture counts under Textures)
25 Particles, // ParticleSystem config
26 Animation, // SkeletalMesh animation keyframe data
27 Nodes, // Runtime node overhead in the game world
28 Other, // Anything without a cheap size estimate
29 FrameBuffer,// Render targets / framebuffers (color x2 + depth) for the surface
30
31 Count
32};
33
34const char* SnapshotCategoryName(SnapshotCategory cat);
35
36struct SnapshotEntry
37{
38 std::string mName;
39 std::string mTypeName;
40 SnapshotCategory mCategory = SnapshotCategory::Other;
41 uint64_t mCpuBytes = 0; // system RAM
42 uint64_t mGpuBytes = 0; // VRAM (0 on unified-memory backends / non-Vulkan)
43 uint32_t mRefCount = 0; // how many game nodes reference this
44 std::string mDetail; // e.g. "1024x1024 RGBA8 +mips", "12k verts", "3.2s 44.1kHz stereo"
45};
46
47struct MemorySnapshot
48{
49 uint32_t mVersion = kSnapshotVersion;
50 std::string mProjectName;
51 std::string mDateString;
52 bool mWasPlayingInEditor = false; // captured live during PIE vs the edit-time scene
53 uint32_t mActiveAudioVoices = 0; // voices playing at capture time
54
55 // Whole-process figures for context. Explicitly NOT game-scoped -- they
56 // include editor overhead and are shown separately from the per-asset sum.
57 uint64_t mSystemRamUsed = 0;
58 uint64_t mSystemVramUsed = 0;
59 uint64_t mSystemTotalRam = 0;
60
61 std::vector<SnapshotEntry> mEntries;
62
63 // Optional downscaled frame thumbnail (RGBA8, row-major, mThumbW*mThumbH*4 bytes).
64 uint32_t mThumbW = 0;
65 uint32_t mThumbH = 0;
66 std::vector<uint8_t> mThumbRgba;
67
68 // Convenience: total CPU/GPU bytes across all entries.
69 uint64_t GetTotalCpuBytes() const;
70 uint64_t GetTotalGpuBytes() const;
71 void GetCategoryTotals(uint64_t outCpu[(int)SnapshotCategory::Count],
72 uint64_t outGpu[(int)SnapshotCategory::Count]) const;
73};
74
75#endif
Definition SkeletalMesh.h:77