summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture_cache
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-05-24 17:59:23 +0200
committerReinUsesLisp <reinuseslisp@airmail.cc>2019-06-21 02:38:33 +0200
commit92513541529e90f4f79a1f2c3f8ccf5a199e4c20 (patch)
treed686a78d8af4e41bf6a7c3fc2136e146b98f42e4 /src/video_core/texture_cache
parenttexture_cache: Only load on recycle with accurate GPU. (diff)
downloadyuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.tar
yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.tar.gz
yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.tar.bz2
yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.tar.lz
yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.tar.xz
yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.tar.zst
yuzu-92513541529e90f4f79a1f2c3f8ccf5a199e4c20.zip
Diffstat (limited to 'src/video_core/texture_cache')
-rw-r--r--src/video_core/texture_cache/surface_base.h9
-rw-r--r--src/video_core/texture_cache/surface_params.h20
-rw-r--r--src/video_core/texture_cache/texture_cache.h8
3 files changed, 27 insertions, 10 deletions
diff --git a/src/video_core/texture_cache/surface_base.h b/src/video_core/texture_cache/surface_base.h
index dacbc97c7..77c2d6758 100644
--- a/src/video_core/texture_cache/surface_base.h
+++ b/src/video_core/texture_cache/surface_base.h
@@ -235,9 +235,8 @@ private:
for (u32 layer = 0; layer < layers; layer++) {
for (u32 level = 0; level < mipmaps; level++) {
- const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))};
- const u32 height{
- std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))};
+ const u32 width = SurfaceParams::IntersectWidth(params, in_params, level, level);
+ const u32 height = SurfaceParams::IntersectHeight(params, in_params, level, level);
result.emplace_back(width, height, layer, level);
}
}
@@ -250,8 +249,8 @@ private:
result.reserve(mipmaps);
for (u32 level = 0; level < mipmaps; level++) {
- const u32 width{std::min(params.GetMipWidth(level), in_params.GetMipWidth(level))};
- const u32 height{std::min(params.GetMipHeight(level), in_params.GetMipHeight(level))};
+ const u32 width = SurfaceParams::IntersectWidth(params, in_params, level, level);
+ const u32 height = SurfaceParams::IntersectHeight(params, in_params, level, level);
const u32 depth{std::min(params.GetMipDepth(level), in_params.GetMipDepth(level))};
result.emplace_back(width, height, depth, level);
}
diff --git a/src/video_core/texture_cache/surface_params.h b/src/video_core/texture_cache/surface_params.h
index d9aa0b521..c3affd621 100644
--- a/src/video_core/texture_cache/surface_params.h
+++ b/src/video_core/texture_cache/surface_params.h
@@ -140,6 +140,26 @@ public:
return (height * bh2 + bh1 - 1) / bh1;
}
+ // this finds the maximun possible width between 2 2D layers of different formats
+ static u32 IntersectWidth(const SurfaceParams& src_params, const SurfaceParams& dst_params,
+ const u32 src_level, const u32 dst_level) {
+ const u32 bw1 = src_params.GetDefaultBlockWidth();
+ const u32 bw2 = dst_params.GetDefaultBlockWidth();
+ const u32 t_src_width = (src_params.GetMipWidth(src_level) * bw2 + bw1 - 1) / bw1;
+ const u32 t_dst_width = (dst_params.GetMipWidth(dst_level) * bw1 + bw2 - 1) / bw2;
+ return std::min(t_src_width, t_dst_width);
+ }
+
+ // this finds the maximun possible height between 2 2D layers of different formats
+ static u32 IntersectHeight(const SurfaceParams& src_params, const SurfaceParams& dst_params,
+ const u32 src_level, const u32 dst_level) {
+ const u32 bh1 = src_params.GetDefaultBlockHeight();
+ const u32 bh2 = dst_params.GetDefaultBlockHeight();
+ const u32 t_src_height = (src_params.GetMipHeight(src_level) * bh2 + bh1 - 1) / bh1;
+ const u32 t_dst_height = (dst_params.GetMipHeight(dst_level) * bh1 + bh2 - 1) / bh2;
+ return std::min(t_src_height, t_dst_height);
+ }
+
/// Returns the default block width.
u32 GetDefaultBlockWidth() const {
return VideoCore::Surface::GetDefaultBlockWidth(pixel_format);
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 685bd28f4..d2093e581 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -444,11 +444,9 @@ private:
}
modified |= surface->IsModified();
// Now we got all the data set up
- const u32 dst_width{params.GetMipWidth(mipmap)};
- const u32 dst_height{params.GetMipHeight(mipmap)};
- const CopyParams copy_params(0, 0, 0, 0, 0, layer, 0, mipmap,
- std::min(src_params.width, dst_width),
- std::min(src_params.height, dst_height), 1);
+ const u32 width = SurfaceParams::IntersectWidth(src_params, params, 0, mipmap);
+ const u32 height = SurfaceParams::IntersectHeight(src_params, params, 0, mipmap);
+ const CopyParams copy_params(0, 0, 0, 0, 0, layer, 0, mipmap, width, height, 1);
passed_tests++;
ImageCopy(surface, new_surface, copy_params);
}