radv: add a size check in radv_create_buffer for Android

This is to make dEQP-VK.api.buffer.basic.size_max_uint64 pass on
android.

The test creates a buffer of size UINT64_MAX and makes sure the memory
requirement for the buffer is sane.  It fails because our memory
requirement is "align64(UINT64_MAX, 16)" which is 0 after overflow.

The test checks maintenance4's maxBufferSize and is skipped normally.
But the extension can be disabled on an android build.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21346>
This commit is contained in:
Chia-I Wu 2023-02-15 11:11:16 -08:00 committed by Marge Bot
parent e13074d763
commit 4459668b6e

View file

@ -6820,6 +6820,14 @@ radv_create_buffer(struct radv_device *device, const VkBufferCreateInfo *pCreate
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
#ifdef ANDROID
/* reject buffers that are larger than maxBufferSize on Android, which
* might not have VK_KHR_maintenance4
*/
if (pCreateInfo->size > RADV_MAX_MEMORY_ALLOCATION_SIZE)
return vk_error(device, VK_ERROR_OUT_OF_DEVICE_MEMORY);
#endif
buffer = vk_alloc2(&device->vk.alloc, pAllocator, sizeof(*buffer), 8,
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
if (buffer == NULL)