fix(nvn): nvnDeviceGetWindowOriginMode and nvnDeviceGetDepthMode answer what the game set #1685

Merged
HumanBean merged 1 commit from rainy/Longshot:fix/nvn-window-origin-depth-getters into main 2026-11-19 07:14:09 +00:00
Contributor

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

  • Who it helps: mods that draw over the game's picture and ask the device which way up it draws.
  • What was wrong: asking for the window origin or the depth mode reached the "not implemented" answer, 0, which means lower left, while the game sets upper left.
  • What changes: both questions answer with the value the game set, or the default before it sets one.
  • What does not change: how the game draws. The game never asks for either value.
  • How it was checked: a new game-free test that fails on main and passes here, and python -I -B tests/run_all.py --jobs 8, which has the same 40 failures as main and one more pass.
  • What is still open: a run in the game on this branch.
  • Risk: low. Two functions that only read a field are added.

Why

A code mod, sloperinaGZ 0.0.8, on snaildev99's mods/module-gaps branch is what showed this. Longshot has nvnDeviceSetWindowOriginMode and nvnDeviceSetDepthMode, which store the value on the device, but not the matching nvnDeviceGetWindowOriginMode and nvnDeviceGetDepthMode. 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 nvnDeviceGetWindowOriginMode on 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.

  • nvn: nvnDeviceGetWindowOriginMode and nvnDeviceGetDepthMode in host/nvn_native.c return the device's origin and depth_mode, which nvnDeviceInitialize sets to 0. Both are in impls[], so nvnDeviceGetProcAddress hands them out.
  • tests: tests/test_nvn_device_modes.py checks that both names are in the proc table, then compiles the device functions cut from the source with tests/srccut.py. It checks the defaults after nvnDeviceInitialize and 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 8 on 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 @ 2f1c0c9c in this environment
  • tests/test_bug_report_defaults.py
  • tests/test_bug_report.py
  • tests/test_capture_read_once.py
  • tests/test_crash_groups.py
  • tests/test_crash_record.py
  • tests/test_crt_options.py
  • tests/test_damage_debug_menu.py
  • tests/test_dev_packs.py
  • tests/test_display_startup_failure.py
  • tests/test_dlss_feature_size.py
  • tests/test_failed_compile_keeps_objects.py
  • tests/test_guest_imported.py
  • tests/test_hardware_report.py
  • tests/test_high_fps_fixes.py
  • tests/test_host_guest_writes.py
  • tests/test_hud_layout_row.py
  • tests/test_invalidate_quick.py
  • tests/test_libc_hooks.py
  • tests/test_link_path_comma.py
  • tests/test_linux_preflight.py
  • tests/test_linux_pressure.py
  • tests/test_linux_update.py
  • tests/test_log_open_failure.py
  • tests/test_missing_nup.py
  • tests/test_mods_size_table.py
  • tests/test_pending_guest_import.py
  • tests/test_pipeline_play_cache.py
  • tests/test_prepare_cache_save.py
  • tests/test_present_thread.py
  • tests/test_profiling_mode.py
  • tests/test_psychov35_fsr3_fg.py
  • tests/test_readback_timeout_source.py
  • tests/test_run_all_changed.py
  • tests/test_slow_frames.py
  • tests/test_song_note_cue.py
  • tests/test_switch_table.py
  • tests/test_upscaler_rows.py
  • tests/test_vcore_escape.py
  • tests/test_walk_key.py
  • tests/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.py fails (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:

  • Linux, any GPU: start the game on this branch, load a save and play for a few minutes, expecting the picture as on main and no new nvn: lines in longshot_log.txt (by hand: the author, before this PR leaves WIP)
  • Windows, any GPU: the same steps, expecting the same result (Test Farm: @Beanstalk windows, start the game, load a save and play a few minutes)

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

  • One topic.
  • The title is a Conventional Commit (type(scope): description) of the status line's type.
  • Why gives the reason plainly and links the issues that fit (the tracker searched).
  • Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what
    can't be run by hand is in Testing's Not testable by hand, with why.
  • Measurements has a verdict, or one line saying why there is nothing to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks.
  • Testing names what was tested, what wasn't, and what must still be tested, where and how.
  • Rebased on current main.
  • python -I -B tests/run_all.py passes (any failure that also fails on main is named).
  • No game files, dumps, build output or generated files.
  • third_party/ untouched (a new folder with a PROVENANCE.md instead).
  • The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled.

When it applies

  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.
  • A game-free test added for the fix, failing on main and passing here.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
**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 - **Who it helps:** mods that draw over the game's picture and ask the device which way up it draws. - **What was wrong:** asking for the window origin or the depth mode reached the "not implemented" answer, 0, which means lower left, while the game sets upper left. - **What changes:** both questions answer with the value the game set, or the default before it sets one. - **What does not change:** how the game draws. The game never asks for either value. - **How it was checked:** a new game-free test that fails on main and passes here, and `python -I -B tests/run_all.py --jobs 8`, which has the same 40 failures as main and one more pass. - **What is still open:** a run in the game on this branch. - **Risk:** low. Two functions that only read a field are added. ## Why A code mod, sloperinaGZ 0.0.8, on snaildev99's mods/module-gaps branch is what showed this. Longshot has `nvnDeviceSetWindowOriginMode` and `nvnDeviceSetDepthMode`, which store the value on the device, but not the matching `nvnDeviceGetWindowOriginMode` and `nvnDeviceGetDepthMode`. 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 `nvnDeviceGetWindowOriginMode` on 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. - nvn: `nvnDeviceGetWindowOriginMode` and `nvnDeviceGetDepthMode` in `host/nvn_native.c` return the device's `origin` and `depth_mode`, which `nvnDeviceInitialize` sets to 0. Both are in `impls[]`, so `nvnDeviceGetProcAddress` hands them out. - tests: `tests/test_nvn_device_modes.py` checks that both names are in the proc table, then compiles the device functions cut from the source with `tests/srccut.py`. It checks the defaults after `nvnDeviceInitialize` and 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 8` on 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: <details> <summary>Tests that also fail on main @ 2f1c0c9c in this environment</summary> - `tests/test_bug_report_defaults.py` - `tests/test_bug_report.py` - `tests/test_capture_read_once.py` - `tests/test_crash_groups.py` - `tests/test_crash_record.py` - `tests/test_crt_options.py` - `tests/test_damage_debug_menu.py` - `tests/test_dev_packs.py` - `tests/test_display_startup_failure.py` - `tests/test_dlss_feature_size.py` - `tests/test_failed_compile_keeps_objects.py` - `tests/test_guest_imported.py` - `tests/test_hardware_report.py` - `tests/test_high_fps_fixes.py` - `tests/test_host_guest_writes.py` - `tests/test_hud_layout_row.py` - `tests/test_invalidate_quick.py` - `tests/test_libc_hooks.py` - `tests/test_link_path_comma.py` - `tests/test_linux_preflight.py` - `tests/test_linux_pressure.py` - `tests/test_linux_update.py` - `tests/test_log_open_failure.py` - `tests/test_missing_nup.py` - `tests/test_mods_size_table.py` - `tests/test_pending_guest_import.py` - `tests/test_pipeline_play_cache.py` - `tests/test_prepare_cache_save.py` - `tests/test_present_thread.py` - `tests/test_profiling_mode.py` - `tests/test_psychov35_fsr3_fg.py` - `tests/test_readback_timeout_source.py` - `tests/test_run_all_changed.py` - `tests/test_slow_frames.py` - `tests/test_song_note_cue.py` - `tests/test_switch_table.py` - `tests/test_upscaler_rows.py` - `tests/test_vcore_escape.py` - `tests/test_walk_key.py` - `tests/test_vbytes.py` (timed out at 600 s) </details> With the fix's source file reverted to main, `python -I -B tests/test_nvn_device_modes.py` fails (`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:** - Linux, any GPU: start the game on this branch, load a save and play for a few minutes, expecting the picture as on main and no new `nvn:` lines in `longshot_log.txt` (by hand: the author, before this PR leaves WIP) - Windows, any GPU: the same steps, expecting the same result (Test Farm: @Beanstalk windows, start the game, load a save and play a few minutes) ## 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 - [x] One topic. - [x] The title is a Conventional Commit (`type(scope): description`) of the status line's type. - [x] Why gives the reason plainly and links the issues that fit (the tracker searched). - [x] Tested on my own PC where it runs (in the game, for a change the game runs), as Testing's Tested says; what can't be run by hand is in Testing's Not testable by hand, with why. - [x] Measurements has a verdict, or one line saying why there is nothing to measure. - [x] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. - [x] Testing names what was tested, what wasn't, and what must still be tested, where and how. - [x] Rebased on current `main`. - [x] `python -I -B tests/run_all.py` passes (any failure that also fails on `main` is named). - [x] No game files, dumps, build output or generated files. - [x] `third_party/` untouched (a new folder with a `PROVENANCE.md` instead). - [x] The license is OK: GPL-3.0-or-later, nothing incompatible and nothing decompiled. ### When it applies - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. - [x] A game-free test added for the fix, failing on `main` and passing here. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened.
fix(nvn): nvnDeviceGetWindowOriginMode and nvnDeviceGetDepthMode answer what the game set
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 7s
Website / Website on Cloudflare (pull_request_target) Has been skipped
0a7aeb564f
Neither was in the proc table: a caller got the "not implemented" stub's 0,
lower left and near = -w, whatever the game had set. The game sets the
window origin to upper left (the renderer draws it so: row 0 at the top), so
code that asks the device to lay its own drawing over the picture (a mod's
overlay) was told lower left and drew it upside down.

Both now answer the device's own fields (nvn_dev origin and depth_mode,
0 from nvnDeviceInitialize until the game sets them).
tests/test_nvn_device_modes.py compiles the device functions and checks the
defaults, the set values, and the proc table entries; it fails on main.

Assisted-by: Grok Bot
Author
Contributor

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.

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.
HumanBean left a comment

From the code and the evidence, this looks ready.

What I checked:

  • The getters return what the setters store. nvnDeviceSetWindowOriginMode and nvnDeviceSetDepthMode (host/nvn_native.c:267-281) already write origin and depth_mode on the guest's nvn_dev. nvnDeviceInitialize zeroes 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 in impls[]. nvn_native_proc sorts that table and binary-searches it, so the table's order doesn't matter, and nvnDeviceGetProcAddress now hands out these functions instead of the unimplemented stub.
  • Threads. Each getter is one aligned 32-bit read of a field that its setter writes with a plain store. That is the same pattern as the other device fields, and no lock is needed.
  • No change to how the game draws. Nothing in host/ or gpu/ reads nvn_dev.origin or nvn_dev.depth_mode. The renderer's depth conversion reads the process-wide depth_minus_w through host->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-time nvn: ... is not implemented log line.
  • The test. It cuts the four device functions with srccut.block. Each marker appears once in the source (the table entries use the n_ 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.

From the code and the evidence, this looks ready. What I checked: - **The getters return what the setters store.** `nvnDeviceSetWindowOriginMode` and `nvnDeviceSetDepthMode` (`host/nvn_native.c:267-281`) already write `origin` and `depth_mode` on the guest's `nvn_dev`. `nvnDeviceInitialize` zeroes 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 in `impls[]`. `nvn_native_proc` sorts that table and binary-searches it, so the table's order doesn't matter, and `nvnDeviceGetProcAddress` now hands out these functions instead of the `unimplemented` stub. - **Threads.** Each getter is one aligned 32-bit read of a field that its setter writes with a plain store. That is the same pattern as the other device fields, and no lock is needed. - **No change to how the game draws.** Nothing in `host/` or `gpu/` reads `nvn_dev.origin` or `nvn_dev.depth_mode`. The renderer's depth conversion reads the process-wide `depth_minus_w` through `host->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-time `nvn: ... is not implemented` log line. - **The test.** It cuts the four device functions with `srccut.block`. Each marker appears once in the source (the table entries use the `n_` 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.
HumanBean deleted branch fix/nvn-window-origin-depth-getters 2026-11-19 07:14:10 +00:00
Some checks are pending
CI / Conventional Commit title (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Blocked by required conditions
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Blocked by required conditions
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Blocked by required conditions
CI / Workflow lint (actionlint) (pull_request) Blocked by required conditions
Guide screenshots / Guide images and local UI source review (pull_request) Blocked by required conditions
Third-party parts / As their notes say (pull_request) Blocked by required conditions
Third-party parts / The same as upstream (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 7s
Website / Website on Cloudflare (pull_request_target) Has been skipped
Some workflows are waiting to be reviewed.
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
MagicBeanDev/Longshot!1685
No description provided.