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.
This commit is contained in:
Stenzek
2016-11-13 18:39:06 +10:00
parent 681294586b
commit aac66a1b61
7 changed files with 227 additions and 40 deletions

View File

@ -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<VkPipeline, bool> 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<VkDescriptorSetLayout, NUM_DESCRIPTOR_SETS> m_descriptor_set_layouts = {};
VkPipelineLayout m_standard_pipeline_layout = VK_NULL_HANDLE;