Skip to content

D3D12.X: make shadowed textures active again when a draw samples them - #2956

Open
BBareth wants to merge 1 commit into
xcl-dev:mainfrom
BBareth:d3d12x/uncover-sampled-shadowed
Open

BBareth wants to merge 1 commit into
xcl-dev:mainfrom
BBareth:d3d12x/uncover-sampled-shadowed

Conversation

@BBareth

@BBareth BBareth commented Nov 27, 2026 •

Copy link
Copy Markdown
Contributor

When a newer texture is placed over part of an older one, title_textures::Table::insert shadows the older one (and unmaps it if the new placement covers a different range). Shadowed textures are never uploaded again. A title can still sample them, though. GTA 6 does this with the Bink Y/Cr/Cb planes of its credit-card scene: a newer placement lands over part of the planes, the GPU then reads zeros from them, and the cards render green with blocky streaks. In one 355 s run, more than 131k draws sampled shadowed textures.

This change makes a shadowed texture active again when a draw binds it. The active textures that overlap it are shadowed but not unmapped. The texture is remapped if it was unmapped, marked pending unless the GPU wrote it, and its known content is forgotten, so the next submit uploads it again.

When two overlapping textures are made active in turn (one draw sampling both, or two draws before their lists are submitted), the second shadows the first again, but a draw already recorded samples it. That first texture is "displaced" until two frames later. Its source stays watched, so what the title writes there still goes up. If it was pending, the next refresh uploads it whole even when no page was written and no other texture is pending. Displaced textures go up before the active ones, so on shared video memory the active content wins. ettehn, andrewDoing, retrope13 and thehollowedone found these cases in review.

Part of #505. Based on nvidia-dev d1be810.

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs:
    • Table::uncover, uncover_drawn and has_shadowed (an AtomicBool, so draws skip the scan when nothing is shadowed);
    • Table::displaced: textures that uncover shadowed again, with the frame they expire at (present::counters + 2) and whether their whole upload is still owed. They keep their source linked (watched ranges and touched_by) until refresh_parts expires them. HAS_DISPLACED keeps refresh_parts from returning early while a whole upload is owed;
    • the unit test a_sampled_shadowed_texture_is_active_again. Its table section covers the watch staying through a refresh before the expiry frame and going away at it, one link each after A and B swap back and forth, and a release clearing it. With only the "keep it linked" change taken out, it fails at "A's source stays watched";
    • the GPU test gpu_both_overlapping_textures_a_draw_samples_go_up. A then B are made active, one refresh, and both read back. It then runs the sequence write, refresh, note_gpu_write(B), uncover_drawn(A, B), refresh, and A must read back the current bytes. With only the HAS_DISPLACED guard taken out, it fails at that readback.
  • crates/xcl/src/hle/d3d12x/bind.rs: uncover_bound_tables reads the first 64 slots of each bound descriptor table that hold a T#. It resolves them to title textures through console_heap::named_by_index and passes them to uncover_drawn. It is called from bind_abi and, for graphics only, from prepare_two_pass_stage.

Tested

  • Hardware and build: RTX 5070 Ti (driver 32.0.16.2124), i7-12700K, Windows 11 Pro 26200, rustc 1.95.0.
  • cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4 (debug) on 2608ea2: 1822 passed, 12 failed, 48 ignored, summed over all test result lines.
    • All 12 failures are of 10 tests that also fail on the base d1be810 without this change. I ran each failing test binary or filter there. split_compute_prefers_the_offline_whole_pipeline and two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs each count twice, because their harness runs them again. The failing tests:
      • fuzz_validate_and_gpu_0..3;
      • texture_upload::tests::pieces_hold_the_texels_of_their_levels and gpu_parts_of_a_texture_go_up_and_the_rest_stays ("attempt to multiply with overflow" at texture_upload.rs:1002, debug builds only);
      • d3d12_mesh_stream console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly;
      • gpu_compute_e2e async_compute_pso_registers_real_pso_and_not_standin, and split_compute_prefers_the_offline_whole_pipeline (twice);
      • gpu_two_pass_cache_e2e, twice.
    • 30 SKIPPED lines, for these reasons: no wave64 (21), no heap windows, no debug layer / d3d12SDKLayers.dll, a driver cache that cannot be disabled, and refused f16 instructions.
  • cargo test -p xcl --lib title_textures -- --test-threads=1: 31 passed.
  • GTA 6 (retail 1.0.2.1), 240 s with one A press at 70 s, run on the earlier base eae0150 and on the first version of this PR (8fb4127), with the same environment:
    • frames: base 2730, PR 2880;
    • in both runs, presents become erratic after about 100 s and stop at about 130 s, while the world loads. This stall exists without this change too;
    • the PR run logged the texture being made active again 7 times, from 131.6 s.
  • On a lab tree with the same change, based on the older nvidia-dev commit 782fde7, the credit cards render correctly (frames 1559–1589 of that run). Without the change, they are green.

Regression run

The main block is from b49be18, the last main commit before the shader-preparation screen (#2555). On the current main tip, shader preparation did not finish within 2 h on this machine. All blocks were made with XCL_PRESS_A_AT=70 and XCL_DXC_DIR set, one run at a time, with warm shader caches, and with xcl.exe copied as exoborne.exe, a name that gets NVIDIA's 2 GiB shader heap (#2403). Under the normal name, the base d1be810 and this PR both lose the device (0x887a0005) at 123–126 s, in 3 of 3 rounds each, as video memory passes the 15.2 GB budget. Main b49be18 does not, even in a 160 s run. In runs 12/1 (this PR) and 13/1 (the base), the first start under the new exe name spent ~69 s on shader preparation. The A press at 70 s came before the title read input, so the world never loaded. Those two blocks are shown but left out of the comparison. Set 12 ran main and this PR in turn, set 13 the base and this PR in turn. Every block is below, unedited, labelled set/round.

Against the mean of main's two runs (leaving out the two runs that missed the A press):

  • This PR, runs 12/2, 13/1, 13/2: frames 74 %, 76 %, 74 % of main's mean (3041); peak commit 125 %, 135 %, 132 % of main's mean (27988 MB).
  • The base without this change, runs 13/2: frames 75 % of main's mean (3041); peak commit 125 % of main's mean (27988 MB).
  • This PR against the base run 13/2: frames 98 %, 101 %, 98 %; peak commit 100 %, 108 %, 105 %.
  • Presents are 0 in the last 6 s in: base 13/2, pr 12/2, pr 13/1 (the title stops presenting while the world loads).
  • "made active again" lines in the PR runs: 6 (run 12/2), 7 (run 13/1), 11 (run 13/2).

pr_check fails on these blocks: this PR has fewer frames and a higher peak commit than main. The base fails the same check, because nvidia-dev itself is at about 75 % of main's frames and 125–135 % of its commit in this scene. Against the base, this PR is within the run-to-run spread on frames and a few percent higher on commit (figures above).

These blocks are on d1be810. nvidia-dev has since moved to f8de0bf. This PR merges onto it without conflicts, and none of the files it changes were touched there. I have not rerun the blocks on f8de0bf.

Run 12/1, this PR, 2608ea2 (no A press: left out of the comparison):

xcl-smoke v1
commit: 2608ea2367ead8d4aa43c9523ba7bad9b17e890d
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 3426 (PresentX 3426)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 21727 MB

Run 13/1, nvidia-dev base d1be810 (without this change) (no A press: left out of the comparison):

xcl-smoke v1
commit: d1be8103644791b7a65f068954324e93d4b1b565
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 3437 (PresentX 3437)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 21995 MB

Run 12/1, main b49be18:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 3033 (PresentX 3033)
presents per 2 s (last 3): 9 23 31
device removals: 0
crashes: 0
peak commit: 27760 MB

Run 12/2, main b49be18:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 3049 (PresentX 3049)
presents per 2 s (last 3): 37 31 45
device removals: 0
crashes: 0
peak commit: 28216 MB

Run 12/2, this PR, 2608ea2:

xcl-smoke v1
commit: 2608ea2367ead8d4aa43c9523ba7bad9b17e890d
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 2246 (PresentX 2246)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 35026 MB

Run 13/2, nvidia-dev base d1be810 (without this change):

xcl-smoke v1
commit: d1be8103644791b7a65f068954324e93d4b1b565
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 2295 (PresentX 2295)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 34908 MB

Run 13/1, this PR, 2608ea2:

xcl-smoke v1
commit: 2608ea2367ead8d4aa43c9523ba7bad9b17e890d
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 2317 (PresentX 2317)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 37868 MB

Run 13/2, this PR, 2608ea2:

xcl-smoke v1
commit: 2608ea2367ead8d4aa43c9523ba7bad9b17e890d
gpu: NVIDIA GeForce RTX 5070 Ti
title: 9cc6a39e
seconds: 120
exit: 0x0
frames shown: 2245 (PresentX 2246)
presents per 2 s (last 3): 0 1 1
device removals: 0
crashes: 0
peak commit: 36816 MB

Not tested

  • The credit cards on nvidia-dev itself: with this environment, both the base and this PR stall while loading, before the scene is reached. The visual fix was checked only on the lab tree described above.
  • AMD GPUs.
  • Any title other than GTA 6.
  • The two frames a displaced texture stays watched are a bound, not tracking of the list that recorded the draw. A list submitted later than that misses CPU writes made after the expiry.
  • There is no GPU pixel test for an uploaded texture that is displaced and then written by the title. The test memory is not in the UMA write-watch regions, so this case is tested on the table only.
  • Frame-time cost when draws keep alternating between two overlapping textures (each upload is whole). This was not measured.
  • The CI job on the no-GPU runner (WARP) for 2608ea2 stopped with a device removal (0x887a0020) while the sparse.rs tests ran. This PR does not touch sparse.rs, and the same job stops with a device removal during the sparse.rs tests on 9 other PR branches from 27–28 Nov. Those tests pass here.

AI use

  • Claude Code with Claude Opus 5.5 found the root cause on the lab tree, planned and reviewed the port, analysed the runs, and wrote the commit message and this description. It also opened this draft on the author's instruction.
  • Codex CLI with gpt-6.2-sol ported the fix to nvidia-dev, wrote the unit test, and ran the first test suite and the first GTA 6 runs.
  • Claude Code with Claude Opus 5.5 wrote the displaced fix and the two fixes for the cases found in review (the HAS_DISPLACED guard and keeping a displaced texture watched until it expires), and their tests. It also ran the test suite, the base checks of the failing tests and the smoke runs on 2608ea2.

🤖 Generated with Claude Code

@ettehn

ettehn commented Nov 27, 2026

Copy link
Copy Markdown
Contributor

I checked the overlapping-descriptor case called out under Not tested on 8fb41275. A standalone Windows x64 fixture used the PR’s descriptor scanner, uncover_drawn and Table with fake resources. A starts shadowed and B is the active overlapping placement. With one bound table, the results were:

Slots scanned Active after the scan Pending upload
A A A
A, B B B
B, A A A

There is a potential correctness case beyond repeated uploads. The scanner visits table entries regardless of which slot the shader actually samples. If a draw uses only A with B also present later in the table, B can undo A’s reactivation before submission and remove A from the pending set. This verifies CPU state and descriptor traversal only, with COM and GPU operations stubbed. Pixel output and frame-time cost remain unmeasured.

OpenAI Codex assisted with verification.

@andrewDoing

Copy link
Copy Markdown
Contributor

I followed up on the overlapping-descriptor observation with a native GPU readback on RTX 5070 / NVIDIA 616.92. This uses the direct parent eae015021c639866ab061cdff2e9daf8ba9daac5 and PR head 8fb41275ee8b5fbb3191f559cc767d6e9072e832, each in a separate build target and each case in a fresh process.

Two 64×64 R8 committed textures had partially overlapping guest ranges. Each run verified A's initial GPU pixels and B's updated GPU pixels, then supplied an ordering directly to uncover_drawn (on the PR head), called the production refresh, and read A back by GPU copy:

Revision Reactivation order A texels matching current guest bytes
Parent A, before reactivation existed 0 / 4,096
Head A 4,096 / 4,096
Head A then B 0 / 4,096
Head B then A 4,096 / 4,096

The A-then-B case preserves all 4,096 old A texels, while the A-only and B-then-A controls restore all 4,096. This extends the earlier CPU-state report to the pixel consequence of the ordering. The fixture supplied the resource order itself; it did not execute descriptor scanning or shader sampling, use tiled resources, or run a retail title. It therefore does not establish the frequency or visual impact in gameplay.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed the results and prepared this report.

@andrewDoing

Copy link
Copy Markdown
Contributor

I tested a separate-draw case on RTX 5070 / NVIDIA 616.92, comparing the same two native draws on parent eae015021c639866ab061cdff2e9daf8ba9daac5 and head 8fb41275ee8b5fbb3191f559cc767d6e9072e832 in fresh processes. Two committed R8 textures have partially overlapping guest ranges. Each draw's pixel shader reads only its own texture and writes one 2,048-pixel half of an output target.

For the head I supplied only the corresponding resource to uncover_drawn immediately before recording each draw, then called production refresh after closing each list and before execution. This models the ordering of bind-time reactivation and submission-time refresh, but does not invoke the guest bind or KickoffX paths themselves.

Revision Submission pattern A half matching current bytes B half matching current bytes
Parent One list / one refresh 0 / 2,048 2,048 / 2,048
Parent Separate lists / refreshes 0 / 2,048 2,048 / 2,048
Head One list / one refresh 0 / 2,048 2,048 / 2,048
Head Separate lists / refreshes 2,048 / 2,048 2,048 / 2,048

All stale A pixels matched the old value. Thus this synthetic committed-texture case also needs attention across draws in one submission: identifying exactly which resource each shader reads is insufficient if the second reactivation cancels the first before the shared refresh. The fixture did not exercise real guest binding, tiled resources, a retail title, or performance.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.

@retrope13

Copy link
Copy Markdown

Verified PR #2956 (8fb41275) independently on Windows 11 across NVIDIA Ada Lovelace (8 GB) and Intel UHD Graphics (targeted title_textures + bind runs) and reviewed the diff. All targeted tests pass on both GPUs and the full workspace suite shows zero new failures beyond the documented nvidia-dev eae01502 baseline.

Environment

  • OS: Windows 11 26H2 (build 26300.9818)
  • CPU / RAM: Intel Core i5-14500HX (14C/20T), 24 GB RAM
  • GPUs:
    • NVIDIA GeForce RTX 4060 Laptop GPU (8 GB, Ada Lovelace, wave32, driver 32.0.16.2140)
    • Intel(R) UHD Graphics (driver 32.0.101.7092)
  • Toolchain: rustc 1.100.0 (stable-x86_64-pc-windows-msvc), VS 2022 Build Tools 17.14.45, Windows SDK 10.0.26100.0 (DXC 1.9.2602.17)

Test Results (8fb41275)

Command Adapter Result
cargo test --locked -p xcl --lib -- title_textures -- --test-threads=1 NVIDIA RTX 4060 Laptop 30 passed, 0 failed (2.63s, includes a_sampled_shadowed_texture_is_active_again)
cargo test --locked -p xcl --lib -- hle::d3d12x::bind:: -- --test-threads=1 NVIDIA RTX 4060 Laptop 53 passed, 0 failed (0.48s)
cargo test --locked -p xcl --lib -- title_textures -- --test-threads=1 Intel(R) UHD Graphics 30 passed, 0 failed (2.14s)
cargo test --locked -p xcl --lib -- hle::d3d12x::bind:: -- --test-threads=1 Intel(R) UHD Graphics 53 passed, 0 failed (0.51s)
cargo build --workspace --locked && cargo test --workspace --locked --no-fail-fast -- --test-threads=4 NVIDIA RTX 4060 Laptop 1,817 passed, 9 failed, 48 ignored (30 SKIPPED lines)

All 9 failures in the workspace run are a subset of the documented pre-existing nvidia-dev eae01502 failures (gpu_compute_thread_limits_leave_the_lanes_past_them_out, texture_upload::tests::gpu_parts_of_a_texture_go_up_and_the_rest_stays, texture_upload::tests::pieces_hold_the_texels_of_their_levels, console_ms_in_as_slot_and_ms_with_as_are_refused_cleanly, async_compute_pso_registers_real_pso_and_not_standin, split_compute_prefers_the_offline_whole_pipeline ×2, two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs ×2; fuzz_validate_and_gpu_0..3 passed here).

Diff Review Notes

  • crates/xcl/src/hle/d3d12x/title_textures.rs:
    • Table::uncover preserves by_va's disjointness invariant, updates pending_res and pending_delta cleanly on both displaced and restored entries, keeps displaced textures mapped for in-flight draws, resets max_shadowed_size when shadowed empties, and HAS_SHADOWED is updated across all four mutation sites (register, retire_overlapping, forget, uncover_drawn).
    • uncover_drawn clones resources under TEXTURES and drops the mutex before calling vram::remap_if_unmapped / vram::map_levels, avoiding any TEXTURES ↔ vram::PAGES lock-order inversion.
  • crates/xcl/src/hle/d3d12x/bind.rs:
    • uncover_bound_tables short-circuits via has_shadowed(), safely falls back to copy_readable outside committed window 0, filters to texture T# descriptors (slot[15] >> 4 >= 8 && index != 0), and resolves byte-copied descriptors through console_heap::named_by_index.

Not Tested

  • Live retail title runs / visual verification of shadowed Bink planes (no retail game files used).
  • AMD or native wave64 hardware.
  • The 48 #[ignore] tests in the workspace suite.

(AI disclosure: diff review, test execution commands, and summary formatting were assisted by Antigravity / Gemini 4; all tests were executed locally on the hardware listed above.)

@BBareth
BBareth force-pushed the d3d12x/uncover-sampled-shadowed branch from 8fb4127 to d527335 Compare November 27, 2026 07:11
@BBareth

BBareth commented Nov 27, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @ettehn and @andrewDoing, the A-then-B case was a real bug, and your readbacks pinned it down. Thanks @retrope13 for the test run.

Fixed in d527335, squashed into the one commit. When a texture that is still pending is shadowed again by a later uncover (one draw sampling both, or two draws in one submission), it now goes into Table::displaced. The next refresh uploads it anyway, since a draw already recorded samples it, and it stays pending, so it goes up whole again if it is made active later.

Tests:

  • The unit test a_sampled_shadowed_texture_is_active_again now also checks that A stays pending and is queued for the next submit.
  • New GPU test gpu_both_overlapping_textures_a_draw_samples_go_up: two overlapping committed R8 textures, uncover_drawn with A then B, one refresh, then A and B read back. On 8fb4127, A reads back the old bytes (0x11); with the fix, both match the current guest bytes. RTX 5070 Ti, driver 32.0.16.2124.

Still open, and listed under Not tested: a texture that is active (not pending) and is displaced later in the same submission misses that submission's dirty-page updates, because those are tracked only for active entries. It catches up at the next refresh that has work.

AI use: Claude Code (Claude Opus 5.5) wrote this fix, its tests and this reply.

🤖 Generated with Claude Code

@andrewDoing

Copy link
Copy Markdown
Contributor

I reran the same two-draw native RTX 5070 fixture from my earlier report on updated head d52733518f8a980a8218ffd0a78d2c527f4b4bc5, in an isolated build and fresh processes.

  • Both draws in one list / one refresh: A and B each produced 2,048 / 2,048 current pixels, with zero old A pixels. The previous head produced 0 / 2,048 current A pixels in this case.
  • Separate lists / refreshes: A and B each produced 2,048 / 2,048 current pixels.

Both focused runs passed without skips. As before, the fixture supplies each draw's resource directly to uncover_drawn and models refresh timing; it does not run guest binding or a retail title. It does not cover the separate active-but-not-pending dirty-page limitation noted in the update.

AI use: OpenAI Codex with GPT-6.2 Astra ran the retest; Codex reviewed and prepared this report.

@retrope13

Copy link
Copy Markdown

Re-verified d5273351 (nvidia-dev) locally on Windows 11 26H2 (rustc 1.100.0, debug) across NVIDIA, Intel, and WARP:

Results (--test-threads=1)

  • NVIDIA GeForce RTX 4060 Laptop GPU (driver 32.0.16.2140):
    • cargo test --locked -p xcl --lib hle::d3d12x::title_textures::tests:: -- --test-threads=1: 31 passed, 0 failed (including a_sampled_shadowed_texture_is_active_again and gpu_both_overlapping_textures_a_draw_samples_go_up)
    • cargo test --locked -p xcl --lib hle::d3d12x::bind:: -- --test-threads=1: 53 passed, 0 failed
  • Intel(R) UHD Graphics (driver 32.0.101.7092):
    • title_textures::tests::: 31 passed, 0 failed
    • bind::: 53 passed, 0 failed
  • WARP (XCL_ADAPTER=warp):
    • title_textures::tests::: 31 passed, 0 failed
    • bind::: 53 passed, 0 failed

Code-reading note on Table::displaced (crates/xcl/src/hle/d3d12x/title_textures.rs)

One small edge case spotted while reading d5273351:

  • In Table::uncover (lines 377-399), if a shadowed CPU-written texture A is uncovered (A.pending = true, PENDING: 0 → 1) and then an overlapping shadowed gpu_written texture B is uncovered before refresh, A moves into self.displaced and pending_delta drops PENDING back to 0 (while B.pending stays false).
  • In refresh_parts (line 1856):
    if dirty_len == 0 && PENDING.load(Ordering::Relaxed) == 0 && AGAIN.lock().unwrap().is_empty() {
        return;
    }
    If no pages were dirtied since the last look (dirty_len == 0) and AGAIN is empty, refresh_parts returns early without draining t.displaced or uploading A (tracking an atomic HAS_DISPLACED or including displaced in that early-return check would close that gap; clearing self.displaced.remove(&res) in Table::remove / Table::uncover would also avoid stale entries across COM address reuse).

Not Tested

  • Full workspace suite on d5273351 or retail titles / xcl-smoke.
  • Reproducing the gpu_written B + dirty_len == 0 edge case above in a dedicated GPU test (code reading only).
  • bind::tests::two_pass_binds_set_the_shared_view_heap (skipped without XCL_HEAP_WINDOWS=1).

AI disclosure: Antigravity (Gemini 4) assisted with reading the d5273351 diff, running the local test commands, and drafting this report; all test runs executed natively on my Windows 11 RTX 4060 / Intel UHD laptop.

@andrewDoing

Copy link
Copy Markdown
Contributor

I reproduced @retrope13's gpu_written / displaced early-return case with native GPU output on RTX 5070 / driver 616.92, at head d52733518f8a980a8218ffd0a78d2c527f4b4bc5.

The fixture uses partially overlapping committed R8 textures. It first uploads A's old value, updates the guest bytes, and gives B a distinct value through a real GPU copy followed by note_gpu_write. It then supplies A and B individually to uncover_drawn as it records two actual draws, with no subsequent guest writes. Each pixel shader reads only its own texture. Before refresh, A is displaced and AGAIN is empty.

Case Pending before refresh A output (2,048 pixels) B output (2,048 pixels) A displaced after refresh
Normal 0 All old 0x19 All GPU-written 0xc5 Yes
Control: unrelated disjoint pending texture 1 All current 0x83 All GPU-written 0xc5 No

Each case ran in a fresh process. The normal case fails the expected-A assertion; the control passes it. This supports the early-return hypothesis and shows its pixel consequence in this fixture while preserving the GPU-written B value. The fixture supplies reactivation and the write notification directly; guest binding, tiled textures, retail incidence, and performance were not tested.

AI use: OpenAI Codex with GPT-6.2 Astra built and ran the fixture; Codex reviewed and prepared this report.

@thehollowedone

Copy link
Copy Markdown
Contributor

Follow-up to the native GPU reproduction on this head: I tested a narrow guard for the gpu_written B / displaced A early return on #2956 head d5273351. PENDING counts active pending textures, so it can reach zero while Table::displaced still owes an upload for the next refresh. The candidate mirrors whether that set is nonempty in an atomic flag, includes it in the idle-return check, and removes queued IDs when a resource is released, retired, replaced or reactivated.

On Windows 11 build 26300, RTX 3080 Ti (621.35), Ryzen 7 9800X3D, Rust 1.99.1 MSVC, DXC 1.8.2502.11, with XCL_REQUIRE_GPU=1:

  • I extended the PR's native gpu_both_overlapping_textures_a_draw_samples_go_up test. After a guest write is consumed while A is shadowed, it marks B GPU-written through note_gpu_write, uncovers A then B, confirms PENDING == 0 and A displaced, and reads A after the next refresh. On the unchanged production head, 0 passed, 1 failed, 0 ignored, with A retaining its old pixel value. With the candidate, 1 passed, 0 failed, 0 ignored, all 4,096 A pixels current; no skip. This extension models the GPU-written state after B's GPU content was already updated by the fixture; it does not perform a new GPU copy for that marking step.
  • cargo test --offline --locked -j 4 -p xcl --lib hle::d3d12x::title_textures::tests:: -- --test-threads=1 with the candidate: 31 passed, 0 failed, 0 ignored. The unit test also checks that reactivated and released resources leave displaced.
Local candidate diff (not committed)
diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index 5c139fea..bc4d6806 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -269,2 +269,3 @@ impl Table {
             if let Some(old) = self.by_res.remove(&ores) {
+                self.displaced.remove(&ores);
                 self.unlink_src(ores, old.src, old.tex.size() as usize);
@@ -282,2 +283,3 @@ impl Table {
             if let Some(old) = self.shadowed.remove(&sres) {
+                self.displaced.remove(&sres);
                 if old.placed && !old.unmapped {
@@ -300,2 +302,3 @@ impl Table {
     fn insert(&mut self, res: usize, mut entry: Entry) -> (isize, Vec<usize>) {
+        self.displaced.remove(&res);
         let va = entry.va;
@@ -365,2 +368,3 @@ impl Table {
         let mut e = self.shadowed.remove(&res)?;
+        self.displaced.remove(&res);
         self.shadowed_by_va.remove(&(e.va, res));
@@ -410,2 +414,3 @@ impl Table {
     fn remove(&mut self, res: usize) -> (bool, isize, Vec<usize>) {
+        self.displaced.remove(&res);
         if let Some(old) = self.shadowed.remove(&res) {
@@ -436,2 +441,3 @@ impl Table {
             if let Some(mut e) = self.shadowed.remove(&sres) {
+                self.displaced.remove(&sres);
                 // (the one that lay over it may have been uploaded over the same video memory)
@@ -498,2 +504,3 @@ static TEXTURES_LEN: std::sync::atomic::AtomicUsize = std::sync::atomic::AtomicU
 static HAS_SHADOWED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
+static HAS_DISPLACED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);
 /// cached `watch_ranges` keyed by `watch_key`
@@ -589,2 +596,3 @@ pub(super) unsafe fn register(device: *mut c_void, res: *mut c_void, va: usize,
         HAS_SHADOWED.store(!t.shadowed.is_empty(), Ordering::Relaxed);
+        HAS_DISPLACED.store(!t.displaced.is_empty(), Ordering::Release);
         clone_resources(&unmap_ptrs)
@@ -895,2 +903,3 @@ pub(super) unsafe fn retire_overlapping(va: usize, len: usize) {
         HAS_SHADOWED.store(!t.shadowed.is_empty(), Ordering::Relaxed);
+        HAS_DISPLACED.store(!t.displaced.is_empty(), Ordering::Release);
         (retired, clone_resources(&unmap_ptrs))
@@ -914,2 +923,3 @@ pub fn forget(res: usize) {
         HAS_SHADOWED.store(!t.shadowed.is_empty(), Ordering::Relaxed);
+        HAS_DISPLACED.store(!t.displaced.is_empty(), Ordering::Release);
         (removed, unsafe { clone_resources(&remap_ptrs) })
@@ -958,2 +968,3 @@ pub(super) fn uncover_drawn(res: &[usize]) {
         HAS_SHADOWED.store(!t.shadowed.is_empty(), Ordering::Relaxed);
+        HAS_DISPLACED.store(!t.displaced.is_empty(), Ordering::Release);
         (restored, unsafe { clone_resources(&remap) })
@@ -1855,3 +1866,3 @@ unsafe fn refresh_parts(queue: *mut c_void, look: bool) {
     recheck_streamed_unwatched(&ranges, recheck_frame);
-    if dirty_len == 0 && PENDING.load(Ordering::Relaxed) == 0 && AGAIN.lock().unwrap().is_empty() {
+    if dirty_len == 0 && PENDING.load(Ordering::Relaxed) == 0 && !HAS_DISPLACED.load(Ordering::Acquire) && AGAIN.lock().unwrap().is_empty() {
         return;
@@ -1867,2 +1878,3 @@ unsafe fn refresh_parts(queue: *mut c_void, look: bool) {
         let displaced = std::mem::take(&mut t.displaced);
+        HAS_DISPLACED.store(false, Ordering::Release);
         names.extend(displaced.iter().copied());
@@ -3913,2 +3925,3 @@ pub(super) mod tests {
         assert!(tbl.by_res.contains_key(&1));
+        assert!(!tbl.displaced.contains(&1), "reactivated A is owned by the active pending queue");
 
@@ -3922,2 +3935,13 @@ pub(super) mod tests {
         assert!(tbl.by_res.contains_key(&10) && !tbl.by_res[&11].pending && tbl.shadowed.contains_key(&12));
+
+        let mut released = Table::new();
+        let mut gpu_b = entry(0x30_0000, &tex_64k, false, false);
+        gpu_b.gpu_written = true;
+        released.insert(20, entry(0x30_4000, &tex_16k, true, false));
+        released.insert(21, gpu_b);
+        assert!(released.uncover(20).is_some());
+        assert!(released.uncover(21).is_some());
+        assert!(released.displaced.contains(&20));
+        assert!(released.remove(20).0);
+        assert!(!released.displaced.contains(&20), "released resources cannot be uploaded after address reuse");
     }
@@ -3977,2 +4001,15 @@ pub(super) mod tests {
             assert_eq!(read_r8(dev, &queue, &b), vec![0x33; 64 * 64]);
+            // Consume the next guest write while A is shadowed, then model a GPU write to B.
+            // B must not become pending when it displaces A before the following refresh.
+            std::ptr::write_bytes(base as *mut u8, 0x44, 2 * size);
+            refresh(queue.as_raw());
+            note_gpu_write(0, kb);
+            uncover_drawn(&[ka, kb]);
+            assert_eq!(PENDING.load(Ordering::Relaxed), 0);
+            assert!(TEXTURES.lock().unwrap().displaced.contains(&ka));
+            assert!(HAS_DISPLACED.load(Ordering::Acquire));
+            refresh(queue.as_raw());
+            assert!(!HAS_DISPLACED.load(Ordering::Acquire));
+            let a_pixels = read_r8(dev, &queue, &a);
+            assert_eq!(a_pixels.iter().filter(|&&v| v == 0x44).count(), 64 * 64, "displaced A goes up with no dirty pages or active pending texture");
             drop((_rb, _ra));

This closes the measured early-return path for committed textures. The PR's separate active-but-not-pending dirty-page limitation still needs a focused regression and a design that retains those bytes through the refresh; this test does not validate placed/tiled overlaps, guest binding, a retail title, the full workspace suite, or paired smoke. AI use: Codex (GPT-6.2 Sol) wrote and ran the local GPU regression and candidate; Codex (GPT-6.2 Astra) independently traced the displaced-set lifecycle and refresh ordering.

@thehollowedone

Copy link
Copy Markdown
Contributor

On #2956 head d5273351, I reproduced the active-but-not-pending case listed under Not tested. This is separate from the pending A / GPU-written B early return.

The added table regression models A as already uploaded (pending = false), with A and B overlapping in guest video memory but reading from distinct CPU source blocks. After uncover(B) displaces A, Table::uncover unlinks A's source and does not add A to displaced. The next cached_watch_ranges can omit A's 16 MiB source block, and refresh_parts has no displaced A to consider. The assertion below fails on the unchanged head at “A's source must stay watched until refresh.”

Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1 MSVC. cargo test --offline --locked -j 4 -p xcl --lib a_sampled_shadowed_texture_is_active_again -- --test-threads=1: 0 passed, 1 failed, 0 ignored, no GPU skip notice. This verifies table bookkeeping, not GPU pixels or retail incidence for this case.

Adding A only to displaced would not restore its missing watched range. A repair needs to keep the source watched, include an already-uploaded displaced A in dirty-page selection, and upload it only when dirty. The lifetime needs care: refresh_parts drains the global displaced set on any refresh, including an unrelated submission. Keeping the watch for one refresh alone can therefore lose a later CPU write before the command list that sampled A submits. Please retain the sampled resource obligation through the owning list's execution or replay (and clear it on reset/release), or provide an equivalent bounded way to keep displaced aliases eligible. Source changes, unmapping, and AGAIN retries also need to preserve or retire that obligation correctly. I have not validated a production fix for those lifecycle paths. A GPU regression that submits the recorded draw after an intervening refresh and later CPU write would distinguish a complete fix from a one-refresh fix; a runtime change also needs the required paired smoke.

Failing table regression
diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index 5c139fea..8b22c9b3 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -3921,4 +3921,17 @@ pub(super) mod tests {
         assert_eq!(tbl.uncover(11), Some((0, false)));
         assert!(tbl.by_res.contains_key(&10) && !tbl.by_res[&11].pending && tbl.shadowed.contains_key(&12));
+
+        // An already uploaded A is displaced by B before its next dirty-page scan.
+        let mut dirty_tbl = Table::new();
+        let mut b = entry(0x30_0000, &tex_64k, false, true);
+        b.src = 0x5000_0000;
+        let mut a = entry(0x30_4000, &tex_16k, false, true);
+        a.src = 0x4000_0000;
+        assert_eq!(dirty_tbl.insert(20, b).0, 0);
+        assert_eq!(dirty_tbl.insert(21, a).0, 0);
+        assert!(dirty_tbl.coarse.contains_key(&(0x4000_0000 >> SRC_COARSE_SHIFT)));
+        assert_eq!(dirty_tbl.uncover(20), Some((1, true)));
+        assert!(dirty_tbl.coarse.contains_key(&(0x4000_0000 >> SRC_COARSE_SHIFT)), "A's source must stay watched until refresh");
+        assert!(dirty_tbl.displaced.contains(&21), "refresh must consider dirty A");
     }

AI use: Codex (GPT-6.2 Sol) traced the relevant state transitions, wrote and ran the table regression, checked the lifecycle conditions, and drafted this report.

@LocranKing

Copy link
Copy Markdown

Tested PR #2956 (d5273351) on Windows 11 with a paired A/B 180 s open-world run against its base (eae01502) and the title_textures unit tests.

Environment

  • GPU: NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, driver 32.0.16.2140)
  • CPU / RAM: AMD Ryzen 5 5500 (6C/12T), 32 GB DDR4, Windows 11 Build 26300
  • Shader cache & runtime: Frozen nvidia-dev DXIL cache (XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_TEXTURE_LEVEL_PAGES=1, XCL_PREPARE_GRAPHICS=0, XCL_DRED=1), Series S (lockhart) profile.

Paired 180 s Open-World Smoke Comparison (lockhart)

Run Exit Crashes / Removals Frames (PresentX) Heavy world start Peak Commit Peak Local VRAM Peak Non-Local Target Pages
Base eae01502 0x0 0 / 0 1764 109.31 s 25679 MB 8285 MB 4288 MB 3647 MB
#2956 (d5273351) 0x0 0 / 0 1911 122.32 s 25488 MB 8414 MB 4353 MB 3632 MB

In #2956, once inside the open world (120.85 s–121.94 s), the title triggered the new reactivation path and logged:

  • D3D12.X: 65 shadowed textures sampled by draws so far were made active again (0 needed remapping in this batch) (with 1 needing remapping per batch in earlier batches at 120.85 s–121.81 s).

Unit tests (title_textures)

Note on test stability when running cargo test --locked -p xcl --lib -- title_textures on d5273351 (31 tests total; placed_title_textures_share_vram_and_preserve_pixels is newly added on d5273351 and not present on eae01502):

  1. First default parallel batch run: 30 passed; 1 failed (hle::d3d12x::title_textures::tests::placed_title_textures_share_vram_and_preserve_pixels ... FAILED).
  2. Re-run with -- --test-threads=1: 31 passed; 0 failed (2.20 s).
  3. Follow-up standalone default parallel run: 31 passed; 0 failed (2.26 s).

So placed_title_textures_share_vram_and_preserve_pixels passed reliably sequentially and on retry, with one observed intermittent failure under parallel execution.

Table::insert shadows the active textures a newer one overlaps, and a
placed texture over a different range is unmapped as well. Shadowed
textures are never uploaded again, but a title can keep sampling them:
GTA 6 samples the Bink planes of its credit-card scene after a newer
placement lands over part of them, so the GPU read zeros and the cards
rendered green with blocky streaks (over 131k draws sampled shadowed
textures in one 355 s run).

When a draw binds descriptor tables, the textures they name that are
shadowed become active again: the active ones overlapping them are
shadowed without being unmapped, the texture is marked pending (unless
the GPU wrote it), remapped if it was unmapped, and its known content
is forgotten so the next submit uploads it.

When two overlapping textures are made active in turn (one draw
sampling both, or two draws before their lists are submitted), the
second shadows the first again, but a draw already recorded samples it.
That first texture is "displaced" until two frames later: its source
stays watched, so what the title writes there still goes up, and if it
was pending, the next refresh uploads it whole even when no page was
written and no other texture is pending (the early return used to skip
it). Displaced textures go up before the active ones, so on shared
video memory the active content wins.

Assisted-by: Codex CLI (gpt-6.2-sol)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@andrewDoing

Copy link
Copy Markdown
Contributor

I retested the GPU-written B / displaced A early-return fixture from my earlier report on updated head 2608ea2367ead8d4aa43c9523ba7bad9b17e890d, RTX 5070 / NVIDIA 616.92. The test overlay changed only the displaced-set lookup to match the new map type.

In the normal case (PENDING=0, AGAIN empty), both native draws now returned all 2,048 expected pixels: A was current (0x83), and B retained its GPU-written value (0xc5). On the earlier d5273351 head, all 2,048 A pixels were stale. The unrelated-pending control also returned all expected A and B pixels. Each case ran in a fresh process, passed without skips, and left A tracked after the refresh, consistent with the revised retention behavior.

This validates the specific synthetic early-return case. The fixture explicitly supplies resource reactivation and GPU-write notification; it does not establish retail rendering or cover every dirty-page and command-list lifetime case.

AI use: OpenAI Codex with GPT-6.2 Astra ran the test; Codex reviewed and prepared this report.

@BBareth

BBareth commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @retrope13, @andrewDoing and @thehollowedone for the two cases, the readbacks and the failing tests. Both are fixed in 2608ea2, squashed into the one commit and rebased onto nvidia-dev d1be810. Thanks also @LocranKing for the open-world run.

Pending A displaced by a GPU-written B (the early return).

  • uncover_drawn sets the atomic HAS_DISPLACED when a displaced texture still owes its whole upload.
  • refresh_parts no longer returns early while it is set.
  • The GPU test gpu_both_overlapping_textures_a_draw_samples_go_up now also does @thehollowedone's sequence: write, refresh, note_gpu_write(B), uncover_drawn(A, B), PENDING == 0, refresh, A reads back the current bytes. With only that guard taken out, it fails at that readback.

Uploaded A displaced, then written by the title.

  • A displaced texture (pending or not, as long as the GPU did not write it) keeps its source linked. That keeps the 16 MiB block in the watched ranges and the pieces in touched_by, so refresh_parts takes it in its dirty-page selection and uploads it only when one of its pages was written.
  • On the lifetime: Table::displaced is a map with an expiry frame, present::counters + 2. It is no longer drained by the next refresh. refresh_parts drops the entries whose frame has passed and only then unlinks their source. The "whole" flag goes after the one whole upload, but the watch stays until the expiry. So an unrelated submit in between no longer ends the obligation.
  • A texture leaves displaced, and its source is unlinked once, when it is made active again, released, replaced or retired.
  • Displaced textures go up before the active ones at a refresh, so on shared video memory the active content is the one left.
  • In a_sampled_shadowed_texture_is_active_again, the table section covers:
    • the watch staying through a refresh before the expiry frame;
    • it going away at that frame;
    • one link each after A and B swap back and forth;
    • a release clearing it.
    • With only the "keep it linked" change taken out, it fails at "A's source stays watched".

Limits, which are also in the description: the two frames are a bound, not tracking of the list that recorded the draw. A list submitted later than that misses writes made after the expiry. There is no GPU pixel test for the second case, because the test memory is not in the UMA write-watch regions, so it is tested on the table.

Thanks @andrewDoing for rerunning the GPU-written B / displaced A fixture on 2608ea2 (2,048 of 2,048 current pixels for A, and B kept its GPU-written value).

The description now has new smoke blocks on 2608ea2. Under its normal exe name, both this PR and the base d1be810 lose the device at about 124 s in GTA 6 (3 of 3 rounds each) once the world loads, while main b49be18 does not. Run as a copy named exoborne.exe, which gets NVIDIA's 2 GiB shader heap (#2403), both are clean. pr_check still fails against main on frames and commit, and it fails the same way for the base. Against the base, this PR is at 98–101 % of its frames and 100–108 % of its peak commit. I am marking the PR ready for review.

On the parallel-run failure of placed_title_textures_share_vram_and_preserve_pixels: that test comes from #248 (ad79932) and is not changed here. I did not see it fail in my runs (counts in the description).

AI use: Claude Code (Claude Opus 5.5) wrote these fixes, their tests and this reply.

🤖 Generated with Claude Code

@BBareth
BBareth marked this pull request as ready for review November 28, 2026 00:33
@BBareth

BBareth commented Nov 28, 2026

Copy link
Copy Markdown
Contributor Author

A title data point for this head (2608ea23) together with #3179, from an RTX 5070 Ti 16 GB (driver 621.24): with both, more of GTA 6's intro cutscene is lit than with #3179 alone, and the run got further than any of ours.

Setup: retail title, release, XCL_HEAP_WINDOWS=1 XCL_UMA_WINDOWS=16 XCL_VIEW_REACH_MB=36 XCL_TWO_PASS_MB=4096 XCL_GFX_PSO_WAIT_MS=250 XCL_HUGE_PSO_CONCURRENCY=3 XCL_ALIAS_COPY=1 XCL_DRED=1, one A press at 150 s, 600 s. The tree is the same as in my #3179 report (nvidia-dev 54225f58 + #3094 + KDenKC's exp/sampler-prelude, prelude off, + a local #2799 port switched off). Each column adds one cherry-pick; this one applied without conflicts.

base + #3179 + #3179 + this PR
end 600 s, no crash 600 s, no crash (another run: device removed at 310 s) 600 s, no crash
frames shown 5,877 5,393 5,866
"made active again" – – 65,538 shadowed textures by 456 s; the logged batches show 1 remap
intro crowd shots near black some shots lit: a night street with lamps the same shots lit further: house fronts, a fence, a parked car, palm trees; more of the following shots lit
furthest shot an outdoor shot with a noisy sky the credit artwork a lit aerial shot over the sea and the coast, then a very bright interior
  • Some lit shots have small magenta and violet blocks, and some shots are still near black.
  • Video memory was 8.0 GB over the process budget at the end, about the same as the base (8.2 GB).

Not tested: more than one run with both; this PR without #3179; this head on its own; the test suite; AMD.

AI use: Claude Code with Claude Opus 5.5 ran the title on the machine above and wrote this.

@Prime1997
Prime1997 changed the base branch from nvidia-dev to main November 28, 2026 20:14
raylitebull added a commit that referenced this pull request Nov 28, 2026
…d textures drawn again

Work in progress on the visual defects of a retail title on an RX 9070 XT
(direct DXIL), not split into single changes yet:

- ambient: the resolve's light and depth are taken from their own slots; the
  estimate is made in space from the depth (cells placed, gathered at 160x90
  points, raised along a normal rebuilt from the depth), the air's light is
  held to the light around, magenta is rejected in the reflection clamps.
  Switches: XCL_AMBIENT_SPACE, XCL_AMBIENT_SPLIT, XCL_AMBIENT_MOST,
  XCL_AMBIENT_SKY. Credit in THIRD_PARTY.md.
- shadowed textures a draw's tables name are made active again (after open
  PR #2956): video frames no longer come up green.
- draws of bake pipelines (drawn once and kept) wait for their pipeline and
  make the shadowed textures they pick by index active again
  (XCL_KEPT_DRAWS, XCL_BAKE_SOURCES).
- diagnostics: XCL_TRACE_LATE, XCL_TRACE_SLOT.
- earlier fixes of this branch: vertex buffers kept out of the alias space,
  the PS export patch table for all pixel shaders, ambient levels.

Tested: cargo test -p xcl --lib -- ambient stage_name placements
title_textures pso_async bcpack rt_leave_out: 117 passed, 0 failed
(RX 9070 XT, release build runs of 300 s without device removal).
Not tested: the whole suite, scripts/smoke.ps1, other GPUs. Open: black
heads at a distance, dotted diagonals, 3-5 fps in the world.

Co-Authored-By: Claude Mythos 5.2 <noreply@anthropic.com>
@BBareth

BBareth commented Nov 30, 2026

Copy link
Copy Markdown
Contributor Author

Status of this PR against current main, from the reporter's machine (RTX 5070 Ti 16 GB, driver 621.24; i7-12700K; Windows 11 26200). Short version: it is not ready for main as it stands, and I am not pushing the rebase yet.

Tree: this PR's one commit rebased onto main 9dfbe3e (local only; two test call sites follow Table::remove's new return value; suite on the rebase: 2887 passed, 1 failed, 51 ignored, 28 SKIPPED, the failure being gpu_direct_image_get_resinfo_d16, which failed on that base alone too), merged with #3516's head 0dfcbd5, which this card needs to stay in the world. Release build, the retail title of #505, shaders prepared before the runs, XCL_DRED=1 XCL_PLACE_RETIRE=0 XCL_TEXTURE_LEVEL_PAGES=1 XCL_PRESS_A_AT=450 XCL_ACTIVITY=1 XCL_CS_PSO_WAIT_MS=250.

What the runs show

  • The rule still triggers on main: over 500 shadowed textures are made active again within 2 s of the world starting.
  • It never settles. The count grows at a steady rate for as long as the run lasts, about 410 a second: 16,384 by about 40 s into the world, 131,072 by about 310 s, 262,144 by about 600 to 640 s, 524,289 after 1,250 s in the 30-minute run. So overlapping textures that are both sampled keep taking the range from each other every frame, each swap possibly a whole upload. The PR's premise was that the set settles after a first round; on main it does not.
  • Frame rate in the world, presents per 2 s, mean over the run: 2.38 (1,290 s of world) and 2.51 (690 s) with this PR, 2.71 (1,275 s) without it (Recompiler: programs whose compact table needs more than 12,288 words take the plain form again #3516 only). One run each, and two further runs of the same tree with a local experiment on top gave 2.33 and 2.88, so the spread between runs is as large as the difference: no cost or gain is established.
  • One of five runs that contained this commit ended with an access violation in the title's own code (a read at address 0, about 65 s into the world). The other four ran to their time limit, and I have one run without the commit to compare with, so I cannot say whether it is related.
  • No device removal in any run.

Not tested: whether the world's picture is better with this PR on main (no frame comparison was made in these runs); nvidia-dev; AMD.

Next: the swapping needs a rule that ends, e.g. letting two CPU-backed textures at the same range stay active together instead of taking turns. A first local attempt at that (placed + committed, exact same range) did not reduce the count reliably (131,072 at 400 s in one run, 262,144 at 645 s in the other), so it is not in the branch. Until there is one, please treat this PR as not mergeable into main; the results on nvidia-dev in the comments above are unchanged.

Claude Code, Claude Fable 5.2 did the rebase, ran the suite and the game runs, read the logs and wrote this report.

@brainhay5

Copy link
Copy Markdown

Triage note: this no longer merges with current main (mergeable=false), so it cannot be built or tested as it stands.

Why I am asking rather than just noting it: we have run fifteen mergeable candidates on the retail title on an RTX 5070 Ti, and every one still stops presenting at 50–80 s (device removed, surfacing ~88 s later on the next allocation). The PRs whose descriptions actually match that symptom are the ones that no longer apply — this is one of them. A rebase would make it testable again, and we will run it and report the numbers.

If it has been superseded by merged work, saying so is enough and it can be closed.

AI use: an agent posted this triage note.

@BBareth

BBareth commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

It is not superseded, but I am not rebasing it for now, for the reason in my status comment above: rebased onto main 9dfbe3ea (with #3516, which this card needs to stay in the world) the reactivation count grew by about 410 per second for the whole run and never settled (524,289 after 1,250 s of world), and the frame rate with and without it was inside the run-to-run spread. Until the swapping has a rule that ends, a rebased head would only cost testers time. I will push a rebase when there is one; if that does not happen it can be closed.

On the symptom you describe (no presents after 50 to 80 s, device removed): on this RTX 5070 Ti that was cs 95cc13288a27a96e in #3261's compact form, and #3516 is what fixed it here; a report of seven runs is on that PR.

AI use: Claude Code, Claude Fable 5.2 wrote this reply from its own runs.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 2608ea2

No PR into main makes this change on its own. amd-dev took it in 8942a5b ("after open PR #2956"), so the amd-dev-based PRs (#3099, #3111, #3112, #3335, #3361) and the amd-dev catch-up merges #3547 / #3554 carry the same lines. Those are not substitutes for this PR.
Notes on the diff:

  • bind.rs uncover_bound_tables copies 64 x 32 bytes of each bound table on every draw while any texture is shadowed. That is a hot-path cost.
  • The PR's own regression blocks give 74-76 % of main's frames and 125-135 % of its peak commit, outside the limits in CONTRIBUTING.md. The description puts this on the base.
    The branch conflicts with main now.
    Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

@gut0to gut0to left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI-assisted static review: I used an AI assistant to trace descriptor-table traversal; I checked the range limit against Microsoft documentation.

/// samples the resource named by its heap index in word 0.
unsafe fn uncover_bound_tables(layout: Option<&Layout>, args: &[u8], u: &crate::gpu::uma::Uma) {
let Some(layout) = layout.filter(|_| super::title_textures::has_shadowed()) else { return };
const TABLE_SLOTS: usize = 64;

@gut0to gut0to Dec 1, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This scan stops at 64 entries, but a D3D12 root descriptor range can be larger or unbounded (NumDescriptors = UINT_MAX). The current Layout traversal records the table start but no descriptor count, so a shadowed T# SRV after slot 63 is omitted and uncover_drawn never reactivates it. Could the scan follow the actual reachable range, or document a console-specific limit and add a slot-64 regression test? AI-assisted static review: I used an AI assistant to inspect this path; I checked the range limit against https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_descriptor_range1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants