freedreno/log: android support
In particular, when stdout doesn't go anywhere useful we need to log to file. Signed-off-by: Rob Clark <robdclark@chromium.org> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4510>
This commit is contained in:
parent
904d5d63b4
commit
b5b32387d6
|
@ -39,6 +39,12 @@
|
|||
#include "freedreno_util.h"
|
||||
#include "util/u_upload_mgr.h"
|
||||
|
||||
#if DETECT_OS_ANDROID
|
||||
#include "util/u_process.h"
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#endif
|
||||
|
||||
static void
|
||||
fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
|
||||
unsigned flags)
|
||||
|
@ -413,12 +419,26 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
|
|||
list_inithead(&ctx->acc_active_queries);
|
||||
list_inithead(&ctx->log_chunks);
|
||||
|
||||
ctx->log_out = stdout;
|
||||
|
||||
if ((fd_mesa_debug & FD_DBG_LOG) &&
|
||||
!(ctx->record_timestamp && ctx->ts_to_ns)) {
|
||||
printf("logging not supported!\n");
|
||||
fd_mesa_debug &= ~FD_DBG_LOG;
|
||||
}
|
||||
|
||||
#if DETECT_OS_ANDROID
|
||||
if (fd_mesa_debug && FD_DBG_LOG) {
|
||||
static unsigned idx = 0;
|
||||
char *p;
|
||||
asprintf(&p, "/data/fdlog/%s-%d.log", util_get_process_name(), idx++);
|
||||
|
||||
FILE *f = fopen(p, "w");
|
||||
if (f)
|
||||
ctx->log_out = f;
|
||||
}
|
||||
#endif
|
||||
|
||||
return pctx;
|
||||
|
||||
fail:
|
||||
|
|
|
@ -361,6 +361,7 @@ struct fd_context {
|
|||
|
||||
struct list_head log_chunks; /* list of flushed log chunks in fifo order */
|
||||
unsigned frame_nr; /* frame counter (for fd_log) */
|
||||
FILE *log_out;
|
||||
|
||||
/*
|
||||
* Common pre-cooked VBO state (used for a3xx and later):
|
||||
|
|
|
@ -109,7 +109,7 @@ free_chunk(struct fd_log_chunk *chunk)
|
|||
static void
|
||||
process_chunk(struct fd_context *ctx, struct fd_log_chunk *chunk)
|
||||
{
|
||||
printf("+----- TS -----+ +----- NS -----+ +-- Δ --+ +----- MSG -----\n");
|
||||
fprintf(ctx->log_out, "+----- TS -----+ +----- NS -----+ +-- Δ --+ +----- MSG -----\n");
|
||||
|
||||
uint64_t *timestamps = fd_bo_map(chunk->timestamps_bo);
|
||||
uint64_t last_time_ns = 0;
|
||||
|
@ -136,15 +136,15 @@ process_chunk(struct fd_context *ctx, struct fd_log_chunk *chunk)
|
|||
delta = 0;
|
||||
}
|
||||
|
||||
printf("%016"PRIu64" %016"PRIu64" %+9d: %s\n", ts, ns, delta, msg);
|
||||
fprintf(ctx->log_out, "%016"PRIu64" %016"PRIu64" %+9d: %s\n", ts, ns, delta, msg);
|
||||
free(msg);
|
||||
|
||||
}
|
||||
|
||||
printf("ELAPSED: %"PRIu64" ns\n", last_time_ns - first_time_ns);
|
||||
fprintf(ctx->log_out, "ELAPSED: %"PRIu64" ns\n", last_time_ns - first_time_ns);
|
||||
|
||||
if (chunk->eof)
|
||||
printf("END OF FRAME %u\n", ctx->frame_nr++);
|
||||
fprintf(ctx->log_out, "END OF FRAME %u\n", ctx->frame_nr++);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -165,6 +165,8 @@ fd_log_process(struct fd_context *ctx, bool wait)
|
|||
process_chunk(ctx, chunk);
|
||||
free_chunk(chunk);
|
||||
}
|
||||
|
||||
fflush(ctx->log_out);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -217,7 +219,7 @@ void fd_log_eof(struct fd_context *ctx)
|
|||
return;
|
||||
|
||||
if (list_is_empty(&ctx->log_chunks)) {
|
||||
printf("WARNING: no log chunks!\n");
|
||||
fprintf(ctx->log_out, "WARNING: no log chunks!\n");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue