vallium: limit buffer allocations to gallium max.
authorDave Airlie <airlied@redhat.com>
Fri, 17 Jul 2020 01:30:25 +0000 (11:30 +1000)
committerDave Airlie <airlied@redhat.com>
Mon, 31 Aug 2020 00:28:21 +0000 (10:28 +1000)
Don't allocate buffers greater than gallium can handle.

Fixes:
dEQP-VK.api.buffer.basic.size_max_uint64

Fixes: b38879f8c5f57b7f1802 ("vallium: initial import of the vulkan frontend")
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6381>

src/gallium/frontends/vallium/val_image.c

index 29a493e77fe2374e9aa9d518f66c4f56488e089f..b40e5b9dccb59978697db96f706d5ca9c1dfeb5e 100644 (file)
@@ -198,6 +198,10 @@ VkResult val_CreateBuffer(
 
    assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
 
+   /* gallium has max 32-bit buffer sizes */
+   if (pCreateInfo->size > UINT32_MAX)
+      return VK_ERROR_OUT_OF_DEVICE_MEMORY;
+
    buffer = vk_alloc2(&device->alloc, pAllocator, sizeof(*buffer), 8,
                        VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
    if (buffer == NULL)