Skip to content

d3d12: with no shader library, the descriptor table is tagged, the tr… - #2543

Open
JamesCicada wants to merge 1 commit into
ProjectLeonida:mainfrom
JamesCicada:rt-descriptor-table-no-library-default
Open

JamesCicada wants to merge 1 commit into
ProjectLeonida:mainfrom
JamesCicada:rt-descriptor-table-no-library-default

Conversation

@JamesCicada

Copy link
Copy Markdown

… translator's default

With no library loaded (the GPU tests, the tools) the device picked the plain descriptor table, while tools/rdna2spirv.py translates for the tagged one by default. cs_texture_uav.spv then read an all-zero kind word, fell back to index 0 and skipped its image stores (got 0x11, expected 0x3f9).

kNoLibraryDescriptorTableLayout (runtime/src/shader_library.h) is now that default; the kind word is additive, so a plain module still reads only its index. A loaded library's vote and LEONIDA_DESCRIPTOR_TABLE are unchanged. tests/test_descriptor_table_default.py keeps the runtime's default equal to the translator's.

From qhukz13's finding in the coordination issue (#1608).

Tested on Windows 11 (CPU tests; GPU test not run, needs llvm-mc): shader_library, d3d12_vulkan_device, d3d12_texture_uav --descriptors-only, descriptor_table, tests/test_descriptor_table_default.py.

AI-assisted (Claude Code).

Claimed in the coordination issue as:

Depends on:

Fixes:

What and why

Tested

GPUs tested:

AI-assisted:

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed.

…anslator's default

With no library loaded (the GPU tests, the tools) the device picked the plain
descriptor table, while tools/rdna2spirv.py translates for the tagged one by
default. cs_texture_uav.spv then read an all-zero kind word, fell back to index
0 and skipped its image stores (got 0x11, expected 0x3f9).

kNoLibraryDescriptorTableLayout (runtime/src/shader_library.h) is now that
default; the kind word is additive, so a plain module still reads only its
index. A loaded library's vote and LEONIDA_DESCRIPTOR_TABLE are unchanged.
tests/test_descriptor_table_default.py keeps the runtime's default equal to
the translator's.

From qhukz13's finding in the coordination issue (ProjectLeonida#1608).

Tested on Windows 11 (CPU tests; GPU test not run, needs llvm-mc):
shader_library, d3d12_vulkan_device, d3d12_texture_uav --descriptors-only,
descriptor_table, tests/test_descriptor_table_default.py.

AI-assisted (Claude Code).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Tyrannys

Copy link
Copy Markdown
Contributor

#2543 | head 4a83ecd | python -I tests/test_descriptor_table_default.py; ctest -C RelWithDebInfo -R "^(shader_library|d3d12_texture_uav|descriptor_table)$" | red: clean main + the PR's Python test: FAILED (failures=1), AssertionError, kNoLibraryDescriptorTableLayout not found (shader_library_test's new CHECK uses that constant, so it does not compile on main) | green: main 02f71cc merged into the head, Python: Ran 2 tests, OK; ctest 3/3 passed (d3d12_texture_uav with --descriptors-only only: the full cs_texture_uav GPU run needs llvm-mc, which this machine does not have yet) | full suite: not run (a game boot was using the machine) | Windows 11, RTX 4070 SUPER, NVIDIA 621.01, Python 3.14 | AI-assisted: yes, Claude Code

@Tyrannys

Copy link
Copy Markdown
Contributor

#2543 (GPU follow-up) | head 4a83ecd | d3d12_texture_uav_test <cs_texture_uav.spv> (the shader built with test/shaders/build.py, llvm-mc 21.1.8 with the AMDGPU target) | red: clean main: fails on an assertion, line 650 (check_case on the 1D texture), 2 of 2 runs | green: main 02f71cc merged into the head: "texture UAVs: 14 GPU cases (10 compared with WARP), format/range/refusal checks passed", 2 of 2 runs | full suite: not run (a game boot was using the machine) | Windows 11, RTX 4070 SUPER, NVIDIA 621.01, Python 3.14 | AI-assisted: yes, Claude Code

@lixonik lixonik left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff and tested merged onto main (493867366) with Ninja Release (MSVC), native llvm-mc (AMDGPU), Vulkan SDK 1.4.363.1 (spirv-val, spirv-as, glslangValidator), and LEONIDA_VK_VALIDATION=1.

Defaulting no-library runs to kNoLibraryDescriptorTableLayout = DescriptorTableLayout::tagged keeps the runtime aligned with tools/rdna2spirv.py, and tests/test_descriptor_table_default.py guards against future drift. Crucially, the translated-shader GPU test d3d12_texture_uav (which exercises cs_texture_uav.spv without a shader library) now builds and passes on real Vulkan hardware with zero validation errors.

Tests run

  • ctest --output-on-failure -R "^(shader_library|descriptor_table|d3d12_texture_uav|d3d12_translated_draw)$" (with LEONIDA_VK_VALIDATION=1): 4/4 passed (descriptor_table 0.03 s, shader_library 0.19 s, d3d12_texture_uav 2.45 s, d3d12_translated_draw 0.32 s).
  • python -I tests/test_descriptor_table_default.py -v: 2/2 passed.

GPUs tested: NVIDIA GeForce RTX 5070 12 GB (Windows 11, driver 610.88, Vulkan 1.4.341, VK_LAYER_KHRONOS_validation 1.4.363).

AI-assisted (Antigravity, Gemini).

@zmasi

zmasi commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

#2543 | head 4a83ecd (merged cleanly with main adfb382) | python -m unittest tests/test_descriptor_table_default.py + ctest --test-dir runtime/build -C RelWithDebInfo -R "^(shader_library|descriptor_table|d3d12_texture_uav|d3d12_compute)$" --output-on-failure (LEONIDA_VK_VALIDATION=1) | red on main: test_descriptor_table_default.py fails (AssertionError: unexpectedly None : kNoLibraryDescriptorTableLayout not found in runtime/src/shader_library.h) and shader_library_test fails to compile (error C2065: 'kNoLibraryDescriptorTableLayout': undeclared identifier) | green on PR+main: test_descriptor_table_default.py (2/2), test_docs_encoding.py, test_docs_repo_paths.py, and 4/4 CTests (shader_library, descriptor_table, d3d12_texture_uav, d3d12_compute) pass on RTX 3090, logging descriptor table: tagged (no shader library; the translator's default) with 0 Khronos validation errors; check_no_game_data.py 0 violations | Windows 11, MSVC 19.44, RTX 3090, Vulkan SDK 1.4.363.1 | AI-assisted: yes

@timbot103 timbot103 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static audit of 4a83ecddc against 48bae6cad. No findings. The tagged default gives caller-supplied shaders the image kind bits they expect, while library metadata and LEONIDA_DESCRIPTOR_TABLE still determine the layout when present. The supplied results report a full texture UAV red/green and a separate Vulkan validation pass on earlier main merges. The registered CTest covers descriptor setup, and the full GPU test dispatches the translated shader and checks the texels.

AI-assisted.

@ecox982745

Copy link
Copy Markdown
Contributor

Independent RTX 4090 verification on Windows 11 build 26300, NVIDIA 616.64, MSVC 19.44, LLVM 23.1.6 and SPIRV-Tools 2026.4. Khronos Vulkan validation was enabled. All fixtures were synthetic.

AI-assisted with OpenAI Codex (GPT-6.2 Sol).

@TheGeogeo

Copy link
Copy Markdown
Contributor

Tested 4a83ecd merged (no commit) with main 8fb9748: MSVC 19.52, Python 3.12.4, Windows 11 10.0.26300.
GPUs tested: NVIDIA GeForce RTX 3080, driver 621.40.

  • Green: shader_library passes, and tests/test_descriptor_table_default.py passes (2 tests). The 296 relinked CTests pass, except xbox_present, which fails on main too (its resize case).
  • Red: with runtime/shims/d3d12_vulkan_device.cpp and runtime/src/shader_library.h back to main, shader_library_test.cpp does not compile (C2065: 'kNoLibraryDescriptorTableLayout'). test_descriptor_table_default.py fails with "kNoLibraryDescriptorTableLayout not found in runtime/src/shader_library.h".
  • gta6rt links with nothing new over main: no new unresolved symbol, same imports.
  • Not run here: the GPU runner case of d3d12_texture_uav with cs_texture_uav.spv. CTest runs that test with --descriptors-only.
  • No merge conflict with the other open PRs that touch these files.
  • No game data check passes.

AI-assisted (Claude Code).

@fiestorra

Copy link
Copy Markdown
Contributor

Independent verification on this machine (Windows 11, MSVC 19.44.35226, Python 3.13.14), and the negative control bites on the Python side.

1. It applies. merge-tree clean; 4a83ecddc cherry-picks onto main 0ae217ceb without a conflict. Five files: the Vulkan device shim, shader_library.h, its test, the doc paragraph and tests/test_descriptor_table_default.py.

2. Both test surfaces pass with the change:

python3 -m pytest tests/test_descriptor_table_default.py -q   -> 2 passed
cmake --build … --target shader_library_test  -> linked
shader_library_test.exe                       -> exit 0, 0, 0

3. The Python check fails on main's sources - the PR's test against the reverted shim and shader_library.h:

-> 1 failed, 1 passed
   FAILED DescriptorTableDefault::test_runtime_matches_translat…

So the pairing the commit establishes - with no shader library, the descriptor table is tagged the way the translator tags it - is absent on main and present with the change. The C++ test does not distinguish on its own (it exercises the new tagging path, which only exists with the change), so the Python half is the evidence.

What I did not test: a title run without a shader library on a device that needs one. The tests drive the decision and the tagging; whether the GPU stops complaining about an untagged table needs the title, which this machine can boot but not in the "no shader library" configuration the commit is about.

Written with an AI assistant.

@github-actions github-actions Bot added the needs rebase Conflicts with the base branch: rebase it on main label Nov 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs rebase Conflicts with the base branch: rebase it on main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants