From bf99c4450b55a0bee268c382cba8c60796cd068b Mon Sep 17 00:00:00 2001 From: Stan Iliev Date: Fri, 29 Mar 2019 11:09:11 -0400 Subject: Invalidate Skia shader cache if Vulkan driver has changed Test: Ran apps several time and observed shader cache validation Change-Id: I7c2620b9a0eefcb7acedc86647ecf44805518b2f --- libs/hwui/renderthread/RenderThread.cpp | 4 ++-- libs/hwui/renderthread/VulkanManager.cpp | 1 + libs/hwui/renderthread/VulkanManager.h | 3 +++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/libs/hwui/renderthread/RenderThread.cpp b/libs/hwui/renderthread/RenderThread.cpp index 6cce31943d03..369eee764a99 100644 --- a/libs/hwui/renderthread/RenderThread.cpp +++ b/libs/hwui/renderthread/RenderThread.cpp @@ -209,8 +209,8 @@ void RenderThread::requireVkContext() { mVkManager->initialize(); GrContextOptions options; initGrContextOptions(options); - // TODO: get a string describing the SPIR-V compiler version and use it here - cacheManager().configureContext(&options, nullptr, 0); + auto vkDriverVersion = mVkManager->getDriverVersion(); + cacheManager().configureContext(&options, &vkDriverVersion, sizeof(vkDriverVersion)); sk_sp grContext = mVkManager->createContext(options); LOG_ALWAYS_FATAL_IF(!grContext.get()); setGrContext(grContext); diff --git a/libs/hwui/renderthread/VulkanManager.cpp b/libs/hwui/renderthread/VulkanManager.cpp index b8ebf3bb0ca9..35729c1b6496 100644 --- a/libs/hwui/renderthread/VulkanManager.cpp +++ b/libs/hwui/renderthread/VulkanManager.cpp @@ -170,6 +170,7 @@ void VulkanManager::setupDevice(GrVkExtensions& grExtensions, VkPhysicalDeviceFe VkPhysicalDeviceProperties physDeviceProperties; mGetPhysicalDeviceProperties(mPhysicalDevice, &physDeviceProperties); LOG_ALWAYS_FATAL_IF(physDeviceProperties.apiVersion < VK_MAKE_VERSION(1, 1, 0)); + mDriverVersion = physDeviceProperties.driverVersion; // query to get the initial queue props size uint32_t queueCount; diff --git a/libs/hwui/renderthread/VulkanManager.h b/libs/hwui/renderthread/VulkanManager.h index c2d18029c731..54333f326d4f 100644 --- a/libs/hwui/renderthread/VulkanManager.h +++ b/libs/hwui/renderthread/VulkanManager.h @@ -82,6 +82,8 @@ public: sk_sp createContext(const GrContextOptions& options); + uint32_t getDriverVersion() const { return mDriverVersion; } + private: friend class VulkanSurface; // Sets up the VkInstance and VkDevice objects. Also fills out the passed in @@ -178,6 +180,7 @@ private: }; SwapBehavior mSwapBehavior = SwapBehavior::Discard; GrVkExtensions mExtensions; + uint32_t mDriverVersion = 0; }; } /* namespace renderthread */ -- cgit v1.2.3-59-g8ed1b