feat: OptiScaler, off by default and turned on in Graphics: the builder places it, the game opens it, closes it on Esc and names it in logs #2985
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2985
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:feat/optiscaler-builder"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Players asked for OptiScaler, a GPL-3.0 mod that swaps upscalers. Until now
it only worked when a player copied it by hand as
winmm.dllbesidebuilds/default/longshot.exe, and nothing in thegame said it was there. A crash inside it read as
winmm.dll+0x…, as if it were Windows', and its default keys clashedwith Longshot's: Insert opened both menus, and Page Up, Page Down and End are Longshot's menu keys.
This PR is the whole of it, the builder's side and the game's:
for its menu key, Esc to close that menu, a log line and crash-report section naming it, and a footer line on the FPS
counter while OptiScaler handles the frame.
SHA-256-pinned, with its keys clear of Longshot's and its frame generation off. Turned off, it takes them out again,
and sets a hand-placed copy aside.
The launcher lists the licences: LongshotLauncher#392.
No other launcher change is needed: it writes nothing.
Design: llun (ship OptiScaler's GPL/MIT parts with Longshot, off by default and turned on in the game's own menu; the
builder owns and places its files like Streamline; AMD/Intel files come from Longshot's own modules; its menu key, F5,
set in the game and never one of Longshot's; Esc closes its menu; its frame generation off; the FPS counter says when
it's in; Longshot's own upscalers named first, and no tagline).
The builder
The game's setting is the line
optiscaler=1in the profile'ssettings.ini. The builder reads it at each play, eachRebuild (
build --profile) and the game's Restart now. Turned on, a Windows build puts these besidelongshot.exe:longshot.exewinmm.dllOptiScaler.dll(signed by SignPath Foundation; longshot.exe imports winmm, so Windows loads it at start)fakenvapi.dll,fakenvapi.iniOptiScaler.inidata/licenses/optiscaler/third_party/optiscaler/PROVENANCE.md)key is F5 and both frame-rate overlay keys are none. A key is rewritten to its default only when it is missing,
auto, not a key, or one of Longshot's keys (Insert, F1, Esc, Home, Page Up, Page Down, End, F10, F11). Any other keyis the player's and stays, so the menu key set in the game's Controls row survives.
which gives a black picture over Longshot's DLSS Frame Generation. Longshot's own FSR 3.1 and DLSS Frame Generation
already do that work. So
dlssg_to_fsr3_amd_is_better.dllis never taken or placed (a build takes out one placedearlier), and before each start
[FrameGen] Enabled=false,FGInput=nofg,FGOutput=nofgand[Menu] FGShortcutKey=-1are forced, whatever OptiScaler's menu saved. Every other line ofOptiScaler.inistays asit was.
verifychecks them and--repairputs them back. Turned off, the files go and
OptiScaler.inistays: OptiScaler's own settings and the player's keyare there again when it's turned on (delete the file for OptiScaler's defaults). A player's own OptiScaler (a DLL the builder
didn't place whose version strings name OptiScaler, as
winmm.dll,winhttp.dllordbghelp.dll) is left alone(
kept): nothing is placed beside it, and the builder's own files leave, so two copies never load. If nothing can be downloaded,the build goes on without OptiScaler (
optiscaler_skipped) and a play tries again 10 minutes later.infoliststhe
optiscalercapability and the record's state (build.optiscaler:placed,kept,skipped).DLL the builder didn't place, sitting under a name the game loads (
winmm.dll,winhttp.dllordbghelp.dll), isrenamed to
<name>.offin one rename when its version strings name OptiScaler. The name is recorded(
longshot_build.json'soptiscaler_aside). With the setting on, it is renamed back (if the name is free) and kept asthe player's. A name in the way or a refused rename is reported (
optiscaler_aside_taken,optiscaler_aside_failed)and never fails the play; renames the record can't be written for are taken back. A DLL that isn't OptiScaler is
never touched.
No name Longshot places itself (
amd_fidelityfx_loader_vk.dll,amd_fidelityfx_upscaler_vk.dll,libxess.dll) istouched: OptiScaler uses the FSR 4 and XeSS files of the modules the player chose. Every DLL sits at the folder's top
level, which is what mod-api's sandbox grants.
beside the files instead.
How it ships, and why. OptiScaler's files are fetched by pin, as every other third-party runtime is. On the
player's PC the builder downloads OptiScaler's own v0.9.5 release archive from GitHub once
(
Optiscaler_0.9.5-final.20261116.7z, 70 MB, checked against GitHub's SHA-256). It takes the files out withWindows' own
tar, which reads a .7z, checks each against its own SHA-256, keeps them in<cache>/runtimes/anddeletes the archive.
I didn't put them inside the release file because that doesn't fit Longshot's release design. A release's
longshot-buildercarries only the tree (the repository holds no binaries; its largest file is 2.7 MB) andtools.lockarchives in Longshot's store, which only a MagicBeanAdmin Release run can upload. It would also add26 MB to every Windows player's download, while most players never turn OptiScaler on. Fetching by pin gives the same
official bytes, checked the same way, with no admin step. The licenses and the source offer still ship in the release,
in the tree. If the team prefers the store route later, the pins and the placement stay as they are; only where the
archive comes from changes.
The game
optiscaler=with the other rows. The builder reads it before the gamestarts, so a change applies at the next start (Restart now).
Longshot's own FSR 3.1, DLSS, FSR 4 and XeSS named first); and the licences (OptiScaler GPL-3.0, fakenvapi MIT).
aside (
winmm.dll.off; the builder does that).menu_close, which acts asInsert), then gives OptiScaler its menu key once Longshot's menu has closed, posted to the window as Esc's close is.
Where that key is Longshot's, off, or bound to a game control, its line says to choose another in Controls.
above OptiScaler's drops that key's messages (the menu still reads the key's state).
does, and OptiScaler's menu opens once Longshot's has closed and the key is let go.
the game that starts again (
menu_restarting).its line saying the key stays OptiScaler's until another is chosen in its row and the game starts again. A control
that had the key already (from before, or by hand) is named on the OptiScaler menu key row and on Open OptiScaler.
foreign_dlls::offered_keys). Never Insert, F1, Esc, Home, Page Up,Page Down, End, F10 or F11, and never a key bound to a control.
[Menu] ShortcutKeyline ofOptiScaler.ini. It writes a new copy beside it, moves itover the old one, and keeps the file's line endings.
with a line saying the builder sets the key (F5) when it starts the game. The check (
file_writable) opens the filefor writing and closes it, writing nothing.
the key OptiScaler started with.
the keys' state.
OptiScaler's menu.
SendInputdoesn't work for this: OptiScaler 0.9.5 drops the game'sSendInputwhile its menu is open.gpu/vk/foreign_dlls.h).System32 DLL, an ASI plugin, or OptiScaler under any name.
takes ~145 ms for OptiScaler's 26 MB). A signature Windows could neither trust nor reject reads "signature not
checked (error …)", never "not signed".
report: foreign WINMM.dll (OptiScaler 0.9.5-final (90d9568), signed by SignPath Foundation, in place of Windows' own). Names, versions and signers only, never a folder.builder/crates/crashfacts.rs) and gives it its own section, "DLLs besidethe game that are not Longshot's".
OptiScaler 0.9.5" under the upscaler's line only while OptiScaler handles the frame: NVIDIA DLSS or DLAA drew it in
gameplay, OptiScaler is loaded, and its
OptiScaler.initakes DLSS's inputs ([Inputs] EnableDlssInputs, read againat most every 2 s).
swap the engine the line above names, which Longshot can't see, so the line names none.
counter is identical. With it, the footer is one line taller, and a window too short for everything drops this line
first.
docs/user/optiscaler.md(new): Longshot's own upscalers first, turning it on, why its frame generationstays off, putting it in by hand, using it, and what to do when something goes wrong; Windows only. Also updated: the
Graphics and Controls guide, the
optiscaler=line in the switches reference, andbuild.md's OptiScaler.
Read first:
builder/crates/build-driver/src/runtimes.rs(OPTISCALER_*,fetch_optiscaler, andarchived_runtime,which is Streamline's archive fetch made general),
builder/crates/build-driver/src/optiscaler.rs(the setting, thekeys and the ini lines),
build.rs'soptiscaler_settings,play.rs(Profile::optiscaler_wanted,RebuildReason::OptiScaler, the keys before each start); thengpu/vk/foreign_dlls.cpp,gpu/vk/menu/optiscaler.cpp,vk_menu.cpp'smenu_closeandoptiscaler_keys_tickcall, and the footer's line 6.Testing
Tested: Windows 11 (10.0.26300), RTX 5080, NVIDIA 621.40, Ryzen 9 7900X. Game folders built by this branch's
longshot-builder from the .nup through the job queue (DLSS module, Ocarina of Time), and this branch's runtimes over
main's base (
56823e27a), through the queue.The builder:
First build with the setting on: the builder downloaded the v0.9.5 archive from GitHub, took out the five files with
System32 tar, each matching its pin, and left no archive behind. The game folder got
winmm.dll, the three otherfiles and
data/licenses/optiscaler/.verifyreported the folder intact (56 files) and countedOptiScaler.inias the player's data.
Played:
WINMM.dllfrom the game folder is in the game's module list. OptiScaler's own log says "OptiScalerv0.9.5-final (90d9568) loaded", "working as winmm.dll",
Menu.ShortcutKey: 0x74,Menu.FpsShortcutKey: -1,Menu.FpsCycleShortcutKey: -1. It hooked Vulkan (vkQueueSubmit, vkCreateInstance and vkCreateDevice) and NGX(
NVSDK_NGX_VULKAN_Init_ProjectID_Extresult 1), and the game ran.A player's own OptiScaler (OptiScaler.dll plus one byte, so not the pinned file) put by hand as
winmm.dll. Withoptiscaler=0, a Rebuild set it aside aswinmm.dll.off(no build needed). Withoptiscaler=1, it went back aswinmm.dll, and the update recordedoptiscaler: keptwith none of the builder's files placed over it. The readerfound
OptiScalerin OptiScaler.dll's version strings and not in Windows' own winmm.dll or dbghelp.dll.Frame generation off (@
ec2b30550): the build placedwinmm.dll,fakenvapi.dll/.iniand the licenses, with nodlssg_to_fsr3_amd_is_better.dll. In the game, OptiScaler's own log readFrameGen.Enabled: false,FrameGen.FGInput: nofg,FrameGen.FGOutput: nofg,Menu.FGShortcutKey: -1andMenu.ShortcutKey: 0x74.An update from an earlier build: the builder at
b78d0f558(before frame generation was turned off) placed OptiScalerwith
dlssg_to_fsr3_amd_is_better.dllanddata/licenses/optiscaler/LICENSE-dlssg-to-fsr3.md, both on disk and inthe note. The next build with this branch's builder logged "LICENSE-dlssg-to-fsr3.md, dlssg_to_fsr3_amd_is_better.dll
removed", took both out of the note too, and kept the rest of OptiScaler placed. A player's own copy of that DLL
(other bytes, not in the note) stayed through an off build and an on build, and
verifylisted it as not thebuilder's, left as it is.
Setting off (before
98812f6a0, when Off still removed the ini; nooptiscaler=line; profile.json's leftover"optiscaler": trueignored): the build removed alleight files and
OptiScaler.ini. Setting on again (optiscaler=1): the build placed them back from the cache(7 s, no download), with the F5/off keys written into a fresh
OptiScaler.ini.BeanBot's review fixes (@
3474f9655), same profile, through the queue:OptiScaler.ini(with their F7 key) there before On: a Rebuild withoptiscaler=1placedOptiScaler beside it and left it the player's (F7 kept; frame generation and the overlay keys forced off as for
any). With
optiscaler=0, the next Rebuild kept it and removed only the builder's files.Its settings kept through Off (@
98812f6a0, llun's decision), in the game through the queue: a play withoptiscaler=1placed OptiScaler and seeded its ini (F5), and the game loggedreport: foreign WINMM.dll (OptiScaler …). Controls → OptiScaler menu key set F6. Graphics → OptiScaler Off, then Restart Now: the builderremoved
winmm.dll, fakenvapi's files and the licenses, keptOptiScaler.ini(F6), and the restarted game had noOptiScaler. On, then Restart Now: OptiScaler placed again with the same ini, not reseeded (F6 kept, frame generation
still forced off), and F6 opened OptiScaler's menu.
The game (OptiScaler 0.9.5 from its GitHub release, SHA-256 checked against GitHub's digest, copied in as
winmm.dll):report: foreign WINMM.dll (OptiScaler 0.9.5-final (90d9568), signed by SignPath Foundation, in place of Windows' own), from the background scan.NVSDK_NGX_VULKAN_CreateFeature1 … Creating new dlss upscaler.In its menu I switched the upscaler to FSR 3.1.6, and its overlay read "Vulkan | FSR 3.1.6 | Input: DLSS".
optiscaler=1and showed "Restart needed"; Off savedoptiscaler=0. The help panel shows its three paragraphs, nothing cut off.OptiScaler once), and Longshot's menu didn't open.
auto, the row showed Insert and its line said Longshot uses it.showed Insert, the key OptiScaler still ran with, and pointed to Controls. After a restart, F7 worked.
stepping skipped F7.
stepping right from F5 went to F7, and left from F7 back to F5; the game logged "OptiScaler's menu key set to F7"
and then "… to F5", and
OptiScaler.iniread0x76, then0x74.Minus control uses too: choose another", Open OptiScaler was locked with the same words, and stepping went F5 → F6
(the warning gone) and back to F4, skipping F5.
OptiScaler.iniread-only, the row was locked with its builder line, and stepping left the fileunchanged.
a56796748):Minus's keyboard cell listened, the cell kept listening with "F5 is OptiScaler's menu key and stays its own…", and
settings.inikeptkey_minus=77,0.then OptiScaler's opens", then "OptiScaler's menu opened").
Now restarted the game; no "opened" line in that run, and the new run started with OptiScaler's menu shut.
opened OptiScaler's.
VK_ERROR_DEVICE_LOST, an NVIDIA graphics exception) during the intromovie, before any menu opened; the same build started cleanly the four times after. Nothing this PR changes runs
there; noted here rather than left out.
present with DLSS in gameplay, under "Upscaling: DLSS Quality". It is whole in the narrowest case (Small, a 1280x720
window, below Graph, version and hardware at every level).
black picture (GPU at 100%), and turning Longshot's frame generation off brought the picture back. That's why it stays
off.
Together, through the builder with a profile: Graphics > OptiScaler On wrote
optiscaler=1, and Restart now (exit 75)ran the builder's fast check ("OptiScaler choice changed") and an update. The game then logged the
report: foreignline above, the record said
placed, and OptiScaler.ini had F5 and the other keys off. F5 opened OptiScaler's menu, andEsc closed it while Longshot's menu stayed shut. Off with Restart now (before
98812f6a0) removed every file, its licenses andOptiScaler.ini. No screenshots: the menu draws in the game's own font, a game file.
Game-free checks:
build-driver:optiscaler::tests: the placed menu key is F5 and the overlay keys none, never one of Longshot's. A player's key iskept, and one of Longshot's,
autoor unreadable goes back to its default. OptiScaler's frame generation lines andits key are forced off whatever they held. CRLF and BOM are kept, a missing line or
[Menu]is added, a non-UTF-8file is left alone, and the game's
optiscaler=line is read. A DLL is recognized as OptiScaler by its versionstrings alone. A player's own copy is set aside and put back, a name in the way is left alone and reported, and the
builder's own copy or a non-OptiScaler DLL is never renamed.
runtimes::tests: the pins, no AMD/Intel/Microsoft file and no Longshot name. The archive is taken once and thesettings are seeded only when missing. A player's own OptiScaler is kept. Offline, OptiScaler is left out with its
own warning and mark and retried 10 minutes later. The tree's licenses are there, and the GPL text is byte-for-byte
OptiScaler's.
play::tests: the setting changes the profile's key only while on and only on Windows, and profile.json isuntouched. A skipped OptiScaler is retried, and its keys are settled before each start only for the builder's own
OptiScaler. A rename aside whose record can't be written is taken back.
3474f9655) and after: Off, skipped and kept builds leaveOptiScaler.inibyte for byte,and On again keeps the player's lines and settles the forced ones without reseeding; a missing ini is seeded again
(
build::optiscaler_settings_tests); a player's OptiScaler aswinhttp.dllordbghelp.dllis keptalone, nothing downloaded or placed, the builder's own files out (
runtimes); a non-OptiScaler DLL under thosenames, or one the builder placed, isn't taken for the player's.
tests/test_foreign_dlls.py(new): which modules count, the log text (no folder), the unchecked-signature text; theini's keys (auto, hex, decimal, -1, other sections), the key names, the clashing and offered keys; the one-line ini
rewrite (CRLF, a missing line, a missing
[Menu]); whether OptiScaler takes DLSS's inputs; on Windows, a real scan ofa
version.dllbeside the test program (found, not signed), one in another folder (not listed), the backgroundstart's single log line, and
file_writable(a writable file, a read-only one, a missing one). The same check passeson Linux (WSL Ubuntu 24.04, g++), the Windows parts left out.
tests/test_fps_stats.cpp: the OptiScaler line's text, and that only DLSS or DLAA drawn by the engine counts.cargo test -p crash the_foreign_dlls_line_is_read.test_menu_ini_keys(the new keysoptiscalerandoptiscaler_keyin FROZEN, on purpose),test_settings_table,test_dlss5_menu(the rows' order),test_keyboard_menu_option,test_menu_i18n. Ata56796748the menu checks (test_foreign_dlls,test_menu_ini_keys,test_settings_table,test_dlss5_menu,test_menu_i18n,test_menu_hooks,test_menu_text_field,test_fps_stats,test_utf8_paths,test_keyboard_menu_optionwith g++) pass again;test_menu_keysfails as onmain(a stale source cut).cargo clippy -D warningsandcargo fmt --checkare clean, andbuild-driver's 191 tests pass (at98812f6a0). The longshot-buildertests that fail here (6 unit tests, 3 in
hot_split.rs) are this PC's Windows path-spelling and no-clang cases in teststhis PR doesn't touch.
mise run testat1300dab32(Windows, 12 at once): 826 passed, 54 failed, 48 skipped. The same54 checks fail on
main@56823e27aon this PC, and none other does here: POSIX-only calls, stale source cuts andmissing tools on Windows. CI's Linux run is the reference.
Still to test:
and restart. Expecting OptiScaler's menu on F5, Open OptiScaler and Esc working, the
report: foreignline, and itsupscaler list naming the game's FSR 4 / XeSS files. Whether Longshot's NVIDIA DLSS row becomes available with
OptiScaler's NGX in place is the open question (
@Beanstalk, once a BigBean approves).optiscaler=1changes nothing (no files, no update, no rows) (by hand, any Linux PC).Measurements
Verdict: nothing changes for a profile with OptiScaler off, which is the default. Turned on, it costs one 70 MB
download per PC, 26.6 MB in the game folder, and a ~145 ms signature check off the renderer's start.
Setup: Windows 11, Ryzen 9 7900X, NVMe, this PC's connection. A game folder built by this branch from the .nup with
warm caches.
56823e27a98812f6a0tarextraction 2.7 s, on top of an update (the whole update took under a minute here)<cache>/runtimes/Nothing per frame: the scan runs once, and the rows only do work when used. The footer's check reads
OptiScaler.iniat most every 2 s, and only while the counter's footer shows. The game's frame rate with OptiScaler loaded is
OptiScaler's own, and only for players who turn it on.
No switch is added or changed:
LONGSHOT_CACHEappears only in a test's environment, andLONGSHOT_KEYSis a Rustconstant (
build_driver::optiscaler::LONGSHOT_KEYS, the keys OptiScaler's may not be), not a variable.Risks
rows apart from the Off switch, and the counter is the same.
and the
report: foreignline makes them visible in logs and crash reports. Turning it off in the game removes everyfile the builder put there at the next start.
OptiScaler.ini: the game writes it only when the player changes the key, and only that line.main; read from its code, not run): the game folder is never written frominside, so the key row is locked, and OptiScaler's own menu can't save its settings there either (they last until the
game closes). How the sandbox
could let it save without letting the ini pick DLLs to load is in a comment below, for mod-api's maintainer.
(
optiscaler_skipped, not retried at a play for that pin), and the game runs without OptiScaler.through the builder.
longshot_options.inigainsoptiscaler=0, which an oldergame ignores.
Checklist
Ready for review
main; the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named).main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.(One new part,
third_party/optiscaler/(fakenvapi's upstream license text, unmodified, and its PROVENANCE.md withtree-sha256), as the third_party rule asks. No existing part changed and no binary committed. OptiScaler is GPL-3.0
and fakenvapi is MIT, both compatible with Longshot's GPL-3.0.)
When it applies
tests/that reads changed source is updated, not weakened.llvm-mingw. Linux:
foreign_dlls.cpp,menu/optiscaler.cppandvk_menu.cppcompile with g++ on WSL Ubuntu 24.04,and
test_foreign_dlls.pypasses there; the Windows parts are under_WIN32. Paths: module paths come fromGetModuleFileNameW, made UTF-8;file_writableopens withCreateFileWfrom UTF-8; the narrowifstreamandMoveFileExAare UTF-8 under the exe'sactiveCodePageUTF-8, which the game requires at its start.)Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
The user's answer ("Rename them aside"): with optiscaler off, before each play, Rebuild and Restart now, a DLL the builder did not place under a name the game loads (winmm, winhttp, dbghelp) whose version strings name OptiScaler is renamed to <name>.off in one rename, recorded in longshot_build.json (optiscaler_aside), and renamed back when the setting is on, then kept as the player's. A name in the way or a refused rename is said (optiscaler_aside_taken, optiscaler_aside_failed) and never fails the play. Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in game: Windows 11 (10.0.26300), RTX 5080, this branch's longshot-builder through the job queue, Ocarina of Time with the DLSS module: with optiscaler=1 the build downloaded OptiScaler v0.9.5's archive, placed winmm.dll and its files (verify: intact), and in the game OptiScaler's log said 'v0.9.5-final (90d9568) loaded', 'working as winmm.dll', Menu.ShortcutKey 0x74 (F5), FGShortcutKey 0x75, FPS keys -1, and it hooked Vulkan and NGX while the game ran. optiscaler=0 took every file and OptiScaler.ini out; on again placed them back from the cache in 7 s. A hand-placed OptiScaler was renamed to winmm.dll.off while off and back (kept) when on. Not seen by eye: pressing F5 to open the overlay (no screen control on this run); it is in Still to test.
Possibly related, for context:
Description: no switch added (LONGSHOT_CACHE is a test's environment, LONGSHOT_KEYS a Rust constant), and the tests/ checks that read the changed builder files pass unchanged.
feat(builder): OptiScaler beside the game when the game's setting turns it on, its keys clear of Longshot'sto WIP: feat(builder): OptiScaler beside the game when the game's setting turns it on, its keys clear of Longshot'sTested with the game side: a local combined build (this branch + feat/optiscaler-foreign-dlls) on Windows 11, RTX 5080. Graphics > OptiScaler On plus Restart now placed it (record placed, keys F5/F6/-1/-1), F5 opened OptiScaler's menu, and Off plus Restart now removed every file. The NVIDIA F5 item is out of Still to test.
OptiScaler's frame generation is now kept off (llun's decision). On Vulkan, OptiScaler 0.9.5's only frame generation is Nukem9's dlssg-to-fsr3, which gives a black picture over Longshot's DLSS Frame Generation, and Longshot's own FSR 3.1 and DLSS Frame Generation already do that work. dlssg_to_fsr3_amd_is_better.dll and its license are no longer taken or placed; a build takes out one placed earlier. Before each start, [FrameGen] Enabled=false, FGInput=nofg, FGOutput=nofg and [Menu] FGShortcutKey=-1 are forced. Ran on this PC: OptiScaler logged FrameGen.Enabled false, FGInput/FGOutput nofg, FGShortcutKey -1, menu key F5.
Tested the update path for the dropped frame generation on this PC. A game folder built by the builder before this change (
b78d0f558) had dlssg_to_fsr3_amd_is_better.dll and LICENSE-dlssg-to-fsr3.md placed and noted. The next build with this branch's builder removed both (log: "LICENSE-dlssg-to-fsr3.md, dlssg_to_fsr3_amd_is_better.dll removed"), dropped them from the note, and kept OptiScaler placed. A player's own copy of the DLL (other bytes, not noted) stayed through off and on builds; verify lists it as not the builder's.WIP: feat(builder): OptiScaler beside the game when the game's setting turns it on, its keys clear of Longshot'sto WIP: feat: OptiScaler, off by default and turned on in Graphics: the builder places it, the game opens it, closes it on Esc and names it in logsFor mod-api's sandbox: OptiScaler's settings, and which DLLs they can load
A handoff for mod-api's maintainer (the sandbox's author), from this PR's work. Nothing here changes mod-api; this PR
targets
main, which has no sandbox. llun asked for it to be written up and left to the maintainer.Where it stands
This PR ships OptiScaler (off by default; the game's Graphics → OptiScaler turns it on, and the builder places it as
winmm.dllbesidelongshot.exe, withfakenvapi.dll/.iniandOptiScaler.ini, all at the folder's top level).Under mod-api's sandbox, as
origin/mod-apistands (e132adfa0), read from the code (not run under mod-api):0x1200a9includesFILE_EXECUTE).sandbox_windows/plan.rsgrants the game folder Read only ("the game folder (neverwritten)"); the single-file writes (
Access::FileWrite) are the user folder'sUSER_FILES. OptiScaler runs in thegame's process, so its own menu's Save of
OptiScaler.iniis refused, and changes last until the game closes. Thegame's Controls → OptiScaler menu key row sees it can't write the file and locks itself, saying the builder sets the
key. The builder, outside the sandbox, still rewrites the key and frame-generation lines before each start.
That is safe as it is. The rest is for if mod-api wants OptiScaler's Save to work.
Why a write grant on
OptiScaler.inialone is not enoughOptiScaler's signature (SignPath Foundation) and the builder's SHA-256 pin vouch for
winmm.dll. They say nothing aboutOptiScaler.ini, which is plain text that tells that genuine DLL what else to load. In 0.9.5's ini:OptiDllPath,NvngxPath,NvngxDlssPath,NvapiPath,FfxDx12Path,FfxDx12SRPath,FfxDx12FGPath,FfxDx12RRPath,FfxDx12RCPath,FfxVkPath,XeSSPath,XeFGPath,XeLLPath,XeSSDx11Path,NvngxFeaturePath(andTTFFontPath, a font);[Plugins]:Path,LoadAsiPlugins,LateAsiPluginsDelay,LoadSpecialK,LoadReshade;OverrideNvapiDll.Access::Writeis0x1301bf, which includesFILE_EXECUTE(0x20), andAccess::Read(0x1200a9) does too. Sowith the ini writable, code in the container could write a DLL into a folder it may write (its caches, logs), point a
path line or
[Plugins] Pathat it, and have the signed OptiScaler load it at every later start: from a mod's scriptto native code in the container, lasting across starts.
What would close that, for every loader and not only OptiScaler
sandbox_windows.rssets one mitigation today(
EXTENSION_POINT_DISABLE,1 << 32). Add, in the samePROC_THREAD_ATTRIBUTE_MITIGATION_POLICYvalue (valuesfrom MinGW's
winbase.h):PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_LOW_LABEL_ALWAYS_ON(1 << 56): the container runs at lowintegrity, so files it creates should carry the Low label, and Windows then refuses to map them as images. To
confirm by test: a DLL written from inside the container, then
LoadLibrary'd, is refused; the builder's and theplayer's own DLLs (medium label) still load.
PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_REMOTE_ALWAYS_ON(1 << 52): nothing loads from a networkshare.
IMAGE_LOAD_PREFER_SYSTEM32(1 << 60): it would load System32'swinmm.dllbefore the game folder's,so OptiScaler (and any proxy-DLL mod a player put there) would stop loading.
0x20fromAccess::Write's mask for files (0x13019f).Careful: on a folder,
0x20isFILE_TRAVERSE. The container's token may not bypass traverse checks, so this mayneed a separate inherit-only ACE for files, or be left out with 1 in place.
To check first: nothing legitimate maps an image from a written folder (driver shader caches are data, and the
mods are read-only grants).
With 1 in place, a grant on
OptiScaler.inibecomes low-risk:OptiScaler.inialone, written in place (Access::FileWrite: no DELETE, no rename), and only when thebuilder placed OptiScaler (
longshot_build.json'soptiscaler: placed). Its Save and the game's key row then workunder the sandbox. Every other refusal stays, with a test for the new grant beside
the_masks_and_the_names.main, in the builder (a follow-up to this PR, if 3 goes ahead): before each start, keep a…Pathline onlyif it names a file at the game folder's top level whose SHA-256 is one the builder placed (its note: Longshot's
DLSS/FSR 4/XeSS module DLLs, OptiScaler's pins); anything else goes back to
autowith a warning. Under the sandbox,the
[Plugins]lines andOverrideNvapiDllare forced off. The builder already forces the frame-generation and keylines the same way (
build-driver/src/optiscaler.rs,settle), and OptiScaler reads these lines at its start,after the builder has run. A rule on the key's name (
…Path) keeps working when a later OptiScaler adds new paths.To check: that OptiScaler doesn't re-read its path lines from the file mid-run.
1 is worth having whatever is decided about OptiScaler: it stops any planted DLL, whoever points at it.
WIP: feat: OptiScaler, off by default and turned on in Graphics: the builder places it, the game opens it, closes it on Esc and names it in logsto feat: OptiScaler, off by default and turned on in Graphics: the builder places it, the game opens it, closes it on Esc and names it in logsRecommendation: Request changes. Turning OptiScaler off can delete a player’s existing settings, and restoring a hand-placed copy under another supported proxy name can load two copies. The menu also mishandles restart confirmation and Windows paths containing non-ASCII characters.
The change adds an opt-in Windows integration for OptiScaler, including builder placement, menu controls and crash-report identification. The reported NVIDIA run shows the main path working, but ownership and menu error cases need fixes.
Blocking (4): must change before merging.
builder/crates/build-driver/src/build.rs:346: Removing OptiScaler deletes its settings even when the builder did not create them. (more on the line) Do: Record whether the builder created the ini and only remove it when that record establishes ownership; preserve pre-existing settings.builder/crates/build-driver/src/runtimes.rs:882: The ownership check only looks at the builder's destination names, not the other proxy names supported by the restore path. (more on the line) Do: Detect an existing player OptiScaler under every supported proxy name before placing any builder-owned copy, and retain it as kept.gpu/vk/menu/optiscaler.cpp:197: The OptiScaler key is sent on a timer even when the requested menu close opens a restart question. (more on the line) Do: Send the key only after Longshot's menu has actually closed, and cancel or defer the action while the restart question is pending.gpu/vk/menu/optiscaler.cpp:276: The ini path is UTF-8, but the file streams and MoveFileExA use Windows narrow-path handling. (more on the line) Do: Convert the UTF-8 path to a wide path and use wide-capable file operations for reads, temporary writes, replacement and deletion, including the footer's ini read.Should fix (2): not blocking, but worth doing before merging.
builder/crates/build-driver/src/play.rs:1060: A successful rename is not undone when writing its record fails. (more on the line) Do: Make the record and rename recoverable together, for example by rolling back the rename on record failure or recording intent before it.tests/test_foreign_dlls.py:180: The Windows test derives a C compiler by rewriting the C++ compiler name and ignores CC. (more on the line) Do: Pass the selected C compiler from the test runner and use it directly for the C DLLs.Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
@fixcan do L1, L2, L3, L4, L5 and L6.Checks: Still running: 11 checks.
More: does it help, other systems, switches, what was read
Does it help: Yes for the tested feature path: the author reports placement, DLSS input interception, menu opening and removal on Windows 11 with an RTX 5080. Other supported Windows GPU configurations have not been shown working.
Other systems: The integration changes Windows startup, game-folder ownership and input handling. Linux ignores the setting; AMD and Intel Windows paths remain untested in the supplied evidence.
Switches: The saved Graphics option optiscaler defaults to 0 (Off), an appropriate opt-in default for a third-party mod. The switch reference is updated.
Reviewed:
1300dab323against56823e27a1: Read the repository instructions and contribution rules, commit messages, the new OptiScaler builder and renderer implementations, and the relevant startup, menu and ownership changes. Skimmed the remaining diffs, documentation, tests and provenance; did not read every changed file or all surrounding code in full.; nothing run (a code review).Checked and fine:
Testing: No commands that build, run tests or execute project code were run. The supplied CI checks are still running.
Overlaps and merge order: Not established from the available offline checkout.
Automated code review by BeanBot (gpt-6.1-terra), asked for by BeanBot, as llun took it out of WIP. Nothing was run; a maintainer decides.
@ -326,0 +343,4 @@r.log(format!("OptiScaler's shortcut keys could not be set ({why})"));}} else if was == Some(runtimes::SL_PLACED) && !runtimes::streamline_stays(fetched.optiscaler) {match std::fs::remove_file(&ini) {L1 (blocking): Removing OptiScaler deletes its settings even when the builder did not create them.
When: A player already has an OptiScaler.ini but no conflicting DLL. Placement preserves that file, records OptiScaler as placed, and the next Off build removes the player's existing settings.
Do: Record whether the builder created the ini and only remove it when that record establishes ownership; preserve pre-existing settings.
@ -988,0 +1057,4 @@crate::optiscaler::set_aside(&crate::layout::game_folder(folder), on, &rec.optiscaler_aside);if aside != rec.optiscaler_aside {rec.optiscaler_aside = aside;if let Err(e) = rec.write(folder) {L5 (should fix): A successful rename is not undone when writing its record fails.
When: If winmm.dll is renamed to winmm.dll.off but the record cannot be written, a later start has no recorded name to restore when the setting is turned on. The player's copy remains disabled.
Do: Make the record and rename recoverable together, for example by rolling back the rename on record failure or recording intent before it.
@ -691,2 +879,4 @@unzip: impl FnMut(&Path, &[&str], &Path) -> std::result::Result<(), String>,r: &Reporter,) -> &'static str {let dests: Vec<PathBuf> = files.iter().map(|f| out.join(f.dest)).collect();L2 (blocking): The ownership check only looks at the builder's destination names, not the other proxy names supported by the restore path.
When: A hand-placed OptiScaler as winhttp.dll is restored when the setting turns on. The build sees no conflicting winmm.dll and installs its own copy there, so both proxy DLLs load instead of keeping the player's copy alone.
Do: Detect an existing player OptiScaler under every supported proxy name before placing any builder-owned copy, and retain it as kept.
@ -0,0 +194,4 @@void open() {if (open_locked()) return;menu_close();press_menu_key(live_key(kMenu), 150);L3 (blocking): The OptiScaler key is sent on a timer even when the requested menu close opens a restart question.
When: With a restart-requiring setting changed, choosing Open OptiScaler makes menu_tick show the restart prompt instead of closing Longshot's menu. The timer nevertheless opens OptiScaler over that prompt, leaving both menus active.
Do: Send the key only after Longshot's menu has actually closed, and cancel or defer the action while the restart question is pending.
@ -0,0 +273,4 @@ok = (bool)out.flush();}#ifdef _WIN32ok = ok && MoveFileExA(temp.c_str(), path.c_str(), MOVEFILE_REPLACE_EXISTING | MOVEFILE_WRITE_THROUGH);L4 (blocking): The ini path is UTF-8, but the file streams and MoveFileExA use Windows narrow-path handling.
When: When the game folder contains characters outside the Windows active code page, the builder can place OptiScaler and the wide writable check can succeed, but the game cannot reliably read or replace its ini. The key row and Open OptiScaler then use the wrong default or fail to save.
Do: Convert the UTF-8 path to a wide path and use wide-capable file operations for reads, temporary writes, replacement and deletion, including the footer's ini read.
@ -0,0 +177,4 @@# (two empty DLLs: one named as Windows' version.dll beside the program, one in another folder)dll = t / "empty.c"dll.write_text("int longshot_foreign_dll_test(void) { return 1; }\n", encoding="utf-8")cc = args.cxx.replace("clang++", "clang").replace("g++", "gcc")L6 (should fix): The Windows test derives a C compiler by rewriting the C++ compiler name and ignores CC.
When: With CXX set to a differently named wrapper or cross compiler and CC set to the working C compiler, the test invokes the unchanged CXX name for the DLL builds instead of CC, which can fail or use the wrong toolchain.
Do: Pass the selected C compiler from the test runner and use it directly for the C DLLs.
Tested the bound-key skip on this PC (Windows 11, RTX 5080, runtimes of this head through the queue): with F6 bound to a game control (Minus, second keyboard slot) and OptiScaler's other keys off, Controls → OptiScaler menu key stepped F5 → F7 and back F7 → F5, skipping F6 both ways. The game logged each write, and OptiScaler.ini read 0x76, then 0x74. Moved from Still to test into Tested.
New commit
a56796748(llun's design): OptiScaler's menu key comes first while OptiScaler is in the game. No control can be bound to it (the Controls page keeps listening and says why), and a control that had it already is named on the key row and on Open OptiScaler. While Longshot's menu is open the key is kept from OptiScaler. Pressed there, it closes Longshot's menu and OptiScaler's opens once Longshot's has closed. With the restart question it waits: Later opens it, Restart Now doesn't (nor in the game that starts again). Open OptiScaler takes the same path. Tested in the game on this PC; details are in the description's Testing.BeanBot's review (L6): the check rewrote the C++ compiler's name into a C compiler's and ignored CC. It now takes --cc {cc} from the test runner, as the other checks with C parts do, and builds its two DLLs with it. Co-Authored-By: Claude Opus 5.5 <[email protected]>Answers to BeanBot's review (of
1300dab32):a56796748, pushed before this review was read. Open OptiScaler (and OptiScaler's key with Longshot's menu open) no longer presses on a timer. OptiScaler's key is kept from it while Longshot's menu is open, and it's given to OptiScaler only once the menu has actually closed. With the restart question, it waits: Later opens OptiScaler's menu; Restart Now cancels it, and the game that starts again has nothing pending. Tested in the game (Testing has each path).longshot.exe's manifest setsactiveCodePageUTF-8 (tests/test_utf8_paths.pychecks it), so the CRT's narrow file calls andMoveFileExAtake UTF-8 paths. Where Windows doesn't apply it (before 1903),host/hos_main.c'snarrow_paths_okrefuses to start the game unless the path is plain ASCII. The ini's folder comes fromGetModuleFileNameW, made UTF-8. So there's no running game where the path holds characters outside the code page. The same holds for the footer's ini read.b4bb36958. The check takes--cc {cc}from the runner, as the other checks with C parts do. It passes on Windows (clang) and Linux (gcc).Builder points of BeanBot's review (issuecomment-96456) L1, L2 and L5 are fixed in
3474f9655, each with a build-driver test. build-driver's 191 tests pass, and clippy and fmt are clean. Replies are on the lines.@ -326,0 +350,4 @@return ours;}if was == Some(runtimes::SL_PLACED) && !runtimes::streamline_stays(fetched.optiscaler) {if !seeded {L1: fixed in
3474f9655. The record now says whether the builder put OptiScaler.ini there (optiscaler_ini: set when the seed is copied in, kept while that file is still there). An Off build removes the ini only then; one that was there before OptiScaler was placed is the player's and stays (logged). Test:build::optiscaler_settings_tests::an_off_build_takes_out_only_the_settings_the_builder_put_there.@ -988,0 +1074,4 @@"the game folder's record could not be written ({e}): your OptiScaler is left where it was"),});said.extend(crate::optiscaler::undo(&moved));L5: fixed in
3474f9655.set_aside_movingreturns the renames it made. When the record can't be written,optiscaler::undorenames them back (last first) and says so (optiscaler_aside_failed), so no copy is left aside without a record of where it is. Test:play::tests::a_rename_aside_that_cannot_be_recorded_is_taken_back(failing write, both ways).@ -681,0 +839,4 @@}// (a player's own OptiScaler under any name the game loads, winhttp.dll or dbghelp.dll as well as winmm.dll: kept// alone, none of the builder's placed beside it, so two never load)let theirs = players_optiscaler(out);L2: fixed in
3474f9655. Before placing anything,players_optiscalerchecks everyoptiscaler::PROXY_NAMESname besides the builder's own (winhttp.dll,dbghelp.dll). A DLL the builder didn't put there whose version strings name OptiScaler is kept alone (kept, nothing downloaded), andFetched::optiscaler_outmakes the build take the builder's own OptiScaler files out, so an earlier placedwinmm.dlldoesn't load beside it. Test:runtimes::tests::a_players_optiscaler_under_any_name_the_game_loads_is_kept_alone.Ran BeanBot's builder fixes (
3474f9655) on this PC through the queue. Normal path: On placed OptiScaler and seeded its ini (record optiscaler_ini true); Graphics → OptiScaler Off plus Restart Now removed every file, the licenses and the seeded ini. L1: a player's own OptiScaler.ini there before On was kept as theirs (their F7 key kept), and an Off Rebuild logged it kept and removed only the builder's files. Details are in Testing.llun's decision ("Yes, keep it"): turning OptiScaler off no longer deletes OptiScaler.ini, seeded or not; its other files still go. Turned on again, the kept file is used as it is, its settled lines (frame generation off, keys clear of Longshot's) set as at every start. The record's optiscaler_ini, now read by nothing, is dropped. The user guide says how to have OptiScaler's defaults back: delete OptiScaler.ini. Co-Authored-By: Claude Opus 5.5 <[email protected]>OptiScaler.ini is now kept when OptiScaler is turned off (
98812f6a0, llun's decision), so OptiScaler's own settings and the key chosen in Controls are there again when it's turned on; deleting the file brings back OptiScaler's defaults. Run in the game through the queue: On seeded the ini (F5); Controls set F6; Off plus Restart Now removed the DLLs and licenses and kept the ini; On plus Restart Now placed OptiScaler again with the same ini (F6, frame generation still forced off), and F6 opened OptiScaler's menu. build-driver's 191 tests pass.@review
Recommendation: Approve. The code is ready: only testing is left. The reported Windows NVIDIA run shows the feature working, and the code fixes address the reviewed defects. AMD and Intel Windows integration runs and the pending CI results are still needed. Recommend approval; not approved on the forge.
Adds an off-by-default Windows OptiScaler integration, including builder-managed files, menu controls, logging and documentation. It preserves the player's settings across disabling and reenabling it, at the cost of additional builder and input-handling complexity.
Testing before merging (1) (runs on the systems it can change; it doesn't hold the recommendation)
Since the last review (on
1300dab323)Resolved: L1 (Removing OptiScaler deletes its settings even when the builder did not create them.); L2 (The ownership check only looks at the builder's destination names, not the other proxy nam…); L3 (The OptiScaler key is sent on a timer even when the requested menu close opens a restart q…); L5 (A successful rename is not undone when writing its record fails.); L6 (The Windows test derives a C compiler by rewriting the C++ compiler name and ignores CC.)
Withdrawn (it was wrong): L4 (The ini path is UTF-8, but the file streams and MoveFileExA use Windows narrow-path handli…)
Still open: L7 (The Windows integration has only a reported NVIDIA run; its intended use with the other ve…)
Checks: Still running: 11 checks.
Also noticed (1; not asked for, not blocking)
More: does it help, other systems, switches, what was read
Does it help: Yes for the feature on the reported Windows 11 RTX 5080 run: the author reports that OptiScaler loaded, took DLSS inputs, and its menu and restart paths worked. This is not a performance change; no performance gain is claimed or measured.
Other systems: The integration affects Windows builder placement, proxy DLL loading, menu input and NVIDIA DLSS routing; Linux ignores the setting. AMD and Intel Windows paths remain untested in the supplied reports.
Switches: Adds the Windows Graphics OptiScaler setting, saved as optiscaler=, default off. The opt-in default is appropriate for a third-party mod; the switch reference and user guides are updated.
Reviewed:
98812f6a00against56823e27a1: Read AGENTS.md, CONTRIBUTING.md, the pull request template, commit list, the changes to the ledger-related code and surrounding rename and path handling. The larger base diff and remaining changed files were not read in full; the supplied test reports were skimmed. docs/review-checklist.md was absent.; nothing run (a code review).Checked and fine:
Testing: No commands from the project were run. The author reports Windows NVIDIA game and builder testing; all listed CI checks are still running.
Overlaps and merge order: LongshotLauncher#392 supplies the licence listing; its merge status is not provided.
Automated code review by BeanBot (gpt-6.1-terra), asked for by llun. Nothing was run; a maintainer decides.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.