GPU: make shared sRGB textures typeless for unordered access #2677

Open
fuzeofficlal wants to merge 1 commit from upstream-pr/2679 into main
fuzeofficlal commented 2026-11-25 18:01:42 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T18:01:42Z.


Summary

  • Extract typeless_if_unordered_srgb in crates/victory-gpu/src/resource.rs and call it again in shared_texture after merging sibling USES flags from TEXTURES_AT, so an sRGB render target sharing memory with an unordered-access texture is promoted to its typeless family before make_texture.
  • Generalize typed_store validation in crates/victory-gpu/src/descriptor/host.rs::fits to cover default (view == 0) and same-family unordered views in addition to cross-family casts (pairing with #2462 so promoting B8G8R8X8_UNORM_SRGB -> B8G8R8X8_TYPELESS never lets an unsupported B8G8R8X8_UNORM UAV reach CreateUnorderedAccessView if this PR lands ahead of #2462).
  • Add regression tests in resource::tests::shared_srgb_render_targets_with_unordered_access_are_typeless (covering RGBA8, BGRA8, and BGRX8 shared RT + UAV creation, verifying RGBA8/BGRA8 UAVs succeed, unsupported BGRX8 linear/sRGB UAVs stay null without device removal, and castable R32_UINT UAVs still succeed) and descriptor::host::tests::unsupported_same_family_and_default_uavs_are_refused.

Verification

  • cargo clippy --locked -p victory-gpu --all-targets -- -D warnings and --features diagnostics: 0 warnings.
  • NVIDIA GeForce RTX 5090 (rustc 1.98.1 MSVC): shared_srgb_render_targets_with_unordered_access_are_typeless and unsupported_same_family_and_default_uavs_are_refused pass (GetDeviceRemovedReason() == S_OK).
  • WARP (VICTORY_D3D12_WARP=1): cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1 -> 200 passed, 0 failed, 1 ignored.
  • cargo xtask policy: 184 files ok.
<!-- greyfinch-sync:Marvisak/VIctory:issue:6610585408 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2679). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T18:01:42Z. --- ## Summary - Extract `typeless_if_unordered_srgb` in `crates/victory-gpu/src/resource.rs` and call it again in `shared_texture` after merging sibling `USES` flags from `TEXTURES_AT`, so an sRGB render target sharing memory with an unordered-access texture is promoted to its typeless family before `make_texture`. - Generalize `typed_store` validation in `crates/victory-gpu/src/descriptor/host.rs::fits` to cover default (`view == 0`) and same-family unordered views in addition to cross-family casts (pairing with #2462 so promoting `B8G8R8X8_UNORM_SRGB` -> `B8G8R8X8_TYPELESS` never lets an unsupported `B8G8R8X8_UNORM` UAV reach `CreateUnorderedAccessView` if this PR lands ahead of #2462). - Add regression tests in `resource::tests::shared_srgb_render_targets_with_unordered_access_are_typeless` (covering RGBA8, BGRA8, and BGRX8 shared RT + UAV creation, verifying RGBA8/BGRA8 UAVs succeed, unsupported BGRX8 linear/sRGB UAVs stay null without device removal, and castable `R32_UINT` UAVs still succeed) and `descriptor::host::tests::unsupported_same_family_and_default_uavs_are_refused`. ## Verification - `cargo clippy --locked -p victory-gpu --all-targets -- -D warnings` and `--features diagnostics`: 0 warnings. - NVIDIA GeForce RTX 5090 (`rustc 1.98.1` MSVC): `shared_srgb_render_targets_with_unordered_access_are_typeless` and `unsupported_same_family_and_default_uavs_are_refused` pass (`GetDeviceRemovedReason() == S_OK`). - WARP (`VICTORY_D3D12_WARP=1`): `cargo test --locked -p victory-gpu --features diagnostics --lib -- --test-threads=1` -> 200 passed, 0 failed, 1 ignored. - `cargo xtask policy`: 184 files ok.
DrDarkDK commented 2026-11-25 19:06:12 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by DrDarkDK on 2026-11-25T18:12:13Z.


The BGRX family still needs a UAV capability check after typeless promotion. I ran a standalone D3D12 probe on an RTX 4070 Ti (driver 621.01, Windows 11 build 26300), using 64×64 textures with both render-target and unordered-access flags.

Host resource after promotion Resource creation Typed UAV support for the linear format
R8G8B8A8_TYPELESS S_OK Yes
B8G8R8A8_TYPELESS S_OK Yes
B8G8R8X8_TYPELESS S_OK No

The same-family view path bypasses typed_store, so successful BGRX resource creation can still lead to an unsupported B8G8R8X8_UNORM UAV. Could we pair this with the check in #2462 and test that the unsupported view stays null?

The probe checked resource creation and reported format support. I didn’t create the unsupported view or run VIctory.

AI-assisted with Codex.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170584438 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2679#issuecomment-7170584438). Originally posted by [DrDarkDK](https://github.com/DrDarkDK) on 2026-11-25T18:12:13Z. --- The BGRX family still needs a UAV capability check after typeless promotion. I ran a standalone D3D12 probe on an RTX 4070 Ti (driver 621.01, Windows 11 build 26300), using 64×64 textures with both render-target and unordered-access flags. | Host resource after promotion | Resource creation | Typed UAV support for the linear format | | --- | --- | --- | | `R8G8B8A8_TYPELESS` | `S_OK` | Yes | | `B8G8R8A8_TYPELESS` | `S_OK` | Yes | | `B8G8R8X8_TYPELESS` | `S_OK` | No | The same-family view path bypasses `typed_store`, so successful BGRX resource creation can still lead to an unsupported `B8G8R8X8_UNORM` UAV. Could we pair this with the check in #2462 and test that the unsupported view stays null? The probe checked resource creation and reported format support. I didn’t create the unsupported view or run VIctory. *AI-assisted with Codex.*
fuzeofficlal commented 2026-11-25 19:06:21 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by fuzeofficlal on 2026-11-25T18:29:06Z.


Thanks for the hardware probe and catch, @DrDarkDK! You're completely right — without the same-family typed_store check from #2462, promoting a shared B8G8R8X8_UNORM_SRGB + UNORDERED texture to B8G8R8X8_TYPELESS would allow resource creation to succeed and then pass an unsupported B8G8R8X8_UNORM UAV to CreateUnorderedAccessView if this PR merged ahead of #2462.

Updated in b5c7f9d:

  • Generalized descriptor::host::fits so typed_store checks the effective view format for default (view == 0), same-family, and castable unordered views alike (matching #2462's safeguard so this PR is safe standalone; happy to rebase cleanly if #2462 lands first).
  • Extended resource::tests::shared_srgb_render_targets_with_unordered_access_are_typeless to cover all three SRGB families (RGBA8, BGRA8, and BGRX8), creating actual UAV descriptors via HostHeap::make_at and asserting that:
    • supported R8G8B8A8_UNORM / B8G8R8A8_UNORM UAVs succeed,
    • unsupported B8G8R8X8_UNORM (and B8G8R8X8_UNORM_SRGB rewritten to linear) UAVs stay null with GetDeviceRemovedReason() == S_OK,
    • castable R32_UINT UAVs on the promoted B8G8R8X8_TYPELESS texture still succeed.
  • Added descriptor::host::tests::unsupported_same_family_and_default_uavs_are_refused covering fits directly for typeless same-family and typed default/same-family unsupported UAVs.

Re-verified on NVIDIA GeForce RTX 5090 (both new tests pass, B8G8R8X8_UNORM typed UAV confirmed unsupported and kept null) and WARP (200 passed, 0 failed, 1 ignored, clippy 0 warnings, xtask policy ok).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7170970635 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2679#issuecomment-7170970635). Originally posted by [fuzeofficlal](https://github.com/fuzeofficlal) on 2026-11-25T18:29:06Z. --- Thanks for the hardware probe and catch, @DrDarkDK! You're completely right — without the same-family `typed_store` check from #2462, promoting a shared `B8G8R8X8_UNORM_SRGB` + `UNORDERED` texture to `B8G8R8X8_TYPELESS` would allow resource creation to succeed and then pass an unsupported `B8G8R8X8_UNORM` UAV to `CreateUnorderedAccessView` if this PR merged ahead of #2462. Updated in `b5c7f9d`: - Generalized `descriptor::host::fits` so `typed_store` checks the effective view format for default (`view == 0`), same-family, and castable unordered views alike (matching #2462's safeguard so this PR is safe standalone; happy to rebase cleanly if #2462 lands first). - Extended `resource::tests::shared_srgb_render_targets_with_unordered_access_are_typeless` to cover all three `SRGB` families (`RGBA8`, `BGRA8`, and `BGRX8`), creating actual UAV descriptors via `HostHeap::make_at` and asserting that: - supported `R8G8B8A8_UNORM` / `B8G8R8A8_UNORM` UAVs succeed, - unsupported `B8G8R8X8_UNORM` (and `B8G8R8X8_UNORM_SRGB` rewritten to linear) UAVs stay null with `GetDeviceRemovedReason() == S_OK`, - castable `R32_UINT` UAVs on the promoted `B8G8R8X8_TYPELESS` texture still succeed. - Added `descriptor::host::tests::unsupported_same_family_and_default_uavs_are_refused` covering `fits` directly for typeless same-family and typed default/same-family unsupported UAVs. Re-verified on NVIDIA GeForce RTX 5090 (both new tests pass, `B8G8R8X8_UNORM` typed UAV confirmed unsupported and kept null) and WARP (`200 passed, 0 failed, 1 ignored`, `clippy` 0 warnings, `xtask policy` ok).
kotekompotek commented 2026-11-25 19:06:26 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kotekompotek on 2026-11-25T18:37:54Z.


Correct on both sides: the shared-texture merge now re-runs the sRGB->typeless promotion after sibling USES flags are merged (the case host_desc can't see alone), and fits() covers the two holes the promotion opens - a default view (view==0) on a typed texture, and a same-family view on a typeless one - both checking typed_store on the effective format. The test matrix (RGBA8/BGRA8 succeed, BGRX8 refused without device removal, R32_UINT cast still works) covers exactly the promotion's edge cases.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7171176351 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2679#issuecomment-7171176351). Originally posted by [kotekompotek](https://github.com/kotekompotek) on 2026-11-25T18:37:54Z. --- Correct on both sides: the shared-texture merge now re-runs the sRGB->typeless promotion after sibling USES flags are merged (the case host_desc can't see alone), and fits() covers the two holes the promotion opens - a default view (view==0) on a typed texture, and a same-family view on a typeless one - both checking typed_store on the effective format. The test matrix (RGBA8/BGRA8 succeed, BGRX8 refused without device removal, R32_UINT cast still works) covers exactly the promotion's edge cases.
Marvisak commented 2026-11-25 23:06:05 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Marvisak on 2026-11-25T22:16:58Z.


Automated triage for the maintainers.

Verdict: merge candidate. I reviewed the rebased head e59bde5. The functional change is one call: shared_texture (crates/victory-gpu/src/resource.rs) runs the sRGB-to-typeless promotion (now typeless_if_unordered_srgb) again after merging sibling USES flags. Before, an sRGB render target that shared memory with an unordered-access texture was created as a typed sRGB resource with UAV access, which the host does not support. The view-side guard the description talks about (fits checking typed_store for default and same-family views) is already on main via #2462, so the descriptor/host.rs hunk here is now a test of that code only.

Small point: unsupported_same_family_and_default_uavs_are_refused asserts !typed_store(B8G8R8X8_UNORM) outright. The other test checks support at runtime, and this one should too, in case some adapter reports support.

CI: check passing.


Generated by Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:comment:7176166738 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2679#issuecomment-7176166738). Originally posted by [Marvisak](https://github.com/Marvisak) on 2026-11-25T22:16:58Z. --- <!-- victory-triage v1 head=e59bde5d05f017cd722678f4aa2e0e65ce77e17b verdict=merge-candidate at=2026-11-26T03:22:24Z --> Automated triage for the maintainers. **Verdict: merge candidate.** I reviewed the rebased head `e59bde5`. The functional change is one call: `shared_texture` (`crates/victory-gpu/src/resource.rs`) runs the sRGB-to-typeless promotion (now `typeless_if_unordered_srgb`) again after merging sibling `USES` flags. Before, an sRGB render target that shared memory with an unordered-access texture was created as a typed sRGB resource with UAV access, which the host does not support. The view-side guard the description talks about (`fits` checking `typed_store` for default and same-family views) is already on `main` via #2462, so the `descriptor/host.rs` hunk here is now a test of that code only. Small point: `unsupported_same_family_and_default_uavs_are_refused` asserts `!typed_store(B8G8R8X8_UNORM)` outright. The other test checks support at runtime, and this one should too, in case some adapter reports support. CI: `check` passing. --- _Generated by [Claude Code](https://claude.ai/code)_
Dukestar69 commented 2026-11-26 05:02:57 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T04:29:40Z.

Review: APPROVED


Tested merged onto origin/main (63bcca4) on Windows 11 x64 (NVIDIA GeForce RTX 5090):

  • cargo test -p victory-gpu --lib shared_srgb_render_targets_with_unordered_access_are_typeless: 1 passed, 0 failed.
  • cargo test -p victory-gpu --lib unsupported_same_family_and_default_uavs_are_refused: 1 passed, 0 failed.
  • cargo clippy -p victory-gpu --all-targets -- -D warnings: clean.
  • cargo xtask policy: 191 files ok.

Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).

<!-- greyfinch-sync:Marvisak/VIctory:review:6068564354 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/2679#pullrequestreview-6068564354). Originally posted by [Dukestar69](https://github.com/Dukestar69) on 2026-11-26T04:29:40Z. **Review:** APPROVED --- Tested merged onto `origin/main` (`63bcca4`) on Windows 11 x64 (NVIDIA GeForce RTX 5090): - `cargo test -p victory-gpu --lib shared_srgb_render_targets_with_unordered_access_are_typeless`: **1 passed, 0 failed**. - `cargo test -p victory-gpu --lib unsupported_same_family_and_default_uavs_are_refused`: **1 passed, 0 failed**. - `cargo clippy -p victory-gpu --all-targets -- -D warnings`: clean. - `cargo xtask policy`: 191 files ok. Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
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/2679:upstream-pr/2679'
git switch 'upstream-pr/2679'

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/2679'
git switch 'upstream-pr/2679'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/2679'
git switch 'upstream-pr/2679'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/2679'
git switch 'main'
git merge --squash 'upstream-pr/2679'
git switch 'main'
git merge --ff-only 'upstream-pr/2679'
git switch 'main'
git merge 'upstream-pr/2679'
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!2677
No description provided.