mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 23:30:10 +01:00
venus: use buffer cache for vkGetDeviceBufferMemoryRequirements
Align with vkGetBufferMemoryRequirements2 and utilize the cache for retrieving memory requirements before trying the host call. Fixes dEQP-VK.api.invariance.memory_requirements_matching dEQP-VK.memory.requirements.create_info.buffer.regular Signed-off-by: Juston Li <justonli@google.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18603>
This commit is contained in:
parent
fe36f763d6
commit
fc1ff335d9
1 changed files with 39 additions and 23 deletions
|
|
@ -286,6 +286,35 @@ vn_buffer_cache_get_memory_requirements(
|
|||
return false;
|
||||
}
|
||||
|
||||
static void
|
||||
vn_copy_cached_memory_requirements(
|
||||
const struct vn_buffer_memory_requirements *cached,
|
||||
VkMemoryRequirements2 *out_mem_req)
|
||||
{
|
||||
union {
|
||||
VkBaseOutStructure *pnext;
|
||||
VkMemoryRequirements2 *two;
|
||||
VkMemoryDedicatedRequirements *dedicated;
|
||||
} u = { .two = out_mem_req };
|
||||
|
||||
while (u.pnext) {
|
||||
switch (u.pnext->sType) {
|
||||
case VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2:
|
||||
u.two->memoryRequirements = cached->memory.memoryRequirements;
|
||||
break;
|
||||
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
|
||||
u.dedicated->prefersDedicatedAllocation =
|
||||
cached->dedicated.prefersDedicatedAllocation;
|
||||
u.dedicated->requiresDedicatedAllocation =
|
||||
cached->dedicated.requiresDedicatedAllocation;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
u.pnext = u.pnext->pNext;
|
||||
}
|
||||
}
|
||||
|
||||
static VkResult
|
||||
vn_buffer_init(struct vn_device *dev,
|
||||
const VkBufferCreateInfo *create_info,
|
||||
|
|
@ -431,29 +460,9 @@ vn_GetBufferMemoryRequirements2(VkDevice device,
|
|||
VkMemoryRequirements2 *pMemoryRequirements)
|
||||
{
|
||||
const struct vn_buffer *buf = vn_buffer_from_handle(pInfo->buffer);
|
||||
union {
|
||||
VkBaseOutStructure *pnext;
|
||||
VkMemoryRequirements2 *two;
|
||||
VkMemoryDedicatedRequirements *dedicated;
|
||||
} u = { .two = pMemoryRequirements };
|
||||
|
||||
while (u.pnext) {
|
||||
switch (u.pnext->sType) {
|
||||
case VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2:
|
||||
u.two->memoryRequirements =
|
||||
buf->requirements.memory.memoryRequirements;
|
||||
break;
|
||||
case VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS:
|
||||
u.dedicated->prefersDedicatedAllocation =
|
||||
buf->requirements.dedicated.prefersDedicatedAllocation;
|
||||
u.dedicated->requiresDedicatedAllocation =
|
||||
buf->requirements.dedicated.requiresDedicatedAllocation;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
u.pnext = u.pnext->pNext;
|
||||
}
|
||||
vn_copy_cached_memory_requirements(&buf->requirements,
|
||||
pMemoryRequirements);
|
||||
}
|
||||
|
||||
VkResult
|
||||
|
|
@ -551,8 +560,15 @@ vn_GetDeviceBufferMemoryRequirements(
|
|||
VkMemoryRequirements2 *pMemoryRequirements)
|
||||
{
|
||||
struct vn_device *dev = vn_device_from_handle(device);
|
||||
struct vn_buffer_memory_requirements cached;
|
||||
|
||||
/* TODO per-device cache */
|
||||
if (vn_buffer_cache_get_memory_requirements(&dev->buffer_cache,
|
||||
pInfo->pCreateInfo, &cached)) {
|
||||
vn_copy_cached_memory_requirements(&cached, pMemoryRequirements);
|
||||
return;
|
||||
}
|
||||
|
||||
/* make the host call if not found in cache */
|
||||
vn_call_vkGetDeviceBufferMemoryRequirements(dev->instance, device, pInfo,
|
||||
pMemoryRequirements);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue