OLD-8904: restore old upstream PR 8904 - root_signature: accept root constants of 0 values, as the host does (D3D-942) #657

Merged
aslan2142 merged 4 commits from upstream-pr/657 into main 2026-11-25 22:57:31 +00:00
aslan2142 commented 2026-11-24 11:07:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-24T11:07:19Z.


Claimed in the coordination issue as: OLD-8904 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129644051

Restoration of my original pull request, old upstream PR 8904 in ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c; no changes beyond the rebase.

Depends on: #420 (adjacent-line conflict in pack_stage(); either order resolves easily)

What and why

  • pack() and pack_stage() in runtime/src/root_signature.cpp refused a 32-bit-constants parameter with Num32BitValues == 0. So CreateRootSignature failed where host D3D12 answers S_OK. The serializer warns for versions 1.0 and 1.1, and both devices still create the root signature.
  • Such a parameter now takes no dwords and adds nothing to the cost:
    • In pack() it gets no provenance entry.
    • In pack_stage() it shares its first SGPR with the next parameter, so no other offset changes.
  • No zero-size Vulkan push-constant range is created, because the range is the fixed ShaderUserData block, not one range per parameter. The command list already refuses any write past a parameter's constant count.
  • 65 constants are still refused by the 64-dword cost limit.
  • New cases in root_signature_test (both packers):
    • zero-value constants alone, between other parameters, and in a hand-built RTS0 blob;
    • 64 constants pass the cost limit and are refused only as a spill;
    • 65 constants are refused by the cost limit.

Tested

Built and run on Linux. The Windows build used clang targeting x86_64-w64-mingw32 and ran under Wine 11.22. The same files were also built natively for Linux with clang. MSVC (/W4 /permissive-) is left to CI.

  • root_signature_test on main unchanged: 56 pass, 0 fail.
  • This branch's tests built against main's code: 58 pass, 8 fail (the 8 zero-value cases).
  • This branch: 66 pass, 0 fail, under Wine and natively.
  • git diff --check and scripts/check_no_game_data.py on the changed files: clean.

GPUs tested: n/a (the test needs no GPU)

AI-assisted: yes

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. (n/a: no translator change)

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5470966791 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/657). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-24T11:07:19Z. --- Claimed in the coordination issue as: OLD-8904 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129644051 Restoration of my original pull request, old upstream PR 8904 in `ItsNotRexed/Leonida`, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bca8c675c62f9dbffc318ce6a59d57faf31; no changes beyond the rebase. Depends on: #420 (adjacent-line conflict in pack_stage(); either order resolves easily) ### What and why - `pack()` and `pack_stage()` in `runtime/src/root_signature.cpp` refused a 32-bit-constants parameter with `Num32BitValues == 0`. So `CreateRootSignature` failed where host D3D12 answers `S_OK`. The serializer warns for versions 1.0 and 1.1, and both devices still create the root signature. - Such a parameter now takes no dwords and adds nothing to the cost: - In `pack()` it gets no provenance entry. - In `pack_stage()` it shares its first SGPR with the next parameter, so no other offset changes. - No zero-size Vulkan push-constant range is created, because the range is the fixed `ShaderUserData` block, not one range per parameter. The command list already refuses any write past a parameter's constant count. - 65 constants are still refused by the 64-dword cost limit. - New cases in `root_signature_test` (both packers): - zero-value constants alone, between other parameters, and in a hand-built RTS0 blob; - 64 constants pass the cost limit and are refused only as a spill; - 65 constants are refused by the cost limit. ### Tested Built and run on Linux. The Windows build used clang targeting x86_64-w64-mingw32 and ran under Wine 11.22. The same files were also built natively for Linux with clang. MSVC (`/W4 /permissive-`) is left to CI. - `root_signature_test` on `main` unchanged: 56 pass, 0 fail. - This branch's tests built against `main`'s code: 58 pass, 8 fail (the 8 zero-value cases). - This branch: 66 pass, 0 fail, under Wine and natively. - `git diff --check` and `scripts/check_no_game_data.py` on the changed files: clean. GPUs tested: n/a (the test needs no GPU) AI-assisted: yes ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [x] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change) AI-assisted (Claude Code, Claude Opus 5.5).
PierreEbele commented 2026-11-25 01:15:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by PierreEbele on 2026-11-25T01:15:55Z.


Reviewed a634430f. I built and ran the real root_signature_test (CMake + Ninja, g++, Release, Linux arm64 sandbox):

  • This branch: all checks pass, rc 0.
  • The PR's test file on a main worktree: rc 1 with 8 failures, all of them the new zero-value-constant cases (e.g. pack_stage: zero-value constants accepted). The new tests exercise the fix.

The branch also merges cleanly into current main (b4b7756e).

I read the diff and the main consumer path (CreateRootSignature -> RootArgumentLayout -> the root-constant writes). A 0-value constant parameter keeps constant_count 0. The bounds check refuses any nonzero write to it, so the SGPR it shares with the next parameter is never written through it.

One consistency note, not blocking: tools/root_sig_contract.py:23 says its packing "mirrors runtime/src/root_signature.{h,cpp}". It still refuses constants with count 0 (:70, "constants need an integer count >= 1"), so after this PR it rejects a signature the runtime accepts. This could be a small follow-up. I could not check the host claim (serializer warns, CreateRootSignature returns S_OK) here.

AI-assisted review.

Recommendation: Merge

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7149371510 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/657#issuecomment-7149371510). Originally posted by [PierreEbele](https://github.com/PierreEbele) on 2026-11-25T01:15:55Z. --- Reviewed a634430f. I built and ran the real `root_signature_test` (CMake + Ninja, g++, Release, Linux arm64 sandbox): - **This branch:** all checks pass, rc 0. - **The PR's test file on a main worktree:** rc 1 with 8 failures, all of them the new zero-value-constant cases (e.g. `pack_stage: zero-value constants accepted`). The new tests exercise the fix. The branch also merges cleanly into current main (b4b7756e). I read the diff and the main consumer path (`CreateRootSignature` -> `RootArgumentLayout` -> the root-constant writes). A 0-value constant parameter keeps `constant_count` 0. The bounds check refuses any nonzero write to it, so the SGPR it shares with the next parameter is never written through it. One consistency note, not blocking: `tools/root_sig_contract.py:23` says its packing "mirrors runtime/src/root_signature.{h,cpp}". It still refuses constants with count 0 (`:70`, "constants need an integer count >= 1"), so after this PR it rejects a signature the runtime accepts. This could be a small follow-up. I could not check the host claim (serializer warns, `CreateRootSignature` returns S_OK) here. AI-assisted review. **Recommendation:** Merge
aslan2142 commented 2026-11-25 22:57:34 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by aslan2142 on 2026-11-25T22:57:34Z.


Merged: root_signature accepts root constants of 0 values, as the host does (D3D-942).

  • Changed since review: main merged in. pack_stage on main now spills trailing compute parameters behind s[0:1] and refuses unknown parameter types. Both are kept, and only the zero-value refusal goes. A zero-value constant takes no SGPRs and no spill dwords, and a new case checks the spill offsets around one. The 64-constant check now expects compute to spill them whole, and a pixel shader to refuse them as a spill.
  • Review point: tools/root_sig_contract.py refused count 0, so it rejected signatures the runtime accepts. It now takes count >= 0, and a new test covers it (244e89f39).
  • Tested: the full Windows suite under Wine on main 5fab93967 with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. root_signature passes on both. root_signature_test also passes natively on Linux (g++), and test_root_sig_contract has 59 passing tests.
  • Checked on main d34c426ef + 48245b436: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; check_no_game_data.py is clean on the 5 changed files.

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7176983414 --> Imported from [ubiquitarianism/leonida](https://github.com/ubiquitarianism/leonida/pull/657#issuecomment-7176983414). Originally posted by [aslan2142](https://github.com/aslan2142) on 2026-11-25T22:57:34Z. --- Merged: `root_signature` accepts root constants of 0 values, as the host does (D3D-942). - **Changed since review:** `main` merged in. `pack_stage` on `main` now spills trailing compute parameters behind `s[0:1]` and refuses unknown parameter types. Both are kept, and only the zero-value refusal goes. A zero-value constant takes no SGPRs and no spill dwords, and a new case checks the spill offsets around one. The 64-constant check now expects compute to spill them whole, and a pixel shader to refuse them as a spill. - **Review point:** `tools/root_sig_contract.py` refused `count` 0, so it rejected signatures the runtime accepts. It now takes `count >= 0`, and a new test covers it (`244e89f39`). - **Tested:** the full Windows suite under Wine on `main` `5fab93967` with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail. `root_signature` passes on both. `root_signature_test` also passes natively on Linux (g++), and `test_root_sig_contract` has 59 passing tests. - **Checked on `main` `d34c426ef` + `48245b436`:** it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass; `check_no_game_data.py` is clean on the 5 changed files. AI-assisted (Claude Code, Claude Opus 5.5).
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
ProjectLeonida/mandy!657
No description provided.