From 8e2c063d6219b01037d1cb5bdb009000e52d8479 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sat, 3 Nov 2018 00:17:00 +1000 Subject: TextureCache: Implement deferred/batched EFB copies --- .../Core/VideoBackends/Software/TextureEncoder.cpp | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'Source/Core/VideoBackends/Software/TextureEncoder.cpp') diff --git a/Source/Core/VideoBackends/Software/TextureEncoder.cpp b/Source/Core/VideoBackends/Software/TextureEncoder.cpp index a31888e544..07eba31530 100644 --- a/Source/Core/VideoBackends/Software/TextureEncoder.cpp +++ b/Source/Core/VideoBackends/Software/TextureEncoder.cpp @@ -5,12 +5,14 @@ #include "VideoBackends/Software/TextureEncoder.h" #include "Common/Align.h" +#include "Common/Assert.h" #include "Common/CommonFuncs.h" #include "Common/CommonTypes.h" #include "Common/MsgHandler.h" #include "Common/Swap.h" #include "VideoBackends/Software/EfbInterface.h" +#include "VideoBackends/Software/SWTexture.h" #include "VideoCommon/BPMemory.h" #include "VideoCommon/LookUpTables.h" @@ -1468,18 +1470,26 @@ void EncodeEfbCopy(u8* dst, const EFBCopyParams& params, u32 native_width, u32 b } } -void Encode(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, - u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, bool scale_by_half, - float y_scale, float gamma) +void Encode(AbstractStagingTexture* dst, const EFBCopyParams& params, u32 native_width, + u32 bytes_per_row, u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, + bool scale_by_half, float y_scale, float gamma) { + // HACK: Override the memory stride for this staging texture with new copy stride. + // This is required because the texture encoder assumes that we're writing directly to memory, + // and each row is tightly packed with no padding, whereas our encoding abstract texture has + // a width of 2560. When we copy the texture back later on, it'll use the tightly packed stride. + ASSERT(memory_stride <= (dst->GetConfig().width * dst->GetTexelSize())); + static_cast(dst)->SetMapStride(memory_stride); + if (params.copy_format == EFBCopyFormat::XFB) { - EfbInterface::EncodeXFB(dst, native_width, src_rect, y_scale, gamma); + EfbInterface::EncodeXFB(reinterpret_cast(dst->GetMappedPointer()), native_width, src_rect, + y_scale, gamma); } else { - EncodeEfbCopy(dst, params, native_width, bytes_per_row, num_blocks_y, memory_stride, src_rect, - scale_by_half); + EncodeEfbCopy(reinterpret_cast(dst->GetMappedPointer()), params, native_width, + bytes_per_row, num_blocks_y, memory_stride, src_rect, scale_by_half); } } } -- cgit v1.2.3