Skip to content

D3D12.X: R9G9B9E5_SHAREDEXP targets become R11G11B10_FLOAT - #651

Closed
yyc160 wants to merge 4 commits into
xcl-dev:mainfrom
yyc160:fix-r9g9b9e5-targets
Closed

yyc160 wants to merge 4 commits into
xcl-dev:mainfrom
yyc160:fix-r9g9b9e5-targets

Conversation

@yyc160

@yyc160 yyc160 commented Nov 24, 2026 •

Copy link
Copy Markdown

What is in it

pc_resource_desc maps console format 67 (R9G9B9E5_SHAREDEXP) to PC format 26 (R11G11B10_FLOAT) when the title asks for a render target or UAV, and pc_shader_view_format maps a view requested in 67 onto a resource made 26 (mirroring the existing (28, 86 | 115) => 28). Plain textures (flags 0) keep format 67.

pc_clear additionally takes (console format, PC format) so an optimized clear value the console wrote in its own format follows the retyped resource. Without it the resource is created fine and still refused, because a clear value's format must match the resource's.

One table-driven test covers the desc conversion (67 with flags 0/1/4/5, plus the existing 116/117 and 86/115 rules as no-regression cases) and the view conversion; two more cover the clear-value follow.

Why

On an RTX 5070 Ti (driver 32.0.16.1742), a 1920x1080 resource in console format 67 with console flags 0x300005 (truncated to PC 0x05) is refused by every creation path — vram::place_on_pages' reserved attempt, the arena's CreatePlacedResource, and the CreateCommittedResource fallback — with E_INVALIDARG. That call is the last log line before the title's 0x80000003 at +0xcc2834 when the run uses device_type = "lockhart".

Measured on this device with a standalone D3D12 probe (no game files):

format flags CreateCommittedResource CreateReservedResource CheckFeatureSupport
67 0x0 OK (1280x720, 2048x512, 1920x1080) OK RT=false, TYPED_UAV=false, UAV_TYPED_STORE=false
67 0x1 / 0x4 / 0x5 FAIL 0x80070057 (all) FAIL 0x80070057 (all) same
26 0x1 / 0x4 / 0x5 OK, RTV created OK RT=true, TYPED_UAV=true, UAV_TYPED_STORE=true
10 0x1 / 0x4 / 0x5 OK OK all true
28 0x5 OK OK all true

Format 26 is 32 bpp like 67 and holds values above 1.0, so the resource footprint and the title address range (computed from the original console desc in create_placed_resource_x) are unchanged. Format 28 would clamp HDR values; format 10 would double the bytes per pixel.

The clear-value half was verified the same way: a reserved resource in format 26 with flags 0x5 creates with no clear value and with a clear value in format 26, and fails with E_INVALIDARG when the clear value says format 67 or 28 — under both D3D12_RESOURCE_STATE_COMMON and D3D12_RESOURCE_STATE_UNORDERED_ACCESS.

title_textures::register is not touched: gpu_owned resources return from create_placed_resource_x at the vram::place early return (device_x.rs:888-898), before the register call at line 909, so these targets are not CPU-uploaded.

Tested

cargo build --workspace then cargo test --workspace -- --test-threads=4 on Windows 11 (build 26200), RTX 5070 Ti, DXC 1.9.2609: 645 passed, 0 failed, 21 ignored in the main crate (666 tests), all other suites green except one e2e — details under this, it fails identically on main without the patch:

  • test_title_runs_and_game_folder_is_untouched: exit code -1073740791 after 15 s, with mfplat: MFResetDXGIDeviceManagerX bridged ResetDevice failed: 0x80070057 in the log. Verified as pre-existing: stashing this PR's changes and re-running on clean main produces the same failure, same exit code, same mfplat line. This machine has no d3d12SDKLayers.dll, which may be related; I did not dig further since it is independent of this change.

Format probe: cargo test --release -p xcl --test format_probe -- --nocapture, 4 passed / 0 failed — local probe, not part of this PR.

Regression run

Both runs on the same title, -Seconds 180, lockhart config (see below), idle GPU, no uncommitted changes. main is the merge base 9ce2070; the PR's block names its head commit.

main@9ce2070 (without this PR):

xcl-smoke v1
commit: 9ce2070eccf436d7bd38601c90407da447df34f3
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3c290c16
seconds: 180
exit: 0x80000003
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 42 24 9
device removals: 0
crashes: 2
peak commit: 14300 MB

This PR @1cd4dbc (both commits):

xcl-smoke v1
commit: 1cd4dbcf78634cc0ac010bd3be9568e3c6fe1b59
gpu: NVIDIA GeForce RTX 5070 Ti
title: 3c290c16
seconds: 180
exit: 0x80000003
frames shown: none logged (the run did not reach its end)
presents per 2 s (last 3): 11 21 7
device removals: 0
crashes: 2
peak commit: 16233 MB

What this shows and what it does not. The frame-count comparison does not apply here: main crashes ~21.7 s in at +0xcc2834, which is exactly the crash this PR removes — the run's last log line is that CreatePlacedResourceX ... format 67 ... (0x80070057) refusal. With the PR, the title creates that resource (the refusal line is gone from the log) and runs to 27.1 s, then hits a new 0x80000003 at +0x131a2ad, whose last log line is a different refusal: CreatePlacedResourceX ... 1024x1024 format 118 flags 0x1800002 – (0x80070057) — console D16_UNORM_S8_UINT, already retyped to R24G8_TYPELESS, with a depth-stencil flag. That looks like the same class of problem (a console format the PC device refuses under these flags) and is worth its own investigation; I have not bundled it here since one problem per PR.

lockhart (device_type = "lockhart" in xcl.toml) is used because with the default anaconda this title never renders at all on this machine — every activity line reads 0 draws, 0 dispatches for the whole run, so neither run can support a frame-count comparison. Peak commit (14300 → 16233 MB, the title allocating further) is the stable number here.

Not tested

  • AMD / Intel GPUs; the probe numbers above are from one NVIDIA device (RDNA4 was not available here either).
  • Titles that CPU-write a 67 target (these are gpu_owned and do not reach title_textures::register).
  • Whether the title later reads the target back expecting the shared-exponent encoding.
  • The new +0x131a2ad breakpoint (see above — separate investigation).

AI use

AI-assisted (gpt-6.2-astra via a local relay): reviewed the approach across several rounds, wrote the standalone D3D12 format/clear probes and the patch. All measurements, source-tracing and the regression runs were executed locally by the contributor; the final text was written by the contributor.

@yyc160

yyc160 commented Nov 24, 2026

Copy link
Copy Markdown
Author

Update: a second fix in the same call chain, and the title now survives the full run.

The +0x131a2ad breakpoint in the regression run above was the same refusal class, one layer deeper. Commit b212ecb adds:

Evidence (RTX 5070 Ti, standalone probe + a temporary diagnostic log in create_placed_resource_x):

DEPTH probe:  committed R24G8_TYPELESS + ALLOW_DEPTH_STENCIL → OK (state 0x0/0x4/0x10, clear None/45)
              reserved (64KB_UNDEFINED_SWIZZLE) + same → FAIL 0x80070057 (all states)
              MSAA irrelevant: samples 1 and 4 behave identically
Actual failing call (probe log): console fmt 118 mips 1 samples 1
              → PC fmt 44 flags 0x2 state 0x0 clear_fmt 0x2c(=44) hr 0x80070057
CLEAR probe:  reserved format 26 flags 0x5: clear=None OK, clear=26 OK, clear=67 FAIL, clear=28 FAIL
              (identical under COMMON and UNORDERED_ACCESS initial states)

The clear value's format was mapped to the resource's typeless format itself (44), and D3D12 refuses a clear value in a typeless format — it must be the family's DSV format (45 = D24_UNORM_S8_UINT). pc_clear now also takes the retyped desc's flags and, through a small helper, makes a depth target's typeless clear value take its DSV format (19→20, 39→40, 44→45, 53→55), and drops a color typeless clear value (pass no optimized clear value) instead of guessing a typed format.

Result on the same title / lockhart / idle GPU / 120 s:

xcl-smoke v1
commit: b212ecb (the probe log line was an uncommitted change at the time; the pushed commit keeps it as a diagnostic)
gpu: NVIDIA GeForce RTX 5070 Ti
title: GTA6.Xbox.v1.0.2.1-CYBERLEEK
seconds: 120
exit: 0x0
frames shown: 630 (PresentX 630)
presents per 2 s (last 3): 10 10 11
device removals: 0
crashes: 0
peak commit: 17975 MB

Timeline on this title: 21.7 s breakpoint (+0xcc2834, format 67) → 27.1 s breakpoint (+0x131a2ad, format 118 depth) → 120 s clean exit. Both resource-creation refusals in the chain are gone.

The title is still in its front end (0 draws, 0 dispatches throughout — same as the anaconda note above), so this is not a rendering milestone; but the crash chain this PR started with is resolved end to end, and the depth probe data (R24G8_TYPELESS refused on reserved/tile while committed is fine on this device) may be useful for the tiled-resources path generally.

@eizispark

eizispark commented Nov 24, 2026 •

Copy link
Copy Markdown

Hardware check of 42ec5f71445f878b09f49f1f7c645ad248a6a029 (verified clean merge with main d5442d2): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace -- --test-threads=4: 689 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none; e2e: 3 passed, 0 failed)
  • cargo test -p xcl --lib hle::d3d12x::device_x::tests: 10 passed, 0 failed, 0 ignored (including target_resource_and_view_formats, matching_clear_follows_rewritten_resource, unchanged_resource_or_other_clear_format_uses_the_existing_mapping, a_depth_targets_typeless_clear_value_takes_its_dsv_format, a_color_typeless_clear_value_is_dropped_not_guessed)

Regression run
Default anaconda device configuration, 60 s:

main (f4ce27c):

xcl-smoke v1
commit: f4ce27ceb6d1b0576d0c659b713b674778bf1968
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1667 (PresentX 1667)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14847 MB

PR (42ec5f7):

xcl-smoke v1
commit: 42ec5f71445f878b09f49f1f7c645ad248a6a029
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14884 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); device_type = "lockhart" mode; gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.

@CryingLaughing

Copy link
Copy Markdown

Tested

  • Head b212ecbeff9d83d1755d007b54bcf69219cad2e9 with a scratch-only native probe in real.rs, and a second run adding only the 67 => 26 case to pc_target_format, as in D3D12.X: promote R9G9B9E5_SHAREDEXP render/UAV targets to R11G11B10_FLOAT #605. NVIDIA GeForce RTX 4080, driver 621.01, Intel Core i5-13600K, Windows 11 25H2 build 26200.9974, Rust 1.100.0 MSVC x64, Windows SDK DXC 1.8.2502.11, debug. XCL_ADAPTER=4080, XCL_REQUIRE_GPU=1, all XCL_SAMPLE_* variables unset.
  • Built with cargo test -p xcl --lib --locked -j 4 --no-run --message-format=json and ran hle::d3d12x::real::shared_exp_target_witness::shared_exp_target_pipeline_format_and_hdr_readback --exact --test-threads=1 --nocapture on each scratch tree. Both runs passed 1/1 with zero skips.
  • The probe requested a format-67 render target and UAV with an optimized clear in format 67, and requested an RTV in 67. XCL created the resource in format 26 and the RTV worked. On the PR head, the production graphics PSO mapper still returned 67. The native driver returned S_OK for both that PSO and the identical PSO specifying 26, so successful creation alone leaves a resource/PSO format mismatch. With the explicit format-26 PSO, the draw produced the expected 32 HDR triangle pixels and preserved 32 HDR clear pixels.
  • With the one-line target-format change, the production mapper returned 26 and its PSO returned S_OK. The probe drew using that mapped PSO and matched the same 64 packed HDR pixels. Both draws used PSOs matching the backing resource format.

pc_topology_type uses pc_target_format for each graphics RTV format. Bringing that mapper into agreement with pc_resource_desc and pc_shader_view_format closes this particular gap. Target mapping in #605

Not tested

  • Drawing with the format-mismatched PSO, native mesh PSO creation, the full workspace suite on this PR, other adapters, release builds, or retail titles.

AI use

  • OpenAI Codex (GPT-6 family, exact variant unavailable) prepared the scratch probe, ran the checks, and drafted this report.

@upipibi upipibi mentioned this pull request Nov 24, 2026
@MrEjecutor

Copy link
Copy Markdown

Test report on Windows + NVIDIA for 42ec5f7 (this PR's head), Series S profile: no crash in 180 s

Tested

Regression run

xcl-smoke v1
commit: d97851cba129b751fcafa8c905713d64026f0d7c
gpu: NVIDIA GeForce RTX 5060 Ti
title: GTAVI
seconds: 180
exit: 0x0
frames shown: 1233 (PresentX 1233)
presents per 2 s (last 3): 9 10 9
device removals: 0
crashes: 0
peak commit: 18302 MB

From the local merge above, not from this PR's head alone.

Not tested

AI use

@yous0serious

Copy link
Copy Markdown
Contributor

Test report on 42ec5f7 (this PR's head): RTX 4090, Series X profile – the 67 => 26 line in pc_target_format removes the 8 refused pipelines on NVIDIA

@eizispark's Series X run above is on AMD, which takes format 67 as a target; this is the NVIDIA side, where the pipelines @CryingLaughing found are refused.

Tested

  • NVIDIA GeForce RTX 4090 (wave32), driver 621.01; Intel Core i7-13700KF; 32 GB; Windows 11 Pro 26200; Rust 1.100.0 stable-x86_64-pc-windows-msvc; release
  • Retail title 1.0.2.1, device_type = "anaconda" (Series X), XCL_NETWORK=0, scripts/smoke.ps1 -Seconds 60, no input, on this head and on its base 9ce2070
  • report.json d3d12.failed_pipelines: base 8, this PR 0 (fallback_pipelines 0, translated_pipelines 6 in both). On the base the 8 are pipeline streams with a console VS + PS and one render target in format 67, refused with 0x8007000e / 0x80070057, and their stand-in versions too (graphics PSO rejected …, the fallback version too), about 8 s after start.

Regression run

Base (9ce2070):

xcl-smoke v1
commit: 9ce2070eccf436d7bd38601c90407da447df34f3
gpu: NVIDIA GeForce RTX 4090
title: GTA6
seconds: 60
exit: 0x0
frames shown: 1575 (PresentX 1575)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14812 MB

This PR (42ec5f7):

xcl-smoke v1
commit: 42ec5f71445f878b09f49f1f7c645ad248a6a029
gpu: NVIDIA GeForce RTX 4090
title: GTA6
seconds: 60
exit: 0x0
frames shown: 1568 (PresentX 1568)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14784 MB

Not tested

  • cargo test --workspace on this head
  • whether the 8 pipelines draw correctly; Series S profile; AMD
  • anything past the first-run screens (no input)

AI use

  • GitHub Copilot app with Claude Opus 5.5: ran the builds and runs, found the pipelines' render-target format with a temporary local log line (in no commit), wrote this report. Checked by me.

@raylitebull

Copy link
Copy Markdown
Member

Closing as a duplicate of #605, which is smaller, cleaner, and passes the PR description check (whereas this PR fails PR description).

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.

6 participants