Share GPUS stats formatting code between the backends (easier to add new stats)

This commit is contained in:
Henrik Rydgård 2020-09-20 21:33:06 +02:00
parent 7d2b5c8a7e
commit 3093b9c7bf
8 changed files with 72 additions and 129 deletions

View File

@ -1759,8 +1759,9 @@ void TextureCacheCommon::Invalidate(u32 addr, int size, GPUInvalidationType type
// This is an active signal from the game that something in the texture cache may have changed.
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
} else {
// Do a quick check to see if the current texture is in range.
// Do a quick check to see if the current texture could potentially be in range.
const u32 currentAddr = gstate.getTextureAddress(0);
// TODO: This can be made tighter.
if (addr_end >= currentAddr && addr < currentAddr + LARGEST_TEXTURE_SIZE) {
gstate_c.Dirty(DIRTY_TEXTURE_IMAGE);
}

View File

@ -304,38 +304,13 @@ void GPU_D3D11::ExecuteOp(u32 op, u32 diff) {
}
void GPU_D3D11::GetStats(char *buffer, size_t bufsize) {
float vertexAverageCycles = gpuStats.numVertsSubmitted > 0 ? (float)gpuStats.vertexGPUCycles / (float)gpuStats.numVertsSubmitted : 0.0f;
snprintf(buffer, bufsize - 1,
"DL processing time: %0.2f ms\n"
"Draw calls: %i, flushes %i, clears %i (cached: %d)\n"
"Num Tracked Vertex Arrays: %i\n"
"GPU cycles executed: %d (%f per vertex)\n"
"Commands per call level: %i %i %i %i\n"
"Vertices submitted: %i\n"
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i (evaluations: %d)\n"
"Textures active: %i, decoded: %i invalidated: %i\n"
"Readbacks: %d, uploads: %d\n"
"Vertex, Fragment shaders loaded: %i, %i\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawCalls,
gpuStats.numFlushes,
gpuStats.numClears,
gpuStats.numCachedDrawCalls,
gpuStats.numTrackedVertexArrays,
gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles,
vertexAverageCycles,
gpuStats.gpuCommandsAtCallLevel[0], gpuStats.gpuCommandsAtCallLevel[1], gpuStats.gpuCommandsAtCallLevel[2], gpuStats.gpuCommandsAtCallLevel[3],
gpuStats.numVertsSubmitted,
gpuStats.numCachedVertsDrawn,
gpuStats.numUncachedVertsDrawn,
(int)framebufferManagerD3D11_->NumVFBs(),
gpuStats.numFramebufferEvaluations,
(int)textureCacheD3D11_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numReadbacks,
gpuStats.numUploads,
size_t offset = FormatGPUStatsCommon(buffer, bufsize);
buffer += offset;
bufsize -= offset;
if ((int)bufsize < 0)
return;
snprintf(buffer, bufsize,
"Vertex, Fragment shaders loaded: %d, %d\n",
shaderManagerD3D11_->GetNumVertexShaders(),
shaderManagerD3D11_->GetNumFragmentShaders()
);

View File

@ -344,38 +344,13 @@ void GPU_DX9::ExecuteOp(u32 op, u32 diff) {
}
void GPU_DX9::GetStats(char *buffer, size_t bufsize) {
float vertexAverageCycles = gpuStats.numVertsSubmitted > 0 ? (float)gpuStats.vertexGPUCycles / (float)gpuStats.numVertsSubmitted : 0.0f;
snprintf(buffer, bufsize - 1,
"DL processing time: %0.2f ms\n"
"Draw calls: %i, flushes %i, clears %i (cached: %d)\n"
"Num Tracked Vertex Arrays: %i\n"
"GPU cycles executed: %d (%f per vertex)\n"
"Commands per call level: %i %i %i %i\n"
"Vertices submitted: %i\n"
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i (evaluations: %d)\n"
"Textures active: %i, decoded: %i invalidated: %i\n"
"Readbacks: %d, uploads: %d\n"
size_t offset = FormatGPUStatsCommon(buffer, bufsize);
buffer += offset;
bufsize -= offset;
if ((int)bufsize < 0)
return;
snprintf(buffer, bufsize,
"Vertex, Fragment shaders loaded: %i, %i\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawCalls,
gpuStats.numFlushes,
gpuStats.numClears,
gpuStats.numCachedDrawCalls,
gpuStats.numTrackedVertexArrays,
gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles,
vertexAverageCycles,
gpuStats.gpuCommandsAtCallLevel[0], gpuStats.gpuCommandsAtCallLevel[1], gpuStats.gpuCommandsAtCallLevel[2], gpuStats.gpuCommandsAtCallLevel[3],
gpuStats.numVertsSubmitted,
gpuStats.numCachedVertsDrawn,
gpuStats.numUncachedVertsDrawn,
(int)framebufferManagerDX9_->NumVFBs(),
gpuStats.numFramebufferEvaluations,
(int)textureCacheDX9_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numReadbacks,
gpuStats.numUploads,
shaderManagerDX9_->GetNumVertexShaders(),
shaderManagerDX9_->GetNumFragmentShaders()
);

View File

@ -445,41 +445,17 @@ void GPU_GLES::ExecuteOp(u32 op, u32 diff) {
}
void GPU_GLES::GetStats(char *buffer, size_t bufsize) {
float vertexAverageCycles = gpuStats.numVertsSubmitted > 0 ? (float)gpuStats.vertexGPUCycles / (float)gpuStats.numVertsSubmitted : 0.0f;
snprintf(buffer, bufsize - 1,
"DL processing time: %0.2f ms\n"
"Draw calls: %i, flushes %i, clears %i (cached: %d)\n"
"Num Tracked Vertex Arrays: %i\n"
"GPU cycles executed: %d (%f per vertex)\n"
"Commands per call level: %i %i %i %i\n"
"Vertices submitted: %i\n"
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i (evaluations: %d)\n"
"Textures active: %i, decoded: %i invalidated: %i\n"
"Readbacks: %d, uploads: %d\n"
"Vertex, Fragment, Programs loaded: %i, %i, %i\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawCalls,
gpuStats.numFlushes,
gpuStats.numClears,
gpuStats.numCachedDrawCalls,
gpuStats.numTrackedVertexArrays,
gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles,
vertexAverageCycles,
gpuStats.gpuCommandsAtCallLevel[0], gpuStats.gpuCommandsAtCallLevel[1], gpuStats.gpuCommandsAtCallLevel[2], gpuStats.gpuCommandsAtCallLevel[3],
gpuStats.numVertsSubmitted,
gpuStats.numCachedVertsDrawn,
gpuStats.numUncachedVertsDrawn,
(int)framebufferManagerGL_->NumVFBs(),
gpuStats.numFramebufferEvaluations,
(int)textureCacheGL_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numReadbacks,
gpuStats.numUploads,
size_t offset = FormatGPUStatsCommon(buffer, bufsize);
buffer += offset;
bufsize -= offset;
if ((int)bufsize < 0)
return;
snprintf(buffer, bufsize,
"Vertex, Fragment, Programs loaded: %d, %d, %d\n",
shaderManagerGL_->GetNumVertexShaders(),
shaderManagerGL_->GetNumFragmentShaders(),
shaderManagerGL_->GetNumPrograms());
shaderManagerGL_->GetNumPrograms()
);
}
void GPU_GLES::ClearCacheNextFrame() {

View File

@ -55,6 +55,7 @@ struct GPUStatistics {
// Never add a vtable :)
memset(this, 0, sizeof(*this));
}
void ResetFrame() {
numDrawCalls = 0;
numCachedDrawCalls = 0;
@ -64,7 +65,9 @@ struct GPUStatistics {
numTrackedVertexArrays = 0;
numTextureInvalidations = 0;
numTextureInvalidationsByFramebuffer = 0;
numTexturesHashed = 0;
numTextureSwitches = 0;
numTextureDataBytesHashed = 0;
numShaderSwitches = 0;
numFlushes = 0;
numTexturesDecoded = 0;
@ -88,6 +91,8 @@ struct GPUStatistics {
int numTrackedVertexArrays;
int numTextureInvalidations;
int numTextureInvalidationsByFramebuffer;
int numTexturesHashed;
int numTextureDataBytesHashed;
int numTextureSwitches;
int numShaderSwitches;
int numTexturesDecoded;

View File

@ -2876,3 +2876,38 @@ bool GPUCommon::FramebufferReallyDirty() {
}
return true;
}
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\n"
"Draw calls: %i, flushes %i, clears %i (cached: %d)\n"
"Num Tracked Vertex Arrays: %i\n"
"GPU cycles executed: %d (%f per vertex)\n"
"Commands per call level: %i %i %i %i\n"
"Vertices submitted: %i\n"
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i (evaluations: %d)\n"
"Textures active: %i, decoded: %i invalidated: %i\n"
"Readbacks: %d, uploads: %d\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawCalls,
gpuStats.numFlushes,
gpuStats.numClears,
gpuStats.numCachedDrawCalls,
gpuStats.numTrackedVertexArrays,
gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles,
vertexAverageCycles,
gpuStats.gpuCommandsAtCallLevel[0], gpuStats.gpuCommandsAtCallLevel[1], gpuStats.gpuCommandsAtCallLevel[2], gpuStats.gpuCommandsAtCallLevel[3],
gpuStats.numVertsSubmitted,
gpuStats.numCachedVertsDrawn,
gpuStats.numUncachedVertsDrawn,
(int)framebufferManager_->NumVFBs(),
gpuStats.numFramebufferEvaluations,
(int)textureCache_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numReadbacks,
gpuStats.numUploads
);
}

View File

@ -303,6 +303,8 @@ protected:
}
}
size_t FormatGPUStatsCommon(char *buf, size_t size);
FramebufferManagerCommon *framebufferManager_ = nullptr;
TextureCacheCommon *textureCache_ = nullptr;
DrawEngineCommon *drawEngineCommon_ = nullptr;

View File

@ -552,44 +552,18 @@ void GPU_Vulkan::DeviceRestore() {
}
void GPU_Vulkan::GetStats(char *buffer, size_t bufsize) {
size_t offset = FormatGPUStatsCommon(buffer, bufsize);
buffer += offset;
bufsize -= offset;
if ((int)bufsize < 0)
return;
const DrawEngineVulkanStats &drawStats = drawEngine_.GetStats();
char texStats[256];
textureCacheVulkan_->GetStats(texStats, sizeof(texStats));
float vertexAverageCycles = gpuStats.numVertsSubmitted > 0 ? (float)gpuStats.vertexGPUCycles / (float)gpuStats.numVertsSubmitted : 0.0f;
snprintf(buffer, bufsize - 1,
"DL processing time: %0.2f ms\n"
"Draw calls: %i, flushes %i, clears %i (cached: %d)\n"
"Num Tracked Vertex Arrays: %i\n"
"GPU cycles executed: %d (%f per vertex)\n"
"Commands per call level: %i %i %i %i\n"
"Vertices submitted: %i\n"
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i (evaluations: %d)\n"
"Textures active: %i, decoded: %i invalidated: %d (%d by fb)\n"
"Readbacks: %d, uploads: %d\n"
snprintf(buffer, bufsize,
"Vertex, Fragment, Pipelines loaded: %i, %i, %i\n"
"Pushbuffer space used: UBO %d, Vtx %d, Idx %d\n"
"%s\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawCalls,
gpuStats.numFlushes,
gpuStats.numClears,
gpuStats.numCachedDrawCalls,
gpuStats.numTrackedVertexArrays,
gpuStats.vertexGPUCycles + gpuStats.otherGPUCycles,
vertexAverageCycles,
gpuStats.gpuCommandsAtCallLevel[0], gpuStats.gpuCommandsAtCallLevel[1], gpuStats.gpuCommandsAtCallLevel[2], gpuStats.gpuCommandsAtCallLevel[3],
gpuStats.numVertsSubmitted,
gpuStats.numCachedVertsDrawn,
gpuStats.numUncachedVertsDrawn,
(int)framebufferManager_->NumVFBs(),
gpuStats.numFramebufferEvaluations,
(int)textureCacheVulkan_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numTextureInvalidationsByFramebuffer,
gpuStats.numReadbacks,
gpuStats.numUploads,
shaderManagerVulkan_->GetNumVertexShaders(),
shaderManagerVulkan_->GetNumFragmentShaders(),
pipelineManager_->GetNumPipelines(),