Skip to content

Commit

Permalink
Merge pull request #17846 from hrydgard/debug-overlay-everywhere
Browse files Browse the repository at this point in the history
Debug overlay everywhere
  • Loading branch information
hrydgard committed Aug 3, 2023
2 parents c3f5cfe + 8e1dc35 commit 74a471d
Show file tree
Hide file tree
Showing 25 changed files with 94 additions and 64 deletions.
4 changes: 4 additions & 0 deletions Common/GPU/OpenGL/thin3d_gl.cpp
Expand Up @@ -492,6 +492,10 @@ class OpenGLContext : public DrawContext {
renderManager_.SetInvalidationCallback(callback);
}

std::string GetGpuProfileString() const override {
return renderManager_.GetGpuProfileString();
}

private:
void ApplySamplers();

Expand Down
8 changes: 7 additions & 1 deletion Common/GPU/Vulkan/VulkanContext.h
Expand Up @@ -291,6 +291,13 @@ class VulkanContext {
return device_extensions_enabled_;
}

const std::vector<VkExtensionProperties> &GetInstanceExtensionsAvailable() const {
return instance_extension_properties_;
}
const std::vector<const char *> &GetInstanceExtensionsEnabled() const {
return instance_extensions_enabled_;
}

const VkPhysicalDeviceMemoryProperties &GetMemoryProperties() const {
return memory_properties_;
}
Expand All @@ -314,7 +321,6 @@ class VulkanContext {
for (const auto &iter : instance_layer_properties_) {
for (const auto &ext : iter.extensions) {
if (!strcmp(extensionName, ext.extensionName)) {
INFO_LOG(G3D, "%s found in layer extensions: %s", extensionName, iter.properties.layerName);
return true;
}
}
Expand Down
12 changes: 8 additions & 4 deletions Common/GPU/Vulkan/thin3d_vulkan.cpp
Expand Up @@ -517,7 +517,7 @@ class VKContext : public DrawContext {
VkDescriptorSet GetOrCreateDescriptorSet(VkBuffer buffer);

std::vector<std::string> GetFeatureList() const override;
std::vector<std::string> GetExtensionList(bool enabledOnly) const override;
std::vector<std::string> GetExtensionList(bool device, bool enabledOnly) const override;

uint64_t GetNativeObject(NativeObject obj, void *srcObject) override;

Expand All @@ -531,6 +531,10 @@ class VKContext : public DrawContext {
renderManager_.SetInvalidationCallback(callback);
}

std::string GetGpuProfileString() const override {
return renderManager_.GetGpuProfileString();
}

private:
VulkanTexture *GetNullTexture();
VulkanContext *vulkan_ = nullptr;
Expand Down Expand Up @@ -1626,14 +1630,14 @@ std::vector<std::string> VKContext::GetFeatureList() const {
return features;
}

std::vector<std::string> VKContext::GetExtensionList(bool enabledOnly) const {
std::vector<std::string> VKContext::GetExtensionList(bool device, bool enabledOnly) const {
std::vector<std::string> extensions;
if (enabledOnly) {
for (auto &iter : vulkan_->GetDeviceExtensionsEnabled()) {
for (auto &iter : (device ? vulkan_->GetDeviceExtensionsEnabled() : vulkan_->GetInstanceExtensionsEnabled())) {
extensions.push_back(iter);
}
} else {
for (auto &iter : vulkan_->GetDeviceExtensionsAvailable()) {
for (auto &iter : (device ? vulkan_->GetDeviceExtensionsAvailable() : vulkan_->GetInstanceExtensionsAvailable())) {
extensions.push_back(iter.extensionName);
}
}
Expand Down
6 changes: 5 additions & 1 deletion Common/GPU/thin3d.h
Expand Up @@ -691,7 +691,7 @@ class DrawContext {
virtual const DeviceCaps &GetDeviceCaps() const = 0;
virtual uint32_t GetDataFormatSupport(DataFormat fmt) const = 0;
virtual std::vector<std::string> GetFeatureList() const { return std::vector<std::string>(); }
virtual std::vector<std::string> GetExtensionList(bool enabledOnly) const { return std::vector<std::string>(); }
virtual std::vector<std::string> GetExtensionList(bool device, bool enabledOnly) const { return std::vector<std::string>(); }
virtual std::vector<std::string> GetDeviceList() const { return std::vector<std::string>(); }

virtual PresentationMode GetPresentationMode() const = 0;
Expand Down Expand Up @@ -848,6 +848,10 @@ class DrawContext {
return FrameTimeData{};
}

virtual std::string GetGpuProfileString() const {
return "";
}

protected:
ShaderModule *vsPresets_[VS_MAX_PRESET];
ShaderModule *fsPresets_[FS_MAX_PRESET];
Expand Down
1 change: 1 addition & 0 deletions Core/Config.cpp
Expand Up @@ -179,6 +179,7 @@ static const ConfigSetting generalSettings[] = {
ConfigSetting("CwCheatRefreshRate", &g_Config.iCwCheatRefreshRate, 77, CfgFlag::PER_GAME),
ConfigSetting("CwCheatScrollPosition", &g_Config.fCwCheatScrollPosition, 0.0f, CfgFlag::PER_GAME),
ConfigSetting("GameListScrollPosition", &g_Config.fGameListScrollPosition, 0.0f, CfgFlag::DEFAULT),
ConfigSetting("DebugOverlay", &g_Config.iDebugOverlay, 0, CfgFlag::DONT_SAVE),

ConfigSetting("ScreenshotsAsPNG", &g_Config.bScreenshotsAsPNG, false, CfgFlag::PER_GAME),
ConfigSetting("UseFFV1", &g_Config.bUseFFV1, false, CfgFlag::DEFAULT),
Expand Down
2 changes: 1 addition & 1 deletion Core/Config.h
Expand Up @@ -471,7 +471,7 @@ struct Config {

// Volatile development settings
// Overlays
DebugOverlay iDebugOverlay;
int iDebugOverlay;

bool bGpuLogProfiler; // Controls the Vulkan logging profiler (profiles textures uploads etc).

Expand Down
6 changes: 3 additions & 3 deletions Core/HLE/sceDisplay.cpp
Expand Up @@ -496,7 +496,7 @@ static void DoFrameIdleTiming() {
#endif
}

if (g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) {
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) {
DisplayNotifySleep(time_now_d() - before);
}
}
Expand Down Expand Up @@ -662,7 +662,7 @@ void __DisplayFlip(int cyclesLate) {
CoreTiming::ScheduleEvent(0 - cyclesLate, afterFlipEvent, 0);
numVBlanksSinceFlip = 0;

if (g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) {
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) {
// Track how long we sleep (whether vsync or sleep_ms.)
DisplayNotifySleep(time_now_d() - frameSleepStart, frameSleepPos);
}
Expand Down Expand Up @@ -726,7 +726,7 @@ void hleLagSync(u64 userdata, int cyclesLate) {
const int over = (int)((now - goal) * 1000000);
ScheduleLagSync(over - emuOver);

if (g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) {
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) {
DisplayNotifySleep(now - before);
}
}
Expand Down
6 changes: 5 additions & 1 deletion Core/HW/Display.cpp
Expand Up @@ -92,7 +92,7 @@ static void CalculateFPS() {
}
}

if (g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) {
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::FRAME_GRAPH || coreCollectDebugStats) {
frameTimeHistory[frameTimeHistoryPos++] = now - lastFrameTimeHistory;
lastFrameTimeHistory = now;
frameTimeHistoryPos = frameTimeHistoryPos % frameTimeHistorySize;
Expand Down Expand Up @@ -182,6 +182,10 @@ void DisplayNotifySleep(double t, int pos) {

void __DisplayGetDebugStats(char *stats, size_t bufsize) {
char statbuf[4096];
if (!gpu) {
snprintf(stats, bufsize, "N/A");
return;
}
gpu->GetStats(statbuf, sizeof(statbuf));

snprintf(stats, bufsize,
Expand Down
8 changes: 0 additions & 8 deletions GPU/Common/GPUDebugInterface.h
Expand Up @@ -252,14 +252,6 @@ class GPUDebugInterface {
virtual bool GetOutputFramebuffer(GPUDebugBuffer &buffer) {
return false;
}

// TODO:
// cached framebuffers / textures / vertices?
// get content of specific framebuffer / texture?
// vertex / texture decoding?

// Note: Wanted to name it GetProfileString but clashes with a Windows API.
virtual std::string GetGpuProfileString() { return ""; }
};

bool GPUDebugInitExpression(GPUDebugInterface *g, const char *str, PostfixExpression &exp);
Expand Down
2 changes: 1 addition & 1 deletion GPU/Common/TextureCacheCommon.cpp
Expand Up @@ -142,7 +142,7 @@ void TextureCacheCommon::StartFrame() {
timesInvalidatedAllThisFrame_ = 0;
replacementTimeThisFrame_ = 0.0;

if (g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS) {
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS) {
gpuStats.numReplacerTrackedTex = replacer_.GetNumTrackedTextures();
gpuStats.numCachedReplacedTextures = replacer_.GetNumCachedReplacedTextures();
}
Expand Down
5 changes: 0 additions & 5 deletions GPU/GLES/GPU_GLES.cpp
Expand Up @@ -309,8 +309,3 @@ void GPU_GLES::GetStats(char *buffer, size_t bufsize) {
shaderManagerGL_->GetNumPrograms()
);
}

std::string GPU_GLES::GetGpuProfileString() {
GLRenderManager *rm = (GLRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
return rm->GetGpuProfileString();
}
2 changes: 0 additions & 2 deletions GPU/GLES/GPU_GLES.h
Expand Up @@ -51,8 +51,6 @@ class GPU_GLES : public GPUCommonHW {
void BeginHostFrame() override;
void EndHostFrame() override;

std::string GetGpuProfileString() override;

protected:
void FinishDeferred() override;

Expand Down
6 changes: 1 addition & 5 deletions GPU/Vulkan/DebugVisVulkan.cpp
Expand Up @@ -98,9 +98,6 @@ void DrawGPUMemoryVis(UIContext *ui, GPUInterface *gpu) {
}

void DrawGPUProfilerVis(UIContext *ui, GPUInterface *gpu) {
if (!gpu) {
return;
}
using namespace Draw;
const int padding = 10 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_LEFT);
const int starty = 50 + System_GetPropertyFloat(SYSPROP_DISPLAY_SAFE_INSET_TOP);
Expand All @@ -115,8 +112,7 @@ void DrawGPUProfilerVis(UIContext *ui, GPUInterface *gpu) {
scale = 0.7f;
}

GPUCommon *gpuCommon = static_cast<GPUCommon *>(gpu);
std::string text = gpuCommon->GetGpuProfileString();
std::string text = ui->GetDrawContext()->GetGpuProfileString();

ui->SetFontScale(0.4f, 0.4f);
ui->DrawTextShadow(text.c_str(), x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
Expand Down
5 changes: 0 additions & 5 deletions GPU/Vulkan/GPU_Vulkan.cpp
Expand Up @@ -499,8 +499,3 @@ std::string GPU_Vulkan::DebugGetShaderString(std::string id, DebugShaderType typ
return GPUCommonHW::DebugGetShaderString(id, type, stringType);
}
}

std::string GPU_Vulkan::GetGpuProfileString() {
VulkanRenderManager *rm = (VulkanRenderManager *)draw_->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
return rm->GetGpuProfileString();
}
2 changes: 0 additions & 2 deletions GPU/Vulkan/GPU_Vulkan.h
Expand Up @@ -59,8 +59,6 @@ class GPU_Vulkan : public GPUCommonHW {
return textureCacheVulkan_;
}

std::string GetGpuProfileString() override;

protected:
void FinishDeferred() override;
void CheckRenderResized() override;
Expand Down
12 changes: 6 additions & 6 deletions SDL/CocoaBarItems.mm
Expand Up @@ -217,7 +217,7 @@ - (void)menuNeedsUpdate:(NSMenu *)menu {
item.state = [self controlStateForBool:g_Config.bIgnoreBadMemAccess];
break;
case 12:
item.state = [self controlStateForBool:g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS];
item.state = [self controlStateForBool:(DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS];
break;
default:
item.enabled = state == UISTATE_INGAME ? YES : NO;
Expand Down Expand Up @@ -405,7 +405,7 @@ -(NSMenu *)makeDebugMenu {
copyBaseAddr.target = self;
copyBaseAddr.tag = 11;

MENU_ITEM(showDebugStatsAction, DESKTOPUI_LOCALIZED("Show Debug Statistics"), @selector(toggleShowDebugStats:), (g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS), 12)
MENU_ITEM(showDebugStatsAction, DESKTOPUI_LOCALIZED("Show Debug Statistics"), @selector(toggleShowDebugStats:), ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS), 12)

[parent addItem:loadSymbolMapAction];
[parent addItem:saveMapFileAction];
Expand Down Expand Up @@ -544,13 +544,13 @@ -(void)toggle##name: (NSMenuItem *)item { \
#undef TOGGLE_METHOD

-(void)toggleShowDebugStats: (NSMenuItem *)item { \
if (g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS) {
g_Config.iDebugOverlay = DebugOverlay::OFF;
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS) {
g_Config.iDebugOverlay = (int)DebugOverlay::OFF;
} else {
g_Config.iDebugOverlay = DebugOverlay::DEBUG_STATS;
g_Config.iDebugOverlay = (int)DebugOverlay::DEBUG_STATS;
}
System_PostUIMessage("clear jit", "");
item.state = [self controlStateForBool: g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS]; \
item.state = [self controlStateForBool: (DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS]; \
}

-(void)setToggleShowCounterItem: (NSMenuItem *)item {
Expand Down
12 changes: 7 additions & 5 deletions UI/DebugOverlay.cpp
Expand Up @@ -150,7 +150,11 @@ static void DrawFrameTiming(UIContext *ctx, const Bounds &bounds) {
ctx->RebindTexture();
}

void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper &controlMapper, DebugOverlay overlay) {
void DrawControlMapperOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper &controlMapper) {
DrawControlDebug(ctx, controlMapper, ctx->GetLayoutBounds());
}

void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, DebugOverlay overlay) {
switch (overlay) {
case DebugOverlay::DEBUG_STATS:
DrawDebugStats(ctx, ctx->GetLayoutBounds());
Expand All @@ -164,11 +168,7 @@ void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper
case DebugOverlay::AUDIO:
DrawAudioDebugStats(ctx, ctx->GetLayoutBounds());
break;
case DebugOverlay::CONTROL:
DrawControlDebug(ctx, controlMapper, ctx->GetLayoutBounds());
break;
#if !PPSSPP_PLATFORM(UWP) && !PPSSPP_PLATFORM(SWITCH)

case DebugOverlay::GPU_PROFILE:
if (g_Config.iGPUBackend == (int)GPUBackend::VULKAN || g_Config.iGPUBackend == (int)GPUBackend::OPENGL) {
DrawGPUProfilerVis(ctx, gpu);
Expand All @@ -180,5 +180,7 @@ void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper
}
break;
#endif
default:
break;
}
}
3 changes: 2 additions & 1 deletion UI/DebugOverlay.h
Expand Up @@ -4,4 +4,5 @@
#include "Core/ConfigValues.h"
#include "Core/ControlMapper.h"

void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper &controlMapper, DebugOverlay overlay);
void DrawControlMapperOverlay(UIContext *ctx, const Bounds &bounds, const ControlMapper &controlMapper);
void DrawDebugOverlay(UIContext *ctx, const Bounds &bounds, DebugOverlay overlay);
21 changes: 18 additions & 3 deletions UI/DevScreens.cpp
Expand Up @@ -776,7 +776,7 @@ void SystemInfoScreen::CreateTabs() {
if (mode == vk->GetPresentMode()) {
str += std::string(" (") + di->T("Current") + ")";
}
presentModes->Add(new TextView(VulkanPresentModeToString(mode), new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true);
presentModes->Add(new TextView(str, new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true);
}

CollapsibleSection *colorFormats = gpuExtensions->Add(new CollapsibleSection(si->T("Display Color Formats")));
Expand All @@ -790,14 +790,29 @@ void SystemInfoScreen::CreateTabs() {
#endif

CollapsibleSection *enabledExtensions = gpuExtensions->Add(new CollapsibleSection(std::string(si->T("Vulkan Extensions")) + " (" + di->T("Enabled") + ")"));
std::vector<std::string> extensions = draw->GetExtensionList(true);
std::vector<std::string> extensions = draw->GetExtensionList(true, true);
std::sort(extensions.begin(), extensions.end());
for (auto &extension : extensions) {
enabledExtensions->Add(new TextView(extension, new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true);
}
// Also get instance extensions
enabledExtensions->Add(new ItemHeader("Instance"));
extensions = draw->GetExtensionList(false, true);
std::sort(extensions.begin(), extensions.end());
for (auto &extension : extensions) {
enabledExtensions->Add(new TextView(extension, new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true);
}

CollapsibleSection *vulkanExtensions = gpuExtensions->Add(new CollapsibleSection(si->T("Vulkan Extensions")));
extensions = draw->GetExtensionList(false);
extensions = draw->GetExtensionList(true, false);
std::sort(extensions.begin(), extensions.end());
for (auto &extension : extensions) {
vulkanExtensions->Add(new TextView(extension, new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true);
}

vulkanExtensions->Add(new ItemHeader("Instance"));
// Also get instance extensions
extensions = draw->GetExtensionList(false, false);
std::sort(extensions.begin(), extensions.end());
for (auto &extension : extensions) {
vulkanExtensions->Add(new TextView(extension, new LayoutParams(FILL_PARENT, WRAP_CONTENT)))->SetFocusable(true);
Expand Down
9 changes: 5 additions & 4 deletions UI/EmuScreen.cpp
Expand Up @@ -1427,7 +1427,7 @@ void EmuScreen::render() {
}
}

Core_UpdateDebugStats(g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS || g_Config.bLogFrameDrops);
Core_UpdateDebugStats((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::DEBUG_STATS || g_Config.bLogFrameDrops);

bool blockedExecution = Achievements::IsBlockingExecution();
if (!blockedExecution) {
Expand Down Expand Up @@ -1503,7 +1503,7 @@ bool EmuScreen::hasVisibleUI() {
if (g_Config.bEnableCardboardVR || g_Config.bEnableNetworkChat)
return true;
// Debug UI.
if (g_Config.iDebugOverlay != DebugOverlay::OFF)
if ((DebugOverlay)g_Config.iDebugOverlay != DebugOverlay::OFF)
return true;

// Exception information.
Expand Down Expand Up @@ -1538,8 +1538,9 @@ void EmuScreen::renderUI() {
}

if (!invalid_) {
DrawDebugOverlay(ctx, ctx->GetLayoutBounds(), controlMapper_, g_Config.iDebugOverlay);

if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::CONTROL) {
DrawControlMapperOverlay(ctx, ctx->GetLayoutBounds(), controlMapper_);
}
if (g_Config.iShowStatusFlags) {
DrawFPS(ctx, ctx->GetLayoutBounds());
}
Expand Down
2 changes: 1 addition & 1 deletion UI/NativeApp.cpp
Expand Up @@ -1098,7 +1098,7 @@ void NativeRender(GraphicsContext *graphicsContext) {
g_screenManager->getUIContext()->SetTintSaturation(g_Config.fUITint, g_Config.fUISaturation);

Draw::DebugFlags debugFlags = Draw::DebugFlags::NONE;
if (g_Config.iDebugOverlay == DebugOverlay::GPU_PROFILE)
if ((DebugOverlay)g_Config.iDebugOverlay == DebugOverlay::GPU_PROFILE)
debugFlags |= Draw::DebugFlags::PROFILE_TIMESTAMPS;
if (g_Config.bGpuLogProfiler)
debugFlags |= Draw::DebugFlags::PROFILE_SCOPES;
Expand Down

0 comments on commit 74a471d

Please sign in to comment.