GPU: a shared-exponent HDR render target gets an RGBA16F stand-in #3925

Open
kotekompotek wants to merge 2 commits from upstream-pr/3925 into main
kotekompotek commented 2026-12-01 03:27:08 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-12-01T03:27:08Z.


Summary

Depends on: #3877 (contains its commits until that lands).

DXGI_FORMAT_R9G9B9E5_SHAREDEXP (format 67) has no render-target or typed-UAV support on NVIDIA: GTA VI's 1920x1080 HDR scene target (flags: RT|UAV) fails CreateCommittedResource with E_INVALIDARG, and every frame it backs stays empty.

stand_in_format gets a second entry: 67 → 10 (R16G16B16A16_FLOAT), which covers the shared-exponent range and more, and supports both uses. The support check still gates the substitution, so a host that does support 67 keeps it.

Issue #904 documents both this format and 115 among the refused target formats.

Test plan

  • cargo test -p victory-gpu resource::tests — 23 passed, including the new 67 assertions.
  • GTA VI boot on GTX 1050: zero no host texture refusals; the loading screens render full-frame (the 115+67 stand-ins together fix the diagonal-half-black loading art).

AI-assisted change.

<!-- greyfinch-sync:Marvisak/VIctory:issue:5578370484 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3925). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-12-01T03:27:08Z. --- ## Summary Depends on: #3877 (contains its commits until that lands). DXGI_FORMAT_R9G9B9E5_SHAREDEXP (format 67) has no render-target or typed-UAV support on NVIDIA: GTA VI's 1920x1080 HDR scene target (flags: RT|UAV) fails `CreateCommittedResource` with E_INVALIDARG, and every frame it backs stays empty. `stand_in_format` gets a second entry: 67 → 10 (R16G16B16A16_FLOAT), which covers the shared-exponent range and more, and supports both uses. The support check still gates the substitution, so a host that does support 67 keeps it. Issue #904 documents both this format and 115 among the refused target formats. #### Test plan - [x] `cargo test -p victory-gpu resource::tests` — 23 passed, including the new 67 assertions. - [x] GTA VI boot on GTX 1050: zero `no host texture` refusals; the loading screens render full-frame (the 115+67 stand-ins together fix the diagonal-half-black loading art). AI-assisted change.
passerbyyhx commented 2026-12-01 12:42:38 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by passerbyyhx on 2026-12-01T12:42:38Z.


Compared the stacked base and ee84179b with guest RGB9E5 rows (48 texels, pitch 256). RTX 4090 Laptop selected RGBA16F: RTV and UAV writes gave the expected (4,2,1) and (1,2,8) via the SRV, but uploading to the stand-in yielded zeros and copying back left all four tested guest pixels at the sentinel. WARP retained native RGB9E5 and passed. With the proposed conversion, both adapters passed separate upload and download probes, a two-row subrectangle round trip and the shader readback controls. The Windows SDK packing/decoding comparison matched in all 47,252 cases. Author-branch fix: https://github.com/kotekompotek/VIctory/pull/4.

Review also turned up signed black: the initial candidate packed four of eight sign combinations of FP16 zero as 0x88000000, which also decodes to black. The follow-up normalizes these to the SDK's 0x00000000. All eight combinations and the earlier 47,244 cases now match the SDK bit for bit.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7311534006 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3925#issuecomment-7311534006). Originally posted by [passerbyyhx](https://github.com/passerbyyhx) on 2026-12-01T12:42:38Z. --- Compared the stacked base and ee84179b with guest RGB9E5 rows (48 texels, pitch 256). RTX 4090 Laptop selected RGBA16F: RTV and UAV writes gave the expected (4,2,1) and (1,2,8) via the SRV, but uploading to the stand-in yielded zeros and copying back left all four tested guest pixels at the sentinel. WARP retained native RGB9E5 and passed. With the proposed conversion, both adapters passed separate upload and download probes, a two-row subrectangle round trip and the shader readback controls. The Windows SDK packing/decoding comparison matched in all 47,252 cases. Author-branch fix: https://github.com/kotekompotek/VIctory/pull/4. Review also turned up signed black: the initial candidate packed four of eight sign combinations of FP16 zero as 0x88000000, which also decodes to black. The follow-up normalizes these to the SDK's 0x00000000. All eight combinations and the earlier 47,244 cases now match the SDK bit for bit.
cloph-dsp commented 2026-12-01 15:32:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-12-01T15:32:02Z.


Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree, per-worktree CARGO_TARGET_DIR.

Base 63bcca43c6a00a758510398fa43096ce7e4f7df0, head ee84179b5998a6367cbc4b1a4dd6be2ffd05b390. git diff --numstat → descriptor.rs 8/0, descriptor/host.rs 23/9, list.rs 196/30, pipeline/host.rs 10/1, resource.rs 420/1, texture.rs 102/0.

Four of the six new tests are CPU-only and their names are new on the base (git grep -F <name> 63bcca43 -- . returns no match for each):

$env:CARGO_TARGET_DIR='D:\Victory-Contrib\target-3925'
cargo test --locked -p victory-gpu --lib -- resource::tests::a_stand_in_view_names_the_texture_format --exact --test-threads=1 --quiet
cargo test --locked -p victory-gpu --lib -- resource::tests::a_4444_stands_in_where_the_host_cannot_use_it --exact --test-threads=1 --quiet
cargo test --locked -p victory-gpu --lib -- resource::tests::a_4444_host_desc_follows_host_support --exact --test-threads=1 --quiet
cargo test --locked -p victory-gpu --lib -- texture::tests::a_4444_row_expands_to_bgra8_and_packs_back --exact --test-threads=1 --quiet

Result, each: running 1 test, test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 237 filtered out (the host-desc case took 0.82s, the rest 0.00s).

The other two — resource::tests::a_4444_copy_round_trips_through_the_stand_in and resource::tests::a_4444_render_target_clears_and_reads_back — begin with if crate::host::host().is_none() { return; } (resource.rs:3389 and 3523). On this machine there is no D3D12 device, so they report pass without asserting anything; I am deliberately not counting them.

git diff --check "63bcca43..ee84179b" → no output, exit 0.

GPU/driver N/A for the four counted tests. No game data.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7316075130 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3925#issuecomment-7316075130). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-12-01T15:32:02Z. --- Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree, per-worktree CARGO_TARGET_DIR. Base `63bcca43c6a00a758510398fa43096ce7e4f7df0`, head `ee84179b5998a6367cbc4b1a4dd6be2ffd05b390`. `git diff --numstat` → descriptor.rs 8/0, descriptor/host.rs 23/9, list.rs 196/30, pipeline/host.rs 10/1, resource.rs 420/1, texture.rs 102/0. Four of the six new tests are CPU-only and their names are new on the base (`git grep -F <name> 63bcca43 -- .` returns no match for each): ``` $env:CARGO_TARGET_DIR='D:\Victory-Contrib\target-3925' cargo test --locked -p victory-gpu --lib -- resource::tests::a_stand_in_view_names_the_texture_format --exact --test-threads=1 --quiet cargo test --locked -p victory-gpu --lib -- resource::tests::a_4444_stands_in_where_the_host_cannot_use_it --exact --test-threads=1 --quiet cargo test --locked -p victory-gpu --lib -- resource::tests::a_4444_host_desc_follows_host_support --exact --test-threads=1 --quiet cargo test --locked -p victory-gpu --lib -- texture::tests::a_4444_row_expands_to_bgra8_and_packs_back --exact --test-threads=1 --quiet ``` Result, each: `running 1 test`, `test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 237 filtered out` (the host-desc case took 0.82s, the rest 0.00s). The other two — `resource::tests::a_4444_copy_round_trips_through_the_stand_in` and `resource::tests::a_4444_render_target_clears_and_reads_back` — begin with `if crate::host::host().is_none() { return; }` (resource.rs:3389 and 3523). On this machine there is no D3D12 device, so they report pass without asserting anything; I am deliberately not counting them. `git diff --check "63bcca43..ee84179b"` → no output, exit 0. GPU/driver N/A for the four counted tests. No game data.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/3925:upstream-pr/3925'
git switch 'upstream-pr/3925'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/3925'
git switch 'upstream-pr/3925'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3925'
git switch 'upstream-pr/3925'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3925'
git switch 'main'
git merge --squash 'upstream-pr/3925'
git switch 'main'
git merge --ff-only 'upstream-pr/3925'
git switch 'main'
git merge 'upstream-pr/3925'
git push origin 'main'
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
Marvisak/VIctory!3925
No description provided.