Repository navigation
D3D12.X: sRGB textures with unordered access are typeless on the PC - #3626
Draft
CharlyRien wants to merge 1 commit into
Draft
CharlyRien wants to merge 1 commit into
CharlyRien wants to merge 1 commit into
Conversation
The console lets a title create an R8G8B8A8_UNORM_SRGB / B8G8R8A8_UNORM_SRGB texture with unordered access and write it through a UNORM UAV. The PC has no sRGB UAV: pc_resource_desc dropped ALLOW_UNORDERED_ACCESS and every such UAV was a null view. A retail title's hair pass writes its colour that way: the hair kept its strands but lost its volume (one saw through it). With XCL_SRGB_TYPELESS (default on, =0 for the old behaviour) such a texture is created in the TYPELESS family with unordered access. SRVs, RTVs and clears keep the title's sRGB format (null and UNKNOWN views too), UAVs are UNORM; a view with an explicit typed format of the family (UNORM, UINT, SNORM, SINT) keeps it. B8G8R8X8 sRGB is never made typeless (no typed UAV of its sibling on the PC). A live counter keeps the table's locks off resource release and view creation while no such texture lives. Found by Jockerino (the retail title's hair, written through a UNORM UAV of an sRGB texture). Same approach as VIctory (GPL-3.0, credited in THIRD_PARTY.md) and amd-dev's opt-in XCL_SRGB_UAV (a68f609). Assisted-by: Codex CLI (GPT-6.2 Sol) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
|
Review (head 45fbb07, diff read, not a merge-check; draft):
Fine: the device check falls back to the old desc when the UNORM sibling has no typed UAV; AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point. |
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The console lets a title create an
R8G8B8A8_UNORM_SRGB/B8G8R8A8_UNORM_SRGBtexture with unordered access and write it through a UNORM UAV. The PC has no sRGB UAV:pc_resource_descdropsALLOW_UNORDERED_ACCESSfrom such a texture, and every UAV of it is a null view, so what the title writes there is lost. On the retail title the hair keeps its strands but loses its volume: one sees through it.With
XCL_SRGB_TYPELESS(default on,=0for the old behaviour) such a texture is created in the TYPELESS family with unordered access. SRVs, RTVs and clears keep the title's sRGB format (null andUNKNOWN-format views too), UAVs are UNORM; a view with an explicit typed format of the family (UNORM, UINT, SNORM, SINT) keeps it.B8G8R8X8sRGB is never made typeless (its sibling has no typed UAV on the PC). A live counter keeps the table's locks off resource release and view creation while no such texture lives.Found by Jockerino, who traced the retail title's see-through hair to this (the hair pass writes an sRGB texture through a UNORM UAV). Same approach as VIctory's (https://github.com/Marvisak/VIctory, GPL-3.0; credited in
THIRD_PARTY.md) and amd-dev's opt-inXCL_SRGB_UAV(a68f609). Related: #3291 makes placed and reserved resources drop the UAV flag the way committed ones do; this PR keeps the flag instead (the two meet inpc_resource_desc_for_device; whichever lands second needs a small rebase).What is in it
d3d12x/device_x.rs: the typeless description, the PC formats of views and clears of such textures.d3d12x/real.rs: the table of typeless sRGB textures (SRGB_TEXTURES, live counter), SRV / RTV / UAV / clear formats, forgetting on release.d3d12x/bind.rs,present.rs: target matching and frame dumps use the title's format, not the typeless one (console_format_of);title_textures.rs: the GPU-owned layout check accepts the typeless storage of an sRGB texture.README.md: the switch.srgb_typeless_views_keep_the_titles_explicit_formats,srgb_uav_resource_desc_selects_typeless_only_for_eligible_textures,srgb_uav_clear_value_keeps_the_title_format,srgb_typeless_views_use_typed_defaults_and_keep_explicit_ranges,gpu_owned_metadata_accepts_exact_colour_layouts_only,gpu_srgb_typeless_uav_clear_and_copy_to_srgb).Tested
45fbb070on main1c8b5514.XCL_REQUIRE_GPU=mesh), withXCL_SRGB_TYPELESSunset and=1: 6 passed, 0 failed, no SKIPPED, both times.R8G8B8A8_UNORM_SRGB).Regression run
scripts/smoke.ps1, 60 s, the retail title,XCL_PREPARE=0, cold shader cache on every run, two runs a side, alternating (head, main, head, main): main1c8b5514480 and 503 frames, this head 345 and 496; peak commit 16,183 / 16,186 MB vs 16,041 / 16,389 MB; no removal, no crash. The 345 lost its frames at the start (after the title's first frames, one 2 s window with no present and two slow ones; steady 60 a 2 s afterwards, as the others); the second pair is 496 vs 503 (99 %). Blocks of the second pair:Not tested
XCL_SRGB_TYPELESS=0in the game (the old behaviour).AI use