Count readbacks in a frame and show in GPU debug stats.

This commit is contained in:
Henrik Rydgård 2017-11-08 11:57:53 +01:00
parent 4970668b99
commit d618b3673b
10 changed files with 22 additions and 5 deletions

View File

@ -364,9 +364,9 @@ void Core_UpdateState(CoreState newState) {
Core_UpdateSingleStep();
}
static void Core_UpdateDebugStats(bool flag) {
if (coreCollectDebugStats != flag) {
coreCollectDebugStats = flag;
void Core_UpdateDebugStats(bool collectStats) {
if (coreCollectDebugStats != collectStats) {
coreCollectDebugStats = collectStats;
mipsr4k.ClearJitCache();
}
@ -518,8 +518,6 @@ void PSP_EndHostFrame() {
}
void PSP_RunLoopUntil(u64 globalticks) {
Core_UpdateDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops);
SaveState::Process();
if (coreState == CORE_POWERDOWN || coreState == CORE_ERROR) {
return;

View File

@ -73,6 +73,9 @@ void PSP_EndHostFrame();
void PSP_RunLoopUntil(u64 globalticks);
void PSP_RunLoopFor(int cycles);
// Call before PSP_BeginHostFrame() in order to not miss any GPU stats.
void Core_UpdateDebugStats(bool collectStats);
void Audio_Init();
bool IsOnSeparateCPUThread();

View File

@ -1929,6 +1929,7 @@ bool FramebufferManagerCommon::GetFramebuffer(u32 fb_address, int fb_stride, GEB
bool flipY = (g_Config.iGPUBackend == GPU_BACKEND_OPENGL && !useBufferedRendering_) ? true : false;
buffer.Allocate(w, h, GE_FORMAT_8888, flipY, true);
bool retval = draw_->CopyFramebufferToMemorySync(bound, Draw::FB_COLOR_BIT, 0, 0, w, h, Draw::DataFormat::R8G8B8A8_UNORM, buffer.GetData(), w);
gpuStats.numReadbacks++;
// Vulkan requires us to re-apply all dynamic state for each command buffer, and the above will cause us to start a new cmdbuf.
// So let's dirty the things that are involved in Vulkan dynamic state. Readbacks are not frequent so this won't hurt other backends.
gstate_c.Dirty(DIRTY_VIEWPORTSCISSOR_STATE | DIRTY_BLEND_STATE | DIRTY_DEPTHSTENCIL_STATE);
@ -2031,6 +2032,7 @@ void FramebufferManagerCommon::PackFramebufferSync_(VirtualFramebuffer *vfb, int
DEBUG_LOG(G3D, "Reading framebuffer to mem, fb_address = %08x", fb_address);
draw_->CopyFramebufferToMemorySync(vfb->fbo, Draw::FB_COLOR_BIT, x, y, w, h, destFormat, destPtr, vfb->fb_stride);
gpuStats.numReadbacks++;
}
void FramebufferManagerCommon::ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) {

View File

@ -713,6 +713,7 @@ void GPU_D3D11::GetStats(char *buffer, size_t bufsize) {
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i\n"
"Textures active: %i, decoded: %i invalidated: %i\n"
"Readbacks: %d\n"
"Vertex, Fragment shaders loaded: %i, %i\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawCalls,
@ -729,6 +730,7 @@ void GPU_D3D11::GetStats(char *buffer, size_t bufsize) {
(int)textureCacheD3D11_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numReadbacks,
shaderManagerD3D11_->GetNumVertexShaders(),
shaderManagerD3D11_->GetNumFragmentShaders()
);

View File

@ -645,6 +645,7 @@ void GPU_DX9::GetStats(char *buffer, size_t bufsize) {
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i\n"
"Textures active: %i, decoded: %i invalidated: %i\n"
"Readbacks: %d\n"
"Vertex, Fragment shaders loaded: %i, %i\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawCalls,
@ -661,6 +662,7 @@ void GPU_DX9::GetStats(char *buffer, size_t bufsize) {
(int)textureCacheDX9_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numReadbacks,
shaderManagerDX9_->GetNumVertexShaders(),
shaderManagerDX9_->GetNumFragmentShaders()
);

View File

@ -884,6 +884,7 @@ void GPU_GLES::GetStats(char *buffer, size_t bufsize) {
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i\n"
"Textures active: %i, decoded: %i invalidated: %i\n"
"Readbacks: %d\n"
"Vertex, Fragment, Programs loaded: %i, %i, %i\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
gpuStats.numDrawCalls,
@ -900,6 +901,7 @@ void GPU_GLES::GetStats(char *buffer, size_t bufsize) {
(int)textureCacheGL_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numReadbacks,
shaderManagerGL_->GetNumVertexShaders(),
shaderManagerGL_->GetNumFragmentShaders(),
shaderManagerGL_->GetNumPrograms());

View File

@ -67,6 +67,7 @@ struct GPUStatistics {
numShaderSwitches = 0;
numFlushes = 0;
numTexturesDecoded = 0;
numReadbacks = 0;
msProcessingDisplayLists = 0;
vertexGPUCycles = 0;
otherGPUCycles = 0;
@ -85,6 +86,7 @@ struct GPUStatistics {
int numTextureSwitches;
int numShaderSwitches;
int numTexturesDecoded;
int numReadbacks;
double msProcessingDisplayLists;
int vertexGPUCycles;
int otherGPUCycles;

View File

@ -833,6 +833,7 @@ void GPU_Vulkan::GetStats(char *buffer, size_t bufsize) {
"Cached, Uncached Vertices Drawn: %i, %i\n"
"FBOs active: %i\n"
"Textures active: %i, decoded: %i invalidated: %i\n"
"Readbacks: %d\n"
"Vertex, Fragment, Pipelines loaded: %i, %i, %i\n"
"Pushbuffer space used: UBO %d, Vtx %d, Idx %d\n",
gpuStats.msProcessingDisplayLists * 1000.0f,
@ -850,6 +851,7 @@ void GPU_Vulkan::GetStats(char *buffer, size_t bufsize) {
(int)textureCacheVulkan_->NumLoadedTextures(),
gpuStats.numTexturesDecoded,
gpuStats.numTextureInvalidations,
gpuStats.numReadbacks,
shaderManagerVulkan_->GetNumVertexShaders(),
shaderManagerVulkan_->GetNumFragmentShaders(),
pipelineManager_->GetNumPipelines(),

View File

@ -1012,6 +1012,8 @@ void EmuScreen::render() {
}
}
Core_UpdateDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops);
PSP_BeginHostFrame();
// We just run the CPU until we get to vblank. This will quickly sync up pretty nicely.

View File

@ -158,6 +158,8 @@ bool RunAutoTest(HeadlessHost *headlessHost, CoreParameter &coreParameter, bool
static double deadline;
deadline = time_now() + timeout;
Core_UpdateDebugStats(g_Config.bShowDebugStats || g_Config.bLogFrameDrops);
PSP_BeginHostFrame();
coreState = CORE_RUNNING;