venus: suballocate memory in more cases

When a dedicated allocation is not required, ignore it and suballocate.

Fixes dEQP-VK.api.invariance.random.

Cc: 21.2 mesa-stable
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12072>
This commit is contained in:
Chia-I Wu
2021-07-26 18:09:39 -07:00
committed by Marge Bot
parent f06b0df741
commit 567bbfd56b
+25 -3
View File
@@ -14,7 +14,9 @@
#include "venus-protocol/vn_protocol_driver_transport.h"
#include "vn_android.h"
#include "vn_buffer.h"
#include "vn_device.h"
#include "vn_image.h"
/* device memory commands */
@@ -188,9 +190,29 @@ vn_device_memory_should_suballocate(const VkMemoryAllocateInfo *alloc_info,
if (alloc_info->allocationSize > 64 * 1024)
return false;
/* reject if there is any pnext struct */
if (alloc_info->pNext)
return false;
/* reject if there is any pnext struct other than
* VkMemoryDedicatedAllocateInfo, or if dedicated allocation is required
*/
if (alloc_info->pNext) {
const VkMemoryDedicatedAllocateInfo *dedicated = alloc_info->pNext;
if (dedicated->sType !=
VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO ||
dedicated->pNext)
return false;
const struct vn_image *img = vn_image_from_handle(dedicated->image);
if (img) {
for (uint32_t i = 0; i < ARRAY_SIZE(img->dedicated_requirements);
i++) {
if (img->dedicated_requirements[i].requiresDedicatedAllocation)
return false;
}
}
const struct vn_buffer *buf = vn_buffer_from_handle(dedicated->buffer);
if (buf && buf->dedicated_requirements.requiresDedicatedAllocation)
return false;
}
return true;
}