mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-02 20:58:04 +02:00
dri: Replace createImageFromDmaBufs() with createImageFromDmaBufs3()
If FromDmaBufs()/FromDmaBufs2() are available, then FromDmaBufs3() is. Drop the old method (unused by third parties) and make the new preferred entrypoint take its name. Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30245>
This commit is contained in:
parent
13ea03f088
commit
24d03a1c0f
8 changed files with 70 additions and 153 deletions
|
|
@ -2789,7 +2789,6 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
|
|||
int pitches[DMA_BUF_MAX_PLANES];
|
||||
int offsets[DMA_BUF_MAX_PLANES];
|
||||
uint64_t modifier;
|
||||
bool has_modifier = false;
|
||||
unsigned error;
|
||||
EGLint egl_error;
|
||||
|
||||
|
|
@ -2826,47 +2825,22 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
|
|||
if (attrs.DMABufPlaneModifiersLo[0].IsPresent) {
|
||||
modifier = combine_u32_into_u64(attrs.DMABufPlaneModifiersHi[0].Value,
|
||||
attrs.DMABufPlaneModifiersLo[0].Value);
|
||||
has_modifier = true;
|
||||
}
|
||||
|
||||
if (attrs.ProtectedContent) {
|
||||
if (dri2_dpy->image->base.version < 18 ||
|
||||
dri2_dpy->image->createImageFromDmaBufs3 == NULL) {
|
||||
_eglError(EGL_BAD_MATCH, "unsupported protected_content attribute");
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
}
|
||||
if (!has_modifier)
|
||||
modifier = DRM_FORMAT_MOD_INVALID;
|
||||
|
||||
dri_image = dri2_dpy->image->createImageFromDmaBufs3(
|
||||
dri2_dpy->dri_screen_render_gpu, attrs.Width, attrs.Height,
|
||||
attrs.DMABufFourCC.Value, modifier, fds, num_fds, pitches, offsets,
|
||||
attrs.DMABufYuvColorSpaceHint.Value, attrs.DMABufSampleRangeHint.Value,
|
||||
attrs.DMABufChromaHorizontalSiting.Value,
|
||||
attrs.DMABufChromaVerticalSiting.Value,
|
||||
attrs.ProtectedContent ? __DRI_IMAGE_PROTECTED_CONTENT_FLAG : 0,
|
||||
&error, NULL);
|
||||
} else if (has_modifier) {
|
||||
if (dri2_dpy->image->base.version < 15 ||
|
||||
dri2_dpy->image->createImageFromDmaBufs2 == NULL) {
|
||||
_eglError(EGL_BAD_MATCH, "unsupported dma_buf format modifier");
|
||||
return EGL_NO_IMAGE_KHR;
|
||||
}
|
||||
dri_image = dri2_dpy->image->createImageFromDmaBufs2(
|
||||
dri2_dpy->dri_screen_render_gpu, attrs.Width, attrs.Height,
|
||||
attrs.DMABufFourCC.Value, modifier, fds, num_fds, pitches, offsets,
|
||||
attrs.DMABufYuvColorSpaceHint.Value, attrs.DMABufSampleRangeHint.Value,
|
||||
attrs.DMABufChromaHorizontalSiting.Value,
|
||||
attrs.DMABufChromaVerticalSiting.Value, &error, NULL);
|
||||
} else {
|
||||
dri_image = dri2_dpy->image->createImageFromDmaBufs(
|
||||
dri2_dpy->dri_screen_render_gpu, attrs.Width, attrs.Height,
|
||||
attrs.DMABufFourCC.Value, fds, num_fds, pitches, offsets,
|
||||
attrs.DMABufYuvColorSpaceHint.Value, attrs.DMABufSampleRangeHint.Value,
|
||||
attrs.DMABufChromaHorizontalSiting.Value,
|
||||
attrs.DMABufChromaVerticalSiting.Value, &error, NULL);
|
||||
modifier = DRM_FORMAT_MOD_INVALID;
|
||||
}
|
||||
|
||||
uint32_t flags = 0;
|
||||
if (attrs.ProtectedContent)
|
||||
flags |= __DRI_IMAGE_PROTECTED_CONTENT_FLAG;
|
||||
|
||||
dri_image = dri2_dpy->image->createImageFromDmaBufs(
|
||||
dri2_dpy->dri_screen_render_gpu, attrs.Width, attrs.Height,
|
||||
attrs.DMABufFourCC.Value, modifier, fds, num_fds, pitches, offsets,
|
||||
attrs.DMABufYuvColorSpaceHint.Value, attrs.DMABufSampleRangeHint.Value,
|
||||
attrs.DMABufChromaHorizontalSiting.Value,
|
||||
attrs.DMABufChromaVerticalSiting.Value,
|
||||
flags, &error, NULL);
|
||||
|
||||
egl_error = egl_error_from_dri_image_error(error);
|
||||
if (egl_error != EGL_SUCCESS)
|
||||
_eglError(egl_error, "createImageFromDmaBufs failed");
|
||||
|
|
@ -2878,6 +2852,7 @@ dri2_create_image_dma_buf(_EGLDisplay *disp, _EGLContext *ctx,
|
|||
|
||||
return res;
|
||||
}
|
||||
|
||||
static _EGLImage *
|
||||
dri2_create_drm_image_mesa(_EGLDisplay *disp, const EGLint *attr_list)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -58,21 +58,12 @@ droid_create_image_from_buffer_info(
|
|||
{
|
||||
unsigned error;
|
||||
|
||||
if (dri2_dpy->image->base.version >= 15 &&
|
||||
dri2_dpy->image->createImageFromDmaBufs2 != NULL) {
|
||||
return dri2_dpy->image->createImageFromDmaBufs2(
|
||||
dri2_dpy->dri_screen_render_gpu, width, height, buf_info->drm_fourcc,
|
||||
buf_info->modifier, buf_info->fds, buf_info->num_planes,
|
||||
buf_info->strides, buf_info->offsets, color_info->yuv_color_space,
|
||||
color_info->sample_range, color_info->horizontal_siting,
|
||||
color_info->vertical_siting, &error, priv);
|
||||
}
|
||||
|
||||
return dri2_dpy->image->createImageFromDmaBufs(
|
||||
dri2_dpy->dri_screen_render_gpu, width, height, buf_info->drm_fourcc,
|
||||
buf_info->fds, buf_info->num_planes, buf_info->strides, buf_info->offsets,
|
||||
color_info->yuv_color_space, color_info->sample_range,
|
||||
color_info->horizontal_siting, color_info->vertical_siting, &error, priv);
|
||||
buf_info->modifier, buf_info->fds, buf_info->num_planes,
|
||||
buf_info->strides, buf_info->offsets, color_info->yuv_color_space,
|
||||
color_info->sample_range, color_info->horizontal_siting,
|
||||
color_info->vertical_siting, 0, &error, priv);
|
||||
}
|
||||
|
||||
static __DRIimage *
|
||||
|
|
|
|||
|
|
@ -1275,7 +1275,7 @@ get_back_bo(struct dri2_egl_surface *dri2_surf)
|
|||
* need to make it visible to render GPU
|
||||
*/
|
||||
dri2_surf->back->linear_copy =
|
||||
dri2_dpy->image->createImageFromDmaBufs3(
|
||||
dri2_dpy->image->createImageFromDmaBufs(
|
||||
dri2_dpy->dri_screen_render_gpu,
|
||||
dri2_surf->base.Width, dri2_surf->base.Height,
|
||||
fourcc, linear_mod,
|
||||
|
|
|
|||
|
|
@ -1804,35 +1804,6 @@ dri2_query_dma_buf_format_modifier_attribs(__DRIscreen *_screen,
|
|||
}
|
||||
}
|
||||
|
||||
static __DRIimage *
|
||||
dri2_from_dma_bufs(__DRIscreen *screen,
|
||||
int width, int height, int fourcc,
|
||||
int *fds, int num_fds,
|
||||
int *strides, int *offsets,
|
||||
enum __DRIYUVColorSpace yuv_color_space,
|
||||
enum __DRISampleRange sample_range,
|
||||
enum __DRIChromaSiting horizontal_siting,
|
||||
enum __DRIChromaSiting vertical_siting,
|
||||
unsigned *error,
|
||||
void *loaderPrivate)
|
||||
{
|
||||
__DRIimage *img;
|
||||
|
||||
img = dri2_create_image_from_fd(screen, width, height, fourcc,
|
||||
DRM_FORMAT_MOD_INVALID, fds, num_fds,
|
||||
strides, offsets, 0, error, loaderPrivate);
|
||||
if (img == NULL)
|
||||
return NULL;
|
||||
|
||||
img->yuv_color_space = yuv_color_space;
|
||||
img->sample_range = sample_range;
|
||||
img->horizontal_siting = horizontal_siting;
|
||||
img->vertical_siting = vertical_siting;
|
||||
|
||||
*error = __DRI_IMAGE_ERROR_SUCCESS;
|
||||
return img;
|
||||
}
|
||||
|
||||
static __DRIimage *
|
||||
dri2_from_dma_bufs2(__DRIscreen *screen,
|
||||
int width, int height, int fourcc,
|
||||
|
|
@ -1863,7 +1834,7 @@ dri2_from_dma_bufs2(__DRIscreen *screen,
|
|||
}
|
||||
|
||||
static __DRIimage *
|
||||
dri2_from_dma_bufs3(__DRIscreen *screen,
|
||||
dri2_from_dma_bufs(__DRIscreen *screen,
|
||||
int width, int height, int fourcc,
|
||||
uint64_t modifier, int *fds, int num_fds,
|
||||
int *strides, int *offsets,
|
||||
|
|
@ -2093,7 +2064,6 @@ static const __DRIimageExtension dri2ImageExtensionTempl = {
|
|||
.unmapImage = dri2_unmap_image,
|
||||
.createImageWithModifiers = NULL,
|
||||
.createImageFromDmaBufs2 = NULL,
|
||||
.createImageFromDmaBufs3 = NULL,
|
||||
.queryDmaBufFormats = NULL,
|
||||
.queryDmaBufModifiers = NULL,
|
||||
.queryDmaBufFormatModifierAttribs = NULL,
|
||||
|
|
@ -2125,7 +2095,6 @@ const __DRIimageExtension driVkImageExtension = {
|
|||
.unmapImage = dri2_unmap_image,
|
||||
.createImageWithModifiers = dri2_create_image_with_modifiers,
|
||||
.createImageFromDmaBufs2 = dri2_from_dma_bufs2,
|
||||
.createImageFromDmaBufs3 = dri2_from_dma_bufs3,
|
||||
.queryDmaBufFormats = dri2_query_dma_buf_formats,
|
||||
.queryDmaBufModifiers = dri2_query_dma_buf_modifiers,
|
||||
.queryDmaBufFormatModifierAttribs = dri2_query_dma_buf_format_modifier_attribs,
|
||||
|
|
@ -2398,7 +2367,6 @@ dri2_init_screen_extensions(struct dri_screen *screen,
|
|||
screen->image_extension.createImageFromFds2 = dri2_from_fds2;
|
||||
screen->image_extension.createImageFromDmaBufs = dri2_from_dma_bufs;
|
||||
screen->image_extension.createImageFromDmaBufs2 = dri2_from_dma_bufs2;
|
||||
screen->image_extension.createImageFromDmaBufs3 = dri2_from_dma_bufs3;
|
||||
screen->image_extension.queryDmaBufFormats =
|
||||
dri2_query_dma_buf_formats;
|
||||
screen->image_extension.queryDmaBufModifiers =
|
||||
|
|
|
|||
|
|
@ -242,15 +242,15 @@ dri3_create_image_from_buffers(xcb_connection_t *c,
|
|||
offsets[i] = offsets_in[i];
|
||||
}
|
||||
|
||||
ret = image->createImageFromDmaBufs2(opaque_dri_screen(screen),
|
||||
bp_reply->width,
|
||||
bp_reply->height,
|
||||
fourcc,
|
||||
bp_reply->modifier,
|
||||
fds, bp_reply->nfd,
|
||||
strides, offsets,
|
||||
0, 0, 0, 0, /* UNDEFINED */
|
||||
&error, loaderPrivate);
|
||||
ret = image->createImageFromDmaBufs(opaque_dri_screen(screen),
|
||||
bp_reply->width,
|
||||
bp_reply->height,
|
||||
fourcc,
|
||||
bp_reply->modifier,
|
||||
fds, bp_reply->nfd,
|
||||
strides, offsets,
|
||||
0, 0, 0, 0, /* UNDEFINED */
|
||||
0, &error, loaderPrivate);
|
||||
|
||||
for (i = 0; i < bp_reply->nfd; i++)
|
||||
close(fds[i]);
|
||||
|
|
|
|||
|
|
@ -1410,7 +1410,7 @@ enum __DRIFixedRateCompression {
|
|||
#define __BLIT_FLAG_FINISH 0x0002
|
||||
|
||||
/**
|
||||
* Flags for createImageFromDmaBufs3 and createImageFromFds2
|
||||
* Flags for createImageFromDmaBufs
|
||||
*/
|
||||
#define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001
|
||||
#define __DRI_IMAGE_PRIME_LINEAR_BUFFER 0x00000002
|
||||
|
|
@ -1512,24 +1512,6 @@ struct __DRIimageExtensionRec {
|
|||
int *strides, int *offsets,
|
||||
void *loaderPrivate);
|
||||
|
||||
/**
|
||||
* Like createImageFromFds, but takes additional attributes.
|
||||
*
|
||||
* For EGL_EXT_image_dma_buf_import.
|
||||
*
|
||||
* \since 8
|
||||
*/
|
||||
__DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
|
||||
int width, int height, int fourcc,
|
||||
int *fds, int num_fds,
|
||||
int *strides, int *offsets,
|
||||
enum __DRIYUVColorSpace color_space,
|
||||
enum __DRISampleRange sample_range,
|
||||
enum __DRIChromaSiting horiz_siting,
|
||||
enum __DRIChromaSiting vert_siting,
|
||||
unsigned *error,
|
||||
void *loaderPrivate);
|
||||
|
||||
/**
|
||||
* Blit a part of a __DRIimage to another and flushes
|
||||
*
|
||||
|
|
@ -1604,10 +1586,13 @@ struct __DRIimageExtensionRec {
|
|||
void *loaderPrivate);
|
||||
|
||||
/*
|
||||
* Like createImageFromDmaBufs, but takes also format modifiers.
|
||||
* Like createImageFromDmaBufs, with fewer options.
|
||||
*
|
||||
* For EGL_EXT_image_dma_buf_import_modifiers.
|
||||
*
|
||||
* Used by ChromeOS's minigbm for AMD devices as of 2023. This is
|
||||
* deprecated, use the current createImageFromDmaBufs() instead.
|
||||
*
|
||||
* \since 15
|
||||
*/
|
||||
__DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,
|
||||
|
|
@ -1697,25 +1682,23 @@ struct __DRIimageExtensionRec {
|
|||
void *loaderPrivate,
|
||||
unsigned *error);
|
||||
|
||||
/*
|
||||
* Like createImageFromDmaBufs2, but with an added flags parameter.
|
||||
/**
|
||||
* Like createImageFromFds, but takes additional attributes.
|
||||
*
|
||||
* See __DRI_IMAGE_*_FLAG for valid definitions of flags.
|
||||
*
|
||||
* \since 18
|
||||
*/
|
||||
__DRIimage *(*createImageFromDmaBufs3)(__DRIscreen *screen,
|
||||
int width, int height, int fourcc,
|
||||
uint64_t modifier,
|
||||
int *fds, int num_fds,
|
||||
int *strides, int *offsets,
|
||||
enum __DRIYUVColorSpace color_space,
|
||||
enum __DRISampleRange sample_range,
|
||||
enum __DRIChromaSiting horiz_siting,
|
||||
enum __DRIChromaSiting vert_siting,
|
||||
uint32_t flags,
|
||||
unsigned *error,
|
||||
void *loaderPrivate);
|
||||
__DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
|
||||
int width, int height, int fourcc,
|
||||
uint64_t modifier,
|
||||
int *fds, int num_fds,
|
||||
int *strides, int *offsets,
|
||||
enum __DRIYUVColorSpace color_space,
|
||||
enum __DRISampleRange sample_range,
|
||||
enum __DRIChromaSiting horiz_siting,
|
||||
enum __DRIChromaSiting vert_siting,
|
||||
uint32_t flags,
|
||||
unsigned *error,
|
||||
void *loaderPrivate);
|
||||
|
||||
/**
|
||||
* Creates an image with implementation's favorite modifiers and the
|
||||
|
|
|
|||
|
|
@ -804,26 +804,26 @@ gbm_dri_bo_import(struct gbm_device *gbm,
|
|||
unsigned int error;
|
||||
int fourcc;
|
||||
|
||||
/* Import with modifier requires createImageFromDmaBufs2 */
|
||||
if (dri->image->createImageFromDmaBufs2 == NULL) {
|
||||
/* Import with modifier requires createImageFromDmaBufs */
|
||||
if (dri->image->createImageFromDmaBufs == NULL) {
|
||||
errno = ENOSYS;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* GBM's GBM_FORMAT_* tokens are a strict superset of the DRI FourCC
|
||||
* tokens accepted by createImageFromDmaBufs2, except for not supporting
|
||||
* tokens accepted by createImageFromDmaBufs, except for not supporting
|
||||
* the sARGB format. */
|
||||
fourcc = gbm_core.v0.format_canonicalize(fd_data->format);
|
||||
|
||||
image = dri->image->createImageFromDmaBufs2(dri->screen, fd_data->width,
|
||||
fd_data->height, fourcc,
|
||||
fd_data->modifier,
|
||||
fd_data->fds,
|
||||
fd_data->num_fds,
|
||||
fd_data->strides,
|
||||
fd_data->offsets,
|
||||
0, 0, 0, 0,
|
||||
&error, NULL);
|
||||
image = dri->image->createImageFromDmaBufs(dri->screen, fd_data->width,
|
||||
fd_data->height, fourcc,
|
||||
fd_data->modifier,
|
||||
fd_data->fds,
|
||||
fd_data->num_fds,
|
||||
fd_data->strides,
|
||||
fd_data->offsets,
|
||||
0, 0, 0, 0,
|
||||
0, &error, NULL);
|
||||
if (image == NULL) {
|
||||
errno = ENOSYS;
|
||||
return NULL;
|
||||
|
|
|
|||
|
|
@ -1891,15 +1891,15 @@ loader_dri3_create_image_from_buffers(xcb_connection_t *c,
|
|||
offsets[i] = offsets_in[i];
|
||||
}
|
||||
|
||||
ret = image->createImageFromDmaBufs2(dri_screen,
|
||||
bp_reply->width,
|
||||
bp_reply->height,
|
||||
loader_image_format_to_fourcc(format),
|
||||
bp_reply->modifier,
|
||||
fds, bp_reply->nfd,
|
||||
strides, offsets,
|
||||
0, 0, 0, 0, /* UNDEFINED */
|
||||
&error, loaderPrivate);
|
||||
ret = image->createImageFromDmaBufs(dri_screen,
|
||||
bp_reply->width,
|
||||
bp_reply->height,
|
||||
loader_image_format_to_fourcc(format),
|
||||
bp_reply->modifier,
|
||||
fds, bp_reply->nfd,
|
||||
strides, offsets,
|
||||
0, 0, 0, 0, /* UNDEFINED */
|
||||
0, &error, loaderPrivate);
|
||||
|
||||
for (i = 0; i < bp_reply->nfd; i++)
|
||||
close(fds[i]);
|
||||
|
|
@ -1963,7 +1963,7 @@ dri3_get_pixmap_buffer(__DRIdrawable *driDrawable, unsigned int format,
|
|||
#ifdef HAVE_DRI3_MODIFIERS
|
||||
if (draw->multiplanes_available &&
|
||||
draw->ext->image->base.version >= 15 &&
|
||||
draw->ext->image->createImageFromDmaBufs2) {
|
||||
draw->ext->image->createImageFromDmaBufs) {
|
||||
xcb_dri3_buffers_from_pixmap_cookie_t bps_cookie;
|
||||
xcb_dri3_buffers_from_pixmap_reply_t *bps_reply;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue