v3dv: Switch to 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: Alejandro Piñeiro <apinheiro@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/13045>
This commit is contained in:
parent
708b65f704
commit
bab0530f07
|
@ -50,7 +50,6 @@ libv3dv_files = files(
|
|||
'v3dv_query.c',
|
||||
'v3dv_queue.c',
|
||||
'v3dv_uniforms.c',
|
||||
'v3dv_util.c',
|
||||
'v3dv_wsi.c',
|
||||
)
|
||||
|
||||
|
|
|
@ -98,7 +98,7 @@ v3dv_CreateCommandPool(VkDevice _device,
|
|||
pool = vk_object_zalloc(&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;
|
||||
|
@ -156,7 +156,7 @@ cmd_buffer_create(struct v3dv_device *device,
|
|||
8,
|
||||
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;
|
||||
result = vk_command_buffer_init(&cmd_buffer->vk, &device->vk);
|
||||
|
|
|
@ -326,7 +326,7 @@ v3dv_CreatePipelineLayout(VkDevice _device,
|
|||
layout = vk_object_zalloc(&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;
|
||||
|
||||
|
@ -433,7 +433,7 @@ v3dv_CreateDescriptorPool(VkDevice _device,
|
|||
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 v3dv_descriptor_pool);
|
||||
|
@ -463,7 +463,7 @@ v3dv_CreateDescriptorPool(VkDevice _device,
|
|||
|
||||
out_of_device_memory:
|
||||
vk_object_free(&device->vk, pAllocator, pool);
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -583,7 +583,7 @@ v3dv_CreateDescriptorSetLayout(VkDevice _device,
|
|||
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);
|
||||
|
||||
/* We just allocate all the immutable samplers at the end of the struct */
|
||||
struct v3dv_sampler *samplers = (void*) &set_layout->binding[num_bindings];
|
||||
|
@ -595,7 +595,7 @@ v3dv_CreateDescriptorSetLayout(VkDevice _device,
|
|||
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);
|
||||
}
|
||||
|
||||
memset(set_layout->binding, 0,
|
||||
|
@ -697,7 +697,7 @@ out_of_pool_memory(const struct v3dv_device *device,
|
|||
* by allocating a new pool, so they don't point to real issues.
|
||||
*/
|
||||
if (!pool->is_driver_internal)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_POOL_MEMORY)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_POOL_MEMORY);
|
||||
else
|
||||
return VK_ERROR_OUT_OF_POOL_MEMORY;
|
||||
}
|
||||
|
@ -726,7 +726,7 @@ descriptor_set_create(struct v3dv_device *device,
|
|||
VK_OBJECT_TYPE_DESCRIPTOR_SET);
|
||||
|
||||
if (!set)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
|
||||
set->pool = pool;
|
||||
|
@ -1142,7 +1142,7 @@ v3dv_CreateDescriptorUpdateTemplate(
|
|||
template = vk_object_alloc(&device->vk, pAllocator, size,
|
||||
VK_OBJECT_TYPE_DESCRIPTOR_UPDATE_TEMPLATE);
|
||||
if (template == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
template->bind_point = pCreateInfo->pipelineBindPoint;
|
||||
|
||||
|
|
|
@ -614,14 +614,14 @@ init_uuids(struct v3dv_physical_device *device)
|
|||
const struct build_id_note *note =
|
||||
build_id_find_nhdr_for_addr(init_uuids);
|
||||
if (!note) {
|
||||
return vk_errorf((struct v3dv_instance*) device->vk.instance,
|
||||
return vk_errorf(device->vk.instance,
|
||||
VK_ERROR_INITIALIZATION_FAILED,
|
||||
"Failed to find build-id");
|
||||
}
|
||||
|
||||
unsigned build_id_len = build_id_length(note);
|
||||
if (build_id_len < 20) {
|
||||
return vk_errorf((struct v3dv_instance*) device->vk.instance,
|
||||
return vk_errorf(device->vk.instance,
|
||||
VK_ERROR_INITIALIZATION_FAILED,
|
||||
"build-id too short. It needs to be a SHA");
|
||||
}
|
||||
|
@ -727,8 +727,7 @@ physical_device_init(struct v3dv_physical_device *device,
|
|||
device->has_primary = primary_path;
|
||||
if (device->has_primary) {
|
||||
if (stat(primary_path, &primary_stat) != 0) {
|
||||
result = vk_errorf(instance,
|
||||
VK_ERROR_INITIALIZATION_FAILED,
|
||||
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"failed to stat DRM primary node %s",
|
||||
primary_path);
|
||||
goto fail;
|
||||
|
@ -738,8 +737,7 @@ physical_device_init(struct v3dv_physical_device *device,
|
|||
}
|
||||
|
||||
if (fstat(render_fd, &render_stat) != 0) {
|
||||
result = vk_errorf(instance,
|
||||
VK_ERROR_INITIALIZATION_FAILED,
|
||||
result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
|
||||
"failed to stat DRM render node %s",
|
||||
path);
|
||||
goto fail;
|
||||
|
@ -1671,8 +1669,7 @@ v3dv_EnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice,
|
|||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
return vk_error((struct v3dv_instance*) physical_device->vk.instance,
|
||||
VK_ERROR_LAYER_NOT_PRESENT);
|
||||
return vk_error(physical_device, VK_ERROR_LAYER_NOT_PRESENT);
|
||||
}
|
||||
|
||||
static VkResult
|
||||
|
@ -2144,7 +2141,7 @@ v3dv_AllocateMemory(VkDevice _device,
|
|||
|
||||
if (result != VK_SUCCESS) {
|
||||
vk_object_free(&device->vk, pAllocator, mem);
|
||||
return vk_error(device->instance, result);
|
||||
return vk_error(device, result);
|
||||
}
|
||||
|
||||
*pMem = v3dv_device_memory_to_handle(mem);
|
||||
|
@ -2195,7 +2192,7 @@ v3dv_MapMemory(VkDevice _device,
|
|||
*/
|
||||
VkResult result = device_map(device, mem);
|
||||
if (result != VK_SUCCESS)
|
||||
return vk_error(device->instance, result);
|
||||
return vk_error(device, result);
|
||||
|
||||
*ppData = ((uint8_t *) mem->bo->map) + offset;
|
||||
return VK_SUCCESS;
|
||||
|
@ -2384,7 +2381,7 @@ v3dv_CreateBuffer(VkDevice _device,
|
|||
buffer = vk_object_zalloc(&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;
|
||||
|
@ -2430,7 +2427,7 @@ v3dv_CreateFramebuffer(VkDevice _device,
|
|||
framebuffer = vk_object_zalloc(&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->width = pCreateInfo->width;
|
||||
framebuffer->height = pCreateInfo->height;
|
||||
|
@ -2480,7 +2477,7 @@ v3dv_GetMemoryFdPropertiesKHR(VkDevice _device,
|
|||
(1 << pdevice->memory.memoryTypeCount) - 1;
|
||||
return VK_SUCCESS;
|
||||
default:
|
||||
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
return vk_error(device, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2501,7 +2498,7 @@ v3dv_GetMemoryFdKHR(VkDevice _device,
|
|||
mem->bo->handle,
|
||||
DRM_CLOEXEC, &fd);
|
||||
if (ret)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
*pFd = fd;
|
||||
|
||||
|
@ -2519,7 +2516,7 @@ v3dv_CreateEvent(VkDevice _device,
|
|||
vk_object_zalloc(&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);
|
||||
|
||||
/* Events are created in the unsignaled state */
|
||||
event->state = false;
|
||||
|
@ -2579,7 +2576,7 @@ v3dv_CreateSampler(VkDevice _device,
|
|||
sampler = vk_object_zalloc(&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);
|
||||
|
||||
sampler->compare_enable = pCreateInfo->compareEnable;
|
||||
sampler->unnormalized_coordinates = pCreateInfo->unnormalizedCoordinates;
|
||||
|
|
|
@ -253,7 +253,7 @@ create_image(struct v3dv_device *device,
|
|||
|
||||
image = vk_image_create(&device->vk, pCreateInfo, pAllocator, sizeof(*image));
|
||||
if (image == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
/* When using the simulator the WSI common code will see that our
|
||||
* driver wsi device doesn't match the display device and because of that
|
||||
|
@ -487,7 +487,7 @@ v3dv_CreateImageView(VkDevice _device,
|
|||
iview = vk_image_view_create(&device->vk, pCreateInfo, pAllocator,
|
||||
sizeof(*iview));
|
||||
if (iview == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
const VkImageSubresourceRange *range = &pCreateInfo->subresourceRange;
|
||||
|
||||
|
@ -578,7 +578,7 @@ v3dv_CreateBufferView(VkDevice _device,
|
|||
vk_object_zalloc(&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);
|
||||
|
||||
uint32_t range;
|
||||
if (pCreateInfo->range == VK_WHOLE_SIZE)
|
||||
|
|
|
@ -143,7 +143,7 @@ v3dv_CreateRenderPass(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->multiview_enabled = multiview_enabled;
|
||||
pass->attachment_count = pCreateInfo->attachmentCount;
|
||||
|
@ -168,7 +168,7 @@ v3dv_CreateRenderPass(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;
|
||||
|
|
|
@ -3049,7 +3049,7 @@ graphics_pipeline_create(VkDevice _device,
|
|||
VK_OBJECT_TYPE_PIPELINE);
|
||||
|
||||
if (pipeline == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
result = pipeline_init(pipeline, device, cache,
|
||||
pCreateInfo,
|
||||
|
@ -3284,7 +3284,7 @@ compute_pipeline_create(VkDevice _device,
|
|||
pipeline = vk_object_zalloc(&device->vk, pAllocator, sizeof(*pipeline),
|
||||
VK_OBJECT_TYPE_PIPELINE);
|
||||
if (pipeline == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
result = compute_pipeline_init(pipeline, device, cache,
|
||||
pCreateInfo, pAllocator);
|
||||
|
|
|
@ -695,7 +695,7 @@ v3dv_CreatePipelineCache(VkDevice _device,
|
|||
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);
|
||||
|
||||
v3dv_pipeline_cache_init(cache, device, pCreateInfo->flags,
|
||||
device->instance->pipeline_cache_enabled);
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include "vk_device.h"
|
||||
#include "vk_instance.h"
|
||||
#include "vk_image.h"
|
||||
#include "vk_log.h"
|
||||
#include "vk_physical_device.h"
|
||||
#include "vk_shader_module.h"
|
||||
#include "vk_util.h"
|
||||
|
@ -1874,13 +1875,6 @@ const nir_shader_compiler_options *v3dv_pipeline_get_nir_options(void);
|
|||
uint32_t v3dv_physical_device_vendor_id(struct v3dv_physical_device *dev);
|
||||
uint32_t v3dv_physical_device_device_id(struct v3dv_physical_device *dev);
|
||||
|
||||
VkResult __vk_errorf(struct v3dv_instance *instance, VkResult error,
|
||||
const char *file, int line,
|
||||
const char *format, ...);
|
||||
|
||||
#define vk_error(instance, error) __vk_errorf(instance, error, __FILE__, __LINE__, NULL);
|
||||
#define vk_errorf(instance, error, format, ...) __vk_errorf(instance, error, __FILE__, __LINE__, format, ## __VA_ARGS__);
|
||||
|
||||
#ifdef DEBUG
|
||||
#define v3dv_debug_ignored_stype(sType) \
|
||||
fprintf(stderr, "%s: ignored VkStructureType %u:%s\n\n", __func__, (sType), vk_StructureType_to_str(sType))
|
||||
|
|
|
@ -39,7 +39,7 @@ v3dv_CreateQueryPool(VkDevice _device,
|
|||
vk_object_zalloc(&device->vk, pAllocator, sizeof(*pool),
|
||||
VK_OBJECT_TYPE_QUERY_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);
|
||||
|
||||
pool->query_type = pCreateInfo->queryType;
|
||||
pool->query_count = pCreateInfo->queryCount;
|
||||
|
@ -50,7 +50,7 @@ v3dv_CreateQueryPool(VkDevice _device,
|
|||
pool->queries = vk_alloc2(&device->vk.alloc, pAllocator, pool_bytes, 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (pool->queries == NULL) {
|
||||
result = vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
result = vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
|
@ -63,11 +63,11 @@ v3dv_CreateQueryPool(VkDevice _device,
|
|||
const uint32_t bo_size = query_groups * 1024;
|
||||
pool->bo = v3dv_bo_alloc(device, bo_size, "query", true);
|
||||
if (!pool->bo) {
|
||||
result = vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
result = vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
goto fail;
|
||||
}
|
||||
if (!v3dv_bo_map(device, pool->bo, bo_size)) {
|
||||
result = vk_error(device->instance, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
result = vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
@ -159,10 +159,10 @@ get_occlusion_query_result(struct v3dv_device *device,
|
|||
* error may occur."
|
||||
*/
|
||||
if (!q->maybe_available)
|
||||
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
||||
|
||||
if (!v3dv_bo_wait(device, q->bo, 0xffffffffffffffffull))
|
||||
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
||||
|
||||
*available = true;
|
||||
} else {
|
||||
|
@ -195,7 +195,7 @@ get_timestamp_query_result(struct v3dv_device *device,
|
|||
* error may occur."
|
||||
*/
|
||||
if (!q->maybe_available)
|
||||
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
||||
|
||||
*available = true;
|
||||
} else {
|
||||
|
|
|
@ -223,7 +223,7 @@ handle_copy_query_results_cpu_job(struct v3dv_job *job)
|
|||
/* Map the entire dst buffer for the CPU copy if needed */
|
||||
assert(!bo->map || bo->map_size == bo->size);
|
||||
if (!bo->map && !v3dv_bo_map(job->device, bo, bo->size))
|
||||
return vk_error(job->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(job->device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
/* FIXME: if flags includes VK_QUERY_RESULT_WAIT_BIT this could trigger a
|
||||
* sync wait on the CPU for the corresponding GPU jobs to finish. We might
|
||||
|
@ -360,7 +360,7 @@ spawn_event_wait_thread(struct v3dv_job *job, pthread_t *wait_thread)
|
|||
assert(wait_thread != NULL);
|
||||
|
||||
if (pthread_create(wait_thread, NULL, event_wait_thread_func, job))
|
||||
return vk_error(job->device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(job->device, VK_ERROR_DEVICE_LOST);
|
||||
|
||||
return VK_NOT_READY;
|
||||
}
|
||||
|
@ -413,13 +413,13 @@ handle_copy_buffer_to_image_cpu_job(struct v3dv_job *job)
|
|||
struct v3dv_bo *dst_bo = info->image->mem->bo;
|
||||
assert(!dst_bo->map || dst_bo->map_size == dst_bo->size);
|
||||
if (!dst_bo->map && !v3dv_bo_map(job->device, dst_bo, dst_bo->size))
|
||||
return vk_error(job->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(job->device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
void *dst_ptr = dst_bo->map;
|
||||
|
||||
struct v3dv_bo *src_bo = info->buffer->mem->bo;
|
||||
assert(!src_bo->map || src_bo->map_size == src_bo->size);
|
||||
if (!src_bo->map && !v3dv_bo_map(job->device, src_bo, src_bo->size))
|
||||
return vk_error(job->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(job->device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
void *src_ptr = src_bo->map;
|
||||
|
||||
const struct v3d_resource_slice *slice =
|
||||
|
@ -492,7 +492,7 @@ handle_csd_indirect_cpu_job(struct v3dv_queue *queue,
|
|||
assert(info->buffer && info->buffer->mem && info->buffer->mem->bo);
|
||||
struct v3dv_bo *bo = info->buffer->mem->bo;
|
||||
if (!bo->map && !v3dv_bo_map(job->device, bo, bo->size))
|
||||
return vk_error(job->device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(job->device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
assert(bo->map);
|
||||
|
||||
const uint32_t offset = info->buffer->mem_offset + info->offset;
|
||||
|
@ -524,7 +524,7 @@ process_semaphores_to_signal(struct v3dv_device *device,
|
|||
drmSyncobjExportSyncFile(render_fd, device->last_job_sync, &fd);
|
||||
mtx_unlock(&device->mutex);
|
||||
if (fd == -1)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
VkResult result = VK_SUCCESS;
|
||||
for (uint32_t i = 0; i < count; i++) {
|
||||
|
@ -563,7 +563,7 @@ process_fence_to_signal(struct v3dv_device *device, VkFence _fence)
|
|||
drmSyncobjExportSyncFile(render_fd, device->last_job_sync, &fd);
|
||||
mtx_unlock(&device->mutex);
|
||||
if (fd == -1)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
int ret;
|
||||
if (!fence->temp_sync)
|
||||
|
@ -661,7 +661,7 @@ handle_cl_job(struct v3dv_queue *queue,
|
|||
free(bo_handles);
|
||||
|
||||
if (ret)
|
||||
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
@ -684,7 +684,7 @@ handle_tfu_job(struct v3dv_queue *queue,
|
|||
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Failed to submit TFU job: %d\n", ret);
|
||||
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
||||
}
|
||||
|
||||
return VK_SUCCESS;
|
||||
|
@ -729,7 +729,7 @@ handle_csd_job(struct v3dv_queue *queue,
|
|||
free(bo_handles);
|
||||
|
||||
if (ret)
|
||||
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
@ -777,7 +777,7 @@ queue_create_noop_job(struct v3dv_queue *queue)
|
|||
queue->noop_job = vk_zalloc(&device->vk.alloc, sizeof(struct v3dv_job), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (!queue->noop_job)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
v3dv_job_init(queue->noop_job, V3DV_JOB_TYPE_GPU_CL, device, NULL, -1);
|
||||
|
||||
v3dv_X(device, job_emit_noop)(queue->noop_job);
|
||||
|
@ -999,7 +999,7 @@ spawn_master_wait_thread(struct v3dv_queue *queue,
|
|||
mtx_lock(&queue->mutex);
|
||||
if (pthread_create(&wait_info->master_wait_thread, NULL,
|
||||
master_wait_thread_func, wait_info)) {
|
||||
result = vk_error(queue->device->instance, VK_ERROR_DEVICE_LOST);
|
||||
result = vk_error(queue, VK_ERROR_DEVICE_LOST);
|
||||
goto done;
|
||||
}
|
||||
|
||||
|
@ -1067,12 +1067,12 @@ v3dv_CreateSemaphore(VkDevice _device,
|
|||
vk_object_zalloc(&device->vk, pAllocator, sizeof(struct v3dv_semaphore),
|
||||
VK_OBJECT_TYPE_SEMAPHORE);
|
||||
if (sem == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
int ret = drmSyncobjCreate(device->pdevice->render_fd, 0, &sem->sync);
|
||||
if (ret) {
|
||||
vk_object_free(&device->vk, pAllocator, sem);
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
|
||||
*pSemaphore = v3dv_semaphore_to_handle(sem);
|
||||
|
@ -1158,23 +1158,23 @@ v3dv_ImportSemaphoreFdKHR(
|
|||
*/
|
||||
unsigned flags = fd == -1 ? DRM_SYNCOBJ_CREATE_SIGNALED : 0;
|
||||
if (drmSyncobjCreate(render_fd, flags, &new_sync))
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
if (fd != -1) {
|
||||
if (drmSyncobjImportSyncFile(render_fd, new_sync, fd)) {
|
||||
drmSyncobjDestroy(render_fd, new_sync);
|
||||
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
return vk_error(device, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT: {
|
||||
if (drmSyncobjFDToHandle(render_fd, fd, &new_sync))
|
||||
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
return vk_error(device, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
return vk_error(device, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
}
|
||||
|
||||
destroy_syncobj(render_fd, &sem->temp_sync);
|
||||
|
@ -1216,12 +1216,12 @@ v3dv_GetSemaphoreFdKHR(VkDevice _device,
|
|||
case VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT: {
|
||||
drmSyncobjExportSyncFile(render_fd, sem->sync, pFd);
|
||||
if (*pFd == -1)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
break;
|
||||
case VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT:
|
||||
drmSyncobjHandleToFD(render_fd, sem->sync, pFd);
|
||||
if (*pFd == -1)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1262,7 +1262,7 @@ v3dv_CreateFence(VkDevice _device,
|
|||
vk_object_zalloc(&device->vk, pAllocator, sizeof(struct v3dv_fence),
|
||||
VK_OBJECT_TYPE_FENCE);
|
||||
if (fence == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
unsigned flags = 0;
|
||||
if (pCreateInfo->flags & VK_FENCE_CREATE_SIGNALED_BIT)
|
||||
|
@ -1270,7 +1270,7 @@ v3dv_CreateFence(VkDevice _device,
|
|||
int ret = drmSyncobjCreate(device->pdevice->render_fd, flags, &fence->sync);
|
||||
if (ret) {
|
||||
vk_object_free(&device->vk, pAllocator, fence);
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
}
|
||||
|
||||
*pFence = v3dv_fence_to_handle(fence);
|
||||
|
@ -1357,23 +1357,23 @@ v3dv_ImportFenceFdKHR(VkDevice _device,
|
|||
*/
|
||||
unsigned flags = fd == -1 ? DRM_SYNCOBJ_CREATE_SIGNALED : 0;
|
||||
if (drmSyncobjCreate(render_fd, flags, &new_sync))
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
if (fd != -1) {
|
||||
if (drmSyncobjImportSyncFile(render_fd, new_sync, fd)) {
|
||||
drmSyncobjDestroy(render_fd, new_sync);
|
||||
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
return vk_error(device, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT: {
|
||||
if (drmSyncobjFDToHandle(render_fd, fd, &new_sync))
|
||||
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
return vk_error(device, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return vk_error(device->instance, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
return vk_error(device, VK_ERROR_INVALID_EXTERNAL_HANDLE);
|
||||
}
|
||||
|
||||
destroy_syncobj(render_fd, &fence->temp_sync);
|
||||
|
@ -1427,7 +1427,7 @@ v3dv_GetFenceStatus(VkDevice _device, VkFence _fence)
|
|||
if (ret == -ETIME)
|
||||
return VK_NOT_READY;
|
||||
else if (ret)
|
||||
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1447,12 +1447,12 @@ v3dv_GetFenceFdKHR(VkDevice _device,
|
|||
case VK_EXTERNAL_FENCE_HANDLE_TYPE_SYNC_FD_BIT: {
|
||||
drmSyncobjExportSyncFile(render_fd, fence->sync, pFd);
|
||||
if (*pFd == -1)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
break;
|
||||
case VK_EXTERNAL_FENCE_HANDLE_TYPE_OPAQUE_FD_BIT:
|
||||
drmSyncobjHandleToFD(render_fd, fence->sync, pFd);
|
||||
if (*pFd == -1)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1471,7 +1471,7 @@ v3dv_ResetFences(VkDevice _device, uint32_t fenceCount, const VkFence *pFences)
|
|||
sizeof(*syncobjs) * fenceCount, 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
if (!syncobjs)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
int render_fd = device->pdevice->render_fd;
|
||||
uint32_t reset_count = 0;
|
||||
|
@ -1501,7 +1501,7 @@ v3dv_ResetFences(VkDevice _device, uint32_t fenceCount, const VkFence *pFences)
|
|||
vk_free(&device->vk.alloc, syncobjs);
|
||||
|
||||
if (ret)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1520,7 +1520,7 @@ v3dv_WaitForFences(VkDevice _device,
|
|||
sizeof(*syncobjs) * fenceCount, 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
|
||||
if (!syncobjs)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
for (uint32_t i = 0; i < fenceCount; i++) {
|
||||
struct v3dv_fence *fence = v3dv_fence_from_handle(pFences[i]);
|
||||
|
@ -1542,7 +1542,7 @@ v3dv_WaitForFences(VkDevice _device,
|
|||
if (ret == -ETIME)
|
||||
return VK_TIMEOUT;
|
||||
else if (ret)
|
||||
return vk_error(device->instance, VK_ERROR_DEVICE_LOST);
|
||||
return vk_error(device, VK_ERROR_DEVICE_LOST);
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1553,5 +1553,5 @@ v3dv_QueueBindSparse(VkQueue _queue,
|
|||
VkFence fence)
|
||||
{
|
||||
V3DV_FROM_HANDLE(v3dv_queue, queue, _queue);
|
||||
return vk_error(queue->device->instance, VK_ERROR_FEATURE_NOT_PRESENT);
|
||||
return vk_error(queue, VK_ERROR_FEATURE_NOT_PRESENT);
|
||||
}
|
||||
|
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* Copyright © 2019 Raspberry Pi
|
||||
*
|
||||
* based in part on anv driver which is:
|
||||
* Copyright © 2015 Intel Corporation
|
||||
*
|
||||
* based in part on radv driver which is:
|
||||
* Copyright © 2016 Red Hat.
|
||||
* Copyright © 2016 Bas Nieuwenhuizen
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the "Software"),
|
||||
* to deal in the Software without restriction, including without limitation
|
||||
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
* and/or sell copies of the Software, and to permit persons to whom the
|
||||
* Software is furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice (including the next
|
||||
* paragraph) shall be included in all copies or substantial portions of the
|
||||
* Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
* IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "vk_enum_to_str.h"
|
||||
#include "v3dv_private.h"
|
||||
|
||||
VkResult
|
||||
__vk_errorf(struct v3dv_instance *instance, VkResult error, const char *file,
|
||||
int line, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
char buffer[256];
|
||||
|
||||
#ifndef DEBUG
|
||||
return error;
|
||||
#endif
|
||||
|
||||
const char *error_str = vk_Result_to_str(error);
|
||||
|
||||
if (format) {
|
||||
va_start(ap, format);
|
||||
vsnprintf(buffer, sizeof(buffer), format, ap);
|
||||
va_end(ap);
|
||||
|
||||
fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);
|
||||
} else {
|
||||
fprintf(stderr, "%s:%d: %s\n", file, line, error_str);
|
||||
}
|
||||
|
||||
return error;
|
||||
}
|
Loading…
Reference in New Issue