CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In
hrydgard

CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!

GitHub Repository: hrydgard/ppsspp
Path: blob/master/Windows/GEDebugger/GEDebugger.h
Views: 1401
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#pragma once
19
20
#include "Common/CommonWindows.h"
21
#include "GPU/Common/GPUDebugInterface.h"
22
#include "GPU/Debugger/Debugger.h"
23
#include "Windows/resource.h"
24
#include "Windows/W32Util/DialogManager.h"
25
#include "Windows/W32Util/TabControl.h"
26
#include "Windows/GEDebugger/SimpleGLWindow.h"
27
28
enum {
29
WM_GEDBG_STEPDISPLAYLIST = WM_USER + 200,
30
WM_GEDBG_TOGGLEPCBREAKPOINT,
31
WM_GEDBG_RUNTOWPARAM,
32
WM_GEDBG_SETCMDWPARAM,
33
WM_GEDBG_UPDATE_WATCH,
34
};
35
36
class CtrlDisplayListView;
37
class TabDisplayLists;
38
class TabStateFlags;
39
class TabStateLighting;
40
class TabStateTexture;
41
class TabStateSettings;
42
class TabVertices;
43
class TabMatrices;
44
class TabStateWatch;
45
struct GPUgstate;
46
47
enum class GETabPosition {
48
LEFT = 1,
49
RIGHT = 2,
50
TOPRIGHT = 4,
51
ALL = 7,
52
};
53
ENUM_CLASS_BITOPS(GETabPosition);
54
55
enum class GETabType {
56
LIST_DISASM,
57
LISTS,
58
STATE,
59
WATCH,
60
};
61
62
struct GEDebuggerTab {
63
const wchar_t *name;
64
GETabPosition pos;
65
GETabType type;
66
struct {
67
union {
68
Dialog *dlg;
69
CtrlDisplayListView *displayList;
70
void *ptr;
71
};
72
int index = -1;
73
} state[3];
74
void *(*add)(GEDebuggerTab *tab, TabControl *tabs, GETabPosition pos, HINSTANCE inst, HWND parent);
75
void (*remove)(GEDebuggerTab *tab, TabControl *tabs, GETabPosition pos, void *ptr);
76
void (*update)(GEDebuggerTab *tab, TabControl *tabs, GETabPosition pos, void *ptr);
77
};
78
79
class StepCountDlg : public Dialog {
80
public:
81
StepCountDlg(HINSTANCE _hInstance, HWND _hParent);
82
~StepCountDlg();
83
protected:
84
BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
85
private:
86
void Jump(int count, bool relative);
87
};
88
89
class CGEDebugger : public Dialog {
90
public:
91
CGEDebugger(HINSTANCE _hInstance, HWND _hParent);
92
~CGEDebugger();
93
94
static void Init();
95
96
protected:
97
BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam) override;
98
99
private:
100
void SetupPreviews();
101
void UpdatePreviews();
102
void UpdatePrimaryPreview(const GPUgstate &state);
103
void UpdateSecondPreview(const GPUgstate &state);
104
u32 PrimPreviewOp();
105
void UpdatePrimPreview(u32 op, int which);
106
void CleanupPrimPreview();
107
void HandleRedraw(int which);
108
void UpdateSize(WORD width, WORD height);
109
void SavePosition();
110
void UpdateTextureLevel(int level);
111
void DescribePrimaryPreview(const GPUgstate &state, char desc[256]);
112
void DescribeSecondPreview(const GPUgstate &state, char desc[256]);
113
void PrimaryPreviewHover(int x, int y);
114
void SecondPreviewHover(int x, int y);
115
void PreviewExport(const GPUDebugBuffer *buffer);
116
void PreviewToClipboard(const GPUDebugBuffer *buffer, bool saveAlpha);
117
static void DescribePixel(u32 pix, GPUDebugBufferFormat fmt, int x, int y, char desc[256]);
118
static void DescribePixelRGBA(u32 pix, GPUDebugBufferFormat fmt, int x, int y, char desc[256]);
119
void UpdateMenus();
120
void UpdateTab(GEDebuggerTab *tab);
121
void AddTab(GEDebuggerTab *tab, GETabPosition mask);
122
void RemoveTab(GEDebuggerTab *tab, GETabPosition mask);
123
int HasTabIndex(GEDebuggerTab *tab, GETabPosition pos);
124
void CheckTabMessage(TabControl *t, GETabPosition pos, LPARAM lParam);
125
126
u32 TexturePreviewFlags(const GPUgstate &state);
127
128
SimpleGLWindow *primaryWindow = nullptr;
129
SimpleGLWindow *secondWindow = nullptr;
130
std::vector<GEDebuggerTab> tabStates_;
131
TabControl *tabs = nullptr;
132
TabControl *tabsRight_ = nullptr;
133
TabControl *tabsTR_ = nullptr;
134
TabControl *fbTabs = nullptr;
135
int textureLevel_ = 0;
136
bool showClut_ = false;
137
bool forceOpaque_ = false;
138
bool autoFlush_ = true;
139
// The most recent primary/framebuffer and texture buffers.
140
const GPUDebugBuffer *primaryBuffer_ = nullptr;
141
const GPUDebugBuffer *secondBuffer_ = nullptr;
142
bool primaryIsFramebuffer_ = false;
143
bool secondIsFramebuffer_ = false;
144
145
uint32_t primaryTrackX_ = 0xFFFFFFFF;
146
uint32_t primaryTrackY_ = 0xFFFFFFFF;
147
uint32_t secondTrackX_ = 0xFFFFFFFF;
148
uint32_t secondTrackY_ = 0xFFFFFFFF;
149
150
bool updating_ = false;
151
int previewsEnabled_ = 3;
152
int minWidth_;
153
int minHeight_;
154
155
StepCountDlg stepCountDlg;
156
};
157
158