From: Daniel Stone <dani...@collabora.com> Intel hardware requires that all planes of an image come from the same buffer, which is currently implemented by testing that all FDs are numerically the same.
However, when going through a winsys (e.g.) or anything which transits FDs individually, the FDs may be different even if the underlying buffer is the same. Instead of checking the FDs for equality, we must check if they actually point to the same buffer (Jason). Signed-off-by: Daniel Stone <dani...@collabora.com> Signed-off-by: Varad Gautam <varad.gau...@collabora.com> --- src/mesa/drivers/dri/i965/intel_screen.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index 9842de6..ddaa8cf 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -815,20 +815,32 @@ intel_create_image_from_fds(__DRIscreen *dri_screen, struct intel_screen *screen = dri_screen->driverPrivate; struct intel_image_format *f; __DRIimage *image; - int i, index; + struct brw_bo *bo; + int i, index, size = 0; if (fds == NULL || num_fds < 1) return NULL; - /* We only support all planes from the same bo */ - for (i = 0; i < num_fds; i++) - if (fds[0] != fds[i]) - return NULL; - f = intel_image_format_lookup(fourcc); if (f == NULL) return NULL; + for (i = 0; i < f->nplanes; i++) { + index = f->planes[i].buffer_index; + const int plane_height = height >> f->planes[i].height_shift; + const int end = offsets[index] + plane_height * strides[index]; + if (size < end) + size = end; + } + /* We only support all planes from the same bo. + * brw_bo_gem_create_from_prime() should return the same pointer for all + * fds received here */ + bo = brw_bo_gem_create_from_prime(screen->bufmgr, fds[0], size); + for (i = 1; i < num_fds; i++) { + if (bo != brw_bo_gem_create_from_prime(screen->bufmgr, fds[i], size)) + return NULL; + } + if (f->nplanes == 1) image = intel_allocate_image(screen, f->planes[0].dri_format, loaderPrivate); -- 2.10.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev