Implement Alt Assets Variable LUS (#619)

* Bump LUS to `94b755b77c0c0f566686c9d23fa4c15e23473a0c`.
Remove `CVAR_ALT_ASSETS` from LUS cvars cmake.
Change all pertinent `CVarGetInteger` calls for `CVAR_ALT_ASSETS` to `ResourceManager::IsAltAssetsEnabled`.
Implement frame-end toggle of `mAltAssetsEnabled`.

* Remove `ShouldClearTextureCacheAtEndOfFrame`.
Move prevAltAssets check to end of `Gfx_ProcessGfxCommands`.

* Missed initial `mAltAssetsEnabled` set.
This commit is contained in:
Malkierian 2024-05-31 14:26:04 -07:00 committed by GitHub
parent 57d4e62ed0
commit 63c293f78a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 23 additions and 19 deletions

View File

@ -17,7 +17,6 @@ set(CVAR_STATS_WINDOW_OPEN "${CVAR_PREFIX_WINDOW}.Stats" CACHE STRING "")
set(CVAR_ENABLE_MULTI_VIEWPORTS "${CVAR_PREFIX_SETTING}.EnableMultiViewports" CACHE STRING "")
set(CVAR_LOW_RES_MODE "${CVAR_PREFIX_SETTING}.LowResMode" CACHE STRING "")
set(CVAR_SIMULATED_INPUT_LAG "${CVAR_PREFIX_SETTING}.SimulatedInputLag" CACHE STRING "")
set(CVAR_ALT_ASSETS "${CVAR_PREFIX_ENHANCEMENT}.AltAssets" CACHE STRING "")
set(CVAR_GAME_OVERLAY_FONT "${CVAR_PREFIX_SETTING}.OverlayFont" CACHE STRING "")
set(CVAR_MENU_BAR_OPEN "${CVAR_PREFIX_SETTING}.OpenMenuBar" CACHE STRING "")
set(CVAR_PREFIX_CONTROLLERS "${CVAR_PREFIX_SETTING}.Controllers" CACHE STRING "")

@ -1 +1 @@
Subproject commit efeeaf34fee7bd7b21e9a9dbda84847e1601fd58
Subproject commit 94b755b77c0c0f566686c9d23fa4c15e23473a0c

View File

@ -20,8 +20,6 @@
#include "include/global.h"
#include "include/z64audio.h"
bool ShouldClearTextureCacheAtEndOfFrame = false;
namespace BenGui {
// MARK: - Delegates

View File

@ -14,8 +14,6 @@
#include "2s2h/DeveloperTools/WarpPoint.h"
#include "HudEditor.h"
extern bool ShouldClearTextureCacheAtEndOfFrame;
extern "C" {
#include "z64.h"
#include "functions.h"

View File

@ -101,6 +101,7 @@ OTRGlobals* OTRGlobals::Instance;
GameInteractor* GameInteractor::Instance;
extern "C" char** cameraStrings;
bool prevAltAssets = false;
std::vector<std::shared_ptr<std::string>> cameraStdStrings;
Color_RGB8 kokiriColor = { 0x1E, 0x69, 0x1B };
@ -148,6 +149,8 @@ OTRGlobals::OTRGlobals() {
// tell LUS to reserve 3 SoH specific threads (Game, Audio, Save)
context =
Ship::Context::CreateInstance("2 Ship 2 Harkinian", appShortName, "2ship2harkinian.json", archiveFiles, {}, 3);
prevAltAssets = CVarGetInteger("gAltAssets", 0);
context->GetResourceManager()->SetAltAssetsEnabled(prevAltAssets);
// Override LUS defaults
Ship::Context::GetInstance()->GetLogger()->set_level(
@ -565,8 +568,6 @@ extern "C" uint64_t GetUnixTimestamp() {
return now;
}
extern bool ShouldClearTextureCacheAtEndOfFrame;
extern "C" void Graph_StartFrame() {
#ifndef __WIIU__
using Ship::KbScancode;
@ -649,7 +650,7 @@ extern "C" void Graph_StartFrame() {
#endif
case KbScancode::LUS_KB_TAB: {
// Toggle HD Assets
CVarSetInteger(CVAR_ALT_ASSETS, !CVarGetInteger(CVAR_ALT_ASSETS, 0));
CVarSetInteger("gAltAssets", !CVarGetInteger("gAltAssets", 0));
// ShouldClearTextureCacheAtEndOfFrame = true;
break;
}
@ -738,12 +739,16 @@ extern "C" void Graph_ProcessGfxCommands(Gfx* commands) {
audio.cv_from_thread.wait(Lock);
}
}
//
// if (ShouldClearTextureCacheAtEndOfFrame) {
// gfx_texture_cache_clear();
// Ship::SkeletonPatcher::UpdateSkeletons();
// ShouldClearTextureCacheAtEndOfFrame = false;
//}
bool curAltAssets = CVarGetInteger("gAltAssets", 0);
if (prevAltAssets != curAltAssets) {
prevAltAssets = curAltAssets;
Ship::Context::GetInstance()->GetResourceManager()->SetAltAssetsEnabled(curAltAssets);
gfx_texture_cache_clear();
// TODO: skeleton patch, hooks
// SOH::SkeletonPatcher::UpdateSkeletons();
// GameInteractor::Instance->ExecuteHooks<GameInteractor::OnAssetAltChange>();
}
// OTRTODO: FIGURE OUT END FRAME POINT
/* if (OTRGlobals::Instance->context->GetWindow()->lastScancode != -1)
@ -777,6 +782,10 @@ extern "C" uint16_t OTRGetPixelDepth(float x, float y) {
return wnd->GetPixelDepth(x, adjustedY);
}
extern "C" bool ResourceMgr_IsAltAssetsEnabled() {
return Ship::Context::GetInstance()->GetResourceManager()->IsAltAssetsEnabled();
}
extern "C" uint32_t ResourceMgr_GetNumGameVersions() {
return Ship::Context::GetInstance()->GetResourceManager()->GetArchiveManager()->GetGameVersions().size();
}
@ -1218,7 +1227,7 @@ extern "C" SkeletonHeader* ResourceMgr_LoadSkeletonByName(const char* path, Skel
pathStr = pathStr.substr(sOtr.length());
}
bool isAlt = CVarGetInteger(CVAR_ALT_ASSETS, 0);
bool isAlt = ResourceMgr_IsAltAssetsEnabled();
if (isAlt) {
pathStr = Ship::IResource::gAltAssetPrefix + pathStr;

View File

@ -62,11 +62,11 @@ void SkeletonPatcher::ClearSkeletons() {
}
void SkeletonPatcher::UpdateSkeletons() {
bool isHD = CVarGetInteger(CVAR_ALT_ASSETS, 0);
auto resourceMgr = Ship::Context::GetInstance()->GetResourceManager();
bool isHD = resourceMgr->IsAltAssetsEnabled();
for (auto skel : skeletons) {
Skeleton* newSkel =
(Skeleton*)Ship::Context::GetInstance()
->GetResourceManager()
(Skeleton*)resourceMgr
->LoadResource((isHD ? Ship::IResource::gAltAssetPrefix : "") + skel.vanillaSkeletonPath, true)
.get();