perf: add Vulkan pipeline cache persistence for faster startup

Create a VkPipelineCache at device init, loaded from disk if available.
All 65 pipeline creation calls across 19 renderer files now use the
shared cache. On shutdown, the cache is serialized to disk so subsequent
launches skip redundant shader compilation.

Cache path: ~/.local/share/wowee/pipeline_cache.bin (Linux),
~/Library/Caches/wowee/ (macOS), %APPDATA%\wowee\ (Windows).
Stale/corrupt caches are handled gracefully (fallback to empty cache).
This commit is contained in:
Kelsi 2026-03-24 09:47:03 -07:00
parent c18720f0f0
commit c8c01f8ac0
23 changed files with 192 additions and 72 deletions

View file

@ -74,6 +74,7 @@ public:
uint32_t getGraphicsQueueFamily() const { return graphicsQueueFamily; }
VmaAllocator getAllocator() const { return allocator; }
VkSurfaceKHR getSurface() const { return surface; }
VkPipelineCache getPipelineCache() const { return pipelineCache_; }
VkSwapchainKHR getSwapchain() const { return swapchain; }
VkFormat getSwapchainFormat() const { return swapchainFormat; }
@ -130,6 +131,8 @@ private:
void destroySwapchain();
bool createCommandPools();
bool createSyncObjects();
bool createPipelineCache();
void savePipelineCache();
bool createImGuiResources();
void destroyImGuiResources();
@ -144,6 +147,9 @@ private:
VkDevice device = VK_NULL_HANDLE;
VmaAllocator allocator = VK_NULL_HANDLE;
// Pipeline cache (persisted to disk for faster startup)
VkPipelineCache pipelineCache_ = VK_NULL_HANDLE;
VkQueue graphicsQueue = VK_NULL_HANDLE;
VkQueue presentQueue = VK_NULL_HANDLE;
uint32_t graphicsQueueFamily = 0;