[Mesa-dev] [PATCH] anv: Limit VkDeviceMemory objects to 2GB
Jason Ekstrand
jason at jlekstrand.net
Tue Apr 11 18:08:51 UTC 2017
On Tue, Apr 11, 2017 at 11:03 AM, Ilia Mirkin <imirkin at alum.mit.edu> wrote:
> On Tue, Apr 11, 2017 at 1:58 PM, Jason Ekstrand <jason at jlekstrand.net>
> wrote:
> > Cc: "Juan A. Suárez" <jasuarez at igalia.com>
> > ---
> > src/intel/vulkan/anv_device.c | 17 +++++++++++++++++
> > 1 file changed, 17 insertions(+)
> >
> > diff --git a/src/intel/vulkan/anv_device.c
> b/src/intel/vulkan/anv_device.c
> > index 35ef4c4..b24c739 100644
> > --- a/src/intel/vulkan/anv_device.c
> > +++ b/src/intel/vulkan/anv_device.c
> > @@ -1539,6 +1539,23 @@ VkResult anv_AllocateMemory(
> > assert(pAllocateInfo->memoryTypeIndex == 0 ||
> > (!device->info.has_llc && pAllocateInfo->memoryTypeIndex <
> 2));
> >
> > + /* The kernel relocation API has a limitation of a 32-bit delta value
> > + * applied to the address before it is written which, in spite of it
> being
> > + * unsigned, is treated as signed . Because of the way that this
> maps to
> > + * the Vulkan API, we cannot handle an offset into a buffer that
> does not
> > + * fit into a signed 31 bits. The only mechanism we have for
> dealing with
>
> 32 bits?
>
Yup.
> > + * this at the moment is to limit all VkDeviceMemory objects to a
> maximum
> > + * of 2GB each. The Vulkan spec allows us to do this:
> > + *
> > + * "Some platforms may have a limit on the maximum size of a
> single
> > + * allocation. For example, certain systems may fail to create
> > + * allocations with a size greater than or equal to 4GB. Such a
> limit is
> > + * implementation-dependent, and if such a failure occurs then
> the error
> > + * VK_ERROR_OUT_OF_DEVICE_MEMORY should be returned."
> > + */
> > + if (pAllocationInfo->allocationSize > (1ull << 31))
>
> 1<<31 is not representable in a 32-bit signed int. did you mean >= ?
>
No. You can't validly have a 2GB offset into a 2GB buffer because you nee
some space after it to put the thing you're binding. Anything over 2GB, on
the other hand, has a potential problem.
> > + return VK_ERROR_OUT_OF_HOST_MEMORY;
>
> The comment above would suggest OUT_OF_DEVICE_MEMORY...
>
Bah! Thanks! I'll send a v3.
> > +
> > /* FINISHME: Fail if allocation request exceeds heap size. */
> >
> > mem = vk_alloc2(&device->alloc, pAllocator, sizeof(*mem), 8,
> > --
> > 2.5.0.400.gff86faf
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20170411/83b2cbfc/attachment-0001.html>
More information about the mesa-dev
mailing list