Permalink
Browse files

GE Debugger: Keep prim preview on pan/zoom.

  • Loading branch information...
unknownbrackets committed Dec 23, 2017
1 parent a32ccd3 commit c55db7a4963945a3857adeca9c8dab770c988a27
@@ -167,6 +167,9 @@ void CGEDebugger::SetupPreviews() {
return true;
});
primaryWindow->SetRedrawCallback([&] {
HandleRedraw(1);
});
primaryWindow->Clear();
}
if (secondWindow == nullptr) {
@@ -188,6 +191,9 @@ void CGEDebugger::SetupPreviews() {
return true;
});
secondWindow->SetRedrawCallback([&] {
HandleRedraw(2);
});
secondWindow->Clear();
}
}
@@ -258,19 +264,18 @@ void CGEDebugger::UpdatePreviews() {
state = gpuDebug->GetGState();
}
updating_ = true;
UpdateTextureLevel(textureLevel_);
UpdatePrimaryPreview(state);
UpdateSecondPreview(state);
u32 primOp = PrimPreviewOp();
if (primOp != 0) {
UpdatePrimPreview(primOp, 3);
}
DisplayList list;
if (gpuDebug != nullptr && gpuDebug->GetCurrentDisplayList(list)) {
const u32 op = Memory::Read_U32(list.pc);
const u32 cmd = op >> 24;
// TODO: Bezier/spline?
if (cmd == GE_CMD_PRIM && !showClut_) {
UpdatePrimPreview(op);
}
displayList->setDisplayList(list);
}
@@ -282,6 +287,7 @@ void CGEDebugger::UpdatePreviews() {
matrices->Update();
lists->Update();
watch->Update();
updating_ = false;
}
u32 CGEDebugger::TexturePreviewFlags(const GPUgstate &state) {
@@ -70,8 +70,10 @@ class CGEDebugger : public Dialog {
void UpdatePreviews();
void UpdatePrimaryPreview(const GPUgstate &state);
void UpdateSecondPreview(const GPUgstate &state);
void UpdatePrimPreview(u32 op);
u32 PrimPreviewOp();
void UpdatePrimPreview(u32 op, int which);
void CleanupPrimPreview();
void HandleRedraw(int which);
void UpdateSize(WORD width, WORD height);
void SavePosition();
void SetBreakNext(BreakNextType type);
@@ -106,6 +108,7 @@ class CGEDebugger : public Dialog {
const GPUDebugBuffer *primaryBuffer_ = nullptr;
const GPUDebugBuffer *secondBuffer_ = nullptr;
bool updating_ = false;
int minWidth_;
int minHeight_;
};
@@ -68,8 +68,7 @@ static const char basic_vs[] =
"}\n";
SimpleGLWindow::SimpleGLWindow(HWND wnd)
: hWnd_(wnd), valid_(false), drawProgram_(nullptr), vao_(0), tex_(0), flags_(0), zoom_(false),
dragging_(false), offsetX_(0), offsetY_(0), reformatBuf_(nullptr), hoverCallback_(nullptr) {
: hWnd_(wnd) {
SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG_PTR) this);
}
@@ -365,10 +364,23 @@ void SimpleGLWindow::GetContentSize(float &x, float &y, float &fw, float &fh) {
void SimpleGLWindow::Redraw(bool andSwap) {
DrawChecker();
if (tw_ == 0 && th_ == 0) {
auto swapWithCallback = [andSwap, this]() {
if (andSwap) {
Swap();
swapped_ = false;
if (redrawCallback_ && !inRedrawCallback_) {
inRedrawCallback_ = true;
redrawCallback_();
inRedrawCallback_ = false;
}
// In case the callback swaps, don't do it twice.
if (!swapped_) {
Swap();
}
}
};
if (tw_ == 0 && th_ == 0) {
swapWithCallback();
return;
}
@@ -412,7 +424,7 @@ void SimpleGLWindow::Redraw(bool andSwap) {
glDrawElements(GL_TRIANGLE_STRIP, 4, GL_UNSIGNED_BYTE, vao_ ? 0 : indices);
if (andSwap) {
Swap();
swapWithCallback();
}
}
@@ -423,7 +435,9 @@ void SimpleGLWindow::Clear() {
}
void SimpleGLWindow::Begin() {
Redraw(false);
if (!inRedrawCallback_) {
Redraw(false);
}
if (vao_) {
glBindVertexArray(0);
@@ -81,6 +81,7 @@ struct SimpleGLWindow {
}
void Swap() {
swapped_ = true;
SwapBuffers(hDC_);
}
@@ -106,6 +107,10 @@ struct SimpleGLWindow {
void GetContentSize(float &x, float &y, float &fw, float &fh);
void SetRedrawCallback(std::function<void()> callback) {
redrawCallback_ = callback;
}
void SetHoverCallback(std::function<void(int, int)> hoverCallback) {
hoverCallback_ = hoverCallback;
}
@@ -134,7 +139,7 @@ struct SimpleGLWindow {
HWND hWnd_;
HDC hDC_;
HGLRC hGLRC_;
bool valid_;
bool valid_ = false;
// Width and height of the window.
int w_;
int h_;
@@ -143,25 +148,28 @@ struct SimpleGLWindow {
int th_;
bool tflipped_;
GLSLProgram *drawProgram_;
GLuint vao_;
GLuint ibuf_;
GLuint vbuf_;
GLuint checker_;
GLuint tex_;
u32 flags_;
GLSLProgram *drawProgram_ = nullptr;
GLuint vao_ = 0;
GLuint ibuf_ = 0;
GLuint vbuf_ = 0;
GLuint checker_ = 0;
GLuint tex_ = 0;
u32 flags_ = 0;
// Disable shrink (toggled by double click.)
bool zoom_;
bool dragging_;
bool zoom_ = false;
bool dragging_ = false;
bool inRedrawCallback_ = false;
bool swapped_ = false;
int dragStartX_;
int dragStartY_;
u32 dragLastUpdate_;
// Offset to position the texture is drawn at.
int offsetX_;
int offsetY_;
u32 *reformatBuf_;
u32 reformatBufSize_;
int offsetX_ = 0;
int offsetY_ = 0;
u32 *reformatBuf_ = nullptr;
u32 reformatBufSize_ = 0;
std::function<void()> redrawCallback_;
std::function<void(int, int)> hoverCallback_;
std::function<void(int)> rightClickCallback_;
HMENU rightClickMenu_;
Oops, something went wrong.

0 comments on commit c55db7a

Please sign in to comment.