From 3a4a260e210f1f832bf7010cd7d242758eee56e5 Mon Sep 17 00:00:00 2001 From: Kenix3 Date: Wed, 15 Feb 2023 01:02:09 -0500 Subject: [PATCH] SoH now uses the multithreaded resource manager. (#2467) * SoH now uses the multithreaded resource manager. * Fixes build errors on Linux and decreases audio heap size. * Updates LUS. --- OTRExporter/OTRExporter/Main.cpp | 1 + libultraship | 2 +- soh/include/z64.h | 2 +- soh/soh/OTRGlobals.cpp | 13 ++++++++++++- soh/soh/resource/type/scenecommand/SetPathways.cpp | 2 +- soh/soh/resource/type/scenecommand/SetPathways.h | 2 +- 6 files changed, 17 insertions(+), 5 deletions(-) diff --git a/OTRExporter/OTRExporter/Main.cpp b/OTRExporter/OTRExporter/Main.cpp index da7180b34..e95c36f1f 100644 --- a/OTRExporter/OTRExporter/Main.cpp +++ b/OTRExporter/OTRExporter/Main.cpp @@ -22,6 +22,7 @@ #include #include #include +#include std::string otrFileName = "oot.otr"; std::shared_ptr otrArchive; diff --git a/libultraship b/libultraship index d3e42d7f4..1fc9f3795 160000 --- a/libultraship +++ b/libultraship @@ -1 +1 @@ -Subproject commit d3e42d7f4e56bfad29aafc1b63a8d09f1d8d720a +Subproject commit 1fc9f3795405f6263c3adb3ab8f7d5f0b24b6e75 diff --git a/soh/include/z64.h b/soh/include/z64.h index f0335ca40..4ab88c5a2 100644 --- a/soh/include/z64.h +++ b/soh/include/z64.h @@ -35,7 +35,7 @@ #define _SOH64 #endif -#define AUDIO_HEAP_SIZE 0x3800000 +#define AUDIO_HEAP_SIZE 0x380000 #define SYSTEM_HEAP_SIZE (1024 * 1024 * 4) #ifdef __cplusplus diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp index 09e227db3..c81be9a98 100644 --- a/soh/soh/OTRGlobals.cpp +++ b/soh/soh/OTRGlobals.cpp @@ -6,6 +6,7 @@ #include #include +#include #include #include #include @@ -878,7 +879,17 @@ std::shared_ptr ResourceMgr_LoadResource(const char* path) { } extern "C" char* ResourceMgr_LoadFileRaw(const char* resName) { - return OTRGlobals::Instance->context->GetResourceManager()->LoadFile(resName)->Buffer.get(); + // TODO: This should not exist. Anywhere we are loading textures with this function should be Resources instead. + // We are not currently packing our otr archive with certain textures as resources with otr headers. + static std::unordered_map> cachedRawFiles; + auto file = OTRGlobals::Instance->context->GetResourceManager()->LoadFile(resName); + cachedRawFiles[resName] = file; + + if (file == nullptr) { + return nullptr; + } + + return file->Buffer.data(); } extern "C" char* ResourceMgr_LoadFileFromDisk(const char* filePath) { diff --git a/soh/soh/resource/type/scenecommand/SetPathways.cpp b/soh/soh/resource/type/scenecommand/SetPathways.cpp index 649391c4d..f203b8090 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.cpp +++ b/soh/soh/resource/type/scenecommand/SetPathways.cpp @@ -6,6 +6,6 @@ void* SetPathways::GetPointer() { } size_t SetPathways::GetPointerSize() { - return paths.size() * sizeof(std::shared_ptr); + return paths.size() * sizeof(std::shared_ptr); } } // namespace Ship diff --git a/soh/soh/resource/type/scenecommand/SetPathways.h b/soh/soh/resource/type/scenecommand/SetPathways.h index 1c96d8bb6..fcf7dd569 100644 --- a/soh/soh/resource/type/scenecommand/SetPathways.h +++ b/soh/soh/resource/type/scenecommand/SetPathways.h @@ -16,6 +16,6 @@ class SetPathways : public SceneCommand { size_t GetPointerSize(); uint32_t numPaths; - std::vector> paths; + std::vector> paths; }; }; // namespace Ship