[PATCH xserver] glamor: Add 30bit RGB color format support

Alex Deucher alexdeucher at gmail.com
Thu Jan 25 17:13:08 UTC 2018


On Thu, Jan 25, 2018 at 12:03 PM, Michel Dänzer <michel at daenzer.net> wrote:
> From: Hawking Zhang <Hawking.Zhang at amd.com>
>
> Signed-off-by: Hawking Zhang <Hawking.Zhang at amd.com>
>
> [ Michel Dänzer: Adapt to glamor changes since 1.19 ]
>
> Signed-off-by: Michel Dänzer <michel.daenzer at amd.com>

Acked-by: Alex Deucher <alexander.deucher at amd.com>

> ---
>  glamor/glamor_egl.c      | 7 +++++--
>  glamor/glamor_fbo.c      | 5 ++++-
>  glamor/glamor_transfer.c | 4 ++++
>  glamor/glamor_utils.h    | 3 +++
>  4 files changed, 16 insertions(+), 3 deletions(-)
>
> diff --git a/glamor/glamor_egl.c b/glamor/glamor_egl.c
> index 53a74b8da..202b83efd 100644
> --- a/glamor/glamor_egl.c
> +++ b/glamor/glamor_egl.c
> @@ -376,14 +376,17 @@ glamor_back_pixmap_from_fd(PixmapPtr pixmap,
>
>      glamor_egl = glamor_egl_get_screen_private(scrn);
>
> -    if (bpp != 32 || !(depth == 24 || depth == 32) || width == 0 || height == 0)
> +    if (bpp != 32 || !(depth == 24 || depth == 32 || depth == 30) || width == 0 || height == 0)
>          return FALSE;
>
>      import_data.fd = fd;
>      import_data.width = width;
>      import_data.height = height;
>      import_data.stride = stride;
> -    import_data.format = GBM_FORMAT_ARGB8888;
> +    if (depth == 30)
> +        import_data.format = GBM_FORMAT_ARGB2101010;
> +    else
> +        import_data.format = GBM_FORMAT_ARGB8888;
>      bo = gbm_bo_import(glamor_egl->gbm, GBM_BO_IMPORT_FD, &import_data, 0);
>      if (!bo)
>          return FALSE;
> diff --git a/glamor/glamor_fbo.c b/glamor/glamor_fbo.c
> index 9f1288c60..e8c4330b3 100644
> --- a/glamor/glamor_fbo.c
> +++ b/glamor/glamor_fbo.c
> @@ -123,7 +123,10 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
>                     int w, int h, GLenum format)
>  {
>      unsigned int tex;
> +    GLenum iformat = format;
>
> +    if (format == GL_RGB10_A2)
> +        format = GL_RGBA;
>      glamor_make_current(glamor_priv);
>      glGenTextures(1, &tex);
>      glBindTexture(GL_TEXTURE_2D, tex);
> @@ -132,7 +135,7 @@ _glamor_create_tex(glamor_screen_private *glamor_priv,
>      if (format == glamor_priv->one_channel_format && format == GL_RED)
>          glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_A, GL_RED);
>      glamor_priv->suppress_gl_out_of_memory_logging = true;
> -    glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0,
> +    glTexImage2D(GL_TEXTURE_2D, 0, iformat, w, h, 0,
>                   format, GL_UNSIGNED_BYTE, NULL);
>      glamor_priv->suppress_gl_out_of_memory_logging = false;
>
> diff --git a/glamor/glamor_transfer.c b/glamor/glamor_transfer.c
> index d788d06f4..ebb5101d1 100644
> --- a/glamor/glamor_transfer.c
> +++ b/glamor/glamor_transfer.c
> @@ -33,6 +33,10 @@ glamor_format_for_pixmap(PixmapPtr pixmap, GLenum *format, GLenum *type)
>          *format = GL_BGRA;
>          *type = GL_UNSIGNED_INT_8_8_8_8_REV;
>          break;
> +    case 30:
> +        *format = GL_BGRA;
> +        *type = GL_UNSIGNED_INT_2_10_10_10_REV;
> +        break;
>      case 16:
>          *format = GL_RGB;
>          *type = GL_UNSIGNED_SHORT_5_6_5;
> diff --git a/glamor/glamor_utils.h b/glamor/glamor_utils.h
> index 090b0e18a..7597b92dc 100644
> --- a/glamor/glamor_utils.h
> +++ b/glamor/glamor_utils.h
> @@ -619,6 +619,9 @@ gl_iformat_for_pixmap(PixmapPtr pixmap)
>      if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
>          ((pixmap)->drawable.depth == 1 || (pixmap)->drawable.depth == 8)) {
>          return glamor_priv->one_channel_format;
> +    } else if (glamor_priv->gl_flavor == GLAMOR_GL_DESKTOP &&
> +               (pixmap)->drawable.depth == 30) {
> +        return GL_RGB10_A2;
>      } else {
>          return GL_RGBA;
>      }
> --
> 2.15.1
>
> _______________________________________________
> xorg-devel at lists.x.org: X.Org development
> Archives: http://lists.x.org/archives/xorg-devel
> Info: https://lists.x.org/mailman/listinfo/xorg-devel


More information about the xorg-devel mailing list