Skip to content

[upstream #1787] D3D12.X: a resolve marks its destination and names the PC's format - #347

Open
ufoptg wants to merge 7 commits into
mainfrom
upstream-pr/1787
Open

ufoptg wants to merge 7 commits into
mainfrom
upstream-pr/1787

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner

Addresses XCL-BT-031 from xcl-dev#1488.

resolve_subresource_x and resolve_subresource_region_x forwarded the console's format code to the PC's ResolveSubresource as it was, and neither marked the destination with title_textures::note_gpu_write, which CopyResource and the copy hooks already do. Two consequences:

  • the console's 116–120 are its depth family's codes and the PC reads them as video formats (116 = P208, …), so a resolve into such a view's target was refused or resolved as the wrong format;
  • a texture XCL keeps in step that the GPU resolved into was uploaded over by the next CPU write scan (the entry stayed "not GPU-written"), losing the resolved image.

This translates the format with device_x::pc_target_format (the resolve format is the target's view format, like an RTV's) and marks the destination GPU-written, as the copies do.

What is in it

  • crates/xcl/src/hle/d3d12x/list_x.rs: resolve_format() (pc_target_format) and title_textures::note_gpu_write(dst) in both resolve hooks; test resolve_subresource_marks_the_destination_and_translates_the_format drives both hooks through a fake list vtable.
  • crates/xcl/src/hle/d3d12x/title_textures.rs: a #[cfg(test)] NOTE_GPU_WRITE_CALLS counter (no production change) so the hook's marking is observable.

Evidence it fails without the fix (each half independently):

  • without the format translation: assertion 'left == right' failed: the console's D16S8 family is the PC's D24S8 on a resolve left: [116, 116] right: [10, 10]
  • without note_gpu_write: assertion 'left == right' failed: both resolves mark the destination GPU-written left: 0 right: 2

Tested

  • hardware (GPU + driver, CPU), Windows build, Rust version, debug / release: NVIDIA GeForce RTX 5080 (driver 32.0.16.1088), AMD Ryzen 9 9950X3D, Windows 11 10.0.26300, Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.9.2609.5, debug (scripts/test.ps1) and release (scripts/smoke.ps1)
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4): 893 passed, 0 failed, 42 ignored (SKIPPED: 2 no wave64; 1 no heap windows; 1 cannot disable the driver cache (Windows Developer Mode is required))
  • cargo test -p xcl --lib list_x: 29 passed, 0 failed

Regression run

main (e9e94ce, clean tree, no local changes):

xcl-smoke v1
commit: e9e94ce665d16bb0e2d2e4cb6b37e149f0d27721
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1646 (PresentX 1646)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14489 MB

PR (f47659a, clean tree, no local changes):

xcl-smoke v1
commit: f47659a701eb0b0ea23db9c08f6026e005064f4a
gpu: NVIDIA GeForce RTX 5080
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1645 (PresentX 1645)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14482 MB

Not tested

  • a title that resolves into a texture XCL keeps in step and then writes its CPU view (the unit test drives the hooks; no game here did both in the smoke run)
  • AMD GPUs and native wave64 hardware
  • other titles (Minecraft Preview, Unicorn Overlord, Fortnite, XDefiant) and Linux / Wine

AI use

  • OpenCode, Gemini 4 Neon: checked XCL-BT-031 against the resolve and copy hooks, wrote the fix and test (and confirmed each half fails without it), rebased onto e9e94ce, ran the test suite and scripts/smoke.ps1 regression runs with Scripts: smoke blocks print the game folder's name xcl-dev/xcl#677's title hashing, and drafted this PR description.

Mirror of xcl-dev#1787 (auto-synced, do not edit).

grahamster2 and others added 7 commits November 23, 2026 22:30
The `title:` line of an xcl-smoke block printed the game folder's name,
and folder names are whatever people called their copy, so PR
descriptions ended up naming specific copies of a commercial game
(xcl-dev#677). It now prints the first 8 hex digits of the SHA-256 of the
folder name (trimmed, UTF-8). pr_check.py only compares the main and PR
blocks' titles for equality, so the check is unchanged, and two
different folders still get different titles. Existing blocks can be
converted with the same function (Python:
hashlib.sha256(name.strip().encode()).hexdigest()[:8]).

-Title <label> prints a label of your choice instead. Control, format
and line/paragraph separator characters and backticks are refused:
pr_check.py splits lines with str.splitlines(), so a U+2028 in a label
would otherwise add keys such as `commit:` to the block.

scripts/smoke-title.tests.ps1 checks hashes of ASCII, accented, CJK and
emoji names against Python's, a trailing backslash, -Title, and the
refused labels, with a stand-in for xcl.exe.

Fixes xcl-dev#677
…v#1307)

The structured form wraps the items that follow a forward jump in a guard
that lists every pending skip flag, and reopens it whenever the set
changes. With many flags pending at once that grows with the square of
the flags. Since b8b1f49 one compute program of the retail pack reaches
it: 148 MB of HLSL from 334 KB of code (3 861 flags, guards of up to 597
terms, 99 MB in guard lines), against 14 MB as pc blocks. DXC on that
fits the host's commit growing about 1 GB/s until it runs out, seen with
b8b1f49 and not without it.

Structured code longer than 128 bytes per byte of program is now
translated as pc blocks. Over the whole pack (CPU-side translation of
every program, macOS), only that program changes, to 13.8 MB. The next
largest structured program is at 61 bytes per byte. Every other program
comes out as it does on main, so b8b1f49's gain stays (1 670 -> 170
programs as pc blocks).

oversized_structured_code_falls_back_to_pc_blocks: 200 conditional
forward jumps whose targets all follow them, in order, cross the bound;
50 do not.

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

dxil: eliminate giant-shader IR and CFG blowup in FormatLoad and multi-window memory
Scripts: smoke blocks name the game folder by a hash, not its name
ResolveSubresource / ResolveSubresourceRegion forwarded the console's
format code as it was - its 116-120 are the console depth family's, and
the PC reads those codes as video formats - so a resolve into such a
view's target was refused (or resolved the wrong depth format). Neither
marked the destination with title_textures::note_gpu_write, which
CopyResource and the copies already do: a kept-in-step texture the GPU
had resolved into was uploaded over by the next CPU write scan, losing
the resolved image.

Translate the format with device_x::pc_target_format (the target's view
format) and mark the destination as written by the GPU.

Assisted-by: OpenCode (Gemini 4 Neon)
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.

5 participants