[Mesa-dev] [PATCH kmscube 4/6] common: Use the create with modifiers interface

Emil Velikov emil.l.velikov at gmail.com
Fri Apr 14 17:11:30 UTC 2017


On 13 April 2017 at 19:22, Ben Widawsky <ben at bwidawsk.net> wrote:
> ---
>  common.c | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
>
> diff --git a/common.c b/common.c
> index 4bf3c5a..e63bb39 100644
> --- a/common.c
> +++ b/common.c
> @@ -31,10 +31,23 @@
>
>  static struct gbm gbm;
>
> +#ifndef DRM_FORMAT_MOD_LINEAR
> +#define DRM_FORMAT_MOD_LINEAR 0
> +#endif
> +static int
> +get_modifiers(uint64_t **mods)
> +{
> +       /* Assumed LINEAR is supported everywhere */
> +       static uint64_t modifiers[] = {DRM_FORMAT_MOD_LINEAR};
> +       *mods = modifiers;
> +       return 1;
> +}
> +
>  const struct gbm * init_gbm(int drm_fd, int w, int h)
>  {
>         gbm.dev = gbm_create_device(drm_fd);
>
> +#ifndef HAVE_GBM_MODIFIERS
>         gbm.surface = gbm_surface_create(gbm.dev, w, h,
>                         GBM_FORMAT_XRGB8888,
>                         GBM_BO_USE_SCANOUT | GBM_BO_USE_RENDERING);
> @@ -42,6 +55,12 @@ const struct gbm * init_gbm(int drm_fd, int w, int h)
>                 printf("failed to create gbm surface\n");
>                 return NULL;
>         }
> +#else
> +       uint64_t *mods;
> +       int count = get_modifiers(&mods);
> +       gbm.surface = gbm_surface_create_with_modifiers(gbm.dev, w, h,
> +                       GBM_FORMAT_XRGB8888, mods, count);
> +#endif
>
Since gbm_surface_create_with_modifiers() can fail we want to have
some error handling.
Move the existing one after the ifndef/else block ?

-Emil


More information about the mesa-dev mailing list