From: Samuel Pitoiset Date: Tue, 21 Jul 2020 13:55:38 +0000 (+0200) Subject: radv/winsys: return a Vulkan error code when binding virtual buffers/images X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f82eb7af87772d050aaf222473c4ffe8490019c4;p=mesa.git radv/winsys: return a Vulkan error code when binding virtual buffers/images Signed-off-by: Samuel Pitoiset Reviewed-by: Bas Nieuwenhuizen Part-of: --- diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c index 8d28be4d92a..dd8b2e4b73a 100644 --- a/src/amd/vulkan/radv_device.c +++ b/src/amd/vulkan/radv_device.c @@ -3936,11 +3936,12 @@ radv_finalize_timelines(struct radv_device *device, } } -static void +static VkResult radv_sparse_buffer_bind_memory(struct radv_device *device, const VkSparseBufferMemoryBindInfo *bind) { RADV_FROM_HANDLE(radv_buffer, buffer, bind->buffer); + VkResult result; for (uint32_t i = 0; i < bind->bindCount; ++i) { struct radv_device_memory *mem = NULL; @@ -3948,19 +3949,24 @@ radv_sparse_buffer_bind_memory(struct radv_device *device, if (bind->pBinds[i].memory != VK_NULL_HANDLE) mem = radv_device_memory_from_handle(bind->pBinds[i].memory); - device->ws->buffer_virtual_bind(buffer->bo, - bind->pBinds[i].resourceOffset, - bind->pBinds[i].size, - mem ? mem->bo : NULL, - bind->pBinds[i].memoryOffset); + result = device->ws->buffer_virtual_bind(buffer->bo, + bind->pBinds[i].resourceOffset, + bind->pBinds[i].size, + mem ? mem->bo : NULL, + bind->pBinds[i].memoryOffset); + if (result != VK_SUCCESS) + return result; } + + return VK_SUCCESS; } -static void +static VkResult radv_sparse_image_opaque_bind_memory(struct radv_device *device, const VkSparseImageOpaqueMemoryBindInfo *bind) { RADV_FROM_HANDLE(radv_image, image, bind->image); + VkResult result; for (uint32_t i = 0; i < bind->bindCount; ++i) { struct radv_device_memory *mem = NULL; @@ -3968,12 +3974,16 @@ radv_sparse_image_opaque_bind_memory(struct radv_device *device, if (bind->pBinds[i].memory != VK_NULL_HANDLE) mem = radv_device_memory_from_handle(bind->pBinds[i].memory); - device->ws->buffer_virtual_bind(image->bo, - bind->pBinds[i].resourceOffset, - bind->pBinds[i].size, - mem ? mem->bo : NULL, - bind->pBinds[i].memoryOffset); + result = device->ws->buffer_virtual_bind(image->bo, + bind->pBinds[i].resourceOffset, + bind->pBinds[i].size, + mem ? mem->bo : NULL, + bind->pBinds[i].memoryOffset); + if (result != VK_SUCCESS) + return result; } + + return VK_SUCCESS; } static VkResult @@ -4283,13 +4293,17 @@ radv_queue_submit_deferred(struct radv_deferred_queue_submission *submission, goto fail; for (uint32_t i = 0; i < submission->buffer_bind_count; ++i) { - radv_sparse_buffer_bind_memory(queue->device, - submission->buffer_binds + i); + result = radv_sparse_buffer_bind_memory(queue->device, + submission->buffer_binds + i); + if (result != VK_SUCCESS) + goto fail; } for (uint32_t i = 0; i < submission->image_opaque_bind_count; ++i) { - radv_sparse_image_opaque_bind_memory(queue->device, - submission->image_opaque_binds + i); + result = radv_sparse_image_opaque_bind_memory(queue->device, + submission->image_opaque_binds + i); + if (result != VK_SUCCESS) + goto fail; } if (!submission->cmd_buffer_count) { diff --git a/src/amd/vulkan/radv_radeon_winsys.h b/src/amd/vulkan/radv_radeon_winsys.h index 4830c7bf2bd..ac5555e957d 100644 --- a/src/amd/vulkan/radv_radeon_winsys.h +++ b/src/amd/vulkan/radv_radeon_winsys.h @@ -255,9 +255,9 @@ struct radeon_winsys { void (*buffer_get_metadata)(struct radeon_winsys_bo *bo, struct radeon_bo_metadata *md); - void (*buffer_virtual_bind)(struct radeon_winsys_bo *parent, - uint64_t offset, uint64_t size, - struct radeon_winsys_bo *bo, uint64_t bo_offset); + VkResult (*buffer_virtual_bind)(struct radeon_winsys_bo *parent, + uint64_t offset, uint64_t size, + struct radeon_winsys_bo *bo, uint64_t bo_offset); VkResult (*ctx_create)(struct radeon_winsys *ws, enum radeon_ctx_priority priority, struct radeon_winsys_ctx **ctx); diff --git a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c index 52b94f2e27a..496d6cf08db 100644 --- a/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c +++ b/src/amd/vulkan/winsys/amdgpu/radv_amdgpu_bo.c @@ -127,7 +127,7 @@ static int bo_comparator(const void *ap, const void *bp) { return (a > b) ? 1 : (a < b) ? -1 : 0; } -static void +static VkResult radv_amdgpu_winsys_rebuild_bo_list(struct radv_amdgpu_winsys_bo *bo) { if (bo->bo_capacity < bo->range_count) { @@ -135,7 +135,7 @@ radv_amdgpu_winsys_rebuild_bo_list(struct radv_amdgpu_winsys_bo *bo) struct radv_amdgpu_winsys_bo **bos = realloc(bo->bos, new_count * sizeof(struct radv_amdgpu_winsys_bo *)); if (!bos) - return; + return VK_ERROR_OUT_OF_HOST_MEMORY; bo->bos = bos; bo->bo_capacity = new_count; } @@ -153,9 +153,11 @@ radv_amdgpu_winsys_rebuild_bo_list(struct radv_amdgpu_winsys_bo *bo) bo->bos[final_bo_count++] = bo->bos[i]; bo->bo_count = final_bo_count; + + return VK_SUCCESS; } -static void +static VkResult radv_amdgpu_winsys_bo_virtual_bind(struct radeon_winsys_bo *_parent, uint64_t offset, uint64_t size, struct radeon_winsys_bo *_bo, uint64_t bo_offset) @@ -165,6 +167,7 @@ radv_amdgpu_winsys_bo_virtual_bind(struct radeon_winsys_bo *_parent, int range_count_delta, new_idx; int first = 0, last; struct radv_amdgpu_map_range new_first, new_last; + VkResult result; assert(parent->is_virtual); assert(!bo || !bo->is_virtual); @@ -176,7 +179,7 @@ radv_amdgpu_winsys_bo_virtual_bind(struct radeon_winsys_bo *_parent, realloc(parent->ranges, range_capacity * sizeof(struct radv_amdgpu_map_range)); if (!ranges) - return; + return VK_ERROR_OUT_OF_HOST_MEMORY; parent->ranges = ranges; parent->range_capacity = range_capacity; } @@ -272,7 +275,11 @@ radv_amdgpu_winsys_bo_virtual_bind(struct radeon_winsys_bo *_parent, parent->range_count += range_count_delta; - radv_amdgpu_winsys_rebuild_bo_list(parent); + result = radv_amdgpu_winsys_rebuild_bo_list(parent); + if (result != VK_SUCCESS) + return result; + + return VK_SUCCESS; } static void radv_amdgpu_winsys_bo_destroy(struct radeon_winsys_bo *_bo)