fix(vk): vk_replay.cpp builds again: the brace after present_thread_drain no longer closes namespace mkwvk #1949

Merged
HumanBean merged 2 commits from d4nkn3ss/Longshot:fix/vk-replay-braces into main 2026-11-21 01:31:20 +00:00
Contributor

Summary

main doesn't build since 8d56b59d (#1105). That change added a closing brace after present_thread_drain() in gpu/vk/vk_replay.cpp, which closes namespace mkwvk early. swapchain_made_ready() and everything after it then sit outside the namespace that vk_internal.h declares them in, and the file's own } // namespace mkwvk at the end is one brace too many. This removes that brace.

On main: build the renderer: vk_replay.cpp fails with use of undeclared identifier 'wait_queue_empty'; did you mean 'mkwvk::wait_queue_empty'? and 19 more errors.

Read first: the one line in gpu/vk/vk_replay.cpp, after present_thread_drain(); then tests/test_vk_braces.py.

See #1105.

Testing

Tested:

  • Windows 11 Pro 26300, llvm-mingw from the Longshot Builder, main @ fc4a6769: the standalone build stops at vk_replay.cpp (20 errors). With this PR it compiles, and longshot.exe and longshot_vk.dll link.
  • In the game, Windows 11, RTX 3080 10 GB (NVIDIA 621.14), this PR's build: an adult save in Hyrule Field, a teleport to the Market, then quit. It arrived, the window closed with #1105's line (vk: the window is closing: the swapchain is let go with its images ...) once, and there was no CRASH, FATAL, VK_ERROR or device lost.
  • python -I -B tests/test_vk_braces.py (new): fails on main (gpu/vk/vk_replay.cpp: line 7785: a '}' with nothing open), passes here, on Windows and on Linux (Debian under WSL 2). It reads every source under gpu/vk whole, leaving out comments, string and character literals (raw strings, L'\' and digit separators too) and preprocessor lines, and counts only the first branch of each #if. All 548 balance here. It needs no compiler, so it runs where the Vulkan headers are missing.
  • The 130 checks under tests/ that read vk_replay.cpp: 104 passed and 26 failed, the same 26 on main @ fc4a6769. They cut functions out of the file, so none sees a brace between functions, which is why none failed on main.
  • The rest of the suite reads no changed file, so it runs as on main (mise isn't installed here; checks through tests/run_all.py).
  • Not compiled on Linux here (no Vulkan headers under WSL on this PC). The change removes one brace, the same on every platform.

Still to test: None

Measurements

Nothing to measure: a build fix, one brace, and its check.

Risks

None beyond #1105's own: this restores the namespace that change meant to keep. Turning it off: a revert, which breaks the build again.

Checklist

Ready for review

  • One topic, on current main; the title is a Conventional Commit.
  • Tested on my own PC, in the game for a change the game runs, as Testing says.
  • mise run test passes (any failure that also fails on main is named).
  • Measured against main, or Measurements says why there is nothing to measure.
  • No game files, build output or hand-edited generated files; third_party/ untouched; nothing GPL-incompatible.

When it applies

  • A fix: a game-free test that fails on main and passes here.
  • A check under tests/ that reads changed source is updated, not weakened.
  • AI assistance recorded with Assisted-by: / Co-Authored-By: trailers.

Ready to merge

  • Everything in Still to test has run, its results in Tested.
  • Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers").
  • Approved in review, every comment answered.
  • CI passes on the head; on current main, measured again or a comment says why the numbers still hold.

🤖 Generated with Claude Code

## Summary `main` doesn't build since 8d56b59d (#1105). That change added a closing brace after `present_thread_drain()` in `gpu/vk/vk_replay.cpp`, which closes `namespace mkwvk` early. `swapchain_made_ready()` and everything after it then sit outside the namespace that `vk_internal.h` declares them in, and the file's own `} // namespace mkwvk` at the end is one brace too many. This removes that brace. **On main:** build the renderer: `vk_replay.cpp` fails with `use of undeclared identifier 'wait_queue_empty'; did you mean 'mkwvk::wait_queue_empty'?` and 19 more errors. Read first: the one line in `gpu/vk/vk_replay.cpp`, after `present_thread_drain()`; then `tests/test_vk_braces.py`. See #1105. ## Testing **Tested:** - Windows 11 Pro 26300, llvm-mingw from the Longshot Builder, main @ fc4a6769: the standalone build stops at `vk_replay.cpp` (20 errors). With this PR it compiles, and `longshot.exe` and `longshot_vk.dll` link. - In the game, Windows 11, RTX 3080 10 GB (NVIDIA 621.14), this PR's build: an adult save in Hyrule Field, a teleport to the Market, then quit. It arrived, the window closed with #1105's line (`vk: the window is closing: the swapchain is let go with its images ...`) once, and there was no `CRASH`, `FATAL`, `VK_ERROR` or device lost. - `python -I -B tests/test_vk_braces.py` (new): fails on main (`gpu/vk/vk_replay.cpp: line 7785: a '}' with nothing open`), passes here, on Windows and on Linux (Debian under WSL 2). It reads every source under `gpu/vk` whole, leaving out comments, string and character literals (raw strings, `L'\'` and digit separators too) and preprocessor lines, and counts only the first branch of each `#if`. All 548 balance here. It needs no compiler, so it runs where the Vulkan headers are missing. - The 130 checks under `tests/` that read `vk_replay.cpp`: 104 passed and 26 failed, the same 26 on main @ fc4a6769. They cut functions out of the file, so none sees a brace between functions, which is why none failed on main. - The rest of the suite reads no changed file, so it runs as on main (`mise` isn't installed here; checks through `tests/run_all.py`). - Not compiled on Linux here (no Vulkan headers under WSL on this PC). The change removes one brace, the same on every platform. **Still to test:** None ## Measurements Nothing to measure: a build fix, one brace, and its check. ## Risks None beyond #1105's own: this restores the namespace that change meant to keep. Turning it off: a revert, which breaks the build again. ## Checklist ### Ready for review - [x] One topic, on current `main`; the title is a Conventional Commit. - [x] Tested on my own PC, in the game for a change the game runs, as Testing says. - [x] `mise run test` passes (any failure that also fails on `main` is named). - [x] Measured against `main`, or Measurements says why there is nothing to measure. - [x] No game files, build output or hand-edited generated files; `third_party/` untouched; nothing GPL-incompatible. ### When it applies - [x] A fix: a game-free test that fails on `main` and passes here. - [x] A check under `tests/` that reads changed source is updated, not weakened. - [x] AI assistance recorded with `Assisted-by:` / `Co-Authored-By:` trailers. ### Ready to merge - [ ] Everything in Still to test has run, its results in Tested. - [ ] Tier 1 hardware it can affect is tested (docs/dev/standards.md, "Hardware tiers"). - [ ] Approved in review, every comment answered. - [ ] CI passes on the head; on current `main`, measured again or a comment says why the numbers still hold. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A brace too many between two functions closes namespace mkwvk early, and the build stops at that file; the checks that
cut single functions out of a source never see it. This reads each gpu/vk source whole, comments, literals and
preprocessor lines left out and the first branch of each #if counted.

Assisted-by: Claude Code
Co-Authored-By: Claude Opus 5.5 <[email protected]>
fix(vk): vk_replay.cpp builds again: the brace after present_thread_drain no longer closes namespace mkwvk
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
PR description / Description follows the template (pull_request_target) Successful in 6s
Website / Website on Cloudflare (pull_request_target) Has been skipped
276d0f7e4b
#1105 added a closing brace after present_thread_drain(), so swapchain_made_ready() and the rest of the file fell outside
namespace mkwvk, and the file's own `} // namespace mkwvk` at the end was one too many. vk_replay.cpp stopped compiling
(`use of undeclared identifier 'wait_queue_empty'; did you mean 'mkwvk::wait_queue_empty'`, 20 errors).

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

Tested in game: Windows 11 Pro 26300, RTX 3080 10 GB (NVIDIA 621.14): main @ fc4a6769 fails to build at vk_replay.cpp; this branch builds and links. An adult save in Hyrule Field, a teleport to the Market, then quit: it arrived, the window closed with #1105's swapchain line once, no CRASH, FATAL, VK_ERROR or device lost.

Tested in game: Windows 11 Pro 26300, RTX 3080 10 GB (NVIDIA 621.14): main @ fc4a6769 fails to build at vk_replay.cpp; this branch builds and links. An adult save in Hyrule Field, a teleport to the Market, then quit: it arrived, the window closed with #1105's swapchain line once, no CRASH, FATAL, VK_ERROR or device lost.
BeanBot left a comment

Recommendation: Request changes. The one-line fix restores the renderer build on Windows. The new check should focus on the namespace regression before it becomes a required test for all Vulkan sources.

Removing the extra brace puts the swapchain helper and the rest of the replay implementation back in mkwvk, so players can build the renderer again. The runtime fix is small. The test adds a second C++ scanner and makes all 548 renderer sources depend on its parsing rules.

Does it help: Yes for the reported Windows build failure. The PR reports 20 compiler errors on base fc4a6769 with the Builder’s llvm-mingw, and successful linking of longshot.exe and longshot_vk.dll on the PR. The new check reportedly fails with the extra brace and passes on Windows and WSL. Native Linux compilation remains unverified. This is a build fix with no performance claim.
Other systems: The namespace repair applies to both Windows and Linux, including Steam Deck, and all Vulkan vendors. It preserves the presenter drain, queue locking, and swapchain lifetime logic. There are no changes to frame pacing, memory allocation, saves, audio, input, shader generation, or the host-renderer interface. The new check is picked up automatically by the full game-free suite.
Switches: None.

Reviewed: 276d0f7e4b against fc4a6769fd: Read AGENTS.md, CONTRIBUTING.md, the Forgejo PR template, developer standards, the fix-with-test guidance, both commits, the complete diff, and tests/test_vk_braces.py in full. Read the changed region of vk_replay.cpp, its namespace boundaries, the presenter hand-off and drain, the relevant declarations and callers, and test discovery. Skimmed the earlier Deck run records and CI configuration. The rest of the unchanged replay implementation was outside the read scope. No review checklist or adjacent Tooling checkout was present. No generated or translated files changed.; nothing run (a code review).
Checked and fine:

  • The anonymous namespace closes before present_thread_drain(). Removing the extra brace keeps swapchain_made_ready(), wait_queue_empty(), and fill_replay_table() in the expected namespace.
  • The C++ edit introduces no new thread hand-off, allocation, index, path handling, or cleanup behavior.
  • Both commits have AI-assistance trailers and the test precedes the fix. The diff contains no game-derived data, build outputs, vendor changes, or generated edits.
  • The test uses the standard library, explicit UTF-8 decoding, and no compiler path or renderer environment switches.

Blocking (to change before merge)

  1. tests/test_vk_braces.py💯 Balanced braces do not establish the scope that broke the build. Moving the final mkwvk close to just after present_thread_drain() still balances the file, but leaves swapchain_made_ready() outside its declared namespace. Make the regression check verify that scope or compile the translation unit.
  2. tests/test_vk_braces.py:35: Keeping the first arm of every conditional does not model a supported build. An extra brace in the Linux #else of the acquire timeout in vk_replay.cpp is discarded. Mutually exclusive blocks written as separate #ifdef and #ifndef directives can also both be counted. Use compiler preprocessing for platform-wide coverage or narrow the check to the unconditional namespace boundary.
  3. tests/test_vk_braces.py:30: Directive handling runs before the scanner knows whether it is inside a comment or literal. A #if 0 example inside a block comment can blank the comment terminator and a real function close. The scanner also counts braces on a continued // line that C++ treats as part of the comment. Recognize directives in lexical context and handle line splicing, or keep the check local to the namespace regression.
  4. tests/test_vk_braces.py:104: The recursive scan reads any matching path in the working tree. An untracked scratch header can fail the suite on a clean change, and a .h symlink can make the test read outside the checkout. Restrict the inputs to the intended repository source files and reject paths that resolve outside the checkout.

Waiting on the author (a run, a measurement or a decision; no edit does it)

  • The Windows build and WSL Python check leave the native Linux renderer unbuilt on this head. Record a Linux build and a Steam Deck Game Mode launch-and-quit smoke test with the swapchain release marker. The existing Deck records are for #1105 builds.
  • The PR gives totals for 130 selected checks and says 26 fail on both revisions, but it omits their names and the strict full-suite result. Record the full-suite or CI result for the reviewed head and name the failures reproduced on the base before marking the checks complete.

Testing: Read-only review. No builds or tests were run. The author reports 104 passes and 26 matching failures among the 130 selected checks, plus a Windows gameplay smoke test that reached the Market and logged the swapchain release once on quit.
Overlaps and merge order: #1105 introduced the extra brace and is already in the base. No other overlap found in the checkout.


Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.

**Recommendation: Request changes.** The one-line fix restores the renderer build on Windows. The new check should focus on the namespace regression before it becomes a required test for all Vulkan sources. Removing the extra brace puts the swapchain helper and the rest of the replay implementation back in `mkwvk`, so players can build the renderer again. The runtime fix is small. The test adds a second C++ scanner and makes all 548 renderer sources depend on its parsing rules. **Does it help:** Yes for the reported Windows build failure. The PR reports 20 compiler errors on base `fc4a6769` with the Builder’s llvm-mingw, and successful linking of `longshot.exe` and `longshot_vk.dll` on the PR. The new check reportedly fails with the extra brace and passes on Windows and WSL. Native Linux compilation remains unverified. This is a build fix with no performance claim. **Other systems:** The namespace repair applies to both Windows and Linux, including Steam Deck, and all Vulkan vendors. It preserves the presenter drain, queue locking, and swapchain lifetime logic. There are no changes to frame pacing, memory allocation, saves, audio, input, shader generation, or the host-renderer interface. The new check is picked up automatically by the full game-free suite. **Switches:** None. **Reviewed:** 276d0f7e4bd3 against fc4a6769fd69: Read AGENTS.md, CONTRIBUTING.md, the Forgejo PR template, developer standards, the fix-with-test guidance, both commits, the complete diff, and `tests/test_vk_braces.py` in full. Read the changed region of `vk_replay.cpp`, its namespace boundaries, the presenter hand-off and drain, the relevant declarations and callers, and test discovery. Skimmed the earlier Deck run records and CI configuration. The rest of the unchanged replay implementation was outside the read scope. No review checklist or adjacent Tooling checkout was present. No generated or translated files changed.; nothing run (a code review). **Checked and fine:** - The anonymous namespace closes before `present_thread_drain()`. Removing the extra brace keeps `swapchain_made_ready()`, `wait_queue_empty()`, and `fill_replay_table()` in the expected namespace. - The C++ edit introduces no new thread hand-off, allocation, index, path handling, or cleanup behavior. - Both commits have AI-assistance trailers and the test precedes the fix. The diff contains no game-derived data, build outputs, vendor changes, or generated edits. - The test uses the standard library, explicit UTF-8 decoding, and no compiler path or renderer environment switches. **Blocking** (to change before merge) 1. tests/test_vk_braces.py:100: Balanced braces do not establish the scope that broke the build. Moving the final `mkwvk` close to just after `present_thread_drain()` still balances the file, but leaves `swapchain_made_ready()` outside its declared namespace. Make the regression check verify that scope or compile the translation unit. 2. tests/test_vk_braces.py:35: Keeping the first arm of every conditional does not model a supported build. An extra brace in the Linux `#else` of the acquire timeout in `vk_replay.cpp` is discarded. Mutually exclusive blocks written as separate `#ifdef` and `#ifndef` directives can also both be counted. Use compiler preprocessing for platform-wide coverage or narrow the check to the unconditional namespace boundary. 3. tests/test_vk_braces.py:30: Directive handling runs before the scanner knows whether it is inside a comment or literal. A `#if 0` example inside a block comment can blank the comment terminator and a real function close. The scanner also counts braces on a continued `//` line that C++ treats as part of the comment. Recognize directives in lexical context and handle line splicing, or keep the check local to the namespace regression. 4. tests/test_vk_braces.py:104: The recursive scan reads any matching path in the working tree. An untracked scratch header can fail the suite on a clean change, and a `.h` symlink can make the test read outside the checkout. Restrict the inputs to the intended repository source files and reject paths that resolve outside the checkout. **Waiting on the author** (a run, a measurement or a decision; no edit does it) - The Windows build and WSL Python check leave the native Linux renderer unbuilt on this head. Record a Linux build and a Steam Deck Game Mode launch-and-quit smoke test with the swapchain release marker. The existing Deck records are for #1105 builds. - The PR gives totals for 130 selected checks and says 26 fail on both revisions, but it omits their names and the strict full-suite result. Record the full-suite or CI result for the reviewed head and name the failures reproduced on the base before marking the checks complete. **Testing:** Read-only review. No builds or tests were run. The author reports 104 passes and 26 matching failures among the 130 selected checks, plus a Windows gameplay smoke test that reached the Market and logged the swapchain release once on quit. **Overlaps and merge order:** #1105 introduced the extra brace and is already in the base. No other overlap found in the checkout. --- <sub>Automated code review by BeanBot (gpt-6.2-sol), on the pull request's opening. Nothing was run; a maintainer decides.</sub>
@ -0,0 +20,4 @@
def code_lines(text):
"""The file's lines with preprocessor lines, and the lines of #else / #elif branches, blanked"""
out, depth_skip, stack, cont = [], 0, [], False
Member

Remove the unused depth_skip variable.

Remove the unused `depth_skip` variable.
@ -0,0 +27,4 @@
cont = s.endswith("\\")
out.append("")
continue
if s.startswith("#"):
Member

A #if 0 inside a block comment can blank real code. Directive recognition needs lexical context, including line continuations.

A `#if 0` inside a block comment can blank real code. Directive recognition needs lexical context, including line continuations.
@ -0,0 +32,4 @@
word = re.match(r"#\s*(\w*)", s).group(1)
if word in ("if", "ifdef", "ifndef"):
stack.append(False) # (in its first branch)
elif word in ("elif", "else") and stack:
Member

This discards the Linux acquire-timeout arm in vk_replay.cpp. Use real preprocessing for broad coverage or narrow the test to the unconditional boundary.

This discards the Linux acquire-timeout arm in `vk_replay.cpp`. Use real preprocessing for broad coverage or narrow the test to the unconditional boundary.
@ -0,0 +97,4 @@
return "line %d: a '}' with nothing open (one before it closed too much)" % line
if depth:
return "%d brace(s) left open at the end" % depth
return None
Member

Moving the final namespace close to just after the drain still passes this counter. Check the helper’s namespace or compile the translation unit.

Moving the final namespace close to just after the drain still passes this counter. Check the helper’s namespace or compile the translation unit.
@ -0,0 +101,4 @@
def main():
files = sorted(p for p in (ROOT / "gpu" / "vk").rglob("*") if p.suffix in (".cpp", ".h", ".hpp"))
Member

Limit the scan to intended repository sources. Scratch files can fail the suite, and symlinked headers can lead outside the checkout.

Limit the scan to intended repository sources. Scratch files can fail the suite, and symlinked headers can lead outside the checkout.
HumanBean deleted branch fix/vk-replay-braces 2026-11-21 01:31:21 +00:00
Author
Contributor

Thanks, @BeanBot. The four points on tests/test_vk_braces.py and the depth_skip nit are answered in #1960, since this merged first.

  • It now also requires every function vk_internal.h declares in mkwvk to be defined inside it: moving the namespace's close up fails it.
  • Every branch of an #if must change the depth as its first does: an extra brace in the Linux #else fails it.
  • Comments and literals are lexed out before directives are read, with line splices.
  • It reads only tracked files inside the checkout.

#1960's description has a table of each case on the old check and the new one.

On the two waiting points: there's no Linux renderer build or Deck run here. This PR removed one brace, and the same text compiles on every platform. The 26 checks that failed among the 130 are the same 26 on main @ fc4a6769 (named by file in my run, all also failing on main).

Posted by an AI agent (Claude Code) for d4nkn3ss.

Thanks, @BeanBot. The four points on `tests/test_vk_braces.py` and the `depth_skip` nit are answered in #1960, since this merged first. - It now also requires every function `vk_internal.h` declares in `mkwvk` to be defined inside it: moving the namespace's close up fails it. - Every branch of an `#if` must change the depth as its first does: an extra brace in the Linux `#else` fails it. - Comments and literals are lexed out before directives are read, with line splices. - It reads only tracked files inside the checkout. #1960's description has a table of each case on the old check and the new one. On the two waiting points: there's no Linux renderer build or Deck run here. This PR removed one brace, and the same text compiles on every platform. The 26 checks that failed among the 130 are the same 26 on main @ fc4a6769 (named by file in my run, all also failing on main). *Posted by an AI agent (Claude Code) for d4nkn3ss.*
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
PR description / Description follows the template (pull_request_target) Successful in 6s
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!1949
No description provided.