mirror of
https://github.com/Facepunch/sbox-public.git
synced 2026-04-18 05:17:53 -04:00
Rewrites Vulkan per-thread resource management to use a pooled PerThreadDataVulkan_t slot system with a TLS fast-path, replacing the previous thread-index/map/array approach and updating Vulkan call sites to pass PerThreadDataVulkan_t* instead of thread indices. * Remove ThreadIndex, SetAssociatedThreadIndex & MaxDeviceThreads (see what breaks) * Refactor per-thread vulkan data into a single pooled struct Replace fixed-array per-thread Vulkan data with a dynamic slot pool. Threads grab slots on demand, hot path is just a TLS read, completly lock-free Two mechanisms manage slot lifetime: - Ref counting: render contexts and the render thread AddRef to keep their slot alive as long as they need it. - Idle reclaim: slots nobody is holding onto get recycled after N frames of inactivity. Keeps short-lived threads (async shader compiles, texture uploads) from leaking slots, while still letting a thread that calls GetPerThreadData() every frame hang onto the same slot and all its resources (command pools, descriptor pools, pipeline cache, etc). Moved VkPipelineCache into the per-thread struct with lazy creation. * Add CRenderDeviceVulkan::GetPerThreadData() acquires from pool * Use PerThreadData eveywhere instead of ThreadIndex And do proper thread data shutdown cleanup * Main render thread gets it's own permaned PerThreadData instance * Rework pipelinecache to use PerThreadData instead of VkPipelineCache directly