Add a tab to show vertex values to the GE debugger.

Should be pretty useful, especially for depth issues.
This commit is contained in:
Unknown W. Brackets committed 2014-02-08 22:03:29 -08:00
1 parent 9798af3b17
commit e7eca477b0
11 files changed
+422 -11

No files matched your search

+1
View File
@@ -183,6 +183,7 @@ struct GPUDebugVertex {
float x;
float y;
float z;
u8 c[4];
};
class GPUDebugInterface {
+24 -4
View File
@@ -909,22 +909,42 @@ bool TransformDrawEngine::GetCurrentSimpleVertices(int count, std::vector<GPUDeb
const SimpleVertex &vert = simpleVertices[i];
if (gstate.isModeThrough()) {
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
if (gstate.vertType & GE_VTYPE_TC_MASK) {
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
} else {
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}
vertices[i].x = vert.pos.x;
vertices[i].y = vert.pos.y;
vertices[i].z = vert.pos.z;
if (gstate.vertType & GE_VTYPE_COL_MASK) {
memcpy(vertices[i].c, vert.color, sizeof(vertices[i].c));
} else {
memset(vertices[i].c, 0, sizeof(vertices[i].c));
}
} else {
float clipPos[4];
Vec3ByMatrix44(clipPos, vert.pos.AsArray(), worldviewproj);
Vec3f screenPos = ClipToScreen(clipPos);
Vec3f drawPos = ScreenToDrawing(screenPos);
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
if (gstate.vertType & GE_VTYPE_TC_MASK) {
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
} else {
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}
vertices[i].x = drawPos.x;
vertices[i].y = drawPos.y;
vertices[i].z = 1.0;
if (gstate.vertType & GE_VTYPE_COL_MASK) {
memcpy(vertices[i].c, vert.color, sizeof(vertices[i].c));
} else {
memset(vertices[i].c, 0, sizeof(vertices[i].c));
}
}
}
+24 -4
View File
@@ -534,22 +534,42 @@ bool TransformUnit::GetCurrentSimpleVertices(int count, std::vector<GPUDebugVert
const SimpleVertex &vert = simpleVertices[i];
if (gstate.isModeThrough()) {
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
if (gstate.vertType & GE_VTYPE_TC_MASK) {
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
} else {
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}
vertices[i].x = vert.pos.x;
vertices[i].y = vert.pos.y;
vertices[i].z = vert.pos.z;
if (gstate.vertType & GE_VTYPE_COL_MASK) {
memcpy(vertices[i].c, vert.color, sizeof(vertices[i].c));
} else {
memset(vertices[i].c, 0, sizeof(vertices[i].c));
}
} else {
float clipPos[4];
Vec3ByMatrix44(clipPos, vert.pos.AsArray(), worldviewproj);
ScreenCoords screenPos = ClipToScreen(clipPos);
DrawingCoords drawPos = ScreenToDrawing(screenPos);
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
if (gstate.vertType & GE_VTYPE_TC_MASK) {
vertices[i].u = vert.uv[0];
vertices[i].v = vert.uv[1];
} else {
vertices[i].u = 0.0f;
vertices[i].v = 0.0f;
}
vertices[i].x = drawPos.x;
vertices[i].y = drawPos.y;
vertices[i].z = 1.0;
if (gstate.vertType & GE_VTYPE_COL_MASK) {
memcpy(vertices[i].c, vert.color, sizeof(vertices[i].c));
} else {
memset(vertices[i].c, 0, sizeof(vertices[i].c));
}
}
}
+6
View File
@@ -25,6 +25,7 @@
#include "Windows/GEDebugger/CtrlDisplayListView.h"
#include "Windows/GEDebugger/TabDisplayLists.h"
#include "Windows/GEDebugger/TabState.h"
#include "Windows/GEDebugger/TabVertices.h"
#include "Windows/InputBox.h"
#include "Windows/WindowsHost.h"
#include "Windows/WndMainWindow.h"
@@ -102,6 +103,9 @@ CGEDebugger::CGEDebugger(HINSTANCE _hInstance, HWND _hParent)
settings = new TabStateSettings(_hInstance, m_hDlg);
tabs->AddTabDialog(settings, L"Settings");
vertices = new TabVertices(_hInstance, m_hDlg);
tabs->AddTabDialog(vertices, L"Vertices");
lists = new TabDisplayLists(_hInstance, m_hDlg);
tabs->AddTabDialog(lists, L"Lists");
@@ -121,6 +125,7 @@ CGEDebugger::~CGEDebugger() {
delete lighting;
delete textureState;
delete settings;
delete vertices;
delete lists;
delete tabs;
delete fbTabs;
@@ -227,6 +232,7 @@ void CGEDebugger::UpdatePreviews() {
lighting->Update();
textureState->Update();
settings->Update();
vertices->Update();
lists->Update();
}
+2
View File
@@ -49,6 +49,7 @@ class TabStateFlags;
class TabStateLighting;
class TabStateTexture;
class TabStateSettings;
class TabVertices;
class CGEDebugger : public Dialog {
public:
@@ -75,6 +76,7 @@ private:
TabStateLighting *lighting;
TabStateTexture *textureState;
TabStateSettings *settings;
TabVertices *vertices;
SimpleGLWindow *frameWindow;
SimpleGLWindow *texWindow;
TabControl *tabs;
+270
View File
@@ -0,0 +1,270 @@
// 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/.
#include "base/basictypes.h"
#include "Windows/resource.h"
#include "Windows/GEDebugger/GEDebugger.h"
#include "Windows/GEDebugger/TabVertices.h"
#include "GPU/GLES/VertexDecoder.h"
#include "GPU/GPUState.h"
#include "GPU/GeDisasm.h"
#include "GPU/Common/GPUDebugInterface.h"
static const GenericListViewColumn vertexListCols[] = {
{ L"X", 0.17f },
{ L"Y", 0.17f },
{ L"Z", 0.17f },
{ L"U", 0.16f },
{ L"V", 0.16f },
{ L"Color", 0.17f },
// TODO: Normal, weight, morph?
};
enum VertexListCols {
VERTEXLIST_COL_X,
VERTEXLIST_COL_Y,
VERTEXLIST_COL_Z,
VERTEXLIST_COL_U,
VERTEXLIST_COL_V,
VERTEXLIST_COL_COLOR,
};
CtrlVertexList::CtrlVertexList(HWND hwnd)
: GenericListControl(hwnd, vertexListCols, ARRAY_SIZE(vertexListCols)), raw_(false) {
decoder = new VertexDecoder();
Update();
}
CtrlVertexList::~CtrlVertexList() {
delete decoder;
}
void CtrlVertexList::GetColumnText(wchar_t *dest, int row, int col) {
if (row < 0 || row >= rowCount_ ) {
wcscpy(dest, L"Invalid");
return;
}
if (!indices.empty()) {
if (row >= indices.size()) {
swprintf(dest, L"Invalid indice %d", row);
return;
}
row = indices[row];
}
if (raw_) {
FormatVertColRaw(dest, row, col);
} else {
if (row >= vertices.size()) {
swprintf(dest, L"Invalid vertex %d", row);
return;
}
FormatVertCol(dest, vertices[row], col);
}
}
void CtrlVertexList::FormatVertCol(wchar_t *dest, const GPUDebugVertex &vert, int col) {
switch (col) {
case VERTEXLIST_COL_X:
swprintf(dest, L"%f", vert.x);
break;
case VERTEXLIST_COL_Y:
swprintf(dest, L"%f", vert.y);
break;
case VERTEXLIST_COL_Z:
swprintf(dest, L"%f", vert.z);
break;
case VERTEXLIST_COL_U:
swprintf(dest, L"%f", vert.u);
break;
case VERTEXLIST_COL_V:
swprintf(dest, L"%f", vert.v);
break;
case VERTEXLIST_COL_COLOR:
swprintf(dest, L"%02x%02x%02x%02x", vert.c[0], vert.c[1], vert.c[2], vert.c[3]);
break;
default:
wcscpy(dest, L"Invalid");
break;
}
}
void CtrlVertexList::FormatVertColRaw(wchar_t *dest, int row, int col) {
// We could use the vertex decoder and reader, but those already do some minor adjustments.
// There's only a few values - let's just go after them directly.
const u8 *vert = Memory::GetPointer(gpuDebug->GetVertexAddress()) + row * decoder->size;
const u8 *pos = vert + decoder->posoff;
const u8 *tc = vert + decoder->tcoff;
const u8 *color = vert + decoder->coloff;
switch (col) {
case VERTEXLIST_COL_X:
FormatVertColRawType(dest, pos, decoder->pos, 0);
break;
case VERTEXLIST_COL_Y:
FormatVertColRawType(dest, pos, decoder->pos, 1);
break;
case VERTEXLIST_COL_Z:
FormatVertColRawType(dest, pos, decoder->pos, 2);
break;
case VERTEXLIST_COL_U:
FormatVertColRawType(dest, tc, decoder->tc, 0);
break;
case VERTEXLIST_COL_V:
FormatVertColRawType(dest, tc, decoder->tc, 1);
break;
case VERTEXLIST_COL_COLOR:
FormatVertColRawColor(dest, color, decoder->col);
break;
default:
wcscpy(dest, L"Invalid");
break;
}
}
void CtrlVertexList::FormatVertColRawType(wchar_t *dest, const void *data, int type, int offset) {
switch (type) {
case 0:
wcscpy(dest, L"-");
break;
case 1: // 8-bit
swprintf(dest, L"%02x", ((const u8 *)data)[offset]);
break;
case 2: // 16-bit
swprintf(dest, L"%04x", ((const u16_le *)data)[offset]);
break;
case 3: // float
swprintf(dest, L"%f", ((const float *)data)[offset]);
break;
default:
wcscpy(dest, L"Invalid");
break;
}
}
void CtrlVertexList::FormatVertColRawColor(wchar_t *dest, const void *data, int type) {
switch (type) {
case GE_VTYPE_COL_NONE >> GE_VTYPE_COL_SHIFT:
wcscpy(dest, L"-");
break;
case GE_VTYPE_COL_565 >> GE_VTYPE_COL_SHIFT:
case GE_VTYPE_COL_5551 >> GE_VTYPE_COL_SHIFT:
case GE_VTYPE_COL_4444 >> GE_VTYPE_COL_SHIFT:
swprintf(dest, L"%04x", *(const u16_le *)data);
break;
case GE_VTYPE_COL_8888 >> GE_VTYPE_COL_SHIFT:
swprintf(dest, L"%08x", *(const u32_le *)data);
break;
default:
wcscpy(dest, L"Invalid");
break;
}
}
int CtrlVertexList::GetRowCount() {
if (!gpuDebug || !Memory::IsValidAddress(gpuDebug->GetVertexAddress())) {
rowCount_ = 0;
return rowCount_;
}
// TODO: Maybe there are smarter ways? Also, is this the best place to recalc?
auto state = gpuDebug->GetGState();
rowCount_ = state.prim & 0xFFFF;
// Override if we're on a prim command.
DisplayList list;
if (gpuDebug->GetCurrentDisplayList(list)) {
u32 cmd = Memory::Read_U32(list.pc);
if ((cmd >> 24) == GE_CMD_PRIM) {
rowCount_ = cmd & 0xFFFF;
}
}
if (!gpuDebug->GetCurrentSimpleVertices(rowCount_, vertices, indices)) {
rowCount_ = 0;
}
decoder->SetVertexType(state.vertType);
return rowCount_;
}
TabVertices::TabVertices(HINSTANCE _hInstance, HWND _hParent)
: Dialog((LPCSTR)IDD_GEDBG_TAB_VERTICES, _hInstance, _hParent) {
values = new CtrlVertexList(GetDlgItem(m_hDlg, IDC_GEDBG_VERTICES));
}
TabVertices::~TabVertices() {
delete values;
}
void TabVertices::UpdateSize(WORD width, WORD height) {
struct Position {
int x,y;
int w,h;
};
Position position;
static const int borderMargin = 5;
static const int checkboxSpace = 22;
position.x = borderMargin;
position.y = borderMargin + checkboxSpace;
position.w = width - 2 * borderMargin;
position.h = height - 2 * borderMargin - checkboxSpace;
HWND handle = GetDlgItem(m_hDlg, IDC_GEDBG_VERTICES);
MoveWindow(handle, position.x, position.y, position.w, position.h, TRUE);
}
BOOL TabVertices::DlgProc(UINT message, WPARAM wParam, LPARAM lParam) {
switch (message) {
case WM_INITDIALOG:
return TRUE;
case WM_SIZE:
UpdateSize(LOWORD(lParam), HIWORD(lParam));
return TRUE;
case WM_COMMAND:
if (LOWORD(wParam) == IDC_GEDBG_RAWVERTS) {
values->SetRaw(IsDlgButtonChecked(m_hDlg, IDC_GEDBG_RAWVERTS) == BST_CHECKED);
values->Update();
}
return TRUE;
case WM_NOTIFY:
switch (wParam)
{
case IDC_GEDBG_VERTICES:
values->HandleNotify(lParam);
break;
}
break;
}
return FALSE;
}
+71
View File
@@ -0,0 +1,71 @@
// 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/.
#pragma once
#include <vector>
#include "GPU/Common/GPUDebugInterface.h"
#include "Windows/W32Util/DialogManager.h"
#include "Windows/W32Util/Misc.h"
class VertexDecoder;
class CtrlVertexList: public GenericListControl {
public:
CtrlVertexList(HWND hwnd);
~CtrlVertexList();
void SetRaw(bool raw) {
raw_ = raw;
Update();
}
protected:
virtual bool WindowMessage(UINT msg, WPARAM wParam, LPARAM lParam, LRESULT& returnValue) { return false; };
virtual void GetColumnText(wchar_t *dest, int row, int col);
virtual int GetRowCount();
private:
void FormatVertCol(wchar_t *dest, const GPUDebugVertex &vert, int col);
void FormatVertColRaw(wchar_t *dest, int row, int col);
void FormatVertColRawType(wchar_t *dest, const void *data, int type, int offset);
void FormatVertColRawColor(wchar_t *dest, const void *data, int type);
std::vector<GPUDebugVertex> vertices;
std::vector<u16> indices;
int rowCount_;
bool raw_;
VertexDecoder *decoder;
};
class TabVertices : public Dialog {
public:
TabVertices(HINSTANCE _hInstance, HWND _hParent);
~TabVertices();
virtual void Update() {
values->Update();
}
protected:
BOOL DlgProc(UINT message, WPARAM wParam, LPARAM lParam);
private:
void UpdateSize(WORD width, WORD height);
CtrlVertexList *values;
};
+2
View File
@@ -294,6 +294,7 @@
<ClCompile Include="GEDebugger\SimpleGLWindow.cpp" />
<ClCompile Include="GEDebugger\TabDisplayLists.cpp" />
<ClCompile Include="GEDebugger\TabState.cpp" />
<ClCompile Include="GEDebugger\TabVertices.cpp" />
<ClCompile Include="GEDebugger\VertexPreview.cpp" />
<ClCompile Include="InputDevice.cpp" />
<ClCompile Include="KeyboardDevice.cpp" />
@@ -346,6 +347,7 @@
<ClInclude Include="GEDebugger\SimpleGLWindow.h" />
<ClInclude Include="GEDebugger\TabDisplayLists.h" />
<ClInclude Include="GEDebugger\TabState.h" />
<ClInclude Include="GEDebugger\TabVertices.h" />
<ClInclude Include="InputDevice.h" />
<ClInclude Include="KeyboardDevice.h" />
<ClInclude Include="RawInput.h" />
+6
View File
@@ -143,6 +143,9 @@
<ClCompile Include="TouchInputHandler.cpp">
<Filter>Windows\Input</Filter>
</ClCompile>
<ClCompile Include="GEDebugger\TabVertices.cpp">
<Filter>Windows\GE Debugger</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="Debugger\CtrlDisAsmView.h">
@@ -260,6 +263,9 @@
<ClInclude Include="TouchInputHandler.h">
<Filter>Windows\Input</Filter>
</ClInclude>
<ClInclude Include="GEDebugger\TabVertices.h">
<Filter>Windows\GE Debugger</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="icon1.ico">
+10
View File
@@ -207,6 +207,16 @@ BEGIN
CONTROL "",IDC_GEDBG_LISTS_SELECTEDLIST,"CtrlDisplayListView",WS_BORDER,225,7,84,89
END
IDD_GEDBG_TAB_VERTICES DIALOGEX 0, 0, 316, 183
STYLE DS_SETFONT | WS_CHILD | DS_CONTROL
CAPTION "Dialog"
FONT 8, "MS Shell Dlg", 400, 0, 0x1
BEGIN
AUTOCHECKBOX "Before transform (raw)", IDC_GEDBG_RAWVERTS, 5, 5, 100, 10
CONTROL "",IDC_GEDBG_VERTICES,"SysListView32",LVS_ALIGNLEFT | LVS_SHOWSELALWAYS | LVS_REPORT | WS_BORDER | WS_TABSTOP,7,22,217,86
END
#include "aboutbox.rc"
IDD_MEMORY DIALOGEX 0, 0, 566, 287
+6 -3
View File
@@ -79,6 +79,7 @@
#define IDD_TABDISPLAYLISTS 251
#define IDD_GEDBG_TAB_VALUES 252
#define IDD_DUMPMEMORY 253
#define IDD_GEDBG_TAB_VERTICES 254
#define IDC_STOPGO 1001
#define IDC_ADDRESS 1002
@@ -156,6 +157,8 @@
#define IDC_GEDBG_FRAMEBUFADDR 1191
#define IDC_GEDBG_TEXADDR 1192
#define IDC_GEDBG_FBTABS 1193
#define IDC_GEDBG_VERTICES 1194
#define IDC_GEDBG_RAWVERTS 1195
#define ID_SHADERS_BASE 5000
@@ -312,9 +315,9 @@
// Next default values for new objects
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 254
#define _APS_NEXT_COMMAND_VALUE 40144
#define _APS_NEXT_CONTROL_VALUE 1193
#define _APS_NEXT_RESOURCE_VALUE 255
#define _APS_NEXT_COMMAND_VALUE 40148
#define _APS_NEXT_CONTROL_VALUE 1196
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif