Repository navigation
d3d12: depth-stencil UAVs for console D16S8 (format 118) made as D24S8 - #2123
Merged
Merged
Conversation
On GPUs with native VK_FORMAT_D24_UNORM_S8_UINT attachments (NVIDIA), pc_format() maps Xbox format 118 (D16_UNORM_S8_UINT) to DXGI_FORMAT_D24_UNORM_S8_UINT before Resource construction. Previously, Resource::enable_depth_stencil_uav only accepted R16_TYPELESS, 118, and R32G8X24_TYPELESS, returning E_INVALIDARG so slots 76 and 133 fell back to creating the texture without unordered access (ProjectLeonida#1558). Track console format 118 origin on Resource before pc_format(), extend enable_depth_stencil_uav and CreateUnorderedAccessView to serve D24S8-made 118 through the existing widened R16_TYPELESS (R16_UINT/R16_UNORM views) plus R8_UINT storage planes and R32_FLOAT conversion image, and convert plane-0 D24 depth words in transfer scratch to/from R32_SFLOAT via the existing Depth24Converter compute pass in copy_depth_uav. Add VK_BUFFER_USAGE_STORAGE_BUFFER_BIT to copy scratch, accept D16S8/D24S8 castable lists in castable_view_formats, and keep ProjectLeonida#1558's refusal fallback in d3d12_xs_device.cpp for any other provider refusal. Replace xbox_d16s8_refused_uav with xbox_d16s8_d24_storage covering slot 76 6-layer round-trips, slot 133 1280x720 placement, CreateCommittedResource3 castable formats, R16_UNORM/R16_UINT/R8_UINT UAV clears, and direct D24S8 parent attachment readback. Verified on Windows 10 19045 / GeForce GTX 1050 Ti (NVIDIA 582.66): 17/17 related CTests pass plain and with LEONIDA_VK_VALIDATION=1 (0 validation errors). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aced path Follow-up review fixes for D24S8-made Xbox D16S8 (format 118) depth UAVs: - Pass the console origin (recorded before pc_format()) into castable_view_formats() instead of widening on format.d24, so a plain PC D24_UNORM_S8_UINT texture keeps main's castable-format rules and refuses the R16/R8/118-120 depth-UAV views. - Set mark_console_d16s8() in create_placed() as well as create_committed(). CreateReservedResource refuses format 118 before it makes anything (a stencil format has no tile shape), so it needs no mark. - Extend xbox_d16s8_d24_storage to cover slot 127, incompatible castable views, plain PC D24S8 castable/UAV refusal, CreateCommittedResource2, CreatePlacedResource/2, and the CreateReservedResource refusal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
create_placed turns a console D16S8 (format 118) description into its PC
format before committed_resource_refusal, but left the clear value as
118, so the clear format's family no longer matched the resource's and
every placed format-118 depth texture with a clear value was refused
("clear value"), with D24S8 backing. The clear value now goes through
pc_format() too, as the description does. Found by
xbox_d16s8_d24_storage's CreatePlacedResource case on a GTX 1050 Ti.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
JordanWebDev
approved these changes
Nov 25, 2026
Collaborator
|
Merged, thanks! Depth-stencil UAVs for the console's D16S8 (format 118) now work when it is stored as D24S8.
AI-assisted (Claude Code, Claude Opus 5.5). |
Kokonotcu
added a commit
to Kokonotcu/leonida
that referenced
this pull request
Nov 26, 2026
12 upstream commits after ad41fd5, all taken: ProjectLeonida#2123 (D16S8 as D24S8: castable widening only for format 118, CreatePlacedResource takes its clear value, the depth-UAV copy path in vulkan_replay.h reworked, with its xbox_depth_storage tests), ProjectLeonida#1662 (rdna2spirv: the backward re-anchor also restores a signed-byte dot4's stored op_sel_hi, as the forward search does), ProjectLeonida#2160 and ProjectLeonida#2177 (typed image-load and texture-array test models), ProjectLeonida#2159 (gameinput test reads the pad before expecting a scripted press to end). No conflict; every line the merge removes from our side is one of upstream's own (checked against the merge base, D:\GTA6\analysis\lostlines.sh). The corpus is to be translated again with this rdna2spirv. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Item:
RT-D16S8-D24-UAV(follow-up of #1558)Problem
Where console D16S8 (format 118) is made as
D24_UNORM_S8_UINT(LEONIDA_CONSOLE_D16S8=d24, the default on every NVIDIA GPU),Resource::enable_depth_stencil_uavrefuses the texture withE_INVALIDARG. Since #1558, slots 76 and 133 then make it withoutALLOW_UNORDERED_ACCESS, so the title's R16/R8 UAVs over those depth planes have nothing behind them.Change
enable_depth_stencil_uavtakes a D24S8 texture that came from format 118 (Resource::console_d16s8_, recorded increate_committedandcreate_placedbeforepc_format()), with the storage planes of the widened D16S8 path:R16_TYPELESS(mutableR16_UNORM) for depth,R8_UINTfor stencil, and anR32_FLOATconversion image.copy_depth_uav(runtime/src/vulkan_replay.h) moves depth between the D24 aspect and the 16-bit plane asD24 words (scratch) -> Depth24Converter -> R32_FLOAT -> vkCmdBlitImage(NEAREST) -> R16_UNORM, and the reverse when the UAV state ends; stencil is copied directly.Depth24Converter(depth24_convert.comp) is used unchanged. Across all 65,536 16-bit values the round tripu -> u/65535 -> D24 -> float -> round(f*65535)gives backuexactly.CreateUnorderedAccessViewacceptsR16_UINTandR16_UNORMon plane 0 of such a texture,R8_UINTon plane 1.castable_view_formatsallows the D16S8/R16/R8 view formats only for textures made from format 118; a plain PCD24_UNORM_S8_UINTtexture keeps main's rules.enable_copy_scratchaddsSTORAGE_BUFFERusage so the copy scratch can be the converter's buffer.VulkanContext::has_depth24()reports whether the converter exists.CreateReservedResourcealready refuses format 118 (a stencil format has no tile shape), so it needs no change; the test checks that it still does.create_placedturned a format-118 description into D24S8 beforecommitted_resource_refusalbut left the clear value as 118, so every placed format-118 depth texture with a clear value was refused ("clear value") on D24S8 backing, with or without UAV access. The clear value now goes throughpc_format()too.Testing
Windows 10 Pro 19045, GeForce GTX 1050 Ti (Pascal, 4 GB;
D24_UNORM_S8_UINTattachments yes,D16_UNORM_S8_UINTno), NVIDIA 582.66, MSVC (VS 18 Build Tools), RelWithDebInfo, base9f9a7c5f3.xbox_d16s8_d24_storage(replacesxbox_d16s8_refused_uav): slot 76 six-layer DSV clear with legacy and enhanced UAV transitions and anR16_UINTUAV clear, read back exactly (6,144 depth words, 6,144 stencil bytes); slot 133 and slot 127 placements keepALLOW_UNORDERED_ACCESSand resolveR16_UINT/R16_UNORM/R8_UINTdescriptors to the storage planes;CreateCommittedResource2/3andCreatePlacedResource/2with format 118, clear values and castable lists; plain PC D24S8 refusing the R16/R8 castable views and the UAV; the parent D24S8 attachment read back afterR16_UNORMfloat,R16_UINTandR8_UINTUAV clears. On main the same checks fail at slot 76 (the depth provider refused ... format 118, hr=0x80070057).9f9a7c5f3(16 there; the extra one isxmem, flaky on this host).xmem,xmem_no_write_watchandxmem_write_watchpass 5/5 each on this branch.LEONIDA_VK_VALIDATION=1:d3d12_depth_stencil_uav,xbox_depth_storage,xbox_d16s8_storage,xbox_d16s8_d24_storage,xbox_d16s8_surface,xs_proxy_mock*(9),device_proxy*(2),d3d12_xmem_placed: 17/17 pass, no validation messages.Overlap: #695 also touches the R16 depth UAV view code in
d3d12_vulkan_device.cpp(normalized views for plain D16); different case, a small textual conflict is possible. #1716 fixes the sameRef = {}leak in tests generally; this PR only usesreset()in the test it changes.AI-assisted (Claude Code, Opus 5.5, with Antigravity / Gemini 4 Neon for the first draft of the code; reviewed, and the reserved-path change dropped by hand).
🤖 Generated with Claude Code