upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/src/root_signature.cpp
diff options
context:
space:
mode:
authorJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 16:40:13 -0500
committerJan Trencansky <jan.trencansky@protonmail.com>2026-11-25 16:40:13 -0500
commit509a543de72c091eb25f6063cc70f06f1bb82e98 (patch)
treea44dab2fc88cbd60d3e46240a6971e39bd39fde3 /runtime/src/root_signature.cpp
parenta634430fec489c0cc1f3475fe4dddfdbcde25e11 (diff)
parent24d8af66af151f024b0b520fb397d899924f5486 (diff)
Merge main into root-constants-zero
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 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/root_signature.cpp')
-rw-r--r--runtime/src/root_signature.cpp27
1 files changed, 22 insertions, 5 deletions
diff --git a/runtime/src/root_signature.cpp b/runtime/src/root_signature.cpp
index 89ea5ef4c..41d3f6c5a 100644
--- a/runtime/src/root_signature.cpp
+++ b/runtime/src/root_signature.cpp
@@ -57,10 +57,18 @@ StagePackResult pack_stage(const RootSignature& sig, Stage stage) {
57 } 57 }
58 uint64_t cost = 0; // 64-bit, as in pack() 58 uint64_t cost = 0; // 64-bit, as in pack()
59 uint64_t next = out.base; 59 uint64_t next = out.base;
60 uint64_t spill_next = 0;
61 bool spilling = false;
60 std::vector<uint32_t> first; 62 std::vector<uint32_t> first;
63 std::vector<uint32_t> spill;
61 first.reserve(sig.params.size()); 64 first.reserve(sig.params.size());
65 spill.reserve(sig.params.size());
62 for (size_t i = 0; i < sig.params.size(); ++i) { 66 for (size_t i = 0; i < sig.params.size(); ++i) {
63 const RootParameter& p = sig.params[i]; 67 const RootParameter& p = sig.params[i];
68 if (p.type != ParamType::Constants && p.type != ParamType::Descriptor && p.type != ParamType::Table) {
69 out.error = "unknown root parameter type";
70 return out;
71 }
64 cost += param_cost(p.type, p.num_values); 72 cost += param_cost(p.type, p.num_values);
65 if (cost > kMaxD3d12Cost) { 73 if (cost > kMaxD3d12Cost) {
66 out.error = "root signature exceeds the 64-dword D3D12 cost limit"; 74 out.error = "root signature exceeds the 64-dword D3D12 cost limit";
@@ -68,18 +76,27 @@ StagePackResult pack_stage(const RootSignature& sig, Stage stage) {
68 } 76 }
69 // 0 for a constant parameter of 0 values, which then shares its first SGPR with the next parameter. 77 // 0 for a constant parameter of 0 values, which then shares its first SGPR with the next parameter.
70 const uint64_t dwords = stage_dwords(p.type, p.num_values); 78 const uint64_t dwords = stage_dwords(p.type, p.num_values);
71 if (next + dwords > kMaxUserSgprs) { 79 if (!spilling && next + dwords <= kMaxUserSgprs) {
72 // The console moves this parameter and every later one to the spill array behind s[0:1]; that array's 80 first.push_back(static_cast<uint32_t>(next));
73 // layout is not modelled here, so refuse rather than drop arguments. 81 spill.push_back(kNoSpill);
82 next += dwords;
83 } else if (stage == Stage::Compute) {
84 // Compute packs this parameter and every later one contiguously into the spill array behind s[0:1]
85 // (docs/d3d12_vulkan.md §3.5 & §7). Total spill stays bounded by kMaxD3d12Cost (<= 64 dwords).
86 spilling = true;
87 first.push_back(kNoSgpr);
88 spill.push_back(static_cast<uint32_t>(spill_next));
89 spill_next += dwords;
90 } else {
74 out.error = "root parameter " + std::to_string(i) + " does not fit in the user SGPRs from s" + 91 out.error = "root parameter " + std::to_string(i) + " does not fit in the user SGPRs from s" +
75 std::to_string(out.base) + " (spill array not modelled)"; 92 std::to_string(out.base) + " (spill array not modelled)";
76 return out; 93 return out;
77 } 94 }
78 first.push_back(static_cast<uint32_t>(next));
79 next += dwords;
80 } 95 }
81 out.first_sgpr = std::move(first); 96 out.first_sgpr = std::move(first);
97 out.spill_dword = std::move(spill);
82 out.end_sgpr = static_cast<uint32_t>(next); 98 out.end_sgpr = static_cast<uint32_t>(next);
99 out.spill_dwords = static_cast<uint32_t>(spill_next);
83 out.d3d12_cost = static_cast<uint32_t>(cost); 100 out.d3d12_cost = static_cast<uint32_t>(cost);
84 out.ok = true; 101 out.ok = true;
85 return out; 102 return out;