[Mesa-dev] [PATCH 12/20] anv: Better support for Android logging (v2)
Chad Versace
chad at kiwitree.net
Wed Sep 13 23:03:21 UTC 2017
From: Chad Versace <chadversary at chromium.org>
In src/intel/vulkan/*, redirect all instances of printf, vk_error,
anv_loge, anv_debug, anv_finishme, anv_perf_warn, anv_assert, and their
many variants to the new intel_log functions. I believe I caught them
all.
The other subdirs of src/intel are left for a future exercise.
v2:
- Rebase onto Tapani's VK_EXT_debug_report changes.
- Drop unused #include <cutils/log.h>.
---
src/intel/vulkan/anv_device.c | 11 +++++------
src/intel/vulkan/anv_private.h | 12 +++++-------
src/intel/vulkan/anv_util.c | 21 +++------------------
src/intel/vulkan/genX_cmd_buffer.c | 4 ++--
4 files changed, 15 insertions(+), 33 deletions(-)
diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
index 8e2ed9eac45..8c645707a90 100644
--- a/src/intel/vulkan/anv_device.c
+++ b/src/intel/vulkan/anv_device.c
@@ -50,7 +50,7 @@ compiler_perf_log(void *data, const char *fmt, ...)
va_start(args, fmt);
if (unlikely(INTEL_DEBUG & DEBUG_PERF))
- vfprintf(stderr, fmt, args);
+ intel_logd_v(fmt, args);
va_end(args);
}
@@ -294,11 +294,11 @@ anv_physical_device_init(struct anv_physical_device *device,
}
if (device->info.is_haswell) {
- fprintf(stderr, "WARNING: Haswell Vulkan support is incomplete\n");
+ intel_logw("Haswell Vulkan support is incomplete");
} else if (device->info.gen == 7 && !device->info.is_baytrail) {
- fprintf(stderr, "WARNING: Ivy Bridge Vulkan support is incomplete\n");
+ intel_logw("Ivy Bridge Vulkan support is incomplete");
} else if (device->info.gen == 7 && device->info.is_baytrail) {
- fprintf(stderr, "WARNING: Bay Trail Vulkan support is incomplete\n");
+ intel_logw("Bay Trail Vulkan support is incomplete");
} else if (device->info.gen >= 8 && device->info.gen <= 9) {
/* Broadwell, Cherryview, Skylake, Broxton, Kabylake is as fully
* supported as anything */
@@ -365,8 +365,7 @@ anv_physical_device_init(struct anv_physical_device *device,
* many platforms, but otherwise, things will just work.
*/
if (device->subslice_total < 1 || device->eu_total < 1) {
- fprintf(stderr, "WARNING: Kernel 4.1 required to properly"
- " query GPU properties.\n");
+ intel_logw("Kernel 4.1 required to properly query GPU properties");
}
} else if (device->info.gen == 7) {
device->subslice_total = 1 << (device->info.gt - 1);
diff --git a/src/intel/vulkan/anv_private.h b/src/intel/vulkan/anv_private.h
index df8de8d9407..16670f2ac3b 100644
--- a/src/intel/vulkan/anv_private.h
+++ b/src/intel/vulkan/anv_private.h
@@ -74,6 +74,7 @@ struct gen_l3_config;
#include "isl/isl.h"
#include "common/gen_debug.h"
+#include "common/intel_log.h"
#include "wsi_common.h"
/* Allowing different clear colors requires us to perform a depth resolve at
@@ -314,11 +315,9 @@ VkResult __vk_errorf(struct anv_instance *instance, const void *object,
#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
#define vk_errorf(instance, obj, error, format, ...) error
-#define anv_debug(format, ...)
#endif
/**
@@ -337,10 +336,8 @@ VkResult __vk_errorf(struct anv_instance *instance, const void *object,
* defined by extensions supported by that component.
*/
#define anv_debug_ignored_stype(sType) \
- anv_debug("%s: ignored VkStructureType %u\n", __func__, (sType))
+ intel_logd("%s: ignored VkStructureType %u\n", __func__, (sType))
-void __anv_finishme(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, ...)
@@ -364,7 +361,8 @@ void anv_debug_report(struct anv_instance *instance,
do { \
static bool reported = false; \
if (!reported) { \
- __anv_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__); \
+ intel_logw("%s:%d: FINISHME: " format, __FILE__, __LINE__, \
+ ##__VA_ARGS__); \
reported = true; \
} \
} while (0)
@@ -386,7 +384,7 @@ void anv_debug_report(struct anv_instance *instance,
#ifdef DEBUG
#define anv_assert(x) ({ \
if (unlikely(!(x))) \
- fprintf(stderr, "%s:%d ASSERT: %s\n", __FILE__, __LINE__, #x); \
+ intel_loge("%s:%d ASSERT: %s", __FILE__, __LINE__, #x); \
})
#else
#define anv_assert(x)
diff --git a/src/intel/vulkan/anv_util.c b/src/intel/vulkan/anv_util.c
index ec61f7355ef..59f893492b7 100644
--- a/src/intel/vulkan/anv_util.c
+++ b/src/intel/vulkan/anv_util.c
@@ -47,22 +47,7 @@ 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");
-}
-
-void anv_printflike(3, 4)
-__anv_finishme(const char *file, int line, const char *format, ...)
-{
- va_list ap;
- char buffer[256];
-
- va_start(ap, format);
- vsnprintf(buffer, sizeof(buffer), format, ap);
- va_end(ap);
-
- fprintf(stderr, "%s:%d: FINISHME: %s\n", file, line, buffer);
+ intel_loge_v(format, va);
}
void anv_printflike(6, 7)
@@ -89,7 +74,7 @@ __anv_perf_warn(struct anv_instance *instance, const void *object,
"anv",
report);
- fprintf(stderr, "%s:%d: PERF: %s\n", file, line, buffer);
+ intel_logw("%s:%d: PERF: %s", file, line, buffer);
}
VkResult
@@ -123,7 +108,7 @@ __vk_errorf(struct anv_instance *instance, const void *object,
"anv",
report);
- fprintf(stderr, "%s\n", report);
+ intel_loge("%s", report);
if (error == VK_ERROR_DEVICE_LOST &&
env_var_as_boolean("ANV_ABORT_ON_DEVICE_LOSS", false))
diff --git a/src/intel/vulkan/genX_cmd_buffer.c b/src/intel/vulkan/genX_cmd_buffer.c
index a16f67b108c..a62669f90df 100644
--- a/src/intel/vulkan/genX_cmd_buffer.c
+++ b/src/intel/vulkan/genX_cmd_buffer.c
@@ -1121,7 +1121,7 @@ genX(cmd_buffer_config_l3)(struct anv_cmd_buffer *cmd_buffer,
return;
if (unlikely(INTEL_DEBUG & DEBUG_L3)) {
- fprintf(stderr, "L3 config transition: ");
+ intel_logd("L3 config transition: ");
gen_dump_l3_config(cfg, stderr);
}
@@ -2278,7 +2278,7 @@ load_indirect_parameters(struct anv_cmd_buffer *cmd_buffer,
emit_mul_gpr0(batch, view_count);
emit_lrr(batch, GEN7_3DPRIM_INSTANCE_COUNT, CS_GPR(0));
#else
- anv_finishme("Multiview + indirect draw requires MI_MATH\n"
+ anv_finishme("Multiview + indirect draw requires MI_MATH; "
"MI_MATH is not supported on Ivy Bridge");
emit_lrm(batch, GEN7_3DPRIM_INSTANCE_COUNT, bo, bo_offset + 4);
#endif
--
2.13.5
More information about the mesa-dev
mailing list