WIP: feat(gameplay): Mirror mode: the world mirrored left for right, the HUD and the menus as they are #1671

Draft
TrashPanda wants to merge 2 commits from TrashPanda/Longshot:feat/mirror-mode into main
Contributor

Type: feat · Risk: medium · Tested on: Linux (Ubuntu 26.04), RTX 4070 Ti · Needs: Windows; AMD and Intel; with DLSS, FSR and frame generation

TL;DR

Longshot has no mirrored mode for a second playthrough. This PR adds Mirror mode, a Gameplay row that's off by
default. The world plays mirrored left for right, while the hearts, text, menus and movies stay readable. The sticks and
mouse still turn the way you push them on screen. In the game, a 100% save showed the world mirrored and the HUD and
pause menu not, and the stick's left still went left on screen. A new game-free test covers every upscale path and the
input rule.

Breakdown

  • Who it helps: players who want a fresh-feeling second run, like the 3DS version's mirrored Master Quest.
  • What was wrong: there was no way to play the world mirrored.
  • What changes: with the row On, the world is mirrored, and so is the controls' left and right during play.
  • What does not change: everything with the row Off (the default). The HUD, text, menus, movies and saves are never mirrored.
  • How it was checked: in the game on a copied 100% save, both ways, with screenshots; tests/test_mirror_mode.py; tests/run_all.py.
  • What is still open: the minimap isn't mirrored; DLSS, FSR, frame generation and other GPUs not seen yet; gyro aiming.
  • Risk: medium: a new copy in the frame's GPU work. A GPU whose picture format takes no blits leaves the world unmirrored and says so once in the log.

Why

A mirrored world is how the 3DS version's Master Quest felt new again, and players ask for it in remakes. The remake has
no mirror of its own: its data has no mirror flag, and Master Quest isn't mirrored. Longshot can add it without
touching the game's logic.

What changed

The world is mirrored in the finished picture, not in the game's camera. The picture is turned over just after the scene
is upscaled into it and before the game draws its HUD over it.

The camera wasn't an option: sead's perspective projection keeps the aspect ratio at +0xb0, and culling reads it there.
Mirroring the camera would also have reversed the triangles' winding for the scene's passes only.

  • Renderer: gpu/vk/vk_mirror.cpp mirror_picture does the flip: a blit into a scratch image with x reversed, then
    a copy back.

    • Its commands go through the recorder (vk_work.h). Called directly, the driver crashed in the recorder thread.
    • The scratch is made GENERAL at each use, its contents dropped. A one-time layout change in whichever recorded part
      came first lost the GPU (Xid 32 / 69) when the parts ran in another order.
  • One point for every path: gpu/vk/vk_draw.cpp picture_written is where every upscale path ends:

    • the game's network, at any Render resolution, 100% included (upscale_picture takes the full-size pass in Mirror
      mode);
    • the FSR 3.1, temporal (DLSS / FSR 4) and TAAU stand-ins;
    • the fallback stub.

    It mirrors first, then calls framegen_hud_before, so frame generation's HUD copy is of the picture as shown.

  • Input: host/nn_hid.c hos_mirror_input swaps the sticks' x in npad_states, where every pad, the keyboard and
    the mouse-as-stick arrive.

    • It does this only while Link is updated and the Insert menu is closed, so the pause menu, item wheel, title and file
      select keep their own left and right.
    • host/mouse_native.c invert_x swaps the mouse camera's horizontal inversion by the same rule.
  • Option: HOS_OPT_MIRROR 75 in gpu/vk/vk_api.h, served by the existing option callback (no API version change).
    The Gameplay row and the README's line come with it.

  • Docs: docs/mirror-mode.md is new.

  • Tests:

    • tests/test_mirror_mode.py is new.
    • tests/test_input_background.py and tests/test_mouse_native.py: their fixtures compile npad_states and
      invert_x, and now carry the new helpers. Mirror mode is off in them, as before.

Measurements

Verdict: nothing measured yet. With the row Off, nothing runs. With it On, there's one 2560x1440 blit and one copy a
frame, measured next (CONTRIBUTING.md, "Measurements") before this leaves WIP.

Flags and settings

One new Insert menu row.

Flag What it is Before this PR After this PR Effect Helps / doesn't help / untested Recommendation
mirror_mode (Gameplay → Mirror mode) the world mirrored, the HUD not none Off the gameplay picture flipped before the HUD; the sticks' and mouse camera's left and right with it during play seen on an RTX 4070 Ti; other GPUs and the upscalers untested Off by default; the player's choice

Testing

Tested:

  • Where: in the game on Linux (Ubuntu 26.04), RTX 4070 Ti, NVIDIA 595.99.02. The runtime was main at 9dff58e6 with
    this branch as a pack (dev_build.py), on a copy of a 100% save in Link's house, the game's own upscale at the
    default Render resolution. The runs were driven through the control bridge.
  • The picture: Mirror mode turned on while playing (it applies at once). The world was mirrored: the house, the
    cow, Link's sword and shield were on the other side. The hearts, item buttons, minimap's place and "Talk" prompt were
    where they were, and readable.
  • The stick: the same push to the left, with the camera the same, went towards +z with the row Off and −z with it
    On. That's the screen's left both times.
  • The pause menu (Items): not mirrored.
  • Checks:
    • tests/test_mirror_mode.py compiles the input helpers and reads the renderer's hooks, and catches each of these
      broken copies: the flip with the menu open, the mirror after frame generation's copy, no x reversal.
    • python -I -B tests/run_all.py --changed: no failure that main doesn't have (test_host_guest_writes.py fails
      on main too).

Not tested:

  • Upscalers: DLSS, FSR 3.1 / 4, XeSS, and frame generation with Mirror mode on.
  • Other Render resolutions than the default.
  • Other GPUs: AMD and Intel.
  • Windows.
  • Gameplay: a lock-on marker or anything else the HUD places from a world position; cutscenes.

Must be tested:

  • Windows, any GPU (Test Farm: @Beanstalk windows): a save in play, Gameplay → Mirror mode On. Expect the world
    mirrored and the HUD not, and no device lost in longshot_log.txt.
  • AMD on Linux, RADV (Test Farm: @Beanstalk linux, amd, radv): the same, and with the Upscaler set to FSR 4
    where available.
  • NVIDIA with DLSS and frame generation, by hand (me, next): the same, with the Upscaler on DLSS and Frame
    generation 2x. Expect the made frames mirrored as the shown ones, and the HUD not smeared.

Risks

What could break: a GPU fault in the new copy on a driver I haven't run. Two such faults on NVIDIA during
development are fixed and named in What changed. Anything the HUD places from a world position would point at the
unmirrored side.

Turning it off: the row (Off by default).

Compatibility:

  • Settings: a new key, mirror_mode, in longshot_options.ini.
  • Unchanged: saves, the caches and the vk ABI.

Screenshots

A copied 100% save in Link's house, the same spot, this PR @ 134e104e:

Mirror mode Off (as main): this PR @ 134e104e

Mirror mode On: the world mirrored, the HUD, the prompt and the minimap's place as they are: this PR @ 134e104e

Mirror mode On, the pause menu: not mirrored: this PR @ 134e104e

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. The cost with the row On is still to measure.
  • Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and
    in Risks. Same: the On cost.
  • 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.
  • Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value.
  • Screenshots of the same spot, captioned like the Measurements columns, for a change that shows on screen.
  • A check under tests/ that reads changed source updated in this PR, not weakened.
  • Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. Linux built and ran; Windows not built yet.
  • Docs updated.

🤖 Generated with Claude Code

**Type:** feat · **Risk:** medium · **Tested on:** Linux (Ubuntu 26.04), RTX 4070 Ti · **Needs:** Windows; AMD and Intel; with DLSS, FSR and frame generation ## TL;DR Longshot has no mirrored mode for a second playthrough. This PR adds **Mirror mode**, a Gameplay row that's off by default. The world plays mirrored left for right, while the hearts, text, menus and movies stay readable. The sticks and mouse still turn the way you push them on screen. In the game, a 100% save showed the world mirrored and the HUD and pause menu not, and the stick's left still went left on screen. A new game-free test covers every upscale path and the input rule. ## Breakdown - **Who it helps:** players who want a fresh-feeling second run, like the 3DS version's mirrored Master Quest. - **What was wrong:** there was no way to play the world mirrored. - **What changes:** with the row On, the world is mirrored, and so is the controls' left and right during play. - **What does not change:** everything with the row Off (the default). The HUD, text, menus, movies and saves are never mirrored. - **How it was checked:** in the game on a copied 100% save, both ways, with screenshots; `tests/test_mirror_mode.py`; `tests/run_all.py`. - **What is still open:** the minimap isn't mirrored; DLSS, FSR, frame generation and other GPUs not seen yet; gyro aiming. - **Risk:** medium: a new copy in the frame's GPU work. A GPU whose picture format takes no blits leaves the world unmirrored and says so once in the log. ## Why A mirrored world is how the 3DS version's Master Quest felt new again, and players ask for it in remakes. The remake has no mirror of its own: its data has no mirror flag, and Master Quest isn't mirrored. Longshot can add it without touching the game's logic. ## What changed The world is mirrored in the finished picture, not in the game's camera. The picture is turned over just after the scene is upscaled into it and before the game draws its HUD over it. The camera wasn't an option: sead's perspective projection keeps the aspect ratio at +0xb0, and culling reads it there. Mirroring the camera would also have reversed the triangles' winding for the scene's passes only. - **Renderer:** `gpu/vk/vk_mirror.cpp` `mirror_picture` does the flip: a blit into a scratch image with x reversed, then a copy back. - Its commands go through the recorder (`vk_work.h`). Called directly, the driver crashed in the recorder thread. - The scratch is made GENERAL at each use, its contents dropped. A one-time layout change in whichever recorded part came first lost the GPU (Xid 32 / 69) when the parts ran in another order. - **One point for every path:** `gpu/vk/vk_draw.cpp` `picture_written` is where every upscale path ends: - the game's network, at any Render resolution, 100% included (`upscale_picture` takes the full-size pass in Mirror mode); - the FSR 3.1, temporal (DLSS / FSR 4) and TAAU stand-ins; - the fallback stub. It mirrors first, then calls `framegen_hud_before`, so frame generation's HUD copy is of the picture as shown. - **Input:** `host/nn_hid.c` `hos_mirror_input` swaps the sticks' x in `npad_states`, where every pad, the keyboard and the mouse-as-stick arrive. - It does this only while Link is updated and the Insert menu is closed, so the pause menu, item wheel, title and file select keep their own left and right. - `host/mouse_native.c` `invert_x` swaps the mouse camera's horizontal inversion by the same rule. - **Option:** `HOS_OPT_MIRROR` 75 in `gpu/vk/vk_api.h`, served by the existing option callback (no API version change). The Gameplay row and the README's line come with it. - **Docs:** `docs/mirror-mode.md` is new. - **Tests:** - `tests/test_mirror_mode.py` is new. - `tests/test_input_background.py` and `tests/test_mouse_native.py`: their fixtures compile `npad_states` and `invert_x`, and now carry the new helpers. Mirror mode is off in them, as before. ## Measurements **Verdict:** nothing measured yet. With the row Off, nothing runs. With it On, there's one 2560x1440 blit and one copy a frame, measured next (CONTRIBUTING.md, "Measurements") before this leaves WIP. ### Flags and settings One new Insert menu row. | Flag | What it is | Before this PR | After this PR | Effect | Helps / doesn't help / untested | Recommendation | |---|---|---|---|---|---|---| | `mirror_mode` (Gameplay → Mirror mode) | the world mirrored, the HUD not | none | Off | the gameplay picture flipped before the HUD; the sticks' and mouse camera's left and right with it during play | seen on an RTX 4070 Ti; other GPUs and the upscalers untested | Off by default; the player's choice | ## Testing **Tested:** - **Where:** in the game on Linux (Ubuntu 26.04), RTX 4070 Ti, NVIDIA 595.99.02. The runtime was `main` at 9dff58e6 with this branch as a pack (`dev_build.py`), on a copy of a 100% save in Link's house, the game's own upscale at the default Render resolution. The runs were driven through the control bridge. - **The picture:** Mirror mode turned on while playing (it applies at once). The world was mirrored: the house, the cow, Link's sword and shield were on the other side. The hearts, item buttons, minimap's place and "Talk" prompt were where they were, and readable. - **The stick:** the same push to the left, with the camera the same, went towards +z with the row Off and −z with it On. That's the screen's left both times. - **The pause menu (Items):** not mirrored. - **Checks:** - `tests/test_mirror_mode.py` compiles the input helpers and reads the renderer's hooks, and catches each of these broken copies: the flip with the menu open, the mirror after frame generation's copy, no x reversal. - `python -I -B tests/run_all.py --changed`: no failure that `main` doesn't have (`test_host_guest_writes.py` fails on `main` too). **Not tested:** - **Upscalers:** DLSS, FSR 3.1 / 4, XeSS, and frame generation with Mirror mode on. - **Other Render resolutions** than the default. - **Other GPUs:** AMD and Intel. - **Windows.** - **Gameplay:** a lock-on marker or anything else the HUD places from a world position; cutscenes. **Must be tested:** - **Windows, any GPU (Test Farm: `@Beanstalk windows`):** a save in play, Gameplay → Mirror mode On. Expect the world mirrored and the HUD not, and no device lost in `longshot_log.txt`. - **AMD on Linux, RADV (Test Farm: `@Beanstalk linux, amd, radv`):** the same, and with the Upscaler set to FSR 4 where available. - **NVIDIA with DLSS and frame generation, by hand (me, next):** the same, with the Upscaler on DLSS and Frame generation 2x. Expect the made frames mirrored as the shown ones, and the HUD not smeared. ## Risks **What could break:** a GPU fault in the new copy on a driver I haven't run. Two such faults on NVIDIA during development are fixed and named in What changed. Anything the HUD places from a world position would point at the unmirrored side. **Turning it off:** the row (Off by default). **Compatibility:** - **Settings:** a new key, `mirror_mode`, in `longshot_options.ini`. - **Unchanged:** saves, the caches and the vk ABI. ## Screenshots A copied 100% save in Link's house, the same spot, this PR @ 134e104e: ![Mirror mode Off (as main): this PR @ 134e104e](https://git.magicbean.dev/attachments/219a99ef-f745-4f5c-a613-90f9af1ea1e9) ![Mirror mode On: the world mirrored, the HUD, the prompt and the minimap's place as they are: this PR @ 134e104e](https://git.magicbean.dev/attachments/c845a22a-2288-4b65-b800-c6baeca8e7d9) ![Mirror mode On, the pause menu: not mirrored: this PR @ 134e104e](https://git.magicbean.dev/attachments/a0f0697b-2818-4f24-a733-3ef950046850) ## 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. - [ ] Measurements has a verdict, or one line saying why there is nothing to measure. *The cost with the row On is still to measure.* - [ ] Nothing gets worse that I know of: any cost (speed, latency, memory, a setup that worked before) is measured and in Risks. *Same: the On cost.* - [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] Switches documented (docs/development.md; the README for a menu row) and shipped at their recommended value. - [x] Screenshots of the same spot, captioned like the Measurements columns, for a change that shows on screen. - [x] A check under `tests/` that reads changed source updated in this PR, not weakened. - [ ] Host code builds on both Windows (llvm-mingw) and Linux, with UTF-8 paths. *Linux built and ran; Windows not built yet.* - [x] Docs updated. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
feat(gameplay): Mirror mode: the world mirrored left for right, the HUD and the menus as they are
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
134e104ea2
A Gameplay row, off by default, that plays the game's world mirrored, as a mirrored second quest does.

- gpu/vk/vk_mirror.cpp mirror_picture: the gameplay picture turned over right after the scene was upscaled into it,
  before the game draws its HUD over it: a blit into a scratch image with the source's x reversed, then a copy back,
  through the recorder (vk_work.h). The scratch is made GENERAL at each use: the replay's parts are recorded on
  several workers and run in order. Culling, depth, shadows, the upscalers and frame generation see the picture as
  the game made it.
- gpu/vk/vk_draw.cpp picture_written: every path that writes the upscale's picture (the game's network at any Render
  resolution, 100% too; the FSR 3.1, temporal and TAAU stand-ins; the fallback stub) mirrors, then gives frame
  generation its HUD copy.
- host/nn_hid.c hos_mirror_input: the sticks' x swapped where the game reads them while Link plays and the Insert menu
  is closed (the pause menu, the wheel and the title keep their left and right); host/mouse_native.c: the mouse
  camera's horizontal inversion by the same rule.
- HOS_OPT_MIRROR 75 (the existing option callback, no API change); the README's row; docs/mirror-mode.md.
- tests/test_mirror_mode.py (the renderer's hooks read, the input helpers compiled); the fixtures of
  test_input_background.py and test_mouse_native.py take the new helpers.

In the game (RTX 4070 Ti, NVIDIA 595.99.02, Linux): a 100% save in Link's house, the world mirrored and the HUD,
the prompt and the pause menu not; the stick's left still left on screen.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Author
Contributor

Tested in game: RTX 4070 Ti, NVIDIA 595.99.02, Ubuntu 26.04, main @ 9dff58e6 + this branch as a pack, the game's own upscale at the default Render resolution: a copied 100% save in Link's house, Mirror mode turned on in play: the world mirrored (the house, the cow, Link's sword and shield on the other side), the hearts, item buttons, minimap's place and the Talk prompt where they were and readable; the same stick push left went +z off and -z on with the camera the same (the screen's left both times); the pause menu not mirrored; no device lost after the two fixes named in What changed. Not seen yet: DLSS / FSR / frame generation, other GPUs, Windows.

Tested in game: RTX 4070 Ti, NVIDIA 595.99.02, Ubuntu 26.04, main @ 9dff58e6 + this branch as a pack, the game's own upscale at the default Render resolution: a copied 100% save in Link's house, Mirror mode turned on in play: the world mirrored (the house, the cow, Link's sword and shield on the other side), the hearts, item buttons, minimap's place and the Talk prompt where they were and readable; the same stick push left went +z off and -z on with the camera the same (the screen's left both times); the pause menu not mirrored; no device lost after the two fixes named in What changed. Not seen yet: DLSS / FSR / frame generation, other GPUs, Windows.
TrashPanda force-pushed feat/mirror-mode from 134e104ea2
Some checks failed
Website / Website on Cloudflare (pull_request_target) Has been skipped
PR description / Description follows the template (pull_request_target) Successful in 4s
CI / Conventional Commit title (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 1/2) (pull_request) Has been cancelled
CI / Python source checks (ubuntu-24.04, part 2/2) (pull_request) Has been cancelled
CI / SPIR-V fixtures (global narrow load/store, direct surface atomics, F2I immediate) (pull_request) Has been cancelled
CI / Workflow lint (actionlint) (pull_request) Has been cancelled
Guide screenshots / Guide images and local UI source review (pull_request) Has been cancelled
Third-party parts / As their notes say (pull_request) Has been cancelled
Third-party parts / The same as upstream (pull_request) Has been cancelled
Website / Website on Cloudflare (pull_request) Has been cancelled
to ef7848ce4e
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
CI / Website build and checks (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
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 7s
2026-11-20 02:18:59 +00:00
Compare
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
CI / Website build and checks (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
Website / Website on Cloudflare (pull_request) Blocked by required conditions
PR description / Description follows the template (pull_request_target) Successful in 7s
This pull request has changes conflicting with the target branch.
  • gpu/vk/vk_api.h
  • gpu/vk/vk_draw.cpp
  • host/nn_hid.c
  • tests/test_input_background.py
Some workflows are waiting to be reviewed.
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.
git fetch -u 'feat/mirror-mode:TrashPanda-feat/mirror-mode'
git switch 'TrashPanda-feat/mirror-mode'
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
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!1671
No description provided.