diff --git a/example/Vulkan/VKDeviceAttribute.cpp b/example/Vulkan/VKDeviceAttribute.cpp index 3af1c170..bd30fd9c 100644 --- a/example/Vulkan/VKDeviceAttribute.cpp +++ b/example/Vulkan/VKDeviceAttribute.cpp @@ -131,6 +131,9 @@ DeviceAttribute::DeviceAttribute(VkInstance inst,const PhysicalDevice *pd,VkSurf DeviceAttribute::~DeviceAttribute() { + if(pipeline_cache) + vkDestroyPipelineCache(device,pipeline_cache,nullptr); + if(desc_pool) vkDestroyDescriptorPool(device,desc_pool,nullptr); diff --git a/example/Vulkan/VKDeviceAttribute.h b/example/Vulkan/VKDeviceAttribute.h index 29efde34..475533e5 100644 --- a/example/Vulkan/VKDeviceAttribute.h +++ b/example/Vulkan/VKDeviceAttribute.h @@ -50,6 +50,8 @@ struct DeviceAttribute }depth; VkDescriptorPool desc_pool =nullptr; + + VkPipelineCache pipeline_cache =nullptr; public: diff --git a/example/Vulkan/VKDeviceCreater.cpp b/example/Vulkan/VKDeviceCreater.cpp index 2057b1b3..cfeee45d 100644 --- a/example/Vulkan/VKDeviceCreater.cpp +++ b/example/Vulkan/VKDeviceCreater.cpp @@ -296,6 +296,23 @@ namespace return desc_pool; } + + VkPipelineCache CreatePipelineCache(VkDevice device) + { + VkPipelineCacheCreateInfo pipelineCache; + pipelineCache.sType = VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO; + pipelineCache.pNext = nullptr; + pipelineCache.initialDataSize = 0; + pipelineCache.pInitialData = nullptr; + pipelineCache.flags = 0; + + VkPipelineCache cache; + + if(!vkCreatePipelineCache(device, &pipelineCache, nullptr, &cache)!=VK_SUCCESS) + return(nullptr); + + return cache; + } }//namespace Device *CreateRenderDevice(VkInstance inst,const PhysicalDevice *physical_device,Window *win) @@ -342,6 +359,11 @@ Device *CreateRenderDevice(VkInstance inst,const PhysicalDevice *physical_device if(!attr->desc_pool) return(nullptr); + attr->pipeline_cache=CreatePipelineCache(attr->device); + + if(!attr->pipeline_cache) + return(nullptr); + auto_delete.Clear(); return(new Device(attr));