+
+ uint64_t bo_flags = ANV_BO_EXTERNAL;
+ if (device->instance->physicalDevice.supports_48bit_addresses)
+ bo_flags |= EXEC_OBJECT_SUPPORTS_48B_ADDRESS;
+ if (device->instance->physicalDevice.use_softpin)
+ bo_flags |= EXEC_OBJECT_PINNED;
+
+ result = anv_bo_cache_import(device, &device->bo_cache,
+ pCreateInfo->fd, bo_flags, &mem->bo);
+ if (result != VK_SUCCESS)
+ goto fail_import;
+
+ VkDeviceSize aligned_image_size = align_u64(image->size, 4096);
+
+ if (mem->bo->size < aligned_image_size) {
+ result = vk_errorf(device->instance, device,
+ VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ "dma-buf too small for image in "
+ "vkCreateDmaBufImageINTEL: %"PRIu64"B < %"PRIu64"B",
+ mem->bo->size, aligned_image_size);
+ anv_bo_cache_release(device, &device->bo_cache, mem->bo);
+ goto fail_import;
+ }
+
+ image->planes[0].address = (struct anv_address) {
+ .bo = mem->bo,
+ .offset = 0,
+ };