@@ -1262,7 +1262,8 @@ dri2_create_image_wayland_wl_buffer(_EGLDisplay *disp, _EGLContext *ctx,
return NULL;
}
- dri_image = dri2_dpy->image->fromPlanar(buffer->driver_buffer, plane, NULL);
+ dri_image = dri2_dpy->image->fromPlanar(buffer->driver_buffer, plane,
+ dri2_dpy->dri_screen);
if (dri_image == NULL) {
_eglError(EGL_BAD_PARAMETER, "dri2_create_image_wayland_wl_buffer");
@@ -739,6 +739,9 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
struct intel_image_format *f;
uint32_t mask_x, mask_y;
__DRIimage *image;
+ const __DRIscreen *dri_screen = loaderPrivate;
+ const struct intel_screen *const intel_screen =
+ (struct intel_screen *) dri_screen->driverPrivate;
if (parent == NULL || parent->planar_format == NULL)
return NULL;
@@ -771,13 +774,42 @@ intel_from_planar(__DRIimage *parent, int plane, void *loaderPrivate)
return NULL;
}
+ if (parent->region->bo->bufmgr == intel_screen->bufmgr) {
+
+
+ image->region->bo = parent->region->bo;
+ drm_intel_bo_reference(image->region->bo);
+ } else {
+ int err, fd;
+
+
+
+ err = drm_intel_bo_gem_export_to_prime(parent->region->bo, &fd);
+ if (err != 0) {
+ _mesa_warning(NULL, "intel_create_sub_image: prime export failed: %d\n",
+ -err);
+ free(image->region);
+ free(image);
+ return NULL;
+ }
+
+ image->region->bo =
+ drm_intel_bo_gem_create_from_prime(intel_screen->bufmgr, fd,
+ parent->region->bo->size);
+ close(fd);
+ if (!image->region->bo) {
+ _mesa_warning(NULL, "intel_create_sub_image: prime import failed\n");
+ free(image->region);
+ free(image);
+ return NULL;
+ }
+ }
+
image->region->cpp = _mesa_get_format_bytes(image->format);
image->region->width = width;
image->region->height = height;
image->region->pitch = stride;
image->region->refcount = 1;
- image->region->bo = parent->region->bo;
- drm_intel_bo_reference(image->region->bo);
image->region->tiling = parent->region->tiling;
image->offset = offset;
intel_setup_image_from_dimensions(image);