mirror of
https://github.com/ubiquitarianism/leonida.git
synced 2026-11-26 23:10:53 +01:00
[PR #1898] runtime: cache ScratchBuffers device addresses and use best-fit largest-4 spare reuse (RT-VK-SCRATCH-BEST-FIT-AND-CACHE) #1909
Labels
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
starred/leonida#1909
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/ubiquitarianism/leonida/pull/1898
Author: @IlyassRS3
Created: 11/25/2026
Status: 🔄 Open
Base:
main← Head:fix/rt-vk-scratch-best-fit-and-cache📝 Commits (1)
a5fa6c0runtime: cache ScratchBuffers device addresses and use best-fit largest-4 spare reuse (RT-VK-SCRATCH-BEST-FIT-AND-CACHE)📊 Changes
2 files changed (+173 additions, -11 deletions)
View changed files
📝
runtime/src/vulkan_scratch.h(+30 -10)📝
runtime/test/vulkan_scratch_test.cpp(+143 -1)📄 Description
Item ID:
RT-VK-SCRATCH-BEST-FIT-AND-CACHE(claimed in #1608).Summary
Optimizes
leonida::ScratchBuffers(runtime/src/vulkan_scratch.h) for continuous per-frame indirect clamping, quad index expansion, and staged transfer workloads:VkDeviceAddressonce per chunk (make_chunk/claim):Chunknow cachesVkDeviceAddress addressonce when the chunk is created (whenaddressable_is true), instead of callingvkGetBufferDeviceAddressthrough the Vulkan driver on every singleget(..., address)suballocation.vkGetBufferDeviceAddress.claim):size >= bytesinstead of first-fit, so small suballocations do not consume a 16+ MiB spare chunk and trigger fresh largeVkDeviceMemoryallocations later in the same frame.collect):spare_is already at the 4-chunk cap, a completed chunk larger than the smallest spare replaces and destroys that smallest spare instead of being destroyed itself, preventing repeated large buffer/VRAM allocation churn across frames while keeping the cap strictly at 4.make_chunk):out = {}on entry and whenvkCreateBufferfails so a non-conforming driver/mock writing a handle on error cannot leave stale state.Verification
runtime/test/vulkan_scratch_test.cpp(extended with cached-address, best-fit, largest-4 eviction, and failingvkCreateBuffertests; Clang 20, C++20,-Wall -Wextra -Werror):-O2× 3: PASSvulkan_indirect_clamp.h+vulkan_scratch.h): PASS.main'svulkan_scratch.h: fails onmain(vk.get_device_address_calls == 1), passes on this branch.python3 -I scripts/check_no_game_data.pyandpython3 -I tests/test_text_write_line_endings.pypassed.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.