From: Mike Blumenkrantz Date: Fri, 7 Jan 2022 17:56:31 +0000 (-0500) Subject: zink: allow sparse buffers to be suballocated X-Git-Tag: upstream/22.3.5~13738 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7753ca2a452d178bcb782b904a0b63b0028c3995;p=platform%2Fupstream%2Fmesa.git zink: allow sparse buffers to be suballocated this is now symmetrical since the backing memory was being cached, and there's no reason not to allow this since memory is no longer in use by the time it gets returned to the cache Acked-by: Dave Airlie Part-of: --- diff --git a/src/gallium/drivers/zink/zink_bo.c b/src/gallium/drivers/zink/zink_bo.c index 017a964..60d21cf 100644 --- a/src/gallium/drivers/zink/zink_bo.c +++ b/src/gallium/drivers/zink/zink_bo.c @@ -357,7 +357,7 @@ sparse_backing_alloc(struct zink_screen *screen, struct zink_bo *bo, size = MAX2(size, ZINK_SPARSE_BUFFER_PAGE_SIZE); buf = zink_bo_create(screen, size, ZINK_SPARSE_BUFFER_PAGE_SIZE, - ZINK_HEAP_DEVICE_LOCAL, ZINK_ALLOC_NO_SUBALLOC, NULL); + ZINK_HEAP_DEVICE_LOCAL, 0, NULL); if (!buf) { FREE(best_backing->chunks); FREE(best_backing); @@ -708,8 +708,8 @@ buffer_commit_single(struct zink_screen *screen, struct zink_resource *res, stru VkSparseMemoryBind mem_bind; mem_bind.resourceOffset = offset; mem_bind.size = MIN2(res->base.b.width0 - offset, size); - mem_bind.memory = commit ? bo->mem : VK_NULL_HANDLE; - mem_bind.memoryOffset = 0; + mem_bind.memory = commit ? (bo->mem ? bo->mem : bo->u.slab.real->mem) : VK_NULL_HANDLE; + mem_bind.memoryOffset = commit ? (bo->mem ? 0 : bo->offset) : 0; mem_bind.flags = 0; sparse_bind.pBinds = &mem_bind; @@ -841,8 +841,8 @@ texture_commit_single(struct zink_screen *screen, struct zink_resource *res, str ibind.subresource = *subresource; ibind.offset = *offset; ibind.extent = *extents; - ibind.memory = commit ? bo->mem : VK_NULL_HANDLE; - ibind.memoryOffset = 0; + ibind.memory = commit ? (bo->mem ? bo->mem : bo->u.slab.real->mem) : VK_NULL_HANDLE; + ibind.memoryOffset = commit ? (bo->mem ? 0 : bo->offset) : 0; ibind.flags = 0; sparse_ibind.image = res->obj->image; sparse_ibind.bindCount = 1;