intel/tools: Disassemble WAIT's argument as a destination
[mesa.git] / src / intel / vulkan / anv_util.c
index 4b916e27f2c910c20d75ea199b90bf6510c688f3..58d2efcc51f2d64b52ff650ff43a486c70c7c58a 100644 (file)
@@ -30,7 +30,6 @@
 
 #include "anv_private.h"
 #include "vk_enum_to_str.h"
-#include "util/debug.h"
 
 /** Log an error message.  */
 void anv_printflike(1, 2)
@@ -47,58 +46,81 @@ anv_loge(const char *format, ...)
 void
 anv_loge_v(const char *format, va_list va)
 {
-   fprintf(stderr, "vk: error: ");
-   vfprintf(stderr, format, va);
-   fprintf(stderr, "\n");
+   intel_loge_v(format, va);
 }
 
-void anv_printflike(3, 4)
-__anv_finishme(const char *file, int line, const char *format, ...)
+void anv_printflike(6, 7)
+__anv_perf_warn(struct anv_device *device, const void *object,
+                VkDebugReportObjectTypeEXT type,
+                const char *file, int line, const char *format, ...)
 {
    va_list ap;
    char buffer[256];
+   char report[512];
 
    va_start(ap, format);
    vsnprintf(buffer, sizeof(buffer), format, ap);
    va_end(ap);
 
-   fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer);
-}
+   snprintf(report, sizeof(report), "%s: %s", file, buffer);
 
-void anv_printflike(3, 4)
-__anv_perf_warn(const char *file, int line, const char *format, ...)
-{
-   va_list ap;
-   char buffer[256];
+   vk_debug_report(&device->physical->instance->debug_report_callbacks,
+                   VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT,
+                   type,
+                   (uint64_t) (uintptr_t) object,
+                   line,
+                   0,
+                   "anv",
+                   report);
 
-   va_start(ap, format);
-   vsnprintf(buffer, sizeof(buffer), format, ap);
-   va_end(ap);
-
-   fprintf(stderr, "%s:%d: PERF: %s\n", file, line, buffer);
+   intel_logw("%s:%d: PERF: %s", file, line, buffer);
 }
 
 VkResult
-__vk_errorf(VkResult error, const char *file, int line, const char *format, ...)
+__vk_errorv(struct anv_instance *instance, const void *object,
+            VkDebugReportObjectTypeEXT type, VkResult error,
+            const char *file, int line, const char *format, va_list ap)
 {
-   va_list ap;
    char buffer[256];
+   char report[512];
 
    const char *error_str = vk_Result_to_str(error);
 
    if (format) {
-      va_start(ap, format);
       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);
+   }
+
+   if (instance) {
+      vk_debug_report(&instance->debug_report_callbacks,
+                      VK_DEBUG_REPORT_ERROR_BIT_EXT,
+                      type,
+                      (uint64_t) (uintptr_t) object,
+                      line,
+                      0,
+                      "anv",
+                      report);
    }
 
-   if (error == VK_ERROR_DEVICE_LOST &&
-       env_var_as_boolean("ANV_ABORT_ON_DEVICE_LOSS", false))
-      abort();
+   intel_loge("%s", report);
+
+   return error;
+}
+
+VkResult
+__vk_errorf(struct anv_instance *instance, const void *object,
+            VkDebugReportObjectTypeEXT type, VkResult error,
+            const char *file, int line, const char *format, ...)
+{
+   va_list ap;
+
+   va_start(ap, format);
+   __vk_errorv(instance, object, type, error, file, line, format, ap);
+   va_end(ap);
 
    return error;
 }