From: zhigang gong <zhigang.gong@gmail.com>
To: mesa-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Subject: [PATCH] EGL: Add hardware cursor image format for EGL image extension.
Date: Tue, 10 May 2011 17:47:45 +0800 [thread overview]
Message-ID: <BANLkTi=AuGMtJMgg8Py1QRG4pEvfdcqSoA@mail.gmail.com> (raw)
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
next reply other threads:[~2011-05-10 9:47 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-10 9:47 zhigang gong [this message]
2011-05-10 12:22 ` [PATCH] EGL: Add hardware cursor image format for EGL image extension Kristian Høgsberg
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='BANLkTi=AuGMtJMgg8Py1QRG4pEvfdcqSoA@mail.gmail.com' \
--to=zhigang.gong@gmail.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=mesa-dev@lists.freedesktop.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.