Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/UI/ImDebugger/ImGe.h
3185 views
1
#pragma once
2
3
#include "GPU/Common/GPUDebugInterface.h"
4
5
// GE-related windows of the ImDebugger
6
7
struct ImConfig;
8
struct ImControl;
9
10
class FramebufferManagerCommon;
11
class TextureCacheCommon;
12
13
constexpr ImU32 ImDebuggerColor_Diff = IM_COL32(255, 96, 32, 255);
14
constexpr ImU32 ImDebuggerColor_DiffAlpha = IM_COL32(255, 96, 32, 128);
15
16
void DrawFramebuffersWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager);
17
void DrawTexturesWindow(ImConfig &cfg, TextureCacheCommon *textureCache);
18
void DrawDisplayWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager);
19
void DrawDebugStatsWindow(ImConfig &cfg);
20
21
class ImGeDisasmView {
22
public:
23
void Draw(GPUDebugInterface *gpuDebug);
24
25
bool followPC_ = true;
26
27
void GotoPC() {
28
gotoPC_ = true;
29
}
30
31
void GotoAddr(uint32_t addr) {
32
selectedAddr_ = addr;
33
}
34
35
void NotifyStep();
36
37
private:
38
u32 selectedAddr_ = 0;
39
u32 dragAddr_ = INVALID_ADDR;
40
bool bpPopup_ = false;
41
bool gotoPC_ = false;
42
enum : u32 {
43
INVALID_ADDR = 0xFFFFFFFF
44
};
45
};
46
47
class ImGeStateWindow {
48
public:
49
void Draw(ImConfig &cfg, ImControl &control, GPUDebugInterface *gpuDebug);
50
void Snapshot();
51
};
52
53
void DrawImGeVertsWindow(ImConfig &cfg, ImControl &control, GPUDebugInterface *gpuDebug);
54
55
namespace Draw {
56
class Texture;
57
enum class Aspect;
58
enum class DataFormat : uint8_t;
59
}
60
61
class PixelLookup {
62
public:
63
virtual ~PixelLookup() {}
64
65
virtual bool FormatValueAt(char *buf, size_t bufSize, int x, int y) const = 0;
66
};
67
68
struct ImGePixelViewer : public PixelLookup {
69
~ImGePixelViewer();
70
bool Draw(GPUDebugInterface *gpuDebug, Draw::DrawContext *draw, float zoom);
71
void Snapshot() {
72
dirty_ = true;
73
}
74
bool FormatValueAt(char *buf, size_t bufSize, int x, int y) const override;
75
void DeviceLost();
76
77
uint32_t addr = 0x04110000;
78
uint16_t stride = 512;
79
uint16_t width = 480;
80
uint16_t height = 272;
81
GEBufferFormat format = GE_FORMAT_DEPTH16;
82
bool useAlpha = false;
83
bool showAlpha = false;
84
float scale = 20.0f;
85
86
private:
87
void UpdateTexture(Draw::DrawContext *draw);
88
Draw::Texture *texture_ = nullptr;
89
bool dirty_ = true;
90
};
91
92
// Reads back framebuffers, not textures.
93
struct ImGeReadbackViewer : public PixelLookup {
94
ImGeReadbackViewer();
95
~ImGeReadbackViewer();
96
bool Draw(GPUDebugInterface *gpuDebug, Draw::DrawContext *draw, float zoom);
97
void Snapshot() {
98
dirty_ = true;
99
}
100
bool FormatValueAt(char *buf, size_t bufSize, int x, int y) const override;
101
void DeviceLost();
102
103
// TODO: This is unsafe! If you load state for example with the debugger open...
104
// We need to re-fetch this each frame from the parameters.
105
VirtualFramebuffer *vfb = nullptr;
106
107
// This specifies what to show
108
Draw::Aspect aspect;
109
float scale = 1.0f; // Scales depth values.
110
111
private:
112
uint8_t *data_ = nullptr;
113
Draw::DataFormat readbackFmt_;
114
Draw::Texture *texture_ = nullptr;
115
bool dirty_ = true;
116
};
117
118
class ImGePixelViewerWindow {
119
public:
120
void Draw(ImConfig &cfg, ImControl &control, GPUDebugInterface *gpuDebug, Draw::DrawContext *draw);
121
void Snapshot() {
122
viewer_.Snapshot();
123
}
124
void Show(uint32_t address, int width, int height, int stride, GEBufferFormat format) {
125
viewer_.addr = address;
126
viewer_.width = width;
127
viewer_.height = height;
128
viewer_.stride = stride;
129
viewer_.format = format;
130
}
131
void DeviceLost() {
132
viewer_.DeviceLost();
133
}
134
135
private:
136
ImGePixelViewer viewer_;
137
};
138
139
class ImGeDebuggerWindow {
140
public:
141
ImGeDebuggerWindow();
142
void Draw(ImConfig &cfg, ImControl &control, GPUDebugInterface *gpuDebug, Draw::DrawContext *draw);
143
ImGeDisasmView &View() {
144
return disasmView_;
145
}
146
const char *Title() const {
147
return "GE Debugger";
148
}
149
void NotifyStep();
150
void DeviceLost();
151
152
private:
153
ImGeDisasmView disasmView_;
154
ImGeReadbackViewer rbViewer_;
155
ImGePixelViewer swViewer_;
156
int showBannerInFrames_ = 0;
157
bool reloadPreview_ = false;
158
GEPrimitiveType previewPrim_ = GEPrimitiveType::GE_PRIM_TRIANGLES;
159
std::vector<u16> previewIndices_;
160
std::vector<GPUDebugVertex> previewVertices_;
161
int previewCount_ = 0;
162
Draw::Aspect selectedAspect_;
163
float previewZoom_ = 1.0f;
164
};
165
166