[Mesa-dev] [PATCH 4/4] gbm: Add map/unmap functions

Eric Anholt eric at anholt.net
Tue Apr 26 00:53:38 UTC 2016

Rob Herring <robh at kernel.org> writes:

> On Fri, Apr 22, 2016 at 9:08 PM, Rob Herring <robh at kernel.org> wrote:
>> On Fri, Apr 22, 2016 at 6:32 PM, Emil Velikov <emil.l.velikov at gmail.com> wrote:
>>> Hi Rob,
>>> On 22 April 2016 at 16:50, Rob Herring <robh at kernel.org> wrote:
>>>> This adds map and unmap functions to GBM utilizing the DRIimage extension
>>>> mapImage/unmapImage functions or existing internal mapping for dumb
>>>> buffers.
>>> Ftr that this is quite sensitive and apart from the obvious breakage
>>> (coming in a second) it will need some testing on a gnome-continuous
>>> setup (iirc some used to hand out in #xorg-devel)
>>>> Unlike prior attempts, this version provides a region to map and
>>>> usage flags for the mapping. The operation follows the same semantics as
>>>> the gallium transfer_map() function.
>>>> This was tested with GBM based gralloc on Android.
>>>> This still creates a context, but I've moved it into gbm_create_device
>>>> rather than in the map function. This should remove any need for reference
>>>> counting and problems with memory leaks.
>>>> Signed-off-by: Rob Herring <robh at kernel.org>
>> [...]
>>>> @@ -1004,6 +1058,10 @@ dri_device_create(int fd)
>>>>     if (ret)
>>>>        goto err_dri;
>>>> +   if (dri->image->base.version >= 12)
>>>> +      dri->context = dri->dri2->createNewContext(dri->screen, NULL,
>>>> +                                                 NULL, NULL);
>>>> +
>>> Have you measured how much this costs us (cpu time and/or memory) ?
>> No, will do.
> On Android (x86_64 + virgl), it is 2ms and ~2MB (out of 20). A
> standalone test with swrast is 4ms and ~4MB. I measured with
> getrusage().

Given that existing clients of GBM don't use this API, it's not OK to
add this cost to all of them.

If you need pthreads to protect the allocation check at map time,
there's this bit of configure.ac from libdrm so that you don't need to
force libgbm to pull in real pthreads and its overhead:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 818 bytes
Desc: not available
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20160425/2d119f49/attachment-0001.sig>

More information about the mesa-dev mailing list