panfrost: Merge varyings_mem into transient buffers
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 16 Jul 2019 18:36:11 +0000 (11:36 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Wed, 17 Jul 2019 16:16:37 +0000 (09:16 -0700)
Theoretically we would like these split since varyings can have
specially optimized flags (no map, coherent local). For now, since
neither of these flags is particularly meaningful right now, merge them
together instead of special casing varyings_mem.

Saves upwards of 64MB of RAM per context.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_context.c
src/gallium/drivers/panfrost/pan_context.h
src/gallium/drivers/panfrost/pan_drm.c

index 49ca1f570f10bdc94fe22e29bfd89fa06649cf5b..929ffd1660589e681ae13410b1884ac708afb387 100644 (file)
@@ -255,9 +255,6 @@ panfrost_invalidate_frame(struct panfrost_context *ctx)
         ctx->payload_vertex.postfix.framebuffer = 0;
         ctx->payload_tiler.postfix.framebuffer = 0;
 
-        /* Reset varyings allocated */
-        ctx->varying_height = 0;
-
         if (ctx->rasterizer)
                 ctx->dirty |= PAN_DIRTY_RASTERIZER;
 
@@ -509,18 +506,17 @@ panfrost_emit_varyings(
         unsigned stride,
         unsigned count)
 {
-        mali_ptr varying_address = ctx->varying_mem.bo->gpu + ctx->varying_height;
-
         /* Fill out the descriptor */
-        slot->elements = varying_address | MALI_ATTR_LINEAR;
         slot->stride = stride;
         slot->size = stride * count;
         slot->shift = slot->extra_flags = 0;
 
-        ctx->varying_height += ALIGN_POT(slot->size, 64);
-        assert(ctx->varying_height < ctx->varying_mem.bo->size);
+        struct panfrost_transfer transfer =
+                panfrost_allocate_transient(ctx, slot->size);
+
+        slot->elements = transfer.gpu | MALI_ATTR_LINEAR;
 
-        return varying_address;
+        return transfer.gpu;
 }
 
 static void
@@ -2531,7 +2527,6 @@ panfrost_destroy(struct pipe_context *pipe)
                 util_blitter_destroy(panfrost->blitter_wallpaper);
 
         panfrost_drm_free_slab(screen, &panfrost->scratchpad);
-        panfrost_drm_free_slab(screen, &panfrost->varying_mem);
         panfrost_drm_free_slab(screen, &panfrost->shaders);
         panfrost_drm_free_slab(screen, &panfrost->tiler_heap);
         panfrost_drm_free_slab(screen, &panfrost->tiler_polygon_list);
@@ -2678,7 +2673,6 @@ panfrost_setup_hardware(struct panfrost_context *ctx)
         struct panfrost_screen *screen = pan_screen(gallium->screen);
 
         panfrost_drm_allocate_slab(screen, &ctx->scratchpad, 64, false, 0, 0, 0);
-        panfrost_drm_allocate_slab(screen, &ctx->varying_mem, 16384, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_COHERENT_LOCAL, 0, 0);
         panfrost_drm_allocate_slab(screen, &ctx->shaders, 4096, true, PAN_ALLOCATE_EXECUTE, 0, 0);
         panfrost_drm_allocate_slab(screen, &ctx->tiler_heap, 32768, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_GROWABLE, 1, 128);
         panfrost_drm_allocate_slab(screen, &ctx->tiler_polygon_list, 128*128, false, PAN_ALLOCATE_INVISIBLE | PAN_ALLOCATE_GROWABLE, 1, 128);
index b7c6bc51e46be2439f4215c88e29e588363a77b8..097de158e094751cffc612588fb50923821b6866 100644 (file)
@@ -107,7 +107,6 @@ struct panfrost_context {
         struct panfrost_memory shaders;
         struct panfrost_memory scratchpad;
         struct panfrost_memory tiler_heap;
-        struct panfrost_memory varying_mem;
         struct panfrost_memory tiler_polygon_list;
         struct panfrost_memory tiler_dummy;
         struct panfrost_memory depth_stencil_buffer;
@@ -136,8 +135,6 @@ struct panfrost_context {
 
         union mali_attr attributes[PIPE_MAX_ATTRIBS];
 
-        unsigned varying_height;
-
         struct mali_single_framebuffer vt_framebuffer_sfbd;
         struct bifrost_framebuffer vt_framebuffer_mfbd;
 
index 5bd2e340751f19ce9cbd789bc47acc36f7f03297..70051450cae4271adba20a16b7de4df5864eddd7 100644 (file)
@@ -284,7 +284,6 @@ panfrost_drm_submit_vs_fs_job(struct panfrost_context *ctx, bool has_draws, bool
         panfrost_job_add_bo(job, ctx->shaders.bo);
         panfrost_job_add_bo(job, ctx->scratchpad.bo);
         panfrost_job_add_bo(job, ctx->tiler_heap.bo);
-        panfrost_job_add_bo(job, ctx->varying_mem.bo);
         panfrost_job_add_bo(job, ctx->tiler_polygon_list.bo);
 
         if (job->first_job.gpu) {