diff options
| author | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-23 14:41:17 -0500 |
|---|---|---|
| committer | Jan Trencansky <jan.trencansky@protonmail.com> | 2026-11-24 06:05:46 -0500 |
| commit | a634430fec489c0cc1f3475fe4dddfdbcde25e11 (patch) | |
| tree | 85a7eb7f875b50558e24aa7ebf69a3c9f319c4b6 /runtime/src/root_signature.cpp | |
| parent | 21625bca8c675c62f9dbffc318ce6a59d57faf31 (diff) | |
root_signature: accept root constants of 0 values, as the host does (D3D-942)
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 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/root_signature.cpp')
| -rw-r--r-- | runtime/src/root_signature.cpp | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/runtime/src/root_signature.cpp b/runtime/src/root_signature.cpp index a0eb96cce..89ea5ef4c 100644 --- a/runtime/src/root_signature.cpp +++ b/runtime/src/root_signature.cpp | |||
| @@ -17,10 +17,8 @@ PackResult pack(const RootSignature& sig) { | |||
| 17 | out.error = "unknown root parameter type"; | 17 | out.error = "unknown root parameter type"; |
| 18 | return out; | 18 | return out; |
| 19 | } | 19 | } |
| 20 | if (p.type == ParamType::Constants && p.num_values == 0) { | 20 | // A constant parameter of 0 values is valid (the host serializer warns, CreateRootSignature answers S_OK): |
| 21 | out.error = "root constant parameter needs at least 1 dword"; | 21 | // it takes no dwords, so it gets no provenance entry and the parameters after it pack as if it were absent. |
| 22 | return out; | ||
| 23 | } | ||
| 24 | const uint32_t dwords = p.type == ParamType::Table ? 2 | 22 | const uint32_t dwords = p.type == ParamType::Table ? 2 |
| 25 | : p.type == ParamType::Descriptor ? 2 | 23 | : p.type == ParamType::Descriptor ? 2 |
| 26 | : p.num_values; | 24 | : p.num_values; |
| @@ -63,15 +61,12 @@ StagePackResult pack_stage(const RootSignature& sig, Stage stage) { | |||
| 63 | first.reserve(sig.params.size()); | 61 | first.reserve(sig.params.size()); |
| 64 | for (size_t i = 0; i < sig.params.size(); ++i) { | 62 | for (size_t i = 0; i < sig.params.size(); ++i) { |
| 65 | const RootParameter& p = sig.params[i]; | 63 | const RootParameter& p = sig.params[i]; |
| 66 | if (p.type == ParamType::Constants && p.num_values == 0) { | ||
| 67 | out.error = "root constant parameter needs at least 1 dword"; | ||
| 68 | return out; | ||
| 69 | } | ||
| 70 | cost += param_cost(p.type, p.num_values); | 64 | cost += param_cost(p.type, p.num_values); |
| 71 | if (cost > kMaxD3d12Cost) { | 65 | if (cost > kMaxD3d12Cost) { |
| 72 | out.error = "root signature exceeds the 64-dword D3D12 cost limit"; | 66 | out.error = "root signature exceeds the 64-dword D3D12 cost limit"; |
| 73 | return out; | 67 | return out; |
| 74 | } | 68 | } |
| 69 | // 0 for a constant parameter of 0 values, which then shares its first SGPR with the next parameter. | ||
| 75 | const uint64_t dwords = stage_dwords(p.type, p.num_values); | 70 | const uint64_t dwords = stage_dwords(p.type, p.num_values); |
| 76 | if (next + dwords > kMaxUserSgprs) { | 71 | if (next + dwords > kMaxUserSgprs) { |
| 77 | // The console moves this parameter and every later one to the spill array behind s[0:1]; that array's | 72 | // The console moves this parameter and every later one to the spill array behind s[0:1]; that array's |