if (mem == NULL)
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
- uint64_t size = (uint64_t)pCreateInfo->strideInBytes * pCreateInfo->extent.height;
-
- result = anv_bo_cache_import(device, &device->bo_cache,
- pCreateInfo->fd, size, &mem->bo);
- if (result != VK_SUCCESS)
- goto fail;
-
- if (device->instance->physicalDevice.supports_48bit_addresses)
- mem->bo->flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
-
- anv_image_create(_device,
+ result = anv_image_create(_device,
&(struct anv_image_create_info) {
.isl_tiling_flags = ISL_TILING_X_BIT,
.stride = pCreateInfo->strideInBytes,
.flags = 0,
}},
pAllocator, &image_h);
+ if (result != VK_SUCCESS)
+ goto fail;
image = anv_image_from_handle(image_h);
+
+ result = anv_bo_cache_import(device, &device->bo_cache,
+ pCreateInfo->fd, image->size, &mem->bo);
+ if (result != VK_SUCCESS)
+ goto fail_import;
+
+ if (device->instance->physicalDevice.supports_48bit_addresses)
+ mem->bo->flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+
image->planes[0].bo = mem->bo;
image->planes[0].bo_offset = 0;
return VK_SUCCESS;
+ fail_import:
+ vk_free2(&device->alloc, pAllocator, image);
+
fail:
vk_free2(&device->alloc, pAllocator, mem);