@@ -35,6 +35,7 @@ VkCommandBuffer commandBuffers[FRAMES_IN_FLIGHT];
3535VkFence fences[FRAMES_IN_FLIGHT];
3636VkSemaphore acquireSemaphores[FRAMES_IN_FLIGHT];
3737VkSemaphore releaseSemaphores[FRAMES_IN_FLIGHT];
38+ VkPipelineCache pipelineCache;
3839
3940VulkanBuffer spriteVertexBuffer;
4041VulkanBuffer spriteIndexBuffer;
@@ -236,6 +237,8 @@ void initApplication(SDL_Window* window) {
236237 SDL_Vulkan_CreateSurface (window, context->instance , &surface);
237238 swapchain = createSwapchain (context, surface, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_STORAGE_BIT);
238239
240+ pipelineCache = createPipelineCache (context, " ../shaders/pipeline_cache.bin" );
241+
239242 recreateRenderPass ();
240243
241244 // model = createModel(context, "../data/models/monkey.glb");
@@ -396,7 +399,7 @@ void initApplication(SDL_Window* window) {
396399 vertexInputBinding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
397400 vertexInputBinding.stride = sizeof (float ) * 7 ;
398401 spritePipeline = createPipeline (context, " ../shaders/texture_vert.spv" , " ../shaders/texture_frag.spv" , renderPass, swapchain.width , swapchain.height ,
399- vertexAttributeDescriptions, ARRAY_COUNT (vertexAttributeDescriptions), &vertexInputBinding, 1 , &spriteDescriptorLayout, 0 , 0 , VK_SAMPLE_COUNT_4_BIT);
402+ vertexAttributeDescriptions, ARRAY_COUNT (vertexAttributeDescriptions), &vertexInputBinding, 1 , &spriteDescriptorLayout, 0 , 0 , VK_SAMPLE_COUNT_4_BIT, 0 , pipelineCache );
400403
401404
402405 VkVertexInputAttributeDescription modelAttributeDescriptions[3 ] = {};
@@ -417,7 +420,7 @@ void initApplication(SDL_Window* window) {
417420 modelInputBinding.inputRate = VK_VERTEX_INPUT_RATE_VERTEX;
418421 modelInputBinding.stride = sizeof (float ) * 8 ;
419422 modelPipeline = createPipeline (context, " ../shaders/model_vert.spv" , " ../shaders/model_frag.spv" , renderPass, swapchain.width , swapchain.height ,
420- modelAttributeDescriptions, ARRAY_COUNT (modelAttributeDescriptions), &modelInputBinding, 1 , &modelDescriptorSetLayout, 0 , 0 , VK_SAMPLE_COUNT_4_BIT);
423+ modelAttributeDescriptions, ARRAY_COUNT (modelAttributeDescriptions), &modelInputBinding, 1 , &modelDescriptorSetLayout, 0 , 0 , VK_SAMPLE_COUNT_4_BIT, 0 , pipelineCache );
421424
422425
423426 // Preparations for Guassian Blur pass
@@ -465,8 +468,8 @@ void initApplication(SDL_Window* window) {
465468 specializationInfo.dataSize = sizeof (vertical);
466469 specializationInfo.pData = &vertical;
467470
468- gaussPipelineVertical = createPipeline (context, " ../shaders/gaussian_vert.spv" , " ../shaders/gaussian_frag.spv" , gaussRenderPass, swapchain.width , swapchain.height , 0 , 0 , 0 , 1 , &gaussDescriptorSetLayout, &pushConstants, 0 , VK_SAMPLE_COUNT_1_BIT, &specializationInfo);
469- gaussPipelineHorizontal = createPipeline (context, " ../shaders/gaussian_vert.spv" , " ../shaders/gaussian_frag.spv" , gaussRenderPassFinal, swapchain.width , swapchain.height , 0 , 0 , 0 , 1 , &gaussDescriptorSetLayout, &pushConstants, 0 , VK_SAMPLE_COUNT_1_BIT);
471+ gaussPipelineVertical = createPipeline (context, " ../shaders/gaussian_vert.spv" , " ../shaders/gaussian_frag.spv" , gaussRenderPass, swapchain.width , swapchain.height , 0 , 0 , 0 , 1 , &gaussDescriptorSetLayout, &pushConstants, 0 , VK_SAMPLE_COUNT_1_BIT, &specializationInfo, pipelineCache );
472+ gaussPipelineHorizontal = createPipeline (context, " ../shaders/gaussian_vert.spv" , " ../shaders/gaussian_frag.spv" , gaussRenderPassFinal, swapchain.width , swapchain.height , 0 , 0 , 0 , 1 , &gaussDescriptorSetLayout, &pushConstants, 0 , VK_SAMPLE_COUNT_1_BIT, 0 , pipelineCache );
470473
471474 for (uint32_t i = 0 ; i < ARRAY_COUNT (fences); ++i) {
472475 VkFenceCreateInfo createInfo = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO };
@@ -923,6 +926,8 @@ void shutdownApplication() {
923926 vkDestroySampler (context->device , sampler, 0 );
924927 vkDestroySampler (context->device , linearSampler, 0 );
925928
929+ destroyPipelineCache (context, pipelineCache, " ../shaders/pipeline_cache.bin" );
930+
926931 for (uint32_t i = 0 ; i < sceneFramebuffers.size (); ++i) {
927932 VK (vkDestroyFramebuffer (context->device , sceneFramebuffers[i], 0 ));
928933 VK (vkDestroyFramebuffer (context->device , gaussFramebuffers[i], 0 ));
0 commit comments