asahi: don't ralloc in agx_fast_link

let the driver allocate upfront so we can suballoc etc.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29179>
This commit is contained in:
Alyssa Rosenzweig 2024-04-24 09:16:41 -04:00 committed by Marge Bot
parent c1d68da5e2
commit ee9dab83e7
3 changed files with 13 additions and 15 deletions

View File

@ -73,13 +73,12 @@ static const uint8_t sample_loop_footer[] = {
#define SAMPLE_LOOP_FOOTER_COUNT_SHIFT (4)
/* clang-format on */
struct agx_linked_shader *
agx_fast_link(void *memctx, struct agx_device *dev, bool fragment,
struct agx_shader_part *main, struct agx_shader_part *prolog,
struct agx_shader_part *epilog, unsigned nr_samples_shaded)
void
agx_fast_link(struct agx_linked_shader *linked, struct agx_device *dev,
bool fragment, struct agx_shader_part *main,
struct agx_shader_part *prolog, struct agx_shader_part *epilog,
unsigned nr_samples_shaded)
{
struct agx_linked_shader *linked = rzalloc(memctx, struct agx_linked_shader);
size_t size = 0;
unsigned nr_gprs = 0, scratch_size = 0;
bool reads_tib = false, writes_sample_mask = false,
@ -238,6 +237,4 @@ agx_fast_link(void *memctx, struct agx_device *dev, bool fragment,
cfg.frag_coord_z = linked->cf.reads_z;
}
}
return linked;
}

View File

@ -37,10 +37,10 @@ struct agx_linked_shader {
struct agx_fragment_control_packed fragment_control;
};
struct agx_linked_shader *
agx_fast_link(void *memctx, struct agx_device *dev, bool fragment,
struct agx_shader_part *main, struct agx_shader_part *prolog,
struct agx_shader_part *epilog, unsigned nr_samples_shaded);
void agx_fast_link(struct agx_linked_shader *linked, struct agx_device *dev,
bool fragment, struct agx_shader_part *main,
struct agx_shader_part *prolog,
struct agx_shader_part *epilog, unsigned nr_samples_shaded);
/* These parts of the vertex element affect the generated code */
struct agx_velem_key {

View File

@ -2160,9 +2160,10 @@ asahi_fast_link(struct agx_context *ctx, struct agx_uncompiled_shader *so,
/* Fast-link it all together */
struct agx_device *dev = agx_device(ctx->base.screen);
struct agx_linked_shader *linked = agx_fast_link(
so->linked_shaders, dev, so->type == PIPE_SHADER_FRAGMENT, &key->main->b,
&prolog->b, &epilog->b, key->nr_samples_shaded);
struct agx_linked_shader *linked =
rzalloc(so->linked_shaders, struct agx_linked_shader);
agx_fast_link(linked, dev, so->type == PIPE_SHADER_FRAGMENT, &key->main->b,
&prolog->b, &epilog->b, key->nr_samples_shaded);
/* Cache the fast linked program */
union asahi_shader_key *cloned_key =