summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture_cache/surface_base.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-05-13 02:33:52 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-06-21 02:36:12 +0200
commit7731a0e2d15da04eea746b4b8dd5c6c4b29f9f29 (patch)
tree9769d59ddb0076234d26993ee8aca62e7da58554 /src/video_core/texture_cache/surface_base.cpp
parentsurface_params: Ensure pitch is always written to avoid surface leaks (diff)
downloadyuzu-7731a0e2d15da04eea746b4b8dd5c6c4b29f9f29.tar
yuzu-7731a0e2d15da04eea746b4b8dd5c6c4b29f9f29.tar.gz
yuzu-7731a0e2d15da04eea746b4b8dd5c6c4b29f9f29.tar.bz2
yuzu-7731a0e2d15da04eea746b4b8dd5c6c4b29f9f29.tar.lz
yuzu-7731a0e2d15da04eea746b4b8dd5c6c4b29f9f29.tar.xz
yuzu-7731a0e2d15da04eea746b4b8dd5c6c4b29f9f29.tar.zst
yuzu-7731a0e2d15da04eea746b4b8dd5c6c4b29f9f29.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/texture_cache/surface_base.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/video_core/texture_cache/surface_base.cpp b/src/video_core/texture_cache/surface_base.cpp
index 510d1aef5..ceff51043 100644
--- a/src/video_core/texture_cache/surface_base.cpp
+++ b/src/video_core/texture_cache/surface_base.cpp
@@ -17,6 +17,7 @@ MICROPROFILE_DEFINE(GPU_Flush_Texture, "GPU", "Texture Flush", MP_RGB(128, 192,
using Tegra::Texture::ConvertFromGuestToHost;
using VideoCore::MortonSwizzleMode;
+using VideoCore::Surface::SurfaceCompression;
SurfaceBaseImpl::SurfaceBaseImpl(GPUVAddr gpu_addr, const SurfaceParams& params)
: params{params}, mipmap_sizes(params.num_levels),
@@ -102,9 +103,20 @@ void SurfaceBaseImpl::LoadBuffer(Tegra::MemoryManager& memory_manager,
}
}
- for (u32 level = 0; level < params.num_levels; ++level) {
- const std::size_t host_offset{params.GetHostMipmapLevelOffset(level)};
- ConvertFromGuestToHost(staging_buffer.data() + host_offset, params.pixel_format,
+ auto compression_type = params.GetCompressionType();
+ if (compression_type == SurfaceCompression::None ||
+ compression_type == SurfaceCompression::Compressed)
+ return;
+
+ for (u32 level_up = params.num_levels; level_up > 0; --level_up) {
+ const u32 level = level_up - 1;
+ const std::size_t in_host_offset{params.GetHostMipmapLevelOffset(level)};
+ const std::size_t out_host_offset = compression_type == SurfaceCompression::Rearranged
+ ? in_host_offset
+ : params.GetConvertedMipmapOffset(level);
+ u8* in_buffer = staging_buffer.data() + in_host_offset;
+ u8* out_buffer = staging_buffer.data() + out_host_offset;
+ ConvertFromGuestToHost(in_buffer, out_buffer, params.pixel_format,
params.GetMipWidth(level), params.GetMipHeight(level),
params.GetMipDepth(level), true, true);
}