VkResult
nvk_allocate_memory(struct nvk_device *device,
const VkMemoryAllocateInfo *pAllocateInfo,
+ const struct nvk_memory_tiling_info *tile_info,
const VkAllocationCallbacks *pAllocator,
struct nvk_device_memory **mem_out)
{
flags |= NOUVEAU_WS_BO_MAP;
mem->map = NULL;
- mem->bo = nouveau_ws_bo_new(device->pdev->dev, pAllocateInfo->allocationSize, 0, flags);
+ if (tile_info) {
+ mem->bo = nouveau_ws_bo_new_tiled(device->pdev->dev,
+ pAllocateInfo->allocationSize, 0,
+ tile_info->pte_kind,
+ tile_info->tile_mode,
+ flags);
+ } else {
+ mem->bo = nouveau_ws_bo_new(device->pdev->dev,
+ pAllocateInfo->allocationSize, 0, flags);
+ }
if (!mem->bo) {
vk_object_free(&device->vk, pAllocator, mem);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
struct nvk_device_memory *mem;
VkResult result;
- result = nvk_allocate_memory(device, pAllocateInfo, pAllocator, &mem);
+ result = nvk_allocate_memory(device, pAllocateInfo, NULL, pAllocator, &mem);
if (result != VK_SUCCESS)
return result;
VK_DEFINE_HANDLE_CASTS(nvk_device_memory, 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 *device,
const VkMemoryAllocateInfo *pAllocateInfo,
+ const struct nvk_memory_tiling_info *tile_info,
const VkAllocationCallbacks *pAllocator,
struct nvk_device_memory **mem_out);
return result;
}
+ if (image->nil.pte_kind) {
+ assert(device->pdev->mem_heaps[0].flags &
+ VK_MEMORY_HEAP_DEVICE_LOCAL_BIT);
+
+ const VkMemoryAllocateInfo alloc_info = {
+ .sType = VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO,
+ .allocationSize = image->nil.size_B,
+ .memoryTypeIndex = 0,
+ };
+ const struct nvk_memory_tiling_info tile_info = {
+ .tile_mode = image->nil.tile_mode,
+ .pte_kind = image->nil.pte_kind,
+ };
+
+ result = nvk_allocate_memory(device, &alloc_info, &tile_info,
+ pAllocator, &image->internal);
+ if (result != VK_SUCCESS) {
+ nvk_image_finish(image);
+ vk_free2(&device->vk.alloc, pAllocator, image);
+ return result;
+ }
+
+ image->mem = image->internal;
+ image->offset = 0;
+ }
+
*pImage = nvk_image_to_handle(image);
return VK_SUCCESS;
if (!image)
return;
+ if (image->internal)
+ nvk_free_memory(device, image->internal, pAllocator);
+
nvk_image_finish(image);
vk_free2(&device->vk.alloc, pAllocator, image);
}
VK_FROM_HANDLE(nvk_device_memory, mem, pBindInfos[i].memory);
VK_FROM_HANDLE(nvk_image, image, pBindInfos[i].image);
+ if (image->internal)
+ continue;
+
image->mem = mem;
image->offset = pBindInfos[i].memoryOffset;
}
struct nvk_image {
struct vk_image vk;
+
+ /* Used for internal dedicated allocations */
+ struct nvk_device_memory *internal;
+
struct nvk_device_memory *mem;
VkDeviceSize offset;