summaryrefslogtreecommitdiff
path: root/src/video_core/texture_cache
diff options
context:
space:
mode:
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,
475 const BlitImages images = GetBlitImages(dst, src); 475 const BlitImages images = GetBlitImages(dst, src);
476 const ImageId dst_id = images.dst_id; 476 const ImageId dst_id = images.dst_id;
477 const ImageId src_id = images.src_id; 477 const ImageId src_id = images.src_id;
478
478 PrepareImage(src_id, false, false); 479 PrepareImage(src_id, false, false);
479 PrepareImage(dst_id, true, false); 480 PrepareImage(dst_id, true, false);
480 481
@@ -758,7 +759,8 @@ ImageId TextureCache<P>::FindImage(const ImageInfo& info, GPUVAddr gpu_addr,
758 return ImageId{}; 759 return ImageId{};
759 } 760 }
760 } 761 }
761 const bool broken_views = runtime.HasBrokenTextureViewFormats(); 762 const bool broken_views =
763 runtime.HasBrokenTextureViewFormats() || True(options & RelaxedOptions::ForceBrokenViews);
762 const bool native_bgr = runtime.HasNativeBgr(); 764 const bool native_bgr = runtime.HasNativeBgr();
763 ImageId image_id; 765 ImageId image_id;
764 const auto lambda = [&](ImageId existing_image_id, ImageBase& existing_image) { 766 const auto lambda = [&](ImageId existing_image_id, ImageBase& existing_image) {
@@ -1094,12 +1096,13 @@ typename TextureCache<P>::BlitImages TextureCache<P>::GetBlitImages(
1094 if (GetFormatType(dst_info.format) != GetFormatType(src_info.format)) { 1096 if (GetFormatType(dst_info.format) != GetFormatType(src_info.format)) {
1095 continue; 1097 continue;
1096 } 1098 }
1097 if (!dst_id) { 1099 RelaxedOptions find_options{};
1098 dst_id = InsertImage(dst_info, dst_addr, RelaxedOptions{}); 1100 if (src_info.num_samples > 1) {
1099 } 1101 // it's a resolve, we must enforce the same format.
1100 if (!src_id) { 1102 find_options = RelaxedOptions::ForceBrokenViews;
1101 src_id = InsertImage(src_info, src_addr, RelaxedOptions{});
1102 } 1103 }
1104 src_id = FindOrInsertImage(src_info, src_addr, find_options);
1105 dst_id = FindOrInsertImage(dst_info, dst_addr, find_options);
1103 } while (has_deleted_images); 1106 } while (has_deleted_images);
1104 return BlitImages{ 1107 return BlitImages{
1105 .dst_id = dst_id, 1108 .dst_id = dst_id,
@@ -1759,8 +1762,8 @@ void TextureCache<P>::CopyImage(ImageId dst_id, ImageId src_id, std::vector<Imag
1759 } 1762 }
1760 UNIMPLEMENTED_IF(dst.info.type != ImageType::e2D); 1763 UNIMPLEMENTED_IF(dst.info.type != ImageType::e2D);
1761 UNIMPLEMENTED_IF(src.info.type != ImageType::e2D); 1764 UNIMPLEMENTED_IF(src.info.type != ImageType::e2D);
1762 if constexpr (HAS_PIXEL_FORMAT_CONVERSIONS) { 1765 if (runtime.ShouldReinterpret(dst, src)) {
1763 return runtime.ConvertImage(dst, src, copies); 1766 return runtime.ReinterpretImage(dst, src, copies);
1764 } 1767 }
1765 for (const ImageCopy& copy : copies) { 1768 for (const ImageCopy& copy : copies) {
1766 UNIMPLEMENTED_IF(copy.dst_subresource.num_layers != 1); 1769 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 {
59 static constexpr bool HAS_EMULATED_COPIES = P::HAS_EMULATED_COPIES; 59 static constexpr bool HAS_EMULATED_COPIES = P::HAS_EMULATED_COPIES;
60 /// True when the API can provide info about the memory of the device. 60 /// True when the API can provide info about the memory of the device.
61 static constexpr bool HAS_DEVICE_MEMORY_INFO = P::HAS_DEVICE_MEMORY_INFO; 61 static constexpr bool HAS_DEVICE_MEMORY_INFO = P::HAS_DEVICE_MEMORY_INFO;
62 /// True when the API provides utilities for pixel format conversions.
63 static constexpr bool HAS_PIXEL_FORMAT_CONVERSIONS = P::HAS_PIXEL_FORMAT_CONVERSIONS;
64 62
65 static constexpr u64 DEFAULT_EXPECTED_MEMORY = 1_GiB; 63 static constexpr u64 DEFAULT_EXPECTED_MEMORY = 1_GiB;
66 static constexpr u64 DEFAULT_CRITICAL_MEMORY = 2_GiB; 64 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 {
54 Size = 1 << 0, 54 Size = 1 << 0,
55 Format = 1 << 1, 55 Format = 1 << 1,
56 Samples = 1 << 2, 56 Samples = 1 << 2,
57 ForceBrokenViews = 1 << 3,
57}; 58};
58DECLARE_ENUM_FLAG_OPERATORS(RelaxedOptions) 59DECLARE_ENUM_FLAG_OPERATORS(RelaxedOptions)
59 60
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
1151 1151
1152void DeduceBlitImages(ImageInfo& dst_info, ImageInfo& src_info, const ImageBase* dst, 1152void DeduceBlitImages(ImageInfo& dst_info, ImageInfo& src_info, const ImageBase* dst,
1153 const ImageBase* src) { 1153 const ImageBase* src) {
1154 if (src && GetFormatType(src->info.format) != SurfaceType::ColorTexture) { 1154 bool is_resolve = false;
1155 src_info.format = src->info.format; 1155 const auto original_src_format = src_info.format;
1156 const auto original_dst_format = dst_info.format;
1157 if (src) {
1158 if (GetFormatType(src->info.format) != SurfaceType::ColorTexture) {
1159 src_info.format = src->info.format;
1160 }
1161 is_resolve = src->info.num_samples > 1;
1162 src_info.num_samples = src->info.num_samples;
1163 src_info.size = src->info.size;
1156 } 1164 }
1157 if (dst && GetFormatType(dst->info.format) != SurfaceType::ColorTexture) { 1165 if (dst && GetFormatType(dst->info.format) != SurfaceType::ColorTexture) {
1158 dst_info.format = dst->info.format; 1166 dst_info.format = dst->info.format;
1159 } 1167 }
1160 if (src && GetFormatType(src->info.format) != SurfaceType::ColorTexture) { 1168 if (src && GetFormatType(src->info.format) != SurfaceType::ColorTexture) {
1161 dst_info.format = src->info.format; 1169 if (dst) {
1170 if (GetFormatType(dst->info.format) == SurfaceType::ColorTexture) {
1171 src_info.format = original_src_format;
1172 }
1173 } else {
1174 dst_info.format = src->info.format;
1175 }
1162 } 1176 }
1163 if (dst && GetFormatType(dst->info.format) != SurfaceType::ColorTexture) { 1177 if (dst && GetFormatType(dst->info.format) != SurfaceType::ColorTexture) {
1164 src_info.format = dst->info.format; 1178 if (src) {
1179 if (GetFormatType(src->info.format) == SurfaceType::ColorTexture) {
1180 dst_info.format = original_dst_format;
1181 }
1182 } else {
1183 src_info.format = dst->info.format;
1184 }
1165 } 1185 }
1186 ASSERT(!is_resolve || dst_info.format == src_info.format);
1166} 1187}
1167 1188
1168u32 MapSizeBytes(const ImageBase& image) { 1189u32 MapSizeBytes(const ImageBase& image) {