Repository navigation
Runtime + translator: 64-bit typed image atomics (D3D-251) - #2033
requiemsnkrp wants to merge 7 commits into
Conversation
- Device: VK_EXT_shader_image_atomic_int64 (shaderImageInt64Atomics) enabled where present, recorded in VulkanDeviceInfo::shader_image_int64_atomics; the test device helper enables it too. - Bindless set 0: bindings 26/27, 2D/3D r64ui storage images sized like the r32ui ones, only with the feature (R64_UINT fallbacks), and StorageViews::r64ui. - Layer: R32G32_UINT/SINT/TYPELESS UAV textures (2D, 3D) are mutable with R64_UINT in their format list; their R32G32_UINT/SINT UAV views get an R64_UINT storage view in the r64ui binding. OPTIONS9 AtomicInt64OnTypedResourceSupported follows the device (host RTX 3060 answers TRUE); group-shared and OPTIONS11 stay FALSE. A castable list no longer chains the format list onto itself. - rdna2spirv.py: image atomics with DMASK 0x3 (0xf for cmpswap) are 64-bit (add, sub, smin, smax, umin, umax, and, or, xor, swap, cmpswap) on an R64ui image (Int64ImageEXT, Int64Atomics, SPV_EXT_shader_image_int64); index feature shaderImageInt64Atomics; vk_pipeline_check knows it. - Tests: cs_imgatomic64.asm (vk_store_test words64, LEONIDA_VK_VALIDATION support), d3d12_image_atomic64_test, bindless_sizing_test cases, tests/semantic/test_image_atomics_64.py with its fixture, check.py / run_gpu_tests.py. - Docs: design.md contract row, d3d12_vulkan.md OPTIONS9 / bindings / section 8.2 question 10. AI-assisted.
Flyander
left a comment
There was a problem hiding this comment.
The OPTIONS9 bit is broader than the implementation. Microsoft defines AtomicInt64OnTypedResourceSupported for typed-resource 64-bit integer atomics, and the DXIL 6.6 valid-resource tables include RWTexture3D and typed, raw, and structured buffers. Here the bit is TRUE when shader_image_int64_atomics and bindless are available, but CreateUnorderedAccessView rejects buffer resources and only accepts Texture2D/Texture2DArray. A caller that sees TRUE can therefore request typed-resource atomic forms this layer cannot expose. Please keep the bit FALSE until the advertised typed-resource set is supported, or establish a narrower API contract that justifies returning TRUE. References: https://learn.microsoft.com/en-us/windows/win32/api/d3d12/ns-d3d12-d3d12_feature_data_d3d12_options9 and https://github.com/Microsoft/DirectXShaderCompiler/blob/main/docs/DXIL.rst#L1705-L1755
…w does
main replaced the Vulkan 1.3 feature struct enable13 with vulkan13_features.h, whose next() is where later
feature structs go (it also handles a 1.2 device with the dynamic rendering and synchronization2 extensions).
VkPhysicalDeviceShaderImageAtomicInt64FeaturesEXT was still linked through enable13.pNext, so after the merge
vk_test_device.h no longer compiled ("'enable13' was not declared in this scope"), and neither would the D3D12
shim. Both now use *v13_.next() / *v13.next(), like the FMA and host-copy features next to them.
|
Independent synthetic verification at
Scope: the existing layer and translator synthetic tests above, without source changes. No full-suite or retail-corpus run, and no RDNA2 hardware measurements. |
|
Tested Merged onto current main #1706 ( At its own head (base
AI-assisted (Claude Code). |
Flyander
left a comment
There was a problem hiding this comment.
A fresh current-main build report found a second merge blocker: after merging this head onto 4eb6155, compilation fails because runtime/shims/d3d12_vulkan_device.cpp references enable13 at lines 6421-6422, which #1706 removed. This branch still builds only against its old base. Please rebase and chain the image-int64 feature into the feature chain current main uses before treating the reported head checks as merge-ready.
|
Tested @requiemsnkrp I've opened requiemsnkrp#1 against your branch ( AI-assisted (Claude Code). |
|
Tested
GitHub now reports a conflict with AI-assisted (Claude Code). Synthetic tests only, no game data. |
D3D12 covers typed, raw and structured buffers and 3D textures by that bit, and the layer exposes no buffer UAV and no 3D texture UAV yet (review on ItsNotRexed#2033). The 2D texture path (binding 26) and the translator's 3D one (binding 27) stay in place. AI-assisted.
|
Thanks @Flyander, @crastinator, @itsonlysimbo.
Retested on the RTX 3060 (driver 32.0.16.1714): AI-assisted (Claude). |
|
Tested bb7b345 (on main 6a6704d; the head has since moved to c0dbff1, not re-run) on an NVIDIA RTX 4090 (621.24) and an AMD Radeon iGPU (Ryzen 7000, RDNA2 gfx1036, driver 26.11.2 / Vulkan 2.0.353), Windows 11, MSVC 19.44, Vulkan SDK 1.4.363.0, RelWithDebInfo: pass for this PR.
(AI-assisted test run.) |
Conflicts, both sides kept: - tools/rdna2spirv.py: main reads image-atomic coordinates through a helper that unpacks a16 (two 16-bit ones per VGPR). It becomes the method image_atomic_coords, and image_atomic_64 reads its coordinates through it too, so a 64-bit atomic with a16 gets the same coordinates as a 32-bit one (test_image_atomics_64.test_a16_coordinates). - docs/design.md: main's a16 LOD row and its updated image-atomics row, then this branch's 64-bit row. - runtime/test/bindless_sizing_test.cpp: the r64ui block and main's MoltenVK block. - runtime/test/vk_test_device.h: main's custom border color extension and VK_EXT_shader_image_atomic_int64. - tests/semantic/regen_fixtures.py: cs_cvt_pk_u8 and cs_imgatomic64. - tests/test_shader_checks.py: STORE64_WORDS with main's count of five compute fixtures.
|
Merged
Retested on RTX 3060 with
Full ctest ( AI-assisted (Claude). |
|
The retail 1.0.2.1 census narrows the 64-bit MIMG path to unsigned max on 2D images. I joined the SFI0 flags to the corresponding listings for all 26,503 shaders, then independently scanned every listing using this PR’s 64-bit DMASK criterion (0xf for compare-swap, 0x3 for other image atomics).
All 685 flagged shaders have at least one such site. The other 25,818 shaders have zero wide MIMG atomics by that criterion. All 954 sites specify 2D. Within the flagged set, 681 shaders also use the narrow unsigned-min and OR forms (681 sites each, DMASK 0x1). For coverage, a 2D unsigned-max case with GLC clear exercises the common path (953 sites), and one with GLC set covers the return form seen once. The census establishes operation, width and dimension. The exact DXGI format of the view bound at draw or dispatch is still unmeasured. Counts only, AI-assisted. |
Merged origin/main 98fa503. Nine files conflicted; both sides kept in each: - tools/rdna2spirv.py: main now translates the remaining 32-bit image atomics (swap, inc, dec, fmin, fmax, fcmpswap: IMG_ATOMICS_EXTRA, emit_image_atomic_extra), so this branch's "image_atomic_swap (32-bit)" refusal and its own swap entries in the dispatch lists are dropped for main's; 64-bit atomics still go first through image_atomic_64, and 3D coordinates through image_atomic_coords. Capabilities, extensions and the feature index list both Int64ImageEXT/Int64Atomics and main's ShaderClockKHR / DrawParameters. - runtime/shims/d3d12_vulkan_device.cpp, d3d12_com.h: VK_EXT_shader_image_atomic_int64 and main's VK_KHR_shader_clock are both chained and enabled (the int64 check now uses main's has_device_extension). The shader_image_int64_atomics comment no longer says OPTIONS9 reports the bit: it stays FALSE. - runtime/test/vk_pipeline_check.cpp: both optional features are requested. - runtime/test/vk_store_test.cpp: the 64-bit readback copies, then main's host-read barrier after every copy. - tests/test_shader_checks.py, tests/semantic/regen_fixtures.py: main's counts and fixtures plus this branch's. - tests/semantic/test_image_atomics_32.py: main listed a dmask 0x3 swap among the rejected 32-bit forms; it is this branch's 64-bit swap now, so it is dropped there (the 64-bit form is tested in test_image_atomics_64.py). - docs/design.md: main's rows plus the 64-bit row. docs/d3d12_vulkan.md: main dropped a duplicate open-question row 10; the D3D-251 sentence moved to the remaining row, now saying OPTIONS9 stays FALSE. AI-assisted.
…orm (D3D-251) @Kev-Ball's census of the 1.0.2.1 listings (ItsNotRexed#2033): the game's only 64-bit MIMG atomics are image_atomic_umax on 2D images, 953 of 954 sites without glc. The GPU fixture covered 2D umax only with glc and the no-return form only for add. - cs_imgatomic64.asm: 2D cases 17 to 19, umax dmask:0x3 without glc: the high dword decides 17 (a per-dword max would give 0x0000001300000001) and keeps 19 (0x00000014ffffffff), the low dword decides 18; their data pairs, left alone, are stored to uint/sint texels 22..24. Header table and fills updated; fixture regenerated. - check.py (STORE64_WORDS), tests/test_shader_checks.py: the new words. - test_image_atomics_64.py: test_game_form_umax_2d_without_glc (high / low dword decides, kept, unsigned, inactive lane). AI-assisted.
|
Merged
Re-ran on NVIDIA GeForce RTX 3060, driver 32.0.16.1714, Windows 11, MSVC 19.51, Vulkan SDK 1.4.363.0, validation on:
AI-assisted (Claude). |
|
@Kev-Ball thanks for the census. It changed what the fixture needed to cover. 73eedd6 adds the game's form to
The return form (glc) was already covered by case 8. RTX 3060, driver 32.0.16.1714, Vulkan SDK 1.4.363.0, validation on: The python tests ( I didn't add a pixel-shader 64-bit case. AI-assisted (Claude). |
|
Follow-up on the semantic suite: |
|
Tested 73eedd6 on RTX 5070, driver 616.86, Windows 10.0.26200: pass. Built
|
What and why
D3D-251, layer and translator half (claim). The layer answered
D3D12_OPTIONS9.AtomicInt64OnTypedResourceSupported = FALSEon every GPU and the translator's image atomics were 32-bit only. The corpus count (which instructions and formats the 685ATOMIC_INT64_ON_TYPED_RESOURCEshaders use) is not part of this PR: it needs the game's shaders, and it stays open in §8.2 question 10.VK_EXT_shader_image_atomic_int64(shaderImageInt64Atomics) when present; recorded inVulkanDeviceInfo; the test device helper can enable it.bindless_sizing_testcovers it).R32G32_UINT/SINT/TYPELESSUAV textures (2D, 3D) are created mutable withR64_UINTin the format list (and in the castable list when one is given); an R32G32 UINT/SINT UAV gets an extra R64 storage view in binding 26/27. Also fixes an existing bug where, with a castable list, the image create info could chain the format list to itself.AtomicInt64OnTypedResourceSupportedstays FALSE (review): D3D12 covers typed/raw/structured buffers and 3D textures by it and the layer exposes no buffer or 3D texture UAV yet. Group-shared andOPTIONS11.AtomicInt64OnDescriptorHeapResourceSupportedstay FALSE too (no 64-bit LDS / raw-buffer atomics in the translator). No UAV atomic bit inFORMAT_SUPPORTfor R32G32, as on the host.image_atomic_cmpswap), the only masks llvm-mc 21.1.8 accepts for the 64-bit register counts (reference: LLVMSIISelLowering::lowerImage). Supported 64-bit, 2D and 3D: add, sub, smin, smax, umin, umax, and, or, xor, swap, cmpswap; VGPR pair low dword first,glcreturns the old value. EmitsInt64ImageEXT,Int64Atomics,SPV_EXT_shader_image_int64; the index listsshaderImageInt64Atomics. Not done:inc/dec, 2D arrays. Contract row added indocs/design.md.Host probe (RTX 3060, NVIDIA 32.0.16.1714, with and without the debug layer)
SM 6.8;
OPTIONS1.Int64ShaderOps1;OPTIONS9.AtomicInt64OnTypedResource1,AtomicInt64OnGroupShared1;OPTIONS11.AtomicInt64OnDescriptorHeapResource1;FORMAT_SUPPORTSupport2 R32G32_UINT 0x3c0, R32G32_SINT 0x2c0 (no UAV atomic bit); R32G32_UINT/SINT/TYPELESS UAV textures 2D and 3D create with S_OK, their UAVs without debug-layer messages.Tested (RTX 3060, driver 32.0.16.1714, Windows 11, MSVC 19.51, Windows SDK 10.0.26100, Vulkan SDK 1.4.363.0, llvm-mc 21.1.8)
cs_imgatomic64.asm(hand-written RDNA2) throughvk_store_test words64withLEONIDA_VK_VALIDATION=1, judged bycheck.py: pass, 0 validation errors. 17 cases on an 8x8 image (carries/borrows across the halves, min/max and compare cases a per-half version gets wrong, no-glc, 63 lanes off, 64 threads adding to one texel) and 6 on a 4x4x4 volume. Fullcheck.py: 123/158 pass, 35 skipped, 0 fail.d3d12_image_atomic64_test(new) with validation: OPTIONS9 FALSE without the extension and TRUE with it; 64-bit add, max, compare-exchange, exchange through binding 26 on UINT, SINT, TYPELESS and castable UINT 2D textures: 16/16 texels and returned values exact, 0 validation errors.bindless_sizing_test: pass with the 26/27 cases. Semantic suite: 1653 tests OK (2 skipped); newtests/semantic/test_image_atomics_64.py(9 tests) fails if the dword order is swapped.tests/test_shader_checks.py,compileall,regen_fixtures --check: clean.d3d12_compute(line 515,device_proxy_ref_count(device.p) == 1) andd3d12_draw(bundle blend pixel 127,0,127,255, expected red 64) fail the same way onorigin/main6a6704d without this branch, so they are not from this PR.Not checked through D3D12: binding 27 (the layer creates no 3D UAV views yet, an older limitation); it is covered by the GPU and semantic tests. Not run on RDNA2 hardware.
No game files used. AI-assisted (Claude).