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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25357>
This commit is contained in:
Faith Ekstrand 2023-09-25 17:28:02 -05:00 committed by Marge Bot
parent 39bb73b21f
commit d17db521f7
2 changed files with 13 additions and 71 deletions

View file

@ -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

View file

@ -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;