GPU: sRGB and linear views of one texture read with their own curve #331
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!331
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/331/head"
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?
@AnoHunted on GitHub · 2026-11-24 02:21 UTC · original
AnoHunted:srgb-typed-cast-views→main· +251 −6 · 2 files · 1 commits · closed without mergingWhat
fits(descriptor/host.rs) keeps the title's view format when the view is the sRGB or lineartwin of a typed texture's format and the host reports
CastingFullyTypedFormatSupported(
D3D12_FEATURE_D3D12_OPTIONS3). An R8G8B8A8_UNORM_SRGB view of an R8G8B8A8_UNORM texture nowconverts sRGB to linear when a shader reads it, and an R8G8B8A8_UNORM view of an sRGB texture no
longer does.
casts_typedasks for the cap once. A host without it keeps today's behaviour and logs a warningonce.
resource::SRGBgains the BC1, BC2, BC3 and BC7 pairs. Its other users handle sRGB unorderedaccess, which block-compressed textures never have.
UNORM, say) still read in the texture's own format.
resource::tests::srgb_and_linear_views_of_one_texture_read_their_own_curve.It makes 4x4 textures through
create_committed: R8G8B8A8, B8G8R8A8 and BC1, each in its linearand its sRGB format. It fills their memory with 0x80 (BC1: one block of red 16/31) and makes three
views with
create_srv: sRGB, linear, and one with no description. They are mirrored into a hostheap as for a draw, uploaded by
texture::upload, and a compute shaderLoads each view once.Why
The console lets a title view a texture in any format of its family. When the view format differed
from a typed texture's own,
fitsswapped in the texture's own format, which its comment flagged asa shortcut. An sRGB view of a UNORM texture then read with no sRGB-to-linear conversion, and a UNORM
view of an sRGB texture converted anyway, so colours came out with the wrong gamma.
Microsoft's D3D12 documentation describes
CastingFullyTypedFormatSupportedas casting "from onefully typed format to another, compatible, format". The DirectX relaxed casting spec defines that as
an SRV, UAV, RTV or DSV in any fully qualified format of the resource's family. Its own example is an
R8G8B8A8_UNORM resource with an R8G8B8A8_UNORM_SRGB SRV. It never allows SNORM to UNORM, or FLOAT to
non-FLOAT. sRGB and UNORM twins are neither, so only those pairs are let through. Depth formats are
not touched.
Two other approaches were weighed:
sRGB textures with unordered access. A view of a typeless resource must name a format; a null
description "inherits the resource format and dimension (if not typeless)". So every null-description
SRV, UAV and RTV of an RGBA8, BGRA8 or BC texture would need a whole-resource description built per
dimension, and frame capture would need to know the typeless formats. That means more code in more
places, overlapping
host_texture, which #55 and #89 also change.ID3D12Device10::CreateCommittedResource3. That call takes anenhanced-barrier initial layout instead of a resource state and needs Agility SDK 1.7 or later. The
layer uses
ID3D12Deviceand legacy states throughout.Casting fully typed formats needs neither: one feature query and one condition in
fits.Render target views already pass the title's format to the host (
RtvRecord::host_desc), so theyneed no change. sRGB unordered access views still become their linear twin, as before: the host has no
sRGB UAVs.
Tested
Windows 11, NVIDIA GeForce RTX 5080, Rust 1.98.1, and WARP.
The new test run against main (the test alone, without the fix) fails on the RTX 5080 and on
WARP alike. One view of every texture reads with the wrong curve; the values below are on the RTX
5080:
On this branch it passes. Every sRGB view reads 0.216 (BC1: 0.230), every linear view 0.502 (BC1:
0.518), and views without a description read in the texture's own format. WARP's values are within
0.0003 of these (
--features diagnostics,VICTORY_D3D12_WARP=1).cargo test -p victory-gpu: main 43 passed, 0 failed, 1 ignored; branch 44 passed (the new test),0 failed, 1 ignored.
cargo test --workspace: main 264 passed, 0 failed, 4 ignored; branch 265 passed, 0 failed, 4ignored.
cargo clippy -p victory-gpu --all-targets: no new warnings; the one warning, inhost.rs, is onmain too.
cargo xtask policy: ok.rustfmt --checkon the two files reports nothing in the lines this change adds. The otherdifferences it reports are already on main.
Not tested
CastingFullyTypedFormatSupported, where the old behaviour and the warning apply.Overlap
#301 (opened while this was being tested) also fixes the sRGB part, as one piece of a larger change (non-stream PSOs, stream subobjects 25..=28, texture-to-buffer readbacks): it makes sRGB-castable host textures typeless and synthesises view descriptions. This PR is the sRGB fix on its own, with a different mechanism (fully typed format casting, no change to how host textures are made), in case a smaller, separate change is easier to review. The two conflict textually in
resource.rs; if #301 lands first, this one can be closed, and its test could still be moved onto #301's version.AI-assisted (Claude Code, Claude Opus 5.5). No game files were used.
@jeremygold02 on GitHub · 2026-11-24 04:21 UTC · original
Tested PR #331 at head
ccdecb80807826e49ce82a5d9aa6e7814d2b8376(state at test time: OPEN). Pre-comment refresh: state OPEN, head unchanged atccdecb80807826e49ce82a5d9aa6e7814d2b8376.cargo test --locked -p victory-gpu srgb_and_linear_views_of_one_texture_read_their_own_curve— passed (ok. 1 passed; 0 failed; 0 ignored; 0 measured; 44 filtered out; finished in 0.40s ); cases: resource::tests::srgb_and_linear_views_of_one_texture_read_their_own_curve.Behavior covered: Checks linear and sRGB texture views of one resource use their own color curve; this is a host GPU test.
Code: crates/victory-gpu/src/descriptor/host.rs, crates/victory-gpu/src/resource.rs
@DeerSilver on GitHub · 2026-11-24 10:51 UTC · original
Tested head
ccdecb8merged ontomainffe310e(clean merge) on NVIDIA GeForce RTX 5060 Laptop GPU (Blackwell), driver 621.24, Windows 11 26300, Rust 1.98.1. No game files: the test suite only: pass.srgb_and_linear_views_of_one_texture_read_their_own_curveran on the RTX 5060 (DXGI adapter 0 on this laptop) and passed. So sRGB and linear views of one texture each read back with their own curve on NVIDIA.cargo test --workspace --locked: 343 passed, 0 failed, 6 ignored, against 342 / 6 onmain.cargo clippy --workspace --all-targets --locked -- -D warnings: clean.AI-assisted (Claude Code).
Pull request closed