diff options
| author | Pierre Bourdon <delroth@gmail.com> | 2018-11-07 09:32:37 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-11-07 09:32:37 +0100 |
| commit | dac58a859ca30262b79f72036f1e78ea54be83c4 (patch) | |
| tree | 9567559377284d746b77b07a14a01518017c99d4 /Source/Core/VideoBackends/Software | |
| parent | 710b893b914bcc1e812f1a63fdb9a143ff682561 (diff) | |
| parent | a45f977d265bb4360ca0b4a7fd189f4a30362f61 (diff) | |
Merge pull request #7539 from stenzek/batched-efb-copies
TextureCache: Deferred/batched EFB copies
Diffstat (limited to 'Source/Core/VideoBackends/Software')
4 files changed, 23 insertions, 11 deletions
diff --git a/Source/Core/VideoBackends/Software/SWTexture.h b/Source/Core/VideoBackends/Software/SWTexture.h index 5c403f54ba..f9d5c50485 100644 --- a/Source/Core/VideoBackends/Software/SWTexture.h +++ b/Source/Core/VideoBackends/Software/SWTexture.h @@ -57,6 +57,8 @@ public: void Unmap() override; void Flush() override; + void SetMapStride(size_t stride) { m_map_stride = stride; } + private: std::vector<u8> m_data; }; diff --git a/Source/Core/VideoBackends/Software/TextureCache.h b/Source/Core/VideoBackends/Software/TextureCache.h index f3d9c91938..06bfbf73fa 100644 --- a/Source/Core/VideoBackends/Software/TextureCache.h +++ b/Source/Core/VideoBackends/Software/TextureCache.h @@ -16,8 +16,8 @@ public: TLUTFormat format) override { } - void CopyEFB(u8* dst, const EFBCopyParams& params, u32 native_width, u32 bytes_per_row, - u32 num_blocks_y, u32 memory_stride, const EFBRectangle& src_rect, + void CopyEFB(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, bool clamp_top, bool clamp_bottom, const CopyFilterCoefficientArray& filter_coefficients) override { 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<SW::SWStagingTexture*>(dst)->SetMapStride(memory_stride); + if (params.copy_format == EFBCopyFormat::XFB) { - EfbInterface::EncodeXFB(dst, native_width, src_rect, y_scale, gamma); + EfbInterface::EncodeXFB(reinterpret_cast<u8*>(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<u8*>(dst->GetMappedPointer()), params, native_width, + bytes_per_row, num_blocks_y, memory_stride, src_rect, scale_by_half); } } } diff --git a/Source/Core/VideoBackends/Software/TextureEncoder.h b/Source/Core/VideoBackends/Software/TextureEncoder.h index 20aa05605a..705fa2e81b 100644 --- a/Source/Core/VideoBackends/Software/TextureEncoder.h +++ b/Source/Core/VideoBackends/Software/TextureEncoder.h @@ -10,7 +10,7 @@ namespace TextureEncoder { -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); } |
