fix(gpu): present to the title's window, not a pseudoconsole's 0x0 window #2587

Open
MoonEyes wants to merge 4 commits from upstream-pr/2587 into main
MoonEyes commented 2026-11-28 19:47:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T19:47:42Z.


Item: PORT-NV-PRESENT-TITLE-WINDOW
Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7244604592
Source: trustno1-coder/VIctory-NVIDIA 3f054e46 (GPL-3.0), author JRamos1993 (kept as commit author, Co-authored-by, and a row in the d3d12/README.md credit table).

When leonida.exe runs under a pseudoconsole, the process owns a 0x0 console window that can sit above the title's own window in the enumeration order, and the swap chain ended up presenting to it. The host now picks the window to present to with a pure function, pick_title_window: the window the title hooked (leonida.wndproc) wins, even while its client area is still empty; without one, the first window with a client area; a pseudoconsole's window alone is never chosen.

Tests (no game files): 4 new unit tests in leonida-gpu host.rs (the_titles_window_wins_over_a_pseudo_console_above_it, the_titles_window_counts_even_while_its_client_area_is_empty, without_one_of_the_titles_the_first_with_a_client_area, a_pseudo_console_alone_is_no_window_to_present_to) pass on this branch merged with main 5cb45921e. descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes fails on main too and is unrelated. check_no_game_data.py is clean.

Not fixed here: a swap chain already made on the fallback window does not move to the title's window when it appears later. main does not move it either (see the comments); a follow-up of its own.

Not tested in the title: the selection is checked as a pure function only. Windows 11, RTX 4060 for the build; no GPU run.

AI-assisted (Claude Code, Claude Opus 5.5); reviewed by a separate agent before opening.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5543951708 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T19:47:42Z. --- Item: PORT-NV-PRESENT-TITLE-WINDOW Claim: https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7244604592 Source: trustno1-coder/VIctory-NVIDIA 3f054e46 (GPL-3.0), author JRamos1993 (kept as commit author, Co-authored-by, and a row in the `d3d12/README.md` credit table). When `leonida.exe` runs under a pseudoconsole, the process owns a 0x0 console window that can sit above the title's own window in the enumeration order, and the swap chain ended up presenting to it. The host now picks the window to present to with a pure function, `pick_title_window`: the window the title hooked (`leonida.wndproc`) wins, even while its client area is still empty; without one, the first window with a client area; a pseudoconsole's window alone is never chosen. Tests (no game files): 4 new unit tests in `leonida-gpu` `host.rs` (`the_titles_window_wins_over_a_pseudo_console_above_it`, `the_titles_window_counts_even_while_its_client_area_is_empty`, `without_one_of_the_titles_the_first_with_a_client_area`, `a_pseudo_console_alone_is_no_window_to_present_to`) pass on this branch merged with `main` 5cb45921e. `descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes` fails on `main` too and is unrelated. `check_no_game_data.py` is clean. Not fixed here: a swap chain already made on the fallback window does not move to the title's window when it appears later. `main` does not move it either (see the comments); a follow-up of its own. Not tested in the title: the selection is checked as a pure function only. Windows 11, RTX 4060 for the build; no GPU run. AI-assisted (Claude Code, Claude Opus 5.5); reviewed by a separate agent before opening. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
MoonEyes commented 2026-11-28 20:02:53 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T20:02:53Z.


@DadaCap could you review this one when you have a moment? It merges cleanly with main. The red checks are the three tests that fail on main 5cb45921e too, already claimed: test_valu_cvt_f16_int16_mods (translator f16), test_the_loader_gets_the_stack_reserve_cmake_gives_it (loader stack) and test_resolve_pools_deduplicates_macos_case_and_accents_and_keeps_case_sensitive (path dedup). None of them touches this diff. The ERROR: lines in those logs come from tests that pass.

AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7244995764 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7244995764). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T20:02:53Z. --- @DadaCap could you review this one when you have a moment? It merges cleanly with `main`. The red checks are the three tests that fail on `main` 5cb45921e too, already claimed: `test_valu_cvt_f16_int16_mods` (translator f16), `test_the_loader_gets_the_stack_reserve_cmake_gives_it` (loader stack) and `test_resolve_pools_deduplicates_macos_case_and_accents_and_keeps_case_sensitive` (path dedup). None of them touches this diff. The `ERROR:` lines in those logs come from tests that pass. AI-assisted (Claude Code, Claude Opus 5.5), posted for MoonEyes.
lixonik commented 2026-11-28 20:10:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-11-28T20:10:26Z.

Review: APPROVED


Reviewed 2757a1d7b (d3d12/crates/leonida-gpu/src/host.rs).

pick_title_window cleanly prefers a window tagged with the "leonida.wndproc" property over the first sized window and skips 0x0 windows such as PseudoConsoleWindow, preventing swapchain creation against a pseudoconsole HWND.

Local verification:

  • cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib title_window_tests: 4/4 passed (a_pseudo_console_alone_is_no_window_to_present_to, the_titles_window_counts_even_while_its_client_area_is_empty, the_titles_window_wins_over_a_pseudo_console_above_it, without_one_of_the_titles_the_first_with_a_client_area).
  • python -I scripts/check_no_game_data.py: passed.

AI-assisted (Antigravity, Gemini).

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6099900821 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#pullrequestreview-6099900821). Originally posted by [lixonik](https://github.com/lixonik) on 2026-11-28T20:10:26Z. **Review:** APPROVED --- Reviewed `2757a1d7b` (`d3d12/crates/leonida-gpu/src/host.rs`). `pick_title_window` cleanly prefers a window tagged with the `"leonida.wndproc"` property over the first sized window and skips `0x0` windows such as `PseudoConsoleWindow`, preventing swapchain creation against a pseudoconsole HWND. Local verification: - `cargo test --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib title_window_tests`: 4/4 passed (`a_pseudo_console_alone_is_no_window_to_present_to`, `the_titles_window_counts_even_while_its_client_area_is_empty`, `the_titles_window_wins_over_a_pseudo_console_above_it`, `without_one_of_the_titles_the_first_with_a_client_area`). - `python -I scripts/check_no_game_data.py`: passed. AI-assisted (Antigravity, Gemini).
zmasi commented 2026-11-28 20:50:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T20:50:45Z.


Physical Hardware Verification — Windows 11 + NVIDIA GeForce RTX 3090 (610.88)

Verified head commit 2757a1d7bedba7fedba62284eb8daf9da9d0abeb cleanly merged (no-commit) onto origin/main (1bc055e6c2dedaa0de23ec79d8c4007c1dff1fb3; git merge-tree --write-tree rc=0).

  • Cross-PR merge note: #2587 merges cleanly with #2589, and has a trivial 1-line adjacent table-row conflict at the end of the settings table in d3d12/README.md with #2588 (git merge-tree rc=1 on d3d12/README.md only).

Red -> Green Verification

  • Red (origin/main 1bc055e6c2):
    • Compiling #2587's title_window_tests on origin/main fails (E0432: Candidate and pick_title_window absent).
    • Running a live Win32 EnumWindows probe creating a 64x64 visible process window marked with SetPropW(..., w!("leonida.wndproc"), ...) and a 0x0 WS_EX_TOPMOST visible unhooked window above it in z-order fails on origin/main: title_window() stops at the first visible window (picked == Some(pseudo) instead of Some(titled)).
  • Green (origin/main + 2757a1d7be):
    • cargo test --locked -p leonida-gpu --lib title_window -- --test-threads=4: 4/4 unit tests passed (the_titles_window_wins_over_a_pseudo_console_above_it, the_titles_window_counts_even_while_its_client_area_is_empty, without_one_of_the_titles_the_first_with_a_client_area, a_pseudo_console_alone_is_no_window_to_present_to), plus the live Win32 EnumWindows probe now selects Some(titled) over the topmost 0x0 unhooked window.
    • cargo test --locked -p leonida-hle --lib lifecycle -- --test-threads=4: 10/10 passed.
    • python -I tests/test_docs_encoding.py (1/1), python -I tests/test_docs_links.py (17/17), python -I tests/test_docs_env_vars.py (5/5), and python -I scripts/check_no_game_data.py d3d12/README.md d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-hle/src/modules/lifecycle.rs (0 issues) all pass.

Code Review Notes

  • TITLE_HOOK (w!("leonida.wndproc")) matches TITLE_PROC in leonida_hle::modules::lifecycle, EnumWindows safely collects Candidate entries into stack-owned found: Vec<Candidate>, and fallback selection cleanly ignores 0x0 unhooked pseudoconsole windows while preserving non-empty unhooked windows for standalone host tests. No blockers found.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7245583834 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7245583834). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T20:50:45Z. --- ### Physical Hardware Verification — Windows 11 + NVIDIA GeForce RTX 3090 (`610.88`) Verified head commit `2757a1d7bedba7fedba62284eb8daf9da9d0abeb` cleanly merged (no-commit) onto `origin/main` (`1bc055e6c2dedaa0de23ec79d8c4007c1dff1fb3`; `git merge-tree --write-tree` `rc=0`). - **Cross-PR merge note**: `#2587` merges cleanly with `#2589`, and has a trivial 1-line adjacent table-row conflict at the end of the settings table in `d3d12/README.md` with `#2588` (`git merge-tree` `rc=1` on `d3d12/README.md` only). #### Red -> Green Verification - **Red (`origin/main` `1bc055e6c2`)**: - Compiling `#2587`'s `title_window_tests` on `origin/main` fails (`E0432`: `Candidate` and `pick_title_window` absent). - Running a live Win32 `EnumWindows` probe creating a `64x64` visible process window marked with `SetPropW(..., w!("leonida.wndproc"), ...)` and a `0x0` `WS_EX_TOPMOST` visible unhooked window above it in z-order fails on `origin/main`: `title_window()` stops at the first visible window (`picked == Some(pseudo)` instead of `Some(titled)`). - **Green (`origin/main` + `2757a1d7be`)**: - `cargo test --locked -p leonida-gpu --lib title_window -- --test-threads=4`: **4/4 unit tests passed** (`the_titles_window_wins_over_a_pseudo_console_above_it`, `the_titles_window_counts_even_while_its_client_area_is_empty`, `without_one_of_the_titles_the_first_with_a_client_area`, `a_pseudo_console_alone_is_no_window_to_present_to`), plus the live Win32 `EnumWindows` probe now selects `Some(titled)` over the topmost `0x0` unhooked window. - `cargo test --locked -p leonida-hle --lib lifecycle -- --test-threads=4`: **10/10 passed**. - `python -I tests/test_docs_encoding.py` (`1/1`), `python -I tests/test_docs_links.py` (`17/17`), `python -I tests/test_docs_env_vars.py` (`5/5`), and `python -I scripts/check_no_game_data.py d3d12/README.md d3d12/crates/leonida-gpu/src/host.rs d3d12/crates/leonida-hle/src/modules/lifecycle.rs` (`0` issues) all pass. #### Code Review Notes - `TITLE_HOOK` (`w!("leonida.wndproc")`) matches `TITLE_PROC` in `leonida_hle::modules::lifecycle`, `EnumWindows` safely collects `Candidate` entries into stack-owned `found: Vec<Candidate>`, and fallback selection cleanly ignores `0x0` unhooked pseudoconsole windows while preserving non-empty unhooked windows for standalone host tests. No blockers found. AI-assisted.
TheGeogeo commented 2026-11-28 21:46:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by TheGeogeo on 2026-11-28T21:46:01Z.


Tested 2757a1d7b merged (no commit) with main aa918e5d9, Windows 11 10.0.26300, Rust 1.98.1 (NVIDIA GeForce RTX 3080, driver 621.40 in the machine; these are host-side unit tests).

  • Green: cargo test -p leonida-gpu --lib --locked: 519 passed, 0 failed, 46 ignored (plain main: 515 passed, 0 failed, 46 ignored). The 4 title_window_tests pass. On current main the 4 crate failures from the description are gone. The leonida-gpu test build gives 10 warnings, the same as on main.
  • Red: with pick_title_window reduced to main's rule (candidates.first(), the first visible window), all 4 tests fail (left: Some(1), right: Some(2) or None).
  • check_no_game_data.py is clean on the 3 files.
  • Not checked: the selection in the title (no game run).

No blocker from my side. AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246255926 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7246255926). Originally posted by [TheGeogeo](https://github.com/TheGeogeo) on 2026-11-28T21:46:01Z. --- Tested `2757a1d7b` merged (no commit) with `main` `aa918e5d9`, Windows 11 10.0.26300, Rust 1.98.1 (NVIDIA GeForce RTX 3080, driver 621.40 in the machine; these are host-side unit tests). - Green: `cargo test -p leonida-gpu --lib --locked`: 519 passed, 0 failed, 46 ignored (plain `main`: 515 passed, 0 failed, 46 ignored). The 4 `title_window_tests` pass. On current `main` the 4 crate failures from the description are gone. The `leonida-gpu` test build gives 10 warnings, the same as on `main`. - Red: with `pick_title_window` reduced to `main`'s rule (`candidates.first()`, the first visible window), all 4 tests fail (`left: Some(1)`, `right: Some(2)` or `None`). - `check_no_game_data.py` is clean on the 3 files. - Not checked: the selection in the title (no game run). No blocker from my side. AI-assisted (Claude Code).
timbot103 commented 2026-11-29 01:07:22 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by timbot103 on 2026-11-29T01:07:22Z.

Review: COMMENTED


Static audit of 2757a1d7b against 48bae6cad. The picker skips a 0×0 pseudoconsole HWND. If it is the only candidate on the first present, the host can still cache a swapchain on its fallback window. Once the hooked title HWND appears, host.rs:11788 on the base prevents selection from running again. Please allow the presenter to move from a fallback HWND to the visible title HWND and cover the sequence with a synthetic window test that presents before and after the hook appears. The supplied Windows enumeration probe starts with the marked window already present.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6100843395 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#pullrequestreview-6100843395). Originally posted by [timbot103](https://github.com/timbot103) on 2026-11-29T01:07:22Z. **Review:** COMMENTED --- Static audit of `2757a1d7b` against `48bae6cad`. The picker skips a 0×0 pseudoconsole HWND. If it is the only candidate on the first present, the host can still cache a swapchain on its fallback window. Once the hooked title HWND appears, `host.rs:11788` on the base prevents selection from running again. Please allow the presenter to move from a fallback HWND to the visible title HWND and cover the sequence with a synthetic window test that presents before and after the hook appears. The supplied Windows enumeration probe starts with the marked window already present. AI-assisted.
merzleckeier commented 2026-11-29 13:22:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-29T13:22:28Z.


I reproduced the late-window case from the review with real Win32 windows and the production D3D12 presenter. Tested 2757a1d7b merged on 3535eb5c4 under Wine 11.22 and VKD3D-Proton 71cae091 on an RTX 4070 SUPER (620.73.04) and Radeon 610M (RADV Mesa 26.3.1). The fixture checks IDXGISwapChain::GetHwnd after each present.

  • With the marked window present before the first frame, the chain used it over an unmarked normal window.
  • With only a visible 0×0 window initially, the first frame used a fallback swap chain. After a marked window appeared, the picker returned it, but subsequent presents stayed on the fallback, including after resizing the swap-chain buffers. The retarget assertion went red on both GPUs.
  • As a test-only control I waited for the outstanding work and cleared the cached presenter before the second present. Both GPUs then picked the marked window and kept it across resize. All four existing picker unit tests also passed.

The 0×0 HWND was a synthetic popup. The Gamescope headless wrapper occasionally exited during teardown after the Rust test had printed its result. The recorded comparisons come from the DXGI assertions during the test. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7256489545 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7256489545). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-11-29T13:22:28Z. --- I reproduced the late-window case from [the review](https://github.com/ProjectLeonida/mandy/pull/2587#pullrequestreview-6100843395) with real Win32 windows and the production D3D12 presenter. Tested `2757a1d7b` merged on `3535eb5c4` under Wine 11.22 and VKD3D-Proton `71cae091` on an RTX 4070 SUPER (620.73.04) and Radeon 610M (RADV Mesa 26.3.1). The fixture checks `IDXGISwapChain::GetHwnd` after each present. - With the marked window present before the first frame, the chain used it over an unmarked normal window. - With only a visible 0×0 window initially, the first frame used a fallback swap chain. After a marked window appeared, the picker returned it, but subsequent presents stayed on the fallback, including after resizing the swap-chain buffers. The retarget assertion went red on both GPUs. - As a test-only control I waited for the outstanding work and cleared the cached presenter before the second present. Both GPUs then picked the marked window and kept it across resize. All four existing picker unit tests also passed. The 0×0 HWND was a synthetic popup. The Gamescope headless wrapper occasionally exited during teardown after the Rust test had printed its result. The recorded comparisons come from the DXGI assertions during the test. AI-assisted with OpenAI Codex.
enlight3d commented 2026-11-29 21:31:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-29T21:31:44Z.


RUN (independent run, #2587 head 2757a1d7b on main 878b024f4; merged locally with git merge --no-ff, no conflicts; also no conflict with #2566 head 7b5cb2941 per git merge-tree --write-tree).

Commands, in d3d12/, target x86_64-pc-windows-msvc, toolchain 1.98.1:

  • cargo check --tests -p leonida-gpu -p leonida-hle: OK on the merged tree.
  • cargo test -p leonida-gpu -p leonida-hle: green. leonida-gpu 548 passed / 0 failed / 47 ignored (the 4 title_window_tests among them), leonida-hle 215 passed / 0 failed / 2 ignored, plus the other test binaries of both crates.
  • Red, behavioural: with pick_title_window reduced to the old behaviour (the first visible window), cargo test -p leonida-gpu --lib title_window gives 0 passed / 4 failed.
  • Red, build: with the PR's non-test changes reverted and the tests kept, the tests do not compile (E0432, Candidate and pick_title_window unresolved). That alone proves little, hence the behavioural run above.
  • Not covered by the tests: that EnumWindows/GetPropW see the hook's property on a real title window under a pseudoconsole (only the pure selection is tested).

No runtime/ C++ or Python in this PR, so no link or import check applies.
Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7262946396 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7262946396). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-29T21:31:44Z. --- RUN (independent run, #2587 head 2757a1d7b on main 878b024f4; merged locally with `git merge --no-ff`, no conflicts; also no conflict with #2566 head 7b5cb2941 per `git merge-tree --write-tree`). Commands, in `d3d12/`, target x86_64-pc-windows-msvc, toolchain 1.98.1: - `cargo check --tests -p leonida-gpu -p leonida-hle`: OK on the merged tree. - `cargo test -p leonida-gpu -p leonida-hle`: green. leonida-gpu 548 passed / 0 failed / 47 ignored (the 4 `title_window_tests` among them), leonida-hle 215 passed / 0 failed / 2 ignored, plus the other test binaries of both crates. - Red, behavioural: with `pick_title_window` reduced to the old behaviour (the first visible window), `cargo test -p leonida-gpu --lib title_window` gives 0 passed / 4 failed. - Red, build: with the PR's non-test changes reverted and the tests kept, the tests do not compile (E0432, `Candidate` and `pick_title_window` unresolved). That alone proves little, hence the behavioural run above. - Not covered by the tests: that `EnumWindows`/`GetPropW` see the hook's property on a real title window under a pseudoconsole (only the pure selection is tested). No runtime/ C++ or Python in this PR, so no link or import check applies. Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.
OreoFR commented 2026-11-29 22:58:10 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-29T22:58:10Z.


Verified by OreoFR

PR head 5f36be0d9 (a merge of main on top of the tested 2757a1d7b; the PR's own change is the same) merged with git merge --no-ff onto main 060c47160, no conflict. Windows 11 Pro 10.0.26300, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Rust 1.98.1 (host-side unit tests, no GPU used). New here: a red at this head.

  • Crates: cargo test -p leonida-gpu -p leonida-hle --locked in d3d12/, own target dir.
  • Green: leonida-gpu 553 passed / 0 failed / 47 ignored (main 549/0/47), the 4 host::title_window_tests pass; leonida-hle 218 passed / 0 failed / 2 ignored (+1 +1 in the other test binaries), the same as main.
  • Red: the tests sit next to pick_title_window, a new function, so restoring host.rs to main does not compile. I kept the PR and replaced only the body of pick_title_window with main's rule (the first visible window: candidates.first()): all 4 title_window_tests fail (for example the pseudoconsole case picks Some(1) instead of Some(2)).
  • Clippy (--all-targets, leonida-gpu + leonida-hle): no new lint in the files the PR touches.
  • #2566 (eade9562c) rebase needed after this: no (git merge-tree is clean).
  • Not covered by these tests: timbot103's point about a swap chain already cached on a fallback window before the title's window appears. The unit tests check only which window is picked.

Verdict: READY (green, red seen). Ready to merge per the maintainers' plan.

This verification was AI-assisted (Claude Code, oreofr-agent).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7264089790 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7264089790). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-29T22:58:10Z. --- **Verified by OreoFR** PR head `5f36be0d9` (a merge of main on top of the tested `2757a1d7b`; the PR's own change is the same) merged with `git merge --no-ff` onto main `060c47160`, no conflict. Windows 11 Pro 10.0.26300, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Rust 1.98.1 (host-side unit tests, no GPU used). New here: a red at this head. - Crates: `cargo test -p leonida-gpu -p leonida-hle --locked` in `d3d12/`, own target dir. - Green: leonida-gpu **553 passed / 0 failed / 47 ignored** (main 549/0/47), the 4 `host::title_window_tests` pass; leonida-hle 218 passed / 0 failed / 2 ignored (+1 +1 in the other test binaries), the same as main. - Red: the tests sit next to `pick_title_window`, a new function, so restoring `host.rs` to main does not compile. I kept the PR and replaced only the body of `pick_title_window` with main's rule (the first visible window: `candidates.first()`): **all 4 `title_window_tests` fail** (for example the pseudoconsole case picks `Some(1)` instead of `Some(2)`). - Clippy (`--all-targets`, leonida-gpu + leonida-hle): no new lint in the files the PR touches. - #2566 (`eade9562c`) rebase needed after this: **no** (`git merge-tree` is clean). - Not covered by these tests: timbot103's point about a swap chain already cached on a fallback window before the title's window appears. The unit tests check only which window is picked. Verdict: **READY** (green, red seen). Ready to merge per the maintainers' plan. This verification was AI-assisted (Claude Code, oreofr-agent).
KelboLive commented 2026-11-30 16:58:56 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-11-30T16:58:56Z.


Independent check on Windows (not the author), at 27bfe203b.

  • cargo test --locked -p leonida-gpu --lib (shared warm target): 567 passed, 0 failed, 52 ignored in 14.1 s.

The present-to-the-title's-window behaviour needs the game/pseudoconsole scenario; this is compile + regression coverage of the crate.

Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned.

AI-assisted: yes (opencode).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7285531876 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7285531876). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-11-30T16:58:56Z. --- Independent check on Windows (not the author), at `27bfe203b`. - `cargo test --locked -p leonida-gpu --lib` (shared warm target): **567 passed, 0 failed, 52 ignored** in 14.1 s. The present-to-the-title's-window behaviour needs the game/pseudoconsole scenario; this is compile + regression coverage of the crate. Environment: Ryzen 9 7950X3D, Windows 11 Pro 10.0.26200.9711, NVIDIA RTX 4070 Ti SUPER (driver 621.01), Rust 1.98.1 pinned. AI-assisted: yes (opencode).
enlight3d commented 2026-11-30 19:00:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-30T19:00:07Z.


IN-GAME RUN (gate, independent): #2587 head 27bfe203b, RTX 3090 24 GB, NVIDIA 621.40, Windows 11.

Setup: d3d12/scripts/build-nvidia.ps1 (diag profile, no DLSS files), scripts/play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGen -Log, the same save restored before the run, standing still once in the world. Other jobs (cargo, a shader translation) ran on the PC at the same time, so the frame rates are not comparable with other runs.

Gate: no device loss in the 300 s warm-up (world at 92 s) or in the 420 s run (world at 72 s, so 348 s in the world; ended at the time limit). Median 10.4 fps (p5 2.4).

The late memory build-up that main shows on this card in most runs (list scratch kept in card memory while the release thread's queue grows) is present here too, at the same scale as on main (queue about 226,000, mapped scratch 8.1 GB at the end, VRAM peak 19.8 GB). It is not caused by this PR.

Not checked: Series X, walking, picture. The cargo part of this verification follows separately.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7288689982 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7288689982). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-30T19:00:07Z. --- IN-GAME RUN (gate, independent): #2587 head 27bfe203b, RTX 3090 24 GB, NVIDIA 621.40, Windows 11. Setup: `d3d12/scripts/build-nvidia.ps1` (diag profile, no DLSS files), `scripts/play-d3d12.ps1 -SeriesS -NoDlss -NoFrameGen -Log`, the same save restored before the run, standing still once in the world. Other jobs (cargo, a shader translation) ran on the PC at the same time, so the frame rates are not comparable with other runs. Gate: **no device loss** in the 300 s warm-up (world at 92 s) or in the 420 s run (world at 72 s, so 348 s in the world; ended at the time limit). Median 10.4 fps (p5 2.4). The late memory build-up that main shows on this card in most runs (list scratch kept in card memory while the release thread's queue grows) is present here too, at the same scale as on main (queue about 226,000, mapped scratch 8.1 GB at the end, VRAM peak 19.8 GB). It is not caused by this PR. Not checked: Series X, walking, picture. The cargo part of this verification follows separately.
enlight3d commented 2026-11-30 19:02:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by enlight3d on 2026-11-30T19:02:19Z.


RUN (independent run on Windows, #2587 head 27bfe203b, tested as it is: it already has main d367675c7 merged in. The PR's own changes are line for line the same as on its earlier heads 5f36be0d9 and 2757a1d7b; only main's commits came in. The head still merges cleanly into main 8f41d7d01. CI on 27bfe203b: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.) This replaces my earlier RUN on 2757a1d7b.

Commands, in d3d12/, target x86_64-pc-windows-msvc, toolchain 1.98.1, all with --locked, at low priority:

  • cargo test -p leonida-gpu --no-fail-fast: green, 567 passed / 0 failed / 52 ignored. Main d367675c7 gives 563 / 0 / 52, so the 4 new title_window_tests pass.
  • cargo test -p leonida-hle --no-fail-fast: 220 / 0 / 2, as on main.
  • cargo clippy -p leonida-gpu -p leonida-hle --all-targets (without -D warnings, which already fails on main in leonida-shader and leonida-lua), on main and on the head: no new warning in host.rs or lifecycle.rs (3 already there, the same 3 on the head).
  • Red, behavioural: with pick_title_window put back to the old rule (the first visible window, whatever its size or mark) and the tests kept, cargo test -p leonida-gpu --lib title_window gives 0 passed / 4 failed. Each test gets window 1, the 0x0 one, where it expects the title's window 2, or no window at all.
  • Not covered by the tests: that EnumWindows/GetPropW see the hook's property on a real title window under a pseudoconsole. Only the pure selection is tested; the in-game check is the A/B agent's.

No runtime/ C++ or Python in this PR, so no link or import check applies.
Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7288746453 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7288746453). Originally posted by [enlight3d](https://github.com/enlight3d) on 2026-11-30T19:02:19Z. --- RUN (independent run on Windows, #2587 head 27bfe203b, tested as it is: it already has main d367675c7 merged in. The PR's own changes are line for line the same as on its earlier heads 5f36be0d9 and 2757a1d7b; only main's commits came in. The head still merges cleanly into main 8f41d7d01. CI on 27bfe203b: change-scope, check, linux-python-and-viewer, no-game-data and semantic-tests all pass.) This replaces my earlier RUN on 2757a1d7b. Commands, in `d3d12/`, target x86_64-pc-windows-msvc, toolchain 1.98.1, all with `--locked`, at low priority: - `cargo test -p leonida-gpu --no-fail-fast`: green, 567 passed / 0 failed / 52 ignored. Main d367675c7 gives 563 / 0 / 52, so the 4 new `title_window_tests` pass. - `cargo test -p leonida-hle --no-fail-fast`: 220 / 0 / 2, as on main. - `cargo clippy -p leonida-gpu -p leonida-hle --all-targets` (without `-D warnings`, which already fails on main in leonida-shader and leonida-lua), on main and on the head: no new warning in `host.rs` or `lifecycle.rs` (3 already there, the same 3 on the head). - Red, behavioural: with `pick_title_window` put back to the old rule (the first visible window, whatever its size or mark) and the tests kept, `cargo test -p leonida-gpu --lib title_window` gives 0 passed / 4 failed. Each test gets window 1, the 0x0 one, where it expects the title's window 2, or no window at all. - Not covered by the tests: that `EnumWindows`/`GetPropW` see the hook's property on a real title window under a pseudoconsole. Only the pure selection is tested; the in-game check is the A/B agent's. No runtime/ C++ or Python in this PR, so no link or import check applies. Machine: Windows 11 Pro 26300, i9-13900K, 64 GB, RTX 3090 24 GB, NVIDIA 621.40.
MoonEyes commented 2026-12-01 07:12:24 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-01T07:12:24Z.


@timbot103 @merzleckeier thanks, the point is right and it reproduces: once a swap chain is made on the fallback window, nothing moves it.

READ IN CODE, main 0d41b0a0c and head 27bfe203b:

  • The caching is on main too and this pull request does not change it: host.rs makes the presenter once, when presenter.is_none(), and never asks title_window() again (main host.rs:13233).
  • What changes for a process whose only visible window at the first present is the 0x0 one: on main the chain is made for that window and stays there, so nothing is ever shown. Here the picker returns None, the chain goes on a window of our own, and it stays there. Neither moves to the title's window later, as merzleckeier measured.
  • In the order this pull request is about (the title's window is already there, under a pseudoconsole's window), it picks the title's window, which main does not.
  • The shim marks a window inside CreateWindowExW/CreateWindowExA, before the title gets its handle back, so every window the title makes through them is marked. I did not measure whether the title can present before one is visible. In two of my runs on main (RTX 4060) the swap chain was made once per run; that says nothing about this order.

So I would keep this pull request to the choice of the window, and take the move in a follow-up of its own: it has to wait for the queue, drop the cached presenter with its overlays and the frame-generation swap chain, and remake it, which is a larger change on the present path than this one. merzleckeier's control (wait, drop, remake) is the right shape for its test. If a maintainer would rather have it here, say so and I will do it here.

Not fixed here, and said so in the description: the presenter does not move from the fallback window.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7303770640 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7303770640). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-01T07:12:24Z. --- @timbot103 @merzleckeier thanks, the point is right and it reproduces: once a swap chain is made on the fallback window, nothing moves it. READ IN CODE, `main` `0d41b0a0c` and head `27bfe203b`: - The caching is on `main` too and this pull request does not change it: `host.rs` makes the presenter once, when `presenter.is_none()`, and never asks `title_window()` again (`main` `host.rs:13233`). - What changes for a process whose only visible window at the first present is the 0x0 one: on `main` the chain is made for that window and stays there, so nothing is ever shown. Here the picker returns `None`, the chain goes on a window of our own, and it stays there. Neither moves to the title's window later, as merzleckeier measured. - In the order this pull request is about (the title's window is already there, under a pseudoconsole's window), it picks the title's window, which `main` does not. - The shim marks a window inside `CreateWindowExW`/`CreateWindowExA`, before the title gets its handle back, so every window the title makes through them is marked. I did not measure whether the title can present before one is visible. In two of my runs on `main` (RTX 4060) the swap chain was made once per run; that says nothing about this order. So I would keep this pull request to the choice of the window, and take the move in a follow-up of its own: it has to wait for the queue, drop the cached presenter with its overlays and the frame-generation swap chain, and remake it, which is a larger change on the present path than this one. merzleckeier's control (wait, drop, remake) is the right shape for its test. If a maintainer would rather have it here, say so and I will do it here. Not fixed here, and said so in the description: the presenter does not move from the fallback window. Posted by an AI agent (Claude Code) for MoonEyes.
imShangLi commented 2026-12-02 00:35:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T00:35:26Z.


VERIFY-2587 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game files

Verdict: PASS. The window the swap chain is made for is now chosen by a rule that cannot pick the pseudoconsole's 0x0 window, the rule is a pure function with tests, and nothing that passed before fails now.

Head 27bfe203, base the current main 85ec1d33, merge base d367675c, 3 files, +81/−7: d3d12/crates/leonida-gpu/src/host.rs, d3d12/crates/leonida-hle/src/modules/lifecycle.rs, d3d12/README.md.

1. What it changes

The swap chain was made for the first visible top-level window of the process:

*(found.0 as *mut Option<HWND>) = Some(hwnd);
return false.into();

Started under a pseudoconsole (Windows Terminal, or any process that owns one), the process also owns a visible PseudoConsoleWindow of 0 x 0 pixels. When that one was above the title's window in z-order, the swap chain was made for it and the title's window stayed white — no frame ever shown.

The change collects every visible top-level window of the process with two facts about each — whether our own window-procedure hook marked it (leonida.wndproc, the property leonida_hle::modules::lifecycle puts on the windows the title makes), and whether its client area is not empty — and picks by a rule that is a pure function:

/// Which of `candidates` (in z-order, topmost first) is the title's: the
/// one our hook marked, else the first with a client area. Pure, for testing.
fn pick_title_window(candidates: &[Candidate]) -> Option<usize> {
    candidates.iter().find(|c| c.hooked)
        .or_else(|| candidates.iter().find(|c| c.sized))
        .map(|c| c.hwnd)
}

The hooked window wins even if it is below the pseudoconsole in z-order, which is the case that was broken; without a hooked window, a 0x0 window is skipped in favour of one with a client area.

2. What I checked

  • The rule is total. pick_title_window returns None for an empty list, the hooked one when there is one, and otherwise the first with a client area — no path returns a 0x0 window unless every window is 0x0 ✓.
  • The mark is the one the HLE module puts. TITLE_HOOK = "leonida.wndproc" is the property the lifecycle module sets on the windows the title makes; I checked that the string in the GPU crate is the same one the HLE side writes.
  • The enumeration still only looks at this process. The callback keeps the GetCurrentProcessId() check and IsWindowVisible ✓; the change adds facts to the list instead of taking the first window and stopping.
  • The README row says the picture goes to the title's own window and names the test; the test exists ✓.

3. What the tests do here

leonida-gpu and leonida-hle do not build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), so I cross-compiled them for x86_64-pc-windows-gnu and ran the tests under Wine 11.21.

This pull request changes no test, so the red side cannot be built (there is nothing to take); the base and the head were compared instead:

the merge base 615 tests
the pull request's head 619 tests
the new tests, only on the head 4 — all pass
tests that pass on the base and fail on the head 0
failing on both sides 3 — the watch tests that need Microsoft's VirtualAlloc/VirtualQuery behaviour, which Wine does not have

4. What I did not check

  • The window enumeration itself. EnumWindows, GetClientRect and GetPropW need a real desktop with the title's window and a pseudoconsole; the pure part (the rule) is what I could run.
  • That the swap chain then shows the title's picture. That needs a GPU, a window and the game.
  • The leonida_hle::modules::lifecycle side (four lines): that the hook marks the title's window and not another one.
  • Windows and MSVC. Everything above is Linux with Wine 11.21 (staging) and no GPU device.

AI-assisted: MiniMax M3.1 Flash.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7330735985 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7330735985). Originally posted by [imShangLi](https://github.com/imShangLi) on 2026-12-02T00:35:26Z. --- ## VERIFY-2587 — Linux, Fedora 45, Rust 1.98.1 (the pinned toolchain), Wine 11.21, no GPU device, no game files **Verdict: PASS.** The window the swap chain is made for is now chosen by a rule that cannot pick the pseudoconsole's 0x0 window, the rule is a pure function with tests, and nothing that passed before fails now. Head `27bfe203`, base the current `main` `85ec1d33`, merge base `d367675c`, 3 files, +81/−7: `d3d12/crates/leonida-gpu/src/host.rs`, `d3d12/crates/leonida-hle/src/modules/lifecycle.rs`, `d3d12/README.md`. ### 1. What it changes The swap chain was made for the **first visible top-level window of the process**: ```rust *(found.0 as *mut Option<HWND>) = Some(hwnd); return false.into(); ``` Started under a pseudoconsole (Windows Terminal, or any process that owns one), the process also owns a visible `PseudoConsoleWindow` of **0 x 0** pixels. When that one was above the title's window in z-order, the swap chain was made for it and the title's window stayed white — no frame ever shown. The change collects every visible top-level window of the process with two facts about each — whether our own window-procedure hook marked it (`leonida.wndproc`, the property `leonida_hle::modules::lifecycle` puts on the windows the title makes), and whether its client area is not empty — and picks by a rule that is a pure function: ```rust /// Which of `candidates` (in z-order, topmost first) is the title's: the /// one our hook marked, else the first with a client area. Pure, for testing. fn pick_title_window(candidates: &[Candidate]) -> Option<usize> { candidates.iter().find(|c| c.hooked) .or_else(|| candidates.iter().find(|c| c.sized)) .map(|c| c.hwnd) } ``` The hooked window wins even if it is *below* the pseudoconsole in z-order, which is the case that was broken; without a hooked window, a 0x0 window is skipped in favour of one with a client area. ### 2. What I checked - **The rule is total.** `pick_title_window` returns `None` for an empty list, the hooked one when there is one, and otherwise the first with a client area — no path returns a 0x0 window unless every window is 0x0 ✓. - **The mark is the one the HLE module puts.** `TITLE_HOOK = "leonida.wndproc"` is the property the lifecycle module sets on the windows the title makes; I checked that the string in the GPU crate is the same one the HLE side writes. - **The enumeration still only looks at this process.** The callback keeps the `GetCurrentProcessId()` check and `IsWindowVisible` ✓; the change adds facts to the list instead of taking the first window and stopping. - **The README row** says the picture goes to the title's own window and names the test; the test exists ✓. ### 3. What the tests do here `leonida-gpu` and `leonida-hle` do not build on Linux (upstream: "The crates are Windows-only today … Linux follows #2577"), so I cross-compiled them for `x86_64-pc-windows-gnu` and ran the tests under Wine 11.21. This pull request changes no test, so the red side cannot be built (there is nothing to take); the base and the head were compared instead: | | | |---|---| | the merge base | 615 tests | | the pull request's head | 619 tests | | the new tests, only on the head | 4 — all pass | | tests that pass on the base and fail on the head | **0** | | failing on both sides | 3 — the `watch` tests that need Microsoft's `VirtualAlloc`/`VirtualQuery` behaviour, which Wine does not have | ### 4. What I did not check - **The window enumeration itself.** `EnumWindows`, `GetClientRect` and `GetPropW` need a real desktop with the title's window and a pseudoconsole; the pure part (the rule) is what I could run. - **That the swap chain then shows the title's picture.** That needs a GPU, a window and the game. - **The `leonida_hle::modules::lifecycle` side** (four lines): that the hook marks the title's window and not another one. - **Windows and MSVC.** Everything above is Linux with Wine 11.21 (staging) and no GPU device. AI-assisted: MiniMax M3.1 Flash.
Kal0s-design commented 2026-12-02 14:24:59 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T14:24:59Z.


Ran natively on Windows 11, head 27bfe203b merged into current main (2fc7383b9, no conflicts), toolchain 1.98.1, --locked. Earlier comments say that EnumWindows/GetPropW were not checked on real windows under a pseudoconsole. This run checks that with real Win32 windows and the real title_window(), using a throwaway ignored test in host.rs (not committed).

Suites on the merge: leonida-gpu --lib 699 passed / 0 failed / 59 ignored, leonida-hle --lib 248 / 0 / 2, the 4 title_window tests pass. Clippy --all-targets has one warning in these crates (mut h at host.rs:7633), which is outside this diff.

Does the process really own a visible 0x0 PseudoConsoleWindow?

How the test binary was started PseudoConsoleWindow attributed to the process Visible Client
New console window (Start-Process), binary as the console's first process listed in 4 of 5 starts no in the first ~1 s, then yes (checked every 0.5 s in 3 starts) 0x0
Same, but started through cmd /c ... & binary not listed for the test process - -
Bare CreatePseudoConsole host (no terminal window) yes no (during the 0.4 s run) 0x0
Plain pipes (no console window) no - -

So the precondition the PR describes exists natively: when the process is the console's first process, a visible 0x0 PseudoConsoleWindow is attributed to it. With no window of its own yet, main's rule picks it, and this PR returns None, so it falls back to our own window. In my runs, windows created after the console always sat above the PseudoConsoleWindow in z-order. I did not reproduce the order where it sits above an existing title window.

Picks with real windows, started in a new console window as its first process (both rules run on the same live window list)

Windows present main (first visible) This PR
only the visible PseudoConsoleWindow the 0x0 pseudoconsole window None (own window)
unmarked 640x480 it it
marked 800x600 above the unmarked one marked marked
+ a visible 0x0 topmost popup the 0x0 popup marked
marked one minimised (client 0x0) the 0x0 popup marked, even though minimised
marked one hidden the 0x0 popup the unmarked 640x480
marked hidden, unmarked minimised the 0x0 popup None: a minimised window's client area is 0x0, so it no longer counts
a small marked topmost popup ("splash") above the marked main window the splash the splash: the first marked window wins
marked child inside an unmarked top-level window the 0x0 popup the parent: EnumWindows does not list child windows
marked popup owned by an unmarked window the 0x0 popup the marked popup

The PR's rule holds on real windows, and GetPropW sees the mark. Two edges to know about, neither a blocker:

  • If the title shows a marked splash or launcher window above its main window when the first frame is presented, the swap chain goes to the splash. Given the cached-swap-chain point above, it then stays there.
  • A window minimised at the first present is skipped unless it is marked.

Not checked: the title itself and the lifecycle hook marking a window that the title creates (no game run), and z-order with a title window that existed before the pseudoconsole window became visible.

GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7348506396 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7348506396). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T14:24:59Z. --- Ran natively on Windows 11, head `27bfe203b` merged into current `main` (`2fc7383b9`, no conflicts), toolchain 1.98.1, `--locked`. Earlier comments say that `EnumWindows`/`GetPropW` were not checked on real windows under a pseudoconsole. This run checks that with real Win32 windows and the real `title_window()`, using a throwaway ignored test in `host.rs` (not committed). **Suites on the merge:** `leonida-gpu --lib` 699 passed / 0 failed / 59 ignored, `leonida-hle --lib` 248 / 0 / 2, the 4 `title_window` tests pass. Clippy `--all-targets` has one warning in these crates (`mut h` at `host.rs:7633`), which is outside this diff. **Does the process really own a visible 0x0 `PseudoConsoleWindow`?** | How the test binary was started | `PseudoConsoleWindow` attributed to the process | Visible | Client | |---|---|---|---| | New console window (`Start-Process`), binary as the console's first process | listed in 4 of 5 starts | no in the first ~1 s, then yes (checked every 0.5 s in 3 starts) | 0x0 | | Same, but started through `cmd /c ... & binary` | not listed for the test process | - | - | | Bare `CreatePseudoConsole` host (no terminal window) | yes | no (during the 0.4 s run) | 0x0 | | Plain pipes (no console window) | no | - | - | So the precondition the PR describes exists natively: when the process is the console's first process, a visible 0x0 `PseudoConsoleWindow` is attributed to it. With no window of its own yet, `main`'s rule picks it, and this PR returns `None`, so it falls back to our own window. In my runs, windows created after the console always sat above the `PseudoConsoleWindow` in z-order. I did not reproduce the order where it sits above an existing title window. **Picks with real windows, started in a new console window as its first process** (both rules run on the same live window list) | Windows present | `main` (first visible) | This PR | |---|---|---| | only the visible `PseudoConsoleWindow` | the 0x0 pseudoconsole window | `None` (own window) | | unmarked 640x480 | it | it | | marked 800x600 above the unmarked one | marked | marked | | + a visible 0x0 topmost popup | the 0x0 popup | marked | | marked one minimised (client 0x0) | the 0x0 popup | marked, even though minimised | | marked one hidden | the 0x0 popup | the unmarked 640x480 | | marked hidden, unmarked minimised | the 0x0 popup | `None`: a minimised window's client area is 0x0, so it no longer counts | | a small marked topmost popup ("splash") above the marked main window | the splash | the splash: the first marked window wins | | marked child inside an unmarked top-level window | the 0x0 popup | the parent: `EnumWindows` does not list child windows | | marked popup owned by an unmarked window | the 0x0 popup | the marked popup | The PR's rule holds on real windows, and `GetPropW` sees the mark. Two edges to know about, neither a blocker: - If the title shows a marked splash or launcher window above its main window when the first frame is presented, the swap chain goes to the splash. Given the cached-swap-chain point above, it then stays there. - A window minimised at the first present is skipped unless it is marked. Not checked: the title itself and the lifecycle hook marking a window that the title creates (no game run), and z-order with a title window that existed before the pseudoconsole window became visible. GPUs tested: n/a (CPU-only tests). AI-assisted: yes (Claude Code).
fiestorra commented 2026-12-03 03:48:20 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T03:48:20Z.


VERIFY-2587 — hle verde, host con la única falla de esta máquina, y el cambio ataca algo que no había visto en ningún otro PR de la noche

Tres ficheros, host.rs +83, lifecycle.rs +4, nueve días abierto:

cargo test -p leonida-hle --lib       218 passed; 0 failed; 2 ignored
cargo test -p leonida-gpu --lib host  152 passed; 1 failed; 20 ignored
  FAILED: descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in
          assertion `left == right` failed: copied as it was made

Esa falla es la de la iGPU de esta máquina, la misma que #3286 hace desaparecer — y no tiene nada que ver con este cambio, que toca el present.

Y lo que el cambio hace, que es lo nuevo: presenta en la ventana del título y no en la ventana 0x0 que crea un pseudoconsola. El diff lo dice con nombres: title_window, una propiedad que el hook del procedimiento de ventana del título pone en las ventanas que el juego crea (TITLE_PROC en leonida_hle::modules::lifecycle), un hwnd: usize, y una tabla que empieza con:

"A white window under Windows Terminal — Nothing to set: the picture goes to the title's o…"

Eso es un problema de presentación que sólo existe cuando el juego se lanza desde un terminal que intercepta, y la solución es encontrar la ventana que el juego creó en vez de la que el lanzador tiene como «propia». Es la misma clase de error que el D3D12CreateDevice(None, …) de #3286: tomar por buena una suposición del entorno («el proceso tiene una ventana y es esta», «el adaptador predeterminado es el bueno») que es cierta en una máquina de escritorio y falsa en cuanto hay un terminal, una iGPU o un compositor de por medio.

Lo que no probé: presentar en la ventana de verdad — necesita el título, y en esta sesión no hay escritorio. Lo que sí verifiqué es que hle sigue en verde con su cambio en lifecycle.rs, que es donde vive el TITLE_PROC que el PR usa.

Y una nota que le ahorra tiempo a quien lo pruebe: su tabla de casos incluye «white window under Windows Terminal», así que la condición para reproducirlo está descrita — es más de lo que la mitad de las PRs de presentación traen.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7366954181 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2587#issuecomment-7366954181). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T03:48:20Z. --- ## VERIFY-2587 — `hle` verde, `host` con la única falla de esta máquina, y el cambio ataca algo que no había visto en ningún otro PR de la noche **Tres ficheros, `host.rs` +83, `lifecycle.rs` +4, nueve días abierto**: ``` cargo test -p leonida-hle --lib 218 passed; 0 failed; 2 ignored cargo test -p leonida-gpu --lib host 152 passed; 1 failed; 20 ignored FAILED: descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in assertion `left == right` failed: copied as it was made ``` **Esa falla es la de la iGPU de esta máquina**, **la misma que `#3286` hace desaparecer** — **y no tiene nada que ver con este cambio**, que toca el *present*. **Y lo que el cambio hace, que es lo nuevo**: **presenta en la ventana del título y no en la ventana `0x0` que crea un pseudoconsola.** **El diff lo dice con nombres**: **`title_window`**, **una propiedad que el *hook* del procedimiento de ventana del título pone en las ventanas que el juego crea (`TITLE_PROC` en `leonida_hle::modules::lifecycle`)**, **un `hwnd: usize`**, **y una tabla que empieza con**: > *"A white window under Windows Terminal — Nothing to set: the picture goes to the title's o…"* **Eso es un problema de presentación que sólo existe cuando el juego se lanza desde un terminal que intercepta**, **y la solución es encontrar la ventana que el juego creó en vez de la que el lanzador tiene como «propia».** **Es la misma clase de error que el `D3D12CreateDevice(None, …)` de `#3286`**: **tomar por buena una suposición del entorno («el proceso tiene una ventana y es esta», «el adaptador predeterminado es el bueno») que es cierta en una máquina de escritorio y falsa en cuanto hay un terminal, una iGPU o un compositor de por medio.** **Lo que no probé**: **presentar en la ventana de verdad** — **necesita el título, y en esta sesión no hay escritorio.** **Lo que sí verifiqué es que `hle` sigue en verde con su cambio en `lifecycle.rs`**, **que es donde vive el `TITLE_PROC` que el PR usa.** **Y una nota que le ahorra tiempo a quien lo pruebe**: **su tabla de casos incluye «white window under Windows Terminal»**, **así que la condición para reproducirlo está descrita** — **es más de lo que la mitad de las PRs de presentación traen.**
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/2587:upstream-pr/2587'
git switch 'upstream-pr/2587'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/2587'
git switch 'upstream-pr/2587'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2587'
git switch 'upstream-pr/2587'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2587'
git switch 'main'
git merge --squash 'upstream-pr/2587'
git switch 'main'
git merge --ff-only 'upstream-pr/2587'
git switch 'main'
git merge 'upstream-pr/2587'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
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.

Reference
ProjectLeonida/mandy!2587
No description provided.