Skip to content
Snippets Groups Projects
Commit ef844fc0 authored by Dave Airlie's avatar Dave Airlie
Browse files

nvk: handle alignments in device memory

parent 87e5bc3d
No related branches found
No related tags found
No related merge requests found
...@@ -76,21 +76,26 @@ nvk_allocate_memory(struct nvk_device *device, ...@@ -76,21 +76,26 @@ nvk_allocate_memory(struct nvk_device *device,
{ {
VkMemoryType *type = &device->pdev->mem_types[pAllocateInfo->memoryTypeIndex]; VkMemoryType *type = &device->pdev->mem_types[pAllocateInfo->memoryTypeIndex];
struct nvk_device_memory *mem; struct nvk_device_memory *mem;
uint64_t align = (1ULL << 12), size;
mem = vk_object_alloc(&device->vk, pAllocator, sizeof(*mem), mem = vk_object_alloc(&device->vk, pAllocator, sizeof(*mem),
VK_OBJECT_TYPE_DEVICE_MEMORY); VK_OBJECT_TYPE_DEVICE_MEMORY);
if (!mem) if (!mem)
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY); return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
enum nouveau_ws_bo_flags flags; enum nouveau_ws_bo_flags flags;
if (type->propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) if (type->propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) {
flags = NOUVEAU_WS_BO_LOCAL; flags = NOUVEAU_WS_BO_LOCAL;
else align = (1ULL << 16);
} else
flags = NOUVEAU_WS_BO_GART; flags = NOUVEAU_WS_BO_GART;
if (type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) if (type->propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT)
flags |= NOUVEAU_WS_BO_MAP; flags |= NOUVEAU_WS_BO_MAP;
size = pAllocateInfo->allocationSize;
#if NVK_NEW_UAPI == 1
size = ALIGN(size, align);
#endif
mem->map = NULL; mem->map = NULL;
if (tile_info) { if (tile_info) {
mem->bo = nouveau_ws_bo_new_tiled(device->pdev->dev, mem->bo = nouveau_ws_bo_new_tiled(device->pdev->dev,
...@@ -100,7 +105,7 @@ nvk_allocate_memory(struct nvk_device *device, ...@@ -100,7 +105,7 @@ nvk_allocate_memory(struct nvk_device *device,
flags); flags);
} else { } else {
mem->bo = nouveau_ws_bo_new(device->pdev->dev, mem->bo = nouveau_ws_bo_new(device->pdev->dev,
pAllocateInfo->allocationSize, 0, flags); size, align, flags);
} }
if (!mem->bo) { if (!mem->bo) {
vk_object_free(&device->vk, pAllocator, mem); vk_object_free(&device->vk, pAllocator, mem);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment