From ad11d18846f1dd17c71542879ad63a5061d7eae2 Mon Sep 17 00:00:00 2001 From: pineappleEA Date: Sat, 2 Dec 2023 17:14:16 +0100 Subject: [PATCH] early-access version 4004 --- README.md | 2 +- src/android/app/src/main/jni/native.cpp | 3 -- src/common/host_memory.cpp | 28 ++++++++++--------- src/core/file_sys/patch_manager.cpp | 4 --- src/core/file_sys/romfs.cpp | 21 +++++++++----- src/core/file_sys/romfs_factory.cpp | 2 +- src/core/loader/nca.cpp | 6 ++-- .../renderer_vulkan/vk_texture_cache.cpp | 6 ++-- .../renderer_vulkan/vk_texture_cache.h | 4 +-- src/video_core/texture_cache/texture_cache.h | 2 +- src/yuzu/main.cpp | 5 ---- 11 files changed, 39 insertions(+), 44 deletions(-) diff --git a/README.md b/README.md index 265d3a252..62243025b 100755 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ yuzu emulator early access ============= -This is the source code for early-access 4003. +This is the source code for early-access 4004. ## Legal Notice diff --git a/src/android/app/src/main/jni/native.cpp b/src/android/app/src/main/jni/native.cpp index ed5ce6f8a..3d795b57f 100755 --- a/src/android/app/src/main/jni/native.cpp +++ b/src/android/app/src/main/jni/native.cpp @@ -123,9 +123,6 @@ int EmulationSession::InstallFileToNand(std::string filename, std::string file_e ErrorFilenameExtension = 4, }; - m_system.SetContentProvider(std::make_unique()); - m_system.GetFileSystemController().CreateFactories(*m_vfs); - [[maybe_unused]] std::shared_ptr nsp; if (file_extension == "nsp") { nsp = std::make_shared(m_vfs->OpenFile(filename, FileSys::Mode::Read)); diff --git a/src/common/host_memory.cpp b/src/common/host_memory.cpp index 8421bd8ae..83721e789 100755 --- a/src/common/host_memory.cpp +++ b/src/common/host_memory.cpp @@ -25,6 +25,10 @@ #include #include "common/scope_exit.h" +#ifndef MAP_NORESERVE +#define MAP_NORESERVE 0 +#endif + #endif // ^^^ Linux ^^^ #include @@ -404,6 +408,16 @@ static void* ChooseVirtualBase(size_t virtual_size) { #else static void* ChooseVirtualBase(size_t virtual_size) { +#if defined(__FreeBSD__) + void* virtual_base = + mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, + MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE | MAP_ALIGNED_SUPER, -1, 0); + + if (virtual_base != MAP_FAILED) { + return virtual_base; + } +#endif + return mmap(nullptr, virtual_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS | MAP_NORESERVE, -1, 0); } @@ -459,24 +473,12 @@ public: } // Virtual memory initialization -#if defined(__FreeBSD__) - virtual_base = - static_cast(mmap(nullptr, virtual_size, PROT_NONE, - MAP_PRIVATE | MAP_ANONYMOUS | MAP_ALIGNED_SUPER, -1, 0)); - if (virtual_base == MAP_FAILED) { - virtual_base = static_cast( - mmap(nullptr, virtual_size, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0)); - if (virtual_base == MAP_FAILED) { - LOG_CRITICAL(HW_Memory, "mmap failed: {}", strerror(errno)); - throw std::bad_alloc{}; - } - } -#else virtual_base = virtual_map_base = static_cast(ChooseVirtualBase(virtual_size)); if (virtual_base == MAP_FAILED) { LOG_CRITICAL(HW_Memory, "mmap failed: {}", strerror(errno)); throw std::bad_alloc{}; } +#if defined(__linux__) madvise(virtual_base, virtual_size, MADV_HUGEPAGE); #endif diff --git a/src/core/file_sys/patch_manager.cpp b/src/core/file_sys/patch_manager.cpp index 2d52a3b95..8e5429391 100755 --- a/src/core/file_sys/patch_manager.cpp +++ b/src/core/file_sys/patch_manager.cpp @@ -429,10 +429,6 @@ VirtualFile PatchManager::PatchRomFS(const NCA* base_nca, VirtualFile base_romfs LOG_DEBUG(Loader, "{}", log_string); } - if (base_romfs == nullptr) { - return base_romfs; - } - auto romfs = base_romfs; // Game Updates diff --git a/src/core/file_sys/romfs.cpp b/src/core/file_sys/romfs.cpp index 22d2955e4..8b0e65c53 100755 --- a/src/core/file_sys/romfs.cpp +++ b/src/core/file_sys/romfs.cpp @@ -3,6 +3,7 @@ #include +#include "common/assert.h" #include "common/common_types.h" #include "common/string_util.h" #include "common/swap.h" @@ -101,24 +102,30 @@ void ProcessDirectory(const VirtualFile& file, std::size_t dir_offset, std::size } // Anonymous namespace VirtualDir ExtractRomFS(VirtualFile file) { - RomFSHeader header{}; - if (file->ReadObject(&header) != sizeof(RomFSHeader)) - return nullptr; + auto root_container = std::make_shared(); + if (!file) { + return root_container; + } - if (header.header_size != sizeof(RomFSHeader)) - return nullptr; + RomFSHeader header{}; + if (file->ReadObject(&header) != sizeof(RomFSHeader)) { + return root_container; + } + + if (header.header_size != sizeof(RomFSHeader)) { + return root_container; + } const u64 file_offset = header.file_meta.offset; const u64 dir_offset = header.directory_meta.offset; - auto root_container = std::make_shared(); - ProcessDirectory(file, dir_offset, file_offset, header.data_offset, 0, root_container); if (auto root = root_container->GetSubdirectory(""); root) { return std::make_shared(std::move(root)); } + ASSERT(false); return nullptr; } diff --git a/src/core/file_sys/romfs_factory.cpp b/src/core/file_sys/romfs_factory.cpp index a3a58e970..042bef68f 100755 --- a/src/core/file_sys/romfs_factory.cpp +++ b/src/core/file_sys/romfs_factory.cpp @@ -22,7 +22,7 @@ RomFSFactory::RomFSFactory(Loader::AppLoader& app_loader, ContentProvider& provi : content_provider{provider}, filesystem_controller{controller} { // Load the RomFS from the app if (app_loader.ReadRomFS(file) != Loader::ResultStatus::Success) { - LOG_ERROR(Service_FS, "Unable to read RomFS!"); + LOG_WARNING(Service_FS, "Unable to read base RomFS"); } updatable = app_loader.IsRomFSUpdatable(); diff --git a/src/core/loader/nca.cpp b/src/core/loader/nca.cpp index a892ad318..00d9a7ade 100755 --- a/src/core/loader/nca.cpp +++ b/src/core/loader/nca.cpp @@ -74,10 +74,8 @@ AppLoader_NCA::LoadResult AppLoader_NCA::Load(Kernel::KProcess& process, Core::S return load_result; } - if (nca->GetRomFS() != nullptr && nca->GetRomFS()->GetSize() > 0) { - system.GetFileSystemController().RegisterRomFS(std::make_unique( - *this, system.GetContentProvider(), system.GetFileSystemController())); - } + system.GetFileSystemController().RegisterRomFS(std::make_unique( + *this, system.GetContentProvider(), system.GetFileSystemController())); is_loaded = true; return load_result; diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.cpp b/src/video_core/renderer_vulkan/vk_texture_cache.cpp index 97894944e..befd76a22 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.cpp +++ b/src/video_core/renderer_vulkan/vk_texture_cache.cpp @@ -1439,7 +1439,7 @@ void Image::UploadMemory(const StagingBufferRef& map, std::span copies) { std::array buffer_handles{ buffer, @@ -1450,7 +1450,7 @@ void Image::DownloadMemory(VkBuffer buffer, VkDeviceSize offset, DownloadMemory(buffer_handles, buffer_offsets, copies); } -void Image::DownloadMemory(std::span buffers_span, std::span offsets_span, +void Image::DownloadMemory(std::span buffers_span, std::span offsets_span, std::span copies) { const bool is_rescaled = True(flags & ImageFlagBits::Rescaled); if (is_rescaled) { @@ -1530,7 +1530,7 @@ void Image::DownloadMemory(const StagingBufferRef& map, std::span(map.offset), }; DownloadMemory(buffers, offsets, copies); } diff --git a/src/video_core/renderer_vulkan/vk_texture_cache.h b/src/video_core/renderer_vulkan/vk_texture_cache.h index 84038f223..216592d71 100755 --- a/src/video_core/renderer_vulkan/vk_texture_cache.h +++ b/src/video_core/renderer_vulkan/vk_texture_cache.h @@ -147,10 +147,10 @@ public: void UploadMemory(const StagingBufferRef& map, std::span copies); - void DownloadMemory(VkBuffer buffer, VkDeviceSize offset, + void DownloadMemory(VkBuffer buffer, size_t offset, std::span copies); - void DownloadMemory(std::span buffers, std::span offsets, + void DownloadMemory(std::span buffers, std::span offsets, std::span copies); void DownloadMemory(const StagingBufferRef& map, diff --git a/src/video_core/texture_cache/texture_cache.h b/src/video_core/texture_cache/texture_cache.h index 3008a89db..40e0156e9 100755 --- a/src/video_core/texture_cache/texture_cache.h +++ b/src/video_core/texture_cache/texture_cache.h @@ -995,7 +995,7 @@ void TextureCache

::DownloadImageIntoBuffer(typename TextureCache

::Image* i buffer, download_map.buffer, }; - std::array buffer_offsets{ + std::array buffer_offsets{ buffer_offset, download_map.offset, }; diff --git a/src/yuzu/main.cpp b/src/yuzu/main.cpp index be3b938e2..03533d707 100755 --- a/src/yuzu/main.cpp +++ b/src/yuzu/main.cpp @@ -2713,11 +2713,6 @@ void GMainWindow::OnGameListDumpRomFS(u64 program_id, const std::string& game_pa } const auto base_romfs = base_nca->GetRomFS(); - if (!base_romfs) { - failed(); - return; - } - const auto dump_dir = target == DumpRomFSTarget::Normal ? Common::FS::GetYuzuPath(Common::FS::YuzuPath::DumpDir)