Changeset e83b155 in opengl-game


Ignore:
Timestamp:
Oct 18, 2019, 2:40:47 PM (5 years ago)
Author:
Dmitry Portnoy <dmitry.portnoy@…>
Branches:
feature/imgui-sdl, master, points-test
Children:
603b5bc
Parents:
b794178
git-author:
Dmitry Portnoy <dmitry.portnoy@…> (10/18/19 14:38:29)
git-committer:
Dmitry Portnoy <dmitry.portnoy@…> (10/18/19 14:40:47)
Message:

In vulkangame, destroy the texture sampler, all the uniform buffer resources, and all the resources for each Vulkan image before terminating the program

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • vulkan-game.cpp

    rb794178 re83b155  
    231231   cleanupSwapChain();
    232232
     233   VulkanUtils::destroyVulkanImage(device, floorTextureImage);
     234   VulkanUtils::destroyVulkanImage(device, sdlOverlayImage);
     235
     236   vkDestroySampler(device, textureSampler, nullptr);
     237
    233238   for (GraphicsPipeline_Vulkan pipeline : graphicsPipelines) {
    234239      pipeline.cleanupBuffers();
     
    660665
    661666   vkDestroySwapchainKHR(device, swapChain, nullptr);
    662 }
     667
     668   for (size_t i = 0; i < swapChainImages.size(); i++) {
     669      vkDestroyBuffer(device, uniformBuffers[i], nullptr);
     670      vkFreeMemory(device, uniformBuffersMemory[i], nullptr);
     671   }
     672}
  • vulkan-ref.cpp

    rb794178 re83b155  
    19651965         createGraphicsPipeline("shaders/scene-vert.spv", "shaders/scene-frag.spv", scenePipeline);
    19661966         createDescriptorPool(scenePipeline);
    1967 /*** END OF REFACTORED CODE ***/
    19681967         createDescriptorSets(scenePipeline);
    19691968
    1970 /*** START OF REFACTORED CODE ***/
    19711969         createGraphicsPipeline("shaders/overlay-vert.spv", "shaders/overlay-frag.spv", overlayPipeline);
    19721970         createDescriptorPool(overlayPipeline);
    1973 /*** END OF REFACTORED CODE ***/
    19741971         createDescriptorSets(overlayPipeline);
     1972/*** END OF REFACTORED CODE ***/
    19751973
    19761974         createCommandBuffers();
     
    19801978/*** START OF REFACTORED CODE ***/
    19811979         cleanupSwapChain();
    1982 /*** END OF REFACTORED CODE ***/
    19831980
    19841981         vkDestroySampler(device, textureSampler, nullptr);
     
    19921989         vkFreeMemory(device, sdlOverlayImageMemory, nullptr);
    19931990
    1994 /*** START OF REFACTORED CODE ***/
    19951991         cleanupPipelineBuffers(scenePipeline);
    19961992         cleanupPipelineBuffers(overlayPipeline);
     
    20682064
    20692065         vkDestroySwapchainKHR(device, swapChain, nullptr);
    2070 /*** END OF REFACTORED CODE ***/
    20712066
    20722067         for (size_t i = 0; i < swapChainImages.size(); i++) {
     
    20762071      }
    20772072
    2078 /*** START OF REFACTORED CODE ***/
    20792073      void cleanupPipeline(GraphicsPipelineInfo& pipeline) {
    20802074         vkDestroyPipeline(device, pipeline.pipeline, nullptr);
     
    20822076         vkDestroyPipelineLayout(device, pipeline.pipelineLayout, nullptr);
    20832077      }
    2084 /*** END OF REFACTORED CODE ***/
    20852078
    20862079      void cleanupPipelineBuffers(GraphicsPipelineInfo& pipeline) {
    2087 /*** START OF REFACTORED CODE ***/
    20882080         vkDestroyDescriptorSetLayout(device, pipeline.descriptorSetLayout, nullptr);
    20892081/*** END OF REFACTORED CODE ***/
  • vulkan-utils.cpp

    rb794178 re83b155  
    475475   return format == VK_FORMAT_D32_SFLOAT_S8_UINT || format == VK_FORMAT_D24_UNORM_S8_UINT;
    476476}
     477
     478void VulkanUtils::destroyVulkanImage(VkDevice& device, VulkanImage& image) {
     479   vkDestroyImageView(device, image.imageView, nullptr);
     480   vkDestroyImage(device, image.image, nullptr);
     481   vkFreeMemory(device, image.imageMemory, nullptr);
     482}
  • vulkan-utils.hpp

    rb794178 re83b155  
    8383
    8484      static bool hasStencilComponent(VkFormat format);
     85
     86      static void destroyVulkanImage(VkDevice& device, VulkanImage& image);
    8587};
    8688
Note: See TracChangeset for help on using the changeset viewer.