map = mmap(NULL, size, PROT_READ | PROT_WRITE,
MAP_SHARED | MAP_POPULATE, table->fd, 0);
if (map == MAP_FAILED) {
- return vk_errorf(table->device->instance, table->device,
+ return vk_errorf(table->device, table->device,
VK_ERROR_OUT_OF_HOST_MEMORY, "mmap failed: %m");
}
MAP_SHARED | MAP_POPULATE, pool->fd,
BLOCK_POOL_MEMFD_CENTER - center_bo_offset);
if (map == MAP_FAILED)
- return vk_errorf(pool->device->instance, pool->device,
+ return vk_errorf(pool->device, pool->device,
VK_ERROR_MEMORY_MAP_FAILED, "mmap failed: %m");
struct anv_bo *new_bo;
if (new_bo.map)
anv_gem_munmap(new_bo.map, size);
anv_gem_close(device, new_bo.gem_handle);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ return vk_errorf(device, NULL, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"failed to allocate virtual address for BO");
}
}
assert(bo->gem_handle == gem_handle);
if (bo_flags != bo->flags) {
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"same host pointer imported two different ways");
}
if (bo->has_client_visible_address !=
((alloc_flags & ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS) != 0)) {
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"The same BO was imported with and without buffer "
"device address");
}
if (client_address && client_address != gen_48b_address(bo->offset)) {
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"The same BO was imported at two different "
"addresses");
}
if (!anv_vma_alloc(device, &new_bo, client_address)) {
anv_gem_close(device, new_bo.gem_handle);
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ return vk_errorf(device, NULL, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"failed to allocate virtual address for BO");
}
if ((bo->flags & EXEC_OBJECT_PINNED) !=
(bo_flags & EXEC_OBJECT_PINNED)) {
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"The same BO was imported two different ways");
}
(bo->flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS) !=
(bo_flags & EXEC_OBJECT_SUPPORTS_48B_ADDRESS)) {
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"The same BO was imported on two different heaps");
}
if (bo->has_client_visible_address !=
((alloc_flags & ANV_BO_ALLOC_CLIENT_VISIBLE_ADDRESS) != 0)) {
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"The same BO was imported with and without buffer "
"device address");
}
if (client_address && client_address != gen_48b_address(bo->offset)) {
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"The same BO was imported at two different "
"addresses");
}
if (!anv_vma_alloc(device, &new_bo, client_address)) {
anv_gem_close(device, new_bo.gem_handle);
pthread_mutex_unlock(&cache->mutex);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ return vk_errorf(device, NULL, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"failed to allocate virtual address for BO");
}
};
if (gralloc_info->handle->numFds != 1) {
- return vk_errorf(device->instance, device,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"VkNativeBufferANDROID::handle::numFds is %d, "
"expected 1", gralloc_info->handle->numFds);
}
0 /* client_address */,
&bo);
if (result != VK_SUCCESS) {
- return vk_errorf(device->instance, device, result,
+ return vk_errorf(device, device, result,
"failed to import dma-buf from VkNativeBufferANDROID");
}
anv_info.isl_tiling_flags = ISL_TILING_Y0_BIT;
break;
case -1:
- result = vk_errorf(device->instance, device,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ result = vk_errorf(device, device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"DRM_IOCTL_I915_GEM_GET_TILING failed for "
"VkNativeBufferANDROID");
goto fail_tiling;
default:
- result = vk_errorf(device->instance, device,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ result = vk_errorf(device, device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"DRM_IOCTL_I915_GEM_GET_TILING returned unknown "
"tiling %d for VkNativeBufferANDROID", i915_tiling);
goto fail_tiling;
goto fail_create;
if (bo->size < image->size) {
- result = vk_errorf(device->instance, device,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ result = vk_errorf(device, device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"dma-buf from VkNativeBufferANDROID is too small for "
"VkImage: %"PRIu64"B < %"PRIu64"B",
bo->size, image->size);
result = anv_GetPhysicalDeviceImageFormatProperties2(phys_dev_h,
&image_format_info, &image_format_props);
if (result != VK_SUCCESS) {
- return vk_errorf(device->instance, device, result,
+ return vk_errorf(device, device, result,
"anv_GetPhysicalDeviceImageFormatProperties2 failed "
"inside %s", __func__);
}
* gralloc swapchains.
*/
if (imageUsage != 0) {
- return vk_errorf(device->instance, device, VK_ERROR_FORMAT_NOT_SUPPORTED,
+ return vk_errorf(device, device, VK_ERROR_FORMAT_NOT_SUPPORTED,
"unsupported VkImageUsageFlags(0x%x) for gralloc "
"swapchain", imageUsage);
}
* VkFence.
*/
if (sync_wait(nativeFenceFd, /*timeout*/ -1) < 0) {
- result = vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
+ result = vk_errorf(device, device, VK_ERROR_DEVICE_LOST,
"%s: failed to wait on nativeFenceFd=%d",
__func__, nativeFenceFd);
}
result = anv_QueueSubmit(anv_queue_to_handle(&device->queue), 1,
&submit, fence_h);
if (result != VK_SUCCESS) {
- return vk_errorf(device->instance, device, result,
+ return vk_errorf(device, device, result,
"anv_QueueSubmit failed inside %s", __func__);
}
}
"Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");
if (anv_gem_get_aperture(fd, &device->gtt_size) == -1) {
- return vk_errorf(NULL, NULL, VK_ERROR_INITIALIZATION_FAILED,
- "failed to get aperture size: %m");
+ return vk_errorfi(device->instance, NULL,
+ VK_ERROR_INITIALIZATION_FAILED,
+ "failed to get aperture size: %m");
}
}
const struct build_id_note *note =
build_id_find_nhdr_for_addr(anv_physical_device_init_uuids);
if (!note) {
- return vk_errorf(device->instance, device,
- VK_ERROR_INITIALIZATION_FAILED,
- "Failed to find build-id");
+ return vk_errorfi(device->instance, NULL,
+ 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(device->instance, device,
- VK_ERROR_INITIALIZATION_FAILED,
- "build-id too short. It needs to be a SHA");
+ return vk_errorfi(device->instance, NULL,
+ VK_ERROR_INITIALIZATION_FAILED,
+ "build-id too short. It needs to be a SHA");
}
memcpy(device->driver_build_sha1, build_id_data(note), 20);
} else if (device->info.gen == 12) {
intel_logw("Vulkan is not yet fully supported on gen12");
} else {
- result = vk_errorf(device->instance, device,
- VK_ERROR_INCOMPATIBLE_DRIVER,
- "Vulkan not yet supported on %s", device->name);
+ result = vk_errorfi(instance, NULL, VK_ERROR_INCOMPATIBLE_DRIVER,
+ "Vulkan not yet supported on %s", device->name);
goto fail;
}
device->cmd_parser_version =
anv_gem_get_param(fd, I915_PARAM_CMD_PARSER_VERSION);
if (device->cmd_parser_version == -1) {
- result = vk_errorf(device->instance, device,
- VK_ERROR_INITIALIZATION_FAILED,
- "failed to get command parser version");
+ result = vk_errorfi(device->instance, NULL,
+ VK_ERROR_INITIALIZATION_FAILED,
+ "failed to get command parser version");
goto fail;
}
}
if (!anv_gem_get_param(fd, I915_PARAM_HAS_WAIT_TIMEOUT)) {
- result = vk_errorf(device->instance, device,
- VK_ERROR_INITIALIZATION_FAILED,
- "kernel missing gem wait");
+ result = vk_errorfi(device->instance, NULL,
+ VK_ERROR_INITIALIZATION_FAILED,
+ "kernel missing gem wait");
goto fail;
}
if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXECBUF2)) {
- result = vk_errorf(device->instance, device,
- VK_ERROR_INITIALIZATION_FAILED,
- "kernel missing execbuf2");
+ result = vk_errorfi(device->instance, NULL,
+ VK_ERROR_INITIALIZATION_FAILED,
+ "kernel missing execbuf2");
goto fail;
}
if (!device->info.has_llc &&
anv_gem_get_param(fd, I915_PARAM_MMAP_VERSION) < 1) {
- result = vk_errorf(device->instance, device,
- VK_ERROR_INITIALIZATION_FAILED,
- "kernel missing wc mmap");
+ result = vk_errorfi(device->instance, NULL,
+ VK_ERROR_INITIALIZATION_FAILED,
+ "kernel missing wc mmap");
goto fail;
}
p_atomic_inc(&device->_lost);
va_start(ap, msg);
- err = __vk_errorv(device->instance, device,
+ err = __vk_errorv(device->physical->instance, device,
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
VK_ERROR_DEVICE_LOST, file, line, msg, ap);
va_end(ap);
p_atomic_inc(&queue->device->_lost);
va_start(ap, msg);
- err = __vk_errorv(queue->device->instance, queue->device,
+ err = __vk_errorv(queue->device->physical->instance, queue->device,
VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
VK_ERROR_DEVICE_LOST, file, line, msg, ap);
va_end(ap);
* this sort of attack but only if it can trust the buffer size.
*/
if (mem->bo->size < aligned_alloc_size) {
- result = vk_errorf(device->instance, device,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ result = vk_errorf(device, device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"aligned allocationSize too large for "
"VK_EXTERNAL_MEMORY_HANDLE_TYPE_OPAQUE_FD_BIT: "
"%"PRIu64"B > %"PRIu64"B",
i915_tiling);
if (ret) {
anv_device_release_bo(device, mem->bo);
- result = vk_errorf(device->instance, NULL,
- VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ result = vk_errorf(device, device, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"failed to set BO tiling: %m");
goto fail;
}
if (mem_heap_used > mem_heap->size) {
p_atomic_add(&mem_heap->used, -mem->bo->size);
anv_device_release_bo(device, mem->bo);
- result = vk_errorf(device->instance, NULL,
- VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ result = vk_errorf(device, device, VK_ERROR_OUT_OF_DEVICE_MEMORY,
"Out of heap memory");
goto fail;
}
* vkGetPhysicalDeviceImageFormatProperties2 returns
* VK_ERROR_FORMAT_NOT_SUPPORTED.
*/
- result = vk_errorf(physical_device->instance, physical_device,
- VK_ERROR_FORMAT_NOT_SUPPORTED,
- "unsupported VkExternalMemoryTypeFlagBits 0x%x",
- external_info->handleType);
+ result = vk_errorfi(physical_device->instance, physical_device,
+ VK_ERROR_FORMAT_NOT_SUPPORTED,
+ "unsupported VkExternalMemoryTypeFlagBits 0x%x",
+ external_info->handleType);
goto fail;
}
}
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,
+ result = vk_errorf(device, device, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"dma-buf too small for image in "
"vkCreateDmaBufImageINTEL: %"PRIu64"B < %"PRIu64"B",
mem->bo->size, aligned_image_size);
#define vk_error(error) __vk_errorf(NULL, NULL,\
VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,\
error, __FILE__, __LINE__, NULL)
-#define vk_errorv(instance, obj, error, format, args)\
- __vk_errorv(instance, obj, REPORT_OBJECT_TYPE(obj), error,\
- __FILE__, __LINE__, format, args)
-#define vk_errorf(instance, obj, error, format, ...)\
+#define vk_errorfi(instance, obj, error, format, ...)\
__vk_errorf(instance, obj, REPORT_OBJECT_TYPE(obj), error,\
__FILE__, __LINE__, format, ## __VA_ARGS__)
+#define vk_errorf(device, obj, error, format, ...)\
+ vk_errorfi(anv_device_instance_or_null(device),\
+ obj, error, format, ## __VA_ARGS__)
#else
#define vk_error(error) error
-#define vk_errorf(instance, obj, error, format, ...) error
+#define vk_errorfi(instance, obj, error, format, ...) error
+#define vk_errorf(device, obj, error, format, ...) error
#endif
/**
struct gen_aux_map_context *aux_map_ctx;
};
+static inline struct anv_instance *
+anv_device_instance_or_null(const struct anv_device *device)
+{
+ return device ? device->physical->instance : NULL;
+}
+
static inline struct anv_state_pool *
anv_binding_table_pool(struct anv_device *device)
{
if (anv_gem_syncobj_import_sync_file(device, new_impl.syncobj, fd)) {
anv_gem_syncobj_destroy(device, new_impl.syncobj);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"syncobj sync file import failed: %m");
}
break;
return vk_error(VK_ERROR_OUT_OF_HOST_MEMORY);
if (anv_gem_syncobj_import_sync_file(device, new_impl.syncobj, fd)) {
anv_gem_syncobj_destroy(device, new_impl.syncobj);
- return vk_errorf(device->instance, NULL,
- VK_ERROR_INVALID_EXTERNAL_HANDLE,
+ return vk_errorf(device, NULL, VK_ERROR_INVALID_EXTERNAL_HANDLE,
"syncobj sync file import failed: %m");
}
/* Ownership of the FD is transfered to Anv. Since we don't need it
const char *function)
{
if (device->physical->cmd_parser_version < required_version) {
- return vk_errorf(device->instance, device->instance,
+ return vk_errorf(device, device->physical,
VK_ERROR_FEATURE_NOT_PRESENT,
"cmd parser version %d is required for %s",
required_version, function);