radeonsi/gfx10: update a tunable max_es_verts_base for NGG
[mesa.git] / src / gallium / drivers / lima / lima_context.c
index 35bf8c89a9ce33a5b8c23ec7fd6a3f3960d98079..558d2346653ede4cafb6fa61d152d454dce4069c 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #include "util/u_memory.h"
+#include "util/u_blitter.h"
 #include "util/u_upload_mgr.h"
 #include "util/u_math.h"
 #include "util/u_debug.h"
@@ -124,6 +125,9 @@ lima_context_destroy(struct pipe_context *pctx)
 
    lima_state_fini(ctx);
 
+   if (ctx->blitter)
+      util_blitter_destroy(ctx->blitter);
+
    if (ctx->suballocator)
       u_suballocator_destroy(ctx->suballocator);
 
@@ -135,6 +139,8 @@ lima_context_destroy(struct pipe_context *pctx)
    for (int i = 0; i < LIMA_CTX_PLB_MAX_NUM; i++) {
       if (ctx->plb[i])
          lima_bo_free(ctx->plb[i]);
+      if (ctx->gp_tile_heap[i])
+         lima_bo_free(ctx->gp_tile_heap[i]);
    }
 
    if (ctx->plb_gp_stream)
@@ -188,6 +194,10 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
 
    slab_create_child(&ctx->transfer_pool, &screen->transfer_pool);
 
+   ctx->blitter = util_blitter_create(&ctx->base);
+   if (!ctx->blitter)
+      goto err_out;
+
    ctx->uploader = u_upload_create_default(&ctx->base);
    if (!ctx->uploader)
       goto err_out;
@@ -204,17 +214,16 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
    util_dynarray_init(&ctx->vs_cmd_array, ctx);
    util_dynarray_init(&ctx->plbu_cmd_array, ctx);
 
-   if (screen->gpu_type == DRM_LIMA_PARAM_GPU_ID_MALI450)
-      ctx->plb_max_blk = 4096;
-   else
-      ctx->plb_max_blk = 512;
-   ctx->plb_size = ctx->plb_max_blk * LIMA_CTX_PLB_BLK_SIZE;
-   ctx->plb_gp_size = ctx->plb_max_blk * 4;
+   ctx->plb_size = screen->plb_max_blk * LIMA_CTX_PLB_BLK_SIZE;
+   ctx->plb_gp_size = screen->plb_max_blk * 4;
 
    for (int i = 0; i < lima_ctx_num_plb; i++) {
       ctx->plb[i] = lima_bo_create(screen, ctx->plb_size, 0);
       if (!ctx->plb[i])
          goto err_out;
+      ctx->gp_tile_heap[i] = lima_bo_create(screen, gp_tile_heap_size, 0);
+      if (!ctx->gp_tile_heap[i])
+         goto err_out;
    }
 
    unsigned plb_gp_stream_size =
@@ -228,7 +237,7 @@ lima_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags)
    /* plb gp stream is static for any framebuffer */
    for (int i = 0; i < lima_ctx_num_plb; i++) {
       uint32_t *plb_gp_stream = ctx->plb_gp_stream->map + i * ctx->plb_gp_size;
-      for (int j = 0; j < ctx->plb_max_blk; j++)
+      for (int j = 0; j < screen->plb_max_blk; j++)
          plb_gp_stream[j] = ctx->plb[i]->va + LIMA_CTX_PLB_BLK_SIZE * j;
    }
 
@@ -260,3 +269,15 @@ lima_need_flush(struct lima_context *ctx, struct lima_bo *bo, bool write)
    return lima_submit_has_bo(ctx->gp_submit, bo, write) ||
       lima_submit_has_bo(ctx->pp_submit, bo, write);
 }
+
+bool
+lima_is_scanout(struct lima_context *ctx)
+{
+        /* If there is no color buffer, it's an FBO */
+        if (!ctx->framebuffer.base.nr_cbufs)
+                return false;
+
+        return ctx->framebuffer.base.cbufs[0]->texture->bind & PIPE_BIND_DISPLAY_TARGET ||
+               ctx->framebuffer.base.cbufs[0]->texture->bind & PIPE_BIND_SCANOUT ||
+               ctx->framebuffer.base.cbufs[0]->texture->bind & PIPE_BIND_SHARED;
+}