Merge pull request #18462 from hrydgard/framebuffer-listing-overlay

Framebuffer listing overlay
This commit is contained in:
Henrik Rydgård 2023-12-02 18:51:33 +01:00 committed by GitHub
commit d584162e06
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 38 additions and 27 deletions

View file

@ -166,4 +166,5 @@ enum class DebugOverlay : int {
AUDIO,
GPU_PROFILE,
GPU_ALLOCATOR,
FRAMEBUFFER_LIST,
};

View file

@ -3195,20 +3195,11 @@ void FramebufferManagerCommon::RebindFramebuffer(const char *tag) {
}
}
std::vector<FramebufferInfo> FramebufferManagerCommon::GetFramebufferList() const {
std::vector<FramebufferInfo> list;
std::vector<const VirtualFramebuffer *> FramebufferManagerCommon::GetFramebufferList() const {
std::vector<const VirtualFramebuffer *> list;
for (auto vfb : vfbs_) {
FramebufferInfo info;
info.fb_address = vfb->fb_address;
info.z_address = vfb->z_address;
info.format = vfb->fb_format;
info.width = vfb->width;
info.height = vfb->height;
info.fbo = vfb->fbo;
list.push_back(info);
list.push_back(vfb);
}
return list;
}

View file

@ -327,7 +327,7 @@ public:
void SetDepthFrameBuffer(bool isClearingDepth);
void RebindFramebuffer(const char *tag);
std::vector<FramebufferInfo> GetFramebufferList() const;
std::vector<const VirtualFramebuffer *> GetFramebufferList() const;
void CopyDisplayToOutput(bool reallyDirty);

View file

@ -727,7 +727,7 @@ bool GPUCommonHW::GetOutputFramebuffer(GPUDebugBuffer &buffer) {
return framebufferManager_ ? framebufferManager_->GetOutputFramebuffer(buffer) : false;
}
std::vector<FramebufferInfo> GPUCommonHW::GetFramebufferList() const {
std::vector<const VirtualFramebuffer *> GPUCommonHW::GetFramebufferList() const {
return framebufferManager_->GetFramebufferList();
}

View file

@ -23,7 +23,7 @@ public:
bool GetCurrentDepthbuffer(GPUDebugBuffer &buffer) override;
bool GetCurrentStencilbuffer(GPUDebugBuffer &buffer) override;
bool GetOutputFramebuffer(GPUDebugBuffer &buffer) override;
std::vector<FramebufferInfo> GetFramebufferList() const override;
std::vector<const VirtualFramebuffer *> GetFramebufferList() const override;
bool GetCurrentTexture(GPUDebugBuffer &buffer, int level, bool *isFramebuffer) override;
bool GetCurrentClut(GPUDebugBuffer &buffer) override;

View file

@ -31,6 +31,7 @@
struct PspGeListArgs;
struct GPUgstate;
class PointerWrap;
struct VirtualFramebuffer;
enum DisplayListStatus {
// The list has been completed
@ -126,16 +127,6 @@ enum class GPUCopyFlag {
};
ENUM_CLASS_BITOPS(GPUCopyFlag);
// Used for debug
struct FramebufferInfo {
u32 fb_address;
u32 z_address;
int format;
u32 width;
u32 height;
void* fbo;
};
struct DisplayListStackEntry {
u32 pc;
u32 offsetAddr;
@ -271,7 +262,7 @@ public:
virtual void GetReportingInfo(std::string &primaryInfo, std::string &fullInfo) = 0;
virtual const std::list<int>& GetDisplayLists() = 0;
// TODO: Currently Qt only, needs to be cleaned up.
virtual std::vector<FramebufferInfo> GetFramebufferList() const = 0;
virtual std::vector<const VirtualFramebuffer *> GetFramebufferList() const = 0;
virtual s64 GetListTicks(int listid) const = 0;
// For debugging. The IDs returned are opaque, do not poke in them or display them in any way.

View file

@ -138,7 +138,7 @@ public:
void SetDisplayFramebuffer(u32 framebuf, u32 stride, GEBufferFormat format) override;
void CopyDisplayToOutput(bool reallyDirty) override;
void GetStats(char *buffer, size_t bufsize) override;
std::vector<FramebufferInfo> GetFramebufferList() const override { return std::vector<FramebufferInfo>(); }
std::vector<const VirtualFramebuffer *> GetFramebufferList() const override { return std::vector<const VirtualFramebuffer *>(); }
void InvalidateCache(u32 addr, int size, GPUInvalidationType type) override;
void PerformWriteFormattedFromMemory(u32 addr, int size, int width, GEBufferFormat format) override;
bool PerformMemoryCopy(u32 dest, u32 src, int size, GPUCopyFlag flags = GPUCopyFlag::NONE) override;

View file

@ -9,8 +9,10 @@
#include "Core/Config.h"
#include "Core/System.h"
#include "GPU/GPU.h"
#include "GPU/GPUInterface.h"
// TODO: This should be moved here or to Common, doesn't belong in /GPU
#include "GPU/Vulkan/DebugVisVulkan.h"
#include "GPU/Common/FramebufferManagerCommon.h"
// For std::max
#include <algorithm>
@ -174,6 +176,27 @@ static void DrawFrameTiming(UIContext *ctx, const Bounds &bounds) {
ctx->RebindTexture();
}
void DrawFramebufferList(UIContext *ctx, GPUInterface *gpu, const Bounds &bounds) {
if (!gpu) {
return;
}
FontID ubuntu24("UBUNTU24");
auto list = gpu->GetFramebufferList();
ctx->Flush();
ctx->BindFontTexture();
ctx->Draw()->SetFontScale(0.7f, 0.7f);
int i = 0;
for (const VirtualFramebuffer *vfb : list) {
char buf[512];
snprintf(buf, sizeof(buf), "%08x (Z %08x): %dx%d (stride %d, %d)",
vfb->fb_address, vfb->z_address, vfb->width, vfb->height, vfb->fb_stride, vfb->z_stride);
ctx->Draw()->DrawTextRect(ubuntu24, buf, bounds.x + 10, bounds.y + 20 + i * 50, bounds.w - 20, bounds.h - 30, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
i++;
}
ctx->Flush();
}
void DrawControlMapperOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper &controlMapper) {
DrawControlDebug(ctx, controlMapper, ctx->GetLayoutBounds());
}
@ -208,6 +231,10 @@ void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, DebugOverlay overlay
}
break;
#endif
case DebugOverlay::FRAMEBUFFER_LIST:
if (inGame)
DrawFramebufferList(ctx, gpu, bounds);
break;
default:
break;
}

View file

@ -102,6 +102,7 @@ static const char *g_debugOverlayList[] = {
"Audio Debug",
"GPU Profile",
"GPU Allocator Viewer",
"Framebuffer List",
};
void AddOverlayList(UI::ViewGroup *items, ScreenManager *screenManager) {