fix(nvn): nvnDeviceGetWindowOriginMode and nvnDeviceGetDepthMode answer what the game set #1685
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
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!1685
Loading…
Reference in a new issue
No description provided.
Delete branch "rainy/Longshot:fix/nvn-window-origin-depth-getters"
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?
Type: fix · Risk: low · Tested on: Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08) · Needs: a run on Windows, any GPU
TL;DR
The graphics API lets a program set the screen's origin and depth mode and ask for them back. Longshot handled setting them but not asking, so a program that asked always got the default, even after the game had set something else. This PR answers with what was set. A new game-free test fails on main and passes here. The full check suite on this branch has the same 40 failures as main, and one more pass. It also ran in the game on Linux.
Breakdown
python -I -B tests/run_all.py --jobs 8, which has the same 40 failures as main and one more pass.Why
A code mod, sloperinaGZ 0.0.8, on snaildev99's mods/module-gaps branch is what showed this. Longshot has
nvnDeviceSetWindowOriginModeandnvnDeviceSetDepthMode, which store the value on the device, but not the matchingnvnDeviceGetWindowOriginModeandnvnDeviceGetDepthMode. A caller that looks them up gets the stub for functions that are not implemented, and that stub returns 0. For the window origin, 0 is lower left, but the game sets upper left. A mod that lays its own drawing over the picture by that answer reads its rows in the wrong order and draws upside down. NVN has no public documentation, so this PR only adds the getters that match the setters main already has. The tracker has no issue or PR for origin.How to reproduce
Seen on: Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08). The answer does not depend on the GPU or driver.
Settings and switches: defaults
Steps: after the game has set the window origin to upper left, call
nvnDeviceGetWindowOriginModeon its device, from mod code or from the game-free test below run against main.Expected: upper left, 1.
Actual: 0, lower left, from the not-implemented stub.
What changed
The two getters are added to the device functions and the proc table.
nvnDeviceGetWindowOriginModeandnvnDeviceGetDepthModeinhost/nvn_native.creturn the device'soriginanddepth_mode, whichnvnDeviceInitializesets to 0. Both are inimpls[], sonvnDeviceGetProcAddresshands them out.tests/test_nvn_device_modes.pychecks that both names are in the proc table, then compiles the device functions cut from the source withtests/srccut.py. It checks the defaults afternvnDeviceInitializeand the values after each setter.Measurements
Nothing to measure. Two functions that read one field each, and the game never calls them.
Flags and settings
None
Testing
Tested:
python -I -B tests/run_all.py --jobs 8on Linux (Omarchy, kernel 7.2.15; Intel Core Ultra 7 270K Plus; RTX 4090, driver 615.78.08). main @2f1c0c9c: 685 passed, 40 failed, 97 skipped. this branch @0a7aeb56: 686 passed, 40 failed, 97 skipped, 0 new failures compared by test name. The 40 failures also fail on main. They are:Tests that also fail on main @
2f1c0c9cin this environmenttests/test_bug_report_defaults.pytests/test_bug_report.pytests/test_capture_read_once.pytests/test_crash_groups.pytests/test_crash_record.pytests/test_crt_options.pytests/test_damage_debug_menu.pytests/test_dev_packs.pytests/test_display_startup_failure.pytests/test_dlss_feature_size.pytests/test_failed_compile_keeps_objects.pytests/test_guest_imported.pytests/test_hardware_report.pytests/test_high_fps_fixes.pytests/test_host_guest_writes.pytests/test_hud_layout_row.pytests/test_invalidate_quick.pytests/test_libc_hooks.pytests/test_link_path_comma.pytests/test_linux_preflight.pytests/test_linux_pressure.pytests/test_linux_update.pytests/test_log_open_failure.pytests/test_missing_nup.pytests/test_mods_size_table.pytests/test_pending_guest_import.pytests/test_pipeline_play_cache.pytests/test_prepare_cache_save.pytests/test_present_thread.pytests/test_profiling_mode.pytests/test_psychov35_fsr3_fg.pytests/test_readback_timeout_source.pytests/test_run_all_changed.pytests/test_slow_frames.pytests/test_song_note_cue.pytests/test_switch_table.pytests/test_upscaler_rows.pytests/test_vcore_escape.pytests/test_walk_key.pytests/test_vbytes.py(timed out at 600 s)With the fix's source file reverted to main,
python -I -B tests/test_nvn_device_modes.pyfails (nvnDeviceGetWindowOriginMode is not in the proc table). It passes on this branch. In the game, built from this branch on Linux with an RTX 4090: the picture is the right way up with no depth faults, as on main.Not testable by hand: the console case can only be reached by a code mod. The game never calls these two functions, so a run of the unmodified game cannot show the fix. The game-free test stands in for it. The in-game run shows that nothing else breaks.
Not tested: Windows (no build or run there) and other GPUs. The same change also ran in the game on snaildev99's mods/module-gaps branch, where a mod's overlay went from upside down to the right way up.
Must be tested:
nvn:lines inlongshot_log.txt(by hand: the author, before this PR leaves WIP)Risks
What could break: nothing in the game, which never calls them. A mod that asked before now gets the real value.
Turning it off: revert the commit
Compatibility: Nothing changes
Checklist
Everyone
type(scope): description) of the status line's type.can't be run by hand is in Testing's Not testable by hand, with why.
in Risks.
main.python -I -B tests/run_all.pypasses (any failure that also fails onmainis named).third_party/untouched (a new folder with aPROVENANCE.mdinstead).When it applies
Assisted-by:/Co-Authored-By:trailers.mainand passing here.tests/that reads changed source updated in this PR, not weakened.Tested in game: Linux (Omarchy, kernel 7.2.15), Intel Core Ultra 7 270K Plus, RTX 4090 driver 615.78.08, a build of this branch on v3.0.0-rc.8: the picture is the right way up with no depth faults, as on main.
From the code and the evidence, this looks ready.
What I checked:
nvnDeviceSetWindowOriginModeandnvnDeviceSetDepthMode(host/nvn_native.c:267-281) already writeoriginanddepth_modeon the guest'snvn_dev.nvnDeviceInitializezeroes both, so before the game sets anything the getters return 0: lower left and near = -w (nvn_api.h:386-394). Those are NVN's defaults. Both new entries are inimpls[].nvn_native_procsorts that table and binary-searches it, so the table's order doesn't matter, andnvnDeviceGetProcAddressnow hands out these functions instead of theunimplementedstub.host/orgpu/readsnvn_dev.originornvn_dev.depth_mode. The renderer's depth conversion reads the process-widedepth_minus_wthroughhost->depth_minus_w()(vk_shader.cpp:1478, 1668, 1690), and this PR leaves that alone. If the game never asks, nothing changes. If something does ask, it gets the real value and no longer causes a one-timenvn: ... is not implementedlog line.srccut.block. Each marker appears once in the source (the table entries use then_prefix). The test checks the defaults, both setters and the proc-table entries, and it would fail on main for the reason given.Measurements: nothing to measure, and the PR says why: two field reads that the game never calls. A fix needs a test that fails on main, and this one does. The in-game run on Linux with an RTX 4090 (comment of 2026-11-19) shows nothing else broke. The "Windows, any GPU" run under Must be tested would be nice to have, but it shouldn't block. The change is plain portable C with nothing specific to one platform.
Nit (description only): under Breakdown, "What is still open: a run in the game on this branch" is out of date. Testing and the author's comment both report that run. The Linux item in Must be tested is also done.