Skip to content

D3D12.X: R9G9B9E5 render targets and UAVs are half floats (GTA VI on the Series S profile) - #242

Open
mrp1no wants to merge 1 commit into
ivall:mainfrom
mrp1no:d3d12x-r9g9b9e5-targets
Open

mrp1no wants to merge 1 commit into
ivall:mainfrom
mrp1no:d3d12x-r9g9b9e5-targets

Conversation

@mrp1no

@mrp1no mrp1no commented Nov 23, 2026 •

Copy link
Copy Markdown

On the Series S profile (device_type = "lockhart"), GTA VI places a 1920x1080 DXGI_FORMAT_R9G9B9E5_SHAREDEXP texture that is both a render target and a UAV (flags 0x300005). A PC device accepts neither use of that format, so CreatePlacedResourceX gets E_INVALIDARG and the title stops on its own assertion (a breakpoint exception). That looks like the assertion #156 reports after a refused pipeline on that profile.

This PR handles the format the way XCL already handles the console's R10G10B10 7e3 / 6e4 floats (116 / 117) and B5G5R5A1 / B4G4R4A4 targets:

  • pc_resource_desc: an R9G9B9E5 texture with ALLOW_RENDER_TARGET or ALLOW_UNORDERED_ACCESS is made R16G16B16A16_FLOAT. Half floats hold every shared-exponent value exactly, since 9 mantissa bits and exponents down to 2^-24 fit in fp16. A texture that is only sampled stays R9G9B9E5.
  • pc_target_format: render target views, pipeline formats and clear values in format 67 become R16G16B16A16_FLOAT.
  • pc_shader_view_format: a shader view in format 67 of such a texture is R16G16B16A16_FLOAT.

The texture is a GPU-owned target, a resource of its own, so nothing the CPU lays out depends on its format. Like the B5G5R5A1 case, it costs twice the memory per texel.

Testing

  • device_x unit test: the desc, the sampled-only case, the view and target formats.
  • cargo test --release -p xcl --lib: 611 passed, 0 failed, 20 ignored.
  • GTA VI 1.0.2.1, Series S profile, RTX 3060 (driver 610.88), i7-11700K, with GTA VI reaches its title screen and menus: GPU title memory in large pages, to_zero pruned once #203:
    • Before: the assertion at ~62 s, right after XCL logs CreatePlacedResourceX … dimension 3 1920x1080 format 67 flags 0x300005 – a resource of its own (0x80070057).
    • After: past it. A 300 s timed run ended without a crash.
  • On the Series X profile the title creates its format-67 textures as sampled only, each aliasing an R32_UINT UAV. This PR leaves those as they are.

No game files attached. AI-assisted (Claude Code).

🤖 Generated with Claude Code

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

klNuno commented Nov 23, 2026 •

Copy link
Copy Markdown

Note

Clanker Claude Opus 5.5 is responding on behalf of meetsu

Test report for #242 on a second GPU: the RTX 3060 result in the description reproduces on an RTX 5080.

Tested

  • Hardware: RTX 5080, driver 616.92, Windows 11 build 26200, release build.
  • Code: main at 9ab7d76 plus the ecdfa5b diff (same git patch-id --stable, 501b6a29), without GTA VI reaches its title screen and menus: GPU title memory in large pages, to_zero pruned once #203.
  • Both builds also carry two unpublished local patches: an opt-in audio mute and an experimental write-watched reservation for a 3977 MiB texture pool.
  • The pool reservation was active in both runs; no XAudio2 engine was created in either run.
  • Profile: Series S (device_type = "Lockhart"), 3136 MB coherent window.
  • cargo test --release -p xcl --lib console_depth_buffers_and_their_views_are_the_pcs: 1 passed, 0 failed.
  • Before (no ecdfa5b): at 8.5 s the log shows CreatePlacedResourceX at ...: dimension 3 1920x1080 format 67 flags 0x300005 - a resource of its own (0x80070057), then exception 0x80000003.
  • After: no such line; a 55 s timed run (XCL_RUN_SECONDS=55) ended with exit code 0, 1062 frames shown for 1063 PresentX calls.

Not tested

AI use

  • The builds and runs were driven by an AI agent session orchestrated from Codex (GPT-6.2 Astra).
  • Claude Opus 5.5 re-checked the logs, frames, diff and patch-id, and wrote this report.

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of ecdfa5bfa on AMD (RDNA4); the PR was tested on NVIDIA only. The branch is based on 0f34407, so I merged it onto current main a6f5f7a locally (clean merge, only device_x.rs, +15 lines) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32029.2010; XCL picked it (backend 'real' – AMD Radeon RX 9060 XT (16191 MiB VRAM))
  • Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • .\scripts\test.ps1 (cargo build --workspace + cargo test --workspace -- --test-threads=4) on the merge: 676 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 636 passed, 0 failed, 21 ignored; the same counts as main on this machine (the PR extends an existing test rather than adding one); console_types_and_descs_become_pc_ones passes
  • 0 SKIPPED on this adapter

One finding on AMD: the description says a PC device accepts R9G9B9E5_SHAREDEXP neither as a render target nor as a UAV. On this RDNA4 card it accepts both. A small standalone program (not part of XCL) on the same adapter:

  • CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT) for DXGI_FORMAT_R9G9B9E5_SHAREDEXP: RENDER_TARGET, TYPED_UNORDERED_ACCESS_VIEW and UAV_TYPED_STORE all set
  • CreateCommittedResource of a 1920x1080 R9G9B9E5 texture with ALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESS: S_OK (R16G16B16A16_FLOAT: S_OK too)

So the E_INVALIDARG is driver-dependent (NVIDIA in the reports so far), not a property of D3D12 on the PC. The conversion is still correct on AMD, since half floats hold every shared-exponent value exactly; it just costs twice the memory there without being needed. Not a blocker; if you want, the conversion could depend on the device's format support for 67, and the comment in pc_resource_desc could say "some PC drivers" instead of "the PC".

Review of the change: I checked that every view of a converted texture goes through the new mappings. RTVs (dev_create_rtv) and UAVs (dev_create_uav_x) use pc_shader_view_format(resource, view), SRVs go through pc_srv → pc_shader_view_format, and pipeline RTV formats and clear values use pc_target_format. A sampled-only R9G9B9E5 texture stays R9G9B9E5, as the test checks.

Not tested: no retail title or Series S profile (I have no unpacked game), no XCL_SAMPLE_* tests, release build; the PR's own head commit on its old base was not run, only its merge onto main.

Run and report by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.

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.

3 participants