Repository navigation
RT-303: typed B8G8R8X8 textures with unordered access through a castable-format list - #4581
SpositoDouglas wants to merge 4 commits into
Conversation
|
Verified PR #4581 on Windows 11 (25H2
Change looks solid: AI-assisted (Gemini, Antigravity). |
Flyander
left a comment
There was a problem hiding this comment.
The placed-allocation and actual-creation paths need to build equivalent VkImageCreateInfo values for castable resources. The allocation path currently omits the list-presence flag, so its memory requirements can differ from the image later bound into the heap.
| VkMemoryRequirements need{}; | ||
| const TextureCreateInfo create(resolved, format, state_.color_attachment_usable(format.format)); | ||
| // castable_uav only changes a B8G8R8X8 texture's usages here; the other castable rules stay as before. | ||
| const TextureCreateInfo create(resolved, format, state_.color_attachment_usable(format.format), false, |
There was a problem hiding this comment.
[P2] Include castable-list usage in allocation requirements. For a B8G8R8X8_UNORM_SRGB resource with ALLOW_UNORDERED_ACCESS and a castable B8G8R8A8_UNORM view, this passes castable_list=false. TextureCreateInfo therefore omits STORAGE and EXTENDED_USAGE here, while Resource::create_texture() passes !castable.empty() and includes them. vkGetImageMemoryRequirements is then queried with a different image create-info than the image that is actually bound, so placed-resource size/alignment/type requirements are not guaranteed to match. Please pass the list-presence condition (or build the same create-info as the creation path) and assert exact allocation requirements in the placed castable-sRGB test.
There was a problem hiding this comment.
Fixed in 419dde0.
allocation()now takes the castable list and builds the same image ascreate_texture: the same usages and the same view-format list. The two sharelist_view_formats, andcreate_committed_validatedandcreate_placedpass their list.d3d12_vulkan_device_testchecks twelve castable textures, committed and placed, through a test hook (rt::d3d12::castable_allocation_info). The sRGB ones are among them:allocation()refuses exactly what creation refuses, and otherwise the size, alignment and memory types equal the created image's.
Measurements and the rest are in #4581 (comment). Could you take another look when you have time?
Kam471
left a comment
There was a problem hiding this comment.
Built and ran d3d12_vulkan_device_test at de466a29 on Windows 11, RTX 5070 Ti (host D3D12 available): exit 0.
B8G8R8X8: typed UAV support and UAV/RTV resource creation match the host runtime.- The new refusals appear in the log:
B8G8R8X8 textures cannot allow unordered access; format 88/93,unordered-access view of a B8G8R8X8 texture in a format its castable list doesn't give it; format 88/28, plus the existing allocation/format/feature comparisons (0 mismatches).
The change keeps typed UAVs on the castable list for these X8 formats and refuses only the view/description shapes the host refuses. git diff --check clean. No blocking issue.
|
Merges cleanly with 3faac55 and every docs/Python guard passes on the merged tree (cli_flags, repo_paths, design_rows, env_vars, links, tables — re-run). The device_test additions and the WARP/AMD creation-and-clear claims need cmake and a GPU, so they were not exercised here; the docs carve-outs (shader stores unchecked, storage-less GPUs skip) read as an honest scoping of what is proven. Checks pending — the linux-gpu-tools run carries the functional verdict. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only review). |
|
Tested de466a2 on Intel UHD 770 ("Intel(R) UHD Graphics 770", validation on), MSVC 19.44, with the Khronos validation layer loaded: d3d12_vulkan_device_test and d3d12_clear_test both exit 0 with 0 validation errors, after a fresh build of both. The new block prints "B8G8R8X8 with unordered access: 10 castable lists created or refused, 6 UAV views given or refused, and B8G8R8A8 UAV clears matched the bytes WARP and AMD's D3D12 driver store (no host here can cast)". On main 3faac55, built the same way, both tests also exit 0 and the B8G8R8X8 block does not exist. On NVIDIA GeForce RTX 4080, driver 617.42, the same head fails: d3d12_vulkan_device_test exits 1 with "B8G8R8X8 UAV clear 1 row 0 byte 0: ours 33, host 00" (bytes 1 to 3 read 22, 11 and 44 against host 00) and "line 7873: differences == 0". d3d12_clear_test, which this PR does not touch, also exits 1 on the RTX 4080 with "5 color/depth format(s) differ from WARP"; it passes on the UHD 770 at this head and on main. I did not run main on the RTX 4080, and I do not know why the host side reads 00 there. AI-assisted. |
…the host does (D3D-466) Typed R8G8B8A8_UNORM_SRGB, B8G8R8A8_UNORM_SRGB, D32_FLOAT and D16_UNORM have no UAV view in D3D12 without a castable-format list, so their UAV-flagged images no longer get VK_IMAGE_USAGE_STORAGE_BIT, which these Vulkan formats lack. The host creates them; the layer refused them (sRGB on NVIDIA, all four on AMD). The test this adds also showed what the storage bit had been refusing by chance: the host refuses unordered access on D24_UNORM_S8_UINT and D32_FLOAT_S8X24_UINT, and any volume texture in a depth format (with or without flags). Both are now refused explicitly, in creation and GetResourceAllocationInfo alike. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…able-format list A typed B8G8R8X8 texture with ALLOW_UNORDERED_ACCESS is valid on the host when its castable-format list names a format with a typed UAV (B8G8R8A8_UNORM, R8G8B8A8_UNORM, R8G8B8A8_UINT, R32_UINT): WARP and AMD's D3D12 driver create it, committed or placed, and refuse it without a list or with one naming only sRGB or B8G8R8X8 formats. Through a B8G8R8A8_UNORM UAV both drivers store the alpha in the X byte, byte for byte alike. The layer refused every such texture in texture_format and every UAV view of the family. texture_format and allocation now take whether the list names a format with a typed UAV; the BGRA8 image then gets storage usage, with mutable format and extended usage so a B8G8R8X8_UNORM_SRGB texture's sRGB image need not take storage writes itself, and bind_image keeps that image's views in formats without storage to sampling. CreateUnorderedAccessView takes a listed B8G8R8A8_UNORM or one-channel 32-bit format. A UAV in B8G8R8X8, in an unlisted format, or in the other channel order stays refused: the bindless set's storage view takes the image's order, so an R8G8B8A8 UAV would store red and blue swapped. d3d12_vulkan_device_test creates ten such textures, committed and placed, and compares the answers with the measured ones and the host's; checks which UAV views get a descriptor; and clears through a B8G8R8A8_UNORM UAV (float, uint, and a float rectangle over the uint clear), comparing the bytes, the X byte included, with the measured ones and WARP's: NVIDIA's D3D12 driver reads 00 after the uint clear (RTX 4080, 617.42), where WARP and AMD's driver store the values' low bits. It skips where BGRA8 has no storage images. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Say that a typed B8G8R8X8 texture allows unordered access when its castable-format list names a format with a typed UAV, as on WARP and AMD's D3D12 driver; how the layer creates its image and which UAV views it takes; and what is left: UAVs in the other channel order, shader stores through these views (only clears are checked), and GPUs whose BGRA8 has no storage images. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…makes them allocation(), which committed and placed creation check a texture against, built its image without the castable-format list: no view-format list, and castable_list false, so its usages could differ from those of the image create_texture makes (Flyander on ItsNotRexed#4581). On an RX 9060 XT (AMD Software 26.11.2) the Vulkan size and alignment came out the same with and without the list for every castable texture that creates, at 64x64 and with full chains at 256x256 and 2048x2048. But an R8G8B8A8_UNORM_SRGB or B8G8R8A8_UNORM_SRGB texture with unordered access and a list naming its UNORM format was sized without storage usage and accepted, then refused at creation, whose image has it. allocation() now takes the list and builds the image as creation does. list_view_formats, shared with create_texture, adds the texture's own format and the R9G9B9E5 pair to the view-format list and chains the list once: an R9G9B9E5 texture's image already has it chained, and creation used to chain it to itself. create_committed_validated and create_placed pass their list. castable_allocation_info, a test hook, gives what allocation() answers for a texture with a list and the requirements of the image it sizes. d3d12_vulkan_device_test creates twelve such textures, committed and placed, and checks that allocation() refuses exactly what creation refuses and otherwise has the created image's size, alignment and memory types. With the old allocation() the four sRGB ones fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
de466a2 to
419dde0
Compare
|
Rebased onto main Two changes beyond the conflicts, both because main changed around this code:
@Flyander, thanks. The two paths did build different images. I measured on the RX 9060 XT first, against the created images:
Fixed in
Those sRGB textures are still refused on this GPU, now by both paths, because their sRGB image can't take storage writes. Giving that image extended usage, as this PR does for B8G8R8X8, would let them be created. That is #4493's rule, so I left it. @gertify, thanks for the RTX 4080 run.
Thanks also to justr4mzi (RX 6700 XT), Kam471 (RTX 5070 Ti) and memorypressure for the runs and the reads. Tested again on the RX 9060 XT (AMD Software 26.11.2):
AI-assisted (Claude Code). |
|
Independent Windows check of 419dde0d with the #4493 changes carried by that revision. RTX 3080 Ti, NVIDIA 621.35, MSVC 19.44, Vulkan SDK 1.4.363.0. In a focused Coverage was creation for both formats and clear readback for B8G8R8A8. I compared clear bytes with WARP, so this run leaves the earlier RTX 4080 native clear comparison open. AI-assisted. |
Claimed in the coordination issue as: RT-303 (claim: #4421 (comment))
Depends on: #4493 (D3D-466). This branch is built on its commit, which shows here until #4493 merges; the three commits of this PR are the last three. It uses the
castable_listargument #4493 givesTextureCreateInfo. #4493 has conflicted with main since #3781 merged, so the copy of its commit here is rebased onto main: its two helpers and #3781'srgba8_any_orderare added at the same place.What and why
A typed B8G8R8X8 texture with
ALLOW_UNORDERED_ACCESSis valid on the host when its castable-format list names a format with a typed UAV. The layer refused every such texture (texture_format) and every UAV view of the family (CreateUnorderedAccessView). This is the follow-up #3252 named.Now:
texture_formattakes whether the list names a format with a typed UAV, committed and placed, the placed heap fit (min_placed_texture_bytes) included.allocation(), which both creations check the texture against (create_committed_validated,create_placed), takes the castable list itself and builds the image creation makes: the same usages and the same view-format list (list_view_formats, shared withcreate_texture). Before, it sized the image without the list (Flyander's review below).lists_typed_uav_formatcounts the formatsCheckFeatureSupportreports withTYPED_UNORDERED_ACCESS_VIEW: a typed colour format, not sRGB, depth or B8G8R8X8, whose image can take storage writes.bind_imagekeeps that image's views in formats without storage to sampling (VkImageViewUsageCreateInfo).CreateUnorderedAccessViewtakes a UAV in a listed B8G8R8A8_UNORM or one-channel 32-bit format.Still refused: a UAV in B8G8R8X8 itself, in a format the list doesn't name, and in the other channel order (R8G8B8A8_*). The last one because the bindless set's storage view takes the image's channel order (
bind_image,vulkan_view_format), and the translator'simage_storewrites the components in order, without the T#'s DST_SEL, so an R8G8B8A8 UAV of the BGRA8 image would store red and blue swapped. Whether the console applies a T#'s swizzle to image stores isn't measured. The same question applies onmainto an R8G8B8A8 texture with a B8G8R8A8 UAV through a list, which this PR doesn't touch.Measured on the host before changing anything:
CreateCommittedResource3withALLOW_UNORDERED_ACCESS, on WARP and on an RX 9060 XT with AMD's D3D12 driver (26.11.2). The two answer identically, byte for byte.Through a UAV in the listed format, with every texel starting as bytes 10, 20, 30, 40:
ClearUnorderedAccessViewFloat, same valueClearUnorderedAccessViewUint(0x11, 0x22, 0x33, 0x44)The alpha lands in the X byte, the same on both drivers. A texel the store doesn't touch keeps its bytes.
Tested
main561b65a8+ d3d12: sRGB and depth-only textures with unordered access created as the host does (D3D-466) #4493 (rebased) + this PR.d3d12_vulkan_device_test, new block:ClearUnorderedAccessViewUintcopies each value's low bits into its channel, as WARP and AMD's driver do. NVIDIA's D3D12 driver reads 00 there (RTX 4080, 617.42, reported below).rt::d3d12::castable_allocation_info).allocation()refuses exactly what creation refuses, and otherwise has the created image's Vulkan size, alignment and memory types. The textures:create_committed_validatedchange reverted, the six committed ones fail.allocation(), the four sRGB textures fail the sizing check: allocation given, creation E_INVALIDARG.ctest --test-dir runtime\build -C RelWithDebInfo: 232/237, the same withLEONIDA_VK_VALIDATION=1. Four of the failures fail the same way on mainf6c6d11e:vk_queue_query_sync;d3d12_texture_tiles;d3d12_indirect_dispatch_count;d3d12_pipeline_library_host.d3d12_sparse_queue_family_contract, is a crash invkDestroyDeviceunderapi_dumpand validation. It comes and goes, and happens at the previous head too, in 2 of 3 runs.d3d12_vulkan_device_test,d3d12_clear_test,d3d12_descriptor_test,d3d12_uav_clear_test,d3d12_r9g9b9e5_uav_test,typeless_rtv_test: pass, with and without validation, with no validation messages.LEONIDA_HOST_ADAPTER=warp,d3d12_vulkan_device_teststops here atcompare_invalid_arguments(line 5571), before this block. Those calls have no castable list, so this PR's changes don't reach them.run_gpu_tests.pywere not rerun.Checklist
docs/design.md, with how it was confirmed. (No translator change.)AI-assisted: written with Claude Code; reviewed and tested by me.
No game data, keys or decryption involved.
🤖 Generated with Claude Code