Repository navigation
Runtime: typed buffer UAVs and UAV counters (typed V#, counter V#; checked against the same adapter's D3D12) - #1858
Merged
Conversation
…copy queues; buffer UAV views and indirect dispatch state d3d12_m4_compute_test, through the proxy with D3D12 API only and two translator-output compute shaders (cs_m4_fill.asm, cs_m4_indirect.asm): a COPY queue streams an input buffer in, a COMPUTE queue waits on it and runs a compute PSO over a UAV table (structured buffer, raw buffers, an R32_UINT RWTexture2D), then ExecuteIndirect of a second PSO from arguments the first wrote (with a transition to INDIRECT_ARGUMENT and UAV barriers), and a COPY queue behind a cross-queue fence reads the results back. 1,924 words match the CPU reference with error 0. Layer gaps the test found, fixed: - CreateUnorderedAccessView of a buffer was a stub: structured and raw views are now a V# in the slot. - ExecuteIndirect of a dispatch ran whatever pipeline and root arguments the command buffer had bound; the command now carries the list's, as Dispatch does. - An image created in UNORDERED_ACCESS and first used by a shader was zero-filled by the first barrier or copy that named it, losing the shader's writes; images with a UAV view are now moved to GENERAL (zeroed) at the next submission. - COMPUTE and COPY command lists no longer log "unimplemented". Test infrastructure: vk_test_device.h can create more than one VkQueue; build.py gives a compute shader's FSSM program extra words (fssm-at/fssm-data from 0x148) so two compute shaders with the same group size get distinct hashes, and honours LEONIDA_SPIRV_TOOLS (as ItsNotRexed#1679) so the target builds under the Visual Studio generator. docs/d3d12_vulkan.md section 6: M4 synthetic part met; M3 row credits @whattheflop's ItsNotRexed#1584 measurement of fences in flight. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ions, ordered for other queues - The zero-fill/GENERAL init of images with a UAV view no longer drains on a copy queue or in a submission that runs no dispatch or draw; every other queue's next submission waits on the initializing one's progress semaphore. - storage_pending_ is a set (UAV descriptors are rewritten every frame). - write_buffer_uav: FirstElement and element count are checked against Width / unit, so the byte range cannot overflow. - docs: M4 row names the remaining limitation. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…# in the slot), d3d12_buffer_uav_test CreateUnorderedAccessView on a buffer with a typed Format writes a typed V# (GFX10_FORMAT code, element size as stride, element count, OOB_SELECT structured, the format's own DST_SEL), and a structured view with pCounterResource + CounterOffsetInBytes writes a second raw 4-byte V# in the upper 16 bytes of the slot (a hypothesis for the console contract, documented in section 3.4). The combinations D3D12 documents as invalid leave a null slot. d3d12_buffer_uav_test runs two hand-written RDNA2 compute shaders through the translator (typed store/load/atomic on five formats with NUM_RECORDS as the bound; append by 256 lanes and consume by 128 on a counter at offset 4096, read back with CopyBufferRegion) against a CPU reference, then compares typed-buffer and counter clears with the host D3D12 runtime on the same adapter (LUID). Depends on: ItsNotRexed#1791 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…-typed-counter # Conflicts: # docs/d3d12_vulkan.md # runtime/shims/d3d12_vulkan_device.cpp
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Author
|
Update on the counter hypothesis: @Vonsek's #1811 measured the whole corpus (SHADER-65). The game uses no append/consume counters (0 of 445,394 PSV0 records, no #1811 also shows that the format of every formatted MUBUF access comes from the descriptor the executable writes (88,924 of 90,316 from a scalar load). That makes the translator's AI-assisted (Claude Code). |
3 tasks done
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.
What and why
Depends on: #1791. This is stacked on M4; until #1791 lands, the diff also shows M4.
Claimed in #1548. M4 left two kinds of buffer UAV stubbed: views with a typed format, and the counter of a structured view.
Typed buffer UAVs:
CreateUnorderedAccessViewon a buffer with a typedFormatnow writes a typed V#:buffer_load_format,buffer_store_formatandbuffer_atomicin a translatedRWBuffer<T>reach it. Formats the layer can't express get a null slot and a log line: typeless, 96-bit, compressed, codes ≥ 128, and formats without a Vulkan mapping. Typed clears (ClearUnorderedAccessViewUint/Float) already worked from the V# and work on the new views too.UAV counters: a structured view with
pCounterResource+CounterOffsetInByteswrites a second, raw 4-byte V# into bytes 16..31 of its slot. The combinations D3D12 documents as invalid leave a null slot. D3D12 has noCopyStructureCount(that's D3D11); the app copies the counter withCopyBufferRegion, which already works.Honest limit, the counter contract is a hypothesis: the corpus has no GDS instruction and the translator no
ds_append/ds_consume, so append/consume must be atomics on a counter in memory. Where a console shader finds that counter's V# isn't measured yet. It could be a second slot, a user SGPR pair or a spill. That's written down in §3.4 "Buffer UAVs" and in open question 16. If the console uses a different place, onlywrite_buffer_uavchanges.New test
d3d12_buffer_uav_test. Two hand-written RDNA2 compute shaders go through the translator:cs_buf_typed: typed stores, loads and an atomic on R32_UINT, R16G16B16A16_FLOAT, R8G8B8A8_UNORM (from FirstElement 16) and R32G32B32A32_UINT, plus an R32_FLOAT → R32_SINT copy. Two views are shorter than the dispatch, so out-of-range stores leave the sentinel and out-of-range loads read 0.cs_buf_counter: 256 lanes append and 128 consume on a counter at offset 4096. The counter is read back withCopyBufferRegion(256, then 128), and the records are compared as sets.Both are compared with a CPU reference. In addition, typed-buffer and counter clears on 13 formats are compared with the host D3D12 runtime on the same adapter (LUID match).
Known differences, not covered: the clear values avoid exact .5 ties and integers wider than their channel. There the RTX 5070's own D3D12 rounds down and clamps, while the layer rounds up and keeps the low bits; same class as #1616. The translator's
FORMATSstill lacks the 8/16-bit SINT/UINT formats (other than RGBA8/RGBA16 UINT) and 10_11_11, so shaders reading those views get zeros. That's a follow-up.Tested
Head
4d9372d4, Windows 11, MSVC 17.14:d3d12_buffer_uavpasses, 21,394 values, error 0, with the host being the same 880M.LEONIDA_VK_VALIDATION=1: 0 VUIDs.d3d12_m4_computepasses.d3d12_buffer_uavpasses, 21,394 values, error 0, with the host being the same 5070. No validation errors.mainwithout this change:d3d12_draw, since Runtime: carry bundle blend factors back to parent draws #1660;d3d12_vulkan_device, the tiled sizes from d3d12: support tiled placed textures (D3D-191) #1674; see the note there.tests/test_ctest_registration.pyandtests/test_shader_checks.py: 62 passed.Checklist
SKIP_RETURN_CODE 77); fixtures inrun_gpu_tests.py's D3D12-harness listdocs/d3d12_vulkan.md: §3.4, known gaps, M4 row, question 16FORMATSgap (follow-up)AI-assisted (Claude Code).
🤖 Generated with Claude Code