mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 20:10:14 +01:00
egl/android: Call createImageFromDmaBufs directly
Instead of building up EGL attribute lists and then having to parse them again, call the DRI driver directly and then use the dri2_create_image_from_dri() helper to wrap the __DRIimage in an EGLImage. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6055>
This commit is contained in:
parent
7c98066e80
commit
972f36d8fa
3 changed files with 41 additions and 58 deletions
|
|
@ -2201,7 +2201,7 @@ dri2_create_image(_EGLDisplay *disp, _EGLContext *ctx, EGLenum target,
|
||||||
attr_list);
|
attr_list);
|
||||||
}
|
}
|
||||||
|
|
||||||
static _EGLImage *
|
_EGLImage *
|
||||||
dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image)
|
dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image)
|
||||||
{
|
{
|
||||||
struct dri2_egl_image *dri2_img;
|
struct dri2_egl_image *dri2_img;
|
||||||
|
|
|
||||||
|
|
@ -445,6 +445,9 @@ _EGLImage *
|
||||||
dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
|
dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
|
||||||
EGLClientBuffer buffer, const EGLint *attr_list);
|
EGLClientBuffer buffer, const EGLint *attr_list);
|
||||||
|
|
||||||
|
_EGLImage *
|
||||||
|
dri2_create_image_from_dri(_EGLDisplay *disp, __DRIimage *dri_image);
|
||||||
|
|
||||||
#ifdef HAVE_X11_PLATFORM
|
#ifdef HAVE_X11_PLATFORM
|
||||||
EGLBoolean
|
EGLBoolean
|
||||||
dri2_initialize_x11(_EGLDisplay *disp);
|
dri2_initialize_x11(_EGLDisplay *disp);
|
||||||
|
|
|
||||||
|
|
@ -769,18 +769,19 @@ droid_swap_buffers(_EGLDisplay *disp, _EGLSurface *draw)
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static _EGLImage *
|
static __DRIimage *
|
||||||
droid_create_image_from_prime_fds_yuv(_EGLDisplay *disp, _EGLContext *ctx,
|
droid_create_image_from_prime_fds_yuv(_EGLDisplay *disp, _EGLContext *ctx,
|
||||||
struct ANativeWindowBuffer *buf,
|
struct ANativeWindowBuffer *buf,
|
||||||
int num_fds, int fds[3])
|
int num_fds, int fds[3])
|
||||||
{
|
{
|
||||||
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||||
struct android_ycbcr ycbcr;
|
struct android_ycbcr ycbcr;
|
||||||
size_t offsets[3];
|
int offsets[3];
|
||||||
size_t pitches[3];
|
int pitches[3];
|
||||||
enum chroma_order chroma_order;
|
enum chroma_order chroma_order;
|
||||||
int fourcc;
|
int fourcc;
|
||||||
int ret;
|
int ret;
|
||||||
|
unsigned error;
|
||||||
|
|
||||||
if (!dri2_dpy->gralloc->lock_ycbcr) {
|
if (!dri2_dpy->gralloc->lock_ycbcr) {
|
||||||
_eglLog(_EGL_WARNING, "Gralloc does not support lock_ycbcr");
|
_eglLog(_EGL_WARNING, "Gralloc does not support lock_ycbcr");
|
||||||
|
|
@ -844,52 +845,27 @@ droid_create_image_from_prime_fds_yuv(_EGLDisplay *disp, _EGLContext *ctx,
|
||||||
assert(num_fds == expected_planes);
|
assert(num_fds == expected_planes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ycbcr.chroma_step == 2) {
|
return dri2_dpy->image->createImageFromDmaBufs(dri2_dpy->dri_screen,
|
||||||
/* Semi-planar Y + CbCr or Y + CrCb format. */
|
buf->width, buf->height, fourcc,
|
||||||
const EGLint attr_list_2plane[] = {
|
fds, num_fds, pitches, offsets,
|
||||||
EGL_WIDTH, buf->width,
|
EGL_ITU_REC601_EXT,
|
||||||
EGL_HEIGHT, buf->height,
|
EGL_YUV_NARROW_RANGE_EXT,
|
||||||
EGL_LINUX_DRM_FOURCC_EXT, fourcc,
|
EGL_YUV_CHROMA_SITING_0_EXT,
|
||||||
EGL_DMA_BUF_PLANE0_FD_EXT, fds[0],
|
EGL_YUV_CHROMA_SITING_0_EXT,
|
||||||
EGL_DMA_BUF_PLANE0_PITCH_EXT, pitches[0],
|
&error,
|
||||||
EGL_DMA_BUF_PLANE0_OFFSET_EXT, offsets[0],
|
NULL);
|
||||||
EGL_DMA_BUF_PLANE1_FD_EXT, fds[1],
|
|
||||||
EGL_DMA_BUF_PLANE1_PITCH_EXT, pitches[1],
|
|
||||||
EGL_DMA_BUF_PLANE1_OFFSET_EXT, offsets[1],
|
|
||||||
EGL_NONE, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list_2plane);
|
|
||||||
} else {
|
|
||||||
/* Fully planar Y + Cb + Cr or Y + Cr + Cb format. */
|
|
||||||
const EGLint attr_list_3plane[] = {
|
|
||||||
EGL_WIDTH, buf->width,
|
|
||||||
EGL_HEIGHT, buf->height,
|
|
||||||
EGL_LINUX_DRM_FOURCC_EXT, fourcc,
|
|
||||||
EGL_DMA_BUF_PLANE0_FD_EXT, fds[0],
|
|
||||||
EGL_DMA_BUF_PLANE0_PITCH_EXT, pitches[0],
|
|
||||||
EGL_DMA_BUF_PLANE0_OFFSET_EXT, offsets[0],
|
|
||||||
EGL_DMA_BUF_PLANE1_FD_EXT, fds[1],
|
|
||||||
EGL_DMA_BUF_PLANE1_PITCH_EXT, pitches[1],
|
|
||||||
EGL_DMA_BUF_PLANE1_OFFSET_EXT, offsets[1],
|
|
||||||
EGL_DMA_BUF_PLANE2_FD_EXT, fds[2],
|
|
||||||
EGL_DMA_BUF_PLANE2_PITCH_EXT, pitches[2],
|
|
||||||
EGL_DMA_BUF_PLANE2_OFFSET_EXT, offsets[2],
|
|
||||||
EGL_NONE, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list_3plane);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static _EGLImage *
|
static __DRIimage *
|
||||||
droid_create_image_from_prime_fds(_EGLDisplay *disp, _EGLContext *ctx,
|
droid_create_image_from_prime_fds(_EGLDisplay *disp, _EGLContext *ctx,
|
||||||
struct ANativeWindowBuffer *buf, int num_fds, int fds[3])
|
struct ANativeWindowBuffer *buf, int num_fds, int fds[3])
|
||||||
{
|
{
|
||||||
unsigned int pitch;
|
struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
|
||||||
|
int pitches[4] = { 0 }, offsets[4] = { 0 };
|
||||||
|
unsigned error;
|
||||||
|
|
||||||
if (is_yuv(buf->format)) {
|
if (is_yuv(buf->format)) {
|
||||||
_EGLImage *image;
|
__DRIimage *image;
|
||||||
|
|
||||||
image = droid_create_image_from_prime_fds_yuv(disp, ctx, buf, num_fds, fds);
|
image = droid_create_image_from_prime_fds_yuv(disp, ctx, buf, num_fds, fds);
|
||||||
/*
|
/*
|
||||||
|
|
@ -916,23 +892,21 @@ droid_create_image_from_prime_fds(_EGLDisplay *disp, _EGLContext *ctx,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
pitch = buf->stride * get_format_bpp(buf->format);
|
pitches[0] = buf->stride * get_format_bpp(buf->format);
|
||||||
if (pitch == 0) {
|
if (pitches[0] == 0) {
|
||||||
_eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
|
_eglError(EGL_BAD_PARAMETER, "eglCreateEGLImageKHR");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
const EGLint attr_list[] = {
|
return dri2_dpy->image->createImageFromDmaBufs(dri2_dpy->dri_screen,
|
||||||
EGL_WIDTH, buf->width,
|
buf->width, buf->height, fourcc,
|
||||||
EGL_HEIGHT, buf->height,
|
fds, num_fds, pitches, offsets,
|
||||||
EGL_LINUX_DRM_FOURCC_EXT, fourcc,
|
EGL_ITU_REC601_EXT,
|
||||||
EGL_DMA_BUF_PLANE0_FD_EXT, fds[0],
|
EGL_YUV_NARROW_RANGE_EXT,
|
||||||
EGL_DMA_BUF_PLANE0_PITCH_EXT, pitch,
|
EGL_YUV_CHROMA_SITING_0_EXT,
|
||||||
EGL_DMA_BUF_PLANE0_OFFSET_EXT, 0,
|
EGL_YUV_CHROMA_SITING_0_EXT,
|
||||||
EGL_NONE, 0
|
&error,
|
||||||
};
|
NULL);
|
||||||
|
|
||||||
return dri2_create_image_dma_buf(disp, ctx, NULL, attr_list);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DRM_GRALLOC
|
#ifdef HAVE_DRM_GRALLOC
|
||||||
|
|
@ -1054,8 +1028,14 @@ dri2_create_image_android_native_buffer(_EGLDisplay *disp,
|
||||||
}
|
}
|
||||||
|
|
||||||
num_fds = get_native_buffer_fds(buf, fds);
|
num_fds = get_native_buffer_fds(buf, fds);
|
||||||
if (num_fds > 0)
|
if (num_fds > 0) {
|
||||||
return droid_create_image_from_prime_fds(disp, ctx, buf, num_fds, fds);
|
__DRIimage *dri_image =
|
||||||
|
droid_create_image_from_prime_fds(disp, ctx, buf, num_fds, fds);
|
||||||
|
if (!dri_image)
|
||||||
|
return EGL_NO_IMAGE_KHR;
|
||||||
|
|
||||||
|
return dri2_create_image_from_dri(disp, dri_image);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_DRM_GRALLOC
|
#ifdef HAVE_DRM_GRALLOC
|
||||||
return droid_create_image_from_name(disp, ctx, buf);
|
return droid_create_image_from_name(disp, ctx, buf);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue