d3d12: textures flicker black, view records written to the title's heap by unwatched writers (port_descriptors fallback can't keep up) #3394

Open
leonida/mandy
opened 2026-12-03 23:13:15 +00:00 by Callimann8 · 7 comments

What happens

In game, textures flicker black for a few frames at a time. Every run logs thousands of renderer port 2: a view record in the title's heap that no store told of (found by the fallback; made now). A slot whose view record no mark told of shows its old view, or none, until the port_descriptors fallback reaches its page, and the fallback falls behind.

Commit

Current main as of 2026-12-03 (FILL IN: git rev-parse --short HEAD). No local patches.

System

  • AMD Radeon RX 7900 XT, Windows 11. (FILL IN: driver version, CPU, RAM.) - Series X profile, 2560x1440 output (LEONIDA_OUTPUT=2560x1440), -HardwareRT. - The same warnings show on an RTX 4070, about 4,100 in a 7-minute run.

Where

assets

Command and steps

Launcher defaults plus -HardwareRT, Series X, 1440p. Play from a save, on foot and driving. It happens every run, within the first minute.

Output

**Not memory.** A run with a 32 GB page file had 54 GB or more left to commit throughout, and no refused staging buffers or "no room" warnings. The flicker was unchanged.

**Not the check cadence.** Default settings, one run:
```
fallback: 16.0 pages looked at whole, 7.80 view records no store told of (2.60 of them of draws' tables), ... 0.7 told and not taken yet
```
With `LEONIDA_PORT_DESCRIPTORS_EVERY=1 LEONIDA_PORT_DESCRIPTORS_CHECK=64 LEONIDA_PAINTED_EVERY=2 LEONIDA_HEAP_RECHECK_EVERY=15`, the flicker was unchanged and the fallback saturated:
```
fallback: 64.0 pages looked at whole, 31.32 view records no store told of (434.32 of them of draws' tables), 12247 other records changed, 706.4 told and not taken yet
of the title's memcpy/memmove calls into the heap 5758, 0 records they marked
```

**The writers the stores and the memcpy/memmove wrap miss** (same run, since the start, 11,972 view records missed):
```
title+0x4d9f264 1725, 0x7ffa7f19c1d3 (not the title's) 1432, 0x7ff9537b0000 (not the title's) 1063,
0x7ffa7f19c283 (not the title's) 967, 0x7ff9537b0080 (not the title's) 874, title+0x4e9b4e9 813
```
In an earlier 9-minute run on the same card, 7,668 of the 9,887 missed records were at slots above 500,000, and 5,306 of them came from writers outside the title.

**Observations:**
- Two title sites, `title+0x4d9f264` and `title+0x4e9b4e9`, are not among the six patched stores.
- Most misses come from code outside the title. The writer at `0x7ffa7f19c1xx` sits inside a module (not identified yet). `0x7ff9537b0000` and `+0x80` are page-aligned, which looks like generated code or a trampoline, not a DLL.
- The memcpy/memmove wrap sees 5,758 calls into the heap per frame but marks 0 records. Either those copies carry no view records, or they reach the heap some other way.
- The log prints only raw addresses for writers outside the title. Naming the module (`GetModuleHandleExW` with `GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS`) would make this much easier to follow up.
### What happens In game, textures flicker black for a few frames at a time. Every run logs thousands of `renderer port 2: a view record in the title's heap that no store told of (found by the fallback; made now)`. A slot whose view record no mark told of shows its old view, or none, until the port_descriptors fallback reaches its page, and the fallback falls behind. ### Commit Current `main` as of 2026-12-03 (FILL IN: `git rev-parse --short HEAD`). No local patches. ### System - AMD Radeon RX 7900 XT, Windows 11. (FILL IN: driver version, CPU, RAM.) - Series X profile, 2560x1440 output (`LEONIDA_OUTPUT=2560x1440`), `-HardwareRT`. - The same warnings show on an RTX 4070, about 4,100 in a 7-minute run. ### Where assets ### Command and steps Launcher defaults plus `-HardwareRT`, Series X, 1440p. Play from a save, on foot and driving. It happens every run, within the first minute. ### Output ````text **Not memory.** A run with a 32 GB page file had 54 GB or more left to commit throughout, and no refused staging buffers or "no room" warnings. The flicker was unchanged. **Not the check cadence.** Default settings, one run: ``` fallback: 16.0 pages looked at whole, 7.80 view records no store told of (2.60 of them of draws' tables), ... 0.7 told and not taken yet ``` With `LEONIDA_PORT_DESCRIPTORS_EVERY=1 LEONIDA_PORT_DESCRIPTORS_CHECK=64 LEONIDA_PAINTED_EVERY=2 LEONIDA_HEAP_RECHECK_EVERY=15`, the flicker was unchanged and the fallback saturated: ``` fallback: 64.0 pages looked at whole, 31.32 view records no store told of (434.32 of them of draws' tables), 12247 other records changed, 706.4 told and not taken yet of the title's memcpy/memmove calls into the heap 5758, 0 records they marked ``` **The writers the stores and the memcpy/memmove wrap miss** (same run, since the start, 11,972 view records missed): ``` title+0x4d9f264 1725, 0x7ffa7f19c1d3 (not the title's) 1432, 0x7ff9537b0000 (not the title's) 1063, 0x7ffa7f19c283 (not the title's) 967, 0x7ff9537b0080 (not the title's) 874, title+0x4e9b4e9 813 ``` In an earlier 9-minute run on the same card, 7,668 of the 9,887 missed records were at slots above 500,000, and 5,306 of them came from writers outside the title. **Observations:** - Two title sites, `title+0x4d9f264` and `title+0x4e9b4e9`, are not among the six patched stores. - Most misses come from code outside the title. The writer at `0x7ffa7f19c1xx` sits inside a module (not identified yet). `0x7ff9537b0000` and `+0x80` are page-aligned, which looks like generated code or a trampoline, not a DLL. - The memcpy/memmove wrap sees 5,758 calls into the heap per frame but marks 0 records. Either those copies carry no view records, or they reach the heap some other way. - The log prints only raw addresses for writers outside the title. Naming the module (`GetModuleHandleExW` with `GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS`) would make this much easier to follow up.

Phase 2 of the diagnostics in #3429 was run by @Otavmacedo (RTX 3070 8 GB, 427 s in the world, n=1), and it changes the picture:

  • The six biggest writers since the start are four sites in VCRUNTIME140.dll's copy routine and two addresses in one page that no module holds; the title's own sites drop out of the top six after the first minute.
  • The new copy-tag counter was 0 in every per-frame line (450 lines), while the wrap saw a median 3,087 title memcpy/memmove calls into the heap a frame, marking 0 records: the title's own copies carry no view records.
  • leonida.exe imports VCRUNTIME140.dll, so a copy made by the runtime itself is the leading candidate for the writer.

Next step worth taking: capture one frame up from those VCRUNTIME140 sites (the caller of memcpy) and name its module — that is what the current instrumentation cannot show. It is not in #3429 (diagnostics only); anyone can take it under this item.

Phase 2 of the diagnostics in #3429 was run by @Otavmacedo (RTX 3070 8 GB, 427 s in the world, n=1), and it changes the picture: - The six biggest writers since the start are **four sites in `VCRUNTIME140.dll`'s copy routine** and two addresses in one page that no module holds; the title's own sites drop out of the top six after the first minute. - The new copy-tag counter was **0 in every per-frame line** (450 lines), while the wrap saw a median 3,087 title `memcpy`/`memmove` calls into the heap a frame, marking 0 records: the title's own copies carry no view records. - `leonida.exe` imports `VCRUNTIME140.dll`, so a copy made by the runtime itself is the leading candidate for the writer. Next step worth taking: capture **one frame up** from those `VCRUNTIME140` sites (the caller of `memcpy`) and name its module — that is what the current instrumentation cannot show. It is not in #3429 (diagnostics only); anyone can take it under this item.

The follow-up phase 2 asked for is now in #3429 (1cd95b811): one copy in 64 into the heap is sampled and its caller outside our own image is named (module.dll+0x…), printed after the writers.

A LEONIDA_PORT_DESCRIPTORS=1 run will name the code that calls VCRUNTIME140's copy — the remaining unknown in the phase-2 report. That run is still open for anyone with a machine free; no game run was made here.

The follow-up phase 2 asked for is now in #3429 (`1cd95b811`): one copy in 64 into the heap is sampled and its **caller outside our own image** is named (`module.dll+0x…`), printed after the writers. A `LEONIDA_PORT_DESCRIPTORS=1` run will name the code that calls `VCRUNTIME140`'s copy — the remaining unknown in the phase-2 report. That run is still open for anyone with a machine free; no game run was made here.

Ran #3467 (3587853c72, LEONIDA_PORT_DESCRIPTORS=1, NVIDIA RTX 5070 12 GB, Windows 11, 315 s) and symbolized the leonida.exe caller recorded at the VCRUNTIME140.dll guard faults (full report on #3467):

  • All top VCRUNTIME140.dll writers share one caller: d3d12/crates/leonida-gpu/src/port_descriptors.rs:543 (port_descriptors::copy → copied() → real(to, from, n)), our own memcpy wrapper — not an unrelated runtime copy.
  • Because copied() already checks the full range and saw 0 view records (0 off-grid tags) across 4,016 heap copies/frame, VCRUNTIME140.dll is an attribution artifact of port_descriptors::faulted() tracking one writer per 64 KiB block (off >> 16): frequent non-view memcpy calls into the same 64 KiB block overwrite a.writers[block] and mask the real missed writer before the fallback runs.
  • The non-masked warnings point to one unmapped executable page (912 warnings — looks like a dynamic stub/trampoline) and three sites inside the title's image (268, 262, and 65 warnings). Skipping a.writers updates during port_descriptors::copy/shift (or tracking per 4 KiB page) should uncover the remaining masked writers cleanly.

AI-assisted.

Ran #3467 (`3587853c72`, `LEONIDA_PORT_DESCRIPTORS=1`, NVIDIA RTX 5070 12 GB, Windows 11, 315 s) and symbolized the `leonida.exe` caller recorded at the `VCRUNTIME140.dll` guard faults (full report on #3467): - **All top `VCRUNTIME140.dll` writers share one caller:** `d3d12/crates/leonida-gpu/src/port_descriptors.rs:543` (`port_descriptors::copy` → `copied()` → `real(to, from, n)`), our own `memcpy` wrapper — not an unrelated runtime copy. - Because `copied()` already checks the full range and saw `0` view records (`0` off-grid tags) across `4,016` heap copies/frame, `VCRUNTIME140.dll` is an **attribution artifact** of `port_descriptors::faulted()` tracking one writer per **64 KiB block** (`off >> 16`): frequent non-view `memcpy` calls into the same 64 KiB block overwrite `a.writers[block]` and mask the real missed writer before the fallback runs. - The non-masked warnings point to **one unmapped executable page** (`912` warnings — looks like a dynamic stub/trampoline) and **three sites inside the title's image** (`268`, `262`, and `65` warnings). Skipping `a.writers` updates during `port_descriptors::copy`/`shift` (or tracking per 4 KiB page) should uncover the remaining masked writers cleanly. AI-assisted.
Contributor

I prepared two additional generated descriptor layouts for the fallback and writer-attribution work. The adjacent-view case complements the sampler-straddle check.

  1. Put a 32-byte SRV across a watch-page boundary and a second SRV entirely on the next page. Change both payloads while keeping their tags, complete the uploads, and run fallback. The expected readback is A0/B0 before publication and A1/B1 afterward. The two control views retain their pixels. Observing both dirty pages should rebuild the straddling record once.
  2. Update a descriptor, rearm the guard, then write ordinary bytes elsewhere in the same 64 KiB watch block. Capture both events. The block's latest fault sample should identify the ordinary write, while the descriptor still contains the bytes from the first write. Repeat the ordinary copy in a different block as a control.

These are proposed GPU and fault-trace checks. The independent synthetic archive tests for this issue already verified equal Present windows, an unknown caller group, and partial status when counter snapshots or flash markers cannot be aligned. Keeping the unattributed remainder visible avoids overstating what a per-block sample says about a specific descriptor. Issue #3394 · Writer attribution #3467 · Sampler straddle #3448 · Fallback #3477

The generated views start at byte offsets 65,532 and 65,564 around a 65,536-byte boundary. In the attribution control, the descriptor is at offset 128 and the ordinary 64-byte copies start at offsets 8,192 and 73,728 for the same-block and other-block variants.

I prepared two additional generated descriptor layouts for the fallback and writer-attribution work. The adjacent-view case complements the sampler-straddle check. 1. Put a 32-byte SRV across a watch-page boundary and a second SRV entirely on the next page. Change both payloads while keeping their tags, complete the uploads, and run fallback. The expected readback is `A0/B0` before publication and `A1/B1` afterward. The two control views retain their pixels. Observing both dirty pages should rebuild the straddling record once. 2. Update a descriptor, rearm the guard, then write ordinary bytes elsewhere in the same 64 KiB watch block. Capture both events. The block's latest fault sample should identify the ordinary write, while the descriptor still contains the bytes from the first write. Repeat the ordinary copy in a different block as a control. These are proposed GPU and fault-trace checks. The independent synthetic archive tests for this issue already verified equal Present windows, an `unknown` caller group, and partial status when counter snapshots or flash markers cannot be aligned. Keeping the unattributed remainder visible avoids overstating what a per-block sample says about a specific descriptor. [Issue #3394](https://git.leonida.now/leonida/mandy/issues/3394) · [Writer attribution #3467](https://git.leonida.now/leonida/mandy/pulls/3467) · [Sampler straddle #3448](https://git.leonida.now/leonida/mandy/pulls/3448) · [Fallback #3477](https://git.leonida.now/leonida/mandy/pulls/3477) The generated views start at byte offsets 65,532 and 65,564 around a 65,536-byte boundary. In the attribution control, the descriptor is at offset 128 and the ordinary 64-byte copies start at offsets 8,192 and 73,728 for the same-block and other-block variants.
Contributor

I have a generated descriptor-report fixture that compares equal confirmed HostPresent windows and keeps missing writer/caller attribution visible. It covers reports with incomplete writer tallies, a missing Present, an archive binding mismatch, unresolved flash times, and a missing route boundary. The generated fixture passed on Windows. It distinguishes a report UTC window from a confirmed per-frame attribution window.

The companion hardware controls remain the previously posted two generated SRV layouts. Existing layouts · Caller tracing #3467

I have a generated descriptor-report fixture that compares equal confirmed HostPresent windows and keeps missing writer/caller attribution visible. It covers reports with incomplete writer tallies, a missing Present, an archive binding mismatch, unresolved flash times, and a missing route boundary. The generated fixture passed on Windows. It distinguishes a report UTC window from a confirmed per-frame attribution window. The companion hardware controls remain the previously posted two generated SRV layouts. [Existing layouts](https://git.leonida.now/leonida/mandy/issues/3394#issuecomment-26544) · [Caller tracing #3467](https://git.leonida.now/leonida/mandy/pulls/3467)
Contributor

The adjacent-view case passed against the actual plan_parts implementation from f4b0404e95fa in a standalone Windows CPU harness. Four 32-byte records begin 36 bytes before a 64 KiB watch-page boundary. With only the second page dirty, the plan emits the crossing record once as its own span and groups the next two records. With both pages dirty, it adds the first-page neighbor and still emits the crossing record once.

The generated case, using byte ranges relative to the page boundary and exclusive end offsets, expects:

Dirty pages Planned spans
Second only [-4, 28), [28, 92)
Both [-36, -4), [-4, 28), [28, 92)

The test-only patch applies to that base. Generated GPU pixel readback for both views is still pending. Earlier layout · Merged fallback #3477

AI-assisted.

The adjacent-view case passed against the actual `plan_parts` implementation from `f4b0404e95fa` in a standalone Windows CPU harness. Four 32-byte records begin 36 bytes before a 64 KiB watch-page boundary. With only the second page dirty, the plan emits the crossing record once as its own span and groups the next two records. With both pages dirty, it adds the first-page neighbor and still emits the crossing record once. The generated case, using byte ranges relative to the page boundary and exclusive end offsets, expects: | Dirty pages | Planned spans | | --- | --- | | Second only | `[-4, 28)`, `[28, 92)` | | Both | `[-36, -4)`, `[-4, 28)`, `[28, 92)` | The test-only patch applies to that base. Generated GPU pixel readback for both views is still pending. [Earlier layout](https://git.leonida.now/leonida/mandy/issues/3394#issuecomment-26544) · [Merged fallback #3477](https://git.leonida.now/leonida/mandy/pulls/3477) AI-assisted.
Contributor

Follow-up to the adjacent-view CPU check. The in-tree Windows Cargo test passed at f4b0404e95fa. I ran the same assertions in a standalone harness with the exact plan_parts implementation from 575c55c6b424, the first parent of the #3477 merge. The old planner emitted only [28, 92) when the second page was dirty. The assertion caught the missing crossing span [-4, 28). Earlier result · Merged planner change #3477

The generated fixture can be added to the existing tests module in port_descriptors.rs.

#[test]
fn adjacent_views_in_a_fallback_page_have_one_read_each() {
    let size = crate::watch::PAGE;
    let page = (size * 32) as u64;
    let step = 32;
    let start = page - 36;
    let end = start + 4 * step;
    let at = |i| (start + i * step) as usize;

    let dirty = [page as usize];
    let expected = [(at(1), at(2), true), (at(2), at(4), true)];
    assert_eq!(plan_parts(start, end, step, 4, &[], &dirty, size), expected);

    let both = [page as usize - size, page as usize];
    assert_eq!(
        plan_parts(start, end, step, 4, &[], &both, size),
        [(at(0), at(1), true), expected[0], expected[1]]
    );
}
cargo test --locked --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib port_descriptors::tests::adjacent_views_in_a_fallback_page_have_one_read_each -- --exact --test-threads=1

Generated GPU pixel readback for the two views remains pending. AI-assisted.

Follow-up to the adjacent-view CPU check. The in-tree Windows Cargo test passed at `f4b0404e95fa`. I ran the same assertions in a standalone harness with the exact `plan_parts` implementation from `575c55c6b424`, the first parent of the #3477 merge. The old planner emitted only `[28, 92)` when the second page was dirty. The assertion caught the missing crossing span `[-4, 28)`. [Earlier result](https://git.leonida.now/leonida/mandy/issues/3394#issuecomment-26682) · [Merged planner change #3477](https://git.leonida.now/leonida/mandy/pulls/3477) The generated fixture can be added to the existing `tests` module in `port_descriptors.rs`. ```rust #[test] fn adjacent_views_in_a_fallback_page_have_one_read_each() { let size = crate::watch::PAGE; let page = (size * 32) as u64; let step = 32; let start = page - 36; let end = start + 4 * step; let at = |i| (start + i * step) as usize; let dirty = [page as usize]; let expected = [(at(1), at(2), true), (at(2), at(4), true)]; assert_eq!(plan_parts(start, end, step, 4, &[], &dirty, size), expected); let both = [page as usize - size, page as usize]; assert_eq!( plan_parts(start, end, step, 4, &[], &both, size), [(at(0), at(1), true), expected[0], expected[1]] ); } ``` ```text cargo test --locked --manifest-path d3d12/Cargo.toml -p leonida-gpu --lib port_descriptors::tests::adjacent_views_in_a_fallback_page_have_one_read_each -- --exact --test-threads=1 ``` Generated GPU pixel readback for the two views remains pending. AI-assisted.
Sign in to join this conversation.
No assignees
No project
No milestone
Dependencies

No dependencies set

Notifications
4 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
leonida/mandy#3394
No description provided.