From d17db521f76e4e7ac020823922d8c8de8c98f7ee Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Mon, 25 Sep 2023 17:28:02 -0500 Subject: [PATCH] nvk: Get rid of the tiled memory allocation helpers These existed entirely to support shadow memory for VkImage cases where we needed tiling. Now that we have VM_BIND, these are no longer used so we can drop the wrappers and just implement VkAllocate/FreeMemory again. Part-of: --- src/nouveau/vulkan/nvk_device_memory.c | 69 +++++++--------------------------- src/nouveau/vulkan/nvk_device_memory.h | 15 -------- 2 files changed, 13 insertions(+), 71 deletions(-) diff --git a/src/nouveau/vulkan/nvk_device_memory.c b/src/nouveau/vulkan/nvk_device_memory.c index c8a5f6a..b89c1e1 100644 --- a/src/nouveau/vulkan/nvk_device_memory.c +++ b/src/nouveau/vulkan/nvk_device_memory.c @@ -153,13 +153,13 @@ nvk_GetMemoryFdPropertiesKHR(VkDevice device, return VK_SUCCESS; } -VkResult -nvk_allocate_memory(struct nvk_device *dev, - const VkMemoryAllocateInfo *pAllocateInfo, - const struct nvk_memory_tiling_info *tile_info, - const VkAllocationCallbacks *pAllocator, - struct nvk_device_memory **mem_out) +VKAPI_ATTR VkResult VKAPI_CALL +nvk_AllocateMemory(VkDevice device, + const VkMemoryAllocateInfo *pAllocateInfo, + const VkAllocationCallbacks *pAllocator, + VkDeviceMemory *pMem) { + VK_FROM_HANDLE(nvk_device, dev, device); struct nvk_physical_device *pdev = nvk_device_physical(dev); struct nvk_device_memory *mem; VkResult result = VK_SUCCESS; @@ -206,16 +206,6 @@ nvk_allocate_memory(struct nvk_device *dev, goto fail_alloc; } assert(!(flags & ~mem->bo->flags)); - } else if (tile_info) { - mem->bo = nouveau_ws_bo_new_tiled(dev->ws_dev, - pAllocateInfo->allocationSize, 0, - tile_info->pte_kind, - tile_info->tile_mode, - flags); - if (!mem->bo) { - result = vk_error(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY); - goto fail_alloc; - } } else { mem->bo = nouveau_ws_bo_new(dev->ws_dev, aligned_size, alignment, flags); if (!mem->bo) { @@ -254,7 +244,7 @@ nvk_allocate_memory(struct nvk_device *dev, close(fd_info->fd); } - *mem_out = mem; + *pMem = nvk_device_memory_to_handle(mem); return VK_SUCCESS; @@ -265,44 +255,6 @@ fail_alloc: return result; } -void -nvk_free_memory(struct nvk_device *dev, - struct nvk_device_memory *mem, - const VkAllocationCallbacks *pAllocator) -{ - if (mem->map) - nouveau_ws_bo_unmap(mem->bo, mem->map); - - nouveau_ws_bo_destroy(mem->bo); - - vk_device_memory_destroy(&dev->vk, pAllocator, &mem->vk); -} - -VKAPI_ATTR VkResult VKAPI_CALL -nvk_AllocateMemory(VkDevice device, - const VkMemoryAllocateInfo *pAllocateInfo, - const VkAllocationCallbacks *pAllocator, - VkDeviceMemory *pMem) -{ - VK_FROM_HANDLE(nvk_device, dev, device); - struct nvk_device_memory *mem; - VkResult result; - - - struct nvk_memory_tiling_info *p_tile_info = NULL; - - - result = nvk_allocate_memory(dev, pAllocateInfo, p_tile_info, - pAllocator, &mem); - if (result != VK_SUCCESS) - return result; - - - *pMem = nvk_device_memory_to_handle(mem); - - return VK_SUCCESS; -} - VKAPI_ATTR void VKAPI_CALL nvk_FreeMemory(VkDevice device, VkDeviceMemory _mem, @@ -314,7 +266,12 @@ nvk_FreeMemory(VkDevice device, if (!mem) return; - nvk_free_memory(dev, mem, pAllocator); + if (mem->map) + nouveau_ws_bo_unmap(mem->bo, mem->map); + + nouveau_ws_bo_destroy(mem->bo); + + vk_device_memory_destroy(&dev->vk, pAllocator, &mem->vk); } VKAPI_ATTR VkResult VKAPI_CALL diff --git a/src/nouveau/vulkan/nvk_device_memory.h b/src/nouveau/vulkan/nvk_device_memory.h index 278bf7f..a2c556c 100644 --- a/src/nouveau/vulkan/nvk_device_memory.h +++ b/src/nouveau/vulkan/nvk_device_memory.h @@ -24,21 +24,6 @@ struct nvk_device_memory { VK_DEFINE_NONDISP_HANDLE_CASTS(nvk_device_memory, vk.base, VkDeviceMemory, VK_OBJECT_TYPE_DEVICE_MEMORY) -struct nvk_memory_tiling_info { - uint16_t tile_mode; - uint8_t pte_kind; -}; - -VkResult nvk_allocate_memory(struct nvk_device *dev, - const VkMemoryAllocateInfo *pAllocateInfo, - const struct nvk_memory_tiling_info *tile_info, - const VkAllocationCallbacks *pAllocator, - struct nvk_device_memory **mem_out); - -void nvk_free_memory(struct nvk_device *dev, - struct nvk_device_memory *mem, - const VkAllocationCallbacks *pAllocator); - extern const VkExternalMemoryProperties nvk_opaque_fd_mem_props; extern const VkExternalMemoryProperties nvk_dma_buf_mem_props; -- 2.7.4