Skip to content

Runtime: GFX10 descriptor codec, bindless set 0 and CopyDescriptors (M2, first part) - #230

Merged
ItsNotRexed merged 4 commits into
ItsNotRexed:mainfrom
aslan2142:d3d12-bindless
Nov 21, 2026
Merged

ItsNotRexed merged 4 commits into
ItsNotRexed:mainfrom
aslan2142:d3d12-bindless

Conversation

@aslan2142

@aslan2142 aslan2142 commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

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.

  • runtime/src/gfx10_descriptors.h: T#, S# and V# encode and decode, with their Vulkan formats, view types, component mappings and samplers. Field positions are Mesa's gfx10-rsrc.json.
  • runtime/src/vulkan_bindless.h: set 0 as the translator declares it (bindings 0-19), with Runtime: implement FNV-1a descriptor hash table for shader contract (set 0, binding 2) #167's DescriptorTable behind binding 2. Fallbacks at index 0, one pending write a slot, and flush_needs_idle() for a flush that moves table entries or replaces the table's buffer.
  • CopyDescriptors / CopyDescriptorsSimple on the Vulkan device: a descriptor is the bytes of its slot.

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).

aslan2142 and others added 3 commits November 21, 2026 16:55
…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>
@0xTehuti

Copy link
Copy Markdown
Contributor

Tested and validated on Windows 11 with MSVC and NVIDIA hardware:

Environment & Toolchain

  • OS: Windows 11
  • Toolchain: MSVC 14.44 (Visual Studio 2022 Community v17.0, cl.exe 19.44.35225)
  • GPU: NVIDIA GeForce RTX 2070 SUPER (Driver 595.79, Vulkan 1.4.321)

Test Results

  • gfx10_descriptors_test: PASS
    • Verified T#, S# and V# bitfields, round trips, 93 format rows and Vulkan mappings.
  • �k_bindless_test: PASS (Pixel validation: 10/10 draws read back, 0 bad pixels, largest error 0)
    • Verified across both configurations:
      1. update after bind, partially bound: gradient at 4th slot probed, miss after erase, table growth 64 -> 1024 slots, alternative view, removal.

o flags: identical behavior without descriptor-indexing extensions.

  • d3d12_descriptor_test: PASS
    • Validated CopyDescriptors and CopyDescriptorsSimple through the Xbox-ABI proxy on the Vulkan device.
  • ** ests/test_gfx10_descriptors.py**: PASS (5/5 tests passed in 0.015s)
    • Layout and format mappings match ools/gfx10_formats.json.

DescriptorTable Integration (#167)

  • Compiles cleanly with 0 MSVC compiler warnings under /W4 /permissive- /utf-8 /std:c++20.
  • Integration between �ulkan_bindless.h set 0 (binding 2) and DescriptorTable operates as expected (descriptor_table_test also verified 0 failures).

(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
untime/CMakeLists.txt.)

@TricksterG

Copy link
Copy Markdown
Contributor

Tested e7de57e on an RTX 5090 (Blackwell, driver 621.24, subgroup 32..32), Windows 11, MSVC 2022 (14.44), Vulkan SDK 1.4.363.0, Release build from a plain shell, llvm-mc 22.1.8 (MSYS2).

AI-assisted (Claude Code): it built the branch, ran the tests and wrote this comment.

  • Build: 0 compiler warnings. ctest: 13/13.
  • With LEONIDA_VK_VALIDATION=1, 0 VUIDs: gfx10_descriptors_test (T#/S#/V# fields, round trips, 93 format rows), d3d12_descriptor_test (CopyDescriptorsSimple / CopyDescriptors).
  • run_gpu_tests.py: ps_tex bindless: 10 draws read back, 0 bad pixels, largest error 0. 25/46 passed, 20 skipped (wave64, no emulation), 1 fail: ps_texture_sample "no checker defined". That one is from the branch's base, not this PR: the shader came in with Runtime: implement FNV-1a descriptor hash table for shader contract (set 0, binding 2) #167 (9eb0437) and its runner case was added on main later (3fae38a), which this branch doesn't have yet.

The branch is 57 commits behind main and git merge-tree reports conflicts, so it needs a rebase; after that ps_texture_sample should run too.

… 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>
@aslan2142

Copy link
Copy Markdown
Contributor Author

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: ctest 4 of 4, run_gpu_tests.py 47 of 48 with one skip.

AI-assisted (Claude Code, Claude Fable 5.2).

@ItsNotRexed
ItsNotRexed merged commit cc1f4d3 into ItsNotRexed:main Nov 21, 2026
ItsNotRexed added a commit that referenced this pull request Nov 21, 2026
…230's ps_tex in the checks' total and fake run)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@aslan2142
aslan2142 deleted the d3d12-bindless branch November 21, 2026 22:37
AlxcBTW added a commit to AlxcBTW/Leonida that referenced this pull request Nov 21, 2026
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants