diff options
author | Lionel Landwerlin <[email protected]> | 2017-10-11 17:24:37 +0100 |
---|---|---|
committer | Lionel Landwerlin <[email protected]> | 2017-10-11 22:29:55 +0100 |
commit | e568d2bd1f148821057a8bf071ce39f342112d83 (patch) | |
tree | 7346662dab70da8d923987cd226a079357504e68 /src/intel/vulkan | |
parent | c0a4f56fb9945e36a004bc38852fbb801aae3bd5 (diff) |
anv: intel: use anv_image's computed size for importing a BO
Rather than relying on size = stride * height, we can rely on
anv_image's total size.
Signed-off-by: Lionel Landwerlin <[email protected]>
Acked-by: Daniel Stone <[email protected]>
Diffstat (limited to 'src/intel/vulkan')
-rw-r--r-- | src/intel/vulkan/anv_intel.c | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/src/intel/vulkan/anv_intel.c b/src/intel/vulkan/anv_intel.c index d4ef3beb743..9f8cd927345 100644 --- a/src/intel/vulkan/anv_intel.c +++ b/src/intel/vulkan/anv_intel.c @@ -49,17 +49,7 @@ VkResult anv_CreateDmaBufImageINTEL( 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, @@ -78,8 +68,19 @@ VkResult anv_CreateDmaBufImageINTEL( .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; @@ -92,6 +93,9 @@ VkResult anv_CreateDmaBufImageINTEL( return VK_SUCCESS; + fail_import: + vk_free2(&device->alloc, pAllocator, image); + fail: vk_free2(&device->alloc, pAllocator, mem); |