Skip to content

Recompiler: programs whose compact table needs more than 12,288 words take the plain form again - #3516

Open
KDenKC wants to merge 1 commit into
xcl-dev:mainfrom
KDenKC:fix/compact-table-limit
Open

KDenKC wants to merge 1 commit into
xcl-dev:mainfrom
KDenKC:fix/compact-table-limit

Conversation

@KDenKC

@KDenKC KDenKC commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

#3261 raised the most table words a program may need to take the direct DXIL compact form from 12,288 to 32,768. On the retail title that lets one more program take it: record 95cc13288a27a96e, whose tables need 16,121 words (19,840 blocks of 1,471 kinds, 237,860 B of DXIL). Its Dispatch never finishes, and the device is removed at the first world frame (DRED's first operation not done: the Dispatch after cs 95cc13288a27a96e). BBareth found it on #505; with the limit at 12,288 the program takes the plain form and the title stays in the world.

This puts the limit back to 12,288 on NVIDIA adapters and keeps 32,768 on others. XCL_COMPACT_TABLE_WORDS (1 to 32,768) sets it on any adapter; a value other than the default goes into the translated cache identity, with the nesting tag. Why the compact form of that program never finishes is not answered here (#3261's liveness or far-jump changes are the suspects in #505); this only stops the form from being chosen for tables that large.

Fixes the removal at the first world frame reported on #3261. Related: #505, #3261. Overlaps #3562 (compact.rs table limit, kernel.rs cache tag) and #3479 (its sized_plan uses the table-limit constant this PR replaces with max_table_words(): the two merge cleanly but the merged tree does not build until that line uses the function).

What is in it (one commit)

  • gpu/dxil/compact.rs: default_table_words: 12,288 on NVIDIA (NVIDIA_TABLE_WORDS), TABLE_WORDS_CEILING (32,768) on other adapters and before the adapter is known; XCL_COMPACT_TABLE_WORDS (max_table_words, table_words) on any adapter; table_words_tag (a limit other than 32,768) for the cache identity; automatic_plan_within takes the limit (tests).
  • gpu/adapter.rs: note_main_vendor / main_vendor, noted where the title's device (hle/d3d12x/real.rs) and the launch preparation's (shaders.rs) are made, so both use the same limit and cache identity.
  • gpu/dxil/kernel.rs: compact_nest_tag also carries that tag, so all three identity sites (recomp/pso.rs) see it.
  • gpu/dxil/compact_tests.rs: a_program_whose_tables_pass_the_limit_takes_the_plain_form (runs of repeated blocks added until the plan needs more than 12,288 table words, and at most 32,768: no plan at NVIDIA's limit, a plan at AMD's; CPU only), compact_table_limit_switch_parses (the limit by vendor, and the switch on any vendor).
  • README.md: the limit by vendor and the switch, where the compact form is described.

Cache. This changes translator source, so the direct DXIL source identity changes: every program is translated again (CPU and DXC) on the first run after updating, as with any translator change. Driver blobs are keyed by their DXIL, so only the programs whose DXIL changes need a new driver compile: on the retail title, by #3261's own count, 5 of 16,307 programs take the new form, so at most those.

Scope: NVIDIA only. The hang is seen on RTX 50-series (our RTX 5090, BBareth's RTX 5070 Ti); on an RTX 4080 the compact form of this program is built and the title stays in the world (throny, #505). On AMD the plain form is the costly one: on an RX 7900 XT with this PR, the driver compile of this program's plain form ran 150–311 s and returned 0x8007000e in 4 runs, and was still in the driver when 7 other runs ended, at the 48 GiB commit limit in most runs (crosettiremi, #505; thehollowedone pointed out what that means for an adapter-wide default, here). That report is not a matched main / head comparison and does not show the compact form is right on AMD, but it is reason enough not to change AMD's default here. The rule is by vendor (0x10DE), not by RTX 50 device ids: all the evidence for the hang is NVIDIA's, and a device-id list would have to be kept up to date for every new card; the RTX 4080 result means NVIDIA cards older than the 50-series pay the plain form's compile cost for nothing (measured on an RTX 3080 below: 124 s once, then a driver blob).

Tested

  • NVIDIA GeForce RTX 3090 24 GB (VM), driver 621.24, Intel i7-10700T, Windows 11 build 26300.9974, Rust 1.99.1, debug:
    • Red, main d52ff48c + the new plain-form test only (50c72beb): cargo test -p xcl --lib -- a_program_whose_tables_pass_the_limit_takes_the_plain_form:
      thread 'gpu::dxil::compact_tests::a_program_whose_tables_pass_the_limit_takes_the_plain_form' (3796) panicked at crates\xcl\src\gpu\dxil\compact_tests.rs:339:9:
      7 runs: 12554 table words take the compact form
      test result: FAILED. 0 passed; 1 failed; 0 ignored; 0 measured; 2765 filtered out; finished in 12.20s
      
    • This head 868dd971 (= 8d7d5091 + the GPU vendor noted during launch preparation, so the translation cache's identity carries the table limit from the start), cargo test --workspace --no-fail-fast -- --test-threads=4 (leaving out the 3 uma_driver tests this VM cannot run): 2870 passed, 6 failed, 51 ignored; 28 SKIPPED. The failures are this VM's on main d52ff48c (gpu_direct_image_get_resinfo_d16, the three title_textures::stream_recheck_*, test_title_runs_and_game_folder_is_untouched) and placed_title_textures_share_vram_and_preserve_pixels, which passes when run alone (on main d0832e61 and other heads): a failure of the parallel run on this VM.
    • The previous head 8d7d5091 (the same tree as 81d3f670, tested before the squash), cargo test -p xcl --lib -- compact: test result: ok. 23 passed; 0 failed; 0 ignored; 0 measured; 2744 filtered out (the plain-form test now checks NVIDIA's limit and AMD's). The whole suite on this head, cargo test --workspace --no-fail-fast -- --test-threads=4 (leaving out the 3 uma_driver tests this VM cannot run): in both runs the lib test binary was killed by an access violation in the parallel run (seen on main runs on this VM too); the other binaries 142 passed, 1 failed, 20 ignored, and the lib binary's one-thread rerun (all of uma_driver::tests left out) 2723 passed, 5 failed, 31 ignored. The failures are main d52ff48c's on this machine: gpu_direct_image_get_resinfo_d16, the 3 title_textures::stream_recheck_* and test_title_runs_and_game_folder_is_untouched.
    • Green, the previous head 0dfcbd5e, cargo test -p xcl --lib -- compact:
      test result: ok. 23 passed; 0 failed; 0 ignored; 0 measured; 2744 filtered out; finished in 24.21s
      
    • On 8d7d5091, cargo test --workspace --no-fail-fast -- --test-threads=4 (leaving out the 3 uma_driver tests that need a GPU upload segment this VM does not have): the other binaries 142 passed, 1 failed, 20 ignored; the lib binary gave no result in the parallel run, so its tests come from a one-thread rerun that leaves out all of uma_driver::tests: 2727 passed, 1 failed, 31 ignored. SKIPPED: 11 (7 no wave64, 1 no heap windows, 3 no debug layer). The 2 failures, gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16 and test_title_runs_and_game_folder_is_untouched, fail on main d52ff48c on the same machine too (its run lost the lib binary the same way; its one-thread rerun: 2721 passed, 5 failed, 31 ignored, the other 3 being title_textures::stream_recheck_*, which pass here).
  • RTX 5090 32 GB, the retail title, main d52ff48c with our local runner patches (an input filter, D3D12.X: XCL_PAIR_PAGES=1 caps a texture in a live one's memory to its pages #3281, a port of D3D12.X: a sampled texture in the memory of a written one of another format is copied from it (XCL_ALIAS_COPY=1) #3094 with the fix posted there), the same switches in each pair:
    • with 16f2f5c1 (two runs):
      [  119.720][…][ERROR] D3D12 device removed: 0x887a0006 The GPU will not respond to more commands, most likely because of an invalid command passed by the calling application.
      [ 1082.707][…][ERROR] D3D12 device removed: 0x887a0006 The GPU will not respond to more commands, most likely because of an invalid command passed by the calling application.
      
    • with 16f2f5c1 reverted (two runs): WORLD (+268 s in it, entry at 107 s); world fps 5.4; crashes 0, device removals 0 and WORLD (+246 s in it, entry at 98 s); world fps 5.9; crashes 0, device removals 0.
    • On the title: the previous head 8d7d5091 reached the world (entry at 247 s, 600 s, no device removal; its smoke pair was main 9dfbe3e 2,797 / 0 / 46,900 MB against 3,177 / 0 / 48,123 MB); this head 868dd971 stayed in the menus under the same recipe (see Regression run); and the run by BBareth below.
  • A game run by BBareth (thanks!), test report: main 9dfbe3e merged with this head (clean), release, RTX 5070 Ti 16 GB, driver 621.24, 1,800 s with 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, no XCL_SKIP_CS, no XCL_COMPACT_TABLE_WORDS: ran to its 1,800 s limit with no device removal, about 1,260 s of it in the world; record 95cc13288a27a96e's compute PSO is made from 1,383,220 B of DXIL again (the plain form; 237,860 B in the compact form that hung). Their merge check on main 9dfbe3e: cargo test --workspace --no-fail-fast -- --test-threads=4: 2887 passed, 1 failed (gpu_direct_image_get_resinfo_d16, failing on the base alone too), 51 ignored.
  • The plain form's cost on an older card, measured by Gevroska (thanks!), comment, RTX 3080, driver 616.92: creating record 95cc13288a27a96e's compute pipeline took 124.0 s cold in the plain form (this head, no driver blob), against 14.2 s for the compact form on d52ff48c, and 0.2 s warm once XCL supplies the driver blob. Their two device errors came 39 min 29 s and 190.6 s after that creation returned; their logs do not tie them to this program.

Regression run
RTX 5090 32 GB, driver 621.40, the retail title, 600 s each, scripts/smoke.ps1 with preparation off (XCL_PREPARE=0), the main arm from a copy of a translated cache made by main. Both runs used this machine's usual settings (XCL_UMA_WINDOWS=16, XCL_UMA_DRIVER=mixed:1536:1792, XCL_COHERENT_MB=4095, XCL_HUGE_PSO_CONCURRENCY=3), XCL_DRED=1, held Enter from the first frame, and XCL_SKIP_CS=95cc13288a27a96e. The head arm started from a translated cache made by a prepared run of this head (its cache identity carries this PR's table limit, so main's cache does not serve it); it built the program this PR changes in its plain form (1,383,220 B of DXIL) and left its dispatches out.

The head arm stayed on the title's menus for its 600 s under this recipe on this machine (shader preparation off, held-Enter input; other heads did the same tonight), so this pair checks start-up and the menus only: no device removal and no crash in either run; the head's 14,802 frames are menu presents and say nothing about speed or the world. The world is covered by BBareth's runs (RTX 5070 Ti, 7 runs), claudetools-gh's A/B (RTX 5070 Ti) and our pair on the previous head (8d7d5091, same base, world entry at 247 s), listed under Tested.

main 9dfbe3e:

xcl-smoke v1
commit: 9dfbe3ea6653a9c76ef3ea0d66187a4b5407483b
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 600
exit: 0x0
frames shown: 2797 (PresentX 2797)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 46900 MB

this head 868dd971:

xcl-smoke v1
commit: 868dd97145253113e0a903058df1bb3846f64890
gpu: NVIDIA GeForce RTX 5090
title: 9cc6a39e
seconds: 600
exit: 0x0
frames shown: 14802 (PresentX 14802)
presents per 2 s (last 3): 49 53 50
device removals: 0
crashes: 0
peak commit: 19884 MB

Not tested

  • AMD and Intel with this change (their limit stays main's 32,768; the AMD plain-form cost above is from the PR's earlier, adapter-wide head).
  • A run on the RTX 5090 longer than the 600 s regression run (BBareth's 1,800 s run is on an RTX 5070 Ti).
  • The fix in the regression pair: its main run did not hang within its 600 s (the smoke recipe does not reach the hang), so the pair shows no regression, not the fix; the removals it fixes are under Tested.
  • Why the compact form of 95cc13288a27a96e hangs.
  • Other titles on NVIDIA (their programs over 12,288 table words take the plain form too).

AI use

  • Claude Code (Claude Opus 5.5, Claude Sonnet 5.5), Codex (GPT-6.2-Sol), Antigravity (Gemini 4 Neon, Gemini 3.8 Flash): an agent swarm wrote, tested, reviewed and described this change from BBareth's diagnosis.

🤖 Generated with Claude Code
https://claude.ai/code/session_013oPUFCA9W9F8Qb5MPK33bR

@github-actions github-actions Bot added area:docs-ci Documentation, scripts, workflows, repo governance area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:tests Unit, integration, e2e tests, or testtitle gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Nov 30, 2026
@BBareth

BBareth commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

merge-check claim
head: 0dfcbd5

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 30, 2026
@BBareth

BBareth commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 9dfbe3e
head: 0dfcbd5
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2887 passed, 1 failed, 51 ignored; failing: gpu::dxil::msaa_tests::gpu_direct_image_get_resinfo_d16, which fails on the base alone too (base: 2885 passed, 1 failed, 51 ignored, 28 SKIPPED lines). 28 SKIPPED lines, as on the base. Both new tests passed (a_program_whose_tables_pass_the_limit_takes_the_plain_form, compact_table_limit_switch_parses), and so did the 14 existing compact tests, the GPU ones included (gpu_compact_inline_table_above_old_cap_checks_late_entries, gpu_compact_form_with_micro_blocks_and_literal_table_runs_as_the_plain_form, gpu_nested_compact_matches_plain_and_flat, ...).
review: no blocking finding; four files, every hunk read. MAX_TABLE_WORDS goes back from 32,768 to 12,288, so a program whose tables need more takes the plain form by default; XCL_COMPACT_TABLE_WORDS (1 to 32,768, anything else is ignored) raises the limit, and a non-default value is added to the translated cache identity next to the nesting tag, so entries made with different limits do not mix. The new test builds a program whose plan passes 12,288 words and still fits 32,768, and checks that automatic_plan refuses it; it returns early when a compact mode or the switch is set in the environment. README updated. This is the reporter's machine for #505 (comment 7271589972): on our tree, on main 53e85fb, a local switch of the same name and value 12288 was what took record 95cc13288a27a96e back to the plain form (1,643,508 B of DXIL) and the title then ran about 2,300 s in the world with no removal, where the compact form was removed in 2 of 2 runs. Not done: a game run of this PR's own head on current main; that needs the shaders prepared again here and I will report it on this PR if I get it done. As the description says, this does not explain why the compact form of that program never finishes.
performance: run time: none for programs within the limit. Start-up: a program between 12,288 and 32,768 table words compiles in the plain form again, which is bigger for the driver (for the one retail program concerned, 1,643,508 B of DXIL in place of 237,860 B), so the compile-time gain #3261 measured for it is given back; the translated cache entries of such programs are made again once.
verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124); i7-12700K; Windows 11 26200. Claude Code, Claude Fable 5.2 read the diff, ran the build and the suite and wrote this check.

@BBareth

BBareth commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Test report: a game run of this PR's head on current main, as announced in my merge check above.

Result (1 run): ran to the 1,800 s limit (XCL_RUN_SECONDS: 1800 s – ending the title (16139 frames shown, 16140 PresentX calls)), no 0x887a0006, no device-removed line. About 1,260 s of that in the world (631 two-second activity samples with the world's dispatch load), mean 2.7 presents per 2 s there.

Record 95cc13288a27a96e is back in the plain form: its compute PSO is created from 1,383,220 B of DXIL (237,860 B in the compact form that hung here; see the #505 comment linked in the PR).

For comparison, on main 53e85fb plus our local stack the same record in the compact form lost the device about 60 s after the world started, 2 runs of 2.

Not tested: main 9dfbe3e without this PR on this machine (the failing runs were on 53e85fb plus local changes); the XCL_COMPACT_TABLE_WORDS switch itself in a game run; more than one run; AMD.

Claude Code, Claude Fable 5.2 ran the build and the game run, read the log and wrote this report.

@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 30, 2026
@Gevroska

Copy link
Copy Markdown

@KDenKC I matched compute record 95cc13288a27a96e from your PR to the native pipeline-creation logs from my RTX 3080 (driver 616.92). Creation succeeded in all three runs. The two #3516 runs used 0dfcbd5e with local measurement counters on top.

Run XCL supplied a driver blob Native creation time When creation returned
Instrumented stock d52ff48c No 14.180 s 659.4 s after the last interval with a present
#3516, cold XCL cache No 124.031 s 24.0 s after Confirm, while frames were still presenting
#3516, warm XCL cache Yes 0.217 s 168.9 s before Confirm

The cold run reported DXGI_ERROR_DEVICE_REMOVED 39 min 29 s after this call returned. The warm run reported DXGI_ERROR_DEVICE_HUNG 190.6 s after it returned. That narrows what I can say about the two exits I reported on #505: this particular creation call had finished in both. My logs don’t identify a subsequent GPU dispatch or completion for this record, so they leave the dispatch hang described in the PR unresolved.

I used Codex GPT-6.2 Sol to analyze the logs. A separate GPT-6.2 Sol agent independently matched the record and checked the return timings against all three runs. Codex GPT-6.2 Astra drafted this comment.

I reviewed and approved this comment before posting.

@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 30, 2026
@KDenKC
KDenKC marked this pull request as ready for review November 30, 2026 23:07
@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Nov 30, 2026
@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@MacieGx @SergeAx a request, only if you have the time: you have both reached the world on an RTX 5080, which would make a useful third RTX 50-series card here. Could one of you check whether #3261's compact form removes the device on a 5080, and whether this PR stops it?

Fair warning: this is a long A/B, and arm B's first start compiles that program cold (Gevroska measured 124 s on a 3080 above). Two runs per arm would settle it; one each already helps.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.

@BBareth

BBareth commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Test report: runs with this PR on an RTX 5070 Ti (arm B of the request in #505; I did not run arm A again tonight).

run time in the world end
1 805 s time limit, no device removal
2 690 s time limit, no device removal
3 691 s time limit, no device removal
4 687 s time limit, no device removal
5 388 s time limit, no device removal
6 390 s time limit, no device removal
7 18 s device removed at 533.5 s, 0x887a0006
  • Run 7: DRED device state 3, page fault at GPU VA 0x0 with no allocation listed there. The compute list it stopped in had cs 1f2c0a6e62bc5346 bound (132 of 1,529 operations done, cs 87b7403562ba17e7 dispatches before it); the graphics list was in ms 05fca5429fa919c6 ps 9ba3a7801435f7d6. 95cc13288a27a96e is not in the breadcrumbs. After the removal the process did not exit and could not be killed (one thread left in a kernel wait).
  • Earlier the same day, on main 9dfbe3ea + this PR (two of the four runs with one more local change): four runs of about 690 s in the world each, no device removal.
  • For comparison, on 30 November main 53e85fb1 without this PR lost the device about 60 s after the start prompt in both runs I made on this card, with a Dispatch of cs 95cc13288a27a96e in the breadcrumbs.
  • Frame rate in the world in runs 1 to 6: 2.6 to 3.1 presents per 2 s; video memory 16.1 to 18.4 GB of a 15.2 GB budget.

Hardware: NVIDIA GeForce RTX 5070 Ti 16 GB, driver 621.24 (32.0.16.2124), i7-12700K, 32 GB RAM, Windows 11 Pro 26200.

AI use: Claude Code, Claude Fable 5.2 made the runs and wrote this report.

@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@BBareth thank you, and that's more than enough from you on this one 😄 Your 30-minute run earlier plus these seven (six clean, and run 7 a different removal: a page fault at VA 0x0 with 95cc13288a27a96e not in the breadcrumbs) cover the 5070 Ti side well. Please don't spend more evenings on it!

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.

@thehollowedone

Copy link
Copy Markdown
Contributor

Cross-linking an AMD result relevant to this PR's adapter-wide default: the RX 7900 XT report in #505 tested d52ff48c plus #3516. The affected compute program took the 1,383,220-byte plain form. In four runs, its driver compile lasted 150–311 seconds and returned 0x8007000e; in seven more, it was still in the driver when the runs ended. Process commit reached the report's 48 GiB limit in most runs.

That report's faster comparison tree differs in more than this PR and had a different cache history. It does not establish that #3516 regresses AMD against a matched current-main control, nor that the compact form is correct there. It does establish that the new plain-form path is costly on this AMD setup; the PR's current “AMD not tested” line misses that evidence.

Before treating the 12,288-word default as an adapter-wide resolution, I suggest a matched AMD main/head comparison with the same driver, inputs, and cache state, recording compile outcome, peak commit, and in-world behavior. If that comparison favors compact on AMD, the narrower RTX 50-series fallback already discussed in the PR description would preserve AMD's path while addressing the observed NVIDIA hang. The separate compact-table fixes in #3473 and #3475 should be assessed on their own heads.

AI use: OpenAI Codex (GPT-6.2 Sol) checked the linked report, this PR's current head, and the source-level selection change. I did not run an AMD test.

@KDenKC
KDenKC marked this pull request as draft December 1, 2026 04:46
@KDenKC
KDenKC force-pushed the fix/compact-table-limit branch from 0dfcbd5 to 8d7d509 Compare December 1, 2026 04:52
@github-actions github-actions Bot added area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test) needs-pr-check Failing the PR description check (CONTRIBUTING.md) and removed gpu:both Code affects both AMD and NVIDIA GPUs (scope tag; see needs:*-test for remaining checks) labels Dec 1, 2026
@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@thehollowedone thank you, agreed: crosettiremi's RX 7900 XT result shows the plain form of that program is the costly one on AMD, and an adapter-wide 12,288 default was not justified by evidence that is all NVIDIA's.

Narrowed in 8d7d509 (squashed): the limit is 12,288 only when the main adapter's vendor is NVIDIA (0x10DE) and stays 32,768 on every other adapter, as on main; XCL_COMPACT_TABLE_WORDS still sets it on any adapter. The vendor is noted where the title's device and the launch preparation's are made, so both pick the same limit and the same translated cache identity. Vendor-level rather than RTX 50 device ids, because all the hang evidence is NVIDIA's and a device-id list would have to follow every new card; on older NVIDIA cards that only costs the plain form's one-time compile (Gevroska measured 124 s cold on an RTX 3080, then a driver blob).

The tests now check both: the plain-form test builds a program over 12,288 table words and checks that it gets no compact plan at NVIDIA's limit and keeps it at AMD's, and the switch test covers the limit by vendor. A matched AMD main / head comparison is still open, as you say; with this change AMD keeps main's behaviour, so it is no longer needed for this PR.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 3.8 Flash.

@github-actions github-actions Bot removed the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@KDenKC
KDenKC marked this pull request as ready for review December 1, 2026 05:37
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Dec 1, 2026
Folded, the two copies of each repeated memory access are compact blocks
of their own, so a folded program's tables can pass the limit its split
form's stay under, and it then took the plain form. On a tree with
xcl-dev#3516's limit of 12,288 words, a retail wave64 compute program of 78,920
reachable instructions took the compact form split (11,311 table words)
and, folded (14,805 words), the plain form: 4,346,408 B of DXIL in one
function, which NVIDIA's compiler had not finished after ten minutes at
4.9 GB.

The folded translation now refuses a program whose compact form is
refused only for the size of its tables (compact::wanted_plan: the
automatic choice before its table check), and the split form takes the
compact form as it did before folding.

Under main's 32,768 words no program of that pack changes: two folded
programs want the compact form, with 14,776 and 14,805 table words. Under
xcl-dev#3516's 12,288 both do.

The test folds a program of 57,344 copies of a load whose split form's
tables fit and whose folded tables do not: the folded translation is
refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

merge-check
base: 7d86c5d
head: 8d7d509
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2898 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff. On NVIDIA, programs needing 12,289-32,768 compact-table words take the plain form again (the limit #3261 / 16f2f5c raised to 32,768 goes back to 12,288 there), and every vendor's translated cache is rebuilt once after updating. Findings: (1) the limit is read on every translation (max_table_words()) from a vendor recorded only when a device is created, while the cache tag that marks it is fixed once in translated::identity() / direct_output() (pso.rs ~361, ~674, OnceLock). prepare_for_launch (shaders.rs ~3279) calls warm_library::reuse -> compatibility() -> translation_cache_identity() (warm_library.rs ~74 / ~91) before any device exists, so in that process the identity is the untagged one while later NVIDIA translations use 12,288: plain forms are cached under the identity other vendors use, and the host and its prepare workers (which create a device first) can disagree. Taking the vendor from the DXGI adapter before the identity is first computed (as preparation_driver_identity_for_adapter already selects it), or fixing the limit together with the tag, would avoid it. The PR's runs all used XCL_PREPARE=0, as does the smoke run here, so this path is untested. (2) Nit: in adapter.rs ~118 the new items sit under the doc comment of name(), which now documents NVIDIA. Fine: parsing and clamping of XCL_COMPACT_TABLE_WORDS, the tag reaching all three identity sites through compact_nest_tag, and the CPU test checking both vendors' limits.
performance: 60 s smoke of a retail title, main 7d86c5d vs this merge (65c22e76): 1663 -> 1682 frames shown (101 %; last presents per 2 s: 61 60 60), peak commit 17153 -> 17493 MB, 0 device removals, 0 crashes.
verdict: not yet: the cache identity is fixed before any device exists during preparation, so on NVIDIA plain forms can be cached under the untagged identity other vendors use (finding 1); fix the ordering, or say why preparation can't reach it
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5

AI-written and posted by Foniass without a human check of each point.

@Aniseto

Aniseto commented Dec 1, 2026

Copy link
Copy Markdown

Ran the compact tests at 8d7d5091 on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib -- compact --test-threads=1
23 passed; 0 failed; 0 ignored; 2744 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib gpu::dxil::compact_tests::a_program_whose_tables_pass_the_limit_takes_the_plain_form -- --test-threads=1
1 passed; 0 failed; 0 ignored; 2766 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib gpu::dxil::compact_tests::compact_table_limit_switch_parses -- --test-threads=1
1 passed; 0 failed; 0 ignored; 2766 filtered out      (exit 0)

All 23 compact tests pass here, including the two named tests of the description. This adapter is NVIDIA, so it is the vendor whose default limit this PR changes; the CPU-only tests check the 12,288-word plain-form case and the switch parsing. No title run was done here.

Not tested: the full workspace suite, a retail title in the world, the 95cc13288a27a96e program's Dispatch on this adapter, XCL_COMPACT_TABLE_WORDS with a non-default value, AMD adapters, Wine, wave64 hosts, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

…2,288 words take the plain form

xcl-dev#3261 raised the most table words a program may need to take the compact form from 12,288 to 32,768. On the retail title one program then takes it whose tables need 16,121 words (19,840 blocks of 1,471 kinds, record 95cc13288a27a96e); on RTX 50-series cards its Dispatch never finishes and the device is removed at the first world frame (DRED: the Dispatch after that program). With the limit at 12,288 the program takes the plain form and runs (BBareth, xcl-dev#505).

The limit goes back to 12,288 on NVIDIA adapters only. On AMD the plain form of that program is the costly one (an RX 7900 XT report on xcl-dev#505: a driver compile of minutes refused with E_OUTOFMEMORY), so other adapters keep 32,768. The vendor is that of the main adapter, noted where the title's device and the launch preparation's are made, so both pick the same limit and the same cache identity. XCL_COMPACT_TABLE_WORDS sets the limit on any adapter (1 to 32,768); a limit other than 32,768 goes into the translated cache identity with the nesting tag.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Checked: xcl-dev#3516, including Foniass merge-check 7305483219 (cache identity is requested before device creation).
@KDenKC
KDenKC force-pushed the fix/compact-table-limit branch from 8d7d509 to 868dd97 Compare December 1, 2026 08:58
@github-actions github-actions Bot added the needs-pr-check Failing the PR description check (CONTRIBUTING.md) label Dec 1, 2026
@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@Foniass thanks for catching the preparation ordering: fixed in 868dd971 (squashed). Launch preparation now records the selected adapter's vendor before computing its driver identity, so warm_library::compatibility() sees the NVIDIA table limit when it first creates the translation cache identity. The adapter-name documentation is back on name().

Validation on the RTX 3090: build exit 0 (45 s); the compact-table test passed. The workspace suite is red:

test result: FAILED. 2728 passed; 5 failed; 31 ignored; 0 measured; 3 filtered out; finished in 133.72s
test result: FAILED. 4 passed; 1 failed; 0 ignored; 0 measured; 0 filtered out; finished in 9.73s

The failures are the same set this VM shows on the base without the PR (your run of main had none, so they are this machine's): D16 resinfo, placed-title-texture plus its three poisoned follow-on tests, and the end-to-end title test (Invalid bitcode signature). I did not add a separate ordering test: the vendor state and translation identity are process-global/once-cached, so a unit test that resets them would race the parallel suite. The existing adapter_identity_matches_the_device_identity test passed.

A new regression pair for this head is running on the RTX 5090 and goes into the description when it lands.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Re-review (head 868dd97, the 3-line change from 8d7d509 read; not a merge-check, since PR description is red until the smoke pair is rerun on this head). Follow-up to my merge-check of 8d7d509.

  • The cache identity during preparation: fixed (from reading). preparation_driver_identity_for_adapter (real.rs ~9409) now notes the vendor of the adapter it selects. warm_library::reuse evaluates it as the argument of compatibility() (warm_library.rs ~91), so the vendor is known before translation_cache_identity() first fixes the identity. The selector is the one the device is made from later, so both agree. Nothing tests this ordering; a test that resets the vendor and checks the identity after reuse would keep it from regressing.
  • The doc comment of name(): fixed.

Nothing else changed: the rest of the diff is identical to the head I merge-checked (suite 2898 passed / 0 failed, smoke 1663 -> 1682 frames). With the smoke pair rerun on this head it looks ready to me.

AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.

@Aniseto

Aniseto commented Dec 1, 2026

Copy link
Copy Markdown

This is a new response on the same thread as my report at 8d7d5091 (#3516 (comment)); the head moved to 868dd971 (the preparation-ordering fix), so I am not editing that comment.

Ran the compact tests at 868dd971 on an NVIDIA Blackwell desktop part with 16 GB of VRAM.

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, 32-lane waves only, 16 GB, mesh shaders) driver 32.0.16.2140 (621.40), Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build, XCL_ADAPTER=NVIDIA, detached worktree at the exact PR head, no local patches.

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib -- compact --test-threads=1
23 passed; 0 failed; 0 ignored; 2744 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib gpu::dxil::compact_tests::a_program_whose_tables_pass_the_limit_takes_the_plain_form -- --test-threads=1
1 passed; 0 failed; 0 ignored; 2766 filtered out      (exit 0)

XCL_ADAPTER=NVIDIA cargo test -q -p xcl --lib gpu::dxil::compact_tests::compact_table_limit_switch_parses -- --test-threads=1
1 passed; 0 failed; 0 ignored; 2766 filtered out      (exit 0)

The same 23 compact tests and the two named tests pass at the squashed head; the translation-ordering change did not alter these results here. No title run was done.

Not tested: the full workspace suite, a retail title in the world, the 95cc13288a27a96e Dispatch on this adapter, XCL_COMPACT_TABLE_WORDS with a non-default value, AMD adapters, Wine, wave64 hosts, release profile, game data.

AI-assisted (OpenCode), model: MiMo-V2.6-Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used.

@Foniass

Foniass commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Triage (#1607) – head 868dd97

No other open PR changes the compact table limit this way (#3562 and #3479 touch the same MAX_TABLE_WORDS check for other purposes and will conflict). Main raised the limit from 12,288 to 32,768 in 16f2f5c; this PR puts NVIDIA back at 12,288.
Possible problem: compact.rs:max_table_words reads adapter::main_vendor() each time, so any translation or cache identity computed before note_main_vendor runs (0 = unknown -> 32,768, no tag) would use a different limit and cache tag than later ones on NVIDIA. The PR notes the vendor at the title device, at the preparation device and in preparation_driver_identity_for_adapter; worth checking that no other path (e.g. xcl cache status, offline xcl shaders) computes the identity first.
Recommendation: keep open.

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

@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

@Foniass checked the other paths you named: translation_cache_identity() has two callers, warm_library::compatibility and warm_replay::native_key. The runtime's expected() / expected_for_adapter evaluate preparation_driver_identity* first, xcl cache status goes through expected_for_adapter(auto) (which notes the vendor before compatibility), warm replay's native_key takes the device's driver identity before the translation identity, and the offline shader / recompiler CLI paths don't compute it at all. So no other path fixes the identity before the vendor is known; no further change.

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

@AAsobu

AAsobu commented Dec 1, 2026

Copy link
Copy Markdown

merge-check
base: b2b1f10
head: 868dd97
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2904 passed, 0 failed, 51 ignored; SKIPPED: 28 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll, 1 no GPU_UPLOAD heaps); failing: none. The PR's 2 tests ran and pass (a_program_whose_tables_pass_the_limit_takes_the_plain_form, compact_table_limit_switch_parses).
review: none. Read the whole diff (+125/-5: compact.rs, compact_tests.rs, kernel.rs, adapter.rs, real.rs, shaders.rs, README). The limit is chosen from the main adapter's vendor, noted where the title's device and the preparation's device are made and in preparation_driver_identity_for_adapter before any device exists; a limit other than 32,768 goes into the translated cache tag next to the nesting tag, so NVIDIA and other adapters never share a translation; XCL_COMPACT_TABLE_WORDS outside 1..=32,768 falls back to the vendor default.
performance: retail title, in the world. Release builds of main b2b1f109 (A) and this merge (B), runs B, A, B, A, B of 420 s; the first B run only built this head's translations (its cache tag on NVIDIA is new) and is left out. xcl.exe with the #2590 profile at 2048 MB. Env: XCL_PREPARE=0 XCL_DIRECT_DXIL=1 XCL_DXC_THREADS=4 XCL_NETWORK=0 XCL_DRED=1 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=1000 XCL_TEXTURE_LEVEL_PAGES=1 XCL_HUGE_PSO_CONCURRENCY=4 XCL_HUGE_PSO_WANTED_CONCURRENCY=4 (default XCL_DIRECT_COMPACT), start prompt by XCL_PRESS_A_AT, no input. From world entry + 30 s: presents per 2 s A 1.12 / 1.05, B 1.03 / 1.11; draws per 2 s A 5098 / 4641, B 4647 / 4834; dispatches per 2 s A 6171 / 5487, B 5304 / 5708; peak process commit A 45,834 / 43,002 MB, B 42,422 / 42,653 MB; peak VRAM A 17,489 / 16,702 MB, B 17,123 / 16,604 MB; 0 skipped draws and 0 device removals in all four. No frame-time or memory change.

@cj-tomlin

Copy link
Copy Markdown

merge-check claim
head: 868dd97

@cj-tomlin

Copy link
Copy Markdown

merge-check
base: f07e426
head: 868dd97
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 passed, 1 failed, 51 ignored; SKIPPED: 27 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll); failing: gpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs, which fails on the base too: run alone 4 times each, 4 of 4 failed on main f07e426d and 4 of 4 on the merge, same machine; this PR does not touch that path. The PR's two tests (a_program_whose_tables_pass_the_limit_takes_the_plain_form, compact_table_limit_switch_parses) ran and pass.
review: none blocking, after reading the whole diff (+125/-5: compact.rs, compact_tests.rs, kernel.rs, adapter.rs, real.rs, shaders.rs, README). The compact form's table limit is 12,288 words when the main adapter is NVIDIA and 32,768 otherwise or before the vendor is known; XCL_COMPACT_TABLE_WORDS (1..=32,768, else the vendor default) overrides it on any adapter, and a limit other than 32,768 goes into the translated cache identity through compact_nest_tag, so the two limits never share translations. The vendor is noted where the title's device and the preparation device are made and in preparation_driver_identity_for_adapter. The new limit test is CPU-only and checks the plan choice at both vendors' limits; it is slow in a debug build. On NVIDIA, which this machine is, the change is in force: translations get the new tag and are made again once after updating. I did not run a title.
performance: no measured run here. By default on NVIDIA, programs whose compact tables need 12,289 to 32,768 words take the plain form again, as before #3261; other adapters are unchanged. AAsobu's world runs above cover the title-level comparison.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB, driver 621.40, AMD Ryzen 7 7800X3D, Windows 11 build 26300, debug build / Claude Code (Claude Opus 5.5) merged, built, ran the suite, read the diff and drafted this; I checked it.

@github-actions github-actions Bot added ready-to-merge Has 2 independent safe merge-checks on current head (#3041) and removed needs-2nd-check Has 1 safe merge-check; needs second independent check (#3041) labels Dec 1, 2026
Royalflamejlh added a commit to Royalflamejlh/xcl that referenced this pull request Dec 1, 2026
Folded, the two copies of each repeated memory access are compact blocks
of their own, so a folded program's tables can pass the limit its split
form's stay under, and it then took the plain form. On a tree with
xcl-dev#3516's limit of 12,288 words, a retail wave64 compute program of 78,920
reachable instructions took the compact form split (11,311 table words)
and, folded (14,805 words), the plain form: 4,346,408 B of DXIL in one
function, which NVIDIA's compiler had not finished after ten minutes at
4.9 GB.

The folded translation now refuses a program whose compact form is
refused only for the size of its tables (compact::wanted_plan: the
automatic choice before its table check), and the split form takes the
compact form as it did before folding.

Under main's 32,768 words no program of that pack changes: two folded
programs want the compact form, with 14,776 and 14,805 table words. Under
xcl-dev#3516's 12,288 both do.

The test folds a program of 57,344 copies of a load whose split form's
tables fit and whose folded tables do not: the folded translation is
refused.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@KDenKC

KDenKC commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author

Heads-up on overlaps, found by trial merges on main 6bfb5c51:

AI use: an agent swarm: Claude Opus 5.5, Claude Sonnet 5.5, GPT-6.2-Sol, Gemini 4 Neon and Gemini 4 Hydrogen.

@github-actions github-actions Bot removed the ready-to-merge Has 2 independent safe merge-checks on current head (#3041) label Dec 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:d3d12 D3D12.X runtime, command lists, resources, sparse memory area:docs-ci Documentation, scripts, workflows, repo governance area:recompiler RDNA2 decoder, HLSL/direct-DXIL recompiler, wave64/wave32 area:shaders Shader cache, PSO compilation, pipeline libraries, precompilation area:tests Unit, integration, e2e tests, or testtitle gpu:nvidia Code is specific to NVIDIA / wave32 GPUs (scope tag; see needs:nvidia-test)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

9 participants