nvc0/ir: fix TargetNVC0::insnCanLoadOffset()
[mesa.git] / src / gallium / drivers / freedreno / freedreno_context.c
index e138ac94ae3cd4ae492d1288e6841d8ef5498bd6..9c6a21ca5b8bd8ef6e8f7c4dd921adc43980400f 100644 (file)
@@ -27,6 +27,7 @@
  */
 
 #include "freedreno_context.h"
+#include "freedreno_blitter.h"
 #include "freedreno_draw.h"
 #include "freedreno_fence.h"
 #include "freedreno_program.h"
@@ -46,6 +47,8 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
        struct fd_context *ctx = fd_context(pctx);
        struct pipe_fence_handle *fence = NULL;
 
+       DBG("%p: flush: flags=%x\n", ctx->batch, flags);
+
        /* Take a ref to the batch's fence (batch can be unref'd when flushed: */
        fd_fence_ref(pctx->screen, &fence, ctx->batch->fence);
 
@@ -54,6 +57,8 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
 
        if (!ctx->screen->reorder) {
                fd_batch_flush(ctx->batch, true, false);
+       } else if (flags & PIPE_FLUSH_DEFERRED) {
+               fd_bc_flush_deferred(&ctx->screen->batch_cache, ctx);
        } else {
                fd_bc_flush(&ctx->screen->batch_cache, ctx);
        }
@@ -75,6 +80,13 @@ fd_texture_barrier(struct pipe_context *pctx, unsigned flags)
        fd_context_flush(pctx, NULL, 0);
 }
 
+static void
+fd_memory_barrier(struct pipe_context *pctx, unsigned flags)
+{
+       fd_context_flush(pctx, NULL, 0);
+       /* TODO do we need to check for persistently mapped buffers and fd_bo_cpu_prep()?? */
+}
+
 /**
  * emit marker string as payload of a no-op packet, which can be
  * decoded by cffdump.
@@ -153,9 +165,10 @@ fd_context_destroy(struct pipe_context *pctx)
        fd_pipe_del(ctx->pipe);
 
        if (fd_mesa_debug & (FD_DBG_BSTAT | FD_DBG_MSGS)) {
-               printf("batch_total=%u, batch_sysmem=%u, batch_gmem=%u, batch_restore=%u\n",
+               printf("batch_total=%u, batch_sysmem=%u, batch_gmem=%u, batch_nondraw=%u, batch_restore=%u\n",
                        (uint32_t)ctx->stats.batch_total, (uint32_t)ctx->stats.batch_sysmem,
-                       (uint32_t)ctx->stats.batch_gmem, (uint32_t)ctx->stats.batch_restore);
+                       (uint32_t)ctx->stats.batch_gmem, (uint32_t)ctx->stats.batch_nondraw,
+                       (uint32_t)ctx->stats.batch_restore);
        }
 
        FREE(ctx);
@@ -255,10 +268,19 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
 {
        struct fd_screen *screen = fd_screen(pscreen);
        struct pipe_context *pctx;
+       unsigned prio = 1;
        int i;
 
+       /* lower numerical value == higher priority: */
+       if (fd_mesa_debug & FD_DBG_HIPRIO)
+               prio = 0;
+       else if (flags & PIPE_CONTEXT_HIGH_PRIORITY)
+               prio = 0;
+       else if (flags & PIPE_CONTEXT_LOW_PRIORITY)
+               prio = 2;
+
        ctx->screen = screen;
-       ctx->pipe = fd_pipe_new(screen->dev, FD_PIPE_3D);
+       ctx->pipe = fd_pipe_new2(screen->dev, FD_PIPE_3D, prio);
 
        ctx->primtypes = primtypes;
        ctx->primtype_mask = 0;
@@ -280,6 +302,7 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
        pctx->create_fence_fd = fd_create_fence_fd;
        pctx->fence_server_sync = fd_fence_server_sync;
        pctx->texture_barrier = fd_texture_barrier;
+       pctx->memory_barrier = fd_memory_barrier;
 
        pctx->stream_uploader = u_upload_create_default(pctx);
        if (!pctx->stream_uploader)
@@ -290,6 +313,9 @@ fd_context_init(struct fd_context *ctx, struct pipe_screen *pscreen,
 
        slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
 
+       if (!ctx->blit)
+               ctx->blit = fd_blitter_blit;
+
        fd_draw_init(pctx);
        fd_resource_context_init(pctx);
        fd_query_context_init(pctx);