mirror of
https://github.com/hrydgard/ppsspp.git
synced 2026-12-02 10:43:44 +01:00
Implement vertex preview in the new Ge debugger
This commit is contained in:
1 parent
50fd2ea1b7
commit
5aeef924d2
7 files changed
+93
-9
No files matched your search
@@ -831,7 +831,7 @@ static void ExpandSpline(int &count, int op, const std::vector<SimpleVertex> &si
|
||||
FreeAlignedMemory(cpoints.col);
|
||||
}
|
||||
|
||||
bool GetPrimPreview(u32 op, int which, GEPrimitiveType &prim, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, int &count) {
|
||||
bool GetPrimPreview(u32 op, GEPrimitiveType &prim, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, int &count) {
|
||||
u32 prim_type = GE_PRIM_INVALID;
|
||||
int count_u = 0;
|
||||
int count_v = 0;
|
||||
@@ -857,7 +857,7 @@ bool GetPrimPreview(u32 op, int which, GEPrimitiveType &prim, std::vector<GPUDeb
|
||||
ERROR_LOG(Log::G3D, "Invalid debugging environment, shutting down?");
|
||||
return false;
|
||||
}
|
||||
if (count == 0 || which == 0) {
|
||||
if (count == 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -45,6 +45,6 @@ void FormatVertColRaw(VertexDecoder *decoder, char *dest, size_t destSize, int r
|
||||
// These are utilities used by the debugger vertex preview.
|
||||
|
||||
// Later I hope to re-use more of the real logic.
|
||||
bool GetPrimPreview(u32 op, int which, GEPrimitiveType &prim, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, int &count);
|
||||
bool GetPrimPreview(u32 op, GEPrimitiveType &prim, std::vector<GPUDebugVertex> &vertices, std::vector<u16> &indices, int &count);
|
||||
void DescribePixel(u32 pix, GPUDebugBufferFormat fmt, int x, int y, char desc[256]);
|
||||
void DescribePixelRGBA(u32 pix, GPUDebugBufferFormat fmt, int x, int y, char desc[256]);
|
||||
@@ -902,14 +902,14 @@ void ImDebugger::Frame(MIPSDebugInterface *mipsDebug, GPUDebugInterface *gpuDebu
|
||||
|
||||
if (lastCpuStepCount_ != Core_GetSteppingCounter()) {
|
||||
lastCpuStepCount_ = Core_GetSteppingCounter();
|
||||
disasm_.View().NotifyStep();
|
||||
disasm_.NotifyStep();
|
||||
}
|
||||
|
||||
if (lastGpuStepCount_ != GPUStepping::GetSteppingCounter()) {
|
||||
// A GPU step has happened since last time. This means that we should re-center the cursor.
|
||||
// Snapshot();
|
||||
lastGpuStepCount_ = GPUStepping::GetSteppingCounter();
|
||||
geDebugger_.View().NotifyStep();
|
||||
geDebugger_.NotifyStep();
|
||||
}
|
||||
|
||||
ImControl control{};
|
||||
|
||||
@@ -36,6 +36,9 @@ public:
|
||||
ImDisasmView &View() {
|
||||
return disasmView_;
|
||||
}
|
||||
void NotifyStep() {
|
||||
disasmView_.NotifyStep();
|
||||
}
|
||||
void DirtySymbolMap() {
|
||||
symsDirty_ = true;
|
||||
}
|
||||
|
||||
+69
-2
@@ -367,8 +367,26 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa
|
||||
|
||||
ImGui::SameLine();
|
||||
|
||||
u32 op = 0;
|
||||
DisplayList list;
|
||||
if (gpuDebug->GetCurrentDisplayList(list)) {
|
||||
op = Memory::Read_U32(list.pc);
|
||||
bool isOnPrim = (op >> 24) == GE_CMD_PRIM;
|
||||
if (isOnPrim) {
|
||||
if (reloadPreview_) {
|
||||
GetPrimPreview(op, previewPrim_, previewVertices_, previewIndices_, previewCount_);
|
||||
reloadPreview_ = false;
|
||||
}
|
||||
} else {
|
||||
previewCount_ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::BeginChild("texture/fb view"); // Leave room for 1 line below us
|
||||
|
||||
|
||||
ImDrawList *drawList = ImGui::GetWindowDrawList();
|
||||
|
||||
if (coreState == CORE_STEPPING_GE) {
|
||||
FramebufferManagerCommon *fbman = gpuDebug->GetFramebufferManagerCommon();
|
||||
u32 fbptr = gstate.getFrameBufAddress();
|
||||
@@ -384,8 +402,31 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa
|
||||
if (ImGui::BeginTabBar("aspects")) {
|
||||
if (ImGui::BeginTabItem("Color")) {
|
||||
ImTextureID texId = ImGui_ImplThin3d_AddFBAsTextureTemp(vfb->fbo, Draw::FB_COLOR_BIT, ImGuiPipeline::TexturedOpaque);
|
||||
const ImVec2 p0 = ImGui::GetCursorScreenPos();
|
||||
ImGui::Image(texId, ImVec2(vfb->width, vfb->height));
|
||||
// TODO: Draw vertex preview on top!
|
||||
// Draw vertex preview on top!
|
||||
if (previewCount_) {
|
||||
switch (previewPrim_) {
|
||||
case GE_PRIM_TRIANGLES:
|
||||
case GE_PRIM_RECTANGLES:
|
||||
{
|
||||
for (int i = 0; i < previewCount_ - 2; i += 3) {
|
||||
const auto &v1 = previewIndices_.empty() ? previewVertices_[i] : previewVertices_[previewIndices_[i]];
|
||||
const auto &v2 = previewIndices_.empty() ? previewVertices_[i + 1] : previewVertices_[previewIndices_[i + 1]];
|
||||
const auto &v3 = previewIndices_.empty() ? previewVertices_[i + 2] : previewVertices_[previewIndices_[i + 2]];
|
||||
drawList->AddTriangleFilled(
|
||||
ImVec2(p0.x + v1.x, p0.y + v1.y),
|
||||
ImVec2(p0.x + v2.x, p0.y + v2.y),
|
||||
ImVec2(p0.x + v3.x, p0.y + v3.y), ImColor(0x600000FF));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// TODO: Support lines etc.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::EndTabItem();
|
||||
}
|
||||
if (ImGui::BeginTabItem("Depth")) {
|
||||
@@ -415,7 +456,33 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa
|
||||
void *nativeView = texcache->GetNativeTextureView(tex, true);
|
||||
ImTextureID texId = ImGui_ImplThin3d_AddNativeTextureTemp(nativeView);
|
||||
|
||||
ImGui::Image(texId, ImVec2(128, 128));
|
||||
const ImVec2 p0 = ImGui::GetCursorScreenPos();
|
||||
float texW = dimWidth(tex->dim);
|
||||
float texH = dimHeight(tex->dim);
|
||||
ImGui::Image(texId, ImVec2(texW, texH));
|
||||
|
||||
// Draw UVs of vertex preview on top of the texture!
|
||||
if (previewCount_) {
|
||||
switch (previewPrim_) {
|
||||
case GE_PRIM_TRIANGLES:
|
||||
case GE_PRIM_RECTANGLES:
|
||||
{
|
||||
for (int i = 0; i < previewCount_ - 2; i += 3) {
|
||||
const auto &v1 = previewIndices_.empty() ? previewVertices_[i] : previewVertices_[previewIndices_[i]];
|
||||
const auto &v2 = previewIndices_.empty() ? previewVertices_[i + 1] : previewVertices_[previewIndices_[i + 1]];
|
||||
const auto &v3 = previewIndices_.empty() ? previewVertices_[i + 2] : previewVertices_[previewIndices_[i + 2]];
|
||||
drawList->AddTriangleFilled(
|
||||
ImVec2(p0.x + v1.u * texW, p0.y + v1.v * texH),
|
||||
ImVec2(p0.x + v2.u * texW, p0.y + v2.v * texH),
|
||||
ImVec2(p0.x + v3.u * texW, p0.y + v3.v * texH), ImColor(0x600000FF));
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
// TODO: Support lines etc.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Let's display the current CLUT.
|
||||
|
||||
|
||||
+11
-1
@@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "GPU/Common/GPUDebugInterface.h"
|
||||
|
||||
// GE-related windows of the ImDebugger
|
||||
|
||||
struct ImConfig;
|
||||
@@ -7,7 +9,6 @@ struct ImControl;
|
||||
|
||||
class FramebufferManagerCommon;
|
||||
class TextureCacheCommon;
|
||||
class GPUDebugInterface;
|
||||
|
||||
void DrawFramebuffersWindow(ImConfig &cfg, FramebufferManagerCommon *framebufferManager);
|
||||
void DrawTexturesWindow(ImConfig &cfg, TextureCacheCommon *textureCache);
|
||||
@@ -57,8 +58,17 @@ public:
|
||||
const char *Title() const {
|
||||
return "GE Debugger";
|
||||
}
|
||||
void NotifyStep() {
|
||||
reloadPreview_ = true;
|
||||
disasmView_.NotifyStep();
|
||||
}
|
||||
|
||||
private:
|
||||
ImGeDisasmView disasmView_;
|
||||
int showBannerInFrames_ = 0;
|
||||
bool reloadPreview_ = false;
|
||||
GEPrimitiveType previewPrim_;
|
||||
std::vector<u16> previewIndices_;
|
||||
std::vector<GPUDebugVertex> previewVertices_;
|
||||
int previewCount_ = 0;
|
||||
};
|
||||
@@ -89,12 +89,16 @@ u32 CGEDebugger::PrimPreviewOp() {
|
||||
void CGEDebugger::UpdatePrimPreview(u32 op, int which) {
|
||||
which &= previewsEnabled_;
|
||||
|
||||
if (which == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
static std::vector<GPUDebugVertex> vertices;
|
||||
static std::vector<u16> indices;
|
||||
|
||||
int count = 0;
|
||||
GEPrimitiveType prim;
|
||||
if (!GetPrimPreview(op, which, prim, vertices, indices, count)) {
|
||||
if (!GetPrimPreview(op, prim, vertices, indices, count)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user