From 7d904fef2e6ac9ce8a3df71e758a36d39b8f69e5 Mon Sep 17 00:00:00 2001 From: ReinUsesLisp Date: Mon, 4 Jan 2021 01:56:44 -0300 Subject: gl_texture_cache: Avoid format views on Intel and AMD Intel and AMD proprietary drivers are incapable of rendering to texture views of different formats than the original texture. Avoid creating these at a cache level. This will consume more memory, emulating them with copies. --- src/video_core/texture_cache/image_base.cpp | 4 +++- src/video_core/texture_cache/image_view_base.cpp | 2 +- src/video_core/texture_cache/texture_cache.h | 15 ++++++++++----- src/video_core/texture_cache/util.cpp | 13 +++++++------ src/video_core/texture_cache/util.h | 8 +++++--- 5 files changed, 26 insertions(+), 16 deletions(-) (limited to 'src/video_core/texture_cache') diff --git a/src/video_core/texture_cache/image_base.cpp b/src/video_core/texture_cache/image_base.cpp index 448a05fcc..959b3f115 100644 --- a/src/video_core/texture_cache/image_base.cpp +++ b/src/video_core/texture_cache/image_base.cpp @@ -120,7 +120,9 @@ void AddImageAlias(ImageBase& lhs, ImageBase& rhs, ImageId lhs_id, ImageId rhs_i if (lhs.info.type == ImageType::Linear) { base = SubresourceBase{.level = 0, .layer = 0}; } else { - base = FindSubresource(rhs.info, lhs, rhs.gpu_addr, OPTIONS); + // We are passing relaxed formats as an option, having broken views or not won't matter + static constexpr bool broken_views = false; + base = FindSubresource(rhs.info, lhs, rhs.gpu_addr, OPTIONS, broken_views); } if (!base) { LOG_ERROR(HW_GPU, "Image alias should have been flipped"); diff --git a/src/video_core/texture_cache/image_view_base.cpp b/src/video_core/texture_cache/image_view_base.cpp index 076a4bcfd..18f72e508 100644 --- a/src/video_core/texture_cache/image_view_base.cpp +++ b/src/video_core/texture_cache/image_view_base.cpp @@ -24,7 +24,7 @@ ImageViewBase::ImageViewBase(const ImageViewInfo& info, const ImageInfo& image_i .height = std::max(image_info.size.height >> range.base.level, 1u), .depth = std::max(image_info.size.depth >> range.base.level, 1u), } { - ASSERT_MSG(VideoCore::Surface::IsViewCompatible(image_info.format, info.format), + ASSERT_MSG(VideoCore::Surface::IsViewCompatible(image_info.format, info.format, false), "Image view format {} is incompatible with image format {}", info.format, image_info.format); const bool is_async = Settings::values.use_asynchronous_gpu_emulation.GetValue(); diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 968059842..ad86c50b4 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -883,6 +883,7 @@ ImageId TextureCache
::FindImage(const ImageInfo& info, GPUVAddr gpu_addr, if (!cpu_addr) { return ImageId{}; } + const bool broken_views = runtime.HasBrokenTextureViewFormats(); ImageId image_id; const auto lambda = [&](ImageId existing_image_id, ImageBase& existing_image) { if (info.type == ImageType::Linear || existing_image.info.type == ImageType::Linear) { @@ -892,11 +893,11 @@ ImageId TextureCache
::FindImage(const ImageInfo& info, GPUVAddr gpu_addr,
if (existing_image.gpu_addr == gpu_addr && existing.type == info.type &&
existing.pitch == info.pitch &&
IsPitchLinearSameSize(existing, info, strict_size) &&
- IsViewCompatible(existing.format, info.format)) {
+ IsViewCompatible(existing.format, info.format, broken_views)) {
image_id = existing_image_id;
return true;
}
- } else if (IsSubresource(info, existing_image, gpu_addr, options)) {
+ } else if (IsSubresource(info, existing_image, gpu_addr, options, broken_views)) {
image_id = existing_image_id;
return true;
}
@@ -926,6 +927,7 @@ template ::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VAddr cpu_addr) {
ImageInfo new_info = info;
const size_t size_bytes = CalculateGuestSizeInBytes(new_info);
+ const bool broken_views = runtime.HasBrokenTextureViewFormats();
std::vector ::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA
}
return;
}
- const auto solution = ResolveOverlap(new_info, gpu_addr, cpu_addr, overlap, true);
+ static constexpr bool strict_size = true;
+ const std::optional ::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA
}
static constexpr auto options = RelaxedOptions::Size | RelaxedOptions::Format;
const ImageBase new_image_base(new_info, gpu_addr, cpu_addr);
- if (IsSubresource(new_info, overlap, gpu_addr, options)) {
+ if (IsSubresource(new_info, overlap, gpu_addr, options, broken_views)) {
left_aliased_ids.push_back(overlap_id);
- } else if (IsSubresource(overlap.info, new_image_base, overlap.gpu_addr, options)) {
+ } else if (IsSubresource(overlap.info, new_image_base, overlap.gpu_addr, options,
+ broken_views)) {
right_aliased_ids.push_back(overlap_id);
}
});
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp
index 9ed1fc007..279932778 100644
--- a/src/video_core/texture_cache/util.cpp
+++ b/src/video_core/texture_cache/util.cpp
@@ -1069,13 +1069,13 @@ bool IsPitchLinearSameSize(const ImageInfo& lhs, const ImageInfo& rhs, bool stri
std::optional