intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Kristian Høgsberg" <krh@bitplanet.net>
To: zhigang gong <zhigang.gong@gmail.com>
Cc: mesa-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH] EGL: Add hardware cursor image format for EGL image extension.
Date: Tue, 10 May 2011 08:22:21 -0400	[thread overview]
Message-ID: <BANLkTikDvORT+-LjQxLZaXhrQr4W=ME7VA@mail.gmail.com> (raw)
In-Reply-To: <BANLkTi=AuGMtJMgg8Py1QRG4pEvfdcqSoA@mail.gmail.com>

I implemented this just a few days ago:

http://cgit.freedesktop.org/mesa/mesa/commit/?id=e5169e9615e8391ea369415b356168717b8f7be0

It's a new use flags instead of a new format, because, well, it's not
a new pixel format, but a restriction on how the buffers should be
allocated.

Kristian

On Tue, May 10, 2011 at 5:47 AM, zhigang gong <zhigang.gong@gmail.com> wrote:
>     Current EGL only support one drm buffer format which is
>     EGL_DRM_BUFFER_FORMAT_ARGB32_MESA. This
>     format works fine with normal image, but if we want to
>     create a drm buffer which will be used for a hardware cursor,
>     then it has problem. The default behaviou for this format is to
>     enable tiling for i915 driver. Thus it will choose 512 as the buffer's
>     stride. But the hardware cursor can only support 256 as the
>     row stride. To solve this problem, I create a new drm buffer
>     format named EGL_DRM_BUFFER_FORMAT_HWCURSOR_ARGB32_MESA
>     for hardware cursor usage. It will disable the tiling by default
>     for i915 driver and then choose 256 as its pitch value. I tested it on a
>     Sandy bridge platform, it works fine.
> ---
>  include/EGL/eglext.h                      |    1 +
>  include/GL/internal/dri_interface.h       |    1 +
>  src/egl/drivers/dri2/egl_dri2.c           |    3 +++
>  src/mesa/drivers/dri/intel/intel_screen.c |    7 +++++--
>  4 files changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h
> index 9fd3eb8..d0153d3 100644
> --- a/include/EGL/eglext.h
> +++ b/include/EGL/eglext.h
> @@ -127,6 +127,7 @@ typedef EGLBoolean (EGLAPIENTRYP
> PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGL
>
>  /* EGL_DRM_BUFFER_FORMAT_MESA tokens */
>  #define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA      0x31D2
> +#define EGL_DRM_BUFFER_FORMAT_HWCURSOR_ARGB32_MESA 0x31D3
>
>  /* EGL_DRM_BUFFER_USE_MESA bits */
>  #define EGL_DRM_BUFFER_USE_SCANOUT_MESA                0x0001
> diff --git a/include/GL/internal/dri_interface.h
> b/include/GL/internal/dri_interface.h
> index 2fb729a..fa2341b 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/interna
> @@ -127,6 +127,7 @@ typedef EGLBoolean (EGLAPIENTRYP
> PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGL
>
>  /* EGL_DRM_BUFFER_FORMAT_MESA tokens */
>  #define EGL_DRM_BUFFER_FORMAT_ARGB32_MESA      0x31D2
> +#define EGL_DRM_BUFFER_FORMAT_HWCURSOR_ARGB32_MESA 0x31D3
>
>  /* EGL_DRM_BUFFER_USE_MESA bits */
>  #define EGL_DRM_BUFFER_USE_SCANOUT_MESA                0x0001
> diff --git a/include/GL/internal/dri_interface.h
> b/include/GL/internal/dri_interface.h
> index 2fb729a..fa2341b 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -813,6 +813,7 @@ struct __DRIdri2ExtensionRec {
>  #define __DRI_IMAGE_FORMAT_RGB565       0x1001
>  #define __DRI_IMAGE_FORMAT_XRGB8888     0x1002
>  #define __DRI_IMAGE_FORMAT_ARGB8888     0x1003
> +#define __DRI_IMAGE_FORMAT_HWCURSOR_ARGB 0x1004
>
>  #define __DRI_IMAGE_USE_SHARE          0x0001
>  #define __DRI_IMAGE_USE_SCANOUT                0x0002
> diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
> index 5e47fbe..23ab0ed 100644
> --- a/src/egl/drivers/dri2/egl_dri2.c
> +++ b/src/egl/drivers/dri2/egl_dri2.c
> @@ -1043,6 +1043,9 @@ dri2_create_drm_image_mesa(_EGLDriver *drv,
> _EGLDisplay *disp,
>    }
>
>    switch (attrs.DRMBufferFormatMESA) {
> +   case EGL_DRM_BUFFER_FORMAT_HWCURSOR_ARGB32_MESA:
> +      format = __DRI_IMAGE_FORMAT_HWCURSOR_ARGB;
> +      break;
>    case EGL_DRM_BUFFER_FORMAT_ARGB32_MESA:
>       format = __DRI_IMAGE_FORMAT_ARGB8888;
>       break;
> diff --git a/src/mesa/drivers/dri/intel/intel_screen.c
> b/src/mesa/drivers/dri/intel/intel_screen.c
> index 7de0d12..475c142 100644
> --- a/src/mesa/drivers/dri/intel/intel_screen.c
> +++ b/src/mesa/drivers/dri/intel/intel_screen.c
> @@ -217,11 +217,12 @@ intel_create_image(__DRIscreen *screen,
>    __DRIimage *image;
>    struct intel_screen *intelScreen = screen->private;
>    int cpp;
> +   int tiling;
>
>    image = CALLOC(sizeof *image);
>    if (image == NULL)
>       return NULL;
> -
> +   tiling = I915_TILING_X;
>    switch (format) {
>    case __DRI_IMAGE_FORMAT_RGB565:
>       image->format = MESA_FORMAT_RGB565;
> @@ -233,6 +234,8 @@ intel_create_image(__DRIscreen *screen,
>       image->internal_format = GL_RGB;
>       image->data_type = GL_UNSIGNED_BYTE;
>       break;
> +   case __DRI_IMAGE_FORMAT_HWCURSOR_ARGB:
> +      tiling = I915_TILING_NONE;
>    case __DRI_IMAGE_FORMAT_ARGB8888:
>       image->format = MESA_FORMAT_ARGB8888;
>       image->internal_format = GL_RGBA;
> @@ -247,7 +250,7 @@ intel_create_image(__DRIscreen *screen,
>    cpp = _mesa_get_format_bytes(image->format);
>
>    image->region =
> -      intel_region_alloc(intelScreen, I915_TILING_X,
> +      intel_region_alloc(intelScreen, tiling,
>                         cpp, width, height, GL_TRUE);
>    if (image->region == NULL) {
>       FREE(image);
> --
> 1.7.3.1
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

      reply	other threads:[~2011-05-10 12:22 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-10  9:47 [PATCH] EGL: Add hardware cursor image format for EGL image extension zhigang gong
2011-05-10 12:22 ` Kristian Høgsberg [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='BANLkTikDvORT+-LjQxLZaXhrQr4W=ME7VA@mail.gmail.com' \
    --to=krh@bitplanet.net \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=mesa-dev@lists.freedesktop.org \
    --cc=zhigang.gong@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).