2013-09-22 17:27:09 +00:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2013-09-23 02:05:33 +00:00
|
|
|
#include <vector>
|
|
|
|
#include <string>
|
|
|
|
#include <set>
|
|
|
|
|
2013-10-12 17:02:21 +00:00
|
|
|
#include "base/functional.h"
|
2013-09-22 18:03:29 +00:00
|
|
|
#include "Windows/GEDebugger/GEDebugger.h"
|
2013-09-23 02:05:33 +00:00
|
|
|
#include "Windows/GEDebugger/SimpleGLWindow.h"
|
2013-09-25 13:24:53 +00:00
|
|
|
#include "Windows/GEDebugger/CtrlDisplayListView.h"
|
2013-09-30 07:57:46 +00:00
|
|
|
#include "Windows/GEDebugger/TabDisplayLists.h"
|
|
|
|
#include "Windows/GEDebugger/TabState.h"
|
2013-10-08 07:28:57 +00:00
|
|
|
#include "Windows/InputBox.h"
|
2013-09-22 17:27:09 +00:00
|
|
|
#include "Windows/WindowsHost.h"
|
2013-09-27 11:11:11 +00:00
|
|
|
#include "Windows/WndMainWindow.h"
|
2013-09-23 02:05:33 +00:00
|
|
|
#include "Windows/main.h"
|
2013-09-22 17:27:09 +00:00
|
|
|
#include "GPU/GPUInterface.h"
|
|
|
|
#include "GPU/Common/GPUDebugInterface.h"
|
|
|
|
#include "GPU/GPUState.h"
|
2013-10-12 11:02:21 +00:00
|
|
|
#include "GPU/Debugger/Breakpoints.h"
|
2013-10-12 17:02:21 +00:00
|
|
|
#include "GPU/Debugger/Stepping.h"
|
2013-09-28 14:04:56 +00:00
|
|
|
#include "Core/Config.h"
|
2013-09-27 11:11:11 +00:00
|
|
|
#include <windowsx.h>
|
|
|
|
#include <commctrl.h>
|
2013-09-22 17:27:09 +00:00
|
|
|
|
2013-10-12 11:02:21 +00:00
|
|
|
using namespace GPUBreakpoints;
|
2013-10-12 17:02:21 +00:00
|
|
|
using namespace GPUStepping;
|
2013-09-23 02:05:33 +00:00
|
|
|
|
2013-09-22 17:27:09 +00:00
|
|
|
static bool attached = false;
|
|
|
|
// TODO
|
|
|
|
static bool textureCaching = true;
|
2013-09-23 02:05:33 +00:00
|
|
|
|
2013-10-08 07:04:11 +00:00
|
|
|
static BreakNextType breakNext = BREAK_NONE;
|
2013-09-23 02:05:33 +00:00
|
|
|
|
2013-10-06 23:48:23 +00:00
|
|
|
enum PrimaryDisplayType {
|
|
|
|
PRIMARY_FRAMEBUF,
|
|
|
|
PRIMARY_DEPTHBUF,
|
|
|
|
PRIMARY_STENCILBUF,
|
|
|
|
};
|
|
|
|
|
2013-09-28 05:41:44 +00:00
|
|
|
void CGEDebugger::Init() {
|
|
|
|
SimpleGLWindow::RegisterClass();
|
2013-09-25 13:24:53 +00:00
|
|
|
CtrlDisplayListView::registerClass();
|
2013-09-24 18:06:25 +00:00
|
|
|
}
|
|
|
|
|
2013-09-22 17:27:09 +00:00
|
|
|
CGEDebugger::CGEDebugger(HINSTANCE _hInstance, HWND _hParent)
|
2013-10-06 23:48:23 +00:00
|
|
|
: Dialog((LPCSTR)IDD_GEDEBUGGER, _hInstance, _hParent), frameWindow(NULL), texWindow(NULL) {
|
2013-10-12 11:02:21 +00:00
|
|
|
GPUBreakpoints::Init();
|
2013-09-28 07:32:45 +00:00
|
|
|
Core_ListenShutdown(ForceUnpause);
|
2013-09-24 18:06:25 +00:00
|
|
|
|
2013-09-28 14:04:56 +00:00
|
|
|
// minimum size = a little more than the default
|
|
|
|
RECT windowRect;
|
|
|
|
GetWindowRect(m_hDlg,&windowRect);
|
|
|
|
minWidth = windowRect.right-windowRect.left+10;
|
|
|
|
minHeight = windowRect.bottom-windowRect.top+10;
|
|
|
|
|
2013-09-24 18:06:25 +00:00
|
|
|
// it's ugly, but .rc coordinates don't match actual pixels and it screws
|
|
|
|
// up both the size and the aspect ratio
|
|
|
|
RECT frameRect;
|
|
|
|
HWND frameWnd = GetDlgItem(m_hDlg,IDC_GEDBG_FRAME);
|
|
|
|
|
|
|
|
GetWindowRect(frameWnd,&frameRect);
|
|
|
|
MapWindowPoints(HWND_DESKTOP,m_hDlg,(LPPOINT)&frameRect,2);
|
|
|
|
MoveWindow(frameWnd,frameRect.left,frameRect.top,512,272,TRUE);
|
2013-09-27 11:11:11 +00:00
|
|
|
|
2013-09-28 18:57:02 +00:00
|
|
|
tabs = new TabControl(GetDlgItem(m_hDlg,IDC_GEDBG_MAINTAB));
|
|
|
|
HWND wnd = tabs->AddTabWindow(L"CtrlDisplayListView",L"Display List");
|
2013-09-27 16:03:08 +00:00
|
|
|
displayList = CtrlDisplayListView::getFrom(wnd);
|
2013-09-28 14:04:56 +00:00
|
|
|
|
2013-10-06 23:48:23 +00:00
|
|
|
fbTabs = new TabControl(GetDlgItem(m_hDlg, IDC_GEDBG_FBTABS));
|
|
|
|
fbTabs->SetMinTabWidth(50);
|
|
|
|
// Must be in the same order as PrimaryDisplayType.
|
|
|
|
fbTabs->AddTab(NULL, L"Color");
|
|
|
|
fbTabs->AddTab(NULL, L"Depth");
|
|
|
|
fbTabs->AddTab(NULL, L"Stencil");
|
|
|
|
fbTabs->ShowTab(0, true);
|
|
|
|
|
2013-09-30 07:57:46 +00:00
|
|
|
flags = new TabStateFlags(_hInstance, m_hDlg);
|
|
|
|
tabs->AddTabDialog(flags, L"Flags");
|
|
|
|
|
2013-09-30 08:13:06 +00:00
|
|
|
lighting = new TabStateLighting(_hInstance, m_hDlg);
|
|
|
|
tabs->AddTabDialog(lighting, L"Lighting");
|
|
|
|
|
2013-09-30 15:18:28 +00:00
|
|
|
textureState = new TabStateTexture(_hInstance, m_hDlg);
|
|
|
|
tabs->AddTabDialog(textureState, L"Texture");
|
|
|
|
|
2013-09-30 08:13:06 +00:00
|
|
|
settings = new TabStateSettings(_hInstance, m_hDlg);
|
|
|
|
tabs->AddTabDialog(settings, L"Settings");
|
|
|
|
|
|
|
|
lists = new TabDisplayLists(_hInstance, m_hDlg);
|
|
|
|
tabs->AddTabDialog(lists, L"Lists");
|
|
|
|
|
|
|
|
tabs->ShowTab(0, true);
|
2013-09-28 23:02:05 +00:00
|
|
|
|
2013-09-28 14:04:56 +00:00
|
|
|
// set window position
|
|
|
|
int x = g_Config.iGEWindowX == -1 ? windowRect.left : g_Config.iGEWindowX;
|
|
|
|
int y = g_Config.iGEWindowY == -1 ? windowRect.top : g_Config.iGEWindowY;
|
|
|
|
int w = g_Config.iGEWindowW == -1 ? minWidth : g_Config.iGEWindowW;
|
|
|
|
int h = g_Config.iGEWindowH == -1 ? minHeight : g_Config.iGEWindowH;
|
|
|
|
MoveWindow(m_hDlg,x,y,w,h,FALSE);
|
2013-09-23 02:05:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CGEDebugger::~CGEDebugger() {
|
2013-10-14 03:47:52 +00:00
|
|
|
CleanupPrimPreview();
|
2013-09-30 07:57:46 +00:00
|
|
|
delete flags;
|
2013-09-30 08:13:06 +00:00
|
|
|
delete lighting;
|
2013-09-30 15:18:28 +00:00
|
|
|
delete textureState;
|
2013-09-30 08:13:06 +00:00
|
|
|
delete settings;
|
2013-09-30 07:57:46 +00:00
|
|
|
delete lists;
|
|
|
|
delete tabs;
|
2013-10-06 23:48:23 +00:00
|
|
|
delete fbTabs;
|
2013-09-22 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
2013-09-28 05:41:44 +00:00
|
|
|
void CGEDebugger::SetupPreviews() {
|
2013-09-24 06:45:17 +00:00
|
|
|
if (frameWindow == NULL) {
|
2013-09-28 05:41:44 +00:00
|
|
|
frameWindow = SimpleGLWindow::GetFrom(GetDlgItem(m_hDlg, IDC_GEDBG_FRAME));
|
2013-09-28 06:52:06 +00:00
|
|
|
frameWindow->Initialize(SimpleGLWindow::ALPHA_IGNORE | SimpleGLWindow::RESIZE_SHRINK_CENTER);
|
2013-09-24 06:45:17 +00:00
|
|
|
frameWindow->Clear();
|
|
|
|
}
|
2013-09-28 05:41:44 +00:00
|
|
|
if (texWindow == NULL) {
|
|
|
|
texWindow = SimpleGLWindow::GetFrom(GetDlgItem(m_hDlg, IDC_GEDBG_TEX));
|
2013-09-28 06:52:06 +00:00
|
|
|
texWindow->Initialize(SimpleGLWindow::ALPHA_BLEND | SimpleGLWindow::RESIZE_SHRINK_CENTER);
|
2013-09-28 05:41:44 +00:00
|
|
|
texWindow->Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGEDebugger::UpdatePreviews() {
|
2013-10-06 22:51:58 +00:00
|
|
|
wchar_t desc[256];
|
2013-10-12 17:02:21 +00:00
|
|
|
const GPUDebugBuffer *primaryBuffer = NULL;
|
|
|
|
bool bufferResult = false;
|
2013-10-06 22:51:58 +00:00
|
|
|
GPUgstate state;
|
|
|
|
|
|
|
|
if (gpuDebug != NULL) {
|
|
|
|
state = gpuDebug->GetGState();
|
|
|
|
}
|
|
|
|
|
2013-10-06 23:48:23 +00:00
|
|
|
switch (PrimaryDisplayType(fbTabs->CurrentTabIndex())) {
|
2013-10-06 00:27:28 +00:00
|
|
|
case PRIMARY_FRAMEBUF:
|
2013-10-12 17:02:21 +00:00
|
|
|
bufferResult = GPU_GetCurrentFramebuffer(primaryBuffer);
|
|
|
|
if (bufferResult) {
|
2013-12-10 14:33:13 +00:00
|
|
|
_snwprintf(desc, ARRAY_SIZE(desc), L"Color: 0x%08x (%dx%d) fmt %i", state.getFrameBufRawAddress(), primaryBuffer->GetStride(), primaryBuffer->GetHeight(), state.FrameBufFormat());
|
2013-10-12 17:02:21 +00:00
|
|
|
}
|
2013-10-06 00:27:28 +00:00
|
|
|
break;
|
2013-09-28 05:41:44 +00:00
|
|
|
|
2013-10-06 00:27:28 +00:00
|
|
|
case PRIMARY_DEPTHBUF:
|
2013-10-12 17:02:21 +00:00
|
|
|
bufferResult = GPU_GetCurrentDepthbuffer(primaryBuffer);
|
|
|
|
if (bufferResult) {
|
|
|
|
_snwprintf(desc, ARRAY_SIZE(desc), L"Depth: 0x%08x (%dx%d)", state.getDepthBufRawAddress(), primaryBuffer->GetStride(), primaryBuffer->GetHeight());
|
|
|
|
}
|
2013-10-06 00:27:28 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case PRIMARY_STENCILBUF:
|
2013-10-12 17:02:21 +00:00
|
|
|
bufferResult = GPU_GetCurrentStencilbuffer(primaryBuffer);
|
|
|
|
if (bufferResult) {
|
|
|
|
_snwprintf(desc, ARRAY_SIZE(desc), L"Stencil: 0x%08x (%dx%d)", state.getFrameBufRawAddress(), primaryBuffer->GetStride(), primaryBuffer->GetHeight());
|
|
|
|
}
|
2013-10-06 00:27:28 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bufferResult && primaryBuffer != NULL) {
|
|
|
|
auto fmt = SimpleGLWindow::Format(primaryBuffer->GetFormat());
|
|
|
|
frameWindow->Draw(primaryBuffer->GetData(), primaryBuffer->GetStride(), primaryBuffer->GetHeight(), primaryBuffer->GetFlipped(), fmt);
|
2013-10-06 22:51:58 +00:00
|
|
|
SetDlgItemText(m_hDlg, IDC_GEDBG_FRAMEBUFADDR, desc);
|
2013-09-28 05:41:44 +00:00
|
|
|
} else {
|
|
|
|
frameWindow->Clear();
|
2013-10-06 22:51:58 +00:00
|
|
|
SetDlgItemText(m_hDlg, IDC_GEDBG_FRAMEBUFADDR, L"Failed");
|
2013-09-28 05:41:44 +00:00
|
|
|
}
|
|
|
|
|
2013-10-12 17:02:21 +00:00
|
|
|
const GPUDebugBuffer *bufferTex = NULL;
|
|
|
|
bufferResult = GPU_GetCurrentTexture(bufferTex);
|
2013-09-28 05:41:44 +00:00
|
|
|
|
|
|
|
if (bufferResult) {
|
2013-10-12 17:02:21 +00:00
|
|
|
auto fmt = SimpleGLWindow::Format(bufferTex->GetFormat());
|
|
|
|
texWindow->Draw(bufferTex->GetData(), bufferTex->GetStride(), bufferTex->GetHeight(), bufferTex->GetFlipped(), fmt);
|
2013-10-06 00:30:42 +00:00
|
|
|
|
|
|
|
if (gpuDebug != NULL) {
|
|
|
|
if (state.isTextureAlphaUsed()) {
|
|
|
|
texWindow->SetFlags(SimpleGLWindow::ALPHA_BLEND | SimpleGLWindow::RESIZE_SHRINK_CENTER);
|
|
|
|
} else {
|
|
|
|
texWindow->SetFlags(SimpleGLWindow::RESIZE_SHRINK_CENTER);
|
|
|
|
}
|
2013-10-06 22:51:58 +00:00
|
|
|
_snwprintf(desc, ARRAY_SIZE(desc), L"Texture: 0x%08x (%dx%d)", state.getTextureAddress(0), state.getTextureWidth(0), state.getTextureHeight(0));
|
|
|
|
SetDlgItemText(m_hDlg, IDC_GEDBG_TEXADDR, desc);
|
2013-10-08 07:04:11 +00:00
|
|
|
|
2013-10-12 16:06:48 +00:00
|
|
|
UpdateLastTexture(state.getTextureAddress(0));
|
2013-10-08 07:04:11 +00:00
|
|
|
} else {
|
2013-10-12 16:06:48 +00:00
|
|
|
UpdateLastTexture((u32)-1);
|
2013-10-06 00:30:42 +00:00
|
|
|
}
|
2013-09-28 05:41:44 +00:00
|
|
|
} else {
|
|
|
|
texWindow->Clear();
|
2013-10-06 22:51:58 +00:00
|
|
|
if (gpuDebug == NULL || state.isTextureMapEnabled()) {
|
|
|
|
SetDlgItemText(m_hDlg, IDC_GEDBG_TEXADDR, L"Texture: failed");
|
|
|
|
} else {
|
|
|
|
SetDlgItemText(m_hDlg, IDC_GEDBG_TEXADDR, L"Texture: disabled");
|
|
|
|
}
|
2013-10-12 16:06:48 +00:00
|
|
|
UpdateLastTexture((u32)-1);
|
2013-09-28 05:41:44 +00:00
|
|
|
}
|
2013-09-28 06:45:15 +00:00
|
|
|
|
|
|
|
DisplayList list;
|
2013-10-06 22:51:58 +00:00
|
|
|
if (gpuDebug != NULL && gpuDebug->GetCurrentDisplayList(list)) {
|
2013-10-13 05:17:24 +00:00
|
|
|
const u32 op = Memory::Read_U32(list.pc);
|
|
|
|
const u32 cmd = op >> 24;
|
|
|
|
// TODO: Bezier/spline?
|
|
|
|
if (cmd == GE_CMD_PRIM) {
|
|
|
|
UpdatePrimPreview(op);
|
|
|
|
}
|
|
|
|
|
2013-09-28 06:45:15 +00:00
|
|
|
displayList->setDisplayList(list);
|
|
|
|
}
|
2013-09-28 23:02:05 +00:00
|
|
|
|
2013-09-30 07:57:46 +00:00
|
|
|
flags->Update();
|
2013-09-30 08:13:06 +00:00
|
|
|
lighting->Update();
|
2013-09-30 15:18:28 +00:00
|
|
|
textureState->Update();
|
2013-09-30 08:13:06 +00:00
|
|
|
settings->Update();
|
2013-09-28 23:02:05 +00:00
|
|
|
lists->Update();
|
2013-09-24 06:45:17 +00:00
|
|
|
}
|
|
|
|
|
2013-10-13 05:17:24 +00:00
|
|
|
void CGEDebugger::UpdateSize(WORD width, WORD height) {
|
2013-09-28 14:04:56 +00:00
|
|
|
// only resize the tab for now
|
|
|
|
HWND tabControl = GetDlgItem(m_hDlg, IDC_GEDBG_MAINTAB);
|
|
|
|
|
|
|
|
RECT tabRect;
|
|
|
|
GetWindowRect(tabControl,&tabRect);
|
|
|
|
MapWindowPoints(HWND_DESKTOP,m_hDlg,(LPPOINT)&tabRect,2);
|
|
|
|
|
|
|
|
tabRect.right = tabRect.left + (width-tabRect.left*2); // assume same gap on both sides
|
|
|
|
tabRect.bottom = tabRect.top + (height-tabRect.top-tabRect.left); // assume same gap on bottom too
|
|
|
|
MoveWindow(tabControl,tabRect.left,tabRect.top,tabRect.right-tabRect.left,tabRect.bottom-tabRect.top,TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void CGEDebugger::SavePosition()
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
if (GetWindowRect(m_hDlg, &rc))
|
|
|
|
{
|
|
|
|
g_Config.iGEWindowX = rc.left;
|
|
|
|
g_Config.iGEWindowY = rc.top;
|
|
|
|
g_Config.iGEWindowW = rc.right - rc.left;
|
|
|
|
g_Config.iGEWindowH = rc.bottom - rc.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-10-08 07:04:11 +00:00
|
|
|
void CGEDebugger::SetBreakNext(BreakNextType type) {
|
|
|
|
attached = true;
|
|
|
|
SetupPreviews();
|
|
|
|
|
2013-10-12 17:02:21 +00:00
|
|
|
ResumeFromStepping();
|
2013-10-08 07:04:11 +00:00
|
|
|
breakNext = type;
|
|
|
|
}
|
|
|
|
|
2013-09-27 16:03:08 +00:00
|
|
|
BOOL CGEDebugger::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
|
2013-09-22 17:27:09 +00:00
|
|
|
switch (message) {
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
return TRUE;
|
|
|
|
|
2013-09-28 14:04:56 +00:00
|
|
|
case WM_GETMINMAXINFO:
|
|
|
|
{
|
|
|
|
MINMAXINFO* minmax = (MINMAXINFO*) lParam;
|
|
|
|
minmax->ptMinTrackSize.x = minWidth;
|
|
|
|
minmax->ptMinTrackSize.y = minHeight;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
|
2013-09-22 17:27:09 +00:00
|
|
|
case WM_SIZE:
|
2013-09-28 14:04:56 +00:00
|
|
|
UpdateSize(LOWORD(lParam), HIWORD(lParam));
|
|
|
|
SavePosition();
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_MOVE:
|
|
|
|
SavePosition();
|
2013-09-22 17:27:09 +00:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
case WM_CLOSE:
|
2013-11-16 09:42:24 +00:00
|
|
|
attached = false;
|
|
|
|
ResumeFromStepping();
|
|
|
|
breakNext = BREAK_NONE;
|
|
|
|
|
2013-09-22 17:27:09 +00:00
|
|
|
Show(false);
|
|
|
|
return TRUE;
|
|
|
|
|
2013-09-24 06:45:17 +00:00
|
|
|
case WM_SHOWWINDOW:
|
2013-09-28 05:41:44 +00:00
|
|
|
SetupPreviews();
|
2013-09-24 06:45:17 +00:00
|
|
|
break;
|
|
|
|
|
2013-09-28 12:34:08 +00:00
|
|
|
case WM_ACTIVATE:
|
|
|
|
if (wParam == WA_ACTIVE || wParam == WA_CLICKACTIVE) {
|
|
|
|
g_activeWindow = WINDOW_GEDEBUGGER;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-09-27 11:11:11 +00:00
|
|
|
case WM_NOTIFY:
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case IDC_GEDBG_MAINTAB:
|
2013-09-28 18:57:02 +00:00
|
|
|
tabs->HandleNotify(lParam);
|
2013-09-27 11:11:11 +00:00
|
|
|
break;
|
2013-10-06 23:48:23 +00:00
|
|
|
case IDC_GEDBG_FBTABS:
|
|
|
|
fbTabs->HandleNotify(lParam);
|
|
|
|
if (attached && gpuDebug != NULL) {
|
|
|
|
UpdatePreviews();
|
|
|
|
}
|
|
|
|
break;
|
2013-09-27 11:11:11 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-09-22 17:27:09 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
switch (LOWORD(wParam)) {
|
2013-09-28 06:45:15 +00:00
|
|
|
case IDC_GEDBG_STEPDRAW:
|
2013-10-08 07:04:11 +00:00
|
|
|
SetBreakNext(BREAK_NEXT_DRAW);
|
2013-09-28 06:45:15 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_GEDBG_STEP:
|
2013-10-08 07:04:11 +00:00
|
|
|
SetBreakNext(BREAK_NEXT_OP);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_GEDBG_STEPTEX:
|
2013-10-12 16:06:48 +00:00
|
|
|
AddTextureChangeTempBreakpoint();
|
2013-10-08 07:04:11 +00:00
|
|
|
SetBreakNext(BREAK_NEXT_TEX);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case IDC_GEDBG_STEPFRAME:
|
|
|
|
SetBreakNext(BREAK_NEXT_FRAME);
|
2013-09-22 17:27:09 +00:00
|
|
|
break;
|
|
|
|
|
2013-10-13 01:31:13 +00:00
|
|
|
case IDC_GEDBG_STEPPRIM:
|
|
|
|
AddCmdBreakpoint(GE_CMD_PRIM, true);
|
|
|
|
AddCmdBreakpoint(GE_CMD_BEZIER, true);
|
|
|
|
AddCmdBreakpoint(GE_CMD_SPLINE, true);
|
|
|
|
SetBreakNext(BREAK_NEXT_PRIM);
|
|
|
|
break;
|
|
|
|
|
2013-10-08 07:28:57 +00:00
|
|
|
case IDC_GEDBG_BREAKTEX:
|
|
|
|
{
|
2013-11-16 09:42:24 +00:00
|
|
|
attached = true;
|
2013-10-12 16:06:48 +00:00
|
|
|
if (!gpuDebug) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
const auto state = gpuDebug->GetGState();
|
|
|
|
u32 texAddr = state.getTextureAddress(0);
|
2013-10-08 07:28:57 +00:00
|
|
|
// TODO: Better interface that allows add/remove or something.
|
2013-10-12 16:06:48 +00:00
|
|
|
if (InputBox_GetHex(GetModuleHandle(NULL), m_hDlg, L"Texture Address", texAddr, texAddr)) {
|
2013-10-12 11:16:35 +00:00
|
|
|
if (IsTextureBreakpoint(texAddr)) {
|
|
|
|
RemoveTextureBreakpoint(texAddr);
|
2013-10-08 07:28:57 +00:00
|
|
|
} else {
|
2013-10-12 11:16:35 +00:00
|
|
|
AddTextureBreakpoint(texAddr);
|
2013-10-08 07:28:57 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-09-22 17:27:09 +00:00
|
|
|
case IDC_GEDBG_RESUME:
|
2013-09-23 02:05:33 +00:00
|
|
|
frameWindow->Clear();
|
2013-09-28 05:41:44 +00:00
|
|
|
texWindow->Clear();
|
2013-10-06 22:51:58 +00:00
|
|
|
SetDlgItemText(m_hDlg, IDC_GEDBG_FRAMEBUFADDR, L"");
|
|
|
|
SetDlgItemText(m_hDlg, IDC_GEDBG_TEXADDR, L"");
|
|
|
|
|
2013-10-12 17:02:21 +00:00
|
|
|
ResumeFromStepping();
|
2013-10-08 07:04:11 +00:00
|
|
|
breakNext = BREAK_NONE;
|
2013-09-22 17:27:09 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-09-23 02:05:33 +00:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_GEDBG_BREAK_CMD:
|
|
|
|
{
|
|
|
|
u32 pc = (u32)wParam;
|
2013-10-12 11:02:21 +00:00
|
|
|
ClearTempBreakpoints();
|
2013-09-23 02:05:33 +00:00
|
|
|
auto info = gpuDebug->DissassembleOp(pc);
|
|
|
|
NOTICE_LOG(COMMON, "Waiting at %08x, %s", pc, info.desc.c_str());
|
2013-09-28 05:41:44 +00:00
|
|
|
UpdatePreviews();
|
2013-09-23 02:05:33 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WM_GEDBG_BREAK_DRAW:
|
|
|
|
{
|
|
|
|
NOTICE_LOG(COMMON, "Waiting at a draw");
|
2013-09-28 05:41:44 +00:00
|
|
|
UpdatePreviews();
|
2013-09-23 02:05:33 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-28 12:34:08 +00:00
|
|
|
|
|
|
|
case WM_GEDBG_STEPDISPLAYLIST:
|
2013-10-08 07:04:11 +00:00
|
|
|
SetBreakNext(BREAK_NEXT_OP);
|
2013-09-28 12:34:08 +00:00
|
|
|
break;
|
2013-10-01 10:05:19 +00:00
|
|
|
|
|
|
|
case WM_GEDBG_TOGGLEPCBREAKPOINT:
|
|
|
|
{
|
2013-11-16 09:42:24 +00:00
|
|
|
attached = true;
|
2013-10-01 14:53:00 +00:00
|
|
|
u32 pc = (u32)wParam;
|
2013-10-12 11:02:21 +00:00
|
|
|
bool temp;
|
|
|
|
bool isBreak = IsAddressBreakpoint(pc, temp);
|
|
|
|
if (isBreak && !temp) {
|
|
|
|
RemoveAddressBreakpoint(pc);
|
|
|
|
} else {
|
|
|
|
AddAddressBreakpoint(pc);
|
|
|
|
}
|
2013-10-01 10:05:19 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2013-10-01 22:41:37 +00:00
|
|
|
case WM_GEDBG_RUNTOWPARAM:
|
|
|
|
{
|
2013-11-16 09:42:24 +00:00
|
|
|
attached = true;
|
2013-10-01 22:41:37 +00:00
|
|
|
u32 pc = (u32)wParam;
|
2013-10-12 11:02:21 +00:00
|
|
|
AddAddressBreakpoint(pc, true);
|
2013-10-01 22:41:37 +00:00
|
|
|
SendMessage(m_hDlg,WM_COMMAND,IDC_GEDBG_RESUME,0);
|
|
|
|
}
|
|
|
|
break;
|
2013-10-07 02:17:06 +00:00
|
|
|
|
|
|
|
case WM_GEDBG_SETCMDWPARAM:
|
|
|
|
{
|
2013-10-12 17:02:21 +00:00
|
|
|
GPU_SetCmdValue((u32)wParam);
|
2013-10-07 02:17:06 +00:00
|
|
|
}
|
|
|
|
break;
|
2013-09-22 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
// The below WindowsHost methods are called on the GPU thread.
|
|
|
|
|
|
|
|
bool WindowsHost::GPUDebuggingActive() {
|
|
|
|
return attached;
|
|
|
|
}
|
|
|
|
|
2013-10-12 17:02:21 +00:00
|
|
|
static void DeliverMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
|
2013-09-23 02:05:33 +00:00
|
|
|
PostMessage(geDebuggerWindow->GetDlgHandle(), msg, wParam, lParam);
|
2013-10-12 17:02:21 +00:00
|
|
|
}
|
2013-09-23 02:05:33 +00:00
|
|
|
|
2013-10-12 17:02:21 +00:00
|
|
|
static void PauseWithMessage(UINT msg, WPARAM wParam = NULL, LPARAM lParam = NULL) {
|
|
|
|
EnterStepping(std::bind(&DeliverMessage, msg, wParam, lParam));
|
2013-09-23 02:05:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowsHost::GPUNotifyCommand(u32 pc) {
|
|
|
|
u32 op = Memory::ReadUnchecked_U32(pc);
|
|
|
|
u8 cmd = op >> 24;
|
|
|
|
|
2013-10-12 16:06:48 +00:00
|
|
|
if (breakNext == BREAK_NEXT_OP || IsBreakpoint(pc, op)) {
|
2013-09-23 02:05:33 +00:00
|
|
|
PauseWithMessage(WM_GEDBG_BREAK_CMD, (WPARAM) pc);
|
2013-09-22 17:27:09 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowsHost::GPUNotifyDisplay(u32 framebuf, u32 stride, int format) {
|
2013-10-08 07:04:11 +00:00
|
|
|
if (breakNext == BREAK_NEXT_FRAME) {
|
|
|
|
// This should work fine, start stepping at the first op of the new frame.
|
|
|
|
breakNext = BREAK_NEXT_OP;
|
|
|
|
}
|
2013-09-22 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowsHost::GPUNotifyDraw() {
|
2013-10-08 07:04:11 +00:00
|
|
|
if (breakNext == BREAK_NEXT_DRAW) {
|
2013-09-23 02:05:33 +00:00
|
|
|
PauseWithMessage(WM_GEDBG_BREAK_DRAW);
|
|
|
|
}
|
2013-09-22 17:27:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void WindowsHost::GPUNotifyTextureAttachment(u32 addr) {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool WindowsHost::GPUAllowTextureCache(u32 addr) {
|
|
|
|
return textureCaching;
|
|
|
|
}
|