diff options
| author | Takoroka <137927095+Takoroka@users.noreply.github.com> | 2026-10-29 03:39:29 -0400 |
|---|---|---|
| committer | Takoroka <137927095+Takoroka@users.noreply.github.com> | 2026-10-29 03:39:29 -0400 |
| commit | ea6c1193fbfa95e586bb6d129dc684163a12cb3e (patch) | |
| tree | e4d23143900184630deeabe27eab1321dac4a428 /src/video_core/texture_cache | |
| parent | 0bb5055b6541c74f47603a8dff0569a509cbaf18 (diff) | |
Revert "Import experimental NS2 support and accumulated GPU fixes"
This reverts commit 535b676970. The Switch 2 support comes from the nx2
work instead, merged next.
Diffstat (limited to 'src/video_core/texture_cache')
| -rw-r--r-- | src/video_core/texture_cache/accelerated_swizzle.cpp | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/accelerated_swizzle.h | 2 | ||||
| -rw-r--r-- | src/video_core/texture_cache/format_lookup_table.cpp | 1 | ||||
| -rw-r--r-- | src/video_core/texture_cache/image_info.h | 12 | ||||
| -rw-r--r-- | src/video_core/texture_cache/pending_download.h | 58 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache.h | 81 | ||||
| -rw-r--r-- | src/video_core/texture_cache/texture_cache_base.h | 7 | ||||
| -rw-r--r-- | src/video_core/texture_cache/util.cpp | 8 |
8 files changed, 29 insertions, 142 deletions
diff --git a/src/video_core/texture_cache/accelerated_swizzle.cpp b/src/video_core/texture_cache/accelerated_swizzle.cpp index 8ae0ed218d..4c3f724d79 100644 --- a/src/video_core/texture_cache/accelerated_swizzle.cpp +++ b/src/video_core/texture_cache/accelerated_swizzle.cpp @@ -37,7 +37,6 @@ BlockLinearSwizzle2DParams MakeBlockLinearSwizzle2DParams(const SwizzleParameter .x_shift = GOB_SIZE_SHIFT + block.height + block.depth, .block_height = block.height, .block_height_mask = (1U << block.height) - 1, - .native_tiling = info.native_tiling, }; } @@ -64,7 +63,6 @@ BlockLinearSwizzle3DParams MakeBlockLinearSwizzle3DParams(const SwizzleParameter .block_height_mask = (1U << block.height) - 1, .block_depth = block.depth, .block_depth_mask = (1U << block.depth) - 1, - .native_tiling = info.native_tiling, }; } diff --git a/src/video_core/texture_cache/accelerated_swizzle.h b/src/video_core/texture_cache/accelerated_swizzle.h index 8296950c38..d4250da689 100644 --- a/src/video_core/texture_cache/accelerated_swizzle.h +++ b/src/video_core/texture_cache/accelerated_swizzle.h @@ -20,7 +20,6 @@ struct BlockLinearSwizzle2DParams { u32 x_shift; u32 block_height; u32 block_height_mask; - u32 native_tiling; }; struct BlockLinearSwizzle3DParams { @@ -34,7 +33,6 @@ struct BlockLinearSwizzle3DParams { u32 block_height_mask; u32 block_depth; u32 block_depth_mask; - u32 native_tiling; }; [[nodiscard]] BlockLinearSwizzle2DParams MakeBlockLinearSwizzle2DParams( diff --git a/src/video_core/texture_cache/format_lookup_table.cpp b/src/video_core/texture_cache/format_lookup_table.cpp index 20bb96aae3..d6e019cddf 100644 --- a/src/video_core/texture_cache/format_lookup_table.cpp +++ b/src/video_core/texture_cache/format_lookup_table.cpp @@ -157,7 +157,6 @@ PixelFormat PixelFormatFromTextureInfo(TextureFormat format, ComponentType red, return PixelFormat::S8_UINT_D24_UNORM; case Hash(TextureFormat::G24R8, UINT, UNORM, UNORM, UNORM, LINEAR): return PixelFormat::S8_UINT_D24_UNORM; - case Hash(TextureFormat::S8Z24, UNORM, UINT, UNORM, UNORM, LINEAR): case Hash(TextureFormat::S8Z24, UNORM, UINT, UINT, UINT, LINEAR): return PixelFormat::D24_UNORM_S8_UINT; case Hash(TextureFormat::Z32_X24S8, FLOAT, UINT, UNORM, UNORM, LINEAR): diff --git a/src/video_core/texture_cache/image_info.h b/src/video_core/texture_cache/image_info.h index 7407062d19..eb490a6424 100644 --- a/src/video_core/texture_cache/image_info.h +++ b/src/video_core/texture_cache/image_info.h @@ -14,17 +14,6 @@ namespace VideoCommon { using Tegra::Texture::TICEntry; using VideoCore::Surface::PixelFormat; -// Native descriptors address the selected view directly. The legacy NVN -// layer-base bookkeeping is not an additional array prefix for this ABI. -inline TICEntry TextureViewHeader(TICEntry entry, bool native) { - if (native) { - entry.layer_base_0_2.Assign(0); - entry.layer_base_3_7.Assign(0); - entry.layer_base_8_10.Assign(0); - } - return entry; -} - struct ImageInfo { ImageInfo() = default; explicit ImageInfo(const TICEntry& config) noexcept; @@ -48,7 +37,6 @@ struct ImageInfo { u32 maybe_unaligned_layer_stride = 0; u32 num_samples = 1; u32 tile_width_spacing = 0; - bool native_tiling = false; bool rescaleable = false; bool downscaleable = false; bool forced_flushed = false; diff --git a/src/video_core/texture_cache/pending_download.h b/src/video_core/texture_cache/pending_download.h deleted file mode 100644 index 52a48e82d3..0000000000 --- a/src/video_core/texture_cache/pending_download.h +++ /dev/null @@ -1,58 +0,0 @@ -// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project -// SPDX-License-Identifier: GPL-3.0-or-later -#pragma once - -#include <algorithm> -#include <memory> -#include <unordered_set> -#include <cstddef> -#include <utility> -#include "common/slot_vector.h" - -namespace VideoCommon { - -template <class Image> -struct PendingImageDownload { - bool is_swizzle; - size_t async_buffer_id; - Common::SlotId object_id; - std::shared_ptr<Image> retired_image{}; - - Image& GetImage(Common::SlotVector<Image>& images) const { - return retired_image ? *retired_image : images[object_id]; - } -}; - -// Whole-image copies are recorded together at commit time. Repeated requests -// for the same live image therefore observe the same contents. Keep the first -// occurrence so reverse CPU writeback order remains unchanged for aliases. -template <class Image, class Downloads> -size_t DeduplicatePendingImageDownloads(Downloads& downloads, Common::SlotVector<Image>& images) { - std::unordered_set<const Image*> seen; - const size_t previous_size = downloads.size(); - const auto end = std::remove_if(downloads.begin(), downloads.end(), [&](const auto& download) { - return download.is_swizzle && !seen.insert(&download.GetImage(images)).second; - }); - downloads.erase(end, downloads.end()); - return previous_size - downloads.size(); -} - -// Cache slots may be recycled before queued GPU downloads are submitted or -// consumed. Keep the actual image, including its metadata, until those finish. -template <class Image, class Downloads, class Batches> -bool RetainPendingImageDownloads(Common::SlotId id, Image& image, Downloads& pending, - Batches& submitted) { - std::shared_ptr<Image> retained; - const auto retain = [&](auto& downloads) { - for (auto& download : downloads) { - if (!download.is_swizzle || download.object_id != id || download.retired_image) continue; - if (!retained) retained = std::make_shared<Image>(std::move(image)); - download.retired_image = retained; - } - }; - retain(pending); - for (auto& downloads : submitted) retain(downloads); - return retained != nullptr; -} - -} // namespace VideoCommon diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 905f73999b..e92e54f8ce 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -803,17 +803,6 @@ std::pair<typename P::ImageView*, bool> TextureCache<P>::TryFindFramebufferImage if (it == page_table.end()) { return {}; } - const auto view_format = [&]() { - switch (config.pixel_format) { - case Service::android::PixelFormat::Rgb565: - return PixelFormat::R5G6B5_UNORM; - case Service::android::PixelFormat::Bgra8888: - return PixelFormat::B8G8R8A8_UNORM; - default: - return PixelFormat::A8B8G8R8_UNORM; - } - }(); - const auto& image_map_ids = it->second; boost::container::small_vector<ImageId, 4> valid_image_ids; for (const ImageMapId map_id : image_map_ids) { @@ -825,17 +814,20 @@ std::pair<typename P::ImageView*, bool> TextureCache<P>::TryFindFramebufferImage if (image.image_view_ids.empty()) { continue; } - if (!VideoCore::Surface::IsViewCompatible(image.info.format, view_format, false, true)) { - static u32 rejected_alias_count{}; - if (std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS") && rejected_alias_count++ < 8) { - LOG_WARNING(HW_GPU, "Ignoring incompatible framebuffer alias: address={:#x}, image={}, view={}", - cpu_addr, image.info.format, view_format); - } - continue; - } valid_image_ids.push_back(map.image_id); } + const auto view_format = [&]() { + switch (config.pixel_format) { + case Service::android::PixelFormat::Rgb565: + return PixelFormat::R5G6B5_UNORM; + case Service::android::PixelFormat::Bgra8888: + return PixelFormat::B8G8R8A8_UNORM; + default: + return PixelFormat::A8B8G8R8_UNORM; + } + }(); + const auto GetImageViewForFramebuffer = [&](ImageId image_id) { ImageViewInfo info{ImageViewType::e2D, view_format}; if (config.blending == Tegra::BlendMode::Opaque) { @@ -877,7 +869,6 @@ void TextureCache<P>::CommitAsyncFlushes() { // This is intentionally passing the value by copy if constexpr (IMPLEMENTS_ASYNC_DOWNLOADS) { auto& download_ids = uncommitted_downloads; - const size_t redundant_images = DeduplicatePendingImageDownloads(download_ids, slot_images); if (download_ids.empty()) { committed_downloads.emplace_back(std::move(uncommitted_downloads)); uncommitted_downloads.clear(); @@ -891,32 +882,17 @@ void TextureCache<P>::CommitAsyncFlushes() { for (PendingDownload& download_info : download_ids) { if (download_info.is_swizzle) { total_size_bytes += - Common::AlignUp(download_info.GetImage(slot_images).unswizzled_size_bytes, 64); + Common::AlignUp(slot_images[download_info.object_id].unswizzled_size_bytes, 64); any_none_dma = true; download_info.async_buffer_id = last_async_buffer_id; } } if (any_none_dma) { - if (std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS") && total_size_bytes >= 64_MiB) { - LOG_WARNING(HW_GPU, "Large image readback batch: bytes={}, entries={}, duplicates_removed={}, submitted_batches={}, retained_buffers={}", - total_size_bytes, download_ids.size(), redundant_images, - committed_downloads.size(), async_buffers_death_ring.size()); - size_t traced_images = 0; - for (const auto& download : download_ids) { - if (!download.is_swizzle || traced_images++ >= 8) continue; - const auto& image = download.GetImage(slot_images); - LOG_WARNING(HW_GPU, "Readback image: gpu={:#x}, cpu={:#x}, format={}, size={}x{}x{}, levels={}, layers={}, layer_stride={}, guest_bytes={}, download_bytes={}", - image.gpu_addr, image.cpu_addr, image.info.format, - image.info.size.width, image.info.size.height, image.info.size.depth, - image.info.resources.levels, image.info.resources.layers, - image.info.layer_stride, image.guest_size_bytes, image.unswizzled_size_bytes); - } - } auto download_map = runtime.DownloadStagingBuffer(total_size_bytes, true); for (const PendingDownload& download_info : download_ids) { if (download_info.is_swizzle) { - Image& image = download_info.GetImage(slot_images); + Image& image = slot_images[download_info.object_id]; const auto copies = FullDownloadCopies(image.info); image.DownloadMemory(download_map, copies); download_map.offset += Common::AlignUp(image.unswizzled_size_bytes, 64); @@ -949,7 +925,7 @@ void TextureCache<P>::PopAsyncFlushes() { auto& download_info = download_ids[i - 1]; auto& download_buffer = download_map[download_info.async_buffer_id]; if (download_info.is_swizzle) { - const ImageBase& image = download_info.GetImage(slot_images); + const ImageBase& image = slot_images[download_info.object_id]; const auto copies = FullDownloadCopies(image.info); download_buffer.offset -= Common::AlignUp(image.unswizzled_size_bytes, 64); std::span<u8> download_span = @@ -978,7 +954,7 @@ void TextureCache<P>::PopAsyncFlushes() { size_t total_size_bytes = 0; for (const PendingDownload& download_info : download_ids) { if (download_info.is_swizzle) { - total_size_bytes += download_info.GetImage(slot_images).unswizzled_size_bytes; + total_size_bytes += slot_images[download_info.object_id].unswizzled_size_bytes; } } auto download_map = runtime.DownloadStagingBuffer(total_size_bytes); @@ -987,7 +963,7 @@ void TextureCache<P>::PopAsyncFlushes() { if (!download_info.is_swizzle) { continue; } - Image& image = download_info.GetImage(slot_images); + Image& image = slot_images[download_info.object_id]; const auto copies = FullDownloadCopies(image.info); image.DownloadMemory(download_map, copies); download_map.offset += image.unswizzled_size_bytes; @@ -1000,7 +976,7 @@ void TextureCache<P>::PopAsyncFlushes() { if (!download_info.is_swizzle) { continue; } - const ImageBase& image = download_info.GetImage(slot_images); + const ImageBase& image = slot_images[download_info.object_id]; const auto copies = FullDownloadCopies(image.info); SwizzleImage(*gpu_memory, image.gpu_addr, image.info, copies, download_span, swizzle_data_buffer); download_map.offset += image.unswizzled_size_bytes; @@ -1202,18 +1178,7 @@ void TextureCache<P>::UploadImageContents(Image& image, StagingBuffer& staging) } template <class P> -ImageViewId TextureCache<P>::CreateImageView(const TICEntry& raw_config) { - const bool native = gpu_memory->UsesNativeTiling(); - if (raw_config.BaseLayer() && std::getenv("EDEN_NATIVE_DRAW_DIAGNOSTICS")) { - static u32 texture_view_traces{}; - if (texture_view_traces++ < 8) { - LOG_WARNING(HW_GPU, "Native texture view header: native={}, graphics_native={}, address={:#x}, dimensions={}x{}x{}, type={}, legacy_layer={}, raw={:016x}/{:016x}/{:016x}/{:016x}", - native, maxwell3d->GetNativeMacroEngine().native_turing, raw_config.Address(), raw_config.Width(), raw_config.Height(), raw_config.Depth(), - static_cast<u32>(raw_config.texture_type.Value()), raw_config.BaseLayer(), - raw_config.raw[0], raw_config.raw[1], raw_config.raw[2], raw_config.raw[3]); - } - } - const TICEntry config = TextureViewHeader(raw_config, native); +ImageViewId TextureCache<P>::CreateImageView(const TICEntry& config) { const ImageInfo info(config); if (info.type == ImageType::Buffer) { const ImageViewInfo view_info(config, 0); @@ -1561,9 +1526,7 @@ ImageId TextureCache<P>::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr, } } ASSERT_MSG(cpu_addr, "Tried to insert an image to an invalid gpu_addr={:#x}", gpu_addr); - ImageInfo storage_info = info; - storage_info.native_tiling = gpu_memory->UsesNativeTiling(); - const ImageId image_id = JoinImages(storage_info, gpu_addr, *cpu_addr); + const ImageId image_id = JoinImages(info, gpu_addr, *cpu_addr); const Image& image = slot_images[image_id]; // Using "image.gpu_addr" instead of "gpu_addr" is important because it might be different const auto [it, is_new] = image_allocs_table.try_emplace(image.gpu_addr); @@ -2422,11 +2385,7 @@ void TextureCache<P>::DeleteImage(ImageId image_id, bool immediate_delete) { } slot_image_views.erase(image_view_id); } - const bool retained = RetainPendingImageDownloads(image_id, slot_images[image_id], - uncommitted_downloads, committed_downloads); - if (retained) { - LOG_INFO(Render_Vulkan, "Retained image for queued download: id={}", image_id.Value()); - } else if (!immediate_delete) { + if (!immediate_delete) { sentenced_images.Push(std::move(slot_images[image_id])); } slot_images.erase(image_id); diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index d103d66189..8a2318cc72 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -28,7 +28,6 @@ #include <ranges> #include "common/scratch_buffer.h" #include "common/slot_vector.h" -#include "video_core/texture_cache/pending_download.h" #include "common/thread_worker.h" #include "video_core/compatible_formats.h" #include "video_core/control/channel_state_cache.h" @@ -464,7 +463,11 @@ private: size_t size; }; - using PendingDownload = PendingImageDownload<Image>; + struct PendingDownload { + bool is_swizzle; + size_t async_buffer_id; + Common::SlotId object_id; + }; Common::SlotVector<Image> slot_images; Common::SlotVector<ImageMapView> slot_map_views; diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index 5bcea68977..e55d0752ec 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp @@ -439,7 +439,7 @@ template <u32 GOB_EXTENT> } layers = 1; } else { - layers = (std::max)(info.resources.layers, resources.layers + base->layer); + layers = (std::max)(resources.layers, info.resources.layers + base->layer); } return OverlapResult{ .gpu_addr = overlap.gpu_addr, @@ -566,7 +566,7 @@ void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr dst(gpu_memory, gpu_addr + guest_offset, subresource_size, &tmp_buffer); SwizzleTexture(dst, src, bytes_per_block, num_tiles.width, num_tiles.height, - num_tiles.depth, block.height, block.depth, 1, gpu_memory.UsesNativeTiling()); + num_tiles.depth, block.height, block.depth); } host_offset += host_bytes_per_layer; @@ -838,7 +838,7 @@ bool IsValidEntry(const Tegra::MemoryManager& gpu_memory, const TICEntry& config if (gpu_memory.GpuToCpuAddress(address).has_value()) { return true; } - const ImageInfo info{TextureViewHeader(config, gpu_memory.UsesNativeTiling())}; + const ImageInfo info{config}; const size_t guest_size_bytes = CalculateGuestSizeInBytes(info); return gpu_memory.GpuToCpuAddress(address, guest_size_bytes).has_value(); } @@ -913,7 +913,7 @@ boost::container::small_vector<BufferImageCopy, 16> UnswizzleImage(Tegra::Memory const std::span<u8> dst = output.subspan(host_offset); const std::span<const u8> src = input.subspan(guest_offset + guest_layer_offset); UnswizzleTexture(dst, src, 1U << bpp_log2, num_tiles.width, num_tiles.height, - num_tiles.depth, block.height, block.depth, stride_alignment, gpu_memory.UsesNativeTiling()); + num_tiles.depth, block.height, block.depth, stride_alignment); guest_layer_offset += layer_stride; host_offset += host_bytes_per_layer; } |
