GPU: substitute R9G9B9E5_SHAREDEXP render targets and UAVs with R16G16B16A16_FLOAT #492
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!492
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-492"
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?
@Yaekai on GitHub · 2026-11-24 04:04 UTC · original
Yaekai:fix/gpu-r9g9b9e5-render-target→main· +564 −17 · 5 files · 4 commits · openSummary
On Xbox Series X|S, GTA VI allocates HDR scene/lighting targets in
DXGI_FORMAT_R9G9B9E5_SHAREDEXP(format67) withALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESS(e.g.1920x1080,flags: 5andflags: 4). PC D3D12 forbidsR9G9B9E5_SHAREDEXPas a render target or unordered-access resource, causingCreateCommittedResourceto fail withE_INVALIDARG(no host texture) and leaving those passes without a host texture.Changes
crates/victory-gpu/src/resource.rs:target_format()substitutingR9G9B9E5_SHAREDEXP(67) →R16G16B16A16_FLOAT(10) for resources created withALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESSand their clear values.R9G9B9E5_SHAREDEXPtextures keep format67(pc_format).view_format()so substituted typed targets are not mistaken for typeless resources.r9g9b9e5_target_format_substitutes_rgba16fandr9g9b9e5_render_target_and_uav_textures_create_on_host).crates/victory-gpu/src/descriptor.rs:Target::desc()maps RTV formats throughtarget_format().crates/victory-gpu/src/descriptor/host.rs:fits()accepts SRV/UAV views requestingR9G9B9E5_SHAREDEXPon a substitutedR16G16B16A16_FLOAThost texture and binds the host format.crates/victory-gpu/src/pipeline/host.rs: PSORTFormatsmap throughtarget_format().Verification
cargo test -p victory-gpu --lib: 45 passed, 0 failed (including both newr9g9b9e5tests on D3D12).--console series-s):no host texturewarnings forformat: 67dropped to 0.Known Limitations (Widening Hosts Only)
R9G9B9E5_SHAREDEXPtoR16G16B16A16_FLOAT(e.g. NVIDIA), aCopyResourceorCopyTextureRegionbetween a widened texture and a non-widened format-67orR32_UINTtexture/footprint is skipped with a one-time warning rather than converted, so the destination keeps its previous contents instead of triggering an invalid D3D12 copy / device removal.R32_UINTplaced aliases: On widening hosts, a placedR32_UINTwriter /R9G9B9E5_SHAREDEXPreader pair on the same memory still gets separate host textures and does not share the writer's data; bit-converting or bridging that alias path is out of scope for this PR.@fromthemoonx on GitHub · 2026-11-24 04:20 UTC · original
Tested
b57e10d(onmaind2a4bae) on NVIDIA.Environment: Windows 11 Pro build 26300, AMD Ryzen 7 5700X, 16 GB, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1
x86_64-pc-windows-msvc, debug.Tested
cargo test --locked -p victory-gpu --lib: 45 passed, 0 failed, 1 ignored, includingr9g9b9e5_target_format_substitutes_rgba16fandr9g9b9e5_render_target_and_uav_textures_create_on_host(which runs on the hardware adapter here).cargo test --locked --workspace: 266 passed, 0 failed, 4 ignored.cargo xtask policy: 151 files ok.cargo clippy -p victory-gpu --all-targets: oneundocumented_unsafe_blockswarning inhost.rs:267;cargo fmt --checklists files this PR doesn't touch. Both are the same onmain, and the PR's one formatting hunk removesresource.rsfrom that list.The premise on this GPU: a throwaway local test (not pushed) asked the device for
CheckFeatureSupport(D3D12_FEATURE_FORMAT_SUPPORT):R9G9B9E5_SHAREDEXPR16G16B16A16_FLOATSo the substitution is needed on NVIDIA as well, and sampled-only textures can keep 67 as the PR does.
Reading the code
texture::title_writtenlimits them to textures without render-target/depth/UAV flags, and only those keep format 67, so a 4-byte detile never lands in an 8-byte host texture.copy_texture_regionandcopy_resourcehand the title's formats to the host unchanged. A copy between a substituted target (now f10, 8 bytes) and a sampled-only f67 texture, or from an f67 placed footprint into a substituted target, would have mismatched formats and texel sizes on the host, which D3D12 doesn't allow. Did the live run show copies to or from these targets (for example withVICTORY_D3D12_DEBUG=1)? If the title never does that, nothing more is needed.Not tested: no game data, so the live
no host textureresult is the description's, not mine.AI-assisted (Claude Code) ran the checks and drafted this comment.
@Mesrine67 on GitHub · 2026-11-24 04:25 UTC · original
Local AMD results for PR head b57e10d719b3a3ffb7a8fd04e63a94ea088787d7:
Environment: Windows 11 Pro build 26300, AMD Radeon RX 6750 XT, driver 32.0.21045.29003, rustc 1.100.0.
This confirms the synthetic host-resource substitution path on this AMD adapter. It does not test a title render, PSO acceptance, or title texture copies.
I also checked the copy wrappers in crates/victory-gpu/src/list.rs: copy_resource forwards the host resources to CopyResource, and copy_texture_region forwards them to CopyTextureRegion; neither path converts formats. If the title copies between a sampled-only format-67 resource and a substituted format-10 target, that copy would violate D3D12 format/size compatibility. Microsoft documents the CopyResource restrictions here: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copyresource and CopyTextureRegion format compatibility here: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/nf-d3d12-id3d12graphicscommandlist-copytextureregion.
I could not confirm whether GTA VI makes such copies without a live title diagnostic capture. If an existing run has D3D12 debug output or copy diagnostics for these format-67 targets, that would settle the remaining question.
@Raxstreams on GitHub · 2026-11-24 04:41 UTC · original
The widened render-target format works in a local Windows integration on an RTX 3080 Ti. There is also a distinct title use case worth preserving: a placed R9G9B9E5 SRV at exactly the same address and dimensions as a writable R32_UINT texture. I verified in a separate GPU test that a castable R32_UINT allocation sampled through the packed SRV decodes a unit red channel correctly. The title creates these pairs during its first scene. An independent RGBA16 allocation for the reader loses the writer's pixels in that case. The tested widening and the packed alias path coexist locally. World lighting is still under investigation.
@RussoJr on GitHub · 2026-11-24 12:31 UTC · original
I reproduced the R32_UINT writer → placed RGB9E5 reader in Raxstreams’ first-scene report. A compute shader wrote red and then green through the integer UAV. The RGB9E5 reader at the same guest address returned black both times.
The attached patch builds on #643 at
e7b2182e. When a table-bound SRV has one matching live R32_UINT producer with a GPU write, it records a bit-preserving D3D12 copy before sampling. Microsoft lists this pair under CopyResource reinterpret copies.With the patch, the shader read red, then green, and still read green from a second command list. CPU-supplied blue survived both before the first GPU write and after the producer was released. Three controls (different address, width, or tiling) stayed black. All nine reads passed on #643 and on a local integration of
main@ffe310eb+ #643 + #492. The two default-suite failures on that main snapshot with #643 were present before and after this patch.The test ran as a Windows x64 binary under Wine 10 with vkd3d-proton 2.14.1 and Mesa llvmpipe (software rendering). Direct heap indexing and recording a consumer on another list before the producer’s first submission remain untested and outside this patch. The first mission still needs an in-game check on native D3D12.
The ZIP contains the source diff and regression test. On a D3D12 machine with D3DCompiler 47, apply the diff on top of #643 and run
Implementation and testing were assisted by Codex.
VIctory-RGB9E5.zip
@fromthemoonx on GitHub · 2026-11-24 12:57 UTC · original
@RussoJr here is the native D3D12 run of your patch.
Environment: Windows 11 Pro build 26300, NVIDIA GeForce RTX 3060 12 GB (driver 610.88), Rust 1.98.1
x86_64-pc-windows-msvc, systemD3DCompiler_47, Graphics Tools installed. I readpacked-rgb9e5.patchfrom the ZIP and applied it to #643 ate7b2182(it applies cleanly).cargo test --locked -p victory-gpu --lib -- --ignored --exact draw::packed_tests::placed_rgb9e5_reads_the_latest_r32_writer --nocapture:--features diagnosticswithVICTORY_D3D12_DEBUG=1refresh_packed_readercall inreadablereplaced byfalseSo on native hardware the control reproduces the black reads of Raxstreams' report, and the patch turns them into red then green. The green also holds from the second command list, and the CPU-written blue returns once the writer is released. The three controls (other address, width, tiling) stay black either way.
cargo test -p victory-gpu --libon #643 + patch: 46 passed, 0 failed, 2 ignored.Like your run, this covers table-bound SRVs only. Direct heap indexing and a consumer recorded on another list before the producer's first submission aren't covered. No game data used.
AI-assisted (Claude Code).
@erLCoder on GitHub · 2026-11-24 13:07 UTC · original
Independent HDR resource check on GTX 1660 Ti (6 GB), NVIDIA 581.42, Windows 10 22H2 19045.6466, Ryzen 5 3600, Rust 1.98.1 MSVC and Agility SDK 1.620.2. Base
d2a4bae; PR b57e10d. Added a test-only adapter check requiring NVIDIA LUID 00000000:00017c52.cargo test --offline --locked -p victory-gpu --features diagnostics --lib r9g9b9e5 -- --nocapture --test-threads=1: 2 passed, 0 failed, 0 ignored, 46 filtered out. At 64x64 the host resource was format 10 for flags 4 and 5, and format 67 for flags 0. Separately, a native D3D12 probe at 1920x1080 returned E_INVALIDARG for unmodified format 67 with flags 4 and 5, and succeeded with flags 0. The two checks use different sizes and paths. HDR pixel values, in-game lighting and final composition remain untested.Codex prepared the worktree, ran the tests and drafted this report.
@fuzeofficlal on GitHub · 2026-11-24 14:10 UTC · original
I tested the format-67 → RGBA16F render-target path on
b57e10dwith a 1×1 synthetic texture. I cleared the widened target to[0.5, 0.75, 0.125, 0.25]and fetched the texel through a guest format-67 SRV. A sampled-only native RGB9E5 texture with the same packed RGB values supplied the reference.0.25on the widened target. Native RGB9E5 read1.0.[A, B, ZERO, G]mapping moved0.25into red on the widened target. Native RGB9E5 produced[1, 0.125, 0, 0.75].Follow-up commit maps every selector for missing source alpha to constant one when the underlying texture is widened. An implicit SRV gets an explicit full-texture view so it uses the same mapping. This follows the RGB9E5 decode rule.
The mismatch reproduced on both RTX 5090 and WARP. The follow-up passed six readbacks on each backend, including an ordinary RGBA16F control with alpha
0.25. Thevictory-gpulibrary suite passed 49 tests by default and 51 with diagnostics, with one benchmark ignored in each run. This verifies SRV component behavior on the substitution path. The link to the black world frame in #904 is unverified.@EgoraWyn on GitHub · 2026-11-24 14:26 UTC · original
Test report: NVIDIA RTX 3060 Laptop 6 GB (Ampere),
--console series-s: the refused format-67 targets are made with this PR.Setup: Windows 11 build 26300, driver 596.21 (32.0.15.9621), title 1.0.2.1 (own copy), Rust 1.98.1, diag build. Base:
8e79c80+ #493 (c48b240) + #206 (05981dd) + #189 (d0fd9bf) + #454 (d2c93fa) +MIN_DYNAMIC = 1 << 18(#747). This PR atb57e10d, clean merge.no host texture … (0x80070057)lines per run:series-s, baseseries-s, base + this PR + #211series-x, baseSo on this card the format-67 refusals only occur in Series S mode, and this PR removes both.
What it does not do alone: with only this PR on the base, the Series S menus stay black (70 s, no input, 30 fps); the picture needs #211 (two present planes). With both merged the menus are correct and the world is reached in Series S mode for 4.5 minutes with no device removal; numbers in my report on #211.
Not tested: this PR in Series X mode, where no format-67 target was refused here anyway; other GPUs. One run per row.
AI use: Claude Code (Claude Fable 5.2) built the trees, ran the runs and wrote this report from the logs; a second tool (Codex) checked the numbers against the logs. The hardware, the title copy and the runs are the user's.
@fuzeofficlal on GitHub · 2026-11-24 14:39 UTC · original
Following the flags-4 report, I ran a separate typed UAV write → SRV load test on
b57e10dand the alpha follow-up. I created a 2×2 texture with guest format 67 andALLOW_UNORDERED_ACCESS, then requested format 67 for both views. A synthetic compute shader wrote four distinct RGBA colors through the UAV. After the transition to shader-read state, a second shader loaded all four texels through the SRV.RTX 5090, AMD Radeon Graphics and WARP all produced the expected RGB values on both revisions. The backing texture was RGBA16F on each device. The author's head returned the stored alpha
0.25; the follow-up returned RGB9E5's default alpha1.0. The separate native RGBA16F control returned0.25on both revisions.This covers the explicit typed UAV and default-mapped SRV on the widened flags-4 resource. The test uses
Texture2D.Loadwith synthetic colors.@jamesn-xt on GitHub · 2026-11-24 16:39 UTC · original · edited 2026-11-24 16:48 UTC
Independent integrated test on Windows 11 x64 build 26200, Ryzen 5 5600, 32 GiB RAM, RTX 4080 / NVIDIA 617.42, Rust 1.98.1.
Tested stack: main
ffe310e+ #1146 + #211 (2fb7a8b) + #89 (081afbd) + this PR (c7bb83f), then #985 and #206. Reproducible source with original PR ancestry and local conflict resolutions: https://github.com/jamesn-xt/VIctory/tree/test/rtx4080-target-formats (abe05a3). This is an integration test, not an isolated attribution of every visual change to one PR.no host texturewarnings within the bounded run. Correction: there were 23 host-pipeline refusal lines; my initial search matched onlyno host pipelineand missedhost pipeline refused.Integration notes: #89's packed conversion/copy guards were combined with main's title-written texture upload handling. The ordinary host upload path retains
defer_fillfor the mapped staging destination. The target-format mapping combines packed16 substitutions with RGB9E5→RGBA16F, and preserves this PR's latest RGB9E5 SRV alpha/component handling. No source from the title was used in those conflict resolutions.No retail files, captures or raw game logs attached.
Follow-up with 12 GiB additional active paging-file headroom: the same integrated runtime got past the earlier memory guard and attempted hundreds of draws per frame, roughly 1 fps. The first captured 3D-stage frame was black. The process then exited with
DXGI_ERROR_DEVICE_REMOVED(0x887A0005), reported removal reasonDXGI_ERROR_DEVICE_HUNG(0x887A0006), after a submission of 32 lists. Visible gameplay is not confirmed. That later run logged 104 host-pipeline refusal lines and 300 shader-translation refusal lines; the format fixes do not resolve those broader world-rendering problems. These counts are log lines, not a claim about all distinct shaders in the package.@465d6a0eac on GitHub · 2026-11-24 17:02 UTC · original · edited 2026-11-24 17:20 UTC
Thank you for this, @Yaekai! Many pull requests here are still waiting to be merged, so I've ported this one to 465d6a0eac/AgentRecompVI, a VIctory fork where AI agents review and merge each other's work: https://github.com/465d6a0eac/AgentRecompVI/pull/34. You're credited as the author there. This pull request stays the original.
Test results
cargo clippy(both variants) andcargo test --workspacepass (407 passed, 0 failed).r9g9b9e5_render_target_and_uav_textures_create_on_hostpasses on the RTX 3070 Ti, so these targets now exist on an NVIDIA host.RTX 4060) D3D12 compatibility, 2s TDR submissions, and 16 GB host OOM #1076@rafaconvaitis on GitHub · 2026-11-24 19:50 UTC · original · edited 2026-11-24 20:28 UTC
I independently checked the earlier bit-preserving alias-copy route on native Windows D3D12, with three mip levels and two array layers. A synthetic compute dispatch wrote different packed lighting words through
R32_UINTUAVs. I used oneCopyResourceto copy to an otherwise matchingR9G9B9E5_SHAREDEXPtexture, then read back the packed bits and sampled the destination through aTexture2DArraySRV at each mip and layer.The RTX 4070 and WARP both matched all 42 packed words (4×4, 2×2, and 1×1 on each layer) and all 42 expected RGBA tuples, with alpha 1. This corroborates the multi-subresource copy itself on native D3D12 for the alias case discussed in this thread. The fixture did not include VIctory's guest-address lookup, producer ordering, or resource lifetime. Those remain the integration questions before attributing any scene lighting change to it.
In two separate title runs on this RTX 4070, the
fxceless/victory-gta6578d459alias path logged five multi-subresource matches for host format 42 written and format 67 read per run. The distinct shapes were 2048×456 with four subresources and 128×128 and 64×64 with six each. The runs used that fork's existing staging-copy implementation. This establishes that multi-subresource alias traffic occurs during the title and leaves its contribution to lighting open.AI-assisted testing. No title files or images attached.
@Marvisak on GitHub · 2026-11-25 00:21 UTC · original · edited 2026-11-25 15:58 UTC
Automated triage for the maintainers.
This pull request no longer merges cleanly into
main(conflicts incrates/victory-gpu/src/list.rs,crates/victory-gpu/src/resource.rs). It will be reviewed once it is rebased onto the currentmain. The earlier verdict (merge-candidate) was for an older state ofmain.Generated by Claude Code
e456e1e884tob4d0e4409b@LAKSHYA-cmd-tech on GitHub · 2026-11-24 04:49 UTC · original · approved these changes
Verified on Windows 11 D3D12:
9g9b9e5_target_format_substitutes_rgba16f\ and
9g9b9e5_render_target_and_uav_textures_create_on_host\ tests against the host D3D12 device.
@mercuryVM on GitHub · 2026-11-24 12:28 UTC · original · reviewed
Tested b57e10d on Windows 11, RTX 5070, MSVC:
cargo test -p victory-gpu -- --test-threads=145 passed, includingr9g9b9e5_render_target_and_uav_textures_create_on_host, which does create the host texture here for flags 4 and 5. Clippy's 1 warning is the existing one in host.rs.Substituting a render-target-capable format is reasonable, and the view-format fix-up in
fitsis consistent. One concern before approving: the substitute has a different texel size, and the copy paths between title memory and the host texture size themselves from different descriptions.texture.rs(the upload staging path):GetCopyableFootprints(&d, …)is computed from the host description,R16G16B16A16_FLOATat 8 bytes per texel. The title'slayout(victory_formats::texture::Layout) describesR9G9B9E5at 4 bytes per texel. Any contents the title writes from the CPU, or that are uploaded on first use, are then detiled into rows twice as wide as their data, and RGBA16F reads them as half-floats, not shared-exponent colour. The same mismatch applies to whatever copies the target back into title memory (copy-back or readback), where the host row is twice the title's.once!log, rather than silently converting bytes. If they can be CPU-touched, the copy needs an R9G9B9E5 ↔ RGBA16F conversion, which a compute pass or a CPU loop could do.AI-assisted (Claude Code).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.