* [PATCH] EGL: Add hardware cursor image format for EGL image extension.
@ 2011-05-10 9:47 zhigang gong
2011-05-10 12:22 ` Kristian Høgsberg
0 siblings, 1 reply; 2+ messages in thread
From: zhigang gong @ 2011-05-10 9:47 UTC (permalink / raw)
To: mesa-dev, intel-gfx
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] EGL: Add hardware cursor image format for EGL image extension.
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
0 siblings, 0 replies; 2+ messages in thread
From: Kristian Høgsberg @ 2011-05-10 12:22 UTC (permalink / raw)
To: zhigang gong; +Cc: mesa-dev, intel-gfx
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-10 12:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 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).