[Mesa-dev] [PATCH 13/23] anv: Better support for Android logging
Jason Ekstrand
jason at jlekstrand.net
Sat Sep 2 16:48:23 UTC 2017
This is going to conflict badly with tapani's work to implement
VK_EXT_debug_report (which I need to finish reviewing).
On Sat, Sep 2, 2017 at 1:17 AM, Chad Versace <chadversary at chromium.org>
wrote:
> 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.
> ---
> src/intel/vulkan/anv_device.c | 11 ++++-----
> src/intel/vulkan/anv_private.h | 26 +++++++++-----------
> src/intel/vulkan/anv_util.c | 50 ++----------------------------
> --------
> src/intel/vulkan/genX_cmd_buffer.c | 4 +--
> 4 files changed, 20 insertions(+), 71 deletions(-)
>
> diff --git a/src/intel/vulkan/anv_device.c b/src/intel/vulkan/anv_device.c
> index 2e0fa19b1aa..d026b541b01 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);
> }
> @@ -288,11 +288,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 */
> @@ -354,8 +354,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 674bc28cc02..8020a5ab0d3 100644
> --- a/src/intel/vulkan/anv_private.h
> +++ b/src/intel/vulkan/anv_private.h
> @@ -41,6 +41,10 @@
> #define VG(x)
> #endif
>
> +#ifdef ANDROID
> +#include <cutils/log.h>
> +#endif
> +
> #include "common/gen_clflush.h"
> #include "common/gen_device_info.h"
> #include "blorp/blorp.h"
> @@ -72,6 +76,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
> @@ -102,8 +107,6 @@ struct gen_l3_config;
> #define ANV_SVGS_VB_INDEX MAX_VBS
> #define ANV_DRAWID_VB_INDEX (MAX_VBS + 1)
>
> -#define anv_printflike(a, b) __attribute__((__format__(__printf__, a,
> b)))
> -
> static inline uint32_t
> align_down_npot_u32(uint32_t v, uint32_t a)
> {
> @@ -205,11 +208,9 @@ VkResult __vk_errorf(VkResult error, const char
> *file, int line, const char *for
> #ifdef DEBUG
> #define vk_error(error) __vk_errorf(error, __FILE__, __LINE__, NULL);
> #define vk_errorf(error, format, ...) __vk_errorf(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(error, format, ...) error
> -#define anv_debug(format, ...)
> #endif
>
> /**
> @@ -228,14 +229,7 @@ VkResult __vk_errorf(VkResult error, const char
> *file, int line, const char *for
> * defined by extensions supported by that component.
> */
> #define anv_debug_ignored_stype(sType) \
> - anv_debug("debug: %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(const char *file, int line, const char *format, ...)
> - anv_printflike(3, 4);
> -void anv_loge(const char *format, ...) anv_printflike(1, 2);
> -void anv_loge_v(const char *format, va_list va);
> + intel_logd("%s: ignored VkStructureType %u", __func__, (sType))
>
> /**
> * Print a FINISHME message, including its source location.
> @@ -244,7 +238,8 @@ void anv_loge_v(const char *format, va_list va);
> 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)
> @@ -256,7 +251,8 @@ void anv_loge_v(const char *format, va_list va);
> do { \
> static bool reported = false; \
> if (!reported && unlikely(INTEL_DEBUG & DEBUG_PERF)) { \
> - __anv_perf_warn(__FILE__, __LINE__, format, ##__VA_ARGS__); \
> + intel_logw("%s:%d: PERF: " format, __FILE__, __LINE__, \
> + ##__VA_ARGS__); \
> reported = true; \
> } \
> } while (0)
> @@ -265,7 +261,7 @@ void anv_loge_v(const char *format, va_list va);
> #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 4b916e27f2c..8357fea8e79 100644
> --- a/src/intel/vulkan/anv_util.c
> +++ b/src/intel/vulkan/anv_util.c
> @@ -32,52 +32,6 @@
> #include "vk_enum_to_str.h"
> #include "util/debug.h"
>
> -/** Log an error message. */
> -void anv_printflike(1, 2)
> -anv_loge(const char *format, ...)
> -{
> - va_list va;
> -
> - va_start(va, format);
> - anv_loge_v(format, va);
> - va_end(va);
> -}
> -
> -/** \see anv_loge() */
> -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);
> -}
> -
> -void anv_printflike(3, 4)
> -__anv_perf_warn(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: PERF: %s\n", file, line, buffer);
> -}
> -
> VkResult
> __vk_errorf(VkResult error, const char *file, int line, const char
> *format, ...)
> {
> @@ -91,9 +45,9 @@ __vk_errorf(VkResult error, const char *file, int line,
> const char *format, ...)
> vsnprintf(buffer, sizeof(buffer), format, ap);
> va_end(ap);
>
> - fprintf(stderr, "%s:%d: %s (%s)\n", file, line, buffer, error_str);
> + intel_loge("%s:%d: %s (%s)", file, line, buffer, error_str);
> } else {
> - fprintf(stderr, "%s:%d: %s\n", file, line, error_str);
> + intel_loge("%s:%d: %s", file, line, error_str);
> }
>
> if (error == VK_ERROR_DEVICE_LOST &&
> diff --git a/src/intel/vulkan/genX_cmd_buffer.c
> b/src/intel/vulkan/genX_cmd_buffer.c
> index db40b45c29a..7d7c5fbf9b1 100644
> --- a/src/intel/vulkan/genX_cmd_buffer.c
> +++ b/src/intel/vulkan/genX_cmd_buffer.c
> @@ -1117,7 +1117,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);
> }
>
> @@ -2274,7 +2274,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
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170902/12d98a52/attachment.html>
More information about the mesa-dev
mailing list