diff options
| author | Almogaver295 <133548141+guimsolutions@users.noreply.github.com> | 2026-11-23 23:53:36 +0100 |
|---|---|---|
| committer | Almogaver295 <133548141+guimsolutions@users.noreply.github.com> | 2026-11-23 23:53:36 +0100 |
| commit | 33f4a5aedeb48e27b004efe5d6ae306130d55cdd (patch) | |
| tree | 08361685151a2a6a4ecf9156955fabb35b4b570c /runtime/src/root_signature.cpp | |
| parent | 57cb669f52ba6ca4bb58bf2e09492ffbe2b8ee60 (diff) | |
| parent | 5d74c272363f2703265d44e6aaab1a1df8ddfaf3 (diff) | |
Merge upstream main and preserve 1D UAV clear compatibilityold-pr/9948
Diffstat (limited to 'runtime/src/root_signature.cpp')
| -rw-r--r-- | runtime/src/root_signature.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/runtime/src/root_signature.cpp b/runtime/src/root_signature.cpp index 844f1b580..a0eb96cce 100644 --- a/runtime/src/root_signature.cpp +++ b/runtime/src/root_signature.cpp | |||
| @@ -48,6 +48,48 @@ PackResult pack(const RootSignature& sig) { | |||
| 48 | return out; | 48 | return out; |
| 49 | } | 49 | } |
| 50 | 50 | ||
| 51 | StagePackResult pack_stage(const RootSignature& sig, Stage stage) { | ||
| 52 | StagePackResult out; | ||
| 53 | out.stage = stage; | ||
| 54 | out.base = stage_base(stage); | ||
| 55 | out.end_sgpr = out.base; | ||
| 56 | if (sig.params.size() > 64) { | ||
| 57 | out.error = "root signature has more than 64 root parameters"; | ||
| 58 | return out; | ||
| 59 | } | ||
| 60 | uint64_t cost = 0; // 64-bit, as in pack() | ||
| 61 | uint64_t next = out.base; | ||
| 62 | std::vector<uint32_t> first; | ||
| 63 | first.reserve(sig.params.size()); | ||
| 64 | for (size_t i = 0; i < sig.params.size(); ++i) { | ||
| 65 | 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); | ||
| 71 | if (cost > kMaxD3d12Cost) { | ||
| 72 | out.error = "root signature exceeds the 64-dword D3D12 cost limit"; | ||
| 73 | return out; | ||
| 74 | } | ||
| 75 | const uint64_t dwords = stage_dwords(p.type, p.num_values); | ||
| 76 | 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 | ||
| 78 | // layout is not modelled here, so refuse rather than drop arguments. | ||
| 79 | out.error = "root parameter " + std::to_string(i) + " does not fit in the user SGPRs from s" + | ||
| 80 | std::to_string(out.base) + " (spill array not modelled)"; | ||
| 81 | return out; | ||
| 82 | } | ||
| 83 | first.push_back(static_cast<uint32_t>(next)); | ||
| 84 | next += dwords; | ||
| 85 | } | ||
| 86 | out.first_sgpr = std::move(first); | ||
| 87 | out.end_sgpr = static_cast<uint32_t>(next); | ||
| 88 | out.d3d12_cost = static_cast<uint32_t>(cost); | ||
| 89 | out.ok = true; | ||
| 90 | return out; | ||
| 91 | } | ||
| 92 | |||
| 51 | namespace { | 93 | namespace { |
| 52 | 94 | ||
| 53 | void put_u32(std::vector<uint8_t>& out, uint32_t v) { | 95 | void put_u32(std::vector<uint8_t>& out, uint32_t v) { |