Bump LUS (#191)
Some checks failed
GenerateBuilds / generate-port-o2r (push) Has been cancelled
GenerateBuilds / build-windows (push) Has been cancelled
GenerateBuilds / build-macos (push) Has been cancelled
GenerateBuilds / build-linux (push) Has been cancelled
GenerateBuilds / build-switch (push) Has been cancelled

* Bump LUS (#190)

* Bump LUS

* Disabled shader-based linear conversion on metal

* Fixed missing mInterpolationIndex

* Bump LUS

---------

Co-authored-by: KiritoDv <kiritodev01@gmail.com>

* restore console

* bump LUS

* Reverted linear conversion on shader

---------

Co-authored-by: KiritoDv <kiritodev01@gmail.com>
This commit is contained in:
Alejandro Asenjo Nitti 2025-04-18 03:22:13 -04:00 committed by GitHub
parent a4a465151a
commit 54a4d76b6f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 59 additions and 49 deletions

@ -1 +1 @@
Subproject commit ec63c7390050c452b34c3f78be7499f88fae2636
Subproject commit dda07c8ac6033ff98d37a05bc28406440c7769e4

View file

@ -258,7 +258,7 @@ void Background_DrawStarfield(void) {
float originalWidth = currentScreenWidth / 3;
float originalAspect = originalWidth / (currentScreenHeight / 3);
float renderMaskWidth = originalWidth * (OTRGetAspectRatio() / originalAspect);
float renderMaskWidth = originalWidth * (GameEngine_GetAspectRatio() / originalAspect);
float marginX = (currentScreenWidth - renderMaskWidth) / 2;
float renderMaskHeight = currentScreenHeight / 3;

View file

@ -41,7 +41,7 @@
#include "port/patches/DisplayListPatch.h"
#include "port/mods/PortEnhancements.h"
#include <Fast3D/gfx_pc.h>
#include <Fast3D/interpreter.h>
#include <filesystem>
#ifdef __SWITCH__
@ -453,14 +453,16 @@ void GameEngine::RunCommands(Gfx* Commands, const std::vector<std::unordered_map
return;
}
auto interpreter = wnd->GetInterpreterWeak().lock().get();
// Process window events for resize, mouse, keyboard events
wnd->HandleEvents();
gInterpolationIndex = 0;
interpreter->mInterpolationIndex = 0;
for (const auto& m : mtx_replacements) {
wnd->DrawAndRunGraphicsCommands(Commands, m);
gInterpolationIndex++;
interpreter->mInterpolationIndex++;
}
bool curAltAssets = CVarGetInteger("gEnhancements.Mods.AlternateAssets", 0);
@ -616,8 +618,16 @@ extern "C" uint32_t GameEngine_GetSamplesPerFrame() {
// End
Fast::Interpreter* GameEngine_GetInterpreter() {
return static_pointer_cast<Fast::Fast3dWindow>(Ship::Context::GetInstance()->GetWindow())
->GetInterpreterWeak()
.lock()
.get();
}
extern "C" float GameEngine_GetAspectRatio() {
return gfx_current_dimensions.aspect_ratio;
auto interpreter = GameEngine_GetInterpreter();
return interpreter->mCurDimensions.aspect_ratio;
}
extern "C" uint32_t GameEngine_GetGameVersion() {
@ -730,34 +740,33 @@ extern "C" uint32_t OTRGetCurrentHeight() {
return GameEngine::Instance->context->GetWindow()->GetHeight();
}
extern "C" float OTRGetAspectRatio() {
return gfx_current_dimensions.aspect_ratio;
}
extern "C" float OTRGetHUDAspectRatio() {
if (CVarGetInteger("gHUDAspectRatio.Enabled", 0) == 0 || CVarGetInteger("gHUDAspectRatio.X", 0) == 0 || CVarGetInteger("gHUDAspectRatio.Y", 0) == 0)
{
return OTRGetAspectRatio();
if (CVarGetInteger("gHUDAspectRatio.Enabled", 0) == 0 || CVarGetInteger("gHUDAspectRatio.X", 0) == 0 || CVarGetInteger("gHUDAspectRatio.Y", 0) == 0) {
return GameEngine_GetAspectRatio();
}
return ((float)CVarGetInteger("gHUDAspectRatio.X", 1) / (float)CVarGetInteger("gHUDAspectRatio.Y", 1));
}
extern "C" float OTRGetDimensionFromLeftEdge(float v) {
return (gfx_native_dimensions.width / 2 - gfx_native_dimensions.height / 2 * OTRGetAspectRatio() + (v));
auto interpreter = GameEngine_GetInterpreter();
return (interpreter->mNativeDimensions.width / 2 - interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio + (v));
}
extern "C" float OTRGetDimensionFromRightEdge(float v) {
return (gfx_native_dimensions.width / 2 + gfx_native_dimensions.height / 2 * OTRGetAspectRatio() -
(gfx_native_dimensions.width - v));
auto interpreter = GameEngine_GetInterpreter();
return (interpreter->mNativeDimensions.width / 2 + interpreter->mNativeDimensions.height / 2 * interpreter->mCurDimensions.aspect_ratio -
(interpreter->mNativeDimensions.width - v));
}
extern "C" float OTRGetDimensionFromLeftEdgeForcedAspect(float v, float aspectRatio) {
return (gfx_native_dimensions.width / 2 - gfx_native_dimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : OTRGetAspectRatio()) + (v));
auto interpreter = GameEngine_GetInterpreter();
return (interpreter->mNativeDimensions.width / 2 - interpreter->mNativeDimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) + (v));
}
extern "C" float OTRGetDimensionFromRightEdgeForcedAspect(float v, float aspectRatio) {
return (gfx_native_dimensions.width / 2 + gfx_native_dimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : OTRGetAspectRatio()) -
(gfx_native_dimensions.width - v));
auto interpreter = GameEngine_GetInterpreter();
return (interpreter->mNativeDimensions.width / 2 + interpreter->mNativeDimensions.height / 2 * (aspectRatio > 0 ? aspectRatio : interpreter->mCurDimensions.aspect_ratio) -
(interpreter->mNativeDimensions.width - v));
}
extern "C" float OTRGetDimensionFromLeftEdgeOverride(float v) {
@ -770,12 +779,14 @@ extern "C" float OTRGetDimensionFromRightEdgeOverride(float v) {
// Gets the width of the current render target area
extern "C" uint32_t OTRGetGameRenderWidth() {
return gfx_current_dimensions.width;
auto interpreter = GameEngine_GetInterpreter();
return interpreter->mCurDimensions.width;
}
// Gets the height of the current render target area
extern "C" uint32_t OTRGetGameRenderHeight() {
return gfx_current_dimensions.height;
auto interpreter = GameEngine_GetInterpreter();
return interpreter->mCurDimensions.height;
}
extern "C" int16_t OTRGetRectDimensionFromLeftEdge(float v) {
@ -803,9 +814,10 @@ extern "C" int16_t OTRGetRectDimensionFromRightEdgeOverride(float v) {
}
extern "C" int32_t OTRConvertHUDXToScreenX(int32_t v) {
float gameAspectRatio = gfx_current_dimensions.aspect_ratio;
int32_t gameHeight = gfx_current_dimensions.height;
int32_t gameWidth = gfx_current_dimensions.width;
auto interpreter = GameEngine_GetInterpreter();
float gameAspectRatio = interpreter->mCurDimensions.aspect_ratio;
int32_t gameHeight = interpreter->mCurDimensions.height;
int32_t gameWidth = interpreter->mCurDimensions.width;
float hudAspectRatio = 4.0f / 3.0f;
int32_t hudHeight = gameHeight;
int32_t hudWidth = hudHeight * hudAspectRatio;

View file

@ -12,7 +12,7 @@ typedef enum {
#ifdef __cplusplus
#include <vector>
#include <SDL2/SDL.h>
#include <Fast3D/gfx_pc.h>
#include <Fast3D/interpreter.h>
#include "libultraship/src/Context.h"
#ifndef IDYES
@ -48,21 +48,23 @@ class GameEngine {
static bool HasVersion(SF64Version ver);
};
extern "C" void* GameEngine_Malloc(size_t size);
Fast::Interpreter* GameEngine_GetInterpreter();
#define memallocn(type, n) (type*) GameEngine_Malloc(sizeof(type) * n)
#define memalloc(type) memallocn(type, 1)
extern "C" {
#else
#include <stdint.h>
#define memalloc(size) GameEngine_Malloc(size)
#endif
void* GameEngine_Malloc(size_t size);
bool GameEngine_HasVersion(SF64Version ver);
void GameEngine_ProcessGfxCommands(Gfx* commands);
float GameEngine_GetAspectRatio();
uint8_t GameEngine_OTRSigCheck(char* imgData);
uint8_t GameEngine_OTRSigCheck(const char* imgData);
uint32_t OTRGetCurrentWidth(void);
uint32_t OTRGetCurrentHeight(void);
float OTRGetAspectRatio(void);
float OTRGetHUDAspectRatio();
int32_t OTRConvertHUDXToScreenX(int32_t v);
float OTRGetDimensionFromLeftEdge(float v);
@ -83,5 +85,7 @@ void* GameEngine_Malloc(size_t size);
void GameEngine_GetTextureInfo(const char* path, int32_t* width, int32_t* height, float* scale, bool* custom);
void gDPSetTileSizeInterp(Gfx* pkt, int t, float uls, float ult, float lrs, float lrt);
uint32_t GameEngine_GetInterpolationFrameCount();
#define memalloc(size) GameEngine_Malloc(size)
#ifdef __cplusplus
}
#endif

View file

@ -3,8 +3,6 @@
#include "Engine.h"
#include "DisplayList.h"
extern "C" uint8_t GameEngine_OTRSigCheck(const char* data);
extern "C" void gSPDisplayList(Gfx* pkt, Gfx* dl) {
char* imgData = (char*)dl;

View file

@ -1,6 +1,6 @@
#include <libultraship.h>
#include <Fast3D/gfx_pc.h>
#include <Fast3D/interpreter.h>
#include "Engine.h"
extern "C" {

View file

@ -1,6 +0,0 @@
#include <libultraship.h>
#include <Fast3D/gfx_pc.h>
extern "C" {
}

View file

@ -9,7 +9,7 @@
#include <imgui_internal.h>
#include <libultraship/libultraship.h>
#include <Fast3D/gfx_pc.h>
#include <Fast3D/interpreter.h>
#include "port/Engine.h"
#include "port/notification/notification.h"
#include "utils/StringHelper.h"

View file

@ -1,10 +1,11 @@
#include "ResolutionEditor.h"
#include "UIWidgets.h"
#include "libultraship/src/Context.h"
#include "port/Engine.h"
#include <imgui.h>
#include <libultraship/libultraship.h>
#include <graphic/Fast3D/gfx_pc.h>
#include <graphic/Fast3D/interpreter.h>
/* Console Variables are grouped under gAdvancedResolution. (e.g. "gAdvancedResolution.Enabled")
@ -59,6 +60,7 @@ namespace AdvancedResolutionSettings {
for (unsigned short i = 0; i < sizeof(setting); i++)
update[i] = false;
static short updateCountdown = 0;
auto interpreter = GameEngine_GetInterpreter();
short countdownStartingValue = CVarGetInteger("gInterpolationFPS", 60) / 2; // half of a second, in frames.
// Initialise integer scale bounds.
@ -67,13 +69,13 @@ namespace AdvancedResolutionSettings {
short integerScale_maximumBounds = 1; // can change when window is resized
// This is mostly just for UX purposes, as Fit Automatically logic is part of LUS.
if (((float)gfx_current_game_window_viewport.width / gfx_current_game_window_viewport.height) >
((float)gfx_current_dimensions.width / gfx_current_dimensions.height)) {
if (((float)interpreter->mGameWindowViewport.width / interpreter->mGameWindowViewport.height) >
((float)interpreter->mCurDimensions.width / interpreter->mCurDimensions.height)) {
// Scale to window height
integerScale_maximumBounds = gfx_current_game_window_viewport.height / gfx_current_dimensions.height;
integerScale_maximumBounds = interpreter->mGameWindowViewport.height / interpreter->mCurDimensions.height;
} else {
// Scale to window width
integerScale_maximumBounds = gfx_current_game_window_viewport.width / gfx_current_dimensions.width;
integerScale_maximumBounds = interpreter->mGameWindowViewport.width / interpreter->mCurDimensions.width;
}
// Lower-clamping maximum bounds value to 1 is no-longer necessary as that's accounted for in LUS.
// Letting it go below 1 in this Editor will even allow for checking if screen bounds are being exceeded.
@ -136,9 +138,9 @@ namespace AdvancedResolutionSettings {
}
}
// Resolution visualiser
ImGui::Text("Viewport dimensions: %d x %d", gfx_current_game_window_viewport.width,
gfx_current_game_window_viewport.height);
ImGui::Text("Internal resolution: %d x %d", gfx_current_dimensions.width, gfx_current_dimensions.height);
ImGui::Text("Viewport dimensions: %d x %d", interpreter->mGameWindowViewport.width,
interpreter->mGameWindowViewport.height);
ImGui::Text("Internal resolution: %d x %d", interpreter->mCurDimensions.width, interpreter->mCurDimensions.height);
UIWidgets::PaddedSeparator(true, true, 3.0f, 3.0f);
@ -171,7 +173,7 @@ namespace AdvancedResolutionSettings {
} else if (showHorizontalResField) { // Show calculated aspect ratio
if (item_aspectRatio) {
UIWidgets::Spacer(2);
float resolvedAspectRatio = (float)gfx_current_dimensions.height / gfx_current_dimensions.width;
float resolvedAspectRatio = (float)interpreter->mCurDimensions.height / interpreter->mCurDimensions.width;
ImGui::Text("Aspect ratio: %.4f", resolvedAspectRatio);
} else {
UIWidgets::Spacer(enhancementSpacerHeight);