d3d12/fsr: fix typeless depth SRVs, PrepareV2 barriers, and launcher texture-room cap (D3D12-FSR-FRAMEGEN-DEPTH-AND-ROOM) #3206

Open
zmasi wants to merge 4 commits from upstream-pr/3206 into main
zmasi commented 2026-12-02 19:17:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-12-02T19:17:19Z.


Claimed in the coordination issue as: D3D12-FSR-FRAMEGEN-DEPTH-AND-ROOM (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7354679753)

Addresses #3173 (does not close it until verified in-game on Series S and Series X: fixes typeless depth resource descriptors and SRV formats in fsr.rs, adds explicit PrepareV2 NON_PIXEL_SHADER_RESOURCE barriers + DEPTH_READ state mapping, and removes the launcher's double-counted LEONIDA_TEXTURE_ROOM_PERCENT=80 cap).

What and why

Fixes three defects when LEONIDA_FSR_FRAMEGEN=1 (-FsrFrameGen or FSR 3 FRAME GEN 2X in the F1 menu) is active (#3173):

  1. Launcher LEONIDA_TEXTURE_ROOM_PERCENT = '80' double-counted FSR 3 VRAM and starved bindless & tiled world textures (d3d12/scripts/play-nvidia.ps1):
    • fsr::swap_chain and fsr::create_context allocate FidelityFX's ~1.5-2.0 GB up front on the first frame, so those bytes are already included in DXGI QueryVideoMemoryInfo(LOCAL).CurrentUsage (used in resource::room). Because FidelityFX allocates directly on ID3D12Device outside HOST_TEXTURES[1], its memory also stacks on top of targets_room_kept() (3,072 MB), LEONIDA_WINDOWS_BAR_MB (3,072 MB on < 48 GB RAM PCs), shadow::card_for, and precompiled pipelines.
    • Lowering LEONIDA_TEXTURE_ROOM_PERCENT from 90 to 80 subtracted an additional 10% of budget after FSR's allocations were already counted in used, tripping resource::room() to false right above the 2 GiB floor (resource::texture_floor_bytes) instead of the 5-7.3 GB needed in the open world. Unmade bindless textures (draw.rs heap_textures) and unmapped on_demand reserved mip tiles (texture.rs) read (0, 0, 0, 0) on D3D12 — turning opaque surfaces black (rgb = 0) and discarding alpha-tested foliage/leaves (alpha = 0 < cutoff).
    • Removing the 80% override leaves room_percent() at its 90% default (matching -FrameGen), while explicit -More @{ LEONIDA_TEXTURE_ROOM_PERCENT = '...' } overrides continue to pass through.
  2. fsr::Resource::texture missed Leonida's typeless depth buffers (d3d12/crates/leonida-gpu/src/fsr.rs):
    • resource.rs creates every shader-readable host depth target as typeless (D32_FLOAT_S8X24_UINT -> R32G8X24_TYPELESS, D32_FLOAT -> R32_TYPELESS, D24_UNORM_S8_UINT -> R24G8_TYPELESS, D16_UNORM -> R16_TYPELESS) with D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL.
    • Resource::texture previously checked desc.Format only against typed D16_UNORM | D32_FLOAT | D24_UNORM_S8_UINT | D32_FLOAT_S8X24_UINT, leaving usage = 0 (missing USAGE_DEPTHTARGET and USAGE_STENCILTARGET) and leaving R32_TYPELESS / R16_TYPELESS as typeless surface_format values (37 / 34). Without USAGE_DEPTHTARGET | USAGE_STENCILTARGET and typed surface formats, FidelityFX's DX12 backend selects invalid SRV formats (DXGI_FORMAT_R32_FLOAT on 2-plane R32G8X24_TYPELESS, or raw typeless formats on R32_TYPELESS / R16_TYPELESS) in PrepareV2.
    • Resource::texture now checks D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL alongside typed depth formats, sets USAGE_DEPTHTARGET (plus USAGE_STENCILTARGET on D24_UNORM_S8_UINT | R24G8_TYPELESS | D32_FLOAT_S8X24_UINT | R32G8X24_TYPELESS), and maps depth-flagged R32_TYPELESS -> R32_FLOAT (28) and R16_TYPELESS -> R16_UNORM (23) to match ffxApiGetResourceDX12.
  3. Explicit PrepareV2 NON_PIXEL_SHADER_RESOURCE barriers and DEPTH_READ state mapping (d3d12/crates/leonida-gpu/src/fsr.rs):
    • On the title's own upscaler path (Series X default and Series S without DLSS), scene depth often reaches Present in DEPTH_READ (0x20) or DEPTH_READ | NON_PIXEL_SHADER_RESOURCE | PIXEL_SHADER_RESOURCE (0xE0). ffx_state previously mapped DEPTH_READ to STATE_DEPTH_ATTACHMENT (which FidelityFX maps back to exclusive D3D12_RESOURCE_STATE_DEPTH_WRITE, 0x10), producing illegal 0xD0 (DEPTH_WRITE | *_SHADER_RESOURCE) barriers or leaving depth in DEPTH_WRITE on the GPU while HostTexture::state still recorded DEPTH_READ.
    • before_present now transitions inputs.depth.0 and inputs.motion.0 on list to D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE (0x40) before ffxDispatch(DISPATCH_PREPARE_V2), passes STATE_COMPUTE_READ to PrepareV2, and restores inputs.depth.1 and inputs.motion.1 immediately after ffxDispatch (whether or not the dispatch succeeded). ffx_state also maps DEPTH_READ to STATE_COMPUTE_READ | STATE_PIXEL_READ rather than STATE_DEPTH_ATTACHMENT.

Tested

  • Red -> Green + mutation check (ea43e2cc1 onto origin/main 45dc41f95):
    • python -I scripts/red_green.py HEAD --base 45dc41f95 --no-fetch --mutate (fsr:: + tests/test_win_launchers.py): verdict: red then green, all 4 new/updated tests (3 Rust fsr::tests + 1 Python WinLaunchersTests) go red -> green, every code hunk caught under --mutate.
  • Rust, Python & hygiene suites (x86_64-pc-windows-msvc):
    • cargo test -p leonida-gpu [--features diagnostics] --lib --target x86_64-pc-windows-msvc fsr::: 5 passed, 0 failed in both default and diagnostics builds (verifies CreateShaderResourceView across all 4 typeless depth formats, ffx_state on 0x20 / 0xE0, and real D3D12 command-list + queue execution of before_present PrepareV2 barriers on both succeeding and failing dispatches).
    • cargo clippy -p leonida-gpu [--features diagnostics] --all-targets --no-deps --target x86_64-pc-windows-msvc: 0 warnings in fsr.rs.
    • python -I tests/test_win_launchers.py (7/7 OK), python -I tests/test_play_nvidia_menu_choice.py (16/16 OK), python -I tools/d3d12_switches.py --check d3d12/docs/switches.md (rc=0), python -I tests/test_d3d12_switches.py (20/20 OK), python -I scripts/check_no_game_data.py (rc=0), and python -I tests/test_text_write_line_endings.py (3/3 OK).
    • git merge-tree --write-tree clean (rc=0) against origin/main, #3111, and #3104.

GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Windows 11 Pro 10.0.26200 (D3D12 SRV and command-list barrier unit tests; no retail title run).

AI-assisted: yes — authored with Gemini 4 Carbon (High) and independently audited in a read-only review pass by Gemini 4 Neon (XHigh) (opus-systems-critic).

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed (n/a: no translator rule changed).
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5613090350 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206). Originally posted by [zmasi](https://github.com/zmasi) on 2026-12-02T19:17:19Z. --- Claimed in the coordination issue as: `D3D12-FSR-FRAMEGEN-DEPTH-AND-ROOM` (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7354679753) Addresses #3173 (does not close it until verified in-game on Series S and Series X: fixes typeless depth resource descriptors and SRV formats in `fsr.rs`, adds explicit `PrepareV2` `NON_PIXEL_SHADER_RESOURCE` barriers + `DEPTH_READ` state mapping, and removes the launcher's double-counted `LEONIDA_TEXTURE_ROOM_PERCENT=80` cap). ### What and why Fixes three defects when `LEONIDA_FSR_FRAMEGEN=1` (`-FsrFrameGen` or `FSR 3 FRAME GEN 2X` in the F1 menu) is active (`#3173`): 1. **Launcher `LEONIDA_TEXTURE_ROOM_PERCENT = '80'` double-counted FSR 3 VRAM and starved bindless & tiled world textures (`d3d12/scripts/play-nvidia.ps1`):** - `fsr::swap_chain` and `fsr::create_context` allocate FidelityFX's `~1.5-2.0 GB` up front on the first frame, so those bytes are already included in DXGI `QueryVideoMemoryInfo(LOCAL).CurrentUsage` (`used` in `resource::room`). Because FidelityFX allocates directly on `ID3D12Device` outside `HOST_TEXTURES[1]`, its memory also stacks on top of `targets_room_kept()` (`3,072 MB`), `LEONIDA_WINDOWS_BAR_MB` (`3,072 MB` on `< 48 GB` RAM PCs), `shadow::card_for`, and precompiled pipelines. - Lowering `LEONIDA_TEXTURE_ROOM_PERCENT` from `90` to `80` subtracted an additional `10%` of `budget` after FSR's allocations were already counted in `used`, tripping `resource::room()` to `false` right above the `2 GiB` floor (`resource::texture_floor_bytes`) instead of the `5-7.3 GB` needed in the open world. Unmade bindless textures (`draw.rs` `heap_textures`) and unmapped `on_demand` reserved mip tiles (`texture.rs`) read `(0, 0, 0, 0)` on D3D12 — turning opaque surfaces black (`rgb = 0`) and discarding alpha-tested foliage/leaves (`alpha = 0 < cutoff`). - Removing the `80%` override leaves `room_percent()` at its `90%` default (matching `-FrameGen`), while explicit `-More @{ LEONIDA_TEXTURE_ROOM_PERCENT = '...' }` overrides continue to pass through. 2. **`fsr::Resource::texture` missed Leonida's typeless depth buffers (`d3d12/crates/leonida-gpu/src/fsr.rs`):** - `resource.rs` creates every shader-readable host depth target as typeless (`D32_FLOAT_S8X24_UINT` -> `R32G8X24_TYPELESS`, `D32_FLOAT` -> `R32_TYPELESS`, `D24_UNORM_S8_UINT` -> `R24G8_TYPELESS`, `D16_UNORM` -> `R16_TYPELESS`) with `D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL`. - `Resource::texture` previously checked `desc.Format` only against typed `D16_UNORM | D32_FLOAT | D24_UNORM_S8_UINT | D32_FLOAT_S8X24_UINT`, leaving `usage = 0` (missing `USAGE_DEPTHTARGET` and `USAGE_STENCILTARGET`) and leaving `R32_TYPELESS` / `R16_TYPELESS` as typeless `surface_format` values (`37` / `34`). Without `USAGE_DEPTHTARGET | USAGE_STENCILTARGET` and typed surface formats, FidelityFX's DX12 backend selects invalid SRV formats (`DXGI_FORMAT_R32_FLOAT` on 2-plane `R32G8X24_TYPELESS`, or raw typeless formats on `R32_TYPELESS` / `R16_TYPELESS`) in `PrepareV2`. - `Resource::texture` now checks `D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL` alongside typed depth formats, sets `USAGE_DEPTHTARGET` (plus `USAGE_STENCILTARGET` on `D24_UNORM_S8_UINT | R24G8_TYPELESS | D32_FLOAT_S8X24_UINT | R32G8X24_TYPELESS`), and maps depth-flagged `R32_TYPELESS -> R32_FLOAT (28)` and `R16_TYPELESS -> R16_UNORM (23)` to match `ffxApiGetResourceDX12`. 3. **Explicit `PrepareV2` `NON_PIXEL_SHADER_RESOURCE` barriers and `DEPTH_READ` state mapping (`d3d12/crates/leonida-gpu/src/fsr.rs`):** - On the title's own upscaler path (Series X default and Series S without DLSS), scene depth often reaches `Present` in `DEPTH_READ` (`0x20`) or `DEPTH_READ | NON_PIXEL_SHADER_RESOURCE | PIXEL_SHADER_RESOURCE` (`0xE0`). `ffx_state` previously mapped `DEPTH_READ` to `STATE_DEPTH_ATTACHMENT` (which FidelityFX maps back to exclusive `D3D12_RESOURCE_STATE_DEPTH_WRITE`, `0x10`), producing illegal `0xD0` (`DEPTH_WRITE | *_SHADER_RESOURCE`) barriers or leaving `depth` in `DEPTH_WRITE` on the GPU while `HostTexture::state` still recorded `DEPTH_READ`. - `before_present` now transitions `inputs.depth.0` and `inputs.motion.0` on `list` to `D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE` (`0x40`) before `ffxDispatch(DISPATCH_PREPARE_V2)`, passes `STATE_COMPUTE_READ` to `PrepareV2`, and restores `inputs.depth.1` and `inputs.motion.1` immediately after `ffxDispatch` (whether or not the dispatch succeeded). `ffx_state` also maps `DEPTH_READ` to `STATE_COMPUTE_READ | STATE_PIXEL_READ` rather than `STATE_DEPTH_ATTACHMENT`. ### Tested - **Red -> Green + mutation check (`ea43e2cc1` onto `origin/main` `45dc41f95`):** - `python -I scripts/red_green.py HEAD --base 45dc41f95 --no-fetch --mutate` (`fsr::` + `tests/test_win_launchers.py`): `verdict: red then green`, all 4 new/updated tests (`3` Rust `fsr::tests` + `1` Python `WinLaunchersTests`) go `red -> green`, every code hunk caught under `--mutate`. - **Rust, Python & hygiene suites (`x86_64-pc-windows-msvc`):** - `cargo test -p leonida-gpu [--features diagnostics] --lib --target x86_64-pc-windows-msvc fsr::`: `5 passed, 0 failed` in both default and `diagnostics` builds (verifies `CreateShaderResourceView` across all 4 typeless depth formats, `ffx_state` on `0x20` / `0xE0`, and real D3D12 command-list + queue execution of `before_present` `PrepareV2` barriers on both succeeding and failing dispatches). - `cargo clippy -p leonida-gpu [--features diagnostics] --all-targets --no-deps --target x86_64-pc-windows-msvc`: `0` warnings in `fsr.rs`. - `python -I tests/test_win_launchers.py` (`7/7 OK`), `python -I tests/test_play_nvidia_menu_choice.py` (`16/16 OK`), `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` (`rc=0`), `python -I tests/test_d3d12_switches.py` (`20/20 OK`), `python -I scripts/check_no_game_data.py` (`rc=0`), and `python -I tests/test_text_write_line_endings.py` (`3/3 OK`). - `git merge-tree --write-tree` clean (`rc=0`) against `origin/main`, `#3111`, and `#3104`. GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Windows 11 Pro `10.0.26200` (D3D12 SRV and command-list barrier unit tests; no retail title run). AI-assisted: yes — authored with Gemini 4 Carbon (High) and independently audited in a read-only review pass by Gemini 4 Neon (XHigh) (`opus-systems-critic`). ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed (n/a: no translator rule changed).
icdmkg2 commented 2026-12-02 20:22:17 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by icdmkg2 on 2026-12-02T20:22:17Z.


Third-party Windows verification of #3206 (D3D12-FSR-FRAMEGEN-DEPTH-AND-ROOM) on head 137c231a5

  • Head / base: 137c231a5d0e494169ac67fdf2ed83cc1e6ff6bd merged cleanly (git merge --no-ff) onto origin/main b41763227.
  • Machine: NVIDIA GeForce RTX 5060 Laptop GPU (8 GB, Profile M laptop), driver 621.24 (32.0.16.2124), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 11 10.0.26300.9974, rustc 1.98.1.
  • Scope: synthetic / D3D12 hardware + debug-layer + WARP + Python launcher tests (no retail title run).

Results (MEASURED)

Check Result
python -I scripts/check_no_game_data.py (all 3 touched files) exit 0
python -I tools/d3d12_switches.py --check d3d12/docs/switches.md exit 0
LEONIDA_ADAPTER=5060 python -I scripts/red_green.py 3206 --mutate exit 0 (verdict: red then green) — 4 tests went red → green (fsr::tests::{before_present_transitions_depth_and_motion_for_prepare_and_restores_states, states_and_formats, typeless_depth_resources_carry_depth_stencil_usage_and_valid_srv_formats} + test_win_launchers.py::test_fsr_framegen_leaves_default_texture_room_and_honors_override); 708 pass on both, 0 failures. (--mutate: fsr.rs:709 and fsr.rs:888 caught; the other 5 Rust sub-hunks were reported not caught due to red_green.py running the Python target test even when Rust fails to compile, not missing coverage.)
LEONIDA_ADAPTER=5060 + LEONIDA_D3D12_DEBUG=1 cargo test -p leonida-gpu --features diagnostics --locked --lib -- fsr:: 5 passed, 0 failed (D3D12 Debug Layer clean across typeless depth SRVs and PrepareV2 pre/post NON_PIXEL_SHADER_RESOURCE barriers)
LEONIDA_D3D12_WARP=1 + LEONIDA_D3D12_DEBUG=1 (same fsr:: command, --features diagnostics) 5 passed, 0 failed

Review notes (READ IN CODE)

  • fsr.rs Resource::texture: checks ALLOW_DEPTH_STENCIL alongside typed depth formats, sets USAGE_DEPTHTARGET (+ USAGE_STENCILTARGET for D24_UNORM_S8_UINT / R24G8_TYPELESS / D32_FLOAT_S8X24_UINT / R32G8X24_TYPELESS), and maps depth-flagged R32_TYPELESS / R16_TYPELESS while preserving non-depth R32_TYPELESS UAVs (37).
  • fsr.rs before_present: deduplicates barrier when motion == depth and restores both states unconditionally whether PrepareV2 dispatch succeeds or fails.
  • Minor doc nit (non-blocking): d3d12/docs/switches.md:561 still marks LEONIDA_TEXTURE_ROOM_PERCENT with L = yes and leonida-gpu/resource.rs +1 because d3d12/scripts/play-nvidia.ps1 was the only launcher assignment; tools/d3d12_switches.py --check only checks switch name presence so CI stays green, though regenerating switches.md would keep the L column exact.

AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7357629924 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206#issuecomment-7357629924). Originally posted by [icdmkg2](https://github.com/icdmkg2) on 2026-12-02T20:22:17Z. --- **Third-party Windows verification of #3206 (`D3D12-FSR-FRAMEGEN-DEPTH-AND-ROOM`) on head `137c231a5`** - **Head / base:** `137c231a5d0e494169ac67fdf2ed83cc1e6ff6bd` merged cleanly (`git merge --no-ff`) onto `origin/main` `b41763227`. - **Machine:** NVIDIA GeForce RTX 5060 Laptop GPU (8 GB, Profile M laptop), driver `621.24` (`32.0.16.2124`), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 11 `10.0.26300.9974`, `rustc 1.98.1`. - **Scope:** synthetic / D3D12 hardware + debug-layer + WARP + Python launcher tests (no retail title run). ### Results (MEASURED) | Check | Result | |---|---| | `python -I scripts/check_no_game_data.py` (all 3 touched files) | exit `0` | | `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` | exit `0` | | `LEONIDA_ADAPTER=5060` `python -I scripts/red_green.py 3206 --mutate` | **exit `0` (`verdict: red then green`)** — `4` tests went red → green (`fsr::tests::{before_present_transitions_depth_and_motion_for_prepare_and_restores_states, states_and_formats, typeless_depth_resources_carry_depth_stencil_usage_and_valid_srv_formats}` + `test_win_launchers.py::test_fsr_framegen_leaves_default_texture_room_and_honors_override`); `708` pass on both, `0` failures. (`--mutate`: `fsr.rs:709` and `fsr.rs:888` caught; the other 5 Rust sub-hunks were reported `not caught` due to `red_green.py` running the Python target test even when Rust fails to compile, not missing coverage.) | | `LEONIDA_ADAPTER=5060` + `LEONIDA_D3D12_DEBUG=1` `cargo test -p leonida-gpu --features diagnostics --locked --lib -- fsr::` | `5 passed, 0 failed` (D3D12 Debug Layer clean across typeless depth SRVs and `PrepareV2` pre/post `NON_PIXEL_SHADER_RESOURCE` barriers) | | `LEONIDA_D3D12_WARP=1` + `LEONIDA_D3D12_DEBUG=1` (same `fsr::` command, `--features diagnostics`) | `5 passed, 0 failed` | ### Review notes (READ IN CODE) - `fsr.rs` `Resource::texture`: checks `ALLOW_DEPTH_STENCIL` alongside typed depth formats, sets `USAGE_DEPTHTARGET` (+ `USAGE_STENCILTARGET` for `D24_UNORM_S8_UINT` / `R24G8_TYPELESS` / `D32_FLOAT_S8X24_UINT` / `R32G8X24_TYPELESS`), and maps depth-flagged `R32_TYPELESS` / `R16_TYPELESS` while preserving non-depth `R32_TYPELESS` UAVs (`37`). - `fsr.rs` `before_present`: deduplicates barrier when `motion == depth` and restores both states unconditionally whether `PrepareV2` dispatch succeeds or fails. - Minor doc nit (non-blocking): `d3d12/docs/switches.md:561` still marks `LEONIDA_TEXTURE_ROOM_PERCENT` with `L = yes` and `leonida-gpu/resource.rs +1` because `d3d12/scripts/play-nvidia.ps1` was the only launcher assignment; `tools/d3d12_switches.py --check` only checks switch name presence so CI stays green, though regenerating `switches.md` would keep the `L` column exact. AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).
ThatAppleFanboy commented 2026-12-02 21:02:05 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ThatAppleFanboy on 2026-12-02T21:02:05Z.

Review: APPROVED


The fix works perfectly on rtx3080

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6158948502 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206#pullrequestreview-6158948502). Originally posted by [ThatAppleFanboy](https://github.com/ThatAppleFanboy) on 2026-12-02T21:02:05Z. **Review:** APPROVED --- The fix works perfectly on rtx3080
ThatAppleFanboy commented 2026-12-02 21:30:07 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ThatAppleFanboy on 2026-12-02T21:30:07Z.

Review: APPROVED


Works

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6159357759 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206#pullrequestreview-6159357759). Originally posted by [ThatAppleFanboy](https://github.com/ThatAppleFanboy) on 2026-12-02T21:30:07Z. **Review:** APPROVED --- Works
fiestorra commented 2026-12-02 21:57:57 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T21:57:57Z.


VERIFY-3206 — Windows nativo: dos de los tres tests nuevos pasan; el tercero necesita un escritorio y no lo hay aquí

Head (this PR)
Merge base b41763227 = current main
Merged onto main — merge-tree clean, git merge --no-ff clean

Ran

cargo test -p leonida-gpu --lib fsr        4 passed; 1 failed
  fsr::tests::typeless_depth_resources_carry_depth_stencil_usage_and_valid_srv_formats ... ok
  fsr::tests::flags_from_depth_and_back_buffer ... ok
  fsr::tests::before_present_transitions_depth_and_motion_for_prepare_and_restores_states ... FAILED
python -I tests/test_win_launchers.py      Ran 7 tests — OK

The failure is environmental, and I traced it to the line:

panicked at crates\leonida-gpu\src\fsr.rs:1388
called `Result::unwrap()` on an `Err` value:
  Error { code: HRESULT(0x887A0022), message: "A resource is not available at the time of the call, but may ..." }

HRESULT(0x887A0022) is DXGI_ERROR_NOT_CURRENTLY_AVAILABLE, and line 1388 is

let sc = factory.CreateSwapChainForComposition(&queue, &sc_desc, None).unwrap()...

A composition swap chain needs a composition-capable session, and this machine has none (CopyFromScreen: The handle is invalid; it is the same reason borderless_from_the_start_stays_shown_when_framed_again fails on main). So this test cannot pass here, and it will not tell you whether the barrier code is right — but note that GitHub's Windows runners are headless too, so if CI runs this test it will fail there for the same reason. That is worth checking before merge, and a CreateSwapChainForComposition that is allowed to fail with a skip would make the test say what it means on machines that cannot build one.

What the two passing tests do say: the typeless depth resources now carry D3D12_RESOURCE_USAGE_DEPTH_STENCIL and validate as the right SRV formats, and the depth/back-buffer flags come out right — the part of the change that does not need a present.

What I could not test

  • The prepare/restore barrier behaviour itself: its test is the one blocked by the missing composition session. It is the most interesting part of the PR (before_present transitions depth and motion and restores the states) and it has no verification from this machine.
  • A run with FSR on: no title, no swap chain.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360034467 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206#issuecomment-7360034467). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T21:57:57Z. --- ## VERIFY-3206 — Windows nativo: dos de los tres tests nuevos pasan; el tercero necesita un escritorio y no lo hay aquí | | | |---|---| | Head | `(this PR)` | | Merge base | `b41763227` = current `main` | | Merged onto | `main` — `merge-tree` clean, `git merge --no-ff` clean | **Ran** ``` cargo test -p leonida-gpu --lib fsr 4 passed; 1 failed fsr::tests::typeless_depth_resources_carry_depth_stencil_usage_and_valid_srv_formats ... ok fsr::tests::flags_from_depth_and_back_buffer ... ok fsr::tests::before_present_transitions_depth_and_motion_for_prepare_and_restores_states ... FAILED python -I tests/test_win_launchers.py Ran 7 tests — OK ``` **The failure is environmental, and I traced it to the line**: ``` panicked at crates\leonida-gpu\src\fsr.rs:1388 called `Result::unwrap()` on an `Err` value: Error { code: HRESULT(0x887A0022), message: "A resource is not available at the time of the call, but may ..." } ``` `HRESULT(0x887A0022)` is **`DXGI_ERROR_NOT_CURRENTLY_AVAILABLE`**, and line 1388 is ```rust let sc = factory.CreateSwapChainForComposition(&queue, &sc_desc, None).unwrap()... ``` **A composition swap chain needs a composition-capable session, and this machine has none** (`CopyFromScreen: The handle is invalid`; it is the same reason `borderless_from_the_start_stays_shown_when_framed_again` fails on `main`). **So this test cannot pass here, and it will not tell you whether the barrier code is right** — but note that **GitHub's Windows runners are headless too**, so if CI runs this test it will fail there for the same reason. That is worth checking before merge, and a `CreateSwapChainForComposition` that is allowed to fail with a skip would make the test say what it means on machines that cannot build one. **What the two passing tests do say**: the typeless depth resources now carry `D3D12_RESOURCE_USAGE_DEPTH_STENCIL` and validate as the right SRV formats, and the depth/back-buffer flags come out right — the part of the change that does not need a present. ## What I could not test - **The prepare/restore barrier behaviour itself**: its test is the one blocked by the missing composition session. It is the most interesting part of the PR (`before_present` transitions depth and motion and restores the states) and **it has no verification from this machine**. - **A run with FSR on**: no title, no swap chain. Written with an AI assistant.
MoonEyes commented 2026-12-02 22:00:28 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:00:28Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360091876 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206#issuecomment-7360091876). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T22:00:28Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
zmasi commented 2026-12-02 22:26:58 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-12-02T22:26:58Z.


Thanks @fiestorra for catching that CreateSwapChainForComposition DXGI_ERROR_NOT_CURRENTLY_AVAILABLE (0x887A0022) failure on headless Session-0 setups!

Since before_present only forwards swap_chain.as_raw() into ConfigureFrameGeneration.swap_chain and makes zero COM calls on it, d024194b38 (merged with current origin/main, #[cfg(test)] only — zero production code change) replaces CreateSwapChainForComposition in before_present_transitions_depth_and_motion_for_prepare_and_restores_states with a minimal COM-shaped StubSwapChain while keeping the full real D3D12 command-list, GPU queue, and fence barrier validation intact (5/5 fsr:: tests passing without needing a desktop compositor).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7360707395 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206#issuecomment-7360707395). Originally posted by [zmasi](https://github.com/zmasi) on 2026-12-02T22:26:58Z. --- Thanks @fiestorra for catching that `CreateSwapChainForComposition` `DXGI_ERROR_NOT_CURRENTLY_AVAILABLE` (`0x887A0022`) failure on headless Session-0 setups! Since `before_present` only forwards `swap_chain.as_raw()` into `ConfigureFrameGeneration.swap_chain` and makes zero COM calls on it, `d024194b38` (merged with current `origin/main`, `#[cfg(test)]` only — zero production code change) replaces `CreateSwapChainForComposition` in `before_present_transitions_depth_and_motion_for_prepare_and_restores_states` with a minimal COM-shaped `StubSwapChain` while keeping the full real D3D12 command-list, GPU queue, and fence barrier validation intact (`5/5` `fsr::` tests passing without needing a desktop compositor).
lixonik commented 2026-12-02 22:41:25 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T22:41:25Z.


RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS on head 137c231a5 (merged cleanly via git merge --no-ff onto main 8877be372).

Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79)

  • python -I scripts/check_no_game_data.py -> PASS
  • python -I tests/test_win_launchers.py -> OK
  • cargo test -p leonida-gpu --lib --locked fsr:: -> 5 passed, 0 failed
  • cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked -> PASS

Live In-Game Gate (-SeriesS -NoFrameGen, standard DLSS path -- non-FSR-FG regression gate)

Run Time in world (total) World samples (max draws) Errors / Device lost Median FPS (ms) Slowest / fastest tenth (fps)
PR #3206 (137c231a5 on 8877be372) 315 s (451.5 s) 65 (5,233) 0 / 0 27.1 fps (36.9 ms) 21.5 / 27.9
Matched main (8877be372) 315 s (441.9 s) 63 (4,338) 0 / 0 27.9 fps (35.8 ms) 26.1 / 29.6
  • Scope note: AMD's signed FidelityFX Frame Generation DLLs (LEONIDA_FIDELITYFX_DIR) were not present on this host, so live LEONIDA_FSR_FRAMEGEN=1 / PrepareV2 dispatch itself was not exercised in-game; the fsr:: unit tests (5/5), tests/test_win_launchers.py, and this 315 s DLSS world run confirm clean compilation, launcher behavior, and zero regressions on the non-FSR-FG path.

AI-assisted: yes (Antigravity -- Gemini 4 Neon).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7361030221 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206#issuecomment-7361030221). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T22:41:25Z. --- **RUN (in game, RTX 5070 12 GB, 315 s in-world gate) -- PASS** on head `137c231a5` (merged cleanly via `git merge --no-ff` onto `main` `8877be372`). ### Build & Unit Checks (Windows 10 x64, RTX 5070 12 GB, driver 595.79) - `python -I scripts/check_no_game_data.py` -> **PASS** - `python -I tests/test_win_launchers.py` -> **OK** - `cargo test -p leonida-gpu --lib --locked fsr::` -> **5 passed, 0 failed** - `cargo build --profile diag --features "diagnostics,dlss,mimalloc" --locked` -> **PASS** ### Live In-Game Gate (`-SeriesS -NoFrameGen`, standard DLSS path -- non-FSR-FG regression gate) | Run | Time in world (total) | World samples (max draws) | Errors / Device lost | Median FPS (ms) | Slowest / fastest tenth (fps) | | --- | ---: | ---: | ---: | ---: | ---: | | **PR #3206 (`137c231a5` on `8877be372`)** | `315 s` (`451.5 s`) | `65` (`5,233`) | **`0` / `0`** | **`27.1 fps`** (`36.9 ms`) | `21.5` / `27.9` | | **Matched `main` (`8877be372`)** | `315 s` (`441.9 s`) | `63` (`4,338`) | **`0` / `0`** | **`27.9 fps`** (`35.8 ms`) | `26.1` / `29.6` | - **Scope note:** AMD's signed FidelityFX Frame Generation DLLs (`LEONIDA_FIDELITYFX_DIR`) were not present on this host, so live `LEONIDA_FSR_FRAMEGEN=1` / `PrepareV2` dispatch itself was not exercised in-game; the `fsr::` unit tests (5/5), `tests/test_win_launchers.py`, and this 315 s DLSS world run confirm clean compilation, launcher behavior, and zero regressions on the non-FSR-FG path. AI-assisted: yes (Antigravity -- Gemini 4 Neon).
MoonEyes commented 2026-12-03 00:02:12 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T00:02:12Z.


RUN (in game, batch of nine pull requests), each head merged with git merge --no-ff onto main 81efe4566, in one build: #3136 74bd1bcd4, #3156 53c3100ce, #3206 d024194b3, #3248 efd21d867, #3256 e7aad1d4c, #3262 3643c2879, #2851 b83b0b375, #3125 89bf1d328, #2642 164506d01. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, -Resolution 1080, frame generation 2x, -PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.

What Result
Device lost / device removed 0
Exceptions, panics, hang watchdog, GPU stall, title suspended 0
Process alive at the end yes, stopped by the time limit
Rendered fps, last 240 s (48 samples) median 15.6, mean 15.6
Rendered fps, last 120 s median 14.3
Time under 5 fps in the world 3 %

For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain.

Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.

Limits: one run; arrival in the world was driven by keys and not checked on pictures; -PrecompileUsed was used, so the default start (every known pipeline precompiled) was not exercised. The precompile before the world took 619 s, against 157 s for the previous batch; the shader-side changes in this batch (#3156, #3262) probably left the pipeline cache cold (not checked). Switches that are off by default (for example #2851's LEONIDA_TITLE_MEMORY_SCALE, #3136's timeline attribution) were not turned on: this run covers their default path only. #2642 targets Wine and was run on Windows only.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7362720717 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3206#issuecomment-7362720717). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-03T00:02:12Z. --- RUN (in game, batch of nine pull requests), each head merged with `git merge --no-ff` onto main `81efe4566`, in one build: #3136 `74bd1bcd4`, #3156 `53c3100ce`, #3206 `d024194b3`, #3248 `efd21d867`, #3256 `e7aad1d4c`, #3262 `3643c2879`, #2851 `b83b0b375`, #3125 `89bf1d328`, #2642 `164506d01`. RTX 4060 8 GB, driver 610.88, Windows 11. Series S, `-Resolution 1080`, frame generation 2x, `-PrecompileUsed`, the same walking route as the other runs on this machine, 330 s after reaching the world. | What | Result | |---|---| | Device lost / device removed | 0 | | Exceptions, panics, hang watchdog, GPU stall, title suspended | 0 | | Process alive at the end | yes, stopped by the time limit | | Rendered fps, last 240 s (48 samples) | median 15.6, mean 15.6 | | Rendered fps, last 120 s | median 14.3 | | Time under 5 fps in the world | 3 % | For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain. Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it. Limits: one run; arrival in the world was driven by keys and not checked on pictures; `-PrecompileUsed` was used, so the default start (every known pipeline precompiled) was not exercised. The precompile before the world took 619 s, against 157 s for the previous batch; the shader-side changes in this batch (#3156, #3262) probably left the pipeline cache cold (not checked). Switches that are off by default (for example #2851's `LEONIDA_TITLE_MEMORY_SCALE`, #3136's timeline attribution) were not turned on: this run covers their default path only. #2642 targets Wine and was run on Windows only. AI-assisted (Claude Code).
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/3206:upstream-pr/3206'
git switch 'upstream-pr/3206'

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/3206'
git switch 'upstream-pr/3206'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3206'
git switch 'upstream-pr/3206'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3206'
git switch 'main'
git merge --squash 'upstream-pr/3206'
git switch 'main'
git merge --ff-only 'upstream-pr/3206'
git switch 'main'
git merge 'upstream-pr/3206'
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!3206
No description provided.