From c8e1881ea9c6bdb316a86f48bb3328bb73140bb5 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Tue, 2 Jun 2020 21:45:36 +1000 Subject: [PATCH] GPU/HW: Clear dirty rectangle when updating shadow texture Fixes high GPU usage in Robbit mon Dieu in D3D11, should improve overall performance slightly when VRAM copies are heavily used. --- src/core/gpu_hw.cpp | 8 ++++++-- src/core/gpu_hw.h | 2 +- src/core/gpu_hw_d3d11.cpp | 2 ++ src/core/gpu_hw_opengl.cpp | 2 ++ 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/core/gpu_hw.cpp b/src/core/gpu_hw.cpp index 0104f5607..95d21ce62 100644 --- a/src/core/gpu_hw.cpp +++ b/src/core/gpu_hw.cpp @@ -99,6 +99,12 @@ void GPU_HW::PrintSettingsToLog() Log_InfoPrintf("Dual-source blending: %s", m_supports_dual_source_blend ? "Supported" : "Not supported"); } +void GPU_HW::UpdateVRAMReadTexture() +{ + m_renderer_stats.num_vram_read_texture_updates++; + ClearVRAMDirtyRectangle(); +} + void GPU_HW::HandleFlippedQuadTextureCoordinates(BatchVertex* vertices) { // Taken from beetle-psx gpu_polygon.cpp @@ -661,8 +667,6 @@ void GPU_HW::DispatchRenderCommand() FlushRender(); UpdateVRAMReadTexture(); - m_renderer_stats.num_vram_read_texture_updates++; - ClearVRAMDirtyRectangle(); } } diff --git a/src/core/gpu_hw.h b/src/core/gpu_hw.h index 197364443..db411bd2c 100644 --- a/src/core/gpu_hw.h +++ b/src/core/gpu_hw.h @@ -157,7 +157,7 @@ protected: static_cast(rgba >> 24) * (1.0f / 255.0f)); } - virtual void UpdateVRAMReadTexture() = 0; + virtual void UpdateVRAMReadTexture(); virtual void UpdateDepthBufferFromMaskBit() = 0; virtual void SetScissorFromDrawingArea() = 0; virtual void MapBatchVertexPointer(u32 required_vertices) = 0; diff --git a/src/core/gpu_hw_d3d11.cpp b/src/core/gpu_hw_d3d11.cpp index b5197d2ec..5bc660b17 100644 --- a/src/core/gpu_hw_d3d11.cpp +++ b/src/core/gpu_hw_d3d11.cpp @@ -805,6 +805,8 @@ void GPU_HW_D3D11::UpdateVRAMReadTexture() const CD3D11_BOX src_box(scaled_rect.left, scaled_rect.top, 0, scaled_rect.right, scaled_rect.bottom, 1); m_context->CopySubresourceRegion(m_vram_read_texture, 0, scaled_rect.left, scaled_rect.top, 0, m_vram_texture, 0, &src_box); + + GPU_HW::UpdateVRAMReadTexture(); } void GPU_HW_D3D11::UpdateDepthBufferFromMaskBit() diff --git a/src/core/gpu_hw_opengl.cpp b/src/core/gpu_hw_opengl.cpp index 15d214381..120aebf12 100644 --- a/src/core/gpu_hw_opengl.cpp +++ b/src/core/gpu_hw_opengl.cpp @@ -945,6 +945,8 @@ void GPU_HW_OpenGL::UpdateVRAMReadTexture() glEnable(GL_SCISSOR_TEST); glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_vram_fbo_id); } + + GPU_HW::UpdateVRAMReadTexture(); } void GPU_HW_OpenGL::UpdateDepthBufferFromMaskBit()