From 198dae2ede276a28a060e73a274aaf2f23cb327e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Fri, 13 Dec 2024 12:49:03 +0100 Subject: [PATCH] Add clipping --- UI/ImDebugger/ImGe.cpp | 51 +++++++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/UI/ImDebugger/ImGe.cpp b/UI/ImDebugger/ImGe.cpp index 096420cd54ed..bfa8769d7b02 100644 --- a/UI/ImDebugger/ImGe.cpp +++ b/UI/ImDebugger/ImGe.cpp @@ -470,7 +470,6 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa ImGui::BeginChild("texture/fb view"); // Leave room for 1 line below us - ImDrawList *drawList = ImGui::GetWindowDrawList(); if (coreState == CORE_STEPPING_GE) { @@ -489,11 +488,18 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa if (ImGui::BeginTabItem("Color")) { ImTextureID texId = ImGui_ImplThin3d_AddFBAsTextureTemp(vfb->fbo, Draw::FB_COLOR_BIT, ImGuiPipeline::TexturedOpaque); const ImVec2 p0 = ImGui::GetCursorScreenPos(); + const ImVec2 p1 = ImVec2(p0.x + vfb->width, p0.y + vfb->height); + + // Draw border and background color + drawList->PushClipRect(p0, p1, true); + ImGui::Image(texId, ImVec2(vfb->width, vfb->height)); // Draw vertex preview on top! DrawPreviewPrimitive(drawList, p0, previewPrim_, previewIndices_, previewVertices_, previewCount_, false); + drawList->PopClipRect(); + ImGui::EndTabItem(); } if (ImGui::BeginTabItem("Depth")) { @@ -514,25 +520,38 @@ void ImGeDebuggerWindow::Draw(ImConfig &cfg, ImControl &control, GPUDebugInterfa ImGui::Text("%dx%d (emulated: %dx%d)", vfb->width, vfb->height, vfb->bufferWidth, vfb->bufferHeight); } + if (gstate.isModeClear()) { + ImGui::Text("(clear mode - texturing not used)"); + } else if (!gstate.isTextureMapEnabled()) { + ImGui::Text("(texturing not enabled"); + } else { + TextureCacheCommon *texcache = gpuDebug->GetTextureCacheCommon(); + TexCacheEntry *tex = texcache->SetTexture(); + if (tex) { + ImGui::Text("Texture: "); + texcache->ApplyTexture(); + + void *nativeView = texcache->GetNativeTextureView(tex, true); + ImTextureID texId = ImGui_ImplThin3d_AddNativeTextureTemp(nativeView); - TextureCacheCommon *texcache = gpuDebug->GetTextureCacheCommon(); - TexCacheEntry *tex = texcache->SetTexture(); - if (tex) { - ImGui::Text("Texture: "); - texcache->ApplyTexture(); + float texW = dimWidth(tex->dim); + float texH = dimHeight(tex->dim); - void *nativeView = texcache->GetNativeTextureView(tex, true); - ImTextureID texId = ImGui_ImplThin3d_AddNativeTextureTemp(nativeView); + const ImVec2 p0 = ImGui::GetCursorScreenPos(); + const ImVec2 sz = ImGui::GetContentRegionAvail(); + const ImVec2 p1 = ImVec2(p0.x + texW, p0.y + texH); - const ImVec2 p0 = ImGui::GetCursorScreenPos(); - float texW = dimWidth(tex->dim); - float texH = dimHeight(tex->dim); - ImGui::Image(texId, ImVec2(texW, texH)); + // Draw border and background color + drawList->PushClipRect(p0, p1, true); - DrawPreviewPrimitive(drawList, p0, previewPrim_, previewIndices_, previewVertices_, previewCount_, true, texW, texH); - } else { - ImGui::Text("(no valid texture bound)"); - // TODO: List some of the texture params here. + ImGui::Image(texId, ImVec2(texW, texH)); + DrawPreviewPrimitive(drawList, p0, previewPrim_, previewIndices_, previewVertices_, previewCount_, true, texW, texH); + + drawList->PopClipRect(); + } else { + ImGui::Text("(no valid texture bound)"); + // TODO: List some of the texture params here. + } } // Let's display the current CLUT.