FidelityFX: write an RGB9E5 output NVIDIA cannot store to through an FP16 texture (fixes a device removal) #1868
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!1868
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1868"
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?
@marquezinii on GitHub · 2026-11-24 23:51 UTC · original
marquezinii:gpu/fsr-rgb9e5-output→main· +679 −57 · 7 files · 2 commits · openmain's host FidelityFX path (0b35b7f) removes the device on NVIDIA when the title's output is RGB9E5. This fixes it.What's wrong
Grand Theft Auto VI upscales into an RGB9E5 texture (#1793's log: host formats
[10, 19, 34, 67]), made with render-target and unordered-access uses. NVIDIA creates that texture, so its host copy takesUNORDERED_ACCESSandffxDispatchhands it to the upscaler. But NVIDIA cannot store to RGB9E5 through a typed unordered access view. When the upscaler writes it, the device is removed:0x887A0005in the test below, on an RTX 5070.AMD's RX 9070 XT and WARP store RGB9E5 (#1793), so this only shows on NVIDIA.
What the fix does
victory_gpu::rgb9e5::stores(texture): whether the host stores to the texture's format through a typed UAV. It asks format support for bothTYPED_UNORDERED_ACCESS_VIEW(support 1) andUAV_TYPED_STORE(support 2), once per format. The state alone is not enough, as above.Where it does not,
ffxDispatchmoves the output toCOPY_DEST, and the upscaler writes an FP16 texture of ours instead (victory_gpu::rgb9e5::Bridge, one per output size, kept). After the upscaler:The bridge's resources end in the states they started in. The title's texture is left in
COPY_DEST, where the list was told it is.The packer is a 5.1 shader with its root signature inside, compiled by the system's compiler, as
indirect.rsdoes. It needs no descriptor heap: root constants, a root SRV and a root UAV.Hosts that store RGB9E5 write it directly, as before.
Some hosts refuse to make the title's texture at all. An RTX 3070 refuses an RGB9E5 texture with either use (reported in the comments). An RTX 5070 refuses it, and a B4G4R4A4 one, when a clear value comes with the render target use, and the title passes one. When
make_texturefails, it now retries without the render target and unordered access uses thatD3D12_FEATURE_FORMAT_SUPPORTdoesn't list for the format, and without the clear value. The texture then exists inCOPY_DEST, and the bridge writes it. Render target views are not made on such a texture, because one would remove the device:set_targetsleaves it unbound and a clear skips it.Tested
Windows 11 26300, RTX 5070 (driver 621.40), FidelityFX SDK 2.4.0
signedbin(provider 3.1.6):tests/fidelityfx.rsnow also upscales into an RGB9E5 output made with the title's uses (render target and unordered access). It checks every pixel of both outputs within 0.05 after two upscalings each, with the debug layer on and no errors from it, and logs which way the RGB9E5 output went. Here:RGB9E5 output written through an FP16 texture. It passes.With the output's way decided by its state only, which is what
maindoes, the same test removed the device while copying back.cargo test -p victory-gpu(76 passed, plus the two NVIDIA heap-cap failuresmainhas, #1744) andcargo test -p victory-hlepass.Clippy with
-D warnings, with and withoutdiagnostics,cargo docandcargo xtask policypass.textures_are_made_without_uses_their_format_does_not_support: B4G4R4A4, RGB9E5, B5G5R5A1 and R8G8B8A8 textures asked for with both uses and a clear value are made, and keep the uses their format supports. Without the retry it fails on the RTX 5070 (no host texture of format 115).In the title (RTX 5070,
mainat940d32fplus #1775 and #1751, without whichmainremoves the device at boot on NVIDIA (#1753); Series S, since only that profile takes the FidelityFX path):a host texture without the uses its format does not support ... format=67 asked=5 made=0. Without it the upscaling never runs. In a run of #1704 before it was stacked here:FidelityFX: a resource has no host texture in its state; the upscaling did not run state=2.FidelityFX: upscaler context on the host provider="3.1.6" render=[1280, 720] output=[1920, 1080], thenthe output is written through an FP16 textureandfirst upscaling, host formats of its textures formats=[10, 19, 34, 10].VICTORY_SKIP_PIPELINES=f607780aa8e502d0, the world ran about 4½ minutes past the first upscaling, and no device removal came from it. Without that skip, the GPU hangs within a minute on an indirect dispatch of that compute pipeline, with or without FidelityFX (DRED names it), which is unrelated to this PR. The world's frames are still dark on this machine, so the picture couldn't be judged.Not tested: AMD, where the direct path is unchanged; Ampere (the retry is meant for it, from the comments' report).
#1704 (DLSS on the same module) is now stacked on this PR and uses this module, so there's one copy of the bridge.
@upipibi on GitHub · 2026-11-25 00:08 UTC · original
Checked on an RTX 3070 (Ampere, driver 616.56, Windows 11) at
3d579a7. I don't have the FidelityFX SDK, sotests/fidelityfx.rsskips here. Instead I drove the bridge directly with a local test (not pushed).The packer is exact. I uploaded a 256×256 FP16 texture: R takes every one of the 65 536 half patterns, including NaN, ±Inf, negatives and denormals, and G and B take other patterns. That went through
Bridge::writeinto an RGB9E5 texture, then copied back. All 65 536 pixels matchfloat3_to_rgb9e5from EXT_texture_shared_exponent computed exactly on the CPU, so the fix-up at 512 and the clamp to 65408 both hold.On Ampere the title's texture is never made, so the bridge is never reached. This driver reports RGB9E5 as
Support1 0x8013f0(sample, load, gather, mip; no render target, no typed UAV) andSupport2 0x200(tiled only).CreateCommittedResourceof an RGB9E5 2D texture fails withE_INVALIDARGwhen it hasALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESS(the title's uses). It also fails with either flag alone. Soresource::make_texturelogsno host texture,external::host_texturereturnsNone, andffxDispatchtakes theunwritablebranch. There,in_state(COPY_DEST)isNoneas well, so the output is left unwritten. The device isn't removed, but no picture comes out either.Your RTX 5070 on 621.40 does create the texture, so this looks like a difference between drivers or generations. One way to cover both: when
make_texturefails, retry once withoutALLOW_RENDER_TARGET/ALLOW_UNORDERED_ACCESS, dropping only the onesD3D12_FEATURE_FORMAT_SUPPORTdoesn't list for the format. The texture then exists inCOPY_DEST,stores()returnsfalse, and this PR's bridge writes it.Batch on the same machine:
victory-shader(206 passed, with the three #1744 failuresmainhas) andvictory-gpu(76 passed, with the two NVIDIA heap-cap failures) are the same asmain.AI-assisted (Claude Code). Synthetic tests only.
@marquezinii on GitHub · 2026-11-25 04:46 UTC · original
@upipibi thanks for the exhaustive packer check and the Ampere report. I took your suggestion in
7db1c07(rebased on940d32f):make_texturefails, it retries without the render target and unordered access uses thatD3D12_FEATURE_FORMAT_SUPPORTdoesn't list for the format, and without the clear value. The texture then exists,stores()is false, and the bridge writes it fromCOPY_DEST.set_targetsleaves it unbound and a clear skips it. One would remove the device, like the B5G5R5A1 UAV in #1753.It turned out to matter on the RTX 5070 as well. This card makes RGB9E5 or B4G4R4A4 render targets without a clear value, but refuses them with one, and the title passes one. In the title (Series S profile) the log now shows
... format=67 asked=5 made=0, then the FSR 3.1.6 context,the output is written through an FP16 texture, and the upscaling running. Without the retry it never ran. Details are in the description. I couldn't check Ampere myself, so a run oftextures_are_made_without_uses_their_format_does_not_supporton your 3070 would be welcome.On the overlap question in the review above: #1704 (DLSS) is now stacked on this PR and uses its
victory_gpu::rgb9e5, so only one copy of the bridge remains. #1793 (Series X switching to the host upscaler) is about which upscaler the title picks, not how its output is written. It patches the title's picker inapps/victory/src/title_patch.rs, doesn't touchfidelityfx.rs, and merges cleanly with this PR.@upipibi on GitHub · 2026-11-25 05:20 UTC · original
Ran the test you asked for on the RTX 3070 (Ampere, driver 616.56), Windows 11, debug build, at
7db1c07:textures_are_made_without_uses_their_format_does_not_supportpasses. The wholevictory-gpusuite gives 142 passed, 2 failed, 2 ignored; the 2 are #1744's heap-cap failures onmain. Same asmainon this hardware.AI-assisted (Claude Code).
@Marvisak on GitHub · 2026-11-25 07:18 UTC · original
Automated triage for the maintainers.
This is a useful fix with hardware evidence (RTX 5070, with the debug layer on).
victory_gpu::rgb9e5::storesasks the host for both typed-UAV support andUAV_TYPED_STORE.Bridgehas the upscaler write an FP16 texture of ours, which is then packed into RGB9E5 by a compute pass (the packing matches D3D's shared-exponent rule: bias 15, max 65408, rounding carried into the exponent) and copied into the title's texture.make_textureretries without render-target/UAV uses the format lacks, andset_targets/clear_rtvskip such textures.One correctness problem in
ffxDispatch(crates/victory-hle/src/modules/fidelityfx.rs):unwritableis true whenever the output has no host texture in the wanted state (is_none_or) or any format the host cannot store to. In both cases the output is sent through the bridge, which always packs RGB9E5 andCopyTextureRegions that into the title's texture. If the output is any other format (for example an RGBA8 output that failedin_statefor an unrelated reason), this records a copy whose formats do not match, instead of the current "did not run" warning. Please take the bridge path only when the output's host texture format isDXGI_FORMAT_R9G9B9E5_SHAREDEXP, and keep the existing warning otherwise.Minor:
renders()callsGetDescfor every bound target on everyset_targets. Fine for now, but it is a per-draw call.CI: passing.
Generated by Claude Code
@pickles976 on GitHub · 2026-11-25 19:37 UTC · original · edited 2026-11-25 19:47 UTC
Additional Linux/Wine NVIDIA capability evidence relevant to the allocation retry in this PR. This is not a full PR/fallback verification.
Host: RTX 4060 Laptop 8 GB, NVIDIA 590.48.01, Linux 6.17.0-40; vkd3d-proton 3.2.0 (
2576c0b4adfae4a), DXVKv3.1.1-209-g1039f682058fa71, Rust 1.98.1 Windows MSVC target. A temporary headless Rust integration probe used the Windows D3D12 API directly; no game, FidelityFX SDK, shaders, command queue submissions, or asset copies.For
DXGI_FORMAT_R9G9B9E5_SHAREDEXP(67):Allocation parameters: DEFAULT heap, 16x16 TEXTURE2D, one mip/array slice/sample, UNKNOWN layout. The first two calls requested
ALLOW_RENDER_TARGET | ALLOW_UNORDERED_ACCESS, initial COMMON state, with and without a matching-format zero clear value. The successful call used no resource flags, COPY_DEST, and no clear value.GetDeviceRemovedReason()remained successful.This host needs the texture-creation retry, not just the dispatch-time FP16 bridge: unlike the NVIDIA case where allocation succeeds despite missing typed stores, vkd3d rejects the original combined uses outright.
Probe detail: the first attempt selected by PCI vendor ID and stopped before device creation because DXVK's default NVIDIA-hiding behavior reported AMD's ID. For the measurement above only,
DXVK_CONFIG='dxgi.hideNvidiaGpu = False'exposed the real vendor; NVIDIA's Vulkan ICD was explicitly selected, and there was no WARP fallback. This did not change the title-launch configuration.Not tested: your PR's implementation, FP16 packing/readback, PC FSR context/dispatch, output image, gameplay, or long-run stability. Reporting against the existing PR rather than proposing a duplicate NVIDIA-specific patch. The temporary probe is being removed after this check.
AI assistance: OpenAI coding assistant wrote and ran the probe and drafted this report from its output.
Follow-up: allocation and pixel tests now pass locally
Integrated the diff at
7db1c078711da6a5085b018129cbdb7aa9259203into the existing local integration tree and ran:The latter ran both frames per format and checked the readback pixels in both FP16 and RGB9E5 with the PR's existing assertions. It did not skip for a missing SDK/GPU. Same headless Wine/NVIDIA environment as above; fetched only SDK v2.4.0's official
signedbin/amd_fidelityfx_upscaler_dx12.dll(57,664,272 bytes), SHA256aad4fccccb29084a655f9a4f9f613bd22c8c03fb4a0f8840148cc6543b4ccace.Integration qualifications: this is not an unmodified checkout of the PR. Existing deferred-texture work adds an
on_demandparameter, so the allocation test passesfalse. The local bridge cache usesArc<Bridge>owned by the map instead ofBox::leak/&'static Bridge, andLazyLockinitialization; the dispatch takes its texture reference before moving that Arc intopacked. These ownership adaptations do not alter the packing shader/copy commands, but must be disclosed when interpreting the result. Other pre-existing local integration changes remain. The debug layer is optional in this test, so a pass does not establish that Microsoft's debug-layer validation ran under Wine.No title gameplay or long-run stability claim. No competing PR proposed.
@steven-seagull27 on GitHub · 2026-11-26 01:55 UTC · original · edited 2026-11-26 02:02 UTC
@marquezinii I put the requested bridge-format correction in one commit on top of
7db1c07. It checks the actual host texture before choosing the RGB9E5 packer. A direct output must support a typed store and have the UAV flag. The existing refusal path handles other unwritable formats and unsupported starting states. When the bridge is used, the provider receives the FP16 scratch texture's actual initial state.PARAMETER(6)0x40The original-head comparison stopped immediately after selection, before submitting the invalid combinations. The new cases exercise the real
ffxDispatchentry point.0xc0000005after the refusal checks, before reporting pixel results. The cause is undetermined. WARP's positive pixel readback remains unverified here.The three existing FidelityFX module tests, strict all-feature Clippy for the HLE and GPU crates, and the asset-policy check passed. From the PR branch:
Current-main integration. Git merged the PR into
63bcca43without a text conflict, but the Windows build failed in bothdraw.rsandlist.rs:host_resourcenow returns an owned resource andrenderstakes a reference. I fixed both callers in the fast-forwardable current-main branch. It includes the review fix above and passes strict GPU/HLE Clippy, asset policy and the full two-format RTX FidelityFX readback.I also checked compatibility with the newly adopted #2626 head
c8cc83e. On the combined tree the real FidelityFX readback passed on the RTX. The #1868 allocation test passed on RTX and built-in WARP, and both of #2626's packed-format footprint checks passed three times per adapter. To take the review fix and main update together, usegit fetch https://github.com/steven-seagull27/VIctory.git codex/pr1868-current-mainandgit merge --ff-only FETCH_HEADon your PR branch.AI-assisted with Codex. Synthetic textures only.
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.