From 957840be9151e7c3b97b638cc0d10d73173c4036 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 5 Nov 2022 22:26:38 +0100 Subject: Fermi2D: Rework blit engine and add a software blitter. --- src/video_core/texture_cache/texture_cache.h | 29 +++++++++++++++++++---- src/video_core/texture_cache/texture_cache_base.h | 8 +++---- 2 files changed, 28 insertions(+), 9 deletions(-) (limited to 'src/video_core/texture_cache') 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

::UnmapGPUMemory(size_t as_id, GPUVAddr gpu_addr, size_t siz } template -void TextureCache

::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, +bool TextureCache

::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, const Tegra::Engines::Fermi2D::Surface& src, const Tegra::Engines::Fermi2D::Config& copy) { - const BlitImages images = GetBlitImages(dst, src, copy); + const auto result = GetBlitImages(dst, src, copy); + if (!result) { + return false; + } + const BlitImages images = *result; const ImageId dst_id = images.dst_id; const ImageId src_id = images.src_id; @@ -596,6 +600,7 @@ void TextureCache

::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, runtime.BlitImage(dst_framebuffer, dst_view, src_view, dst_region, src_region, copy.filter, copy.operation); } + return true; } template @@ -1133,7 +1138,7 @@ ImageId TextureCache

::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VA } template -typename TextureCache

::BlitImages TextureCache

::GetBlitImages( +std::optional::BlitImages> TextureCache

::GetBlitImages( const Tegra::Engines::Fermi2D::Surface& dst, const Tegra::Engines::Fermi2D::Surface& src, const Tegra::Engines::Fermi2D::Config& copy) { @@ -1154,6 +1159,20 @@ typename TextureCache

::BlitImages TextureCache

::GetBlitImages( has_deleted_images = false; src_id = FindImage(src_info, src_addr, try_options); dst_id = FindImage(dst_info, dst_addr, try_options); + if (!copy.must_accelerate) { + do { + if (!src_id && !dst_id) { + return std::nullopt; + } + if (src_id && True(slot_images[src_id].flags & ImageFlagBits::GpuModified)) { + break; + } + if (dst_id && True(slot_images[dst_id].flags & ImageFlagBits::GpuModified)) { + break; + } + return std::nullopt; + } while (false); + } const ImageBase* const src_image = src_id ? &slot_images[src_id] : nullptr; if (src_image && src_image->info.num_samples > 1) { RelaxedOptions find_options{FIND_OPTIONS | RelaxedOptions::ForceBrokenViews}; @@ -1194,12 +1213,12 @@ typename TextureCache

::BlitImages TextureCache

::GetBlitImages( dst_id = FindOrInsertImage(dst_info, dst_addr, RelaxedOptions{}); } while (has_deleted_images); } - return BlitImages{ + return {BlitImages{ .dst_id = dst_id, .src_id = src_id, .dst_format = dst_info.format, .src_format = src_info.format, - }; + }}; } template 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: void UnmapGPUMemory(size_t as_id, GPUVAddr gpu_addr, size_t size); /// Blit an image with the given parameters - void BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, + bool BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, const Tegra::Engines::Fermi2D::Surface& src, const Tegra::Engines::Fermi2D::Config& copy); @@ -285,9 +285,9 @@ private: [[nodiscard]] ImageId JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VAddr cpu_addr); /// Return a blit image pair from the given guest blit parameters - [[nodiscard]] BlitImages GetBlitImages(const Tegra::Engines::Fermi2D::Surface& dst, - const Tegra::Engines::Fermi2D::Surface& src, - const Tegra::Engines::Fermi2D::Config& copy); + [[nodiscard]] std::optional GetBlitImages( + const Tegra::Engines::Fermi2D::Surface& dst, const Tegra::Engines::Fermi2D::Surface& src, + const Tegra::Engines::Fermi2D::Config& copy); /// Find or create a sampler from a guest descriptor sampler [[nodiscard]] SamplerId FindSampler(const TSCEntry& config); -- cgit v1.2.3