From be63ce3a4a62e1f1fe4c6f1e6fe121e9c0460fee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 3 Aug 2023 16:31:20 +0200 Subject: [PATCH] Minor refactor allowing getting the GPU profile string outside games --- Common/GPU/OpenGL/thin3d_gl.cpp | 4 ++++ Common/GPU/Vulkan/thin3d_vulkan.cpp | 4 ++++ Common/GPU/thin3d.h | 4 ++++ GPU/Common/GPUDebugInterface.h | 8 -------- GPU/GLES/GPU_GLES.cpp | 5 ----- GPU/GLES/GPU_GLES.h | 2 -- GPU/Vulkan/DebugVisVulkan.cpp | 6 +----- GPU/Vulkan/GPU_Vulkan.cpp | 5 ----- GPU/Vulkan/GPU_Vulkan.h | 2 -- 9 files changed, 13 insertions(+), 27 deletions(-) diff --git a/Common/GPU/OpenGL/thin3d_gl.cpp b/Common/GPU/OpenGL/thin3d_gl.cpp index 5c0a155027..18f8cde843 100644 --- a/Common/GPU/OpenGL/thin3d_gl.cpp +++ b/Common/GPU/OpenGL/thin3d_gl.cpp @@ -492,6 +492,10 @@ public: renderManager_.SetInvalidationCallback(callback); } + std::string GetGpuProfileString() const override { + return renderManager_.GetGpuProfileString(); + } + private: void ApplySamplers(); diff --git a/Common/GPU/Vulkan/thin3d_vulkan.cpp b/Common/GPU/Vulkan/thin3d_vulkan.cpp index 894f6e1a90..53d1a77b10 100644 --- a/Common/GPU/Vulkan/thin3d_vulkan.cpp +++ b/Common/GPU/Vulkan/thin3d_vulkan.cpp @@ -531,6 +531,10 @@ public: renderManager_.SetInvalidationCallback(callback); } + std::string GetGpuProfileString() const override { + return renderManager_.GetGpuProfileString(); + } + private: VulkanTexture *GetNullTexture(); VulkanContext *vulkan_ = nullptr; diff --git a/Common/GPU/thin3d.h b/Common/GPU/thin3d.h index 633bb9bb14..7e627f1ab7 100644 --- a/Common/GPU/thin3d.h +++ b/Common/GPU/thin3d.h @@ -848,6 +848,10 @@ public: return FrameTimeData{}; } + virtual std::string GetGpuProfileString() const { + return ""; + } + protected: ShaderModule *vsPresets_[VS_MAX_PRESET]; ShaderModule *fsPresets_[FS_MAX_PRESET]; diff --git a/GPU/Common/GPUDebugInterface.h b/GPU/Common/GPUDebugInterface.h index 54ff31481e..974ebc2413 100644 --- a/GPU/Common/GPUDebugInterface.h +++ b/GPU/Common/GPUDebugInterface.h @@ -252,14 +252,6 @@ public: 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); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index d333b9f2f9..41c0abc253 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -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(); -} diff --git a/GPU/GLES/GPU_GLES.h b/GPU/GLES/GPU_GLES.h index 5b56504eea..9e03285ee9 100644 --- a/GPU/GLES/GPU_GLES.h +++ b/GPU/GLES/GPU_GLES.h @@ -51,8 +51,6 @@ public: void BeginHostFrame() override; void EndHostFrame() override; - std::string GetGpuProfileString() override; - protected: void FinishDeferred() override; diff --git a/GPU/Vulkan/DebugVisVulkan.cpp b/GPU/Vulkan/DebugVisVulkan.cpp index 7fa7b55fe0..f259fafe8f 100644 --- a/GPU/Vulkan/DebugVisVulkan.cpp +++ b/GPU/Vulkan/DebugVisVulkan.cpp @@ -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); @@ -115,8 +112,7 @@ void DrawGPUProfilerVis(UIContext *ui, GPUInterface *gpu) { scale = 0.7f; } - GPUCommon *gpuCommon = static_cast(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); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index 7146123a65..340d2391fa 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -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(); -} diff --git a/GPU/Vulkan/GPU_Vulkan.h b/GPU/Vulkan/GPU_Vulkan.h index 1c7f76756a..d5bae97988 100644 --- a/GPU/Vulkan/GPU_Vulkan.h +++ b/GPU/Vulkan/GPU_Vulkan.h @@ -59,8 +59,6 @@ public: return textureCacheVulkan_; } - std::string GetGpuProfileString() override; - protected: void FinishDeferred() override; void CheckRenderResized() override;