Пример #1
0
		// Destroys all Vulkan resources created for this model
		void destroy(VkDevice device)
		{
			vkDestroyBuffer(device, vertices.buffer, nullptr);
			vkFreeMemory(device, vertices.memory, nullptr);
			vkDestroyBuffer(device, indices.buffer, nullptr);
			vkFreeMemory(device, indices.memory, nullptr);
		};
Пример #2
0
	void Model::destroy()
	{
		vkDestroyBuffer(getDevice(), m_vertices.buffer, nullptr);
		vkFreeMemory(getDevice(), m_vertices.memory, nullptr);

		vkDestroyBuffer(getDevice(), m_indices.buffer, nullptr);
		vkFreeMemory(getDevice(), m_indices.memory, nullptr);
	}
Пример #3
0
	static void freeMeshBufferResources(VkDevice device, vkMeshLoader::MeshBuffer *meshBuffer)
	{
		vkDestroyBuffer(device, meshBuffer->vertices.buf, nullptr);
		vkFreeMemory(device, meshBuffer->vertices.mem, nullptr);
		if (meshBuffer->indices.buf != VK_NULL_HANDLE)
		{
			vkDestroyBuffer(device, meshBuffer->indices.buf, nullptr);
			vkFreeMemory(device, meshBuffer->indices.mem, nullptr);
		}
	}
Пример #4
0
VulkanGear::~VulkanGear()
{
	// Clean up vulkan resources
	vkDestroyBuffer(device, uniformData.buffer, nullptr);
	vkFreeMemory(device, uniformData.memory, nullptr);

	vkDestroyBuffer(device, vertexBuffer.buf, nullptr);
	vkFreeMemory(device, vertexBuffer.mem, nullptr);

	vkDestroyBuffer(device, indexBuffer.buf, nullptr);
	vkFreeMemory(device, indexBuffer.mem, nullptr);
}
Пример #5
0
    void cleanupVulkan()
    {
        prepared = false;
        vkDestroyPipeline(device, pipelines.solid, nullptr);
        vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
        vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
        vkDestroyBuffer(device, vertices.buf, nullptr);
        vkFreeMemory(device, vertices.mem, nullptr);
        vkDestroyBuffer(device, indices.buf, nullptr);
        vkFreeMemory(device, indices.mem, nullptr);
        vkDestroyBuffer(device, uniformDataVS.buffer, nullptr);
        vkFreeMemory(device, uniformDataVS.memory, nullptr);

        VulkanExample::cleanUpVulkan();
    }
Пример #6
0
	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class
		vkDestroyPipeline(device, pipelines.terrain, nullptr);
		if (pipelines.wireframe != VK_NULL_HANDLE) {
			vkDestroyPipeline(device, pipelines.wireframe, nullptr);
		}
		vkDestroyPipeline(device, pipelines.skysphere, nullptr);

		vkDestroyPipelineLayout(device, pipelineLayouts.skysphere, nullptr);
		vkDestroyPipelineLayout(device, pipelineLayouts.terrain, nullptr);

		vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.terrain, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayouts.skysphere, nullptr);

		models.terrain.destroy();
		models.skysphere.destroy();

		uniformBuffers.skysphereVertex.destroy();
		uniformBuffers.terrainTessellation.destroy();

		textures.heightMap.destroy();
		textures.skySphere.destroy();
		textures.terrainArray.destroy();

		if (queryPool != VK_NULL_HANDLE) {
			vkDestroyQueryPool(device, queryPool, nullptr);
			vkDestroyBuffer(device, queryResult.buffer, nullptr);
			vkFreeMemory(device, queryResult.memory, nullptr);
		}
	}
Пример #7
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();
        }
    }
Пример #8
0
/*
===============
GL_DestroyHeap
===============
*/
void GL_DestroyHeap(glheap_t * heap)
{
	GL_WaitForDeviceIdle();
	vkFreeMemory(vulkan_globals.device, heap->memory, NULL);
	free(heap->head);
	free(heap);
}
Пример #9
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();
	}
Пример #10
0
	void destroyUniformData(VkDevice device, vkTools::UniformData * uniformData)
	{
		if (uniformData->mapped != nullptr) {
			vkUnmapMemory(device, uniformData->memory);
		}
		vkDestroyBuffer(device, uniformData->buffer, nullptr);
		vkFreeMemory(device, uniformData->memory, nullptr);
	}
Пример #11
0
	void free() {
		if (memory) {
			munmap();

			vkFreeMemory(device.get(), *this, &host_allocator::allocation_callbacks());
			memory = none;
		}
	}
Пример #12
0
void
VKDevice::free_mem_id (VkDeviceMemory mem)
{
    XCAM_ASSERT (XCAM_IS_VALID_VK_ID (_dev_id));
    XCAM_ASSERT (XCAM_IS_VALID_VK_ID (mem));

    vkFreeMemory (_dev_id, mem, _allocator.ptr ());
}
Пример #13
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
}
Пример #14
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;



}
Пример #15
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;
}
Пример #16
0
coVulkanDeviceAllocator::~coVulkanDeviceAllocator()
{
	const VkDevice& device_vk = GetVkDevice();
	for (auto& p : chunks)
	{
		coCHECK(device_vk != VK_NULL_HANDLE, nullptr);
		vkFreeMemory(device_vk, p->deviceMemory_vk, nullptr);
		delete p;
	}
}
Пример #17
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);

		// Destroy and free mesh resources 
		vkDestroyBuffer(device, mesh.vertices.buf, nullptr);
		vkFreeMemory(device, mesh.vertices.mem, nullptr);
		vkDestroyBuffer(device, mesh.indices.buf, nullptr);
		vkFreeMemory(device, mesh.indices.mem, nullptr);

		textureLoader->destroyTexture(textures.colorMap);

		vkTools::destroyUniformData(device, &uniformData.vsScene);
	}
Пример #18
0
	void cleanupVulkan()
	{
		prepared = false;
		vkDestroyPipeline(device, pipelines.solid, nullptr);
		vkDestroyPipelineLayout(device, pipelineLayout, nullptr);
		vkDestroyPipelineLayout(device, computePipelineLayout, nullptr);
		vkDestroyDescriptorSetLayout(device, descriptorSetLayout, nullptr);
		vkDestroyDescriptorSetLayout(device, computeDescriptorSetLayout, nullptr);
		vkDestroyBuffer(device, uniformDataCompute.buffer, nullptr);
		vkFreeMemory(device, uniformDataCompute.memory, nullptr);
		vkDestroyBuffer(device, computeStorageBuffer.buffer, nullptr);
		vkFreeMemory(device, computeStorageBuffer.memory, nullptr);

		destroyTextureImage(&texture);

		vkFreeCommandBuffers(device, cmdPool, 1, &computeCmdBuffer);
		
		VulkanExample::cleanUpVulkan();
	}
Пример #19
0
	XdevLVertexBufferVulkan::~XdevLVertexBufferVulkan() {
		if(m_deviceMemory) {
			vkFreeMemory(m_device, m_deviceMemory, nullptr);
			m_deviceMemory = nullptr;
		}		
		if(m_buffer) {
			vkDestroyBuffer(m_device, m_buffer, nullptr);
			m_buffer = nullptr;
		}
	}
		/** 
		* Release all Vulkan resources held by this buffer
		*/
		void destroy()
		{
			if (buffer)
			{
				vkDestroyBuffer(device, buffer, nullptr);
			}
			if (memory)
			{
				vkFreeMemory(device, memory, nullptr);
			}
		}
Пример #21
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);
	}
Пример #22
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);
	}
Пример #23
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;
}
void    ImGui_ImplGlfwVulkan_InvalidateFontUploadObjects()
{
    if (g_UploadBuffer)
    {
        vkDestroyBuffer(g_Device, g_UploadBuffer, g_Allocator);
        g_UploadBuffer = VK_NULL_HANDLE;
    }
    if (g_UploadBufferMemory)
    {
        vkFreeMemory(g_Device, g_UploadBufferMemory, g_Allocator);
        g_UploadBufferMemory = VK_NULL_HANDLE;
    }
}
Пример #25
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();
	}
Пример #26
0
	void ModelLoader::CleanupModels(VkDevice device)
	{
		for (auto& model : mModelMap)
		{
			// Free vertex and index buffers
			vkDestroyBuffer(device, model.second->vertices.buffer, nullptr);
			vkFreeMemory(device, model.second->vertices.memory, nullptr);
			vkDestroyBuffer(device, model.second->indices.buffer, nullptr);
			vkFreeMemory(device, model.second->indices.memory, nullptr);

			// Free the texture (NOTE: not sure if this is the right place to delete them, texture loader maybe?)
			if (model.second->texture != nullptr)
			{
				vkDestroyImageView(device, model.second->texture->view, nullptr);		// NOTE: Ugly
				vkDestroyImage(device, model.second->texture->image, nullptr);
				vkDestroySampler(device, model.second->texture->sampler, nullptr);
				vkFreeMemory(device, model.second->texture->deviceMemory, nullptr);
			}

			delete model.second;
		}
	}
Пример #27
0
	~VulkanExample()
	{
		// Clean up used Vulkan resources 
		// Note : Inherited destructor cleans up resources stored in base class
		vkDestroyPipeline(device, pipelines.solid, nullptr);
		vkDestroyPipeline(device, pipelines.wire, nullptr);
		vkDestroyPipeline(device, pipelines.solidPassThrough, nullptr);
		vkDestroyPipeline(device, pipelines.wirePassThrough, nullptr);

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

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

		vkDestroyBuffer(device, uniformDataTC.buffer, nullptr);
		vkFreeMemory(device, uniformDataTC.memory, nullptr);

		vkDestroyBuffer(device, uniformDataTE.buffer, nullptr);
		vkFreeMemory(device, uniformDataTE.memory, nullptr);

		textureLoader->destroyTexture(textures.colorMap);
	}
void VulkanQuad::ShutdownImpl ()
{
    vkDestroyPipeline (device_, pipeline_, nullptr);
    vkDestroyPipelineLayout (device_, pipelineLayout_, nullptr);

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

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

    VulkanSample::ShutdownImpl ();
}
Пример #29
0
	~gl_450_draw()
	{
		vkDestroyPipeline(device, pipeline, nullptr);

		vkDestroyBuffer(device, vertices.buffer, nullptr);
		vkFreeMemory(device, vertices.memory, nullptr);

		vkDestroyBuffer(device, indices.buffer, nullptr);
		vkFreeMemory(device, indices.memory, nullptr);

		vkDestroyBuffer(device, uniformDataVS.buffer, nullptr);
		vkFreeMemory(device, uniformDataVS.memory, nullptr);

		vkDestroySemaphore(device, presentCompleteSemaphore, nullptr);
		vkDestroySemaphore(device, renderCompleteSemaphore, nullptr);

		for (auto& fence : waitFences)
		{
			vkDestroyFence(device, fence, nullptr);
		}

		wglDeleteContextGTC(this->Context);
	}
Пример #30
0
void DeviceMemory::destroy()
{
    if (deviceMemory)
    {
        if (mapped)
        {
            unmapMemory();
        }

        vkFreeMemory(device, deviceMemory, nullptr);

        deviceMemory = VK_NULL_HANDLE;
    }
}