From 231f4efbbb4d59088dbbde51b87377332ede35ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Sun, 26 Feb 2023 10:33:11 +0100 Subject: [PATCH] Move some more stuff to GPUCommonHW --- GPU/GPUCommon.cpp | 68 ---------------------------------------- GPU/GPUCommon.h | 6 ---- GPU/GPUCommonHW.cpp | 57 ++++++++++++++++++++++++++++++++- GPU/GPUCommonHW.h | 2 ++ GPU/Software/SoftGpu.cpp | 2 ++ 5 files changed, 60 insertions(+), 75 deletions(-) diff --git a/GPU/GPUCommon.cpp b/GPU/GPUCommon.cpp index 40990eb41b..884b06816b 100644 --- a/GPU/GPUCommon.cpp +++ b/GPU/GPUCommon.cpp @@ -12,12 +12,9 @@ #endif #include -#include -#include #include "Common/Profiler/Profiler.h" -#include "Common/Data/Convert/ColorConv.h" #include "Common/GraphicsContext.h" #include "Common/LogReporting.h" #include "Common/Serialize/Serializer.h" @@ -41,10 +38,8 @@ #include "Core/HLE/sceGe.h" #include "Core/HW/Display.h" #include "Core/MemMapHelpers.h" -#include "Core/Util/PPGeDraw.h" #include "GPU/Common/DrawEngineCommon.h" #include "GPU/Common/FramebufferManagerCommon.h" -#include "GPU/Common/SplineCommon.h" #include "GPU/Common/TextureCacheCommon.h" #include "GPU/Debugger/Debugger.h" #include "GPU/Debugger/Record.h" @@ -74,13 +69,6 @@ GPUCommon::GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : UpdateVsyncInterval(true); ResetMatrices(); - - PPGeSetDrawContext(draw); -} - -GPUCommon::~GPUCommon() { - // Probably not necessary. - PPGeSetDrawContext(nullptr); } void GPUCommon::BeginHostFrame() { @@ -126,19 +114,6 @@ void GPUCommon::Reinitialize() { framebufferManager_->DestroyAllFBOs(); } -// Call at the END of the GPU implementation's DeviceLost -void GPUCommon::DeviceLost() { - framebufferManager_->DeviceLost(); - draw_ = nullptr; -} - -// Call at the start of the GPU implementation's DeviceRestore -void GPUCommon::DeviceRestore(Draw::DrawContext *draw) { - draw_ = draw; - framebufferManager_->DeviceRestore(draw_); - PPGeSetDrawContext(draw_); -} - void GPUCommon::UpdateVsyncInterval(bool force) { #if !(PPSSPP_PLATFORM(ANDROID) || defined(USING_QT_UI) || PPSSPP_PLATFORM(UWP) || PPSSPP_PLATFORM(IOS)) int desiredVSyncInterval = g_Config.bVSync ? 1 : 0; @@ -2053,46 +2028,3 @@ void GPUCommon::UpdateUVScaleOffset() { gstate_c.uv.vOff = getFloat24(gstate.texoffsetv); #endif } - -size_t GPUCommon::FormatGPUStatsCommon(char *buffer, size_t size) { - float vertexAverageCycles = gpuStats.numVertsSubmitted > 0 ? (float)gpuStats.vertexGPUCycles / (float)gpuStats.numVertsSubmitted : 0.0f; - return snprintf(buffer, size, - "DL processing time: %0.2f ms, %d drawsync, %d listsync\n" - "Draw calls: %d, flushes %d, clears %d (cached: %d)\n" - "Num Tracked Vertex Arrays: %d\n" - "Vertices: %d cached: %d uncached: %d\n" - "FBOs active: %d (evaluations: %d)\n" - "Textures: %d, dec: %d, invalidated: %d, hashed: %d kB\n" - "readbacks %d (%d non-block), uploads %d, depal %d\n" - "Copies: depth %d, color %d, reint %d, blend %d, selftex %d\n" - "GPU cycles executed: %d (%f per vertex)\n", - gpuStats.msProcessingDisplayLists * 1000.0f, - gpuStats.numDrawSyncs, - gpuStats.numListSyncs, - gpuStats.numDrawCalls, - gpuStats.numFlushes, - gpuStats.numClears, - gpuStats.numCachedDrawCalls, - gpuStats.numTrackedVertexArrays, - gpuStats.numVertsSubmitted, - gpuStats.numCachedVertsDrawn, - gpuStats.numUncachedVertsDrawn, - (int)framebufferManager_->NumVFBs(), - gpuStats.numFramebufferEvaluations, - (int)textureCache_->NumLoadedTextures(), - gpuStats.numTexturesDecoded, - gpuStats.numTextureInvalidations, - gpuStats.numTextureDataBytesHashed / 1024, - gpuStats.numBlockingReadbacks, - gpuStats.numReadbacks, - gpuStats.numUploads, - gpuStats.numDepal, - gpuStats.numDepthCopies, - gpuStats.numColorCopies, - gpuStats.numReinterpretCopies, - gpuStats.numCopiesForShaderBlend, - gpuStats.numCopiesForSelfTex, - gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles, - vertexAverageCycles - ); -} diff --git a/GPU/GPUCommon.h b/GPU/GPUCommon.h index b58923013e..367da7c85b 100644 --- a/GPU/GPUCommon.h +++ b/GPU/GPUCommon.h @@ -70,7 +70,6 @@ struct TransformedVertex { class GPUCommon : public GPUInterface, public GPUDebugInterface { public: GPUCommon(GraphicsContext *gfxCtx, Draw::DrawContext *draw); - ~GPUCommon(); Draw::DrawContext *GetDrawContext() override { return draw_; @@ -225,9 +224,6 @@ public: } protected: - void DeviceLost() override; - void DeviceRestore(Draw::DrawContext *draw) override; - void ClearCacheNextFrame() override {} virtual void CheckRenderResized() {} @@ -275,8 +271,6 @@ protected: } } - size_t FormatGPUStatsCommon(char *buf, size_t size); - virtual void BuildReportingInfo() = 0; virtual void UpdateMSAALevel(Draw::DrawContext *draw) {} diff --git a/GPU/GPUCommonHW.cpp b/GPU/GPUCommonHW.cpp index 6a1771875d..2278ceadb2 100644 --- a/GPU/GPUCommonHW.cpp +++ b/GPU/GPUCommonHW.cpp @@ -6,6 +6,7 @@ #include "Core/System.h" #include "Core/Config.h" +#include "Core/Util/PPGeDraw.h" #include "GPU/GPUCommonHW.h" #include "GPU/Common/SplineCommon.h" @@ -386,6 +387,8 @@ GPUCommonHW::GPUCommonHW(GraphicsContext *gfxCtx, Draw::DrawContext *draw) : GPU UpdateCmdInfo(); UpdateMSAALevel(draw); + + PPGeSetDrawContext(draw); } GPUCommonHW::~GPUCommonHW() { @@ -407,13 +410,22 @@ void GPUCommonHW::CheckRenderResized() { } } +// Call at the END of the GPU implementation's DeviceLost void GPUCommonHW::DeviceLost() { - textureCache_->Clear(false); framebufferManager_->DeviceLost(); + draw_ = nullptr; + textureCache_->Clear(false); textureCache_->DeviceLost(); shaderManager_->DeviceLost(); } +// Call at the start of the GPU implementation's DeviceRestore +void GPUCommonHW::DeviceRestore(Draw::DrawContext *draw) { + draw_ = draw; + framebufferManager_->DeviceRestore(draw_); + PPGeSetDrawContext(draw_); +} + void GPUCommonHW::UpdateCmdInfo() { if (g_Config.bSoftwareSkinning) { cmdInfo_[GE_CMD_VERTEXTYPE].flags &= ~FLAG_FLUSHBEFOREONCHANGE; @@ -1599,3 +1611,46 @@ void GPUCommonHW::Execute_BoneMtxData(u32 op, u32 diff) { gstate.boneMatrixNumber = (GE_CMD_BONEMATRIXNUMBER << 24) | (num & 0x00FFFFFF); gstate.boneMatrixData = GE_CMD_BONEMATRIXDATA << 24; } + +size_t GPUCommonHW::FormatGPUStatsCommon(char *buffer, size_t size) { + float vertexAverageCycles = gpuStats.numVertsSubmitted > 0 ? (float)gpuStats.vertexGPUCycles / (float)gpuStats.numVertsSubmitted : 0.0f; + return snprintf(buffer, size, + "DL processing time: %0.2f ms, %d drawsync, %d listsync\n" + "Draw calls: %d, flushes %d, clears %d (cached: %d)\n" + "Num Tracked Vertex Arrays: %d\n" + "Vertices: %d cached: %d uncached: %d\n" + "FBOs active: %d (evaluations: %d)\n" + "Textures: %d, dec: %d, invalidated: %d, hashed: %d kB\n" + "readbacks %d (%d non-block), uploads %d, depal %d\n" + "Copies: depth %d, color %d, reint %d, blend %d, selftex %d\n" + "GPU cycles executed: %d (%f per vertex)\n", + gpuStats.msProcessingDisplayLists * 1000.0f, + gpuStats.numDrawSyncs, + gpuStats.numListSyncs, + gpuStats.numDrawCalls, + gpuStats.numFlushes, + gpuStats.numClears, + gpuStats.numCachedDrawCalls, + gpuStats.numTrackedVertexArrays, + gpuStats.numVertsSubmitted, + gpuStats.numCachedVertsDrawn, + gpuStats.numUncachedVertsDrawn, + (int)framebufferManager_->NumVFBs(), + gpuStats.numFramebufferEvaluations, + (int)textureCache_->NumLoadedTextures(), + gpuStats.numTexturesDecoded, + gpuStats.numTextureInvalidations, + gpuStats.numTextureDataBytesHashed / 1024, + gpuStats.numBlockingReadbacks, + gpuStats.numReadbacks, + gpuStats.numUploads, + gpuStats.numDepal, + gpuStats.numDepthCopies, + gpuStats.numColorCopies, + gpuStats.numReinterpretCopies, + gpuStats.numCopiesForShaderBlend, + gpuStats.numCopiesForSelfTex, + gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles, + vertexAverageCycles + ); +} diff --git a/GPU/GPUCommonHW.h b/GPU/GPUCommonHW.h index ca3fe1780d..2e13a11738 100644 --- a/GPU/GPUCommonHW.h +++ b/GPU/GPUCommonHW.h @@ -12,6 +12,7 @@ public: void CopyDisplayToOutput(bool reallyDirty) override; void DoState(PointerWrap &p) override; void DeviceLost() override; + void DeviceRestore(Draw::DrawContext *draw) override; void BeginFrame() override; @@ -69,6 +70,7 @@ private: void CheckFlushOp(int cmd, u32 diff); protected: + size_t FormatGPUStatsCommon(char *buf, size_t size); void UpdateCmdInfo() override; void PreExecuteOp(u32 op, u32 diff) override; diff --git a/GPU/Software/SoftGpu.cpp b/GPU/Software/SoftGpu.cpp index 2a3bf685f7..bf54743958 100644 --- a/GPU/Software/SoftGpu.cpp +++ b/GPU/Software/SoftGpu.cpp @@ -454,6 +454,8 @@ SoftGPU::SoftGPU(GraphicsContext *gfxCtx, Draw::DrawContext *draw) NotifyConfigChanged(); NotifyRenderResized(); NotifyDisplayResized(); + + PPGeSetDrawContext(draw); } void SoftGPU::DeviceLost() {