From 131acc313319f6e229dd1343276684a358ec579d Mon Sep 17 00:00:00 2001 From: Steven Noonan Date: Fri, 23 Jun 2023 04:12:09 -0700 Subject: [PATCH] Vulkan: fix blob caching of initial pipeline cache When creating a new pipeline cache and the blob cache doesn't have a matching one we can load, we unintentionally skipped serializing it to the blob cache until the pipeline cache state changed later on. Bug: angleproject:8230 Change-Id: If86d1bd169a63da9f9a394284a754bccb7d52e20 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/4639496 Commit-Queue: Shahbaz Youssefi Reviewed-by: Shahbaz Youssefi --- src/libANGLE/renderer/vulkan/RendererVk.cpp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/libANGLE/renderer/vulkan/RendererVk.cpp b/src/libANGLE/renderer/vulkan/RendererVk.cpp index 3e1b72782..b37820d37 100644 --- a/src/libANGLE/renderer/vulkan/RendererVk.cpp +++ b/src/libANGLE/renderer/vulkan/RendererVk.cpp @@ -3407,11 +3407,14 @@ angle::Result RendererVk::initializeDevice(DisplayVk *displayVk, uint32_t queueF mDefaultUniformBufferSize, getPhysicalDeviceProperties().limits.maxUniformBufferRange); // Initialize the vulkan pipeline cache. - bool success = false; { std::unique_lock lock(mPipelineCacheMutex); - ANGLE_TRY(initPipelineCache(displayVk, &mPipelineCache, &success)); - ANGLE_TRY(getPipelineCacheSize(displayVk, &mPipelineCacheSizeAtLastSync)); + bool loadedFromBlobCache = false; + ANGLE_TRY(initPipelineCache(displayVk, &mPipelineCache, &loadedFromBlobCache)); + if (loadedFromBlobCache) + { + ANGLE_TRY(getPipelineCacheSize(displayVk, &mPipelineCacheSizeAtLastSync)); + } } // Track the set of supported pipeline stages. This is used when issuing image layout @@ -4774,17 +4777,18 @@ angle::Result RendererVk::getPipelineCache(vk::PipelineCacheAccess *pipelineCach { // We should now recreate the pipeline cache with the blob cache pipeline data. vk::PipelineCache pCache; - bool success = false; - ANGLE_TRY(initPipelineCache(displayVk, &pCache, &success)); - if (success) + bool loadedFromBlobCache = false; + ANGLE_TRY(initPipelineCache(displayVk, &pCache, &loadedFromBlobCache)); + if (loadedFromBlobCache) { // Merge the newly created pipeline cache into the existing one. mPipelineCache.merge(mDevice, 1, pCache.ptr()); + + ANGLE_TRY(getPipelineCacheSize(displayVk, &mPipelineCacheSizeAtLastSync)); } + mPipelineCacheInitialized = true; pCache.destroy(mDevice); - - ANGLE_TRY(getPipelineCacheSize(displayVk, &mPipelineCacheSizeAtLastSync)); } pipelineCacheOut->init(&mPipelineCache, &mPipelineCacheMutex);