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: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22353>
This commit is contained in:
Asahi Lina
2023-04-05 15:39:46 +09:00
committed by Marge Bot
parent 883ba4b161
commit 0a132b0640
4 changed files with 19 additions and 11 deletions

View File

@@ -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;
}

View File

@@ -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;
}
}

View File

@@ -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);

View File

@@ -26,6 +26,14 @@
#include "util/u_range.h"
#include "agx_meta.h"
#ifdef __GLIBC__
#include <errno.h>
#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;