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

Rob Herring robh at kernel.org
Fri Apr 22 21:34:36 UTC 2016


On Fri, Apr 22, 2016 at 1:21 PM, Eric Anholt <eric at anholt.net> wrote:
> Rob Herring <robh at kernel.org> writes:
>
>> This adds map and unmap functions to GBM utilizing the DRIimage extension
>> mapImage/unmapImage functions or existing internal mapping for dumb
>> buffers. 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>
>
>
>
>> @@ -981,6 +1033,8 @@ dri_device_create(int fd)
>>     dri->base.base.fd = fd;
>>     dri->base.base.bo_create = gbm_dri_bo_create;
>>     dri->base.base.bo_import = gbm_dri_bo_import;
>> +   dri->base.base.bo_map = gbm_dri_bo_map;
>> +   dri->base.base.bo_unmap = gbm_dri_bo_unmap;
>>     dri->base.base.is_format_supported = gbm_dri_is_format_supported;
>>     dri->base.base.bo_write = gbm_dri_bo_write;
>>     dri->base.base.bo_get_fd = gbm_dri_bo_get_fd;
>> @@ -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);
>> +
>>     return &dri->base.base;
>
> I don't think we want to always make a spare context just in case
> someone uses the map API.  Contexts can be pretty expensive to set up,
> in time (for piglit tests on gbm) and memory (for X.Org).

There was some discussion about this context in the last version. I
put it here for now for simplicity given what to do here is not clear.
It's not clear to me exactly what the concurrency guarantees there are
with GBM. I was assuming gbm_device_create doesn't need to be thread
safe, but creating and mapping BOs does.

Rob


More information about the mesa-dev mailing list