turnip: Plumb non-startup errors through the new vk_error helpers

Also, change every vk_error to use the closest object instead of
fetching all the way back to the instance.

Reviewed-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
This commit is contained in:
Jason Ekstrand 2021-09-24 15:35:20 -05:00 committed by Marge Bot
parent bab0530f07
commit a1ac8234ec
13 changed files with 80 additions and 83 deletions

View File

@ -142,7 +142,7 @@ tu_gralloc_info_other(struct tu_device *device,
*/
if (gralloc_info->handle->numInts < 2) {
return vk_errorf(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE,
return vk_errorf(device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"VkNativeBufferANDROID::handle::numInts is %d, "
"expected at least 2 for qcom gralloc",
gralloc_info->handle->numFds);
@ -150,7 +150,7 @@ tu_gralloc_info_other(struct tu_device *device,
uint32_t gmsm = ('g' << 24) | ('m' << 16) | ('s' << 8) | 'm';
if (handle_data[0] != gmsm) {
return vk_errorf(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE,
return vk_errorf(device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"private_handle_t::magic is %x, expected %x",
handle_data[0], gmsm);
}
@ -164,7 +164,7 @@ tu_gralloc_info_other(struct tu_device *device,
*/
*dma_buf = handle_fds[0];
} else {
return vk_errorf(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE,
return vk_errorf(device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"VkNativeBufferANDROID::handle::numFds is %d, "
"expected 1 (gbm_gralloc) or 2 (qcom gralloc)",
gralloc_info->handle->numFds);
@ -358,7 +358,7 @@ format_supported_with_usage(VkDevice device_h, VkFormat format,
result = tu_GetPhysicalDeviceImageFormatProperties2(
phys_dev_h, &image_format_info, &image_format_props);
if (result != VK_SUCCESS) {
return vk_errorf(device->instance, result,
return vk_errorf(device, result,
"tu_GetPhysicalDeviceImageFormatProperties2 failed "
"inside %s",
__func__);
@ -385,7 +385,7 @@ setup_gralloc0_usage(struct tu_device *device, VkFormat format,
* gralloc swapchains.
*/
if (imageUsage != 0) {
return vk_errorf(device->instance, VK_ERROR_FORMAT_NOT_SUPPORTED,
return vk_errorf(device, VK_ERROR_FORMAT_NOT_SUPPORTED,
"unsupported VkImageUsageFlags(0x%x) for gralloc "
"swapchain",
imageUsage);

View File

@ -1398,7 +1398,7 @@ tu_create_cmd_buffer(struct tu_device *device,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (cmd_buffer == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
VkResult result = vk_command_buffer_init(&cmd_buffer->vk, &device->vk);
if (result != VK_SUCCESS) {
@ -3003,7 +3003,7 @@ tu_CreateCommandPool(VkDevice _device,
pool = vk_object_alloc(&device->vk, pAllocator, sizeof(*pool),
VK_OBJECT_TYPE_COMMAND_POOL);
if (pool == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
if (pAllocator)
pool->alloc = *pAllocator;

View File

@ -152,7 +152,7 @@ tu_CreateDescriptorSetLayout(
set_layout = vk_object_zalloc(&device->vk, pAllocator, size,
VK_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT);
if (!set_layout)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
set_layout->flags = pCreateInfo->flags;
@ -166,7 +166,7 @@ tu_CreateDescriptorSetLayout(
pCreateInfo->pBindings, pCreateInfo->bindingCount, &bindings);
if (result != VK_SUCCESS) {
vk_object_free(&device->vk, pAllocator, set_layout);
return vk_error(device->instance, result);
return vk_error(device, result);
}
set_layout->binding_count = num_bindings;
@ -388,7 +388,7 @@ tu_CreatePipelineLayout(VkDevice _device,
layout = vk_object_alloc(&device->vk, pAllocator, sizeof(*layout),
VK_OBJECT_TYPE_PIPELINE_LAYOUT);
if (layout == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
layout->num_sets = pCreateInfo->setLayoutCount;
layout->dynamic_offset_count = 0;
@ -448,7 +448,7 @@ tu_descriptor_set_create(struct tu_device *device,
if (pool->host_memory_base) {
if (pool->host_memory_end - pool->host_memory_ptr < mem_size)
return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_POOL_MEMORY);
set = (struct tu_descriptor_set*)pool->host_memory_ptr;
pool->host_memory_ptr += mem_size;
@ -457,7 +457,7 @@ tu_descriptor_set_create(struct tu_device *device,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (!set)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
}
memset(set, 0, mem_size);
@ -482,7 +482,7 @@ tu_descriptor_set_create(struct tu_device *device,
if (!pool->host_memory_base && pool->entry_count == pool->max_entry_count) {
vk_object_free(&device->vk, NULL, set);
return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_POOL_MEMORY);
}
/* try to allocate linearly first, so that we don't spend
@ -511,7 +511,7 @@ tu_descriptor_set_create(struct tu_device *device,
if (pool->size - offset < layout_size) {
vk_object_free(&device->vk, NULL, set);
return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_POOL_MEMORY);
}
set->mapped_ptr = (uint32_t*)(pool_base(pool) + offset);
@ -524,7 +524,7 @@ tu_descriptor_set_create(struct tu_device *device,
pool->entries[index].set = set;
pool->entry_count++;
} else
return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_POOL_MEMORY);
}
if (layout->has_immutable_samplers) {
@ -635,7 +635,7 @@ tu_CreateDescriptorPool(VkDevice _device,
pool = vk_object_zalloc(&device->vk, pAllocator, size,
VK_OBJECT_TYPE_DESCRIPTOR_POOL);
if (!pool)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
if (!(pCreateInfo->flags & VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT)) {
pool->host_memory_base = (uint8_t*)pool + sizeof(struct tu_descriptor_pool);
@ -1073,7 +1073,7 @@ tu_CreateDescriptorUpdateTemplate(
templ = vk_object_alloc(&device->vk, pAllocator, size,
VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE);
if (!templ)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
templ->entry_count = entry_count;
@ -1253,7 +1253,7 @@ tu_CreateSamplerYcbcrConversion(
conversion = vk_object_alloc(&device->vk, pAllocator, sizeof(*conversion),
VK_OBJECT_TYPE_SAMPLER_YCBCR_CONVERSION);
if (!conversion)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
conversion->format = pCreateInfo->format;
conversion->ycbcr_model = pCreateInfo->ycbcrModel;

View File

@ -1856,12 +1856,12 @@ tu_AllocateMemory(VkDevice _device,
struct tu_memory_heap *mem_heap = &device->physical_device->heap;
uint64_t mem_heap_used = p_atomic_read(&mem_heap->used);
if (mem_heap_used > mem_heap->size)
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
mem = vk_object_alloc(&device->vk, pAllocator, sizeof(*mem),
VK_OBJECT_TYPE_DEVICE_MEMORY);
if (mem == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
const VkImportMemoryFdInfoKHR *fd_info =
vk_find_struct_const(pAllocateInfo->pNext, IMPORT_MEMORY_FD_INFO_KHR);
@ -1897,7 +1897,7 @@ tu_AllocateMemory(VkDevice _device,
if (mem_heap_used > mem_heap->size) {
p_atomic_add(&mem_heap->used, -mem->bo.size);
tu_bo_finish(device, &mem->bo);
result = vk_errorf(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY,
result = vk_errorf(device, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"Out of heap memory");
}
}
@ -2113,7 +2113,7 @@ tu_CreateEvent(VkDevice _device,
vk_object_alloc(&device->vk, pAllocator, sizeof(*event),
VK_OBJECT_TYPE_EVENT);
if (!event)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
VkResult result = tu_bo_init_new(device, &event->bo, 0x1000,
TU_BO_ALLOC_NO_FLAGS);
@ -2132,7 +2132,7 @@ fail_map:
tu_bo_finish(device, &event->bo);
fail_alloc:
vk_object_free(&device->vk, pAllocator, event);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
}
VKAPI_ATTR void VKAPI_CALL
@ -2192,7 +2192,7 @@ tu_CreateBuffer(VkDevice _device,
buffer = vk_object_alloc(&device->vk, pAllocator, sizeof(*buffer),
VK_OBJECT_TYPE_BUFFER);
if (buffer == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
buffer->size = pCreateInfo->size;
buffer->usage = pCreateInfo->usage;
@ -2234,7 +2234,7 @@ tu_CreateFramebuffer(VkDevice _device,
framebuffer = vk_object_alloc(&device->vk, pAllocator, size,
VK_OBJECT_TYPE_FRAMEBUFFER);
if (framebuffer == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
framebuffer->attachment_count = pCreateInfo->attachmentCount;
framebuffer->width = pCreateInfo->width;
@ -2351,7 +2351,7 @@ tu_CreateSampler(VkDevice _device,
sampler = vk_object_alloc(&device->vk, pAllocator, sizeof(*sampler),
VK_OBJECT_TYPE_SAMPLER);
if (!sampler)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
tu_init_sampler(device, sampler, pCreateInfo);
*pSampler = tu_sampler_to_handle(sampler);
@ -2447,7 +2447,7 @@ tu_GetMemoryFdKHR(VkDevice _device,
int prime_fd = tu_bo_export_dmabuf(device, &memory->bo);
if (prime_fd < 0)
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
*pFd = prime_fd;
return VK_SUCCESS;

View File

@ -318,7 +318,7 @@ tu_bo_init_new(struct tu_device *dev, struct tu_bo *bo, uint64_t size,
int ret = drmCommandWriteRead(dev->fd,
DRM_MSM_GEM_NEW, &req, sizeof(req));
if (ret)
return vk_error(dev->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return vk_error(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return tu_bo_init(dev, bo, req.handle, size, flags & TU_BO_ALLOC_ALLOW_DUMP);
}
@ -333,13 +333,13 @@ tu_bo_init_dmabuf(struct tu_device *dev,
off_t real_size = lseek(prime_fd, 0, SEEK_END);
lseek(prime_fd, 0, SEEK_SET);
if (real_size < 0 || (uint64_t) real_size < size)
return vk_error(dev->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
return vk_error(dev, VK_ERROR_INVALID_EXTERNAL_HANDLE);
uint32_t gem_handle;
int ret = drmPrimeFDToHandle(dev->fd, prime_fd,
&gem_handle);
if (ret)
return vk_error(dev->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
return vk_error(dev, VK_ERROR_INVALID_EXTERNAL_HANDLE);
return tu_bo_init(dev, bo, gem_handle, size, false);
}
@ -362,13 +362,13 @@ tu_bo_map(struct tu_device *dev, struct tu_bo *bo)
uint64_t offset = tu_gem_info(dev, bo->gem_handle, MSM_INFO_GET_OFFSET);
if (!offset)
return vk_error(dev->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
return vk_error(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY);
/* TODO: Should we use the wrapper os_mmap() like Freedreno does? */
void *map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
dev->fd, offset);
if (map == MAP_FAILED)
return vk_error(dev->instance, VK_ERROR_MEMORY_MAP_FAILED);
return vk_error(dev, VK_ERROR_MEMORY_MAP_FAILED);
bo->map = map;
return VK_SUCCESS;
@ -579,7 +579,7 @@ sync_create(VkDevice _device,
vk_object_alloc(&device->vk, pAllocator, sizeof(*sync),
fence ? VK_OBJECT_TYPE_FENCE : VK_OBJECT_TYPE_SEMAPHORE);
if (!sync)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
if (binary) {
struct drm_syncobj_create create = {};
@ -701,7 +701,7 @@ sync_export(VkDevice _device, struct tu_syncobj *sync, bool sync_fd, int *p_fd)
};
int ret = drmIoctl(device->fd, DRM_IOCTL_SYNCOBJ_HANDLE_TO_FD, &handle);
if (ret)
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
return vk_error(device, VK_ERROR_INVALID_EXTERNAL_HANDLE);
/* restore permanent payload on export */
sync_set_temporary(device, sync, 0);
@ -892,7 +892,7 @@ tu_queue_submit_create_locked(struct tu_queue *queue,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (new_submit->cmd_buffers == NULL) {
result = vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY)
result = vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_cmd_buffers;
}
@ -903,7 +903,7 @@ tu_queue_submit_create_locked(struct tu_queue *queue,
submit_info->waitSemaphoreCount * sizeof(*new_submit->wait_semaphores),
8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (new_submit->wait_semaphores == NULL) {
result = vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY)
result = vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_wait_semaphores;
}
new_submit->wait_semaphore_count = submit_info->waitSemaphoreCount;
@ -912,7 +912,7 @@ tu_queue_submit_create_locked(struct tu_queue *queue,
submit_info->signalSemaphoreCount *sizeof(*new_submit->signal_semaphores),
8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (new_submit->signal_semaphores == NULL) {
result = vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY)
result = vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_signal_semaphores;
}
new_submit->signal_semaphore_count = submit_info->signalSemaphoreCount;
@ -966,7 +966,7 @@ tu_queue_submit_create_locked(struct tu_queue *queue,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (new_submit->cmds == NULL) {
result = vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY)
result = vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_cmds;
}
@ -976,7 +976,7 @@ tu_queue_submit_create_locked(struct tu_queue *queue,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (new_submit->cmd_buffer_trace_data == NULL) {
result = vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY)
result = vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_cmd_trace_data;
}
@ -993,7 +993,7 @@ tu_queue_submit_create_locked(struct tu_queue *queue,
if (tu_create_copy_timestamp_cs(cmdbuf,
&new_submit->cmd_buffer_trace_data[i].timestamp_copy_cs,
&new_submit->cmd_buffer_trace_data[i].trace) != VK_SUCCESS) {
result = vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY)
result = vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_copy_timestamp_cs;
}
assert(new_submit->cmd_buffer_trace_data[i].timestamp_copy_cs->entry_count == 1);
@ -1009,7 +1009,7 @@ tu_queue_submit_create_locked(struct tu_queue *queue,
sizeof(*new_submit->in_syncobjs), 8, VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (new_submit->in_syncobjs == NULL) {
result = vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY)
result = vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_in_syncobjs;
}
@ -1019,7 +1019,7 @@ tu_queue_submit_create_locked(struct tu_queue *queue,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (new_submit->out_syncobjs == NULL) {
result = vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY)
result = vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
goto fail_out_syncobjs;
}
@ -1258,14 +1258,14 @@ tu_timeline_add_point_locked(struct tu_device *device,
VK_SYSTEM_ALLOCATION_SCOPE_DEVICE);
if (!(*point))
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
struct drm_syncobj_create create = {};
int ret = drmIoctl(device->fd, DRM_IOCTL_SYNCOBJ_CREATE, &create);
if (ret) {
vk_free(&device->vk.alloc, *point);
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
return vk_error(device, VK_ERROR_DEVICE_LOST);
}
(*point)->syncobj = create.handle;

View File

@ -511,7 +511,7 @@ tu_get_external_image_format_properties(
VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT;
break;
default:
return vk_errorf(physical_device->instance, VK_ERROR_FORMAT_NOT_SUPPORTED,
return vk_errorf(physical_device, VK_ERROR_FORMAT_NOT_SUPPORTED,
"VkExternalMemoryTypeFlagBits(0x%x) unsupported for VkImageType(%d)",
handleType, pImageFormatInfo->type);
}
@ -521,7 +521,7 @@ tu_get_external_image_format_properties(
compat_flags = VK_EXTERNAL_MEMORY_HANDLE_TYPE_HOST_ALLOCATION_BIT_EXT;
break;
default:
return vk_errorf(physical_device->instance, VK_ERROR_FORMAT_NOT_SUPPORTED,
return vk_errorf(physical_device, VK_ERROR_FORMAT_NOT_SUPPORTED,
"VkExternalMemoryTypeFlagBits(0x%x) unsupported",
handleType);
}

View File

@ -568,7 +568,7 @@ tu_CreateImage(VkDevice _device,
image = vk_object_zalloc(&device->vk, alloc, sizeof(*image),
VK_OBJECT_TYPE_IMAGE);
if (!image)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
const VkExternalMemoryImageCreateInfo *external_info =
vk_find_struct_const(pCreateInfo->pNext, EXTERNAL_MEMORY_IMAGE_CREATE_INFO);
@ -737,7 +737,7 @@ tu_CreateImage(VkDevice _device,
invalid_layout:
vk_object_free(&device->vk, alloc, image);
return vk_error(device->instance, VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT);
return vk_error(device, VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT);
}
VKAPI_ATTR void VKAPI_CALL
@ -819,7 +819,7 @@ tu_CreateImageView(VkDevice _device,
view = vk_object_alloc(&device->vk, pAllocator, sizeof(*view),
VK_OBJECT_TYPE_IMAGE_VIEW);
if (view == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
tu_image_view_init(view, pCreateInfo, device->physical_device->info->a6xx.has_z24uint_s8uint);
@ -902,7 +902,7 @@ tu_CreateBufferView(VkDevice _device,
view = vk_object_alloc(&device->vk, pAllocator, sizeof(*view),
VK_OBJECT_TYPE_BUFFER_VIEW);
if (!view)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
tu_buffer_view_init(view, device, pCreateInfo);

View File

@ -96,7 +96,7 @@ tu_bo_init_new(struct tu_device *dev, struct tu_bo *bo, uint64_t size,
ret = safe_ioctl(dev->physical_device->local_fd,
IOCTL_KGSL_GPUMEM_ALLOC_ID, &req);
if (ret) {
return vk_errorf(dev->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY,
return vk_errorf(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"GPUMEM_ALLOC_ID failed (%s)", strerror(errno));
}
@ -129,7 +129,7 @@ tu_bo_init_dmabuf(struct tu_device *dev,
ret = safe_ioctl(dev->physical_device->local_fd,
IOCTL_KGSL_GPUOBJ_IMPORT, &req);
if (ret)
return vk_errorf(dev->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY,
return vk_errorf(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"Failed to import dma-buf (%s)\n", strerror(errno));
struct kgsl_gpuobj_info info_req = {
@ -139,7 +139,7 @@ tu_bo_init_dmabuf(struct tu_device *dev,
ret = safe_ioctl(dev->physical_device->local_fd,
IOCTL_KGSL_GPUOBJ_INFO, &info_req);
if (ret)
return vk_errorf(dev->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY,
return vk_errorf(dev, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"Failed to get dma-buf info (%s)\n", strerror(errno));
*bo = (struct tu_bo) {
@ -169,7 +169,7 @@ tu_bo_map(struct tu_device *dev, struct tu_bo *bo)
void *map = mmap(0, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED,
dev->physical_device->local_fd, offset);
if (map == MAP_FAILED)
return vk_error(dev->instance, VK_ERROR_MEMORY_MAP_FAILED);
return vk_error(dev, VK_ERROR_MEMORY_MAP_FAILED);
bo->map = map;
@ -366,7 +366,7 @@ tu_QueueSubmit(VkQueue _queue,
sizeof(cmds[0]) * max_entry_count, 8,
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
if (cmds == NULL)
return vk_error(queue->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(queue, VK_ERROR_OUT_OF_HOST_MEMORY);
for (uint32_t i = 0; i < submitCount; ++i) {
const VkSubmitInfo *submit = pSubmits + i;
@ -482,7 +482,7 @@ sync_create(VkDevice _device,
vk_object_alloc(&device->vk, pAllocator, sizeof(*sync),
fence ? VK_OBJECT_TYPE_FENCE : VK_OBJECT_TYPE_SEMAPHORE);
if (!sync)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
if (signaled)
tu_finishme("CREATE FENCE SIGNALED");

View File

@ -642,7 +642,7 @@ tu_CreateRenderPass2(VkDevice _device,
pass = vk_object_zalloc(&device->vk, pAllocator, size,
VK_OBJECT_TYPE_RENDER_PASS);
if (pass == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
pass->attachment_count = pCreateInfo->attachmentCount;
pass->subpass_count = pCreateInfo->subpassCount;
@ -688,7 +688,7 @@ tu_CreateRenderPass2(VkDevice _device,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (pass->subpass_attachments == NULL) {
vk_object_free(&device->vk, pAllocator, pass);
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
}
} else
pass->subpass_attachments = NULL;

View File

@ -162,7 +162,7 @@ tu_pipeline_cache_grow(struct tu_pipeline_cache *cache)
table = malloc(byte_size);
if (table == NULL)
return vk_error(cache->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(cache, VK_ERROR_OUT_OF_HOST_MEMORY);
cache->hash_table = table;
cache->table_size = table_size;
@ -257,7 +257,7 @@ tu_CreatePipelineCache(VkDevice _device,
cache = vk_object_alloc(&device->vk, pAllocator, sizeof(*cache),
VK_OBJECT_TYPE_PIPELINE_CACHE);
if (cache == NULL)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
if (pAllocator)
cache->alloc = *pAllocator;

View File

@ -60,6 +60,7 @@
#include "vk_dispatch_table.h"
#include "vk_extensions.h"
#include "vk_instance.h"
#include "vk_log.h"
#include "vk_physical_device.h"
#include "vk_shader_module.h"
#include "wsi_common.h"
@ -135,25 +136,21 @@ typedef uint32_t xcb_window_t;
struct tu_instance;
VkResult
__vk_errorf(struct tu_instance *instance,
VkResult error,
bool force_print,
const char *file,
int line,
const char *format,
...) PRINTFLIKE(6, 7);
#define vk_error(instance, error) \
__vk_errorf(instance, error, false, __FILE__, __LINE__, NULL);
#define vk_errorf(instance, error, format, ...) \
__vk_errorf(instance, error, false, __FILE__, __LINE__, format, ##__VA_ARGS__);
__vk_startup_errorf(struct tu_instance *instance,
VkResult error,
bool force_print,
const char *file,
int line,
const char *format,
...) PRINTFLIKE(6, 7);
/* Prints startup errors if TU_DEBUG=startup is set or on a debug driver
* build.
*/
#define vk_startup_errorf(instance, error, format, ...) \
__vk_errorf(instance, error, instance->debug_flags & TU_DEBUG_STARTUP, \
__FILE__, __LINE__, format, ##__VA_ARGS__)
__vk_startup_errorf(instance, error, \
instance->debug_flags & TU_DEBUG_STARTUP, \
__FILE__, __LINE__, format, ##__VA_ARGS__)
void
__tu_finishme(const char *file, int line, const char *format, ...)

View File

@ -265,7 +265,7 @@ tu_CreateQueryPool(VkDevice _device,
vk_object_alloc(&device->vk, pAllocator, pool_size,
VK_OBJECT_TYPE_QUERY_POOL);
if (!pool)
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
if (pCreateInfo->queryType == VK_QUERY_TYPE_PERFORMANCE_QUERY_KHR) {
pool->perf_group = fd_perfcntrs(&device->physical_device->dev_id,
@ -426,7 +426,7 @@ wait_for_available(struct tu_device *device, struct tu_query_pool *pool,
if (query_is_available(slot))
return VK_SUCCESS;
}
return vk_error(device->instance, VK_TIMEOUT);
return vk_error(device, VK_TIMEOUT);
}
/* Writes a query value to a buffer from the CPU. */

View File

@ -47,13 +47,13 @@ void PRINTFLIKE(3, 4)
}
VkResult
__vk_errorf(struct tu_instance *instance,
VkResult error,
bool always_print,
const char *file,
int line,
const char *format,
...)
__vk_startup_errorf(struct tu_instance *instance,
VkResult error,
bool always_print,
const char *file,
int line,
const char *format,
...)
{
va_list ap;
char buffer[256];