From 4faac3a6270c288dad57a59ee0f821512846ebfb Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 3 May 2018 14:09:32 +1000 Subject: TextureConversionShader: Don't sample from adjacent rows when not needed --- Source/Core/VideoCommon/TextureCacheBase.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'Source/Core/VideoCommon/TextureCacheBase.cpp') diff --git a/Source/Core/VideoCommon/TextureCacheBase.cpp b/Source/Core/VideoCommon/TextureCacheBase.cpp index f0b1392531..0a04a93168 100644 --- a/Source/Core/VideoCommon/TextureCacheBase.cpp +++ b/Source/Core/VideoCommon/TextureCacheBase.cpp @@ -1499,8 +1499,8 @@ void TextureCacheBase::LoadTextureLevelZeroFromMemory(TCacheEntry* entry_to_upda } } -TextureCacheBase::CopyFilterCoefficientArray -TextureCacheBase::GetRAMCopyFilterCoefficients(const CopyFilterCoefficients::Values& coefficients) +TextureCacheBase::CopyFilterCoefficientArray TextureCacheBase::GetRAMCopyFilterCoefficients( + const CopyFilterCoefficients::Values& coefficients) const { // To simplify the backend, we precalculate the three coefficients in common. Coefficients 0, 1 // are for the row above, 2, 3, 4 are for the current pixel, and 5, 6 are for the row below. @@ -1510,8 +1510,8 @@ TextureCacheBase::GetRAMCopyFilterCoefficients(const CopyFilterCoefficients::Val static_cast(coefficients[5]) + static_cast(coefficients[6])}; } -TextureCacheBase::CopyFilterCoefficientArray -TextureCacheBase::GetVRAMCopyFilterCoefficients(const CopyFilterCoefficients::Values& coefficients) +TextureCacheBase::CopyFilterCoefficientArray TextureCacheBase::GetVRAMCopyFilterCoefficients( + const CopyFilterCoefficients::Values& coefficients) const { // If the user disables the copy filter, only apply it to the VRAM copy. // This way games which are sensitive to changes to the RAM copy of the XFB will be unaffected. @@ -1528,6 +1528,12 @@ TextureCacheBase::GetVRAMCopyFilterCoefficients(const CopyFilterCoefficients::Va return res; } +bool TextureCacheBase::NeedsCopyFilterInShader(const CopyFilterCoefficientArray& coefficients) const +{ + // If the top/bottom coefficients are zero, no point sampling/blending from these rows. + return coefficients[0] != 0 || coefficients[2] != 0; +} + void TextureCacheBase::CopyRenderTargetToTexture( u32 dstAddr, EFBCopyFormat dstFormat, u32 width, u32 height, u32 dstStride, bool is_depth_copy, const EFBRectangle& srcRect, bool isIntensity, bool scaleByHalf, float y_scale, float gamma, @@ -1650,11 +1656,12 @@ void TextureCacheBase::CopyRenderTargetToTexture( if (copy_to_ram) { + CopyFilterCoefficientArray coefficients = GetRAMCopyFilterCoefficients(filter_coefficients); PEControl::PixelFormat srcFormat = bpmem.zcontrol.pixel_format; - EFBCopyParams format(srcFormat, dstFormat, is_depth_copy, isIntensity); + EFBCopyParams format(srcFormat, dstFormat, is_depth_copy, isIntensity, + NeedsCopyFilterInShader(coefficients)); CopyEFB(dst, format, tex_w, bytes_per_row, num_blocks_y, dstStride, srcRect, scaleByHalf, - y_scale, gamma, clamp_top, clamp_bottom, - GetRAMCopyFilterCoefficients(filter_coefficients)); + y_scale, gamma, clamp_top, clamp_bottom, coefficients); } else { -- cgit v1.2.3