D3D12.X: a view-by-address desc's padding is zeroed before it keys a texture #3000

Closed
voiceovarian1-max wants to merge 1 commit from upstream-pr/3000 into main
voiceovarian1-max commented 2026-11-27 11:14:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by voiceovarian1-max on 2026-11-27T11:14:31Z.


resource_at makes one PC texture per address and desc for a title's views by address, keyed by the PC part of the desc. The 4 bytes after the dimension are padding (before the 8-byte Alignment) and hold whatever the title's stack held there, so the same texture at the same address was made again for each value: in a retail title's world, 19,780 of 65,536 texture creations by address. The key (view_desc_key) now zeroes that padding as well as the padding after the flags.

What is in it

  • hle/d3d12x/real.rs: view_desc_key, used by resource_at, and the test view_desc_padding_does_not_change_the_key.

Tested

  • Linux (CachyOS, kernel 7.3), Proton Experimental (Wine 11.0) with vkd3d-proton 3.1, RTX 4070 Ti 12 GB, NVIDIA 620.73.04; Rust stable, x86_64-pc-windows-gnu, release; head 001bf96a074d on main 623d02e4.
  • cargo test -p xcl --lib view_desc (under Wine): 2 passed, 0 failed. Without the change the new test fails (1 failed).
  • The count above is from a retail run on our Linux tree (the same 3-line change on nvidia-dev), not from this branch.

Regression run

  • None: scripts/smoke.ps1 needs Windows, and we only have Linux. A Windows run of smoke on main and on this head would be welcome.

Not tested

  • Windows, AMD, the whole suite on a GPU (this machine's NVIDIA driver refused new devices at the time of the run), a retail title on this branch.

AI use

  • Claude Code with Claude Opus 5.5: found the duplicate creations in a run's counts, wrote the change, the test and this description.

🤖 Generated with Claude Code

<!-- greyfinch-sync:ivall/xcl:issue:5525682658 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3000). Originally posted by [voiceovarian1-max](https://github.com/voiceovarian1-max) on 2026-11-27T11:14:31Z. --- `resource_at` makes one PC texture per address and desc for a title's views by address, keyed by the PC part of the desc. The 4 bytes after the dimension are padding (before the 8-byte `Alignment`) and hold whatever the title's stack held there, so the same texture at the same address was made again for each value: in a retail title's world, 19,780 of 65,536 texture creations by address. The key (`view_desc_key`) now zeroes that padding as well as the padding after the flags. **What is in it** - `hle/d3d12x/real.rs`: `view_desc_key`, used by `resource_at`, and the test `view_desc_padding_does_not_change_the_key`. **Tested** - Linux (CachyOS, kernel 7.3), Proton Experimental (Wine 11.0) with vkd3d-proton 3.1, RTX 4070 Ti 12 GB, NVIDIA 620.73.04; Rust stable, `x86_64-pc-windows-gnu`, release; head `001bf96a074d` on main `623d02e4`. - `cargo test -p xcl --lib view_desc` (under Wine): 2 passed, 0 failed. Without the change the new test fails (1 failed). - The count above is from a retail run on our Linux tree (the same 3-line change on nvidia-dev), not from this branch. **Regression run** - None: `scripts/smoke.ps1` needs Windows, and we only have Linux. A Windows run of smoke on main and on this head would be welcome. **Not tested** - Windows, AMD, the whole suite on a GPU (this machine's NVIDIA driver refused new devices at the time of the run), a retail title on this branch. **AI use** - Claude Code with Claude Opus 5.5: found the duplicate creations in a run's counts, wrote the change, the test and this description. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Alm0stSurely commented 2026-11-27 11:38:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Alm0stSurely on 2026-11-27T11:38:44Z.


RTX 5080, driver 620.73.04, Proton Experimental, Series X profile. We tested the cache-key change at 001bf96a on our #2057 (70a7e1d5) integration with a local port of #2306. #2762 covers the same four padding bytes. The focused test failed on the old key and passed on the patched key.

In a 660 s title run, resource_at returned a cached, non-null texture 110,751 times. We could compare 96,848 hits to the description recorded when that same object was created. Bytes 0x04..0x08 matched on every one of those hits. The diagnostic table filled at 65,536 keys, leaving 13,903 hits unclassified and 12,001 creation events beyond capacity. This measures reuse calls and cannot quantify allocations saved or rule out padding differences among the unclassified hits.

With the same save, driver and cache seeds as the unpatched control, both runs passed the credits and showed the cellmate tutorial over uniform gray. The 790 × 510 scene crop stayed pixel-identical in all 15 captures around forward/backward and camera inputs in each run. We still have no visible gameplay on this setup. This is an integration result, separate from the clean-main regression run.

AI-assisted testing and write-up with OpenAI Codex (gpt-6.2-astra).

<!-- greyfinch-sync:ivall/xcl:comment:7217312915 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3000#issuecomment-7217312915). Originally posted by [Alm0stSurely](https://github.com/Alm0stSurely) on 2026-11-27T11:38:44Z. --- RTX 5080, driver 620.73.04, Proton Experimental, Series X profile. We tested the cache-key change at `001bf96a` on our #2057 (`70a7e1d5`) integration with a local port of #2306. #2762 covers the same four padding bytes. The focused test failed on the old key and passed on the patched key. In a 660 s title run, `resource_at` returned a cached, non-null texture 110,751 times. We could compare 96,848 hits to the description recorded when that same object was created. Bytes `0x04..0x08` matched on every one of those hits. The diagnostic table filled at 65,536 keys, leaving 13,903 hits unclassified and 12,001 creation events beyond capacity. This measures reuse calls and cannot quantify allocations saved or rule out padding differences among the unclassified hits. With the same save, driver and cache seeds as the unpatched control, both runs passed the credits and showed the cellmate tutorial over uniform gray. The 790 × 510 scene crop stayed pixel-identical in all 15 captures around forward/backward and camera inputs in each run. We still have no visible gameplay on this setup. This is an integration result, separate from the clean-main regression run. AI-assisted testing and write-up with OpenAI Codex (`gpt-6.2-astra`).
Royalflamejlh commented 2026-11-27 11:58:36 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Royalflamejlh on 2026-11-27T11:58:36Z.


The Windows regression run the description asks for: scripts/smoke.ps1 on an RTX 2070 SUPER 8 GB, main 623d02e4 and this head 001bf96a in turn, 2 runs each, showed no regression: 60 presents per 2 s at the end, no crash and no device removal in all four runs.

Setup: Windows 11 Pro 26200, RTX 2070 SUPER 8 GB, driver 621.01, Ryzen 7 5700X3D, 16 GB RAM, rustc 1.100.0, release; XCL_PREPARE=0 in all four runs (the shader preparation left out, as #2976 allows, so that the 60 s are the title's).

Run Tree Frames shown Peak commit
1 main 623d02e4 1106 14794 MB
2 this head 001bf96a 1117 14792 MB
3 main 623d02e4 1141 14691 MB
4 this head 001bf96a 1144 14651 MB

The blocks of runs 3 and 4, for Regression run:

xcl-smoke v1
commit: 623d02e465a17497a757a4ce867f482b0a6c8f3b
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1141 (PresentX 1141)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14691 MB
xcl-smoke v1
commit: 001bf96a074d8d3a27a1da29f4834bc71dc0c077
gpu: NVIDIA GeForce RTX 2070 SUPER
title: 5330474d
seconds: 60
exit: 0x0
frames shown: 1144 (PresentX 1144)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14651 MB
  • As Alm0stSurely wrote, #2762 (496ef578, open since 26 November) makes the same change: its view_key zeroes 0x04..0x08 and 0x34... On #2762 we measured it under Wine on an RTX 4070, on main b49be18 + #684, 3 runs of each key: 41,136 to 41,369 textures kept at 118 s, against 59,564 to 60,240 with the old key (https://github.com/xcl-dev/xcl/pull/2762#issuecomment-7195134140). #2762 also logs that count under XCL_ACTIVITY.
  • Read: view_desc_key (real.rs:2366) zeroes 0x04..0x08 (the padding between Dimension and the 8-byte Alignment of D3D12_RESOURCE_DESC) and 0x34..0x38 (after Flags), and resource_at keys MADE with it (real.rs:2380). No field of D3D12_RESOURCE_DESC is in either range.

Not tested: the title's world, where the duplicates were counted (smoke.ps1 presses nothing, so these 60 s stayed on the first screens); the texture count on Windows; the pull request's test; Linux at this head; AMD.

AI use: Claude Code (Claude Opus 5.5) ran the smoke runs, read the diff and wrote this comment.

Posted without review by a person: the account owner was away and reads replies later.

<!-- greyfinch-sync:ivall/xcl:comment:7217691919 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3000#issuecomment-7217691919). Originally posted by [Royalflamejlh](https://github.com/Royalflamejlh) on 2026-11-27T11:58:36Z. --- The Windows regression run the description asks for: `scripts/smoke.ps1` on an RTX 2070 SUPER 8 GB, `main` `623d02e4` and this head `001bf96a` in turn, 2 runs each, showed no regression: 60 presents per 2 s at the end, no crash and no device removal in all four runs. Setup: Windows 11 Pro 26200, RTX 2070 SUPER 8 GB, driver 621.01, Ryzen 7 5700X3D, 16 GB RAM, rustc 1.100.0, release; `XCL_PREPARE=0` in all four runs (the shader preparation left out, as #2976 allows, so that the 60 s are the title's). | Run | Tree | Frames shown | Peak commit | |---|---|---|---| | 1 | `main` `623d02e4` | 1106 | 14794 MB | | 2 | this head `001bf96a` | 1117 | 14792 MB | | 3 | `main` `623d02e4` | 1141 | 14691 MB | | 4 | this head `001bf96a` | 1144 | 14651 MB | The blocks of runs 3 and 4, for **Regression run**: ```xcl-smoke xcl-smoke v1 commit: 623d02e465a17497a757a4ce867f482b0a6c8f3b gpu: NVIDIA GeForce RTX 2070 SUPER title: 5330474d seconds: 60 exit: 0x0 frames shown: 1141 (PresentX 1141) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14691 MB ``` ```xcl-smoke xcl-smoke v1 commit: 001bf96a074d8d3a27a1da29f4834bc71dc0c077 gpu: NVIDIA GeForce RTX 2070 SUPER title: 5330474d seconds: 60 exit: 0x0 frames shown: 1144 (PresentX 1144) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14651 MB ``` - As Alm0stSurely wrote, #2762 (`496ef578`, open since 26 November) makes the same change: its `view_key` zeroes `0x04..0x08` and `0x34..`. On #2762 we measured it under Wine on an RTX 4070, on `main` `b49be18` + #684, 3 runs of each key: 41,136 to 41,369 textures kept at 118 s, against 59,564 to 60,240 with the old key (https://github.com/xcl-dev/xcl/pull/2762#issuecomment-7195134140). #2762 also logs that count under `XCL_ACTIVITY`. - Read: `view_desc_key` (`real.rs:2366`) zeroes `0x04..0x08` (the padding between `Dimension` and the 8-byte `Alignment` of `D3D12_RESOURCE_DESC`) and `0x34..0x38` (after `Flags`), and `resource_at` keys `MADE` with it (`real.rs:2380`). No field of `D3D12_RESOURCE_DESC` is in either range. **Not tested:** the title's world, where the duplicates were counted (`smoke.ps1` presses nothing, so these 60 s stayed on the first screens); the texture count on Windows; the pull request's test; Linux at this head; AMD. **AI use:** Claude Code (Claude Opus 5.5) ran the smoke runs, read the diff and wrote this comment. Posted without review by a person: the account owner was away and reads replies later.
LocranKing commented 2026-11-27 13:59:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T13:59:51Z.


Tested PR #3000 (001bf96a) on Windows 11 (Ryzen 5 5500, 32 GB RAM, NVIDIA GeForce RTX 3060 Ti 8 GB, driver 32.0.16.2140).

Unit test

  • cargo test --locked -p xcl --lib -- view_desc_padding_does_not_change_the_key --nocapture on 001bf96a:
    • hle::d3d12x::real::view_desc_key_tests::view_desc_padding_does_not_change_the_key — ok (1 passed, 0 failed)

Smoke check (180 s, lockhart, XCL_PREPARE=0, XCL_DIRECT_DXIL=all)

Against origin/main (06f90c19) on copies of the same warmed main DXIL cache:

  • origin/main (06f90c19): exit: 0x0, 0 crashes, 0 device removals, 1236 frames (PresentX 1236), peak commit 27336 MB, local 14032 MB, non-local 1639 MB.
  • #3000 (001bf96a): exit: 0x0, 0 crashes, 0 device removals, 1242 frames (PresentX 1242), peak commit 26801 MB, local 14115 MB, non-local 1606 MB.
  • Scope caveat: Under default main texture settings (~7.7 GB target pages / ~14 GB local VRAM on an 8 GB card), both runs paused presenting during title loading after ~60 s and did not enter open-world gameplay in this 180 s window.
<!-- greyfinch-sync:ivall/xcl:comment:7220202423 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3000#issuecomment-7220202423). Originally posted by [LocranKing](https://github.com/LocranKing) on 2026-11-27T13:59:51Z. --- Tested PR #3000 (`001bf96a`) on Windows 11 (Ryzen 5 5500, 32 GB RAM, NVIDIA GeForce RTX 3060 Ti 8 GB, driver `32.0.16.2140`). ### Unit test - `cargo test --locked -p xcl --lib -- view_desc_padding_does_not_change_the_key --nocapture` on `001bf96a`: - `hle::d3d12x::real::view_desc_key_tests::view_desc_padding_does_not_change_the_key` — **ok** (`1 passed, 0 failed`) ### Smoke check (`180 s`, `lockhart`, `XCL_PREPARE=0`, `XCL_DIRECT_DXIL=all`) Against `origin/main` (`06f90c19`) on copies of the same warmed `main` DXIL cache: - **`origin/main` (`06f90c19`):** `exit: 0x0`, `0` crashes, `0` device removals, `1236` frames (`PresentX 1236`), peak commit `27336 MB`, local `14032 MB`, non-local `1639 MB`. - **`#3000` (`001bf96a`):** `exit: 0x0`, `0` crashes, `0` device removals, `1242` frames (`PresentX 1242`), peak commit `26801 MB`, local `14115 MB`, non-local `1606 MB`. - **Scope caveat:** Under default `main` texture settings (`~7.7 GB` target pages / `~14 GB` local VRAM on an 8 GB card), both runs paused presenting during title loading after ~60 s and did not enter open-world gameplay in this `180 s` window.
raylitebull commented 2026-11-28 21:13:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by raylitebull on 2026-11-28T21:13:39Z.


Closing as a duplicate of #2762 (confirmed by 2+ contributors in #1607, group D152). Thanks for the contribution — feel free to comment if this covers something #2762 does not.

<!-- greyfinch-sync:ivall/xcl:comment:7245864126 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3000#issuecomment-7245864126). Originally posted by [raylitebull](https://github.com/raylitebull) on 2026-11-28T21:13:39Z. --- Closing as a duplicate of #2762 (confirmed by 2+ contributors in #1607, group D152). Thanks for the contribution — feel free to comment if this covers something #2762 does not.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!3000
No description provided.