GPU: RGBA8 shader views keep their sRGB or linear format where the host can cast (#578) #644

Open
laptopnotebook wants to merge 1 commit from upstream-pr/644 into main
laptopnotebook commented 2026-11-25 03:52:05 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by laptopnotebook on 2026-11-25T03:52:05Z.


Fixes #578.

fits in descriptor/host.rs gave a shader view of a typed texture the texture's format whenever the view asked for another format of the same family. For RGBA8 that dropped the sRGB conversion: an sRGB view of a UNORM texture read its texels as linear, and a linear view of an sRGB texture read them converted.

On a host that reports CastingFullyTypedFormatSupported (Options3, queried once and logged like the depth bounds check), an RGBA8 shader view now keeps the sRGB or linear format it asks for. Unordered access views, other format pairs (BGRA8 still has the old shortcut) and hosts without the cast behave as before. This follows the patch @akimfomin proposed in the issue.

inplace::Rig is now pub(crate) so the new test can use its queue; nothing else about it changed.

Validation (Windows 11, NVIDIA):

  • New test descriptor::host::tests::rgba8_views_keep_their_srgb_conversion uploads one 0x80 texel and samples it on the GPU through all four texture/view pairs. The sRGB view of the UNORM texture reads 0.2159 with the change and 0.5020 without it (the test fails then).
  • Under the D3D12 debug layer (diagnostics build, VICTORY_D3D12_DEBUG=1) the four views raise no messages.
  • cargo test --workspace --locked: all pass.
  • A run of the title through the menus into the prologue: no crash or device loss. The new path was not hit there (the capability line was never logged), so this run shows no regression but no visible change either.
  • Clippy currently fails on main in draw.rs (sort_unstable_by_key), indirect.rs (depth_written unused) and resource.rs (placed_filler_twins unused); this PR doesn't touch those.
<!-- greyfinch-sync:fxceless/victory-fork:issue:6596811491 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/644). Originally posted by [laptopnotebook](https://github.com/laptopnotebook) on 2026-11-25T03:52:05Z. --- Fixes #578. `fits` in `descriptor/host.rs` gave a shader view of a typed texture the texture's format whenever the view asked for another format of the same family. For RGBA8 that dropped the sRGB conversion: an sRGB view of a UNORM texture read its texels as linear, and a linear view of an sRGB texture read them converted. On a host that reports `CastingFullyTypedFormatSupported` (Options3, queried once and logged like the depth bounds check), an RGBA8 shader view now keeps the sRGB or linear format it asks for. Unordered access views, other format pairs (BGRA8 still has the old shortcut) and hosts without the cast behave as before. This follows the patch @akimfomin proposed in the issue. `inplace::Rig` is now `pub(crate)` so the new test can use its queue; nothing else about it changed. Validation (Windows 11, NVIDIA): - New test `descriptor::host::tests::rgba8_views_keep_their_srgb_conversion` uploads one 0x80 texel and samples it on the GPU through all four texture/view pairs. The sRGB view of the UNORM texture reads 0.2159 with the change and 0.5020 without it (the test fails then). - Under the D3D12 debug layer (diagnostics build, `VICTORY_D3D12_DEBUG=1`) the four views raise no messages. - `cargo test --workspace --locked`: all pass. - A run of the title through the menus into the prologue: no crash or device loss. The new path was not hit there (the capability line was never logged), so this run shows no regression but no visible change either. - Clippy currently fails on `main` in `draw.rs` (`sort_unstable_by_key`), `indirect.rs` (`depth_written` unused) and `resource.rs` (`placed_filler_twins` unused); this PR doesn't touch those.
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/644:upstream-pr/644'
git switch 'upstream-pr/644'

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