zink: fix sparse bo placement

the util function here takes a bitmask of memory type indices, not properties.
rename the function and correct the usage

fixes sparse on nvidia blob

Fixes: c71287e70c ("zink: correct sparse bo mem_type_idx placement")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27414>
(cherry picked from commit 3b025d6b42)
This commit is contained in:
Mike Blumenkrantz
2024-02-01 10:26:10 -05:00
committed by Eric Engestrom
parent 8e4ab92d42
commit c7750d900a
4 changed files with 6 additions and 6 deletions

View File

@@ -54,7 +54,7 @@
"description": "zink: fix sparse bo placement",
"nominated": true,
"nomination_type": 1,
"resolution": 0,
"resolution": 1,
"main_sha": null,
"because_sha": "c71287e70c2bf4aac96b24635e48ec13cd31fddf",
"notes": null

View File

@@ -549,7 +549,7 @@ bo_sparse_create(struct zink_screen *screen, uint64_t size)
bo->base.alignment_log2 = util_logbase2(ZINK_SPARSE_BUFFER_PAGE_SIZE);
bo->base.size = size;
bo->base.vtbl = &bo_sparse_vtbl;
unsigned placement = zink_mem_type_idx_from_bits(screen, ZINK_HEAP_DEVICE_LOCAL_SPARSE, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
unsigned placement = zink_mem_type_idx_from_types(screen, ZINK_HEAP_DEVICE_LOCAL_SPARSE, UINT32_MAX);
assert(placement != UINT32_MAX);
bo->base.placement = placement;
bo->unique_id = p_atomic_inc_return(&screen->pb.next_bo_unique_id);

View File

@@ -94,10 +94,10 @@ zink_heap_from_domain_flags(VkMemoryPropertyFlags domains, enum zink_alloc_flag
}
static ALWAYS_INLINE unsigned
zink_mem_type_idx_from_bits(struct zink_screen *screen, enum zink_heap heap, uint32_t bits)
zink_mem_type_idx_from_types(struct zink_screen *screen, enum zink_heap heap, uint32_t types)
{
for (unsigned i = 0; i < screen->heap_count[heap]; i++) {
if (bits & BITFIELD_BIT(screen->heap_map[heap][i])) {
if (types & BITFIELD_BIT(screen->heap_map[heap][i])) {
return screen->heap_map[heap][i];
}
}

View File

@@ -1266,7 +1266,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
alignment = MAX2(alignment, screen->info.props.limits.minMemoryMapAlignment);
obj->alignment = alignment;
if (zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits) == UINT32_MAX) {
if (zink_mem_type_idx_from_types(screen, heap, reqs.memoryTypeBits) == UINT32_MAX) {
/* not valid based on reqs; demote to more compatible type */
switch (heap) {
case ZINK_HEAP_DEVICE_LOCAL_VISIBLE:
@@ -1278,7 +1278,7 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
default:
break;
}
assert(zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits) != UINT32_MAX);
assert(zink_mem_type_idx_from_types(screen, heap, reqs.memoryTypeBits) != UINT32_MAX);
}
retry: