[Mesa-dev] [PATCH 6/6] egl_dri2: Avoid using createSubImage when not neccassery
Jakob Bornecrantz
jakob at vmware.com
Wed Aug 15 03:50:18 PDT 2012
Makes it possible to run Wayland on Gallium drivers.
Signed-off-by: Jakob Bornecrantz <jakob at vmware.com>
---
src/egl/drivers/dri2/egl_dri2.c | 22 ++++++++++++++++------
src/gbm/backends/dri/gbm_dri.c | 10 ++++++----
2 files changed, 22 insertions(+), 10 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 423d18d..d714dc9 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1197,9 +1197,13 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
offset = buffer->offset[index];
stride = buffer->stride[index];
- dri_image = dri2_dpy->image->createSubImage(buffer->driver_buffer,
- width, height, format,
- offset, stride / cpp, NULL);
+ if (f->nplanes == 1) {
+ dri_image = dri2_dpy->image->dupImage(buffer->driver_buffer, NULL);
+ } else {
+ dri_image = dri2_dpy->image->createSubImage(buffer->driver_buffer,
+ width, height, format,
+ offset, stride / cpp, NULL);
+ }
return dri2_create_image(disp, dri_image);
}
@@ -1360,11 +1364,17 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name,
{
_EGLDisplay *disp = user_data;
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
- int i;
+ const struct wl_drm_format_descriptor *f;
+ int i, format = 0;
for (i = 0; i < ARRAY_SIZE(wl_drm_formats); i++)
if (wl_drm_formats[i].wl_format == buffer->format) {
- buffer->driver_format = &wl_drm_formats[i];
+ f = &wl_drm_formats[i];
+ buffer->driver_format = f;
+ if (f->nplanes == 1)
+ format = f->planes[0].dri_format;
+ else
+ format = __DRI_IMAGE_FORMAT_NONE;
break;
}
@@ -1375,7 +1385,7 @@ dri2_wl_reference_buffer(void *user_data, uint32_t name,
dri2_dpy->image->createImageFromName(dri2_dpy->dri_screen,
buffer->buffer.width,
buffer->buffer.height,
- __DRI_IMAGE_FORMAT_NONE, name,
+ format, name,
buffer->stride[0] / 4,
NULL);
}
diff --git a/src/gbm/backends/dri/gbm_dri.c b/src/gbm/backends/dri/gbm_dri.c
index 1731e4a..dfa5d39 100644
--- a/src/gbm/backends/dri/gbm_dri.c
+++ b/src/gbm/backends/dri/gbm_dri.c
@@ -422,10 +422,12 @@ gbm_dri_bo_import(struct gbm_device *gbm,
dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_WIDTH, &width);
dri->image->queryImage(image, __DRI_IMAGE_ATTRIB_HEIGHT, &height);
- bo->image = dri->image->createSubImage(image,
- width, height, dri_format,
- offset, stride / cpp, NULL);
-
+ if (dri->image->version < 5)
+ bo->image = dri->image->dupImage(image, NULL);
+ else
+ bo->image = dri->image->createSubImage(image,
+ width, height, dri_format,
+ offset, stride / cpp, NULL);
if (usage & GBM_BO_USE_SCANOUT)
dri_use |= __DRI_IMAGE_USE_SCANOUT;
--
1.7.9.5
More information about the mesa-dev
mailing list