diff options
author | Daniel Stone <daniels@collabora.com> | 2017-10-03 12:58:53 +0100 |
---|---|---|
committer | Daniel Stone <daniels@collabora.com> | 2017-10-04 18:36:06 +0100 |
commit | b138d7afb3a2a7d51dccb12f08d70c2d86766901 (patch) | |
tree | 6076ab91821f9ed2b81ca940586411ba41282f46 | |
parent | cbe7fb0bb5fbca0ffc37cfc7f1c78fc96fad7c1e (diff) |
gl-renderer: Ignore INVALID modifier
If the user has passed an INVALID modifier, it's because there is no
applicable modifier, and the buffer layout should be determined by a
magic side-channel call (e.g. bo_get_tiling). If the modifier is
INVALID, don't try to pass it through to EGL, but just drop it.
On the other hand, if a modifier _is_ explicitly specified and we don't
have the modifiers extension, then refuse to import the buffer.
Signed-off-by: Daniel Stone <daniels@collabora.com>
-rw-r--r-- | libweston/gl-renderer.c | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/libweston/gl-renderer.c b/libweston/gl-renderer.c index 5749aa71..244ce309 100644 --- a/libweston/gl-renderer.c +++ b/libweston/gl-renderer.c @@ -1735,6 +1735,7 @@ import_simple_dmabuf(struct gl_renderer *gr, struct egl_image *image; EGLint attribs[50]; int atti = 0; + bool has_modifier; /* This requires the Mesa commit in * Mesa 10.3 (08264e5dad4df448e7718e782ad9077902089a07) or @@ -1751,6 +1752,14 @@ import_simple_dmabuf(struct gl_renderer *gr, attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT; attribs[atti++] = attributes->format; + if (attributes->modifier[0] != DRM_FORMAT_MOD_INVALID) { + if (!gr->has_dmabuf_import_modifiers) + return NULL; + has_modifier = true; + } else { + has_modifier = false; + } + if (attributes->n_planes > 0) { attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT; attribs[atti++] = attributes->fd[0]; @@ -1758,7 +1767,7 @@ import_simple_dmabuf(struct gl_renderer *gr, attribs[atti++] = attributes->offset[0]; attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT; attribs[atti++] = attributes->stride[0]; - if (gr->has_dmabuf_import_modifiers) { + if (has_modifier) { attribs[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT; attribs[atti++] = attributes->modifier[0] & 0xFFFFFFFF; attribs[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT; @@ -1773,7 +1782,7 @@ import_simple_dmabuf(struct gl_renderer *gr, attribs[atti++] = attributes->offset[1]; attribs[atti++] = EGL_DMA_BUF_PLANE1_PITCH_EXT; attribs[atti++] = attributes->stride[1]; - if (gr->has_dmabuf_import_modifiers) { + if (has_modifier) { attribs[atti++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT; attribs[atti++] = attributes->modifier[1] & 0xFFFFFFFF; attribs[atti++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT; @@ -1788,7 +1797,7 @@ import_simple_dmabuf(struct gl_renderer *gr, attribs[atti++] = attributes->offset[2]; attribs[atti++] = EGL_DMA_BUF_PLANE2_PITCH_EXT; attribs[atti++] = attributes->stride[2]; - if (gr->has_dmabuf_import_modifiers) { + if (has_modifier) { attribs[atti++] = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT; attribs[atti++] = attributes->modifier[2] & 0xFFFFFFFF; attribs[atti++] = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT; |