d3d12_xs: R9G9B9E5 UAV textures stored as RGBA16F on hosts without typed UAV (FidelityFX on NVIDIA/Intel) #55
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
library
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/omonkeyz--xbox-emulator!55
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/55/head"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@QuentinDanblon on GitHub · 2026-11-21 21:38 UTC · original
QuentinDanblon:fix/rgb9e5-typed-uav→main· +1044 −25 · 6 files · 104 commits · closed without mergingLibrary / area: d3d12_xs (resource creation, views, copies, title-memory mirror)
Exports changed (exports.txt rows): none
Source of the behaviour: D3D12 format support queries on the host. The observation that GTA VI's
amd_fidelityfx_upscaler_xbox.dllcreates a 1920x1080 R9G9B9E5_SHAREDEXP texture with ALLOW_UNORDERED_ACCESS comes from americas-recomp (GPL-2.0, observation only, no code taken).Problem
Console RDNA2 supports typed UAVs on R9G9B9E5. NVIDIA and Intel don't (
D3D12_FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEWis missing; RTX 5090 Support1 = 0x8013f0). Creating such a texture with the UAV flag returns E_INVALIDARG, so the FidelityFX upscaler failsffxCreateContext. WARP supports the format, which is why tests on WARP don't see this.Change (new
uav_subst.rs)D3D12XboxCreateDeviceon the real device.Not covered (documented in the module)
Tests (on
0fc7295)cargo test -p d3d12_xs: lib 420 pass, 1 fail, integration tests pass. The failure iscentroid_bind … fxc, which also fails on main without this commit.Hardware
hw_ -- --ignored --test-threads=1: 37/37 pass on the RTX 5090 and 37/37 on WARP.The new
hw_rgb9e5_typed_uav_texture_is_substitutedreproduces the host E_INVALIDARG, then:The test skips on WARP because WARP supports the format natively.
Not run in a title.
cargo test -p d3d12_xspasses (except the fxc test that also fails on main)No game or console files and no binaries included
No fake success; anything not possible is left
missingwith a noteGTA VI's amd_fidelityfx_upscaler_xbox.dll creates a 1920x1080 R9G9B9E5_SHAREDEXP texture with ALLOW_UNORDERED_ACCESS (device slot 76). RDNA2 consoles accept it. NVIDIA rejects it with E_INVALIDARG because the format lacks FORMAT_SUPPORT1_TYPED_UNORDERED_ACCESS_VIEW, and ffxCreateContext throws. Credit: the failure was observed and documented by americas-recomp (realdody, GPL-2.0). Only the behavioural fact is used here; the code is an independent implementation. Measured on this machine with CheckFeatureSupport(FORMAT_SUPPORT): - RTX 5090 and UHD 770: R9G9B9E5 Support1=0x8013f0, so CreateCommittedResource with ALLOW_UAV returns 0x80070057. - WARP: Support1=0x2ecd3f1, and it accepts the texture. - 85/86/115/191 (B5G6R5, B5G5R5A1, B4G4R4A4, A4B4G4R4) are the only other formats that WARP binds as typed UAVs and NVIDIA/Intel do not. They are left alone: there is no console evidence for them and no exact wider container. R16G16B16A16_FLOAT is an exact container for RGB9E5. Every channel value m*2^(e-24) (m<512, e<=31, max 65408) is an f16; a unit test checks all 16384. uav_subst.rs: - Decision gated on the host's real Support1. Unknown support never substitutes. - Substitution applied in CreateCommittedResource (27, also reached by 76/83), CreatePlacedResource (29) and CreatePlacedResourceX (44, which then gets its own committed resource because the wider texture must not alias the title's neighbouring VA placements). - CPU-visible heaps are refused so that Map/Read/WriteToSubresource never see 8-byte texels. - Per-resource registry, validated against GetDesc. - SRV/UAV/RTV descriptors whose format is R9G9B9E5 are rewritten through a hook on the real device's method table (18/19/20), installed with the first substitution. That one point covers wrapper slots, placed-view slots, title_heap and titles that hold the real device. SRV swizzles that read source alpha are forced to 1, as an RGB9E5 read returns. - GetResourceAllocationInfo sizes substituted descs at 8 bytes per texel. - Title-memory mirroring (upload.rs) widens console RGB9E5 texels to RGBA16F while de-tiling. - On the Xbox command list, copies between a substituted texture and an R9G9B9E5 footprint or an unsubstituted texture are refused and logged; they are never forwarded as corrupt data. Substitute-to-substitute copies pass. Not mapped: - Shader UAV stores keep f16 values: more precise, within one RGB9E5 quantum, with no clamp of negatives/NaN/>65408. - Typed UAV loads return the stored alpha. - Reserved resources are not substituted. Tests: - Unit tests for the decision table, desc/view rewrite, swizzle, copy rules, conversions and the widening de-tile. - hw_rgb9e5_typed_uav_texture_is_substituted goes through slot 76, writes with a UAV compute shader and reads back through an SRV. - On the RTX 5090: 512 texels are exact, 512 more are within one quantum, and the refusal of the console-footprint copy is checked. - The test skips on WARP, which supports the format natively. - With the debug layer it reports only the intended host rejection. Co-Authored-By: Claude Fable 5.2 <[email protected]>@QuentinDanblon on GitHub · 2026-11-22 11:36 UTC · original
Rebased onto
51f5319. One conflict inupload.rs(check): main'sstage_timemeasurement is kept, with the host element size of the substituted format. Main's newone_megabyte_detiles_on_one_thread_in_a_few_mstest passesNonefor the extradetile_spanargument.Tests on this base:
cargo test -p d3d12_xs --release --lib hw_ -- --ignored --test-threads=1: 39 of 39 on the RTX 5090, 39 of 39 withTOMBOX_HW_ADAPTER=warp.--lib uav_subst: 10 pass.--lib: 460 pass, 3 fail. Main alone: 450 pass, 2 fail (device_console_fix::tests::console_heap_properties_create_on_pc_through_every_wrapped_pathandxs_exports::console_fixed_tests::fixed_result_dxgix_exports_match_every_console_d3d12_xs, both also failing here).The third failure is
slot_audit_tests::done_slots_have_real_handlers, and it does not come from a slot change (this PR does not touch the device vtable). The audit names each handler withSymFromAddr, and the release linker folds functions with identical code.device_wrap::dev_stubandconsole_slots_dev2::scarlett_notimplboth only returnE_NOTIMPL, so they share one address and the name that comes back depends on link order. With this branch the fold resolves todev_stubfor Device 31-35, 69, 83, 85, 88 and 89, which the test counts as placeholders. Main's own audit output (TOMBOX_SLOT_AUDIT_OUT) already shows folded names: Device 7 is reported astitle_heap::tests::f_releaseand Device 6 ascl_console_fix::set_name_x. Any change that moves the link order can trip it. A body fordev_stubthat no real handler shares would make the audit independent of folding.@omonkeyz on GitHub · 2026-11-22 13:12 UTC · original
Main's history was rewritten, which auto-closed this PR (sorry for the noise). Please restate this without naming a title or the GPL-2.0 project as the source (keep those facts in the PR text), strip the comment lines, and rebase on the current device_wrap.rs. It needs maintainer hardware testing after that. To resubmit:
git fetchthis repo, branch from the currentmain, cherry-pick only your own commits (the old branch is based on the previous history and cannot be merged), and open a new PR.Pull request closed