zink: move memoryTypeIndex selection down in general bo allocation

no functional changes

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22567>
This commit is contained in:
Mike Blumenkrantz 2023-04-13 13:48:54 -04:00 committed by Eric Engestrom
parent 907621dc09
commit 27dd6245d3
2 changed files with 20 additions and 18 deletions

View file

@ -148,7 +148,7 @@
"description": "zink: move memoryTypeIndex selection down in general bo allocation",
"nominated": false,
"nomination_type": null,
"resolution": 4,
"resolution": 1,
"main_sha": null,
"because_sha": null
},

View file

@ -985,23 +985,6 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
mai.pNext = NULL;
mai.allocationSize = reqs.size;
enum zink_heap heap = zink_heap_from_domain_flags(flags, aflags);
mai.memoryTypeIndex = zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits);
if (mai.memoryTypeIndex == UINT32_MAX) {
/* not valid based on reqs; demote to more compatible type */
switch (heap) {
case ZINK_HEAP_DEVICE_LOCAL_VISIBLE:
heap = ZINK_HEAP_DEVICE_LOCAL;
break;
case ZINK_HEAP_HOST_VISIBLE_CACHED:
heap = ZINK_HEAP_HOST_VISIBLE_COHERENT;
break;
default:
break;
}
mai.memoryTypeIndex = zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits);
assert(mai.memoryTypeIndex != UINT32_MAX);
}
assert(reqs.memoryTypeBits & BITFIELD_BIT(mai.memoryTypeIndex));
VkMemoryDedicatedAllocateInfo ded_alloc_info = {
.sType = VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO,
@ -1077,6 +1060,25 @@ resource_object_create(struct zink_screen *screen, const struct pipe_resource *t
if (templ->usage == PIPE_USAGE_STAGING && obj->is_buffer)
alignment = MAX2(alignment, screen->info.props.limits.minMemoryMapAlignment);
obj->alignment = alignment;
mai.memoryTypeIndex = zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits);
if (mai.memoryTypeIndex == UINT32_MAX) {
/* not valid based on reqs; demote to more compatible type */
switch (heap) {
case ZINK_HEAP_DEVICE_LOCAL_VISIBLE:
heap = ZINK_HEAP_DEVICE_LOCAL;
break;
case ZINK_HEAP_HOST_VISIBLE_CACHED:
heap = ZINK_HEAP_HOST_VISIBLE_COHERENT;
break;
default:
break;
}
mai.memoryTypeIndex = zink_mem_type_idx_from_bits(screen, heap, reqs.memoryTypeBits);
assert(mai.memoryTypeIndex != UINT32_MAX);
}
assert(reqs.memoryTypeBits & BITFIELD_BIT(mai.memoryTypeIndex));
retry:
obj->bo = zink_bo(zink_bo_create(screen, reqs.size, alignment, heap, mai.pNext ? ZINK_ALLOC_NO_SUBALLOC : 0, mai.memoryTypeIndex, mai.pNext));
if (!obj->bo) {