libagx: do not include heap in geometry params

the only dynamic allocation left for geometry shaders is all done in the setup
indirect kernel. so just pass the heap to that kernel directly, so we don't
reserve a heap for direct draws with GS (including pure-VS XFB). this should
reduce our memory footprint a lot in certain apps.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Mary Guillemard <mary.guillemard@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34661>
This commit is contained in:
Alyssa Rosenzweig 2025-04-23 10:09:55 -04:00 committed by Marge Bot
parent cb52aa58d6
commit 29cc2b6d42
4 changed files with 10 additions and 13 deletions

View file

@ -556,7 +556,7 @@ libagx_setup_xfb_buffer(global struct agx_geometry_params *p, uint i)
}
void
libagx_end_primitive(global int *index_buffer, uint total_verts,
libagx_end_primitive(global uint32_t *index_buffer, uint total_verts,
uint verts_in_prim, uint total_prims, uint index_offs,
uint geometry_base, bool restart)
{
@ -579,6 +579,7 @@ libagx_gs_setup_indirect(
global uintptr_t *vertex_buffer /* output */,
global struct agx_ia_state *ia /* output */,
global struct agx_geometry_params *p /* output */,
global struct agx_geometry_state *state,
uint64_t vs_outputs /* Vertex (TES) output mask */,
uint32_t index_size_B /* 0 if no index bffer */,
uint32_t index_buffer_range_el,
@ -618,8 +619,6 @@ libagx_gs_setup_indirect(
}
/* We need to allocate VS and GS count buffers, do so now */
global struct agx_geometry_state *state = p->state;
uint vertex_buffer_size =
libagx_tcs_in_size(vertex_count * instance_count, vs_outputs);

View file

@ -170,9 +170,6 @@ libagx_index_buffer_range_el(uint size_el, uint offset_el)
}
struct agx_geometry_params {
/* Persistent (cross-draw) geometry state */
DEVICE(struct agx_geometry_state) state;
/* Address of associated indirect draw buffer */
DEVICE(uint) indirect_desc;
@ -249,7 +246,7 @@ struct agx_geometry_params {
*/
uint32_t input_topology;
} PACKED;
static_assert(sizeof(struct agx_geometry_params) == 88 * 4);
static_assert(sizeof(struct agx_geometry_params) == 86 * 4);
/* TCS shared memory layout:
*

View file

@ -1112,7 +1112,6 @@ hk_upload_geometry_params(struct hk_cmd_buffer *cmd, struct agx_draw draw)
}
struct agx_geometry_params params = {
.state = hk_geometry_state(cmd),
.flat_outputs = fs->info.fs.interp.flat,
.input_topology = mode,
@ -1450,6 +1449,7 @@ hk_launch_gs_prerast(struct hk_cmd_buffer *cmd, struct hk_cs *cs,
/* Setup grids */
if (agx_is_indirect(draw.b)) {
struct libagx_gs_setup_indirect_args gsi = {
.state = hk_geometry_state(cmd),
.index_buffer = draw.index_buffer,
.draw = draw.b.ptr,
.ia = desc->root.draw.input_assembly,

View file

@ -3981,7 +3981,6 @@ agx_batch_geometry_params(struct agx_batch *batch, uint64_t input_index_buffer,
agx_pool_upload_aligned(&batch->pool, &ia, sizeof(ia), 8);
struct agx_geometry_params params = {
.state = agx_batch_geometry_state(batch),
.indirect_desc = batch->geom_indirect,
.flat_outputs =
batch->ctx->stage[PIPE_SHADER_FRAGMENT].shader->info.inputs_flat_shaded,
@ -4050,9 +4049,6 @@ agx_batch_geometry_params(struct agx_batch *batch, uint64_t input_index_buffer,
agx_pool_alloc_aligned(&batch->pool, 8, 8).gpu;
params.vs_grid[2] = params.gs_grid[2] = 1;
batch->geom_index_bo = agx_resource(batch->ctx->heap)->bo;
batch->geom_index = batch->geom_index_bo->va->addr;
} else {
params.vs_grid[0] = draw->count;
params.gs_grid[0] =
@ -4158,6 +4154,7 @@ agx_launch_gs_prerast(struct agx_batch *batch,
.vertex_buffer = batch->uniforms.vertex_output_buffer_ptr,
.ia = batch->uniforms.input_assembly,
.p = batch->uniforms.geometry_params,
.state = agx_batch_geometry_state(batch),
.vs_outputs = batch->uniforms.vertex_outputs,
.index_size_B = info->index_size,
.prim = info->mode,
@ -5142,7 +5139,7 @@ agx_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
/* Wrap the pool allocation in a fake resource for meta-Gallium use */
struct agx_resource indirect_rsrc = {.bo = batch->geom_indirect_bo};
struct agx_resource index_rsrc = {.bo = batch->geom_index_bo};
struct agx_resource index_rsrc = {};
if (ctx->gs) {
/* Launch the pre-rasterization parts of the geometry shader */
@ -5170,6 +5167,9 @@ agx_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
};
indirect = &indirect_gs;
batch->geom_index_bo = agx_resource(batch->ctx->heap)->bo;
batch->geom_index = batch->geom_index_bo->va->addr;
} else {
unsigned prims =
u_decomposed_prims_for_vertices(info->mode, draws->count);
@ -5186,6 +5186,7 @@ agx_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info,
}
info = &info_gs;
index_rsrc.bo = batch->geom_index_bo;
/* TODO: Deduplicate? */
batch->reduced_prim = u_reduced_prim(info->mode);