mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2024-11-24 18:32:19 -05:00
LUS bump and implement alt assets performance changes. (#4240)
* LUS bump and implement alt assets performance changes. * LUS ref update.
This commit is contained in:
parent
3d73faa9a0
commit
7bc2259c82
@ -1 +1 @@
|
|||||||
Subproject commit 96c8a8929c18c1bffd7d92a35a589f74cf16fc59
|
Subproject commit 275c741d5dd48d78b6a746c0709c75d095e48eeb
|
@ -137,6 +137,8 @@ Color_RGB8 zoraColor = { 0x00, 0xEC, 0x64 };
|
|||||||
|
|
||||||
float previousImGuiScale;
|
float previousImGuiScale;
|
||||||
|
|
||||||
|
bool prevAltAssets = false;
|
||||||
|
|
||||||
// Same as NaviColor type from OoT src (z_actor.c), but modified to be sans alpha channel for Controller LED.
|
// Same as NaviColor type from OoT src (z_actor.c), but modified to be sans alpha channel for Controller LED.
|
||||||
typedef struct {
|
typedef struct {
|
||||||
Color_RGB8 inner;
|
Color_RGB8 inner;
|
||||||
@ -297,6 +299,8 @@ OTRGlobals::OTRGlobals() {
|
|||||||
};
|
};
|
||||||
// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
|
// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
|
||||||
context = LUS::Context::CreateInstance("Ship of Harkinian", appShortName, "shipofharkinian.json", OTRFiles, {}, 3);
|
context = LUS::Context::CreateInstance("Ship of Harkinian", appShortName, "shipofharkinian.json", OTRFiles, {}, 3);
|
||||||
|
prevAltAssets = CVarGetInteger("gAltAssets", 0);
|
||||||
|
context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets);
|
||||||
SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion);
|
SPDLOG_INFO("Starting Ship of Harkinian version {}", (char*)gBuildVersion);
|
||||||
|
|
||||||
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Animation, "Animation", std::make_shared<LUS::AnimationFactory>());
|
context->GetResourceManager()->GetResourceLoader()->RegisterResourceFactory(LUS::ResourceType::SOH_Animation, "Animation", std::make_shared<LUS::AnimationFactory>());
|
||||||
@ -1235,7 +1239,7 @@ extern "C" void Graph_StartFrame() {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
case KbScancode::LUS_KB_TAB: {
|
case KbScancode::LUS_KB_TAB: {
|
||||||
ToggleAltAssetsAtEndOfFrame = true;
|
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1315,11 +1319,10 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ToggleAltAssetsAtEndOfFrame) {
|
bool curAltAssets = CVarGetInteger("gAltAssets", 0);
|
||||||
ToggleAltAssetsAtEndOfFrame = false;
|
if (prevAltAssets != curAltAssets) {
|
||||||
|
prevAltAssets = curAltAssets;
|
||||||
// Actually update the CVar now before runing the alt asset update listeners
|
LUS::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets);
|
||||||
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0));
|
|
||||||
gfx_texture_cache_clear();
|
gfx_texture_cache_clear();
|
||||||
LUS::SkeletonPatcher::UpdateSkeletons();
|
LUS::SkeletonPatcher::UpdateSkeletons();
|
||||||
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnAssetAltChange>();
|
GameInteractor::Instance->ExecuteHooks<GameInteractor::OnAssetAltChange>();
|
||||||
@ -1495,10 +1498,14 @@ extern "C" uint8_t ResourceMgr_FileAltExists(const char* filePath) {
|
|||||||
return ExtensionCache.contains(path);
|
return ExtensionCache.contains(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern "C" bool ResourceMgr_IsAltAssetsEnabled() {
|
||||||
|
return LUS::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
// Unloads a resource if an alternate version exists when alt assets are enabled
|
// Unloads a resource if an alternate version exists when alt assets are enabled
|
||||||
// The resource is only removed from the internal cache to prevent it from used in the next resource lookup
|
// The resource is only removed from the internal cache to prevent it from used in the next resource lookup
|
||||||
extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) {
|
extern "C" void ResourceMgr_UnloadOriginalWhenAltExists(const char* resName) {
|
||||||
if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileAltExists((char*) resName)) {
|
if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileAltExists((char*) resName)) {
|
||||||
ResourceMgr_UnloadResource((char*) resName);
|
ResourceMgr_UnloadResource((char*) resName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1868,7 +1875,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel
|
|||||||
pathStr = pathStr.substr(sOtr.length());
|
pathStr = pathStr.substr(sOtr.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isAlt = CVarGetInteger("gAltAssets", 0);
|
bool isAlt = ResourceMgr_IsAltAssetsEnabled();
|
||||||
|
|
||||||
if (isAlt) {
|
if (isAlt) {
|
||||||
pathStr = LUS::IResource::gAltAssetPrefix + pathStr;
|
pathStr = LUS::IResource::gAltAssetPrefix + pathStr;
|
||||||
|
@ -120,6 +120,7 @@ void Ctx_ReadSaveFile(uintptr_t addr, void* dramAddr, size_t size);
|
|||||||
void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size);
|
void Ctx_WriteSaveFile(uintptr_t addr, void* dramAddr, size_t size);
|
||||||
|
|
||||||
uint64_t GetPerfCounter();
|
uint64_t GetPerfCounter();
|
||||||
|
bool ResourceMgr_IsAltAssetsEnabled();
|
||||||
struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime);
|
struct SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, SkelAnime* skelAnime);
|
||||||
void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime);
|
void ResourceMgr_UnregisterSkeleton(SkelAnime* skelAnime);
|
||||||
void ResourceMgr_ClearSkeletons();
|
void ResourceMgr_ClearSkeletons();
|
||||||
|
@ -38,7 +38,6 @@
|
|||||||
#include "Enhancements/game-interactor/GameInteractor.h"
|
#include "Enhancements/game-interactor/GameInteractor.h"
|
||||||
#include "Enhancements/cosmetics/authenticGfxPatches.h"
|
#include "Enhancements/cosmetics/authenticGfxPatches.h"
|
||||||
|
|
||||||
bool ToggleAltAssetsAtEndOfFrame = false;
|
|
||||||
bool isBetaQuestEnabled = false;
|
bool isBetaQuestEnabled = false;
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include "Enhancements/randomizer/randomizer_item_tracker.h"
|
#include "Enhancements/randomizer/randomizer_item_tracker.h"
|
||||||
#include "Enhancements/randomizer/randomizer_settings_window.h"
|
#include "Enhancements/randomizer/randomizer_settings_window.h"
|
||||||
|
|
||||||
extern bool ToggleAltAssetsAtEndOfFrame;
|
|
||||||
extern bool isBetaQuestEnabled;
|
extern bool isBetaQuestEnabled;
|
||||||
|
|
||||||
extern "C" PlayState* gPlayState;
|
extern "C" PlayState* gPlayState;
|
||||||
@ -916,12 +915,7 @@ void DrawEnhancementsMenu() {
|
|||||||
if (ImGui::BeginMenu("Graphics"))
|
if (ImGui::BeginMenu("Graphics"))
|
||||||
{
|
{
|
||||||
if (ImGui::BeginMenu("Mods")) {
|
if (ImGui::BeginMenu("Mods")) {
|
||||||
if (UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", "gAltAssets", false, false)) {
|
UIWidgets::PaddedEnhancementCheckbox("Use Alternate Assets", "gAltAssets", false, false);
|
||||||
// The checkbox will flip the alt asset CVar, but we instead want it to change at the end of the game frame
|
|
||||||
// We toggle it back while setting the flag to update the CVar later
|
|
||||||
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0));
|
|
||||||
ToggleAltAssetsAtEndOfFrame = true;
|
|
||||||
}
|
|
||||||
UIWidgets::Tooltip("Toggle between standard assets and alternate assets. Usually mods will indicate if this setting has to be used or not.");
|
UIWidgets::Tooltip("Toggle between standard assets and alternate assets. Usually mods will indicate if this setting has to be used or not.");
|
||||||
UIWidgets::PaddedEnhancementCheckbox("Disable Bomb Billboarding", "gDisableBombBillboarding", true, false);
|
UIWidgets::PaddedEnhancementCheckbox("Disable Bomb Billboarding", "gDisableBombBillboarding", true, false);
|
||||||
UIWidgets::Tooltip("Disables bombs always rotating to face the camera. To be used in conjunction with mods that want to replace bombs with 3D objects.");
|
UIWidgets::Tooltip("Disables bombs always rotating to face the camera. To be used in conjunction with mods that want to replace bombs with 3D objects.");
|
||||||
|
@ -65,12 +65,11 @@ void SkeletonPatcher::ClearSkeletons()
|
|||||||
}
|
}
|
||||||
|
|
||||||
void SkeletonPatcher::UpdateSkeletons() {
|
void SkeletonPatcher::UpdateSkeletons() {
|
||||||
bool isHD = CVarGetInteger("gAltAssets", 0);
|
auto resourceMgr = LUS::Context::GetInstance()->GetResourceManager();
|
||||||
|
bool isHD = resourceMgr->IsAltAssetsEnabled();
|
||||||
for (auto skel : skeletons) {
|
for (auto skel : skeletons) {
|
||||||
Skeleton* newSkel =
|
Skeleton* newSkel =
|
||||||
(Skeleton*)LUS::Context::GetInstance()->GetResourceManager()
|
(Skeleton*)resourceMgr->LoadResource((isHD ? LUS::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true).get();
|
||||||
->LoadResource((isHD ? LUS::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true)
|
|
||||||
.get();
|
|
||||||
|
|
||||||
if (newSkel != nullptr) {
|
if (newSkel != nullptr) {
|
||||||
skel.skelAnime->skeleton = newSkel->skeletonData.skeletonHeader.segment;
|
skel.skelAnime->skeleton = newSkel->skeletonData.skeletonHeader.segment;
|
||||||
|
@ -467,7 +467,7 @@ void GameState_Destroy(GameState* gameState) {
|
|||||||
// Performing clear skeletons before unload resources fixes an actor heap corruption crash due to the skeleton patching system.
|
// Performing clear skeletons before unload resources fixes an actor heap corruption crash due to the skeleton patching system.
|
||||||
ResourceMgr_ClearSkeletons();
|
ResourceMgr_ClearSkeletons();
|
||||||
|
|
||||||
if (CVarGetInteger("gAltAssets", 0)) {
|
if (ResourceMgr_IsAltAssetsEnabled()) {
|
||||||
ResourceUnloadDirectory("alt/*");
|
ResourceUnloadDirectory("alt/*");
|
||||||
gfx_texture_cache_clear();
|
gfx_texture_cache_clear();
|
||||||
}
|
}
|
||||||
|
@ -141,7 +141,7 @@ static const ALIGN_ASSET(2) char rGfxPrintFontDataAlt[] = drGfxPrintFontDataAlt;
|
|||||||
// https://github.com/HarbourMasters/Shipwright/issues/2762
|
// https://github.com/HarbourMasters/Shipwright/issues/2762
|
||||||
typedef enum {hardcoded, otrDefault, otrAlt} font_texture_t;
|
typedef enum {hardcoded, otrDefault, otrAlt} font_texture_t;
|
||||||
font_texture_t GfxPrint_TextureToUse() {
|
font_texture_t GfxPrint_TextureToUse() {
|
||||||
if (CVarGetInteger("gAltAssets", 0) && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) {
|
if (ResourceMgr_IsAltAssetsEnabled() && ResourceMgr_FileExists(rGfxPrintFontDataAlt)) {
|
||||||
// If we have alt assets enabled, and we have alt prefixed font texture, use that
|
// If we have alt assets enabled, and we have alt prefixed font texture, use that
|
||||||
return otrAlt;
|
return otrAlt;
|
||||||
} else if (ResourceMgr_FileExists(rGfxPrintFontData)) {
|
} else if (ResourceMgr_FileExists(rGfxPrintFontData)) {
|
||||||
|
Loading…
Reference in New Issue
Block a user