From 7b2236778b0f54c4ece821b6ab2bf52a5b647223 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 5 Nov 2020 14:38:20 +0100 Subject: [PATCH] Remove remnants of an old, no longer applicable readback optimization --- Common/GPU/OpenGL/GLQueueRunner.cpp | 1 - GPU/Common/FramebufferManagerCommon.cpp | 40 ++++--------------------- GPU/Common/FramebufferManagerCommon.h | 2 -- GPU/D3D11/FramebufferManagerD3D11.cpp | 4 --- GPU/D3D11/FramebufferManagerD3D11.h | 2 -- GPU/D3D11/GPU_D3D11.cpp | 1 - GPU/Directx9/FramebufferManagerDX9.cpp | 4 --- GPU/Directx9/FramebufferManagerDX9.h | 2 -- GPU/Directx9/GPU_DX9.cpp | 1 - GPU/GLES/FramebufferManagerGLES.cpp | 12 -------- GPU/GLES/FramebufferManagerGLES.h | 2 -- GPU/GLES/GPU_GLES.cpp | 15 ---------- GPU/GPUState.h | 2 +- GPU/Vulkan/FramebufferManagerVulkan.cpp | 4 --- GPU/Vulkan/FramebufferManagerVulkan.h | 1 - GPU/Vulkan/GPU_Vulkan.cpp | 1 - 16 files changed, 7 insertions(+), 87 deletions(-) diff --git a/Common/GPU/OpenGL/GLQueueRunner.cpp b/Common/GPU/OpenGL/GLQueueRunner.cpp index e53721bb1b..b2914e7de0 100644 --- a/Common/GPU/OpenGL/GLQueueRunner.cpp +++ b/Common/GPU/OpenGL/GLQueueRunner.cpp @@ -1434,7 +1434,6 @@ void GLQueueRunner::PerformReadback(const GLRStep &pass) { if (convert && tempBuffer_ && readbackBuffer_) { ConvertFromRGBA8888(readbackBuffer_, tempBuffer_, pixelStride, pixelStride, rect.w, rect.h, pass.readback.dstFormat); } - CHECK_GL_ERROR_IF_DEBUG(); } diff --git a/GPU/Common/FramebufferManagerCommon.cpp b/GPU/Common/FramebufferManagerCommon.cpp index 5e5bded88d..a9c1b75ded 100644 --- a/GPU/Common/FramebufferManagerCommon.cpp +++ b/GPU/Common/FramebufferManagerCommon.cpp @@ -1431,14 +1431,16 @@ VirtualFramebuffer *FramebufferManagerCommon::FindDownloadTempBuffer(VirtualFram nvfb->drawnFormat = vfb->format; nvfb->colorDepth = vfb->colorDepth; - if (!CreateDownloadTempBuffer(nvfb)) { + char name[64]; + snprintf(name, sizeof(name), "download_temp"); + nvfb->fbo = draw_->CreateFramebuffer({ nvfb->bufferWidth, nvfb->bufferHeight, 1, 1, false, (Draw::FBColorDepth)nvfb->colorDepth, name }); + if (!nvfb->fbo) { delete nvfb; - return nullptr; + ERROR_LOG(FRAMEBUF, "Error creating download temp FBO! %d x %d", nvfb->renderWidth, nvfb->renderHeight); + return false; } bvfbs_.push_back(nvfb); - } else { - UpdateDownloadTempBuffer(nvfb); } nvfb->usageFlags |= FB_USAGE_RENDERTARGET; @@ -1448,36 +1450,6 @@ VirtualFramebuffer *FramebufferManagerCommon::FindDownloadTempBuffer(VirtualFram return nvfb; } -bool FramebufferManagerCommon::CreateDownloadTempBuffer(VirtualFramebuffer *nvfb) { - // When updating VRAM, it need to be exact format. - if (!gstate_c.Supports(GPU_PREFER_CPU_DOWNLOAD)) { - switch (nvfb->format) { - case GE_FORMAT_4444: - nvfb->colorDepth = Draw::FBO_4444; - break; - case GE_FORMAT_5551: - nvfb->colorDepth = Draw::FBO_5551; - break; - case GE_FORMAT_565: - nvfb->colorDepth = Draw::FBO_565; - break; - case GE_FORMAT_8888: - default: - nvfb->colorDepth = Draw::FBO_8888; - break; - } - } - - char name[64]; - snprintf(name, sizeof(name), "download_temp"); - nvfb->fbo = draw_->CreateFramebuffer({ nvfb->bufferWidth, nvfb->bufferHeight, 1, 1, false, (Draw::FBColorDepth)nvfb->colorDepth, name }); - if (!nvfb->fbo) { - ERROR_LOG(FRAMEBUF, "Error creating FBO! %d x %d", nvfb->renderWidth, nvfb->renderHeight); - return false; - } - return true; -} - void FramebufferManagerCommon::ApplyClearToMemory(int x1, int y1, int x2, int y2, u32 clearColor) { if (currentRenderVfb_) { if ((currentRenderVfb_->usageFlags & FB_USAGE_DOWNLOAD_CLEAR) != 0) { diff --git a/GPU/Common/FramebufferManagerCommon.h b/GPU/Common/FramebufferManagerCommon.h index acdab123ab..9bd22ff92a 100644 --- a/GPU/Common/FramebufferManagerCommon.h +++ b/GPU/Common/FramebufferManagerCommon.h @@ -349,8 +349,6 @@ protected: void DownloadFramebufferOnSwitch(VirtualFramebuffer *vfb); void FindTransferFramebuffers(VirtualFramebuffer *&dstBuffer, VirtualFramebuffer *&srcBuffer, u32 dstBasePtr, int dstStride, int &dstX, int &dstY, u32 srcBasePtr, int srcStride, int &srcX, int &srcY, int &srcWidth, int &srcHeight, int &dstWidth, int &dstHeight, int bpp); VirtualFramebuffer *FindDownloadTempBuffer(VirtualFramebuffer *vfb); - virtual bool CreateDownloadTempBuffer(VirtualFramebuffer *nvfb); - virtual void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) = 0; VirtualFramebuffer *CreateRAMFramebuffer(uint32_t fbAddress, int width, int height, int stride, GEBufferFormat format); diff --git a/GPU/D3D11/FramebufferManagerD3D11.cpp b/GPU/D3D11/FramebufferManagerD3D11.cpp index 92734d5be6..900ac2892e 100644 --- a/GPU/D3D11/FramebufferManagerD3D11.cpp +++ b/GPU/D3D11/FramebufferManagerD3D11.cpp @@ -353,10 +353,6 @@ void FramebufferManagerD3D11::BindFramebufferAsColorTexture(int stage, VirtualFr } } -void FramebufferManagerD3D11::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) { - // Nothing to do here. -} - void FramebufferManagerD3D11::SimpleBlit( Draw::Framebuffer *dest, float destX1, float destY1, float destX2, float destY2, Draw::Framebuffer *src, float srcX1, float srcY1, float srcX2, float srcY2, bool linearFilter) { diff --git a/GPU/D3D11/FramebufferManagerD3D11.h b/GPU/D3D11/FramebufferManagerD3D11.h index a8a4089198..6c88dd5855 100644 --- a/GPU/D3D11/FramebufferManagerD3D11.h +++ b/GPU/D3D11/FramebufferManagerD3D11.h @@ -58,8 +58,6 @@ protected: // Used by ReadFramebufferToMemory and later framebuffer block copies void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override; - void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; - private: void Bind2DShader() override; void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h); diff --git a/GPU/D3D11/GPU_D3D11.cpp b/GPU/D3D11/GPU_D3D11.cpp index a8f7b95fa6..63940fab8d 100644 --- a/GPU/D3D11/GPU_D3D11.cpp +++ b/GPU/D3D11/GPU_D3D11.cpp @@ -129,7 +129,6 @@ void GPU_D3D11::CheckGPUFeatures() { features |= GPU_SUPPORTS_VS_RANGE_CULLING; } features |= GPU_SUPPORTS_BLEND_MINMAX; - features |= GPU_PREFER_CPU_DOWNLOAD; // Accurate depth is required because the Direct3D API does not support inverse Z. // So we cannot incorrectly use the viewport transform as the depth range on Direct3D. diff --git a/GPU/Directx9/FramebufferManagerDX9.cpp b/GPU/Directx9/FramebufferManagerDX9.cpp index be182d77f1..a6f73c53b5 100644 --- a/GPU/Directx9/FramebufferManagerDX9.cpp +++ b/GPU/Directx9/FramebufferManagerDX9.cpp @@ -371,10 +371,6 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = { } } - void FramebufferManagerDX9::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) { - // Nothing to do here. - } - void FramebufferManagerDX9::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) { if (!dst->fbo || !src->fbo || !useBufferedRendering_) { // This can happen if we recently switched from non-buffered. diff --git a/GPU/Directx9/FramebufferManagerDX9.h b/GPU/Directx9/FramebufferManagerDX9.h index 3a8578599a..6884002eb3 100644 --- a/GPU/Directx9/FramebufferManagerDX9.h +++ b/GPU/Directx9/FramebufferManagerDX9.h @@ -69,8 +69,6 @@ protected: // Used by ReadFramebufferToMemory and later framebuffer block copies void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override; - void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; - private: void PackFramebufferSync_(VirtualFramebuffer *vfb, int x, int y, int w, int h) override; void PackDepthbuffer(VirtualFramebuffer *vfb, int x, int y, int w, int h); diff --git a/GPU/Directx9/GPU_DX9.cpp b/GPU/Directx9/GPU_DX9.cpp index 439b443cd7..b2f2b5aa11 100644 --- a/GPU/Directx9/GPU_DX9.cpp +++ b/GPU/Directx9/GPU_DX9.cpp @@ -164,7 +164,6 @@ void GPU_DX9::CheckGPUFeatures() { features |= GPU_SUPPORTS_16BIT_FORMATS; features |= GPU_SUPPORTS_BLEND_MINMAX; features |= GPU_SUPPORTS_TEXTURE_LOD_CONTROL; - features |= GPU_PREFER_CPU_DOWNLOAD; // Accurate depth is required because the Direct3D API does not support inverse Z. // So we cannot incorrectly use the viewport transform as the depth range on Direct3D. diff --git a/GPU/GLES/FramebufferManagerGLES.cpp b/GPU/GLES/FramebufferManagerGLES.cpp index 5ba89b5c4e..a7280d0d8c 100644 --- a/GPU/GLES/FramebufferManagerGLES.cpp +++ b/GPU/GLES/FramebufferManagerGLES.cpp @@ -293,18 +293,6 @@ void FramebufferManagerGLES::BindFramebufferAsColorTexture(int stage, VirtualFra } } -void FramebufferManagerGLES::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) { - _assert_msg_(nvfb->fbo, "Expecting a valid nvfb in UpdateDownloadTempBuffer"); - - // Discard the previous contents of this buffer where possible. - if (gl_extensions.GLES3) { - draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE, Draw::RPAction::DONT_CARE }, "UpdateDownloadTempBuffer"); - } else if (gl_extensions.IsGLES) { - draw_->BindFramebufferAsRenderTarget(nvfb->fbo, { Draw::RPAction::CLEAR, Draw::RPAction::CLEAR, Draw::RPAction::CLEAR }, "UpdateDownloadTempBuffer"); - gstate_c.Dirty(DIRTY_BLEND_STATE); - } -} - void FramebufferManagerGLES::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) { if (!dst->fbo || !src->fbo || !useBufferedRendering_) { // This can happen if they recently switched from non-buffered. diff --git a/GPU/GLES/FramebufferManagerGLES.h b/GPU/GLES/FramebufferManagerGLES.h index 51d44af73c..590d2b22fa 100644 --- a/GPU/GLES/FramebufferManagerGLES.h +++ b/GPU/GLES/FramebufferManagerGLES.h @@ -62,8 +62,6 @@ protected: // Used by ReadFramebufferToMemory and later framebuffer block copies void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override; - void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; - private: void CreateDeviceObjects(); void DestroyDeviceObjects(); diff --git a/GPU/GLES/GPU_GLES.cpp b/GPU/GLES/GPU_GLES.cpp index 86fd6d8acf..fb18350c1e 100644 --- a/GPU/GLES/GPU_GLES.cpp +++ b/GPU/GLES/GPU_GLES.cpp @@ -189,21 +189,6 @@ void GPU_GLES::CheckGPUFeatures() { features |= GPU_SUPPORTS_VAO; } - bool useCPU = false; - if (!gl_extensions.IsGLES) { - // Some cards or drivers seem to always dither when downloading a framebuffer to 16-bit. - // This causes glitches in games that expect the exact values. - // It has not been experienced on NVIDIA cards, so those are left using the GPU (which is faster.) - if (gl_extensions.gpuVendor != GPU_VENDOR_NVIDIA || !gl_extensions.VersionGEThan(3, 0)) { - useCPU = true; - } - } else { - useCPU = true; - } - - if (useCPU) - features |= GPU_PREFER_CPU_DOWNLOAD; - if ((gl_extensions.gpuVendor == GPU_VENDOR_NVIDIA) || (gl_extensions.gpuVendor == GPU_VENDOR_AMD)) features |= GPU_PREFER_REVERSE_COLOR_ORDER; diff --git a/GPU/GPUState.h b/GPU/GPUState.h index b23b6fd1fb..0deaa9e8f0 100644 --- a/GPU/GPUState.h +++ b/GPU/GPUState.h @@ -493,7 +493,7 @@ enum { GPU_SUPPORTS_FRAMEBUFFER_BLIT_TO_DEPTH = FLAG_BIT(27), GPU_SUPPORTS_OES_TEXTURE_NPOT = FLAG_BIT(28), GPU_NEEDS_Z_EQUAL_W_HACK = FLAG_BIT(29), - GPU_PREFER_CPU_DOWNLOAD = FLAG_BIT(30), + // Free bit: 30 GPU_PREFER_REVERSE_COLOR_ORDER = FLAG_BIT(31), }; diff --git a/GPU/Vulkan/FramebufferManagerVulkan.cpp b/GPU/Vulkan/FramebufferManagerVulkan.cpp index 31ba520907..b3c92ecb5f 100644 --- a/GPU/Vulkan/FramebufferManagerVulkan.cpp +++ b/GPU/Vulkan/FramebufferManagerVulkan.cpp @@ -305,10 +305,6 @@ VkImageView FramebufferManagerVulkan::BindFramebufferAsColorTexture(int stage, V } } -void FramebufferManagerVulkan::UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) { - // Nothing to do here. -} - void FramebufferManagerVulkan::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) { if (!dst->fbo || !src->fbo || !useBufferedRendering_) { // This can happen if they recently switched from non-buffered. diff --git a/GPU/Vulkan/FramebufferManagerVulkan.h b/GPU/Vulkan/FramebufferManagerVulkan.h index a653aeb15d..47b4255efc 100644 --- a/GPU/Vulkan/FramebufferManagerVulkan.h +++ b/GPU/Vulkan/FramebufferManagerVulkan.h @@ -67,7 +67,6 @@ protected: // Used by ReadFramebufferToMemory and later framebuffer block copies void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) override; - void UpdateDownloadTempBuffer(VirtualFramebuffer *nvfb) override; private: void InitDeviceObjects(); diff --git a/GPU/Vulkan/GPU_Vulkan.cpp b/GPU/Vulkan/GPU_Vulkan.cpp index caa979b8b8..0f06c1a970 100644 --- a/GPU/Vulkan/GPU_Vulkan.cpp +++ b/GPU/Vulkan/GPU_Vulkan.cpp @@ -231,7 +231,6 @@ void GPU_Vulkan::CheckGPUFeatures() { features |= GPU_SUPPORTS_INSTANCE_RENDERING; features |= GPU_SUPPORTS_VERTEX_TEXTURE_FETCH; features |= GPU_SUPPORTS_TEXTURE_FLOAT; - features |= GPU_PREFER_CPU_DOWNLOAD; if (vulkan_->GetDeviceInfo().canBlitToPreferredDepthStencilFormat) { features |= GPU_SUPPORTS_FRAMEBUFFER_BLIT_TO_DEPTH;