[Mesa-dev] [PATCH v2 2/5] anv: wire up anv_perf_warn macro to do debug reporting

Jason Ekstrand jason at jlekstrand.net
Thu Sep 7 16:53:15 UTC 2017


On Mon, Aug 28, 2017 at 10:44 PM, Tapani Pälli <tapani.palli at intel.com>
wrote:

> Signed-off-by: Tapani Pälli <tapani.palli at intel.com>
> ---
>  src/intel/vulkan/anv_device.c      |   3 +-
>  src/intel/vulkan/anv_image.c       |  12 ++--
>  src/intel/vulkan/anv_private.h     | 112 ++++++++++++++++++++++++++++++
> +++++--
>  src/intel/vulkan/anv_util.c        |  18 +++++-
>  src/intel/vulkan/genX_cmd_buffer.c |  12 ++--
>  5 files changed, 141 insertions(+), 16 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 7e091246a8..037b8258df 100644
> --- a/src/intel/vulkan/anv_device.c
> +++ b/src/intel/vulkan/anv_device.c
> @@ -64,7 +64,8 @@ anv_compute_heap_size(int fd, uint64_t *heap_size)
>        /* If, for whatever reason, we can't actually get the GTT size from
> the
>         * kernel (too old?) fall back to the aperture size.
>         */
> -      anv_perf_warn("Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");
> +      anv_perf_warn(NULL, NULL,
> +                    "Failed to get I915_CONTEXT_PARAM_GTT_SIZE: %m");
>
>        if (anv_gem_get_aperture(fd, &gtt_size) == -1) {
>           return vk_errorf(VK_ERROR_INITIALIZATION_FAILED,
> diff --git a/src/intel/vulkan/anv_image.c b/src/intel/vulkan/anv_image.c
> index 4f0a818b08..492b341303 100644
> --- a/src/intel/vulkan/anv_image.c
> +++ b/src/intel/vulkan/anv_image.c
> @@ -269,13 +269,14 @@ make_surface(const struct anv_device *dev,
>        if (!(image->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT))
> {
>           /* It will never be used as an attachment, HiZ is pointless. */
>        } else if (dev->info.gen == 7) {
> -         anv_perf_warn("Implement gen7 HiZ");
> +         anv_perf_warn(dev->instance, image, "Implement gen7 HiZ");
>        } else if (vk_info->mipLevels > 1) {
> -         anv_perf_warn("Enable multi-LOD HiZ");
> +         anv_perf_warn(dev->instance, image, "Enable multi-LOD HiZ");
>        } else if (vk_info->arrayLayers > 1) {
> -         anv_perf_warn("Implement multi-arrayLayer HiZ clears and
> resolves");
> +         anv_perf_warn(dev->instance, image,
> +                       "Implement multi-arrayLayer HiZ clears and
> resolves");
>        } else if (dev->info.gen == 8 && vk_info->samples > 1) {
> -         anv_perf_warn("Enable gen8 multisampled HiZ");
> +         anv_perf_warn(dev->instance, image, "Enable gen8 multisampled
> HiZ");
>        } else if (!unlikely(INTEL_DEBUG & DEBUG_NO_HIZ)) {
>           assert(image->aux_surface.isl.size == 0);
>           ok = isl_surf_get_hiz_surf(&dev->isl_dev,
> &image->depth_surface.isl,
> @@ -299,7 +300,8 @@ make_surface(const struct anv_device *dev,
>                  * image, we currently don't have things hooked up to get
> it
>                  * working.
>                  */
> -               anv_perf_warn("This image format doesn't support
> rendering. "
> +               anv_perf_warn(dev->instance, image,
> +                             "This image format doesn't support
> rendering. "
>                               "Not allocating an CCS buffer.");
>                 image->aux_surface.isl.size = 0;
>                 return VK_SUCCESS;
> diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_
> private.h
> index ae66c5439b..4d59d5b24c 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -197,6 +197,107 @@ vk_to_isl_color(VkClearColorValue color)
>     memcpy((dest), (src), (count) * sizeof(*(src))); \
>  })
>
> +/* Mapping from anv object to VkDebugReportObjectTypeEXT. New types need
> + * to be added here in order to utilize mapping in debug/error/perf
> macros.
> + */
> +#define REPORT_OBJECT_TYPE(o)
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_instance*),
>           \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_INSTANCE_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_physical_device*),       \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_PHYSICAL_DEVICE_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_device*),
>           \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), const struct
> anv_device*),          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_queue*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_QUEUE_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_semaphore*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_SEMAPHORE_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_cmd_buffer*),
>           \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_BUFFER_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_fence*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_FENCE_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_device_memory*),         \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_buffer*),
>           \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_image*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), const struct anv_image*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_event*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_EVENT_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_query_pool*),
>           \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_QUERY_POOL_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_buffer_view*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_VIEW_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_image_view*),
>           \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_VIEW_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_shader_module*),         \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_SHADER_MODULE_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_pipeline_cache*),        \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_CACHE_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_pipeline_layout*),       \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_LAYOUT_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_render_pass*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_RENDER_PASS_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_pipeline*),
>           \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_PIPELINE_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_descriptor_set_layout*), \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_LAYOUT_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_sampler*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_SAMPLER_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_descriptor_pool*),       \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_POOL_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_descriptor_set*),        \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_DESCRIPTOR_SET_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_framebuffer*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_FRAMEBUFFER_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_cmd_pool*),
>           \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_COMMAND_POOL_EXT,
>            \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct anv_surface*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct wsi_swapchain*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), struct
> anv_debug_callback*),        \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_CALLBACK_EXT_EXT,
>           \
> +   __builtin_choose_expr (
>          \
> +   __builtin_types_compatible_p (__typeof (o), void*),
>          \
> +   VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
>           \
> +   /* The void expression results in a compile-time error
>           \
> +      when assigning the result to something.  */
>           \
> +   (void)0)))))))))))))))))))))))))))))))
> +
>  /* Whenever we generate an error, pass it through this function. Useful
> for
>   * debugging, where we can break on it. Only call at error site, not when
>   * propagating errors. Might be useful to plug in a stack trace here.
> @@ -234,8 +335,10 @@ VkResult __vk_errorf(VkResult error, const char
> *file, int line, const char *for
>
>  void __anv_finishme(const char *file, int line, const char *format, ...)
>     anv_printflike(3, 4);
> -void __anv_perf_warn(const char *file, int line, const char *format, ...)
> -   anv_printflike(3, 4);
> +void __anv_perf_warn(struct anv_instance *instance, const void *object,
> +                     VkDebugReportObjectTypeEXT type, const char *file,
> +                     int line, const char *format, ...)
> +   anv_printflike(6, 7);
>  void anv_loge(const char *format, ...) anv_printflike(1, 2);
>  void anv_loge_v(const char *format, va_list va);
>
> @@ -263,11 +366,12 @@ void anv_debug_report(struct anv_instance *instance,
>  /**
>   * Print a perf warning message.  Set INTEL_DEBUG=perf to see these.
>   */
> -#define anv_perf_warn(format, ...) \
> +#define anv_perf_warn(instance, obj, format, ...) \
>     do { \
>        static bool reported = false; \
>        if (!reported && unlikely(INTEL_DEBUG & DEBUG_PERF)) { \
> -         __anv_perf_warn(__FILE__, __LINE__, format, ##__VA_ARGS__); \
> +         __anv_perf_warn(instance, obj, REPORT_OBJECT_TYPE(obj),
> __FILE__, __LINE__,\
> +                         format, ##__VA_ARGS__); \
>           reported = true; \
>        } \
>     } while (0)
> diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
> index 4b916e27f2..a374db5cc6 100644
> --- a/src/intel/vulkan/anv_util.c
> +++ b/src/intel/vulkan/anv_util.c
> @@ -65,16 +65,30 @@ __anv_finishme(const char *file, int line, const char
> *format, ...)
>     fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer);
>  }
>
> -void anv_printflike(3, 4)
> -__anv_perf_warn(const char *file, int line, const char *format, ...)
> +void anv_printflike(6, 7)
> +__anv_perf_warn(struct anv_instance *instance, const void *object,
> +                VkDebugReportObjectTypeEXT type,
> +                const char *file, int line, const char *format, ...)
>  {
>     va_list ap;
>     char buffer[256];
> +   char report[256];
>
>     va_start(ap, format);
>     vsnprintf(buffer, sizeof(buffer), format, ap);
>     va_end(ap);
>
> +   snprintf(report, 256, "%s: %s", file, buffer);
> +
> +   anv_debug_report(instance,
> +                    VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
> +                    type,
> +                    (uint64_t) object,
>

Some compilers may complain if you don't do (uint64_t)(uintptr_t) here


> +                    line,
> +                    0,
> +                    "anv",
> +                    report);
> +
>     fprintf(stderr, "%s:%d: PERF: %s\n", file, line, buffer);
>  }
>
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> b/src/intel/vulkan/genX_cmd_buffer.c
> index c5735b27e0..1bc5c06c55 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -280,7 +280,8 @@ color_attachment_compute_aux_usage(struct anv_device
> * device,
>            */
>           if (cmd_state->pass->attachments[att].first_subpass_layout ==
>               VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL) {
> -            anv_perf_warn("Not temporarily enabling CCS_E.");
> +            anv_perf_warn(device->instance, iview->image,
> +                          "Not temporarily enabling CCS_E.");
>           }
>        } else {
>           att_state->input_aux_usage = ISL_AUX_USAGE_NONE;
> @@ -325,7 +326,8 @@ color_attachment_compute_aux_usage(struct anv_device
> * device,
>            anv_image_aux_layers(iview->image, iview->isl.base_level)) {
>           att_state->fast_clear = false;
>           if (GEN_GEN == 7) {
> -            anv_perf_warn("Not fast-clearing the first layer in "
> +            anv_perf_warn(device->instance, iview->image,
> +                          "Not fast-clearing the first layer in "
>                            "a multi-layer fast clear.");
>           }
>        }
> @@ -692,7 +694,8 @@ transition_color_buffer(struct anv_cmd_buffer
> *cmd_buffer,
>         */
>        if ((GEN_GEN >= 9 && image->samples == 1) || image->samples > 1) {
>           if (image->samples == 4 || image->samples == 16) {
> -            anv_perf_warn("Doing a potentially unnecessary fast-clear to "
> +            anv_perf_warn(cmd_buffer->device->instance, image,
> +                          "Doing a potentially unnecessary fast-clear to "
>                            "define an MCS buffer.");
>           }
>
> @@ -713,7 +716,8 @@ transition_color_buffer(struct anv_cmd_buffer
> *cmd_buffer,
>           /* The CCS_D buffer may not be enabled in the final layout.
> Continue
>            * executing this function to perform a resolve.
>            */
> -          anv_perf_warn("Performing an additional resolve for CCS_D
> layout "
> +          anv_perf_warn(cmd_buffer->device->instance, image,
> +                        "Performing an additional resolve for CCS_D
> layout "
>                          "transition. Consider always leaving it on or "
>                          "performing an ambiguation pass.");
>        } else {
> --
> 2.13.5
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170907/d552f619/attachment-0001.html>


More information about the mesa-dev mailing list