VKRenderPass::~VKRenderPass() 
            {
                VKRenderer* renderer = VKRenderer::RendererInstance;

                //Free input descriptor sets
                vkFreeDescriptorSets(m_device, m_descriptorPool, static_cast<uint32_t>(m_inputTargetDescriptorSets.size()), m_inputTargetDescriptorSets.data());

                //Destroy framebuffer images
                for (size_t i = 0; i < m_colorImages.size(); i++)
                {
                    Image_vk image = m_colorImages[i];

                    vkDestroyImageView(m_device, image.view, nullptr);
                    vkDestroyImage(m_device, image.image, nullptr);
                    vkFreeMemory(m_device, image.memory, nullptr);
                }

                //Destroy depth image
                vkDestroyImageView(m_device, m_depthImage.view, nullptr);
                vkDestroyImage(m_device, m_depthImage.image, nullptr);
                vkFreeMemory(m_device, m_depthImage.memory, nullptr);
                
                //Free instance texel buffers
                if(m_instanceBlock.buffer != VK_NULL_HANDLE)
                    DeleteUniformBuffer(m_device, m_instanceBlock);

                //Destroy framebuffer
                vkDestroyFramebuffer(m_device, m_framebuffer, nullptr);

                //Destroy the render pass
                vkDestroyRenderPass(m_device, m_renderPass, nullptr);
            }
Exemplo n.º 2
0
    void vkImageBase::cleanup() {

        VulkanCore * instance = VulkanCore::getInstance();
        VkDevice device = instance->getDevice();

        if(imageView != 0) {
            vkDestroyImageView(device, imageView, nullptr);
            imageView = 0;
        }

        if(imageHandle != 0 ) {
            vkDestroyImage(device, imageHandle, nullptr);
            imageHandle = 0;
        }

        if(device_memory != 0) {
            vkFreeMemory(device, device_memory, nullptr);
            device_memory = 0;
        }

        if(cascadeImageView.size() != 0) {
            for(int i = 0; i < cascadeImageView.size(); i++)
                vkDestroyImageView(device, cascadeImageView[i], nullptr);

            cascadeImageView.clear();
        }
    }
Exemplo n.º 3
0
	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class

		vkDestroyImageView(device, attachments.color.view, nullptr);
		vkDestroyImage(device, attachments.color.image, nullptr);
		vkFreeMemory(device, attachments.color.memory, nullptr);

		vkDestroyImageView(device, attachments.depth.view, nullptr);
		vkDestroyImage(device, attachments.depth.image, nullptr);
		vkFreeMemory(device, attachments.depth.memory, nullptr);

		vkDestroyPipeline(device, pipelines.attachmentRead, nullptr);
		vkDestroyPipeline(device, pipelines.attachmentWrite, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayouts.attachmentWrite, nullptr);
		vkDestroyPipelineLayout(device, pipelineLayouts.attachmentRead, nullptr);

		vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.attachmentWrite, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.attachmentRead, nullptr);

		vkDestroyRenderPass(device, uiRenderPass, nullptr);

		scene.destroy();
		uniformBuffers.matrices.destroy();
		uniformBuffers.params.destroy();
	}
void    ImGui_ImplGlfwVulkan_InvalidateDeviceObjects()
{
    ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects();
    for (int i=0; i<IMGUI_VK_QUEUED_FRAMES; i++)
    {
        if (g_VertexBuffer[i])
            vkDestroyBuffer(g_Device, g_VertexBuffer[i], g_Allocator);
        if (g_VertexBufferMemory[i])
            vkFreeMemory(g_Device, g_VertexBufferMemory[i], g_Allocator);
        if (g_IndexBuffer[i])
            vkDestroyBuffer(g_Device, g_IndexBuffer[i], g_Allocator);
        if (g_IndexBufferMemory[i])
            vkFreeMemory(g_Device, g_IndexBufferMemory[i], g_Allocator);
    }

    if (g_FontView)
        vkDestroyImageView(g_Device, g_FontView, g_Allocator);
    if (g_FontImage)
        vkDestroyImage(g_Device, g_FontImage, g_Allocator);
    if (g_FontMemory)
        vkFreeMemory(g_Device, g_FontMemory, g_Allocator);
    if (g_FontSampler)
        vkDestroySampler(g_Device, g_FontSampler, g_Allocator);

    if (g_DescriptorSetLayout)
        vkDestroyDescriptorSetLayout(g_Device, g_DescriptorSetLayout, g_Allocator);
    if (g_PipelineLayout)
        vkDestroyPipelineLayout(g_Device, g_PipelineLayout, g_Allocator);
    if (g_Pipeline)
        vkDestroyPipeline(g_Device, g_Pipeline, g_Allocator);
}
Exemplo n.º 5
0
	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class

		// Clean up texture resources
		vkDestroyImageView(device, cubeMap.view, nullptr);
		vkDestroyImage(device, cubeMap.image, nullptr);
		vkDestroySampler(device, cubeMap.sampler, nullptr);
		vkFreeMemory(device, cubeMap.deviceMemory, nullptr);

		vkDestroyPipeline(device, pipelines.skybox, nullptr);
		vkDestroyPipeline(device, pipelines.reflect, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);

		for (auto& model : models.objects) {
			model.destroy();
		}
		models.skybox.destroy();

		uniformBuffers.object.destroy();
		uniformBuffers.skybox.destroy();
	}
  VulkanCommon::~VulkanCommon() {
    if( Vulkan.Device != VK_NULL_HANDLE ) {
      vkDeviceWaitIdle( Vulkan.Device );

      for( size_t i = 0; i < Vulkan.SwapChain.Images.size(); ++i ) {
        if( Vulkan.SwapChain.Images[i].ImageView != VK_NULL_HANDLE ) {
          vkDestroyImageView( GetDevice(), Vulkan.SwapChain.Images[i].ImageView, nullptr );
        }
      }

      if( Vulkan.SwapChain.Handle != VK_NULL_HANDLE ) {
        vkDestroySwapchainKHR( Vulkan.Device, Vulkan.SwapChain.Handle, nullptr );
      }
      vkDestroyDevice( Vulkan.Device, nullptr );
    }

    if( Vulkan.PresentationSurface != VK_NULL_HANDLE ) {
      vkDestroySurfaceKHR( Vulkan.Instance, Vulkan.PresentationSurface, nullptr );
    }

    if( Vulkan.Instance != VK_NULL_HANDLE ) {
      vkDestroyInstance( Vulkan.Instance, nullptr );
    }

    if( VulkanLibrary ) {
#if defined(VK_USE_PLATFORM_WIN32_KHR)
      FreeLibrary( VulkanLibrary );
#elif defined(VK_USE_PLATFORM_XCB_KHR) || defined(VK_USE_PLATFORM_XLIB_KHR)
      dlclose( VulkanLibrary );
#endif
    }
  }
Exemplo n.º 7
0
static void cleanup_vulkan()
{
    vkDestroyDescriptorPool(g_Device, g_DescriptorPool, g_Allocator);
    for (int i = 0; i < IMGUI_VK_QUEUED_FRAMES; i++)
    {
        vkDestroyFence(g_Device, g_Fence[i], g_Allocator);
        vkFreeCommandBuffers(g_Device, g_CommandPool[i], 1, &g_CommandBuffer[i]);
        vkDestroyCommandPool(g_Device, g_CommandPool[i], g_Allocator);
        vkDestroySemaphore(g_Device, g_PresentCompleteSemaphore[i], g_Allocator);
        vkDestroySemaphore(g_Device, g_RenderCompleteSemaphore[i], g_Allocator);
    }
    for (uint32_t i = 0; i < g_BackBufferCount; i++)
    {
        vkDestroyImageView(g_Device, g_BackBufferView[i], g_Allocator);
        vkDestroyFramebuffer(g_Device, g_Framebuffer[i], g_Allocator);
    }
    vkDestroyRenderPass(g_Device, g_RenderPass, g_Allocator);
    vkDestroySwapchainKHR(g_Device, g_Swapchain, g_Allocator);
    vkDestroySurfaceKHR(g_Instance, g_Surface, g_Allocator);

#ifdef IMGUI_VULKAN_DEBUG_REPORT
    // get the proc address of the function pointer, required for used extensions
    auto vkDestroyDebugReportCallbackEXT = (PFN_vkDestroyDebugReportCallbackEXT)vkGetInstanceProcAddr(g_Instance, "vkDestroyDebugReportCallbackEXT");
    vkDestroyDebugReportCallbackEXT(g_Instance, g_Debug_Report, g_Allocator);
#endif // IMGUI_VULKAN_DEBUG_REPORT

    vkDestroyDevice(g_Device, g_Allocator);
    vkDestroyInstance(g_Instance, g_Allocator);
}
void VulkanTexturedQuad::ShutdownImpl()
{
    vkDestroyPipeline(device_, pipeline_, nullptr);
    vkDestroyPipelineLayout(device_, pipelineLayout_, nullptr);

    vkDestroyBuffer(device_, vertexBuffer_, nullptr);
    vkDestroyBuffer(device_, indexBuffer_, nullptr);
    vkFreeMemory(device_, deviceBufferMemory_, nullptr);

    vkDestroyImageView (device_, rubyImageView_, nullptr);
    vkDestroyImage (device_, rubyImage_, nullptr);
    vkFreeMemory (device_, deviceImageMemory_, nullptr);

    vkDestroyBuffer (device_, uploadImageBuffer_, nullptr);
    vkFreeMemory (device_, uploadImageMemory_, nullptr);

    vkDestroyBuffer (device_, uploadBufferBuffer_, nullptr);
    vkFreeMemory (device_, uploadBufferMemory_, nullptr);

    vkDestroyDescriptorSetLayout (device_, descriptorSetLayout_, nullptr);
    vkDestroyDescriptorPool (device_, descriptorPool_, nullptr);

    vkDestroySampler (device_, sampler_, nullptr);

    vkDestroyShaderModule(device_, vertexShader_, nullptr);
    vkDestroyShaderModule(device_, fragmentShader_, nullptr);

    VulkanSample::ShutdownImpl();
}
Exemplo n.º 9
0
VulkanExampleBase::~VulkanExampleBase()
{
	// Clean up Vulkan resources
	swapChain.cleanup();
	if (descriptorPool != VK_NULL_HANDLE)
	{
		vkDestroyDescriptorPool(device, descriptorPool, nullptr);
	}
	if (setupCmdBuffer != VK_NULL_HANDLE)
	{
		vkFreeCommandBuffers(device, cmdPool, 1, &setupCmdBuffer);

	}
	destroyCommandBuffers();
	vkDestroyRenderPass(device, renderPass, nullptr);
	for (uint32_t i = 0; i < frameBuffers.size(); i++)
	{
		vkDestroyFramebuffer(device, frameBuffers[i], nullptr);
	}

	for (auto& shaderModule : shaderModules)
	{
		vkDestroyShaderModule(device, shaderModule, nullptr);
	}
	vkDestroyImageView(device, depthStencil.view, nullptr);
	vkDestroyImage(device, depthStencil.image, nullptr);
	vkFreeMemory(device, depthStencil.mem, nullptr);

	vkDestroyPipelineCache(device, pipelineCache, nullptr);

	if (textureLoader)
	{
		delete textureLoader;
	}

	vkDestroyCommandPool(device, cmdPool, nullptr);

	vkDestroySemaphore(device, semaphores.presentComplete, nullptr);
	vkDestroySemaphore(device, semaphores.renderComplete, nullptr);

	vkDestroyDevice(device, nullptr);

	if (enableValidation)
	{
		vkDebug::freeDebugCallback(instance);
	}

	vkDestroyInstance(instance, nullptr);

#if defined(__linux)
#if defined(__ANDROID__)
	// todo : android cleanup (if required)
#else
	xcb_destroy_window(connection, window);
	xcb_disconnect(connection);
#endif
#endif
}
Exemplo n.º 10
0
void vkeGameRendererDynamic::releaseFramebuffer(){


	VulkanDC *dc = VulkanDC::Get();
	VulkanDC::Device *device = dc->getDefaultDevice();
	device->waitIdle();

	vkDestroyImageView(device->getVKDevice(), m_depth_attachment.view, NULL);
	vkDestroyImageView(device->getVKDevice(), m_color_attachment.view, NULL);
	vkDestroyImageView(device->getVKDevice(), m_resolve_attachment[0].view, NULL);
	vkDestroyImageView(device->getVKDevice(), m_resolve_attachment[1].view, NULL);

	m_depth_attachment.view = NULL;
	m_color_attachment.view = NULL;
	m_resolve_attachment[0].view = NULL;
	m_resolve_attachment[1].view = NULL;

	vkDestroyImage(device->getVKDevice(), m_depth_attachment.image, NULL);
	vkDestroyImage(device->getVKDevice(), m_color_attachment.image, NULL);
	vkDestroyImage(device->getVKDevice(), m_resolve_attachment[0].image, NULL);
	vkDestroyImage(device->getVKDevice(), m_resolve_attachment[1].image, NULL);

	m_depth_attachment.image = NULL;
	m_color_attachment.image = NULL;
	m_resolve_attachment[0].image = NULL;
	m_resolve_attachment[1].image = NULL;

	vkFreeMemory(device->getVKDevice(), m_depth_attachment.memory, NULL);
	vkFreeMemory(device->getVKDevice(), m_color_attachment.memory, NULL);
	vkFreeMemory(device->getVKDevice(), m_resolve_attachment[0].memory, NULL);
	vkFreeMemory(device->getVKDevice(), m_resolve_attachment[1].memory, NULL);

	m_depth_attachment.memory = NULL;
	m_color_attachment.memory = NULL;
	m_resolve_attachment[0].memory = NULL;
	m_resolve_attachment[1].memory = NULL;

	vkDestroyFramebuffer(device->getVKDevice(), m_framebuffers[0], NULL);
	vkDestroyFramebuffer(device->getVKDevice(), m_framebuffers[1], NULL);
	m_framebuffers[0] = NULL;
	m_framebuffers[1] = NULL;



}
Exemplo n.º 11
0
 // Free all Vulkan resources used by the swap chain
 void cleanup()
 {
     for (uint32_t i = 0; i < imageCount; i++)
     {
         vkDestroyImageView(device, buffers[i].view, nullptr);
     }
     fpDestroySwapchainKHR(device, swapChain, nullptr);
     vkDestroySurfaceKHR(instance, surface, nullptr);
 }
Exemplo n.º 12
0
void _agpu_framebuffer::lostReferences()
{
    vkDestroyFramebuffer(device->device, framebuffer, nullptr);
    vkDestroyRenderPass(device->device, renderPass, nullptr);
    for (auto view : attachmentViews)
        vkDestroyImageView(device->device, view, nullptr);
    for (auto texture : attachmentTextures)
        texture->release();
}
Exemplo n.º 13
0
void destroy_swapchain_framebuffers(const VulkanBackend& backend, PresentationInfo& presentInfo)
{
    for (size_t i = 0; i < presentInfo.framebuffers.size(); i++)
    {
        vkDestroyImageView(backend.device, presentInfo.imageViews[i], nullptr);
        vkDestroyFramebuffer(backend.device, presentInfo.framebuffers[i], nullptr);
    }
    presentInfo.imageViews.clear();
    presentInfo.framebuffers.clear();
}
Exemplo n.º 14
0
	// Free all Vulkan resources used a texture object
	void destroyTextureImage(Texture texture)
	{
		if (texture.view != VK_NULL_HANDLE)
			vkDestroyImageView(device, texture.view, nullptr);
		if (texture.image != VK_NULL_HANDLE)
			vkDestroyImage(device, texture.image, nullptr);
		if (texture.sampler != VK_NULL_HANDLE)
			vkDestroySampler(device, texture.sampler, nullptr);
		if (texture.deviceMemory != VK_NULL_HANDLE)
			vkFreeMemory(device, texture.deviceMemory, nullptr);
	}
Exemplo n.º 15
0
 void VulkanWindow::FinalizeImageViews()
 {
     for ( auto& i : mVkSwapchainImageViews )
     {
         if ( i != VK_NULL_HANDLE )
         {
             vkDestroyImageView ( mVulkanRenderer.GetDevice(), i, nullptr );
             i = VK_NULL_HANDLE;
         }
     }
 }
Exemplo n.º 16
0
void DestroySwapchainInfo(const DeviceInfo* deviceInfo, SwapchainInfo* swapchainInfo)
{
	for (uint32_t i = 0; i < swapchainInfo->imageCount; i++)
	{
		//TODO is image destroyed along with its associated imageview?
		//vkDestroyImage(device, surfaceInfo->images[i], nullptr);
		vkDestroyImageView(deviceInfo->device, swapchainInfo->views[i], nullptr);
	}

	DestroySwapchainKHR(deviceInfo->device, swapchainInfo->swapChain, nullptr);
	*swapchainInfo = {};
}
Exemplo n.º 17
0
	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class

		// Texture target
		textureLoader->destroyTexture(offScreenFrameBuf.textureTarget);

		// Frame buffer

		// Color attachment
		vkDestroyImageView(device, offScreenFrameBuf.color.view, nullptr);
		vkDestroyImage(device, offScreenFrameBuf.color.image, nullptr);
		vkFreeMemory(device, offScreenFrameBuf.color.mem, nullptr);

		// Depth attachment
		vkDestroyImageView(device, offScreenFrameBuf.depth.view, nullptr);
		vkDestroyImage(device, offScreenFrameBuf.depth.image, nullptr);
		vkFreeMemory(device, offScreenFrameBuf.depth.mem, nullptr);

		vkDestroyFramebuffer(device, offScreenFrameBuf.frameBuffer, nullptr);

		vkDestroyPipeline(device, pipelines.quad, nullptr);
		vkDestroyPipeline(device, pipelines.offscreen, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayouts.quad, nullptr);
		vkDestroyPipelineLayout(device, pipelineLayouts.offscreen, nullptr);

		vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);

		// Meshes
		vkMeshLoader::freeMeshBufferResources(device, &meshes.scene);
		vkMeshLoader::freeMeshBufferResources(device, &meshes.quad);

		// Uniform buffers
		vkTools::destroyUniformData(device, &uniformDataVS);
		vkTools::destroyUniformData(device, &uniformDataOffscreenVS);

		vkFreeCommandBuffers(device, cmdPool, 1, &offScreenCmdBuffer);
	}
Exemplo n.º 18
0
void swapChainCleanup( struct SwapChain *swapChain ) {
	struct SwapChainBuffer *buf;
	int n;
	for( n = 0; n < swapChain->nImages; n++ ) {
		vkDestroyImageView( swapChain->device, swapChain->images[n], NULL );
	}
	swapChain->fpDestroySwapchainKHR( swapChain->device,
		swapChain->swapChain,
		NULL );
	vkDestroySurfaceKHR( swapChain->instance,
		swapChain->surface,
		NULL );
}
Exemplo n.º 19
0
void Image::destroy() {
	if (view) {
		vkDestroyImageView(vk, view, NULL);
		view = NULL;
	}
	if (mem) {
		vkFreeMemory(vk, mem, NULL);
		mem = NULL;
		if (image)
			vkDestroyImage(vk, image, NULL);
	}
	image = NULL;
}
Exemplo n.º 20
0
	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class

		// Frame buffer

		// Color attachment
		vkDestroyImageView(device, offscreenPass.color.view, nullptr);
		vkDestroyImage(device, offscreenPass.color.image, nullptr);
		vkFreeMemory(device, offscreenPass.color.mem, nullptr);

		// Depth attachment
		vkDestroyImageView(device, offscreenPass.depth.view, nullptr);
		vkDestroyImage(device, offscreenPass.depth.image, nullptr);
		vkFreeMemory(device, offscreenPass.depth.mem, nullptr);

		vkDestroyRenderPass(device, offscreenPass.renderPass, nullptr);
		vkDestroySampler(device, offscreenPass.sampler, nullptr);
		vkDestroyFramebuffer(device, offscreenPass.frameBuffer, nullptr);

		vkDestroyPipeline(device, pipelines.radialBlur, nullptr);
		vkDestroyPipeline(device, pipelines.phongPass, nullptr);
		vkDestroyPipeline(device, pipelines.colorPass, nullptr);
		vkDestroyPipeline(device, pipelines.offscreenDisplay, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayouts.radialBlur, nullptr);
		vkDestroyPipelineLayout(device, pipelineLayouts.scene, nullptr);

		vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.scene, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.radialBlur, nullptr);

		models.example.destroy();

		uniformBuffers.scene.destroy();
		uniformBuffers.blurParams.destroy();

		textures.gradient.destroy();
	}
Exemplo n.º 21
0
			void VkContext::Destroy() {
				vkDeviceWaitIdle(dev);

				// Free command buffers
				if (drawCmdBuffers.size() > 0) {
					vkFreeCommandBuffers(dev, cmdPool, (u32)drawCmdBuffers.size(),
						&drawCmdBuffers[0]);
				}

				// Destroy command pools
				vkDestroyCommandPool(dev, cmdPool, nullptr);

				// Destroy semaphores
				vkDestroySemaphore(dev, acquireCompleteSemaphore, nullptr);
				vkDestroySemaphore(dev, renderCompleteSemaphore, nullptr);

				// Destroy swapchain image views
				for (u32 i = 0; i < swapchainImageViews.size(); i++) {
					vkDestroyImageView(dev, swapchainImageViews[i], nullptr);
				}

				// Destroy swapchain
				if (swapchain) {
					vkDestroySwapchainKHR(dev, swapchain, nullptr);
				}

				// Destroy surface
				if (surf) {
					vkDestroySurfaceKHR(instance, surf, nullptr);
				}

				// Destroy device
				if (dev) {
					vkDestroyDevice(dev, nullptr);
				}

#ifdef VOXL_DEBUG
				// Destroy debug report callback
				if (msgCallback != VK_NULL_HANDLE) {
					vkDestroyDebugReportCallbackEXT(instance, msgCallback, nullptr);
				}
#endif

				// Destroy instance
				if (instance) {
					vkDestroyInstance(instance, nullptr);
				}

				// Terminate GLFW
				glfwTerminate();
			}
Exemplo n.º 22
0
	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class
		vkDestroyPipeline(device, pipelines.solid, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);

		vkMeshLoader::freeMeshBufferResources(device, &meshes.example);

		// Destroy MSAA target
		vkDestroyImage(device, multisampleTarget.color.image, nullptr);
		vkDestroyImageView(device, multisampleTarget.color.view, nullptr);
		vkFreeMemory(device, multisampleTarget.color.memory, nullptr);
		vkDestroyImage(device, multisampleTarget.depth.image, nullptr);
		vkDestroyImageView(device, multisampleTarget.depth.view, nullptr);
		vkFreeMemory(device, multisampleTarget.depth.memory, nullptr);

		textureLoader->destroyTexture(textures.colorMap);

		vkTools::destroyUniformData(device, &uniformData.vsScene);
	}
Exemplo n.º 23
0
	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class
		vkDestroyPipeline(device, pipelines.MSAA, nullptr);
		vkDestroyPipeline(device, pipelines.MSAASampleShading, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);

		models.example.destroy();

		// Destroy MSAA target
		vkDestroyImage(device, multisampleTarget.color.image, nullptr);
		vkDestroyImageView(device, multisampleTarget.color.view, nullptr);
		vkFreeMemory(device, multisampleTarget.color.memory, nullptr);
		vkDestroyImage(device, multisampleTarget.depth.image, nullptr);
		vkDestroyImageView(device, multisampleTarget.depth.view, nullptr);
		vkFreeMemory(device, multisampleTarget.depth.memory, nullptr);

		textures.colorMap.destroy();

		uniformBuffer.destroy();
	}
Exemplo n.º 24
0
		void destroy_vulkan_texture(vulkan_texture& texture) {
			if (texture.sampler != VK_NULL_HANDLE) {
				vkDestroySampler(_vulkan_device, texture.sampler, NULL);
			}

			if (texture.image != VK_NULL_HANDLE) {
				vkDestroyImage(_vulkan_device, texture.image, NULL);
			}

			if (texture.view != VK_NULL_HANDLE) {
				vkDestroyImageView(_vulkan_device, texture.view, NULL);
			}

			if (texture.device_memory != VK_NULL_HANDLE) {
				vkFreeMemory(_vulkan_device, texture.device_memory, NULL);
			}
		}
Exemplo n.º 25
0
	SwapChain::~SwapChain()
	{
		if (VK_NULL_HANDLE != mVkSurfaceKHR)
		{
			const VulkanRenderer& vulkanRenderer = static_cast<VulkanRenderer&>(getRenderer());
			const VkDevice vkDevice = vulkanRenderer.getContext().getVkDevice();
			for (uint32_t i = 0; i < mSwapchainImageCount; ++i)
			{
				vkDestroyImageView(vkDevice, mSwapChainBuffer[i].view, nullptr);
			}
			if (VK_NULL_HANDLE != mVkSwapchainKHR)
			{
				vkDestroySwapchainKHR(vkDevice, mVkSwapchainKHR, nullptr);
			}
			vkDestroySurfaceKHR(vulkanRenderer.getVulkanRuntimeLinking().getVkInstance(), mVkSurfaceKHR, nullptr);
		}
	}
Exemplo n.º 26
0
	/**
	* Default destructor, frees up all Vulkan resources acquired by the text overlay
	*/
	~VulkanTextOverlay()
	{
		// Free up all Vulkan resources requested by the text overlay
		vertexBuffer.destroy();
		vkDestroySampler(vulkanDevice->logicalDevice, sampler, nullptr);
		vkDestroyImage(vulkanDevice->logicalDevice, image, nullptr);
		vkDestroyImageView(vulkanDevice->logicalDevice, view, nullptr);
		vkFreeMemory(vulkanDevice->logicalDevice, imageMemory, nullptr);
		vkDestroyDescriptorSetLayout(vulkanDevice->logicalDevice, descriptorSetLayout, nullptr);
		vkDestroyDescriptorPool(vulkanDevice->logicalDevice, descriptorPool, nullptr);
		vkDestroyPipelineLayout(vulkanDevice->logicalDevice, pipelineLayout, nullptr);
		vkDestroyPipelineCache(vulkanDevice->logicalDevice, pipelineCache, nullptr);
		vkDestroyPipeline(vulkanDevice->logicalDevice, pipeline, nullptr);
		vkDestroyRenderPass(vulkanDevice->logicalDevice, renderPass, nullptr);
		vkFreeCommandBuffers(vulkanDevice->logicalDevice, commandPool, static_cast<uint32_t>(cmdBuffers.size()), cmdBuffers.data());
		vkDestroyCommandPool(vulkanDevice->logicalDevice, commandPool, nullptr);
		vkDestroyFence(vulkanDevice->logicalDevice, fence, nullptr);
	}
Exemplo n.º 27
0
void WImage::_DestroyResources() {
	VkDevice device = m_app->GetVulkanDevice();
	if (m_stagingBuffer)
		vkDestroyBuffer(device, m_stagingBuffer, nullptr);
	if (m_stagingMemory)
		vkFreeMemory(device, m_stagingMemory, nullptr);
	if (m_image)
		vkDestroyImage(device, m_image, nullptr);
	if (m_deviceMemory)
		vkFreeMemory(device, m_deviceMemory, nullptr);
	if (m_view)
		vkDestroyImageView(device, m_view, nullptr);
	m_stagingBuffer = VK_NULL_HANDLE;
	m_stagingMemory = VK_NULL_HANDLE;
	m_image = VK_NULL_HANDLE;
	m_deviceMemory = VK_NULL_HANDLE;
	m_view = VK_NULL_HANDLE;
}
Exemplo n.º 28
0
    void cleanup() {
        vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
        vkDestroyRenderPass(device, renderPass, nullptr);

        for (auto imageView : swapChainImageViews) {
            vkDestroyImageView(device, imageView, nullptr);
        }

        vkDestroySwapchainKHR(device, swapChain, nullptr);
        vkDestroyDevice(device, nullptr);
        DestroyDebugReportCallbackEXT(instance, callback, nullptr);
        vkDestroySurfaceKHR(instance, surface, nullptr);
        vkDestroyInstance(instance, nullptr);

        glfwDestroyWindow(window);

        glfwTerminate();
    }
Exemplo n.º 29
0
void VulkanExampleBase::windowResize()
{
	if (!prepared)
	{
		return;
	}
	prepared = false;

	// Recreate swap chain
	width = destWidth;
	height = destHeight;
	createSetupCommandBuffer();
	setupSwapChain();

	// Recreate the frame buffers

	vkDestroyImageView(device, depthStencil.view, nullptr);
	vkDestroyImage(device, depthStencil.image, nullptr);
	vkFreeMemory(device, depthStencil.mem, nullptr);
	setupDepthStencil();
	
	for (uint32_t i = 0; i < frameBuffers.size(); i++)
	{
		vkDestroyFramebuffer(device, frameBuffers[i], nullptr);
	}
	setupFrameBuffer();

	flushSetupCommandBuffer();

	// Command buffers need to be recreated as they may store
	// references to the recreated frame buffer
	destroyCommandBuffers();
	createCommandBuffers();
	buildCommandBuffers();

	vkQueueWaitIdle(queue);
	vkDeviceWaitIdle(device);

	// Notify derived class
	windowResized();
	viewChanged();

	prepared = true;
}
Exemplo n.º 30
0
Anvil::ImageView::~ImageView()
{
    /* Unregister the object */
    Anvil::ObjectTracker::get()->unregister_object(Anvil::OBJECT_TYPE_IMAGE_VIEW,
                                                   this);

    if (m_image_view != VK_NULL_HANDLE)
    {
        lock();
        {
            vkDestroyImageView(m_device_ptr->get_device_vk(),
                               m_image_view,
                               nullptr /* pAllocator */);
        }
        unlock();

        m_image_view = VK_NULL_HANDLE;
    }
}