Repository navigation
Runtime: GFX10 descriptor codec, bindless set 0 and CopyDescriptors (M2, first part) - #230
Conversation
…ings) docs/d3d12_vulkan.md section 5.3 asks for a C++ decoder of the structures the shaders read from descriptor heaps, and section 3.4 for the layer to write them in Create*View and CreateSampler. runtime/src/gfx10_descriptors.h is that piece, as a header with no Windows dependency; nothing uses it yet. - T# (image, 8 dwords), S# (sampler, 4) and V# (buffer, 4): encode from and decode to plain structs. Field positions are Mesa's register database (src/amd/registers/gfx10-rsrc.json, the gfx103 types), enum values its gfx6.json, and what goes where follows ac_descriptors.c and radv. They agree with what the translator reads: T# FORMAT at word 1 bits 28:20, the V# base, stride, NUM_RECORDS, FORMAT and DST_SEL. - Only what a Vulkan view or sampler needs is encoded; tiling, compression metadata and tuning fields are written as zero and ignored when decoding. - decode refuses dwords whose TYPE is not an image's (so a V# in a 32-byte heap slot is told apart), a reserved DST_SEL, and ranges that end before they start. - Format table: GFX10_FORMAT code <-> VkFormat with each format's channel order as a DST_SEL (BGRA8 is 8_8_8_8 read as Z, Y, X, W), the view format for a T# on an image, DST_SEL -> VkComponentMapping, S# -> VkSamplerCreateInfo, T# type -> VkImageViewType (a cube is a 2D array, as the translator samples it). Tests: gfx10_descriptors_test (ctest, Vulkan headers only): every field alone at its bit position, round trips, refusals, the T#s cs_imgstore.asm builds, the V# as the translator reads it, sampler words as radv writes them, the format table and the mappings. tests/test_gfx10_descriptors.py reads the table out of the header and checks each code's name against tools/gfx10_formats.json and each Vulkan format's layout against that name. Moving FORMAT by one bit, or giving a row another code, fails them. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Set 0 as the translator declares it (docs/design.md, docs/d3d12_vulkan.md section 5), in runtime/src/vulkan_bindless.h: the twenty bindings with the array sizes vk_pipeline_check uses, and DescriptorTable (descriptor_table.h) behind binding 2. - An image has one index in its dimension (2D, 2D array, 3D, 1D), the same in every binding of that dimension. The storage arrays hold 256, so an image with a storage view gets an index below 256 and a read-only one goes above while there is room. - Index 0 of every array is a fallback (a 1x1 image of zeros, a nearest clamping sampler), because a miss in the table is index 0. - Changes are queued and written by flush(), one write a slot: a view removed before the next flush is never written, so it may be destroyed at once. - insert_key / erase_key change the table; flush() copies it to the buffer, into a new and larger one when it has grown. Erasing compacts a probe cluster, which moves other keys' entries, and a new buffer rewrites binding 2: flush_needs_idle() says when a flush would do either, so the owner can make sure no command buffer that uses the set is still running. - With update after bind the set may be flushed between submissions; with partially bound only index 0 is written at creation. Test: vk_bindless_test, run by runtime/test/shaders/check.py and scripts/run_gpu_tests.py. ps_tex.asm, a hand-written RDNA2 pixel shader built by build.py, loads a T# and an S# from a descriptor table and samples: the translator's own lookup against the table and the set. It draws the gradient with the T# at the fourth slot probed, the fallback after the key is erased, the gradient after the table has grown into a new buffer, another view at the same index and the fallback after removal, with and without the descriptor-indexing flags; and it adds, removes and destroys a view before its first flush, which the validation layer reports if the write is still made. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
A descriptor is the bytes of its heap slot (a TargetView in RTV and DSV heaps, otherwise what the shader loads), so both are byte copies. CopyDescriptors walks the destination and source range lists together, one descriptor at a time; null size arrays mean one descriptor per range, and whichever side runs out first ends the copy. Test: d3d12_descriptor_test, through the Xbox-ABI proxy, checks the slots' bytes for one run, range lists of different shapes on each side, null size arrays, a destination longer than its source, and null arguments. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested and validated on Windows 11 with MSVC and NVIDIA hardware: Environment & Toolchain
Test Results
o flags: identical behavior without descriptor-indexing extensions.
DescriptorTable Integration (#167)
(Note: As a minor follow-up, scripts/build_runtime.ps1's direct MSVC build block can be updated to include these tests when VULKAN_SDK is defined, keeping it in sync with |
|
Tested AI-assisted (Claude Code): it built the branch, ran the tests and wrote this comment.
The branch is 57 commits behind |
… and vk_bindless_test The fallback block (no VS CMake tools) built vk_texture_test when VULKAN_SDK is set but not the two tests this branch adds. They are built the same way now: both include their headers by relative path and need no library. Not run here: this machine has no MSVC or PowerShell. The two sources build with MSVC through CMake (reported on the pull request). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
e7de57e to
16586f7
Compare
|
Thanks for the MSVC run, @0xTehuti. That was the one thing I couldn't check here. What changed in this push:
One caveat: I could not run that block (no MSVC or PowerShell on this machine). If you have a setup without the VS CMake tools, a run of it would be welcome. Re-tested after the rebase on an RX 7900 XTX (RADV, Mesa 26.3.1) and llvmpipe, validation on: AI-assisted (Claude Code, Claude Fable 5.2). |
…230's ps_tex in the checks' total and fake run) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Resolve the conflicts with the GPU test lists and counts (ItsNotRexed#203, ItsNotRexed#212, ItsNotRexed#218, ItsNotRexed#222, ItsNotRexed#235, ItsNotRexed#246, ItsNotRexed#219, ItsNotRexed#298, ItsNotRexed#230), and keep main's partial-wave rule for ds_bpermute_b32 in wave64. The wave32 path gets the same ballot, so a source lane that isn't running reads 0 there too. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claimed in #156 as: D3D-5
#167 is merged; no open dependency.
The part of D3D-5 (#156) that needs nothing from #119. The device wiring (CreateShaderResourceView / CreateUnorderedAccessView / CreateSampler, set 0 in compute pipelines) is done on top of #119 and follows when #119 is rebased.
Tests: gfx10_descriptors_test and tests/test_gfx10_descriptors.py; vk_bindless_test, run by check.py and run_gpu_tests.py (ps_tex.asm, a hand-written RDNA2 pixel shader, finds a texture through the table and the set: at the fourth slot probed, a miss after erase, after the table has grown, another view, removal); d3d12_descriptor_test (copies through the Xbox-ABI proxy).
Tested on an RX 7900 XTX (RADV, Mesa 26.3.1) and llvmpipe on Linux, validation layer on. d3d12_descriptor_test was cross-built with mingw-w64 and run under Wine; not built with MSVC here. On this GPU check.py also reports cs_w64x_partial failing, which it does on main too.
AI-assisted (Claude Code, Claude Fable 5.2).