aboutsummaryrefslogtreecommitdiff
path: root/src/video_core/texture_cache/util.cpp
diff options
context:
space:
mode:
authorweakboson <weakboson@quantum-field.net>2025-08-04 18:39:17 +0200
committercrueter <crueter@eden-emu.dev>2025-08-04 18:39:17 +0200
commit33275c28d34589e0e1cf639a47187d9ce4f9e34f (patch)
treea0d36fe56592f43dab356fe43b91ec9629530f22 /src/video_core/texture_cache/util.cpp
parent51b170b470ed587f99a7c2a773e4464687f0d07a (diff)
[texture_cache] Enforce conservative 3D texture aliasing. Consistently merge/lookup images. (#196)
Previously, the merging strategy is permissive but the lookup strategy is strict. Together they create a infinite merge loop because lookup always fails and merges are always executed. The last attempt to fix this issue made the lookup strategy more permissive which created unexpected aliased textures. This commit implements an alternative: make the merging strategy strict. Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/196 Reviewed-by: Shinmegumi <shinmegumi@eden-emu.dev> Co-authored-by: weakboson <weakboson@quantum-field.net> Co-committed-by: weakboson <weakboson@quantum-field.net>
Diffstat (limited to 'src/video_core/texture_cache/util.cpp')
-rw-r--r--src/video_core/texture_cache/util.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp
index f61a8558d9..e3faa5bf95 100644
--- a/src/video_core/texture_cache/util.cpp
+++ b/src/video_core/texture_cache/util.cpp
@@ -346,7 +346,7 @@ template <u32 GOB_EXTENT>
if (!IsBlockLinearSizeCompatible(new_info, info, base.level, 0, strict_size)) {
return std::nullopt;
}
- const u32 mip_depth = std::max(1U, new_info.size.depth << base.level);
+ const u32 mip_depth = AdjustMipSize(new_info.size.depth, base.level);
if (mip_depth < info.size.depth + base.layer) {
return std::nullopt;
}
@@ -431,8 +431,14 @@ template <u32 GOB_EXTENT>
return std::nullopt;
}
const SubresourceExtent resources = new_info.resources;
- s32 layers = 1;
- if (info.type != ImageType::e3D) {
+ s32 layers;
+ if (info.type == ImageType::e3D) {
+ const u32 mip_depth = AdjustMipSize(info.size.depth, base->level);
+ if (mip_depth < new_info.size.depth + base->layer) {
+ return std::nullopt;
+ }
+ layers = 1;
+ } else {
layers = std::max(resources.layers, info.resources.layers + base->layer);
}
return OverlapResult{
@@ -1219,10 +1225,10 @@ std::optional<SubresourceBase> FindSubresource(const ImageInfo& candidate, const
return std::nullopt;
}
if (existing.type == ImageType::e3D) {
- // const u32 mip_depth = std::max(1U, existing.size.depth << base->level);
- // if (mip_depth < candidate.size.depth + base->layer) {
- // return std::nullopt;
- // }
+ const u32 mip_depth = AdjustMipSize(existing.size.depth, base->level);
+ if (mip_depth < candidate.size.depth + base->layer) {
+ return std::nullopt;
+ }
} else if (existing.resources.layers < candidate.resources.layers + base->layer) {
return std::nullopt;
}
@@ -1250,7 +1256,7 @@ bool IsSubCopy(const ImageInfo& candidate, const ImageBase& image, GPUVAddr cand
return false;
}
if (existing.type == ImageType::e3D) {
- const u32 mip_depth = std::max(1U, existing.size.depth << base->level);
+ const u32 mip_depth = AdjustMipSize(existing.size.depth, base->level);
if (mip_depth < candidate.size.depth + base->layer) {
return false;
}