From 0a132b06406debc79565a7eb4dbe02e9f793e5cc Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Wed, 5 Apr 2023 15:39:46 +0900 Subject: [PATCH] asahi: Add a helper macro for debug/error messages This includes the program short name in the message, which is useful when running entire desktop sessions with a single log to figure out who is doing what. Part-of: --- src/gallium/drivers/asahi/agx_fence.c | 8 ++++---- src/gallium/drivers/asahi/agx_pipe.c | 10 +++++----- src/gallium/drivers/asahi/agx_state.c | 4 ++-- src/gallium/drivers/asahi/agx_state.h | 8 ++++++++ 4 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/asahi/agx_fence.c b/src/gallium/drivers/asahi/agx_fence.c index ad8e281..6cb16f6 100644 --- a/src/gallium/drivers/asahi/agx_fence.c +++ b/src/gallium/drivers/asahi/agx_fence.c @@ -82,20 +82,20 @@ agx_fence_from_fd(struct agx_context *ctx, int fd, enum pipe_fd_type type) if (type == PIPE_FD_TYPE_NATIVE_SYNC) { ret = drmSyncobjCreate(dev->fd, 0, &f->syncobj); if (ret) { - fprintf(stderr, "create syncobj failed\n"); + agx_msg("create syncobj failed\n"); goto err_free_fence; } ret = drmSyncobjImportSyncFile(dev->fd, f->syncobj, fd); if (ret) { - fprintf(stderr, "import syncfile failed\n"); + agx_msg("import syncfile failed\n"); goto err_destroy_syncobj; } } else { assert(type == PIPE_FD_TYPE_SYNCOBJ); ret = drmSyncobjFDToHandle(dev->fd, fd, &f->syncobj); if (ret) { - fprintf(stderr, "import syncobj FD failed\n"); + agx_msg("import syncobj FD failed\n"); goto err_free_fence; } } @@ -125,7 +125,7 @@ agx_fence_create(struct agx_context *ctx) ret = drmSyncobjExportSyncFile(dev->fd, ctx->syncobj, &fd); assert(ret >= 0 && fd != -1 && "export failed"); if (ret || fd == -1) { - fprintf(stderr, "export failed\n"); + agx_msg("export failed\n"); return NULL; } diff --git a/src/gallium/drivers/asahi/agx_pipe.c b/src/gallium/drivers/asahi/agx_pipe.c index 18d7270..fb2e00a 100644 --- a/src/gallium/drivers/asahi/agx_pipe.c +++ b/src/gallium/drivers/asahi/agx_pipe.c @@ -474,7 +474,7 @@ agx_resource_create_with_modifiers(struct pipe_screen *screen, renderonly_scanout_for_resource(&scanout_tmpl, dev->ro, &handle); if (!nresource->scanout) { - fprintf(stderr, "Failed to create scanout resource\n"); + agx_msg("Failed to create scanout resource\n"); free(nresource); return NULL; } @@ -1963,10 +1963,10 @@ agx_screen_create(int fd, struct renderonly *ro, struct sw_winsys *winsys) static bool warned_about_hacks = false; if (!warned_about_hacks) { - fprintf(stderr, "\n------------------\n" - "Unsupported debug parameter set. Expect breakage.\n" - "Do not report bugs.\n" - "------------------\n\n"); + agx_msg("\n------------------\n" + "Unsupported debug parameter set. Expect breakage.\n" + "Do not report bugs.\n" + "------------------\n\n"); warned_about_hacks = true; } } diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index b3be212..52eba19 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -379,8 +379,8 @@ agx_create_rs_state(struct pipe_context *ctx, * implementation lowers to multiple draws with culling. Warn. */ if (unlikely(cso->fill_front != cso->fill_back)) { - fprintf(stderr, "Warning: Two-sided fill modes are unsupported, " - "rendering may be incorrect.\n"); + agx_msg("Warning: Two-sided fill modes are unsupported, " + "rendering may be incorrect.\n"); } so->polygon_mode = agx_translate_polygon_mode(cso->fill_front); diff --git a/src/gallium/drivers/asahi/agx_state.h b/src/gallium/drivers/asahi/agx_state.h index cc2a5d8..74afda3 100644 --- a/src/gallium/drivers/asahi/agx_state.h +++ b/src/gallium/drivers/asahi/agx_state.h @@ -26,6 +26,14 @@ #include "util/u_range.h" #include "agx_meta.h" +#ifdef __GLIBC__ +#include +#define agx_msg(fmt, ...) \ + fprintf(stderr, "[%s] " fmt, program_invocation_short_name, ##__VA_ARGS__) +#else +#define agx_msg(...) fprintf(stderr, __VA_ARGS) +#endif + struct agx_streamout_target { struct pipe_stream_output_target base; uint32_t offset; -- 2.7.4