From patchwork Tue May 10 09:47:45 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: zhigang gong X-Patchwork-Id: 773702 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p4A9m61N019410 for ; Tue, 10 May 2011 09:48:26 GMT Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 724609F064 for ; Tue, 10 May 2011 02:48:06 -0700 (PDT) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-wy0-f177.google.com (mail-wy0-f177.google.com [74.125.82.177]) by gabe.freedesktop.org (Postfix) with ESMTP id A8AAE9E9DE; Tue, 10 May 2011 02:47:46 -0700 (PDT) Received: by wyb28 with SMTP id 28so5716902wyb.36 for ; Tue, 10 May 2011 02:47:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to :content-type; bh=PBeIBdpW5XVpJfK3X/asrHIV5ifDMrpWIVF8/OMi7N8=; b=nkq3zovc0P+ug+PtGjuyQm8A8jfgXs6njWo/Mte16tD9wxgA3FefjS0pZcr586t/5V pIe5+3iUSvgHEYBhgBc56SLyYidK148cEae/kNg2H7CkxH96Qgkp/C0ZEB/YL63Hm5wY +hjQ79sW5fwcysDUZAhHMIYIU/kB77m4srXcE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=bdWB7bBdtRRedqfV1LSba4jf4glkxpPVDWCQESmiAywYjkRzaMK1ZmQBvCk+Oj9AEl yRJkGG89AUn9/UCP0oif/VFqe9wjUhyZCXKBibDqHud6Nv4u4ZZ8ZhQDVMEbF7B/Irlf RZS4IaHa3deRJpfiAbmdwWJ/1gb0A72bz7xeo= MIME-Version: 1.0 Received: by 10.216.237.102 with SMTP id x80mr3933709weq.111.1305020865472; Tue, 10 May 2011 02:47:45 -0700 (PDT) Received: by 10.216.158.134 with HTTP; Tue, 10 May 2011 02:47:45 -0700 (PDT) Date: Tue, 10 May 2011 17:47:45 +0800 Message-ID: From: zhigang gong To: mesa-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [Intel-gfx] [PATCH] EGL: Add hardware cursor image format for EGL image extension. X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org Errors-To: intel-gfx-bounces+patchwork-intel-gfx=patchwork.kernel.org@lists.freedesktop.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Tue, 10 May 2011 09:48:27 +0000 (UTC) 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(-) -- 1.7.3.1 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);