From 1882527f786bd25a050a3e8e04de06aa88a7e377 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Wed, 21 Feb 2024 10:54:15 +0100 Subject: [PATCH] zink: decrease aggressiveness of increasing descriptor data space adaptive An increase by factor 10 with each re-allocation is a bit aggressive and we hit the available limit easily on lavapipe. By starting of with an initial larger scale, but decreasing this over time this error can be avoided. Specifically with "spec@arb_shader_texture_lod@execution@tex-miplevel-selection *gradarb 1d" originally the buffer sizes would be 250, 2500, 25000, and 250000, with the patch it's 250, 4000, and 32000. v2: use minimum scale of 4 instead of 2 (Mike) v3: fix typo (Mike) Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/zink/zink_descriptors.c | 8 ++++++-- src/gallium/drivers/zink/zink_types.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_descriptors.c b/src/gallium/drivers/zink/zink_descriptors.c index 731582497f2..2a3bfd2d3a1 100644 --- a/src/gallium/drivers/zink/zink_descriptors.c +++ b/src/gallium/drivers/zink/zink_descriptors.c @@ -1060,8 +1060,11 @@ enlarge_db(struct zink_context *ctx) struct zink_batch_state *bs = ctx->batch.state; /* ensure current db surives */ zink_batch_reference_resource(&ctx->batch, bs->dd.db); - /* rebinding a db mid-batch is extremely costly: scaling by 10x should ensure it never happens more than twice */ - ctx->dd.db.max_db_size *= 10; + /* rebinding a db mid-batch is extremely costly: if we start with a factor + * 16 and then half the factor with each new allocation. It shouldn't need to + * do this more than twice. */ + ctx->dd.db.max_db_size *= ctx->dd.db.size_enlarge_scale; + ctx->dd.db.size_enlarge_scale = MAX2(ctx->dd.db.size_enlarge_scale >> 1, 4); reinit_db(screen, bs); } @@ -1644,6 +1647,7 @@ zink_descriptors_init(struct zink_context *ctx) } /* start small */ ctx->dd.db.max_db_size = 250; + ctx->dd.db.size_enlarge_scale = 16; } return true; diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h index 6d5169caf83..c05b3187aaa 100644 --- a/src/gallium/drivers/zink/zink_types.h +++ b/src/gallium/drivers/zink/zink_types.h @@ -449,6 +449,7 @@ struct zink_descriptor_data { struct pipe_transfer *bindless_db_xfer; uint32_t bindless_db_offsets[4]; unsigned max_db_size; + unsigned size_enlarge_scale; } db; };