<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Sun, Sep 10, 2017 at 10:29 PM, Tapani Pälli <span dir="ltr"><<a href="mailto:tapani.palli@intel.com" target="_blank">tapani.palli@intel.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Signed-off-by: Tapani Pälli <<a href="mailto:tapani.palli@intel.com">tapani.palli@intel.com</a>><br>
---<br>
src/intel/vulkan/anv_<wbr>allocator.c | 8 +++++---<br>
src/intel/vulkan/anv_device.c | 38 ++++++++++++++++++++++++------<wbr>--------<br>
src/intel/vulkan/anv_formats.c | 3 ++-<br>
src/intel/vulkan/anv_private.h | 12 +++++++++---<br>
src/intel/vulkan/anv_queue.c | 13 ++++++++-----<br>
src/intel/vulkan/anv_util.c | 20 +++++++++++++++++---<br>
src/intel/vulkan/anv_wsi.c | 6 ++++--<br>
src/intel/vulkan/genX_cmd_<wbr>buffer.c | 3 ++-<br>
src/intel/vulkan/genX_query.c | 3 ++-<br>
9 files changed, 73 insertions(+), 33 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_<wbr>allocator.c b/src/intel/vulkan/anv_<wbr>allocator.c<br>
index 708b32b345..be750adeb5 100644<br>
--- a/src/intel/vulkan/anv_<wbr>allocator.c<br>
+++ b/src/intel/vulkan/anv_<wbr>allocator.c<br>
@@ -361,12 +361,14 @@ anv_block_pool_expand_range(<wbr>struct anv_block_pool *pool,<br>
MAP_SHARED | MAP_POPULATE, pool->fd,<br>
BLOCK_POOL_MEMFD_CENTER - center_bo_offset);<br>
if (map == MAP_FAILED)<br>
- return vk_errorf(VK_ERROR_MEMORY_MAP_<wbr>FAILED, "mmap failed: %m");<br>
+ return vk_errorf(pool->device-><wbr>instance, pool->device,<br>
+ VK_ERROR_MEMORY_MAP_FAILED, "mmap failed: %m");<br>
<br>
gem_handle = anv_gem_userptr(pool->device, map, size);<br>
if (gem_handle == 0) {<br>
munmap(map, size);<br>
- return vk_errorf(VK_ERROR_TOO_MANY_<wbr>OBJECTS, "userptr failed: %m");<br>
+ return vk_errorf(pool->device-><wbr>instance, pool->device,<br>
+ VK_ERROR_TOO_MANY_OBJECTS, "userptr failed: %m");<br>
}<br>
<br>
cleanup->map = map;<br>
@@ -1190,7 +1192,7 @@ anv_bo_cache_init(struct anv_bo_cache *cache)<br>
<br>
if (pthread_mutex_init(&cache-><wbr>mutex, NULL)) {<br>
_mesa_hash_table_destroy(<wbr>cache->bo_map, NULL);<br>
- return vk_errorf(VK_ERROR_OUT_OF_<wbr>HOST_MEMORY,<br>
+ return vk_errorf(NULL, NULL, VK_ERROR_OUT_OF_HOST_MEMORY,<br>
"pthread_mutex_init failed: %m");<br>
}<br>
<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index f246e0ee6b..32a6e99fa2 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -68,7 +68,7 @@ anv_compute_heap_size(int fd, uint64_t *heap_size)<br>
"Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");<br>
<br>
if (anv_gem_get_aperture(fd, >t_size) == -1) {<br>
- return vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
+ return vk_errorf(NULL, NULL, VK_ERROR_INITIALIZATION_<wbr>FAILED,<br>
"failed to get aperture size: %m");<br>
}<br>
}<br>
@@ -210,13 +210,15 @@ anv_physical_device_init_<wbr>uuids(struct anv_physical_device *device)<br>
{<br>
const struct build_id_note *note = build_id_find_nhdr("libvulkan_<wbr>intel.so");<br>
if (!note) {<br>
- return vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
+ return vk_errorf(device->instance, device,<br>
+ VK_ERROR_INITIALIZATION_<wbr>FAILED,<br>
"Failed to find build-id");<br>
}<br>
<br>
unsigned build_id_len = build_id_length(note);<br>
if (build_id_len < 20) {<br>
- return vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
+ return vk_errorf(device->instance, device,<br>
+ VK_ERROR_INITIALIZATION_<wbr>FAILED,<br>
"build-id too short. It needs to be a SHA");<br>
}<br>
<br>
@@ -298,7 +300,8 @@ anv_physical_device_init(<wbr>struct anv_physical_device *device,<br>
/* Broadwell, Cherryview, Skylake, Broxton, Kabylake is as fully<br>
* supported as anything */<br>
} else {<br>
- result = vk_errorf(VK_ERROR_<wbr>INCOMPATIBLE_DRIVER,<br>
+ result = vk_errorf(device->instance, device,<br>
+ VK_ERROR_INCOMPATIBLE_DRIVER,<br>
"Vulkan not yet supported on %s", device->name);<br>
goto fail;<br>
}<br>
@@ -308,27 +311,31 @@ anv_physical_device_init(<wbr>struct anv_physical_device *device,<br>
device->cmd_parser_version =<br>
anv_gem_get_param(fd, I915_PARAM_CMD_PARSER_VERSION)<wbr>;<br>
if (device->cmd_parser_version == -1) {<br>
- result = vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
+ result = vk_errorf(device->instance, device,<br>
+ VK_ERROR_INITIALIZATION_<wbr>FAILED,<br>
"failed to get command parser version");<br>
goto fail;<br>
}<br>
}<br>
<br>
if (!anv_gem_get_param(fd, I915_PARAM_HAS_WAIT_TIMEOUT)) {<br>
- result = vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
+ result = vk_errorf(device->instance, device,<br>
+ VK_ERROR_INITIALIZATION_<wbr>FAILED,<br>
"kernel missing gem wait");<br>
goto fail;<br>
}<br>
<br>
if (!anv_gem_get_param(fd, I915_PARAM_HAS_EXECBUF2)) {<br>
- result = vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
+ result = vk_errorf(device->instance, device,<br>
+ VK_ERROR_INITIALIZATION_<wbr>FAILED,<br>
"kernel missing execbuf2");<br>
goto fail;<br>
}<br>
<br>
if (!device->info.has_llc &&<br>
anv_gem_get_param(fd, I915_PARAM_MMAP_VERSION) < 1) {<br>
- result = vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
+ result = vk_errorf(device->instance, device,<br>
+ VK_ERROR_INITIALIZATION_<wbr>FAILED,<br>
"kernel missing wc mmap");<br>
goto fail;<br>
}<br>
@@ -475,7 +482,7 @@ VkResult anv_CreateInstance(<br>
"incompatible driver version",<br>
ctor_cb->pUserData);<br>
<br>
- return vk_errorf(VK_ERROR_<wbr>INCOMPATIBLE_DRIVER,<br>
+ return vk_errorf(NULL, NULL, VK_ERROR_INCOMPATIBLE_DRIVER,<br>
"Client requested version %d.%d.%d",<br>
VK_VERSION_MAJOR(client_<wbr>version),<br>
VK_VERSION_MINOR(client_<wbr>version),<br>
@@ -1362,16 +1369,17 @@ anv_device_query_status(struct anv_device *device)<br>
if (ret == -1) {<br>
/* We don't know the real error. */<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "get_reset_stats failed: %m");<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
+ "get_reset_stats failed: %m");<br>
}<br>
<br>
if (active) {<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST,<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
"GPU hung on one of our command buffers");<br>
} else if (pending) {<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST,<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
"GPU hung with commands in-flight");<br>
}<br>
<br>
@@ -1391,7 +1399,8 @@ anv_device_bo_busy(struct anv_device *device, struct anv_bo *bo)<br>
} else if (ret == -1) {<br>
/* We don't know the real error. */<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "gem wait failed: %m");<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
+ "gem wait failed: %m");<br>
}<br>
<br>
/* Query for device status after the busy call. If the BO we're checking<br>
@@ -1413,7 +1422,8 @@ anv_device_wait(struct anv_device *device, struct anv_bo *bo,<br>
} else if (ret == -1) {<br>
/* We don't know the real error. */<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "gem wait failed: %m");<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
+ "gem wait failed: %m");<br>
}<br>
<br>
/* Query for device status after the wait. If the BO we're waiting on got<br>
diff --git a/src/intel/vulkan/anv_<wbr>formats.c b/src/intel/vulkan/anv_<wbr>formats.c<br>
index eead1aa790..47acc56fd0 100644<br>
--- a/src/intel/vulkan/anv_<wbr>formats.c<br>
+++ b/src/intel/vulkan/anv_<wbr>formats.c<br>
@@ -730,7 +730,8 @@ VkResult anv_<wbr>GetPhysicalDeviceImageFormatPr<wbr>operties2KHR(<br>
* vkGetPhysicalDeviceImageFormat<wbr>Properties2KHR returns<br>
* VK_ERROR_FORMAT_NOT_SUPPORTED.<br>
*/<br>
- result = vk_errorf(VK_ERROR_FORMAT_NOT_<wbr>SUPPORTED,<br>
+ result = vk_errorf(physical_device-><wbr>instance, physical_device,<br>
+ VK_ERROR_FORMAT_NOT_SUPPORTED,<br>
"unsupported VkExternalMemoryTypeFlagBitsKH<wbr>R 0x%x",<br>
external_info->handleType);<br>
goto fail;<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index 141712232d..1b48162199 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -303,11 +303,17 @@ vk_to_isl_color(<wbr>VkClearColorValue color)<br>
* propagating errors. Might be useful to plug in a stack trace here.<br>
*/<br>
<br>
-VkResult __vk_errorf(VkResult error, const char *file, int line, const char *format, ...);<br>
+VkResult __vk_errorf(struct anv_instance *instance, const void *object,<br>
+ VkDebugReportObjectTypeEXT type, VkResult error,<br>
+ const char *file, int line, const char *format, ...);<br>
<br>
#ifdef DEBUG<br>
-#define vk_error(error) __vk_errorf(error, __FILE__, __LINE__, NULL);<br>
-#define vk_errorf(error, format, ...) __vk_errorf(error, __FILE__, __LINE__, format, ## __VA_ARGS__);<br>
+#define vk_error(error) __vk_errorf(NULL, NULL,\<br>
+ VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>UNKNOWN_EXT,\<br>
+ error, __FILE__, __LINE__, NULL);<br>
+#define vk_errorf(instance, obj, error, format, ...)\<br>
+ __vk_errorf(instance, obj, REPORT_OBJECT_TYPE(obj), error,\<br>
+ __FILE__, __LINE__, format, ## __VA_ARGS__);<br>
#define anv_debug(format, ...) fprintf(stderr, "debug: " format, ##__VA_ARGS__)<br>
#else<br>
#define vk_error(error) error<br>
diff --git a/src/intel/vulkan/anv_queue.c b/src/intel/vulkan/anv_queue.c<br>
index 21ca66757e..aff7c53119 100644<br>
--- a/src/intel/vulkan/anv_queue.c<br>
+++ b/src/intel/vulkan/anv_queue.c<br>
@@ -43,7 +43,8 @@ anv_device_execbuf(struct anv_device *device,<br>
if (ret != 0) {<br>
/* We don't know the real error. */<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "execbuf2 failed: %m");<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
+ "execbuf2 failed: %m");<br>
}<br>
<br>
struct drm_i915_gem_exec_object2 *objects =<br>
@@ -239,7 +240,8 @@ out:<br>
* VK_ERROR_DEVICE_LOST to ensure that clients do not attempt to<br>
* submit the same job again to this device.<br>
*/<br>
- result = vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "vkQueueSubmit() failed");<br>
+ result = vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
+ "vkQueueSubmit() failed");<br>
device->lost = true;<br>
}<br>
<br>
@@ -429,7 +431,7 @@ VkResult anv_GetFenceStatus(<br>
} else {<br>
/* We don't know the real error. */<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST,<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
"drm_syncobj_wait failed: %m");<br>
}<br>
} else {<br>
@@ -509,7 +511,7 @@ anv_wait_for_syncobj_fences(<wbr>struct anv_device *device,<br>
} else {<br>
/* We don't know the real error. */<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST,<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
"drm_syncobj_wait failed: %m");<br>
}<br>
} else {<br>
@@ -751,7 +753,8 @@ VkResult anv_ImportFenceFdKHR(<br>
<br>
if (anv_gem_syncobj_import_sync_<wbr>file(device, new_impl.syncobj, fd)) {<br>
anv_gem_syncobj_destroy(<wbr>device, new_impl.syncobj);<br>
- return vk_errorf(VK_ERROR_INVALID_<wbr>EXTERNAL_HANDLE_KHR,<br>
+ return vk_errorf(device->instance, NULL,<br>
+ VK_ERROR_INVALID_EXTERNAL_<wbr>HANDLE_KHR,<br>
"syncobj sync file import failed: %m");<br>
}<br>
break;<br>
diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c<br>
index 36d9b2680e..fc6459f0e0 100644<br>
--- a/src/intel/vulkan/anv_util.c<br>
+++ b/src/intel/vulkan/anv_util.c<br>
@@ -93,10 +93,13 @@ __anv_perf_warn(struct anv_instance *instance, const void *object,<br>
}<br>
<br>
VkResult<br>
-__vk_errorf(VkResult error, const char *file, int line, const char *format, ...)<br>
+__vk_errorf(struct anv_instance *instance, const void *object,<br>
+ VkDebugReportObjectTypeEXT type, VkResult error,<br>
+ const char *file, int line, const char *format, ...)<br>
{<br>
va_list ap;<br>
char buffer[256];<br>
+ char report[256];<br>
<br>
const char *error_str = vk_Result_to_str(error);<br>
<br>
@@ -105,11 +108,22 @@ __vk_errorf(VkResult error, const char *file, int line, const char *format, ...)<br>
vsnprintf(buffer, sizeof(buffer), format, ap);<br>
va_end(ap);<br>
<br>
- fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);<br>
+ snprintf(report, 256, "%s:%d: %s (%s)", file, line, buffer, error_str);<br></blockquote><div><br></div><div>Please use sizeof(report) instead of 256 here<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
} else {<br>
- fprintf(stderr, "%s:%d: %s\n", file, line, error_str);<br>
+ snprintf(report, 256, "%s:%d: %s", file, line, error_str);<br></blockquote><div><br></div><div>and here<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
}<br>
<br>
+ anv_debug_report(instance,<br>
+ VK_DEBUG_REPORT_ERROR_BIT_EXT,<br>
+ type,<br>
+ (uint64_t) (uintptr_t) object,<br>
+ line,<br>
+ 0,<br>
+ "anv",<br>
+ report);<br>
+<br>
+ fprintf(stderr, "%s\n", report);<br>
+<br>
if (error == VK_ERROR_DEVICE_LOST &&<br>
env_var_as_boolean("ANV_ABORT_<wbr>ON_DEVICE_LOSS", false))<br>
abort();<br>
diff --git a/src/intel/vulkan/anv_wsi.c b/src/intel/vulkan/anv_wsi.c<br>
index 00edb220b2..c3e5dc1870 100644<br>
--- a/src/intel/vulkan/anv_wsi.c<br>
+++ b/src/intel/vulkan/anv_wsi.c<br>
@@ -248,7 +248,8 @@ anv_wsi_image_create(VkDevice device_h,<br>
surface->isl.row_pitch, I915_TILING_X);<br>
if (ret) {<br>
/* FINISHME: Choose a better error. */<br>
- result = vk_errorf(VK_ERROR_OUT_OF_<wbr>DEVICE_MEMORY,<br>
+ result = vk_errorf(device->instance, device,<br>
+ VK_ERROR_OUT_OF_DEVICE_MEMORY,<br>
"set_tiling failed: %m");<br>
goto fail_alloc_memory;<br>
}<br>
@@ -256,7 +257,8 @@ anv_wsi_image_create(VkDevice device_h,<br>
int fd = anv_gem_handle_to_fd(device, memory->bo->gem_handle);<br>
if (fd == -1) {<br>
/* FINISHME: Choose a better error. */<br>
- result = vk_errorf(VK_ERROR_OUT_OF_<wbr>DEVICE_MEMORY,<br>
+ result = vk_errorf(device->instance, device,<br>
+ VK_ERROR_OUT_OF_DEVICE_MEMORY,<br>
"handle_to_fd failed: %m");<br>
goto fail_alloc_memory;<br>
}<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index 67fc3f33df..a16f67b108 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -2492,7 +2492,8 @@ verify_cmd_parser(const struct anv_device *device,<br>
const char *function)<br>
{<br>
if (device->instance-><wbr>physicalDevice.cmd_parser_<wbr>version < required_version) {<br>
- return vk_errorf(VK_ERROR_FEATURE_<wbr>NOT_PRESENT,<br>
+ return vk_errorf(device->instance, device->instance,<br>
+ VK_ERROR_FEATURE_NOT_PRESENT,<br>
"cmd parser version %d is required for %s",<br>
required_version, function);<br>
} else {<br>
diff --git a/src/intel/vulkan/genX_query.<wbr>c b/src/intel/vulkan/genX_query.<wbr>c<br>
index 5745fae8df..7683d0d1e3 100644<br>
--- a/src/intel/vulkan/genX_query.<wbr>c<br>
+++ b/src/intel/vulkan/genX_query.<wbr>c<br>
@@ -167,7 +167,8 @@ wait_for_available(struct anv_device *device,<br>
} else if (ret == -1) {<br>
/* We don't know the real error. */<br>
device->lost = true;<br>
- return vk_errorf(VK_ERROR_DEVICE_<wbr>LOST, "gem wait failed: %m");<br>
+ return vk_errorf(device->instance, device, VK_ERROR_DEVICE_LOST,<br>
+ "gem wait failed: %m");<br>
} else {<br>
assert(ret == 0);<br>
/* The BO is no longer busy. */<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.5<br>
<br>
</font></span></blockquote></div><br></div></div>