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

Open
github-bot wants to merge 1 commit from github-bot/gh-3000 into main AGit
Owner

@⁠voiceovarian1-max on GitHub · 2026-11-27 11:14 UTC · original
voiceovarian1-max:pr/view-desc-padding → main · +33 −3 · 1 files · 1 commits · draft

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

**@⁠voiceovarian1-max** on GitHub · 2026-11-27 11:14 UTC · [original](https://github.com/xcl-dev/xcl/pull/3000) `voiceovarian1-max:pr/view-desc-padding` → `main` · +33 −3 · 1 files · 1 commits · draft `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)
`resource_at` makes one PC texture per address and desc for the title's views
by address (device #70 and the UAV form), 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 different garbage: 19,780 of 65,536 creations
in a retail title's world (a texture object cost 1-7 ms under vkd3d-proton here). The
key is now `view_desc_key`, which zeroes that padding as well as the padding
after the flags.

Test: view_desc_padding_does_not_change_the_key (fails without the change).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 11:17:42 +00:00
Author
Owner

@⁠Alm0stSurely on GitHub · 2026-11-27 11:38 UTC · original

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).

**@⁠Alm0stSurely** on GitHub · 2026-11-27 11:38 UTC · [original](https://github.com/xcl-dev/xcl/pull/3000#issuecomment-7217312915) 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`).
Author
Owner

@⁠Royalflamejlh on GitHub · 2026-11-27 11:58 UTC · original

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 (#2762). #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.

**@⁠Royalflamejlh** on GitHub · 2026-11-27 11:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/3000#issuecomment-7217691919) 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://git.gtahub.st/github/xcl-dev--xcl/pulls/2762). #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.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/3000/head:github-bot/gh-3000'
git switch 'github-bot/gh-3000'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-3000'
git switch 'github-bot/gh-3000'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-3000'
git switch 'github-bot/gh-3000'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-3000'
git switch 'main'
git merge --squash 'github-bot/gh-3000'
git switch 'main'
git merge --ff-only 'github-bot/gh-3000'
git switch 'main'
git merge 'github-bot/gh-3000'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.