diff --git a/include/EGL/eglext.h b/include/EGL/eglext.h index fa523a5..e322631 100644 --- a/include/EGL/eglext.h +++ b/include/EGL/eglext.h @@ -131,6 +131,7 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLDESTROYIMAGEKHRPROC) (EGLDisplay dpy, EGL /* EGL_DRM_BUFFER_USE_MESA bits */ #define EGL_DRM_BUFFER_USE_SCANOUT_MESA 0x0001 #define EGL_DRM_BUFFER_USE_SHARE_MESA 0x0002 +#define EGL_DRM_BUFFER_USE_CURSOR_MESA 0x0004 #define EGL_DRM_BUFFER_MESA 0x31D3 /* eglCreateImageKHR target */ #define EGL_DRM_BUFFER_STRIDE_MESA 0x31D4 /* eglCreateImageKHR attribute */ diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 2fb729a..d791557 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -816,6 +816,7 @@ struct __DRIdri2ExtensionRec { #define __DRI_IMAGE_USE_SHARE 0x0001 #define __DRI_IMAGE_USE_SCANOUT 0x0002 +#define __DRI_IMAGE_USE_CURSOR 0x0004 /** * queryImage attributes diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 5e47fbe..ca7d5d0 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1054,7 +1054,8 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, valid_mask = EGL_DRM_BUFFER_USE_SCANOUT_MESA | - EGL_DRM_BUFFER_USE_SHARE_MESA; + EGL_DRM_BUFFER_USE_SHARE_MESA | + EGL_DRM_BUFFER_USE_CURSOR_MESA; if (attrs.DRMBufferUseMESA & ~valid_mask) { _eglLog(_EGL_WARNING, "bad image use bit 0x%04x", attrs.DRMBufferUseMESA & ~valid_mask); @@ -1066,6 +1067,8 @@ dri2_create_drm_image_mesa(_EGLDriver *drv, _EGLDisplay *disp, dri_use |= __DRI_IMAGE_USE_SHARE; if (attrs.DRMBufferUseMESA & EGL_DRM_BUFFER_USE_SCANOUT_MESA) dri_use |= __DRI_IMAGE_USE_SCANOUT; + if (attrs.DRMBufferUseMESA & EGL_DRM_BUFFER_USE_CURSOR_MESA) + dri_use |= __DRI_IMAGE_USE_CURSOR; dri2_img->dri_image = dri2_dpy->image->createImage(dri2_dpy->dri_screen, diff --git a/src/mesa/drivers/dri/intel/intel_regions.c b/src/mesa/drivers/dri/intel/intel_regions.c index a4da1ce..40f4b5d 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.c +++ b/src/mesa/drivers/dri/intel/intel_regions.c @@ -196,6 +196,32 @@ intel_region_alloc(struct intel_screen *screen, return region; } +struct intel_region * +intel_region_alloc_cursor(struct intel_screen *screen, + GLuint cpp, GLuint width, GLuint height) +{ + drm_intel_bo *buffer; + struct intel_region *region; + +#define GTT_PAGE_SIZE 4096 +#define HWCURSOR_SIZE GTT_PAGE_SIZE +#define HWCURSOR_SIZE_ARGB GTT_PAGE_SIZE * 4 + + buffer = drm_intel_bo_alloc(screen->bufmgr, "ARGB cursor", + HWCURSOR_SIZE_ARGB, GTT_PAGE_SIZE); + if (buffer == NULL) + return NULL; + + region = intel_region_alloc_internal(screen, cpp, width, height, + width, 0, buffer); + if (region == NULL) { + drm_intel_bo_unreference(buffer); + return NULL; + } + + return region; +} + GLboolean intel_region_flink(struct intel_region *region, uint32_t *name) { diff --git a/src/mesa/drivers/dri/intel/intel_regions.h b/src/mesa/drivers/dri/intel/intel_regions.h index 8464a5e..3877146 100644 --- a/src/mesa/drivers/dri/intel/intel_regions.h +++ b/src/mesa/drivers/dri/intel/intel_regions.h @@ -83,6 +83,10 @@ struct intel_region *intel_region_alloc(struct intel_screen *screen, GLboolean expect_accelerated_upload); struct intel_region * +intel_region_alloc_cursor(struct intel_screen *screen, + GLuint cpp, GLuint width, GLuint height); + +struct intel_region * intel_region_alloc_for_handle(struct intel_screen *screen, GLuint cpp, GLuint width, GLuint height, GLuint pitch, diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 64a21a1..397e427 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -246,9 +246,13 @@ intel_create_image(__DRIscreen *screen, image->data = loaderPrivate; cpp = _mesa_get_format_bytes(image->format); - image->region = - intel_region_alloc(intelScreen, I915_TILING_NONE, - cpp, width, height, GL_TRUE); + if (use & __DRI_IMAGE_USE_CURSOR) + image->region = + intel_region_alloc_cursor(intelScreen, cpp, width, height); + else + image->region = + intel_region_alloc(intelScreen, I915_TILING_NONE, + cpp, width, height, GL_TRUE); if (image->region == NULL) { FREE(image); return NULL;