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

Closed
opened 2026-11-26 20:18:44 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/657
Author: @aslan2142
Created: 11/24/2026
Status: ✅ Merged
Merged: 11/25/2026
Merged by: @aslan2142

Base: main ← Head: root-constants-zero


📝 Commits (4)

  • a634430 root_signature: accept root constants of 0 values, as the host does (D3D-942)
  • 509a543 Merge main into root-constants-zero
  • 244e89f root_sig_contract: accept root constants of 0 values, as the runtime packer does
  • 48245b4 root_signature_test: 64 constants spill whole for compute, refused as a spill for pixel

📊 Changes

5 files changed (+94 additions, -17 deletions)

View changed files

📝 runtime/src/root_signature.cpp (+3 -8)
📝 runtime/src/root_signature.h (+5 -3)
📝 runtime/test/root_signature_test.cpp (+64 -1)
📝 tests/test_root_sig_contract.py (+15 -1)
📝 tools/root_sig_contract.py (+7 -4)

📄 Description

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


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/657 **Author:** [@aslan2142](https://github.com/aslan2142) **Created:** 11/24/2026 **Status:** ✅ Merged **Merged:** 11/25/2026 **Merged by:** [@aslan2142](https://github.com/aslan2142) **Base:** `main` ← **Head:** `root-constants-zero` --- ### 📝 Commits (4) - [`a634430`](https://github.com/ubiquitarianism/leonida/commit/a634430fec489c0cc1f3475fe4dddfdbcde25e11) root_signature: accept root constants of 0 values, as the host does (D3D-942) - [`509a543`](https://github.com/ubiquitarianism/leonida/commit/509a543de72c091eb25f6063cc70f06f1bb82e98) Merge main into root-constants-zero - [`244e89f`](https://github.com/ubiquitarianism/leonida/commit/244e89f39cc6d7199d8ab5dd126eac2d9f95b062) root_sig_contract: accept root constants of 0 values, as the runtime packer does - [`48245b4`](https://github.com/ubiquitarianism/leonida/commit/48245b436d0890ad67f2a6b9098840bdea90e189) root_signature_test: 64 constants spill whole for compute, refused as a spill for pixel ### 📊 Changes **5 files changed** (+94 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/root_signature.cpp` (+3 -8) 📝 `runtime/src/root_signature.h` (+5 -3) 📝 `runtime/test/root_signature_test.cpp` (+64 -1) 📝 `tests/test_root_sig_contract.py` (+15 -1) 📝 `tools/root_sig_contract.py` (+7 -4) </details> ### 📄 Description 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
4ld0 2026-11-26 20:18:44 +01:00
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#697
No description provided.