<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Mon, Aug 28, 2017 at 10:44 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_device.c      |   3 +-<br>
 src/intel/vulkan/anv_image.c       |  12 ++--<br>
 src/intel/vulkan/anv_private.h     | 112 ++++++++++++++++++++++++++++++<wbr>+++++--<br>
 src/intel/vulkan/anv_util.c        |  18 +++++-<br>
 src/intel/vulkan/genX_cmd_<wbr>buffer.c |  12 ++--<br>
 5 files changed, 141 insertions(+), 16 deletions(-)<br>
<br>
diff --git a/src/intel/vulkan/anv_device.<wbr>c b/src/intel/vulkan/anv_device.<wbr>c<br>
index 7e091246a8..037b8258df 100644<br>
--- a/src/intel/vulkan/anv_device.<wbr>c<br>
+++ b/src/intel/vulkan/anv_device.<wbr>c<br>
@@ -64,7 +64,8 @@ anv_compute_heap_size(int fd, uint64_t *heap_size)<br>
       /* If, for whatever reason, we can't actually get the GTT size from the<br>
        * kernel (too old?) fall back to the aperture size.<br>
        */<br>
-      anv_perf_warn("Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");<br>
+      anv_perf_warn(NULL, NULL,<br>
+                    "Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");<br>
<br>
       if (anv_gem_get_aperture(fd, &gtt_size) == -1) {<br>
          return vk_errorf(VK_ERROR_<wbr>INITIALIZATION_FAILED,<br>
diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c<br>
index 4f0a818b08..492b341303 100644<br>
--- a/src/intel/vulkan/anv_image.c<br>
+++ b/src/intel/vulkan/anv_image.c<br>
@@ -269,13 +269,14 @@ make_surface(const struct anv_device *dev,<br>
       if (!(image->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_<wbr>ATTACHMENT_BIT)) {<br>
          /* It will never be used as an attachment, HiZ is pointless. */<br>
       } else if (dev->info.gen == 7) {<br>
-         anv_perf_warn("Implement gen7 HiZ");<br>
+         anv_perf_warn(dev->instance, image, "Implement gen7 HiZ");<br>
       } else if (vk_info->mipLevels > 1) {<br>
-         anv_perf_warn("Enable multi-LOD HiZ");<br>
+         anv_perf_warn(dev->instance, image, "Enable multi-LOD HiZ");<br>
       } else if (vk_info->arrayLayers > 1) {<br>
-         anv_perf_warn("Implement multi-arrayLayer HiZ clears and resolves");<br>
+         anv_perf_warn(dev->instance, image,<br>
+                       "Implement multi-arrayLayer HiZ clears and resolves");<br>
       } else if (dev->info.gen == 8 && vk_info->samples > 1) {<br>
-         anv_perf_warn("Enable gen8 multisampled HiZ");<br>
+         anv_perf_warn(dev->instance, image, "Enable gen8 multisampled HiZ");<br>
       } else if (!unlikely(INTEL_DEBUG & DEBUG_NO_HIZ)) {<br>
          assert(image->aux_surface.isl.<wbr>size == 0);<br>
          ok = isl_surf_get_hiz_surf(&dev-><wbr>isl_dev, &image->depth_surface.isl,<br>
@@ -299,7 +300,8 @@ make_surface(const struct anv_device *dev,<br>
                 * image, we currently don't have things hooked up to get it<br>
                 * working.<br>
                 */<br>
-               anv_perf_warn("This image format doesn't support rendering. "<br>
+               anv_perf_warn(dev->instance, image,<br>
+                             "This image format doesn't support rendering. "<br>
                              "Not allocating an CCS buffer.");<br>
                image->aux_surface.isl.size = 0;<br>
                return VK_SUCCESS;<br>
diff --git a/src/intel/vulkan/anv_<wbr>private.h b/src/intel/vulkan/anv_<wbr>private.h<br>
index ae66c5439b..4d59d5b24c 100644<br>
--- a/src/intel/vulkan/anv_<wbr>private.h<br>
+++ b/src/intel/vulkan/anv_<wbr>private.h<br>
@@ -197,6 +197,107 @@ vk_to_isl_color(<wbr>VkClearColorValue color)<br>
    memcpy((dest), (src), (count) * sizeof(*(src))); \<br>
 })<br>
<br>
+/* Mapping from anv object to VkDebugReportObjectTypeEXT. New types need<br>
+ * to be added here in order to utilize mapping in debug/error/perf macros.<br>
+ */<br>
+#define REPORT_OBJECT_TYPE(o)                                                      \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_instance*),              \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>INSTANCE_EXT,                                       \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_physical_device*),       \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>PHYSICAL_DEVICE_EXT,                                \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_device*),                \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>DEVICE_EXT,                                         \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), const struct anv_device*),          \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>DEVICE_EXT,                                         \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_queue*),                 \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>QUEUE_EXT,                                          \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_semaphore*),             \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>SEMAPHORE_EXT,                                      \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_cmd_buffer*),            \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>COMMAND_BUFFER_EXT,                                 \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_fence*),                 \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>FENCE_EXT,                                          \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_device_memory*),         \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>DEVICE_MEMORY_EXT,                                  \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_buffer*),                \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>BUFFER_EXT,                                         \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_image*),                 \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>IMAGE_EXT,                                          \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), const struct anv_image*),           \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>IMAGE_EXT,                                          \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_event*),                 \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>EVENT_EXT,                                          \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_query_pool*),            \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>QUERY_POOL_EXT,                                     \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_buffer_view*),           \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>BUFFER_VIEW_EXT,                                    \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_image_view*),            \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>IMAGE_VIEW_EXT,                                     \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_shader_module*),         \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>SHADER_MODULE_EXT,                                  \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_pipeline_cache*),        \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>PIPELINE_CACHE_EXT,                                 \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_pipeline_layout*),       \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>PIPELINE_LAYOUT_EXT,                                \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_render_pass*),           \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>RENDER_PASS_EXT,                                    \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_pipeline*),              \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>PIPELINE_EXT,                                       \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_descriptor_set_layout*), \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>DESCRIPTOR_SET_LAYOUT_EXT,                          \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_sampler*),               \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>SAMPLER_EXT,                                        \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_descriptor_pool*),       \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>DESCRIPTOR_POOL_EXT,                                \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_descriptor_set*),        \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>DESCRIPTOR_SET_EXT,                                 \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_framebuffer*),           \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>FRAMEBUFFER_EXT,                                    \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_cmd_pool*),              \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>COMMAND_POOL_EXT,                                   \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_surface*),               \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>SURFACE_KHR_EXT,                                    \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct wsi_swapchain*),             \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>SWAPCHAIN_KHR_EXT,                                  \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), struct anv_debug_callback*),        \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>DEBUG_REPORT_CALLBACK_EXT_EXT,                      \<br>
+   __builtin_choose_expr (                                                         \<br>
+   __builtin_types_compatible_p (__typeof (o), void*),                             \<br>
+   VK_DEBUG_REPORT_OBJECT_TYPE_<wbr>UNKNOWN_EXT,                                        \<br>
+   /* The void expression results in a compile-time error                          \<br>
+      when assigning the result to something.  */                                  \<br>
+   (void)0)))))))))))))))))))))))<wbr>))))))))<br>
+<br>
 /* Whenever we generate an error, pass it through this function. Useful for<br>
  * debugging, where we can break on it. Only call at error site, not when<br>
  * propagating errors. Might be useful to plug in a stack trace here.<br>
@@ -234,8 +335,10 @@ VkResult __vk_errorf(VkResult error, const char *file, int line, const char *for<br>
<br>
 void __anv_finishme(const char *file, int line, const char *format, ...)<br>
    anv_printflike(3, 4);<br>
-void __anv_perf_warn(const char *file, int line, const char *format, ...)<br>
-   anv_printflike(3, 4);<br>
+void __anv_perf_warn(struct anv_instance *instance, const void *object,<br>
+                     VkDebugReportObjectTypeEXT type, const char *file,<br>
+                     int line, const char *format, ...)<br>
+   anv_printflike(6, 7);<br>
 void anv_loge(const char *format, ...) anv_printflike(1, 2);<br>
 void anv_loge_v(const char *format, va_list va);<br>
<br>
@@ -263,11 +366,12 @@ void anv_debug_report(struct anv_instance *instance,<br>
 /**<br>
  * Print a perf warning message.  Set INTEL_DEBUG=perf to see these.<br>
  */<br>
-#define anv_perf_warn(format, ...) \<br>
+#define anv_perf_warn(instance, obj, format, ...) \<br>
    do { \<br>
       static bool reported = false; \<br>
       if (!reported && unlikely(INTEL_DEBUG & DEBUG_PERF)) { \<br>
-         __anv_perf_warn(__FILE__, __LINE__, format, ##__VA_ARGS__); \<br>
+         __anv_perf_warn(instance, obj, REPORT_OBJECT_TYPE(obj), __FILE__, __LINE__,\<br>
+                         format, ##__VA_ARGS__); \<br>
          reported = true; \<br>
       } \<br>
    } while (0)<br>
diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c<br>
index 4b916e27f2..a374db5cc6 100644<br>
--- a/src/intel/vulkan/anv_util.c<br>
+++ b/src/intel/vulkan/anv_util.c<br>
@@ -65,16 +65,30 @@ __anv_finishme(const char *file, int line, const char *format, ...)<br>
    fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer);<br>
 }<br>
<br>
-void anv_printflike(3, 4)<br>
-__anv_perf_warn(const char *file, int line, const char *format, ...)<br>
+void anv_printflike(6, 7)<br>
+__anv_perf_warn(struct anv_instance *instance, const void *object,<br>
+                VkDebugReportObjectTypeEXT type,<br>
+                const char *file, int line, const char *format, ...)<br>
 {<br>
    va_list ap;<br>
    char buffer[256];<br>
+   char report[256];<br>
<br>
    va_start(ap, format);<br>
    vsnprintf(buffer, sizeof(buffer), format, ap);<br>
    va_end(ap);<br>
<br>
+   snprintf(report, 256, "%s: %s", file, buffer);<br>
+<br>
+   anv_debug_report(instance,<br>
+                    VK_DEBUG_REPORT_PERFORMANCE_<wbr>WARNING_BIT_EXT,<br>
+                    type,<br>
+                    (uint64_t) object,<br></blockquote><div><br></div><div>Some compilers may complain if you don't do (uint64_t)(uintptr_t) here<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+                    line,<br>
+                    0,<br>
+                    "anv",<br>
+                    report);<br>
+<br>
    fprintf(stderr, "%s:%d: PERF: %s\n", file, line, buffer);<br>
 }<br>
<br>
diff --git a/src/intel/vulkan/genX_cmd_<wbr>buffer.c b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
index c5735b27e0..1bc5c06c55 100644<br>
--- a/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
+++ b/src/intel/vulkan/genX_cmd_<wbr>buffer.c<br>
@@ -280,7 +280,8 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device * device,<br>
           */<br>
          if (cmd_state->pass->attachments[<wbr>att].first_subpass_layout ==<br>
              VK_IMAGE_LAYOUT_COLOR_<wbr>ATTACHMENT_OPTIMAL) {<br>
-            anv_perf_warn("Not temporarily enabling CCS_E.");<br>
+            anv_perf_warn(device-><wbr>instance, iview->image,<br>
+                          "Not temporarily enabling CCS_E.");<br>
          }<br>
       } else {<br>
          att_state->input_aux_usage = ISL_AUX_USAGE_NONE;<br>
@@ -325,7 +326,8 @@ color_attachment_compute_aux_<wbr>usage(struct anv_device * device,<br>
           anv_image_aux_layers(iview-><wbr>image, iview->isl.base_level)) {<br>
          att_state->fast_clear = false;<br>
          if (GEN_GEN == 7) {<br>
-            anv_perf_warn("Not fast-clearing the first layer in "<br>
+            anv_perf_warn(device-><wbr>instance, iview->image,<br>
+                          "Not fast-clearing the first layer in "<br>
                           "a multi-layer fast clear.");<br>
          }<br>
       }<br>
@@ -692,7 +694,8 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
        */<br>
       if ((GEN_GEN >= 9 && image->samples == 1) || image->samples > 1) {<br>
          if (image->samples == 4 || image->samples == 16) {<br>
-            anv_perf_warn("Doing a potentially unnecessary fast-clear to "<br>
+            anv_perf_warn(cmd_buffer-><wbr>device->instance, image,<br>
+                          "Doing a potentially unnecessary fast-clear to "<br>
                           "define an MCS buffer.");<br>
          }<br>
<br>
@@ -713,7 +716,8 @@ transition_color_buffer(struct anv_cmd_buffer *cmd_buffer,<br>
          /* The CCS_D buffer may not be enabled in the final layout. Continue<br>
           * executing this function to perform a resolve.<br>
           */<br>
-          anv_perf_warn("Performing an additional resolve for CCS_D layout "<br>
+          anv_perf_warn(cmd_buffer-><wbr>device->instance, image,<br>
+                        "Performing an additional resolve for CCS_D layout "<br>
                         "transition. Consider always leaving it on or "<br>
                         "performing an ambiguation pass.");<br>
       } else {<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.13.5<br>
<br>
</font></span></blockquote></div><br></div></div>