Skip to content

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

Draft
voiceovarian1-max wants to merge 1 commit into
xcl-dev:mainfrom
voiceovarian1-max:pr/view-desc-padding
Draft

voiceovarian1-max wants to merge 1 commit into
xcl-dev:mainfrom
voiceovarian1-max:pr/view-desc-padding

Conversation

@voiceovarian1-max

Copy link
Copy Markdown

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

…texture

`resource_at` makes one PC texture per address and desc for the title's views
by address (device xcl-dev#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 <noreply@anthropic.com>
@Alm0stSurely

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Contributor

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

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

Copy link
Copy Markdown

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.

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.

4 participants