From a634430fec489c0cc1f3475fe4dddfdbcde25e11 Mon Sep 17 00:00:00 2001 From: Jan Trencansky Date: Mon, 23 Nov 2026 14:41:17 -0500 Subject: 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 --- runtime/src/root_signature.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) (limited to 'runtime/src/root_signature.cpp') 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) { out.error = "unknown root parameter type"; return out; } - if (p.type == ParamType::Constants && p.num_values == 0) { - out.error = "root constant parameter needs at least 1 dword"; - return out; - } + // A constant parameter of 0 values is valid (the host serializer warns, CreateRootSignature answers S_OK): + // it takes no dwords, so it gets no provenance entry and the parameters after it pack as if it were absent. const uint32_t dwords = p.type == ParamType::Table ? 2 : p.type == ParamType::Descriptor ? 2 : p.num_values; @@ -63,15 +61,12 @@ StagePackResult pack_stage(const RootSignature& sig, Stage stage) { first.reserve(sig.params.size()); for (size_t i = 0; i < sig.params.size(); ++i) { const RootParameter& p = sig.params[i]; - if (p.type == ParamType::Constants && p.num_values == 0) { - out.error = "root constant parameter needs at least 1 dword"; - return out; - } cost += param_cost(p.type, p.num_values); if (cost > kMaxD3d12Cost) { out.error = "root signature exceeds the 64-dword D3D12 cost limit"; return out; } + // 0 for a constant parameter of 0 values, which then shares its first SGPR with the next parameter. const uint64_t dwords = stage_dwords(p.type, p.num_values); if (next + dwords > kMaxUserSgprs) { // The console moves this parameter and every later one to the spill array behind s[0:1]; that array's -- cgit v1.2.3