From 9f98dcc617df5b21eb66b48a289914b551769029 Mon Sep 17 00:00:00 2001 From: Moriz82 <72836413+Moriz82@users.noreply.github.com> Date: Wed, 25 Nov 2026 14:30:51 -0600 Subject: Improve post-load GPU memory and pipeline handling (RT-POST-LOAD-GPU-MEMORY) Fall back to a dedicated buffer allocation when the shared arena fills. Update console descriptors and resource backing, preserve pipeline cache entries, and replay mesh records using bounded indirect arguments. Keep scripted input available until read and cover the runtime and translator paths with synthetic tests. Co-authored-by: Plaaasma <47513553+Plaaasma@users.noreply.github.com> Co-authored-by: ivanepsilondelta <264061546+ivanepsilondelta@users.noreply.github.com> --- runtime/src/descriptor_range_changes.h | 46 ++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 runtime/src/descriptor_range_changes.h (limited to 'runtime/src/descriptor_range_changes.h') diff --git a/runtime/src/descriptor_range_changes.h b/runtime/src/descriptor_range_changes.h new file mode 100644 index 000000000..5a4d7717f --- /dev/null +++ b/runtime/src/descriptor_range_changes.h @@ -0,0 +1,46 @@ +#pragma once +#include +#include +#include +#include + +namespace leonida { +// A separate cursor per console heap. The owning backing/alias registry locks record() and read(). +struct DescriptorRanges { + struct Range { uint64_t first, last; }; // inclusive, including UINT64_MAX + std::vector ranges; + void merge() { + std::sort(ranges.begin(), ranges.end(), [](auto a, auto b) { return a.first < b.first; }); + size_t n = 0; + for (auto r : ranges) { + if (n && r.first <= ranges[n-1].last) + ranges[n-1].last = (std::max)(ranges[n-1].last, r.last); + else ranges[n++] = r; + } + ranges.resize(n); + } + bool overlaps(uint64_t base, uint64_t bytes) const { + if (!bytes) return false; + auto it = std::lower_bound(ranges.begin(), ranges.end(), base, + [](auto r, uint64_t v) { return r.last < v; }); + return it != ranges.end() && (it->first <= base || it->first - base < bytes); + } +}; +class DescriptorRangeChanges { + std::array ring_{}; + uint64_t serial_{}; +public: + void record(uint64_t start, uint64_t bytes) { + if (bytes) { + ring_[serial_++ % ring_.size()] = {start, start + (std::min)(UINT64_MAX-start, bytes-1)}; + } + } + bool read(uint64_t& cursor, DescriptorRanges& out) const { + const auto previous = cursor; + cursor = serial_; + if (serial_ - previous > ring_.size()) return false; + for (auto i = previous; i != serial_; ++i) out.ranges.push_back(ring_[i % ring_.size()]); + return true; + } +}; +} -- cgit v1.2.3