MAP_SHARED | MAP_POPULATE, pool->fd,
BLOCK_POOL_MEMFD_CENTER - center_bo_offset);
if (map == MAP_FAILED)
- return vk_errorf(VK_ERROR_MEMORY_MAP_FAILED, "mmap failed: %m");
+ return vk_errorf(pool->device->instance, pool->device,
+ VK_ERROR_MEMORY_MAP_FAILED, "mmap failed: %m");
gem_handle = anv_gem_userptr(pool->device, map, size);
if (gem_handle == 0) {
munmap(map, size);
- return vk_errorf(VK_ERROR_TOO_MANY_OBJECTS, "userptr failed: %m");
+ return vk_errorf(pool->device->instance, pool->device,
+ VK_ERROR_TOO_MANY_OBJECTS, "userptr failed: %m");
}
cleanup->map = map;
if (pthread_mutex_init(&cache->mutex, NULL)) {
_mesa_hash_table_destroy(cache->bo_map, NULL);
- return vk_errorf(VK_ERROR_OUT_OF_HOST_MEMORY,
+ return vk_errorf(NULL, NULL, VK_ERROR_OUT_OF_HOST_MEMORY,
"pthread_mutex_init failed: %m");
}
"Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");
if (anv_gem_get_aperture(fd, >t_size) == -1) {
- return vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ return vk_errorf(NULL, NULL, VK_ERROR_INITIALIZATION_FAILED,
"failed to get aperture size: %m");
}
}
{
const struct build_id_note *note = build_id_find_nhdr("libvulkan_intel.so");
if (!note) {
- return vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ return vk_errorf(device->instance, device,
+ 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(VK_ERROR_INITIALIZATION_FAILED,
+ return vk_errorf(device->instance, device,
+ VK_ERROR_INITIALIZATION_FAILED,
"build-id too short. It needs to be a SHA");
}
/* Broadwell, Cherryview, Skylake, Broxton, Kabylake is as fully
* supported as anything */
} else {
- result = vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
+ result = vk_errorf(device->instance, device,
+ 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(VK_ERROR_INITIALIZATION_FAILED,
+ result = vk_errorf(device->instance, device,
+ 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(VK_ERROR_INITIALIZATION_FAILED,
+ result = vk_errorf(device->instance, device,
+ VK_ERROR_INITIALIZATION_FAILED,
"kernel missing gem wait");
goto fail;
}
if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXECBUF2)) {
- result = vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
+ result = vk_errorf(device->instance, device,
+ 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(VK_ERROR_INITIALIZATION_FAILED,
+ result = vk_errorf(device->instance, device,
+ VK_ERROR_INITIALIZATION_FAILED,
"kernel missing wc mmap");
goto fail;
}
"incompatible driver version",
ctor_cb->pUserData);
- return vk_errorf(VK_ERROR_INCOMPATIBLE_DRIVER,
+ return vk_errorf(NULL, NULL, VK_ERROR_INCOMPATIBLE_DRIVER,
"Client requested version %d.%d.%d",
VK_VERSION_MAJOR(client_version),
VK_VERSION_MINOR(client_version),
if (ret == -1) {
/* We don't know the real error. */
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST, "get_reset_stats failed: %m");
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
+ "get_reset_stats failed: %m");
}
if (active) {
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST,
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"GPU hung on one of our command buffers");
} else if (pending) {
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST,
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"GPU hung with commands in-flight");
}
} else if (ret == -1) {
/* We don't know the real error. */
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST, "gem wait failed: %m");
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
+ "gem wait failed: %m");
}
/* Query for device status after the busy call. If the BO we're checking
} else if (ret == -1) {
/* We don't know the real error. */
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST, "gem wait failed: %m");
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
+ "gem wait failed: %m");
}
/* Query for device status after the wait. If the BO we're waiting on got
* vkGetPhysicalDeviceImageFormatProperties2KHR returns
* VK_ERROR_FORMAT_NOT_SUPPORTED.
*/
- result = vk_errorf(VK_ERROR_FORMAT_NOT_SUPPORTED,
+ result = vk_errorf(physical_device->instance, physical_device,
+ VK_ERROR_FORMAT_NOT_SUPPORTED,
"unsupported VkExternalMemoryTypeFlagBitsKHR 0x%x",
external_info->handleType);
goto fail;
* propagating errors. Might be useful to plug in a stack trace here.
*/
-VkResult __vk_errorf(VkResult error, const char *file, int line, const char *format, ...);
+VkResult __vk_errorf(struct anv_instance *instance, const void *object,
+ VkDebugReportObjectTypeEXT type, VkResult error,
+ const char *file, int line, const char *format, ...);
#ifdef DEBUG
-#define vk_error(error) __vk_errorf(error, __FILE__, __LINE__, NULL);
-#define vk_errorf(error, format, ...) __vk_errorf(error, __FILE__, __LINE__, format, ## __VA_ARGS__);
+#define vk_error(error) __vk_errorf(NULL, NULL,\
+ VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,\
+ error, __FILE__, __LINE__, NULL);
+#define vk_errorf(instance, obj, error, format, ...)\
+ __vk_errorf(instance, obj, REPORT_OBJECT_TYPE(obj), error,\
+ __FILE__, __LINE__, format, ## __VA_ARGS__);
#define anv_debug(format, ...) fprintf(stderr, "debug: " format, ##__VA_ARGS__)
#else
#define vk_error(error) error
if (ret != 0) {
/* We don't know the real error. */
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST, "execbuf2 failed: %m");
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
+ "execbuf2 failed: %m");
}
struct drm_i915_gem_exec_object2 *objects =
* VK_ERROR_DEVICE_LOST to ensure that clients do not attempt to
* submit the same job again to this device.
*/
- result = vk_errorf(VK_ERROR_DEVICE_LOST, "vkQueueSubmit() failed");
+ result = vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
+ "vkQueueSubmit() failed");
device->lost = true;
}
} else {
/* We don't know the real error. */
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST,
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"drm_syncobj_wait failed: %m");
}
} else {
} else {
/* We don't know the real error. */
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST,
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
"drm_syncobj_wait failed: %m");
}
} else {
if (anv_gem_syncobj_import_sync_file(device, new_impl.syncobj, fd)) {
anv_gem_syncobj_destroy(device, new_impl.syncobj);
- return vk_errorf(VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
+ return vk_errorf(device->instance, NULL,
+ VK_ERROR_INVALID_EXTERNAL_HANDLE_KHR,
"syncobj sync file import failed: %m");
}
break;
}
VkResult
-__vk_errorf(VkResult error, const char *file, int line, const char *format, ...)
+__vk_errorf(struct anv_instance *instance, const void *object,
+ VkDebugReportObjectTypeEXT type, VkResult error,
+ const char *file, int line, const char *format, ...)
{
va_list ap;
char buffer[256];
+ char report[256];
const char *error_str = vk_Result_to_str(error);
vsnprintf(buffer, sizeof(buffer), format, ap);
va_end(ap);
- fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);
+ snprintf(report, sizeof(report), "%s:%d: %s (%s)", file, line, buffer,
+ error_str);
} else {
- fprintf(stderr, "%s:%d: %s\n", file, line, error_str);
+ snprintf(report, sizeof(report), "%s:%d: %s", file, line, error_str);
}
+ anv_debug_report(instance,
+ VK_DEBUG_REPORT_ERROR_BIT_EXT,
+ type,
+ (uint64_t) (uintptr_t) object,
+ line,
+ 0,
+ "anv",
+ report);
+
+ fprintf(stderr, "%s\n", report);
+
if (error == VK_ERROR_DEVICE_LOST &&
env_var_as_boolean("ANV_ABORT_ON_DEVICE_LOSS", false))
abort();
surface->isl.row_pitch, I915_TILING_X);
if (ret) {
/* FINISHME: Choose a better error. */
- result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ result = vk_errorf(device->instance, device,
+ VK_ERROR_OUT_OF_DEVICE_MEMORY,
"set_tiling failed: %m");
goto fail_alloc_memory;
}
int fd = anv_gem_handle_to_fd(device, memory->bo->gem_handle);
if (fd == -1) {
/* FINISHME: Choose a better error. */
- result = vk_errorf(VK_ERROR_OUT_OF_DEVICE_MEMORY,
+ result = vk_errorf(device->instance, device,
+ VK_ERROR_OUT_OF_DEVICE_MEMORY,
"handle_to_fd failed: %m");
goto fail_alloc_memory;
}
const char *function)
{
if (device->instance->physicalDevice.cmd_parser_version < required_version) {
- return vk_errorf(VK_ERROR_FEATURE_NOT_PRESENT,
+ return vk_errorf(device->instance, device->instance,
+ VK_ERROR_FEATURE_NOT_PRESENT,
"cmd parser version %d is required for %s",
required_version, function);
} else {
} else if (ret == -1) {
/* We don't know the real error. */
device->lost = true;
- return vk_errorf(VK_ERROR_DEVICE_LOST, "gem wait failed: %m");
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,
+ "gem wait failed: %m");
} else {
assert(ret == 0);
/* The BO is no longer busy. */