summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Kindestam <antonki@kth.se>2018-03-04 11:16:47 +0100
committerKevin Mitchell <kevmitch@gmail.com>2018-03-04 16:56:06 -0800
commit33cffdcbac354179756db732c03b87026f710e8e (patch)
treefa9b126ee561ddc20dded1289fbff84bee86ab21
parentf0223e1b835894a20989523555a0f4e19cd36619 (diff)
downloadmpv-33cffdcbac354179756db732c03b87026f710e8e.tar.bz2
mpv-33cffdcbac354179756db732c03b87026f710e8e.tar.xz
context_drm_egl: Allow fallback EGLConfig formats
It turns out that Mali drivers are likely broken, and do not return GBM_FORMAT_ARGB8888 (they return GBM_FORMAT_XRGB8888) when getting EGL_NATIVE_VISUAL_ID for any EGLConfig, even though the resulting EGLConfig appears to be capable of alpha. It could also be potentially useful to allow an ARGB EGLConfig used with an XRGB framebuffer on some platforms, so we do that. (cf. weston) Unrelated indentation fix in gbm_format_to_string.
-rw-r--r--video/out/opengl/context_drm_egl.c66
1 files changed, 49 insertions, 17 deletions
diff --git a/video/out/opengl/context_drm_egl.c b/video/out/opengl/context_drm_egl.c
index 3f12b1a3da..1973092739 100644
--- a/video/out/opengl/context_drm_egl.c
+++ b/video/out/opengl/context_drm_egl.c
@@ -87,16 +87,36 @@ struct priv {
static const char *gbm_format_to_string(uint32_t format)
{
switch (format) {
- case GBM_FORMAT_XRGB8888:
- return "GBM_FORMAT_XRGB8888";
- case GBM_FORMAT_ARGB8888:
- return "GBM_FORMAT_ARGB8888";
- case GBM_FORMAT_XRGB2101010:
- return "GBM_FORMAT_XRGB2101010";
- case GBM_FORMAT_ARGB2101010:
- return "GBM_FORMAT_ARGB2101010";
- default:
- return "UNKNOWN";
+ case GBM_FORMAT_XRGB8888:
+ return "GBM_FORMAT_XRGB8888";
+ case GBM_FORMAT_ARGB8888:
+ return "GBM_FORMAT_ARGB8888";
+ case GBM_FORMAT_XRGB2101010:
+ return "GBM_FORMAT_XRGB2101010";
+ case GBM_FORMAT_ARGB2101010:
+ return "GBM_FORMAT_ARGB2101010";
+ default:
+ return "UNKNOWN";
+ }
+}
+
+// Allow falling back to an ARGB EGLConfig when we have an XRGB framebuffer.
+// Also allow falling back to an XRGB EGLConfig for ARGB framebuffers, since
+// this seems neccessary to work with broken Mali drivers that don't report
+// their EGLConfigs as supporting alpha properly.
+static uint32_t fallback_format_for(uint32_t format)
+{
+ switch (format) {
+ case GBM_FORMAT_XRGB8888:
+ return GBM_FORMAT_ARGB8888;
+ case GBM_FORMAT_ARGB8888:
+ return GBM_FORMAT_XRGB8888;
+ case GBM_FORMAT_XRGB2101010:
+ return GBM_FORMAT_ARGB2101010;
+ case GBM_FORMAT_ARGB2101010:
+ return GBM_FORMAT_XRGB2101010;
+ default:
+ return 0;
}
}
@@ -104,16 +124,28 @@ static int match_config_to_visual(void *user_data, EGLConfig *configs, int num_c
{
struct ra_ctx *ctx = (struct ra_ctx*)user_data;
struct priv *p = ctx->priv;
- const EGLint visual_id = (EGLint)p->gbm_format;
+ const EGLint visual_id[] = {
+ (EGLint)p->gbm_format,
+ (EGLint)fallback_format_for(p->gbm_format),
+ 0
+ };
- for (unsigned int i = 0; i < num_configs; ++i) {
- EGLint id;
+ for (unsigned int i = 0; visual_id[i] != 0; ++i) {
+ MP_VERBOSE(ctx, "Attempting to find EGLConfig matching %s\n",
+ gbm_format_to_string(visual_id[i]));
+ for (unsigned int j = 0; j < num_configs; ++j) {
+ EGLint id;
- if (!eglGetConfigAttrib(p->egl.display, configs[i], EGL_NATIVE_VISUAL_ID, &id))
- continue;
+ if (!eglGetConfigAttrib(p->egl.display, configs[j], EGL_NATIVE_VISUAL_ID, &id))
+ continue;
- if (visual_id == id)
- return i;
+ if (visual_id[i] == id) {
+ MP_VERBOSE(ctx, "Found matching EGLConfig for %s\n",
+ gbm_format_to_string(visual_id[i]));
+ return j;
+ }
+ }
+ MP_VERBOSE(ctx, "No matching EGLConfig for %s\n", gbm_format_to_string(visual_id[i]));
}
MP_ERR(ctx, "Could not find EGLConfig matching the GBM visual (%s).\n",