From 0a2536a0df1f4aea406f2132d3edda0430acc9d1 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Mon, 25 Dec 2023 07:32:16 +0100 Subject: SMMU: Initial adaptation to video_core. --- src/video_core/texture_cache/texture_cache.h | 75 ++++++++++++----------- src/video_core/texture_cache/texture_cache_base.h | 28 +++++---- src/video_core/texture_cache/util.cpp | 4 +- 3 files changed, 56 insertions(+), 51 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 0d5a1709f..7398ed2ec 100644 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -8,10 +8,11 @@ #include "common/alignment.h" #include "common/settings.h" -#include "core/memory.h" #include "video_core/control/channel_state.h" #include "video_core/dirty_flags.h" #include "video_core/engines/kepler_compute.h" +#include "video_core/guest_memory.h" +#include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/texture_cache/image_view_base.h" #include "video_core/texture_cache/samples_helper.h" #include "video_core/texture_cache/texture_cache_base.h" @@ -27,8 +28,8 @@ using VideoCore::Surface::SurfaceType; using namespace Common::Literals; template -TextureCache

::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface& rasterizer_) - : runtime{runtime_}, rasterizer{rasterizer_} { +TextureCache

::TextureCache(Runtime& runtime_, Tegra::MaxwellDeviceMemoryManager& device_memory_) + : runtime{runtime_}, device_memory{device_memory_} { // Configure null sampler TSCEntry sampler_descriptor{}; sampler_descriptor.min_filter.Assign(Tegra::Texture::TextureFilter::Linear); @@ -49,19 +50,19 @@ TextureCache

::TextureCache(Runtime& runtime_, VideoCore::RasterizerInterface& void(slot_samplers.insert(runtime, sampler_descriptor)); if constexpr (HAS_DEVICE_MEMORY_INFO) { - const s64 device_memory = static_cast(runtime.GetDeviceLocalMemory()); - const s64 min_spacing_expected = device_memory - 1_GiB; - const s64 min_spacing_critical = device_memory - 512_MiB; - const s64 mem_threshold = std::min(device_memory, TARGET_THRESHOLD); + const s64 device_local_memory = static_cast(runtime.GetDeviceLocalMemory()); + const s64 min_spacing_expected = device_local_memory - 1_GiB; + const s64 min_spacing_critical = device_local_memory - 512_MiB; + const s64 mem_threshold = std::min(device_local_memory, TARGET_THRESHOLD); const s64 min_vacancy_expected = (6 * mem_threshold) / 10; const s64 min_vacancy_critical = (3 * mem_threshold) / 10; expected_memory = static_cast( - std::max(std::min(device_memory - min_vacancy_expected, min_spacing_expected), + std::max(std::min(device_local_memory - min_vacancy_expected, min_spacing_expected), DEFAULT_EXPECTED_MEMORY)); critical_memory = static_cast( - std::max(std::min(device_memory - min_vacancy_critical, min_spacing_critical), + std::max(std::min(device_local_memory - min_vacancy_critical, min_spacing_critical), DEFAULT_CRITICAL_MEMORY)); - minimum_memory = static_cast((device_memory - mem_threshold) / 2); + minimum_memory = static_cast((device_local_memory - mem_threshold) / 2); } else { expected_memory = DEFAULT_EXPECTED_MEMORY + 512_MiB; critical_memory = DEFAULT_CRITICAL_MEMORY + 1_GiB; @@ -513,7 +514,7 @@ FramebufferId TextureCache

::GetFramebufferId(const RenderTargets& key) { } template -void TextureCache

::WriteMemory(VAddr cpu_addr, size_t size) { +void TextureCache

::WriteMemory(DAddr cpu_addr, size_t size) { ForEachImageInRegion(cpu_addr, size, [this](ImageId image_id, Image& image) { if (True(image.flags & ImageFlagBits::CpuModified)) { return; @@ -526,7 +527,7 @@ void TextureCache

::WriteMemory(VAddr cpu_addr, size_t size) { } template -void TextureCache

::DownloadMemory(VAddr cpu_addr, size_t size) { +void TextureCache

::DownloadMemory(DAddr cpu_addr, size_t size) { boost::container::small_vector images; ForEachImageInRegion(cpu_addr, size, [&images](ImageId image_id, ImageBase& image) { if (!image.IsSafeDownload()) { @@ -553,7 +554,7 @@ void TextureCache

::DownloadMemory(VAddr cpu_addr, size_t size) { } template -std::optional TextureCache

::GetFlushArea(VAddr cpu_addr, +std::optional TextureCache

::GetFlushArea(DAddr cpu_addr, u64 size) { std::optional area{}; ForEachImageInRegion(cpu_addr, size, [&](ImageId, ImageBase& image) { @@ -579,7 +580,7 @@ std::optional TextureCache

::GetFlushArea(V } template -void TextureCache

::UnmapMemory(VAddr cpu_addr, size_t size) { +void TextureCache

::UnmapMemory(DAddr cpu_addr, size_t size) { boost::container::small_vector deleted_images; ForEachImageInRegion(cpu_addr, size, [&](ImageId id, Image&) { deleted_images.push_back(id); }); for (const ImageId id : deleted_images) { @@ -713,7 +714,7 @@ bool TextureCache

::BlitImage(const Tegra::Engines::Fermi2D::Surface& dst, template typename P::ImageView* TextureCache

::TryFindFramebufferImageView( - const Tegra::FramebufferConfig& config, VAddr cpu_addr) { + const Tegra::FramebufferConfig& config, DAddr cpu_addr) { // TODO: Properly implement this const auto it = page_table.find(cpu_addr >> YUZU_PAGEBITS); if (it == page_table.end()) { @@ -940,7 +941,7 @@ bool TextureCache

::IsRescaling(const ImageViewBase& image_view) const noexcep } template -bool TextureCache

::IsRegionGpuModified(VAddr addr, size_t size) { +bool TextureCache

::IsRegionGpuModified(DAddr addr, size_t size) { bool is_modified = false; ForEachImageInRegion(addr, size, [&is_modified](ImageId, ImageBase& image) { if (False(image.flags & ImageFlagBits::GpuModified)) { @@ -1059,7 +1060,7 @@ void TextureCache

::UploadImageContents(Image& image, StagingBuffer& staging) return; } - Core::Memory::GpuGuestMemory swizzle_data( + Tegra::Memory::GpuGuestMemory swizzle_data( *gpu_memory, gpu_addr, image.guest_size_bytes, &swizzle_data_buffer); if (True(image.flags & ImageFlagBits::Converted)) { @@ -1124,7 +1125,7 @@ ImageId TextureCache

::FindOrInsertImage(const ImageInfo& info, GPUVAddr gpu_a template ImageId TextureCache

::FindImage(const ImageInfo& info, GPUVAddr gpu_addr, RelaxedOptions options) { - std::optional cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); + std::optional cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); if (!cpu_addr) { cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr, CalculateGuestSizeInBytes(info)); if (!cpu_addr) { @@ -1265,7 +1266,7 @@ void TextureCache

::QueueAsyncDecode(Image& image, ImageId image_id) { static Common::ScratchBuffer local_unswizzle_data_buffer; local_unswizzle_data_buffer.resize_destructive(image.unswizzled_size_bytes); - Core::Memory::GpuGuestMemory swizzle_data( + Tegra::Memory::GpuGuestMemory swizzle_data( *gpu_memory, image.gpu_addr, image.guest_size_bytes, &swizzle_data_buffer); auto copies = UnswizzleImage(*gpu_memory, image.gpu_addr, image.info, swizzle_data, @@ -1339,14 +1340,14 @@ bool TextureCache

::ScaleDown(Image& image) { template ImageId TextureCache

::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr, RelaxedOptions options) { - std::optional cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); + std::optional cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); if (!cpu_addr) { const auto size = CalculateGuestSizeInBytes(info); cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr, size); if (!cpu_addr) { - const VAddr fake_addr = ~(1ULL << 40ULL) + virtual_invalid_space; + const DAddr fake_addr = ~(1ULL << 40ULL) + virtual_invalid_space; virtual_invalid_space += Common::AlignUp(size, 32); - cpu_addr = std::optional(fake_addr); + cpu_addr = std::optional(fake_addr); } } ASSERT_MSG(cpu_addr, "Tried to insert an image to an invalid gpu_addr=0x{:x}", gpu_addr); @@ -1362,7 +1363,7 @@ ImageId TextureCache

::InsertImage(const ImageInfo& info, GPUVAddr gpu_addr, } template -ImageId TextureCache

::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VAddr cpu_addr) { +ImageId TextureCache

::JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, DAddr cpu_addr) { ImageInfo new_info = info; const size_t size_bytes = CalculateGuestSizeInBytes(new_info); const bool broken_views = runtime.HasBrokenTextureViewFormats(); @@ -1650,7 +1651,7 @@ std::optional::BlitImages> TextureCache

::GetBlitImag template ImageId TextureCache

::FindDMAImage(const ImageInfo& info, GPUVAddr gpu_addr) { - std::optional cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); + std::optional cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); if (!cpu_addr) { cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr, CalculateGuestSizeInBytes(info)); if (!cpu_addr) { @@ -1780,7 +1781,7 @@ ImageViewId TextureCache

::FindRenderTargetView(const ImageInfo& info, GPUVAdd template template -void TextureCache

::ForEachImageInRegion(VAddr cpu_addr, size_t size, Func&& func) { +void TextureCache

::ForEachImageInRegion(DAddr cpu_addr, size_t size, Func&& func) { using FuncReturn = typename std::invoke_result::type; static constexpr bool BOOL_BREAK = std::is_same_v; boost::container::small_vector images; @@ -1924,11 +1925,11 @@ void TextureCache

::ForEachSparseImageInRegion(GPUVAddr gpu_addr, size_t size, template template void TextureCache

::ForEachSparseSegment(ImageBase& image, Func&& func) { - using FuncReturn = typename std::invoke_result::type; + using FuncReturn = typename std::invoke_result::type; static constexpr bool RETURNS_BOOL = std::is_same_v; const auto segments = gpu_memory->GetSubmappedRange(image.gpu_addr, image.guest_size_bytes); for (const auto& [gpu_addr, size] : segments) { - std::optional cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); + std::optional cpu_addr = gpu_memory->GpuToCpuAddress(gpu_addr); ASSERT(cpu_addr); if constexpr (RETURNS_BOOL) { if (func(gpu_addr, *cpu_addr, size)) { @@ -1980,7 +1981,7 @@ void TextureCache

::RegisterImage(ImageId image_id) { } boost::container::small_vector sparse_maps; ForEachSparseSegment( - image, [this, image_id, &sparse_maps](GPUVAddr gpu_addr, VAddr cpu_addr, size_t size) { + image, [this, image_id, &sparse_maps](GPUVAddr gpu_addr, DAddr cpu_addr, size_t size) { auto map_id = slot_map_views.insert(gpu_addr, cpu_addr, size, image_id); ForEachCPUPage(cpu_addr, size, [this, map_id](u64 page) { page_table[page].push_back(map_id); }); @@ -2048,7 +2049,7 @@ void TextureCache

::UnregisterImage(ImageId image_id) { auto& sparse_maps = it->second; for (auto& map_view_id : sparse_maps) { const auto& map_range = slot_map_views[map_view_id]; - const VAddr cpu_addr = map_range.cpu_addr; + const DAddr cpu_addr = map_range.cpu_addr; const std::size_t size = map_range.size; ForEachCPUPage(cpu_addr, size, [this, image_id](u64 page) { const auto page_it = page_table.find(page); @@ -2080,7 +2081,7 @@ void TextureCache

::TrackImage(ImageBase& image, ImageId image_id) { ASSERT(False(image.flags & ImageFlagBits::Tracked)); image.flags |= ImageFlagBits::Tracked; if (False(image.flags & ImageFlagBits::Sparse)) { - rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1); + device_memory.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, 1); return; } if (True(image.flags & ImageFlagBits::Registered)) { @@ -2089,15 +2090,15 @@ void TextureCache

::TrackImage(ImageBase& image, ImageId image_id) { auto& sparse_maps = it->second; for (auto& map_view_id : sparse_maps) { const auto& map = slot_map_views[map_view_id]; - const VAddr cpu_addr = map.cpu_addr; + const DAddr cpu_addr = map.cpu_addr; const std::size_t size = map.size; - rasterizer.UpdatePagesCachedCount(cpu_addr, size, 1); + device_memory.UpdatePagesCachedCount(cpu_addr, size, 1); } return; } ForEachSparseSegment(image, - [this]([[maybe_unused]] GPUVAddr gpu_addr, VAddr cpu_addr, size_t size) { - rasterizer.UpdatePagesCachedCount(cpu_addr, size, 1); + [this]([[maybe_unused]] GPUVAddr gpu_addr, DAddr cpu_addr, size_t size) { + device_memory.UpdatePagesCachedCount(cpu_addr, size, 1); }); } @@ -2106,7 +2107,7 @@ void TextureCache

::UntrackImage(ImageBase& image, ImageId image_id) { ASSERT(True(image.flags & ImageFlagBits::Tracked)); image.flags &= ~ImageFlagBits::Tracked; if (False(image.flags & ImageFlagBits::Sparse)) { - rasterizer.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, -1); + device_memory.UpdatePagesCachedCount(image.cpu_addr, image.guest_size_bytes, -1); return; } ASSERT(True(image.flags & ImageFlagBits::Registered)); @@ -2115,9 +2116,9 @@ void TextureCache

::UntrackImage(ImageBase& image, ImageId image_id) { auto& sparse_maps = it->second; for (auto& map_view_id : sparse_maps) { const auto& map = slot_map_views[map_view_id]; - const VAddr cpu_addr = map.cpu_addr; + const DAddr cpu_addr = map.cpu_addr; const std::size_t size = map.size; - rasterizer.UpdatePagesCachedCount(cpu_addr, size, -1); + device_memory.UpdatePagesCachedCount(cpu_addr, size, -1); } } diff --git a/src/video_core/texture_cache/texture_cache_base.h b/src/video_core/texture_cache/texture_cache_base.h index 6caf75b46..8699d40d4 100644 --- a/src/video_core/texture_cache/texture_cache_base.h +++ b/src/video_core/texture_cache/texture_cache_base.h @@ -36,9 +36,11 @@ #include "video_core/texture_cache/types.h" #include "video_core/textures/texture.h" -namespace Tegra::Control { +namespace Tegra { +namespace Control { struct ChannelState; } +} // namespace Tegra namespace VideoCommon { @@ -126,7 +128,7 @@ class TextureCache : public VideoCommon::ChannelSetupCaches GetFlushArea(VAddr cpu_addr, u64 size); + std::optional GetFlushArea(DAddr cpu_addr, u64 size); /// Remove images in a region - void UnmapMemory(VAddr cpu_addr, size_t size); + void UnmapMemory(DAddr cpu_addr, size_t size); /// Remove images in a region void UnmapGPUMemory(size_t as_id, GPUVAddr gpu_addr, size_t size); @@ -210,7 +212,7 @@ public: /// Try to find a cached image view in the given CPU address [[nodiscard]] ImageView* TryFindFramebufferImageView(const Tegra::FramebufferConfig& config, - VAddr cpu_addr); + DAddr cpu_addr); /// Return true when there are uncommitted images to be downloaded [[nodiscard]] bool HasUncommittedFlushes() const noexcept; @@ -235,7 +237,7 @@ public: GPUVAddr address = 0, size_t size = 0); /// Return true when a CPU region is modified from the GPU - [[nodiscard]] bool IsRegionGpuModified(VAddr addr, size_t size); + [[nodiscard]] bool IsRegionGpuModified(DAddr addr, size_t size); [[nodiscard]] bool IsRescaling() const noexcept; @@ -252,7 +254,7 @@ public: private: /// Iterate over all page indices in a range template - static void ForEachCPUPage(VAddr addr, size_t size, Func&& func) { + static void ForEachCPUPage(DAddr addr, size_t size, Func&& func) { static constexpr bool RETURNS_BOOL = std::is_same_v, bool>; const u64 page_end = (addr + size - 1) >> YUZU_PAGEBITS; for (u64 page = addr >> YUZU_PAGEBITS; page <= page_end; ++page) { @@ -326,7 +328,7 @@ private: /// Create a new image and join perfectly matching existing images /// Remove joined images from the cache - [[nodiscard]] ImageId JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, VAddr cpu_addr); + [[nodiscard]] ImageId JoinImages(const ImageInfo& info, GPUVAddr gpu_addr, DAddr cpu_addr); [[nodiscard]] ImageId FindDMAImage(const ImageInfo& info, GPUVAddr gpu_addr); @@ -349,7 +351,7 @@ private: /// Iterates over all the images in a region calling func template - void ForEachImageInRegion(VAddr cpu_addr, size_t size, Func&& func); + void ForEachImageInRegion(DAddr cpu_addr, size_t size, Func&& func); template void ForEachImageInRegionGPU(size_t as_id, GPUVAddr gpu_addr, size_t size, Func&& func); @@ -421,7 +423,7 @@ private: Runtime& runtime; - VideoCore::RasterizerInterface& rasterizer; + Tegra::MaxwellDeviceMemoryManager& device_memory; std::deque gpu_page_table_storage; RenderTargets render_targets; @@ -432,7 +434,7 @@ private: std::unordered_map, Common::IdentityHash> sparse_page_table; std::unordered_map> sparse_views; - VAddr virtual_invalid_space{}; + DAddr virtual_invalid_space{}; bool has_deleted_images = false; bool is_rescaling = false; diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index fcf70068e..96f04b6c8 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp @@ -23,6 +23,7 @@ #include "core/memory.h" #include "video_core/compatible_formats.h" #include "video_core/engines/maxwell_3d.h" +#include "video_core/guest_memory.h" #include "video_core/memory_manager.h" #include "video_core/surface.h" #include "video_core/texture_cache/decode_bc.h" @@ -552,7 +553,8 @@ void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr for (s32 layer = 0; layer < info.resources.layers; ++layer) { const std::span src = input.subspan(host_offset); { - Core::Memory::GpuGuestMemoryScoped + Tegra::Memory::GpuGuestMemoryScoped dst(gpu_memory, gpu_addr + guest_offset, subresource_size, &tmp_buffer); SwizzleTexture(dst, src, bytes_per_block, num_tiles.width, num_tiles.height, -- cgit v1.2.3 From 23430e67724d803184b6a861e4bcb3cac0e38cb0 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 7 Jan 2024 05:33:43 +0100 Subject: Core: Eliminate core/memory dependancies. --- src/core/device_memory_manager.h | 4 ++++ src/core/gpu_dirty_memory_manager.h | 4 ++-- src/tests/video_core/memory_tracker.cpp | 7 +++---- src/video_core/buffer_cache/buffer_cache.h | 21 ++++++++++----------- src/video_core/buffer_cache/buffer_cache_base.h | 4 ++-- src/video_core/buffer_cache/word_manager.h | 4 ++-- src/video_core/engines/maxwell_3d.cpp | 1 - src/video_core/engines/maxwell_dma.cpp | 1 - src/video_core/memory_manager.cpp | 8 ++++---- src/video_core/memory_manager.h | 1 - src/video_core/query_cache.h | 1 - src/video_core/query_cache/query_cache.h | 15 +++++++-------- src/video_core/query_cache/query_cache_base.h | 7 +++---- src/video_core/renderer_null/null_rasterizer.cpp | 5 ++--- src/video_core/renderer_opengl/gl_rasterizer.cpp | 4 ++-- src/video_core/renderer_opengl/renderer_opengl.cpp | 1 - src/video_core/renderer_vulkan/pipeline_helper.h | 1 - .../renderer_vulkan/vk_graphics_pipeline.cpp | 1 + src/video_core/renderer_vulkan/vk_query_cache.cpp | 5 ++--- src/video_core/renderer_vulkan/vk_rasterizer.cpp | 4 ++-- src/video_core/texture_cache/util.cpp | 1 - 21 files changed, 46 insertions(+), 54 deletions(-) (limited to 'src/video_core/texture_cache') diff --git a/src/core/device_memory_manager.h b/src/core/device_memory_manager.h index cc9fd023f..6311e9ece 100644 --- a/src/core/device_memory_manager.h +++ b/src/core/device_memory_manager.h @@ -15,6 +15,10 @@ namespace Core { +constexpr size_t DEVICE_PAGEBITS = 12ULL; +constexpr size_t DEVICE_PAGESIZE = 1ULL << DEVICE_PAGEBITS; +constexpr size_t DEVICE_PAGEMASK = DEVICE_PAGESIZE - 1ULL; + class DeviceMemory; namespace Memory { diff --git a/src/core/gpu_dirty_memory_manager.h b/src/core/gpu_dirty_memory_manager.h index f1abf4f83..cc8fc176f 100644 --- a/src/core/gpu_dirty_memory_manager.h +++ b/src/core/gpu_dirty_memory_manager.h @@ -10,7 +10,7 @@ #include #include -#include "core/memory.h" +#include "core/device_memory_manager.h" namespace Core { @@ -80,7 +80,7 @@ private: u32 mask; }; - constexpr static size_t page_bits = Memory::YUZU_PAGEBITS - 1; + constexpr static size_t page_bits = DEVICE_PAGEBITS - 1; constexpr static size_t page_size = 1ULL << page_bits; constexpr static size_t page_mask = page_size - 1; diff --git a/src/tests/video_core/memory_tracker.cpp b/src/tests/video_core/memory_tracker.cpp index 618793668..0e559a590 100644 --- a/src/tests/video_core/memory_tracker.cpp +++ b/src/tests/video_core/memory_tracker.cpp @@ -24,9 +24,8 @@ constexpr VAddr c = 16 * HIGH_PAGE_SIZE; class RasterizerInterface { public: void UpdatePagesCachedCount(VAddr addr, u64 size, int delta) { - const u64 page_start{addr >> Core::Memory::YUZU_PAGEBITS}; - const u64 page_end{(addr + size + Core::Memory::YUZU_PAGESIZE - 1) >> - Core::Memory::YUZU_PAGEBITS}; + const u64 page_start{addr >> Core::DEVICE_PAGEBITS}; + const u64 page_end{(addr + size + Core::DEVICE_PAGESIZE - 1) >> Core::DEVICE_PAGEBITS}; for (u64 page = page_start; page < page_end; ++page) { int& value = page_table[page]; value += delta; @@ -40,7 +39,7 @@ public: } [[nodiscard]] int Count(VAddr addr) const noexcept { - const auto it = page_table.find(addr >> Core::Memory::YUZU_PAGEBITS); + const auto it = page_table.find(addr >> Core::DEVICE_PAGEBITS); return it == page_table.end() ? 0 : it->second; } diff --git a/src/video_core/buffer_cache/buffer_cache.h b/src/video_core/buffer_cache/buffer_cache.h index 5325a715a..b4bf369d1 100644 --- a/src/video_core/buffer_cache/buffer_cache.h +++ b/src/video_core/buffer_cache/buffer_cache.h @@ -13,7 +13,7 @@ namespace VideoCommon { -using Core::Memory::YUZU_PAGESIZE; +using Core::DEVICE_PAGESIZE; template BufferCache

::BufferCache(Tegra::MaxwellDeviceMemoryManager& device_memory_, Runtime& runtime_) @@ -120,8 +120,8 @@ void BufferCache

::CachedWriteMemory(DAddr device_addr, u64 size) { if (!is_dirty) { return; } - DAddr aligned_start = Common::AlignDown(device_addr, YUZU_PAGESIZE); - DAddr aligned_end = Common::AlignUp(device_addr + size, YUZU_PAGESIZE); + DAddr aligned_start = Common::AlignDown(device_addr, DEVICE_PAGESIZE); + DAddr aligned_end = Common::AlignUp(device_addr + size, DEVICE_PAGESIZE); if (!IsRegionGpuModified(aligned_start, aligned_end - aligned_start)) { WriteMemory(device_addr, size); return; @@ -151,9 +151,8 @@ std::optional BufferCache

::GetFlushArea(DA u64 size) { std::optional area{}; area.emplace(); - DAddr device_addr_start_aligned = Common::AlignDown(device_addr, Core::Memory::YUZU_PAGESIZE); - DAddr device_addr_end_aligned = - Common::AlignUp(device_addr + size, Core::Memory::YUZU_PAGESIZE); + DAddr device_addr_start_aligned = Common::AlignDown(device_addr, Core::DEVICE_PAGESIZE); + DAddr device_addr_end_aligned = Common::AlignUp(device_addr + size, Core::DEVICE_PAGESIZE); area->start_address = device_addr_start_aligned; area->end_address = device_addr_end_aligned; if (memory_tracker.IsRegionPreflushable(device_addr, size)) { @@ -1354,10 +1353,10 @@ typename BufferCache

::OverlapResult BufferCache

::ResolveOverlaps(DAddr dev int stream_score = 0; bool has_stream_leap = false; auto expand_begin = [&](DAddr add_value) { - static constexpr DAddr min_page = CACHING_PAGESIZE + Core::Memory::YUZU_PAGESIZE; + static constexpr DAddr min_page = CACHING_PAGESIZE + Core::DEVICE_PAGESIZE; if (add_value > begin - min_page) { begin = min_page; - device_addr = Core::Memory::YUZU_PAGESIZE; + device_addr = Core::DEVICE_PAGESIZE; return; } begin -= add_value; @@ -1587,8 +1586,8 @@ bool BufferCache

::InlineMemory(DAddr dest_address, size_t copy_size, if (!is_dirty) { return false; } - DAddr aligned_start = Common::AlignDown(dest_address, YUZU_PAGESIZE); - DAddr aligned_end = Common::AlignUp(dest_address + copy_size, YUZU_PAGESIZE); + DAddr aligned_start = Common::AlignDown(dest_address, DEVICE_PAGESIZE); + DAddr aligned_end = Common::AlignUp(dest_address + copy_size, DEVICE_PAGESIZE); if (!IsRegionGpuModified(aligned_start, aligned_end - aligned_start)) { return false; } @@ -1786,7 +1785,7 @@ Binding BufferCache

::StorageBufferBinding(GPUVAddr ssbo_addr, u32 cbuf_index, ASSERT_MSG(device_addr, "Unaligned storage buffer address not found for cbuf index {}", cbuf_index); // The end address used for size calculation does not need to be aligned - const DAddr cpu_end = Common::AlignUp(*device_addr + size, Core::Memory::YUZU_PAGESIZE); + const DAddr cpu_end = Common::AlignUp(*device_addr + size, Core::DEVICE_PAGESIZE); const Binding binding{ .device_addr = *aligned_device_addr, diff --git a/src/video_core/buffer_cache/buffer_cache_base.h b/src/video_core/buffer_cache/buffer_cache_base.h index 4074003e4..80dbb81e7 100644 --- a/src/video_core/buffer_cache/buffer_cache_base.h +++ b/src/video_core/buffer_cache/buffer_cache_base.h @@ -449,8 +449,8 @@ private: } static bool IsRangeGranular(DAddr device_addr, size_t size) { - return (device_addr & ~Core::Memory::YUZU_PAGEMASK) == - ((device_addr + size) & ~Core::Memory::YUZU_PAGEMASK); + return (device_addr & ~Core::DEVICE_PAGEMASK) == + ((device_addr + size) & ~Core::DEVICE_PAGEMASK); } void RunGarbageCollector(); diff --git a/src/video_core/buffer_cache/word_manager.h b/src/video_core/buffer_cache/word_manager.h index 1ca333b32..3db9d8b42 100644 --- a/src/video_core/buffer_cache/word_manager.h +++ b/src/video_core/buffer_cache/word_manager.h @@ -13,12 +13,12 @@ #include "common/common_funcs.h" #include "common/common_types.h" #include "common/div_ceil.h" -#include "core/memory.h" +#include "video_core/host1x/gpu_device_memory_manager.h" namespace VideoCommon { constexpr u64 PAGES_PER_WORD = 64; -constexpr u64 BYTES_PER_PAGE = Core::Memory::YUZU_PAGESIZE; +constexpr u64 BYTES_PER_PAGE = Core::DEVICE_PAGESIZE; constexpr u64 BYTES_PER_WORD = PAGES_PER_WORD * BYTES_PER_PAGE; enum class Type { diff --git a/src/video_core/engines/maxwell_3d.cpp b/src/video_core/engines/maxwell_3d.cpp index 95ba4f76c..a94e1f043 100644 --- a/src/video_core/engines/maxwell_3d.cpp +++ b/src/video_core/engines/maxwell_3d.cpp @@ -9,7 +9,6 @@ #include "common/settings.h" #include "core/core.h" #include "core/core_timing.h" -#include "core/memory.h" #include "video_core/dirty_flags.h" #include "video_core/engines/draw_manager.h" #include "video_core/engines/maxwell_3d.h" diff --git a/src/video_core/engines/maxwell_dma.cpp b/src/video_core/engines/maxwell_dma.cpp index 4bf461fb0..2ebd21fc5 100644 --- a/src/video_core/engines/maxwell_dma.cpp +++ b/src/video_core/engines/maxwell_dma.cpp @@ -8,7 +8,6 @@ #include "common/polyfill_ranges.h" #include "common/settings.h" #include "core/core.h" -#include "core/memory.h" #include "video_core/engines/maxwell_3d.h" #include "video_core/engines/maxwell_dma.h" #include "video_core/guest_memory.h" diff --git a/src/video_core/memory_manager.cpp b/src/video_core/memory_manager.cpp index b18b44e42..a52f8e486 100644 --- a/src/video_core/memory_manager.cpp +++ b/src/video_core/memory_manager.cpp @@ -606,14 +606,14 @@ bool MemoryManager::IsGranularRange(GPUVAddr gpu_addr, std::size_t size) const { const std::size_t page{(page_index & big_page_mask) + size}; return page <= big_page_size; } - const std::size_t page{(gpu_addr & Core::Memory::YUZU_PAGEMASK) + size}; - return page <= Core::Memory::YUZU_PAGESIZE; + const std::size_t page{(gpu_addr & Core::DEVICE_PAGEMASK) + size}; + return page <= Core::DEVICE_PAGESIZE; } if (GetEntry(gpu_addr) != EntryType::Mapped) { return false; } - const std::size_t page{(gpu_addr & Core::Memory::YUZU_PAGEMASK) + size}; - return page <= Core::Memory::YUZU_PAGESIZE; + const std::size_t page{(gpu_addr & Core::DEVICE_PAGEMASK) + size}; + return page <= Core::DEVICE_PAGESIZE; } bool MemoryManager::IsContinuousRange(GPUVAddr gpu_addr, std::size_t size) const { diff --git a/src/video_core/memory_manager.h b/src/video_core/memory_manager.h index eb00918fc..c5255f36c 100644 --- a/src/video_core/memory_manager.h +++ b/src/video_core/memory_manager.h @@ -15,7 +15,6 @@ #include "common/range_map.h" #include "common/scratch_buffer.h" #include "common/virtual_buffer.h" -#include "core/memory.h" #include "video_core/cache_types.h" #include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/pte_kind.h" diff --git a/src/video_core/query_cache.h b/src/video_core/query_cache.h index b01d843e4..4861b123a 100644 --- a/src/video_core/query_cache.h +++ b/src/video_core/query_cache.h @@ -18,7 +18,6 @@ #include "common/assert.h" #include "common/settings.h" -#include "core/memory.h" #include "video_core/control/channel_state_cache.h" #include "video_core/engines/maxwell_3d.h" #include "video_core/host1x/gpu_device_memory_manager.h" diff --git a/src/video_core/query_cache/query_cache.h b/src/video_core/query_cache/query_cache.h index b5e90cf8c..08b779055 100644 --- a/src/video_core/query_cache/query_cache.h +++ b/src/video_core/query_cache/query_cache.h @@ -15,7 +15,6 @@ #include "common/logging/log.h" #include "common/scope_exit.h" #include "common/settings.h" -#include "core/memory.h" #include "video_core/engines/maxwell_3d.h" #include "video_core/gpu.h" #include "video_core/host1x/gpu_device_memory_manager.h" @@ -253,8 +252,8 @@ void QueryCacheBase::CounterReport(GPUVAddr addr, QueryType counter_type query_location.stream_id.Assign(static_cast(streamer_id)); query_location.query_id.Assign(static_cast(new_query_id)); const auto gen_caching_indexing = [](VAddr cur_addr) { - return std::make_pair(cur_addr >> Core::Memory::YUZU_PAGEBITS, - static_cast(cur_addr & Core::Memory::YUZU_PAGEMASK)); + return std::make_pair(cur_addr >> Core::DEVICE_PAGEBITS, + static_cast(cur_addr & Core::DEVICE_PAGEMASK)); }; u8* pointer = impl->device_memory.template GetPointer(cpu_addr); u8* pointer_timestamp = impl->device_memory.template GetPointer(cpu_addr + 8); @@ -325,8 +324,8 @@ void QueryCacheBase::CounterReport(GPUVAddr addr, QueryType counter_type template void QueryCacheBase::UnregisterPending() { const auto gen_caching_indexing = [](VAddr cur_addr) { - return std::make_pair(cur_addr >> Core::Memory::YUZU_PAGEBITS, - static_cast(cur_addr & Core::Memory::YUZU_PAGEMASK)); + return std::make_pair(cur_addr >> Core::DEVICE_PAGEBITS, + static_cast(cur_addr & Core::DEVICE_PAGEMASK)); }; std::scoped_lock lock(cache_mutex); for (QueryLocation loc : impl->pending_unregister) { @@ -390,7 +389,7 @@ bool QueryCacheBase::AccelerateHostConditionalRendering() { } VAddr cpu_addr = *cpu_addr_opt; std::scoped_lock lock(cache_mutex); - auto it1 = cached_queries.find(cpu_addr >> Core::Memory::YUZU_PAGEBITS); + auto it1 = cached_queries.find(cpu_addr >> Core::DEVICE_PAGEBITS); if (it1 == cached_queries.end()) { return VideoCommon::LookupData{ .address = cpu_addr, @@ -398,10 +397,10 @@ bool QueryCacheBase::AccelerateHostConditionalRendering() { }; } auto& sub_container = it1->second; - auto it_current = sub_container.find(cpu_addr & Core::Memory::YUZU_PAGEMASK); + auto it_current = sub_container.find(cpu_addr & Core::DEVICE_PAGEMASK); if (it_current == sub_container.end()) { - auto it_current_2 = sub_container.find((cpu_addr & Core::Memory::YUZU_PAGEMASK) + 4); + auto it_current_2 = sub_container.find((cpu_addr & Core::DEVICE_PAGEMASK) + 4); if (it_current_2 == sub_container.end()) { return VideoCommon::LookupData{ .address = cpu_addr, diff --git a/src/video_core/query_cache/query_cache_base.h b/src/video_core/query_cache/query_cache_base.h index 3c820b5f2..c12fb75ef 100644 --- a/src/video_core/query_cache/query_cache_base.h +++ b/src/video_core/query_cache/query_cache_base.h @@ -13,7 +13,6 @@ #include "common/assert.h" #include "common/bit_field.h" #include "common/common_types.h" -#include "core/memory.h" #include "video_core/control/channel_state_cache.h" #include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/query_cache/query_base.h" @@ -123,10 +122,10 @@ protected: const u64 addr_begin = addr; const u64 addr_end = addr_begin + size; - const u64 page_end = addr_end >> Core::Memory::YUZU_PAGEBITS; + const u64 page_end = addr_end >> Core::DEVICE_PAGEBITS; std::scoped_lock lock(cache_mutex); - for (u64 page = addr_begin >> Core::Memory::YUZU_PAGEBITS; page <= page_end; ++page) { - const u64 page_start = page << Core::Memory::YUZU_PAGEBITS; + for (u64 page = addr_begin >> Core::DEVICE_PAGEBITS; page <= page_end; ++page) { + const u64 page_start = page << Core::DEVICE_PAGEBITS; const auto in_range = [page_start, addr_begin, addr_end](const u32 query_location) { const u64 cache_begin = page_start + query_location; const u64 cache_end = cache_begin + sizeof(u32); diff --git a/src/video_core/renderer_null/null_rasterizer.cpp b/src/video_core/renderer_null/null_rasterizer.cpp index 11b93fdc9..abfabb65b 100644 --- a/src/video_core/renderer_null/null_rasterizer.cpp +++ b/src/video_core/renderer_null/null_rasterizer.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "common/alignment.h" -#include "core/memory.h" #include "video_core/control/channel_state.h" #include "video_core/host1x/host1x.h" #include "video_core/memory_manager.h" @@ -55,8 +54,8 @@ bool RasterizerNull::OnCPUWrite(PAddr addr, u64 size) { void RasterizerNull::OnCacheInvalidation(PAddr addr, u64 size) {} VideoCore::RasterizerDownloadArea RasterizerNull::GetFlushArea(PAddr addr, u64 size) { VideoCore::RasterizerDownloadArea new_area{ - .start_address = Common::AlignDown(addr, Core::Memory::YUZU_PAGESIZE), - .end_address = Common::AlignUp(addr + size, Core::Memory::YUZU_PAGESIZE), + .start_address = Common::AlignDown(addr, Core::DEVICE_PAGESIZE), + .end_address = Common::AlignUp(addr + size, Core::DEVICE_PAGESIZE), .preemtive = true, }; return new_area; diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 71b748c74..d5354ef2d 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -526,8 +526,8 @@ VideoCore::RasterizerDownloadArea RasterizerOpenGL::GetFlushArea(DAddr addr, u64 } } VideoCore::RasterizerDownloadArea new_area{ - .start_address = Common::AlignDown(addr, Core::Memory::YUZU_PAGESIZE), - .end_address = Common::AlignUp(addr + size, Core::Memory::YUZU_PAGESIZE), + .start_address = Common::AlignDown(addr, Core::DEVICE_PAGESIZE), + .end_address = Common::AlignUp(addr + size, Core::DEVICE_PAGESIZE), .preemtive = true, }; return new_area; diff --git a/src/video_core/renderer_opengl/renderer_opengl.cpp b/src/video_core/renderer_opengl/renderer_opengl.cpp index 821a045ad..b75376fdb 100644 --- a/src/video_core/renderer_opengl/renderer_opengl.cpp +++ b/src/video_core/renderer_opengl/renderer_opengl.cpp @@ -15,7 +15,6 @@ #include "common/telemetry.h" #include "core/core_timing.h" #include "core/frontend/emu_window.h" -#include "core/memory.h" #include "core/telemetry_session.h" #include "video_core/host_shaders/ffx_a_h.h" #include "video_core/host_shaders/ffx_fsr1_h.h" diff --git a/src/video_core/renderer_vulkan/pipeline_helper.h b/src/video_core/renderer_vulkan/pipeline_helper.h index 71c783709..850c34a3a 100644 --- a/src/video_core/renderer_vulkan/pipeline_helper.h +++ b/src/video_core/renderer_vulkan/pipeline_helper.h @@ -12,7 +12,6 @@ #include "shader_recompiler/shader_info.h" #include "video_core/renderer_vulkan/vk_texture_cache.h" #include "video_core/renderer_vulkan/vk_update_descriptor.h" -#include "video_core/texture_cache/texture_cache.h" #include "video_core/texture_cache/types.h" #include "video_core/vulkan_common/vulkan_device.h" diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index f2fd2670f..ec6b3a4b0 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -19,6 +19,7 @@ #include "video_core/renderer_vulkan/vk_texture_cache.h" #include "video_core/renderer_vulkan/vk_update_descriptor.h" #include "video_core/shader_notify.h" +#include "video_core/texture_cache/texture_cache.h" #include "video_core/vulkan_common/vulkan_device.h" #if defined(_MSC_VER) && defined(NDEBUG) diff --git a/src/video_core/renderer_vulkan/vk_query_cache.cpp b/src/video_core/renderer_vulkan/vk_query_cache.cpp index 522f92dae..7cbc9c73c 100644 --- a/src/video_core/renderer_vulkan/vk_query_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_query_cache.cpp @@ -13,7 +13,6 @@ #include "common/bit_util.h" #include "common/common_types.h" -#include "core/memory.h" #include "video_core/engines/draw_manager.h" #include "video_core/host1x/gpu_device_memory_manager.h" #include "video_core/query_cache/query_cache.h" @@ -1482,8 +1481,8 @@ void QueryCacheRuntime::SyncValues(std::span values, VkBuffer ba for (auto& sync_val : values) { total_size += sync_val.size; bool found = false; - DAddr base = Common::AlignDown(sync_val.address, Core::Memory::YUZU_PAGESIZE); - DAddr base_end = base + Core::Memory::YUZU_PAGESIZE; + DAddr base = Common::AlignDown(sync_val.address, Core::DEVICE_PAGESIZE); + DAddr base_end = base + Core::DEVICE_PAGESIZE; for (size_t i = 0; i < impl->little_cache.size(); i++) { const auto set_found = [&] { impl->redirect_cache.push_back(i); diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 874927311..5bf41b81f 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -553,8 +553,8 @@ VideoCore::RasterizerDownloadArea RasterizerVulkan::GetFlushArea(DAddr addr, u64 } } VideoCore::RasterizerDownloadArea new_area{ - .start_address = Common::AlignDown(addr, Core::Memory::YUZU_PAGESIZE), - .end_address = Common::AlignUp(addr + size, Core::Memory::YUZU_PAGESIZE), + .start_address = Common::AlignDown(addr, Core::DEVICE_PAGESIZE), + .end_address = Common::AlignUp(addr + size, Core::DEVICE_PAGESIZE), .preemtive = true, }; return new_area; diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp index 96f04b6c8..1a6f0d1ad 100644 --- a/src/video_core/texture_cache/util.cpp +++ b/src/video_core/texture_cache/util.cpp @@ -20,7 +20,6 @@ #include "common/div_ceil.h" #include "common/scratch_buffer.h" #include "common/settings.h" -#include "core/memory.h" #include "video_core/compatible_formats.h" #include "video_core/engines/maxwell_3d.h" #include "video_core/guest_memory.h" -- cgit v1.2.3