Commit fe784b95 authored by Thomas Guillem's avatar Thomas Guillem

opengl: vaapi: early check EGLImageKHR creation

This fixes green screen with some systems that have a working vaDeriveImage
implementation but no EGL/DMABUF (or not recent enough).
parent 5870e657
......@@ -244,16 +244,51 @@ tc_vaegl_get_pool(const opengl_tex_converter_t *tc, unsigned requested_count)
if (!pool)
return NULL;
/* Check if a surface from the pool can be derived */
VAImage va_image;
/* Check if a surface from the pool can be derived and displayed via dmabuf
* */
bool success = false;
VAImage va_image = { .image_id = VA_INVALID_ID };
if (vlc_vaapi_DeriveImage(o, priv->vadpy, priv->va_surface_ids[0],
&va_image))
goto error;
assert(va_image.format.fourcc == priv->fourcc);
VABufferInfo va_buffer_info = (VABufferInfo) {
.mem_type = VA_SURFACE_ATTRIB_MEM_TYPE_DRM_PRIME
};
if (vlc_vaapi_AcquireBufferHandle(o ,priv->vadpy, va_image.buf,
&va_buffer_info))
goto error;
for (unsigned i = 0; i < va_image.num_planes; ++i)
{
picture_pool_Release(pool);
return NULL;
EGLint w = (va_image.width * tc->texs[i].w.num) / tc->texs[i].w.den;
EGLint h = (va_image.height * tc->texs[i].h.num) / tc->texs[i].h.den;
EGLImageKHR egl_image =
vaegl_image_create(tc, w, h, priv->drm_fourccs[i], va_buffer_info.handle,
va_image.offsets[i], va_image.pitches[i]);
if (egl_image == NULL)
{
msg_Warn(o, "Can't create Image KHR: kernel too old ?");
goto error;
}
vaegl_image_destroy(tc, egl_image);
}
vlc_vaapi_DestroyImage(o, priv->vadpy, va_image.image_id);
success = true;
error:
if (va_image.image_id != VA_INVALID_ID)
{
if (va_image.buf != VA_INVALID_ID)
vlc_vaapi_ReleaseBufferHandle(o, priv->vadpy, va_image.buf);
vlc_vaapi_DestroyImage(o, priv->vadpy, va_image.image_id);
}
if (!success)
{
picture_pool_Release(pool);
pool = NULL;
}
return pool;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment