From 27d405dc2fddb5b814476a4e055358fd1efa7a4d Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Tue, 18 Jan 2022 13:06:55 -0500 Subject: [PATCH] zink: clamp tbo creation to maxTexelBufferElements for sparse buffers, the total buffer size will be huge, so this needs to only be the limit that the driver can support to avoid crashing or whatever cc: mesa-stable Reviewed-by: Dave Airlie Part-of: --- src/gallium/drivers/zink/zink_context.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gallium/drivers/zink/zink_context.c b/src/gallium/drivers/zink/zink_context.c index fbc019aad84..86fb7c8d045 100644 --- a/src/gallium/drivers/zink/zink_context.c +++ b/src/gallium/drivers/zink/zink_context.c @@ -656,6 +656,9 @@ create_bvci(struct zink_context *ctx, struct zink_resource *res, enum pipe_forma assert(bvci.format); bvci.offset = offset; bvci.range = !offset && range == res->base.b.width0 ? VK_WHOLE_SIZE : range; + uint32_t clamp = util_format_get_blocksize(format) * screen->info.props.limits.maxTexelBufferElements; + if (bvci.range == VK_WHOLE_SIZE && res->base.b.width0 > clamp) + bvci.range = clamp; bvci.flags = 0; return bvci; }