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

Manually merged
github merged 4 commits from gh-pr/657/head into gh-pr/657/base 2026-11-26 09:14:21 +00:00
Owner

@⁠aslan2142 on GitHub · 2026-11-24 11:07 UTC · original
aslan2142:root-constants-zero → main · +94 −17 · 5 files · 4 commits · merged 2026-11-25 22:57 UTC

Claimed in the coordination issue as: OLD-8904 #14

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

**@⁠aslan2142** on GitHub · 2026-11-24 11:07 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/657) `aslan2142:root-constants-zero` → `main` · +94 −17 · 5 files · 4 commits · merged 2026-11-25 22:57 UTC Claimed in the coordination issue as: OLD-8904 https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14 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).
pack() and pack_stage() 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; both devices create it).
Such a parameter now takes no dwords and no cost: it gets no provenance entry in pack(), and in pack_stage() it
shares its first SGPR with the next parameter, so every other offset is unchanged. The Vulkan push-constant range
is the fixed ShaderUserData block, not per parameter, so no zero-size range is created; the command list already
refuses any write past a parameter's constant count. 65 constants stay refused by the 64-dword cost limit.

root_signature_test: zero-value constants alone, between other parameters and from a hand-built RTS0 blob (both
packers); 64 constants pass the cost limit and are refused only as a spill; 65 by the cost limit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
main's pack_stage now spills trailing compute parameters into the array
behind s[0:1] and refuses an unknown parameter type. Keep both; drop only
the zero-value constant refusal, as this branch does. A zero-value
constant takes no SGPRs and no spill dwords, and a new case checks the
spill offsets around one. The old "32-SGPR budget refuses before the
cost limit" comment no longer holds with spilling and goes; main's
over-cost case replaces it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
tools/root_sig_contract.py says its packing mirrors
runtime/src/root_signature.{h,cpp}, but it still refused a constant
parameter with count 0, so after this branch it rejected a signature the
runtime accepts. Accept count >= 0; a zero count adds no dwords and its
neighbours pack as if it were absent, in both the s0 and the console
layout. Raised in review.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This branch's check expected pack_stage(Compute) to refuse 64 constants
as an unmodelled spill. main's pack_stage now spills trailing compute
parameters behind s[0:1], so compute takes them (cost 64, one spilled
parameter of 64 dwords). The "refused only as a spill, not for cost"
check moves to a pixel shader, where a spill is still refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:14:17 +00:00
github manually merged commit 48245b436d into gh-pr/657/base 2026-11-26 09:14:21 +00:00
Author
Owner

@⁠PierreEbele on GitHub · 2026-11-25 01:15 UTC · original

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

**@⁠PierreEbele** on GitHub · 2026-11-25 01:15 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/657#issuecomment-7149371510) 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
Author
Owner

@⁠aslan2142 on GitHub · 2026-11-25 22:57 UTC · original

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

**@⁠aslan2142** on GitHub · 2026-11-25 22:57 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/657#issuecomment-7176983414) 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).
This discussion has been locked. Commenting is limited to contributors.
No description provided.