From aac66a1b61a0e4c1c2b85d89bc818a8b521bcffa Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 13 Nov 2016 18:39:06 +1000 Subject: Vulkan: Implement a pipeline UID cache This stores enough information to recreate the pipeline, including the shader UIDs, blend/depth/rasterization state, primitive and vertex format. --- Source/Core/VideoBackends/Vulkan/ObjectCache.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/ObjectCache.h') diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.h b/Source/Core/VideoBackends/Vulkan/ObjectCache.h index b991b8a3b8..e102440164 100644 --- a/Source/Core/VideoBackends/Vulkan/ObjectCache.h +++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.h @@ -111,9 +111,18 @@ public: // Perform at startup, create descriptor layouts, compiles all static shaders. bool Initialize(); - // Find a pipeline by the specified description, if not found, attempts to create it + // Creates a pipeline for the specified description. The resulting pipeline, if successful + // is not stored anywhere, this is left up to the caller. + VkPipeline CreatePipeline(const PipelineInfo& info); + + // Find a pipeline by the specified description, if not found, attempts to create it. VkPipeline GetPipeline(const PipelineInfo& info); + // Find a pipeline by the specified description, if not found, attempts to create it. If this + // resulted in a pipeline being created, the second field of the return value will be false, + // otherwise for a cache hit it will be true. + std::pair GetPipelineWithCacheResult(const PipelineInfo& info); + // Wipes out the pipeline cache, use when MSAA modes change, for example // Also destroys the data that would be stored in the disk cache. void ClearPipelineCache(); @@ -133,6 +142,9 @@ public: VkShaderModule GetPassthroughVertexShader() const { return m_passthrough_vertex_shader; } VkShaderModule GetScreenQuadGeometryShader() const { return m_screen_quad_geometry_shader; } VkShaderModule GetPassthroughGeometryShader() const { return m_passthrough_geometry_shader; } + // Gets the filename of the specified type of cache object (e.g. vertex shader, pipeline). + std::string GetDiskCacheFileName(const char* type); + private: bool CreatePipelineCache(bool load_from_disk); void DestroyPipelineCache(); @@ -148,8 +160,6 @@ private: void DestroySharedShaders(); void DestroySamplers(); - std::string GetDiskCacheFileName(const char* type); - std::array m_descriptor_set_layouts = {}; VkPipelineLayout m_standard_pipeline_layout = VK_NULL_HANDLE; -- cgit v1.2.3 From 9604b336c8213c43dff90fab67df8eaa31cdbbb5 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 13 Nov 2016 18:41:36 +1000 Subject: Vulkan: Don't destroy the device's pipeline cache on MSAA mode change The user could switch back again, and this would mean this data would be lost. Disk space is cheap, and it's not going to be much. --- Source/Core/VideoBackends/Vulkan/ObjectCache.h | 4 ---- 1 file changed, 4 deletions(-) (limited to 'Source/Core/VideoBackends/Vulkan/ObjectCache.h') diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.h b/Source/Core/VideoBackends/Vulkan/ObjectCache.h index e102440164..a1b9be54a4 100644 --- a/Source/Core/VideoBackends/Vulkan/ObjectCache.h +++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.h @@ -123,10 +123,6 @@ public: // otherwise for a cache hit it will be true. std::pair GetPipelineWithCacheResult(const PipelineInfo& info); - // Wipes out the pipeline cache, use when MSAA modes change, for example - // Also destroys the data that would be stored in the disk cache. - void ClearPipelineCache(); - // Saves the pipeline cache to disk. Call when shutting down. void SavePipelineCache(); -- cgit v1.2.3 From 8d48319414d7e3f348e4ef38e976121e9a1fce6a Mon Sep 17 00:00:00 2001 From: Stenzek Date: Sun, 13 Nov 2016 18:50:10 +1000 Subject: Vulkan: Validate the pipeline cache before using it This ensures that if a user changes adapters or vendors we're not passing invalid data to the driver. --- Source/Core/VideoBackends/Vulkan/ObjectCache.h | 1 + 1 file changed, 1 insertion(+) (limited to 'Source/Core/VideoBackends/Vulkan/ObjectCache.h') diff --git a/Source/Core/VideoBackends/Vulkan/ObjectCache.h b/Source/Core/VideoBackends/Vulkan/ObjectCache.h index a1b9be54a4..26593d139d 100644 --- a/Source/Core/VideoBackends/Vulkan/ObjectCache.h +++ b/Source/Core/VideoBackends/Vulkan/ObjectCache.h @@ -143,6 +143,7 @@ public: private: bool CreatePipelineCache(bool load_from_disk); + bool ValidatePipelineCache(const u8* data, size_t data_length); void DestroyPipelineCache(); void LoadShaderCaches(); void DestroyShaderCaches(); -- cgit v1.2.3