public void Dispose()
 {
     imageAvailableSemaphore.Dispose();
     renderFinishedSemaphore.Dispose();
     indexBufferMemory.Dispose();
     indexBuffer.Dispose();
     vertexBufferMemory.Dispose();
     vertexBuffer.Dispose();
     commandPool.Dispose();
     foreach (var fb in swapchainFramebuffers)
     {
         fb.Dispose();
     }
     pipeline.Dispose();
     pipelineLayout.Dispose();
     renderPass.Dispose();
     foreach (var iv in swapchainImageViews)
     {
         iv.Dispose();
     }
     swapchain.Dispose();
     device.Dispose();
     surface.Dispose();
     debugCallbacks.Dispose();
     instance.Dispose();
     GLFW.DestroyWindow(window);
     GLFW.Terminate();
 }
        void CreateRenderPass()
        {
            var colorAttachment = new VkAttachmentDescription();

            colorAttachment.format         = swapchainImageFormat;
            colorAttachment.samples        = VkSampleCountFlags._1_Bit;
            colorAttachment.loadOp         = VkAttachmentLoadOp.Clear;
            colorAttachment.storeOp        = VkAttachmentStoreOp.Store;
            colorAttachment.stencilLoadOp  = VkAttachmentLoadOp.DontCare;
            colorAttachment.stencilStoreOp = VkAttachmentStoreOp.DontCare;
            colorAttachment.initialLayout  = VkImageLayout.Undefined;
            colorAttachment.finalLayout    = VkImageLayout.PresentSrcKhr;

            var colorAttachmentRef = new VkAttachmentReference();

            colorAttachmentRef.attachment = 0;
            colorAttachmentRef.layout     = VkImageLayout.ColorAttachmentOptimal;

            var subpass = new VkSubpassDescription();

            subpass.pipelineBindPoint = VkPipelineBindPoint.Graphics;
            subpass.colorAttachments  = new List <VkAttachmentReference> {
                colorAttachmentRef
            };

            var dependency = new VkSubpassDependency();

            dependency.srcSubpass    = -1; //VK_SUBPASS_EXTERNAL
            dependency.dstSubpass    = 0;
            dependency.srcStageMask  = VkPipelineStageFlags.BottomOfPipeBit;
            dependency.srcAccessMask = VkAccessFlags.MemoryReadBit;
            dependency.dstStageMask  = VkPipelineStageFlags.ColorAttachmentOutputBit;
            dependency.dstAccessMask = VkAccessFlags.ColorAttachmentReadBit
                                       | VkAccessFlags.ColorAttachmentWriteBit;

            var info = new VkRenderPassCreateInfo();

            info.attachments = new List <VkAttachmentDescription> {
                colorAttachment
            };
            info.subpasses = new List <VkSubpassDescription> {
                subpass
            };
            info.dependencies = new List <VkSubpassDependency> {
                dependency
            };

            renderPass?.Dispose();
            renderPass = new VkRenderPass(device, info);
        }
 public void Dispose()
 {
     generator.Dispose();
     imageAvailableSemaphore.Dispose();
     renderFinishedSemaphore.Dispose();
     descriptorPool.Dispose();
     uniformBuffer.Dispose();
     uniformBufferMemory.Dispose();
     indexBuffer.Dispose();
     indexBufferMemory.Dispose();
     vertexBuffer.Dispose();
     vertexBufferMemory.Dispose();
     textureSampler.Dispose();
     textureImageView.Dispose();
     textureImage.Dispose();
     textureImageMemory.Dispose();
     stagingBuffer.Dispose();
     stagingBufferMemory.Dispose();
     commandPool.Dispose();
     foreach (var fb in swapchainFramebuffers)
     {
         fb.Dispose();
     }
     pipeline.Dispose();
     pipelineLayout.Dispose();
     descriptorSetLayout.Dispose();
     renderPass.Dispose();
     foreach (var iv in swapchainImageViews)
     {
         iv.Dispose();
     }
     swapchain.Dispose();
     device.Dispose();
     surface.Dispose();
     instance.Dispose();
     window.Dispose();
     GLFW.Terminate();
 }