diff options
| author | 2022-11-05 22:26:38 +0100 | |
|---|---|---|
| committer | 2022-11-24 20:35:44 +0100 | |
| commit | 957840be9151e7c3b97b638cc0d10d73173c4036 (patch) | |
| tree | bf3f3aa7b612265fd19db8297ee09d71c819abe7 /src/video_core/texture_cache | |
| parent | Merge pull request #9299 from lioncash/cast (diff) | |
| download | yuzu-957840be9151e7c3b97b638cc0d10d73173c4036.tar.gz yuzu-957840be9151e7c3b97b638cc0d10d73173c4036.tar.xz yuzu-957840be9151e7c3b97b638cc0d10d73173c4036.zip | |
Fermi2D: Rework blit engine and add a software blitter.
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 29 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 8 |
2 files changed, 28 insertions, 9 deletions
diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 8ef75fe73..8e68a2e53 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h | |||
| @@ -506,10 +506,14 @@ void TextureCache<P>::UnmapGPUMemory(size_t as_id, GPUVAddr gpu_addr, size_t siz | |||
| 506 | } | 506 | } |
| 507 | 507 | ||
| 508 | template <class P> | 508 | template <class P> |
| 509 | void TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, | 509 | bool TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, |
| 510 | const Tegra::Engines::Fermi2D::Surface& src, | 510 | const Tegra::Engines::Fermi2D::Surface& src, |
| 511 | const Tegra::Engines::Fermi2D::Config& copy) { | 511 | const Tegra::Engines::Fermi2D::Config& copy) { |
| 512 | const BlitImages images = GetBlitImages(dst, src, copy); | 512 | const auto result = GetBlitImages(dst, src, copy); |
| 513 | if (!result) { | ||
| 514 | return false; | ||
| 515 | } | ||
| 516 | const BlitImages images = *result; | ||
| 513 | const ImageId dst_id = images.dst_id; | 517 | const ImageId dst_id = images.dst_id; |
| 514 | const ImageId src_id = images.src_id; | 518 | const ImageId src_id = images.src_id; |
| 515 | 519 | ||
| @@ -596,6 +600,7 @@ void TextureCache<P>::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, | |||
| 596 | runtime.BlitImage(dst_framebuffer, dst_view, src_view, dst_region, src_region, copy.filter, | 600 | runtime.BlitImage(dst_framebuffer, dst_view, src_view, dst_region, src_region, copy.filter, |
| 597 | copy.operation); | 601 | copy.operation); |
| 598 | } | 602 | } |
| 603 | return true; | ||
| 599 | } | 604 | } |
| 600 | 605 | ||
| 601 | template <class P> | 606 | template <class P> |
| @@ -1133,7 +1138,7 @@ ImageId TextureCache<P>::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA | |||
| 1133 | } | 1138 | } |
| 1134 | 1139 | ||
| 1135 | template <class P> | 1140 | template <class P> |
| 1136 | typename TextureCache<P>::BlitImages TextureCache<P>::GetBlitImages( | 1141 | std::optional<typename TextureCache<P>::BlitImages> TextureCache<P>::GetBlitImages( |
| 1137 | const Tegra::Engines::Fermi2D::Surface& dst, const Tegra::Engines::Fermi2D::Surface& src, | 1142 | const Tegra::Engines::Fermi2D::Surface& dst, const Tegra::Engines::Fermi2D::Surface& src, |
| 1138 | const Tegra::Engines::Fermi2D::Config& copy) { | 1143 | const Tegra::Engines::Fermi2D::Config& copy) { |
| 1139 | 1144 | ||
| @@ -1154,6 +1159,20 @@ typename TextureCache<P>::BlitImages TextureCache<P>::GetBlitImages( | |||
| 1154 | has_deleted_images = false; | 1159 | has_deleted_images = false; |
| 1155 | src_id = FindImage(src_info, src_addr, try_options); | 1160 | src_id = FindImage(src_info, src_addr, try_options); |
| 1156 | dst_id = FindImage(dst_info, dst_addr, try_options); | 1161 | dst_id = FindImage(dst_info, dst_addr, try_options); |
| 1162 | if (!copy.must_accelerate) { | ||
| 1163 | do { | ||
| 1164 | if (!src_id && !dst_id) { | ||
| 1165 | return std::nullopt; | ||
| 1166 | } | ||
| 1167 | if (src_id && True(slot_images[src_id].flags & ImageFlagBits::GpuModified)) { | ||
| 1168 | break; | ||
| 1169 | } | ||
| 1170 | if (dst_id && True(slot_images[dst_id].flags & ImageFlagBits::GpuModified)) { | ||
| 1171 | break; | ||
| 1172 | } | ||
| 1173 | return std::nullopt; | ||
| 1174 | } while (false); | ||
| 1175 | } | ||
| 1157 | const ImageBase* const src_image = src_id ? &slot_images[src_id] : nullptr; | 1176 | const ImageBase* const src_image = src_id ? &slot_images[src_id] : nullptr; |
| 1158 | if (src_image && src_image->info.num_samples > 1) { | 1177 | if (src_image && src_image->info.num_samples > 1) { |
| 1159 | RelaxedOptions find_options{FIND_OPTIONS | RelaxedOptions::ForceBrokenViews}; | 1178 | RelaxedOptions find_options{FIND_OPTIONS | RelaxedOptions::ForceBrokenViews}; |
| @@ -1194,12 +1213,12 @@ typename TextureCache<P>::BlitImages TextureCache<P>::GetBlitImages( | |||
| 1194 | dst_id = FindOrInsertImage(dst_info, dst_addr, RelaxedOptions{}); | 1213 | dst_id = FindOrInsertImage(dst_info, dst_addr, RelaxedOptions{}); |
| 1195 | } while (has_deleted_images); | 1214 | } while (has_deleted_images); |
| 1196 | } | 1215 | } |
| 1197 | return BlitImages{ | 1216 | return {BlitImages{ |
| 1198 | .dst_id = dst_id, | 1217 | .dst_id = dst_id, |
| 1199 | .src_id = src_id, | 1218 | .src_id = src_id, |
| 1200 | .dst_format = dst_info.format, | 1219 | .dst_format = dst_info.format, |
| 1201 | .src_format = src_info.format, | 1220 | .src_format = src_info.format, |
| 1202 | }; | 1221 | }}; |
| 1203 | } | 1222 | } |
| 1204 | 1223 | ||
| 1205 | template <class P> | 1224 | template <class P> |
diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 2fa8445eb..9db7195bf 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h | |||
| @@ -174,7 +174,7 @@ public: | |||
| 174 | void UnmapGPUMemory(size_t as_id, GPUVAddr gpu_addr, size_t size); | 174 | void UnmapGPUMemory(size_t as_id, GPUVAddr gpu_addr, size_t size); |
| 175 | 175 | ||
| 176 | /// Blit an image with the given parameters | 176 | /// Blit an image with the given parameters |
| 177 | void BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, | 177 | bool BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, |
| 178 | const Tegra::Engines::Fermi2D::Surface& src, | 178 | const Tegra::Engines::Fermi2D::Surface& src, |
| 179 | const Tegra::Engines::Fermi2D::Config& copy); | 179 | const Tegra::Engines::Fermi2D::Config& copy); |
| 180 | 180 | ||
| @@ -285,9 +285,9 @@ private: | |||
| 285 | [[nodiscard]] ImageId JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VAddr cpu_addr); | 285 | [[nodiscard]] ImageId JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VAddr cpu_addr); |
| 286 | 286 | ||
| 287 | /// Return a blit image pair from the given guest blit parameters | 287 | /// Return a blit image pair from the given guest blit parameters |
| 288 | [[nodiscard]] BlitImages GetBlitImages(const Tegra::Engines::Fermi2D::Surface& dst, | 288 | [[nodiscard]] std::optional<BlitImages> GetBlitImages( |
| 289 | const Tegra::Engines::Fermi2D::Surface& src, | 289 | const Tegra::Engines::Fermi2D::Surface& dst, const Tegra::Engines::Fermi2D::Surface& src, |
| 290 | const Tegra::Engines::Fermi2D::Config& copy); | 290 | const Tegra::Engines::Fermi2D::Config& copy); |
| 291 | 291 | ||
| 292 | /// Find or create a sampler from a guest descriptor sampler | 292 | /// Find or create a sampler from a guest descriptor sampler |
| 293 | [[nodiscard]] SamplerId FindSampler(const TSCEntry& config); | 293 | [[nodiscard]] SamplerId FindSampler(const TSCEntry& config); |