[Mesa-dev] [PATCH v2 21/37] panfrost: Allocate tiler and scratchpad BOs per-batch

Alyssa Rosenzweig alyssa at rosenzweig.io
Mon Sep 16 12:40:13 UTC 2019


> Note to Alyssa: I tried removing the dummy_tiler BO replacing it by a
> dummy value (tried both 0xdeafbeef and 0x0) and unfortunately it
> crashed, so I decided to keep this dummy allocation for now.

Very well. That'd be a neat but very low prio RE task, so *shrug*

> -static void
> -panfrost_setup_hardware(struct panfrost_context *ctx)
> -{
> -        struct pipe_context *gallium = (struct pipe_context *) ctx;
> -        struct panfrost_screen *screen = pan_screen(gallium->screen);
> -
> -        ctx->scratchpad = panfrost_bo_create(screen, 64 * 4 * 4096, 0);
> -        ctx->tiler_heap = panfrost_bo_create(screen, 4096 * 4096,
> -                                                 PAN_BO_INVISIBLE |
> -                                                 PAN_BO_GROWABLE);
> -        ctx->tiler_dummy = panfrost_bo_create(screen, 4096,
> -                                                  PAN_BO_INVISIBLE);
> -        assert(ctx->scratchpad && ctx->tiler_heap && ctx->tiler_dummy);
> -}
> -
>  /* New context creation, which also does hardware initialisation since I don't
>   * know the better way to structure this :smirk: */

Glad to see that function gone. Could you remove the comment as well?

> +struct panfrost_bo *
> +panfrost_batch_get_scratchpad(struct panfrost_batch *batch)
> +{
> +        if (batch->scratchpad)
> +                return batch->scratchpad;
> +
> +        batch->scratchpad = panfrost_batch_create_bo(batch, 64 * 4 * 4096,
> +                                                     PAN_BO_INVISIBLE);
> +        assert(batch->scratchpad);
> +        return batch->scratchpad;
> +}

FWIW, the size of the scratchpad is computed from the amount of stack
memory used by a given shader (known at shader compile-time), summed
across all the shaders using stack memory in the batch, times a thread
constant we get from the kernel parameter.

We don't actually do this computation yet; we probably should. But it
should give you some idea of what will be needed here.

---

Conditional on removing the :smirk: comment, R-b


More information about the mesa-dev mailing list