[Mesa-dev] [PATCH 10/15] gbm: Create a DRI image for dumb buffers, too.

Thomas Hellstrom thellstrom at vmware.com
Wed Nov 20 05:53:59 PST 2013


Hi!

As discussed also offline, this is not a good thing to do, for the 
following reasons:

1) The bo handle does not necessarily represent a gem object. Calling 
gem_flink on such a handle is illegal.
2) Dumb bos and BO_USE_RENDERING may be totally different objects.
It's incorrect to assume that a dumb bo handle can be typecasted to a 
rendering BO handle.
This is to avoid having to deal with coherence issues without having 
enough information to make it efficient.

There currently is no accepted API to allow direct mmaping of a 
GBM_BO_USE_RENDERING.
If we should invent one, it would need synchronization infomation, like 
damaged- and readback regions.

So this is a NAK.

Thanks,
Thomas


On 07/20/2013 01:40 PM, Christopher James Halse Rogers wrote:
> We want this so we can hand out CPU-mappable buffers to clients, but still
> use EGL in the server to composite said buffers.
> ---
>   src/gbm/backends/dri/gbm_dri.c | 23 +++++++++++++++++++++--
>   1 file changed, 21 insertions(+), 2 deletions(-)
>
> diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
> index 8b71cca..8ca7b54 100644
> --- a/src/gbm/backends/dri/gbm_dri.c
> +++ b/src/gbm/backends/dri/gbm_dri.c
> @@ -318,9 +318,9 @@ gbm_dri_bo_destroy(struct gbm_bo *_bo)
>      struct gbm_dri_bo *bo = gbm_dri_bo(_bo);
>      struct drm_mode_destroy_dumb arg;
>   
> -   if (bo->image != NULL) {
> +   if (bo->image)
>         dri->image->destroyImage(bo->image);
> -   } else {
> +   if (bo->map) {
>         munmap(bo->map, bo->size);
>         memset(&arg, 0, sizeof(arg));
>         arg.handle = bo->handle;
> @@ -532,6 +532,25 @@ create_dumb(struct gbm_device *gbm,
>      if (bo->map == MAP_FAILED)
>         goto destroy_dumb;
>   
> +   if (usage & GBM_BO_USE_RENDERING)
> +   {
> +      struct drm_gem_flink flink_arg;
> +      memset(&flink_arg, 0, sizeof(flink_arg));
> +      flink_arg.handle = bo->handle;
> +      ret = drmIoctl(dri->base.base.fd, DRM_IOCTL_GEM_FLINK, &flink_arg);
> +      if (ret)
> +         goto destroy_dumb;
> +
> +      bo->image = dri->image->createImageFromName(dri->screen,
> +                                                  width, height,
> +                                                  gbm_to_dri_format(format),
> +                                                  flink_arg.name,
> +                                                  bo->base.base.stride / 4,
> +                                                  bo);
> +
> +      if (!bo->image)
> +         goto destroy_dumb;
> +   }
>      return &bo->base.base;
>   
>   destroy_dumb:


More information about the mesa-dev mailing list