#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)
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:
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;
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
process_chunk(ctx, chunk);
free_chunk(chunk);
}
+
+ fflush(ctx->log_out);
}
void
return;
if (list_is_empty(&ctx->log_chunks)) {
- printf("WARNING: no log chunks!\n");
+ fprintf(ctx->log_out, "WARNING: no log chunks!\n");
return;
}