From 36595e94c7043d365e39e2d8250ed80f1bafb320 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 9 Feb 2023 08:03:05 -0500 Subject: [PATCH] zink: avoid the descriptor set multiplier for bindless buffers the bindless descriptor buffer is already correctly sized, so it needs to avoid the huge set multiplier or it'll explode all available vram Part-of: --- src/gallium/drivers/zink/zink_descriptors.c | 2 +- src/gallium/drivers/zink/zink_resource.c | 3 ++- src/gallium/drivers/zink/zink_resource.h | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/zink/zink_descriptors.c b/src/gallium/drivers/zink/zink_descriptors.c index a8bf65b74f4..9a1c52770da 100644 --- a/src/gallium/drivers/zink/zink_descriptors.c +++ b/src/gallium/drivers/zink/zink_descriptors.c @@ -1489,7 +1489,7 @@ zink_descriptors_init_bindless(struct zink_context *ctx) unsigned bind = ZINK_BIND_RESOURCE_DESCRIPTOR | ZINK_BIND_SAMPLER_DESCRIPTOR; VkDeviceSize size; VKSCR(GetDescriptorSetLayoutSizeEXT)(screen->dev, screen->bindless_layout, &size); - struct pipe_resource *pres = pipe_buffer_create(&screen->base, bind, 0, size); + struct pipe_resource *pres = pipe_buffer_create(&screen->base, bind, ZINK_USAGE_BINDLESS, size); ctx->dd.db.bindless_db = zink_resource(pres); ctx->dd.db.bindless_db_map = pipe_buffer_map(&ctx->base, pres, PIPE_MAP_READ | PIPE_MAP_WRITE, &ctx->dd.db.bindless_db_xfer); zink_batch_bind_db(ctx); diff --git a/src/gallium/drivers/zink/zink_resource.c b/src/gallium/drivers/zink/zink_resource.c index b1c812eac46..006b7536867 100644 --- a/src/gallium/drivers/zink/zink_resource.c +++ b/src/gallium/drivers/zink/zink_resource.c @@ -180,7 +180,8 @@ create_bci(struct zink_screen *screen, const struct pipe_resource *templ, unsign if (bind & ZINK_BIND_DESCRIPTOR) { /* gallium sizes are all uint32_t, while the total size of this buffer may exceed that limit */ - bci.size *= ZINK_DESCRIPTOR_BUFFER_MULTIPLIER; + if (templ->usage != ZINK_USAGE_BINDLESS) + bci.size *= ZINK_DESCRIPTOR_BUFFER_MULTIPLIER; bci.usage = 0; if (bind & ZINK_BIND_SAMPLER_DESCRIPTOR) bci.usage |= VK_BUFFER_USAGE_SAMPLER_DESCRIPTOR_BUFFER_BIT_EXT; diff --git a/src/gallium/drivers/zink/zink_resource.h b/src/gallium/drivers/zink/zink_resource.h index 37da41827c9..2b368b1ca55 100644 --- a/src/gallium/drivers/zink/zink_resource.h +++ b/src/gallium/drivers/zink/zink_resource.h @@ -27,6 +27,7 @@ #include "zink_types.h" #define ZINK_MAP_TEMPORARY (PIPE_MAP_DRV_PRV << 0) +#define ZINK_USAGE_BINDLESS 128 //this is used for bindless descriptors #define ZINK_BIND_SAMPLER_DESCRIPTOR (1u << 26) #define ZINK_BIND_RESOURCE_DESCRIPTOR (1u << 27) #define ZINK_BIND_DESCRIPTOR (ZINK_BIND_SAMPLER_DESCRIPTOR | ZINK_BIND_RESOURCE_DESCRIPTOR)