summaryrefslogtreecommitdiffstats
path: root/src/video_core/texture_cache
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2021-11-21 01:51:13 +0100
committerGitHub <noreply@github.com>2021-11-21 01:51:13 +0100
commitea6fa044f3e55de3b542c6c1b7ca581cbf76d77e (patch)
tree3eb75c6d43296f2a4cbb41099b4f4e787918b1a1 /src/video_core/texture_cache
parentMerge pull request #7294 from vonchenplus/fix_image_update_error_when_width_too_small (diff)
parentTextureCache: Refactor and fix linux compiling. (diff)
downloadyuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar
yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.gz
yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.bz2
yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.lz
yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.xz
yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.tar.zst
yuzu-ea6fa044f3e55de3b542c6c1b7ca581cbf76d77e.zip
Diffstat (limited to 'src/video_core/texture_cache')
-rw-r--r--src/video_core/texture_cache/texture_cache.h19
-rw-r--r--src/video_core/texture_cache/texture_cache_base.h2
-rw-r--r--src/video_core/texture_cache/types.h1
-rw-r--r--src/video_core/texture_cache/util.cpp29
4 files changed, 37 insertions, 14 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h
index 241f71a91..44a0d42ba 100644
--- a/src/video_core/texture_cache/texture_cache.h
+++ b/src/video_core/texture_cache/texture_cache.h
@@ -475,6 +475,7 @@ void TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst,
const BlitImages images = GetBlitImages(dst, src);
const ImageId dst_id = images.dst_id;
const ImageId src_id = images.src_id;
+
PrepareImage(src_id, false, false);
PrepareImage(dst_id, true, false);
@@ -758,7 +759,8 @@ ImageId TextureCache<P>::FindImage(const ImageInfo& info, GPUVAddr gpu_addr,
return ImageId{};
}
}
- const bool broken_views = runtime.HasBrokenTextureViewFormats();
+ const bool broken_views =
+ runtime.HasBrokenTextureViewFormats() || True(options & RelaxedOptions::ForceBrokenViews);
const bool native_bgr = runtime.HasNativeBgr();
ImageId image_id;
const auto lambda = [&](ImageId existing_image_id, ImageBase& existing_image) {
@@ -1094,12 +1096,13 @@ typename TextureCache<P>::BlitImages TextureCache<P>::GetBlitImages(
if (GetFormatType(dst_info.format) != GetFormatType(src_info.format)) {
continue;
}
- if (!dst_id) {
- dst_id = InsertImage(dst_info, dst_addr, RelaxedOptions{});
- }
- if (!src_id) {
- src_id = InsertImage(src_info, src_addr, RelaxedOptions{});
+ RelaxedOptions find_options{};
+ if (src_info.num_samples > 1) {
+ // it's a resolve, we must enforce the same format.
+ find_options = RelaxedOptions::ForceBrokenViews;
}
+ src_id = FindOrInsertImage(src_info, src_addr, find_options);
+ dst_id = FindOrInsertImage(dst_info, dst_addr, find_options);
} while (has_deleted_images);
return BlitImages{
.dst_id = dst_id,
@@ -1759,8 +1762,8 @@ void TextureCache<P>::CopyImage(ImageId dst_id, ImageId src_id, std::vector<Imag
}
UNIMPLEMENTED_IF(dst.info.type != ImageType::e2D);
UNIMPLEMENTED_IF(src.info.type != ImageType::e2D);
- if constexpr (HAS_PIXEL_FORMAT_CONVERSIONS) {
- return runtime.ConvertImage(dst, src, copies);
+ if (runtime.ShouldReinterpret(dst, src)) {
+ return runtime.ReinterpretImage(dst, src, copies);
}
for (const ImageCopy& copy : copies) {
UNIMPLEMENTED_IF(copy.dst_subresource.num_layers != 1);
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h
index a9504c0e8..643ad811c 100644
--- a/src/video_core/texture_cache/texture_cache_base.h
+++ b/src/video_core/texture_cache/texture_cache_base.h
@@ -59,8 +59,6 @@ class TextureCache {
static constexpr bool HAS_EMULATED_COPIES = P::HAS_EMULATED_COPIES;
/// True when the API can provide info about the memory of the device.
static constexpr bool HAS_DEVICE_MEMORY_INFO = P::HAS_DEVICE_MEMORY_INFO;
- /// True when the API provides utilities for pixel format conversions.
- static constexpr bool HAS_PIXEL_FORMAT_CONVERSIONS = P::HAS_PIXEL_FORMAT_CONVERSIONS;
static constexpr u64 DEFAULT_EXPECTED_MEMORY = 1_GiB;
static constexpr u64 DEFAULT_CRITICAL_MEMORY = 2_GiB;
diff --git a/src/video_core/texture_cache/types.h b/src/video_core/texture_cache/types.h
index 5c274abdf..5ac27b3a7 100644
--- a/src/video_core/texture_cache/types.h
+++ b/src/video_core/texture_cache/types.h
@@ -54,6 +54,7 @@ enum class RelaxedOptions : u32 {
Size = 1 << 0,
Format = 1 << 1,
Samples = 1 << 2,
+ ForceBrokenViews = 1 << 3,
};
DECLARE_ENUM_FLAG_OPERATORS(RelaxedOptions)
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp
index ddc9fb13a..e4d82631e 100644
--- a/src/video_core/texture_cache/util.cpp
+++ b/src/video_core/texture_cache/util.cpp
@@ -1151,18 +1151,39 @@ bool IsSubresource(const ImageInfo& candidate, const ImageBase& image, GPUVAddr
void DeduceBlitImages(ImageInfo& dst_info, ImageInfo& src_info, const ImageBase* dst,
const ImageBase* src) {
- if (src && GetFormatType(src->info.format) != SurfaceType::ColorTexture) {
- src_info.format = src->info.format;
+ bool is_resolve = false;
+ const auto original_src_format = src_info.format;
+ const auto original_dst_format = dst_info.format;
+ if (src) {
+ if (GetFormatType(src->info.format) != SurfaceType::ColorTexture) {
+ src_info.format = src->info.format;
+ }
+ is_resolve = src->info.num_samples > 1;
+ src_info.num_samples = src->info.num_samples;
+ src_info.size = src->info.size;
}
if (dst && GetFormatType(dst->info.format) != SurfaceType::ColorTexture) {
dst_info.format = dst->info.format;
}
if (src && GetFormatType(src->info.format) != SurfaceType::ColorTexture) {
- dst_info.format = src->info.format;
+ if (dst) {
+ if (GetFormatType(dst->info.format) == SurfaceType::ColorTexture) {
+ src_info.format = original_src_format;
+ }
+ } else {
+ dst_info.format = src->info.format;
+ }
}
if (dst && GetFormatType(dst->info.format) != SurfaceType::ColorTexture) {
- src_info.format = dst->info.format;
+ if (src) {
+ if (GetFormatType(src->info.format) == SurfaceType::ColorTexture) {
+ dst_info.format = original_dst_format;
+ }
+ } else {
+ src_info.format = dst->info.format;
+ }
}
+ ASSERT(!is_resolve || dst_info.format == src_info.format);
}
u32 MapSizeBytes(const ImageBase& image) {