freedreno: Use the right amount of &'s
[mesa.git] / src / gallium / drivers / freedreno / freedreno_context.c
index e396d61c6cbca814f09c0a384e8353f3e96f47f0..c45a1583eac3c2d9f0436c6de311f4f675f40caf 100644 (file)
@@ -28,6 +28,7 @@
 #include "freedreno_blitter.h"
 #include "freedreno_draw.h"
 #include "freedreno_fence.h"
+#include "freedreno_log.h"
 #include "freedreno_program.h"
 #include "freedreno_resource.h"
 #include "freedreno_texture.h"
 #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)
@@ -89,6 +96,9 @@ out:
        fd_fence_ref(&ctx->last_fence, fence);
 
        fd_fence_ref(&fence, NULL);
+
+       if (flags & PIPE_FLUSH_END_OF_FRAME)
+               fd_log_eof(ctx);
 }
 
 static void
@@ -168,6 +178,13 @@ fd_context_destroy(struct pipe_context *pctx)
 
        DBG("");
 
+       fd_screen_lock(ctx->screen);
+       list_del(&ctx->node);
+       fd_screen_unlock(ctx->screen);
+
+       fd_log_process(ctx, true);
+       assert(list_is_empty(&ctx->log_chunks));
+
        fd_fence_ref(&ctx->last_fence, NULL);
 
        util_copy_framebuffer_state(&ctx->framebuffer, NULL);
@@ -363,10 +380,11 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
 
        (void) mtx_init(&ctx->gmem_lock, mtx_plain);
 
-       /* need some sane default in case state tracker doesn't
+       /* need some sane default in case gallium frontends don't
         * set some state:
         */
        ctx->sample_mask = 0xffff;
+       ctx->active_queries = true;
 
        pctx = &ctx->base;
        pctx->screen = pscreen;
@@ -385,9 +403,6 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
                goto fail;
        pctx->const_uploader = pctx->stream_uploader;
 
-       if (!ctx->screen->reorder)
-               ctx->batch = fd_bc_alloc_batch(&screen->batch_cache, ctx, false);
-
        slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
 
        fd_draw_init(pctx);
@@ -406,6 +421,33 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
 
        list_inithead(&ctx->hw_active_queries);
        list_inithead(&ctx->acc_active_queries);
+       list_inithead(&ctx->log_chunks);
+
+       fd_screen_lock(ctx->screen);
+       list_add(&ctx->node, &ctx->screen->context_list);
+       fd_screen_unlock(ctx->screen);
+
+       ctx->current_scissor = &ctx->disabled_scissor;
+
+       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;