sRGB views of typed textures keep their format where the host casts fully typed formats #4383

Open
github-bot wants to merge 2 commits from github-bot/gh-4382 into main AGit
Owner

@⁠tyr0nsur on GitHub · 2026-11-30 19:29 UTC · original
tyr0nsur:claude/srgb-views-keep-their-format → main · +254 −6 · 2 files · 2 commits · open

Relates to the fits shortcut in descriptor/host.rs ("such a view (sRGB of UNORM, say) reads without its conversion") and the cast log added in cb191f38.

What it changes

fits gives a shader view of a typed host texture in another format of its family the texture's own format. For the other half of an sRGB pair that drops the conversion: an sRGB view of UNORM memory reads the stored bytes as linear (too bright, few steps in the dark), and a UNORM view of sRGB memory decodes when the title asked it not to.

The opening of the title makes such views of BC7 on an RTX 4060 (release v2026.11.30, from the existing cast log line):

a view in another format than its typed host texture kind="shader resource" texture_format=98 view_format=99 same_family=true srgb_pair=false host_casts_fully_typed=true
a view in another format than its typed host texture kind="shader resource" texture_format=99 view_format=98 same_family=true srgb_pair=false host_casts_fully_typed=true

(srgb_pair=false there is the table, which named only the three 8-bit pairs.)

  • resource::SRGB_BLOCKS: the block pairs, BC1 (72/71), BC2 (75/74), BC3 (78/77) and BC7 (99/98), in a table of their own. SRGB (the UAV linear twin in fits, the typeless sRGB UAV texture at creation) is unchanged. srgb_pair reads both tables, and the cast log now says srgb_pair=true for the block pairs.
  • resource::srgb_cast(own, view): a shader view (not unordered access) that is the other half of the texture's sRGB pair keeps the title's format when the host reports CastingFullyTypedFormatSupported. Every other cast is as before.
  • VICTORY_SRGB_CASTS=0 restores the old behaviour.

How it was tested

  • GPU: RTX 4060 8 GB, driver 621.14, Windows 11 26300; and WARP.
  • New test descriptor::host::srgb_cast_tests reads a texel through SRVs of 4x4 RGBA8, BC1 and BC7 textures, each made in UNORM and in sRGB and viewed in both formats:
hardware casts=true RGBA8: UNORM 0.5059, sRGB 0.2197, sRGB view of UNORM 0.2197, UNORM view of sRGB 0.5059
hardware casts=true BC1: UNORM 0.5176, sRGB 0.2305, sRGB view of UNORM 0.2305, UNORM view of sRGB 0.5176
hardware casts=true BC7: UNORM 0.5059, sRGB 0.2197, sRGB view of UNORM 0.2197, UNORM view of sRGB 0.5059
warp casts=true RGBA8: UNORM 0.5059, sRGB 0.2195, sRGB view of UNORM 0.2195, UNORM view of sRGB 0.5059
warp casts=true BC1: UNORM 0.5176, sRGB 0.2307, sRGB view of UNORM 0.2307, UNORM view of sRGB 0.5176
warp casts=true BC7: UNORM 0.5059, sRGB 0.2195, sRGB view of UNORM 0.2195, UNORM view of sRGB 0.5059

A cast view reads exactly what a texture made in the view's format reads, so the host does the conversion the console does. On an adapter without the cap the test only checks the plain textures; it needs no game data and returns early without a device.

  • Before: the BC7 views above read in the texture's format (the shortcut). After: in the title's.
  • In-game before/after captures: not yet; a comparison of the opening on a card with the cap is welcome, and VICTORY_SRGB_CASTS=0 gives the old picture for an A/B.
  • cargo test -p victory-gpu --locked --lib descriptor::host: 97 passed. Both Clippy steps pass with #4297 applied (on main alone they stop at the findings #4297 fixes). cargo xtask policy: only the existing native.rs finding.

A second review by GPT-6.2 confirmed that these seven casts are valid under CastingFullyTypedFormatSupported (BC included, either direction) and suggested keeping the block pairs out of SRGB, which the second commit does.

Checked for overlap

  • I searched the open pull requests for the same issue and for the files this touches. Related: #2646 and #2632 (display planes read as plain UNORM in compose, a separate path this leaves alone), cb191f38 (the cast log).

🤖 Generated with Claude Code

**@⁠tyr0nsur** on GitHub · 2026-11-30 19:29 UTC · [original](https://github.com/trustno1-coder/VIctory-NVIDIA/pull/4382) `tyr0nsur:claude/srgb-views-keep-their-format` → `main` · +254 −6 · 2 files · 2 commits · open Relates to the `fits` shortcut in `descriptor/host.rs` ("such a view (sRGB of UNORM, say) reads without its conversion") and the cast log added in cb191f38. ## What it changes `fits` gives a shader view of a typed host texture in another format of its family the texture's own format. For the other half of an sRGB pair that drops the conversion: an sRGB view of UNORM memory reads the stored bytes as linear (too bright, few steps in the dark), and a UNORM view of sRGB memory decodes when the title asked it not to. The opening of the title makes such views of **BC7** on an RTX 4060 (release v2026.11.30, from the existing cast log line): ``` a view in another format than its typed host texture kind="shader resource" texture_format=98 view_format=99 same_family=true srgb_pair=false host_casts_fully_typed=true a view in another format than its typed host texture kind="shader resource" texture_format=99 view_format=98 same_family=true srgb_pair=false host_casts_fully_typed=true ``` (`srgb_pair=false` there is the table, which named only the three 8-bit pairs.) - `resource::SRGB_BLOCKS`: the block pairs, BC1 (72/71), BC2 (75/74), BC3 (78/77) and BC7 (99/98), in a table of their own. `SRGB` (the UAV linear twin in `fits`, the typeless sRGB UAV texture at creation) is unchanged. `srgb_pair` reads both tables, and the cast log now says `srgb_pair=true` for the block pairs. - `resource::srgb_cast(own, view)`: a shader view (not unordered access) that is the other half of the texture's sRGB pair keeps the title's format when the host reports `CastingFullyTypedFormatSupported`. Every other cast is as before. - `VICTORY_SRGB_CASTS=0` restores the old behaviour. ## How it was tested - GPU: RTX 4060 8 GB, driver 621.14, Windows 11 26300; and WARP. - New test `descriptor::host::srgb_cast_tests` reads a texel through SRVs of 4x4 RGBA8, BC1 and BC7 textures, each made in UNORM and in sRGB and viewed in both formats: ``` hardware casts=true RGBA8: UNORM 0.5059, sRGB 0.2197, sRGB view of UNORM 0.2197, UNORM view of sRGB 0.5059 hardware casts=true BC1: UNORM 0.5176, sRGB 0.2305, sRGB view of UNORM 0.2305, UNORM view of sRGB 0.5176 hardware casts=true BC7: UNORM 0.5059, sRGB 0.2197, sRGB view of UNORM 0.2197, UNORM view of sRGB 0.5059 warp casts=true RGBA8: UNORM 0.5059, sRGB 0.2195, sRGB view of UNORM 0.2195, UNORM view of sRGB 0.5059 warp casts=true BC1: UNORM 0.5176, sRGB 0.2307, sRGB view of UNORM 0.2307, UNORM view of sRGB 0.5176 warp casts=true BC7: UNORM 0.5059, sRGB 0.2195, sRGB view of UNORM 0.2195, UNORM view of sRGB 0.5059 ``` A cast view reads exactly what a texture made in the view's format reads, so the host does the conversion the console does. On an adapter without the cap the test only checks the plain textures; it needs no game data and returns early without a device. - Before: the BC7 views above read in the texture's format (the shortcut). After: in the title's. - In-game before/after captures: not yet; a comparison of the opening on a card with the cap is welcome, and `VICTORY_SRGB_CASTS=0` gives the old picture for an A/B. - `cargo test -p victory-gpu --locked --lib descriptor::host`: 97 passed. Both Clippy steps pass with #4297 applied (on `main` alone they stop at the findings #4297 fixes). `cargo xtask policy`: only the existing `native.rs` finding. A second review by GPT-6.2 confirmed that these seven casts are valid under `CastingFullyTypedFormatSupported` (BC included, either direction) and suggested keeping the block pairs out of `SRGB`, which the second commit does. ## Checked for overlap - [x] I searched the open pull requests for the same issue and for the files this touches. Related: #2646 and #2632 (display planes read as plain UNORM in compose, a separate path this leaves alone), cb191f38 (the cast log). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A shader view of a typed host texture in the other half of its sRGB pair
(BC7_UNORM_SRGB of BC7_UNORM, R8G8B8A8_UNORM of R8G8B8A8_UNORM_SRGB, ...)
was given the texture's own format by `fits`, so it read without its
conversion: an sRGB view of UNORM memory read the stored bytes as linear.
On a host with CastingFullyTypedFormatSupported such a view keeps the
title's format and decodes as on the console. The title's opening makes
BC7 views of both kinds (98 of 99, 99 of 98) on an RTX 4060.

The sRGB table gains the block pairs (BC1, BC2, BC3, BC7), which also
makes `srgb_pair` true for them in the cast log line. Block formats are
never unordered access or targets, so its other users see no change.
VICTORY_SRGB_CASTS=0 gives the texture's format, as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 19:34:36 +00:00
The BC sRGB pairs were added to SRGB, which also picks the linear format
of an sRGB unordered access view and makes sRGB textures with unordered
access typeless. Block textures never take those paths, but the SRV cast
is all they are for: they now sit in SRGB_BLOCKS, read by srgb_pair
(srgb_cast and the cast log line) alone. Suggested in a review by GPT-6.2.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot force-pushed github-bot/gh-4382 from 144c951adf to 2f4040899d 2026-12-01 00:05:03 +00:00 Compare
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/4383/head:github-bot/gh-4382'
git switch 'github-bot/gh-4382'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-4382'
git switch 'github-bot/gh-4382'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-4382'
git switch 'github-bot/gh-4382'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-4382'
git switch 'main'
git merge --squash 'github-bot/gh-4382'
git switch 'main'
git merge --ff-only 'github-bot/gh-4382'
git switch 'main'
git merge 'github-bot/gh-4382'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/trustno1-coder--VIctory-NVIDIA!4383
No description provided.