From 10e04a8eba30f667d2d05e49100318fc2c945cde Mon Sep 17 00:00:00 2001 From: Rafostar <40623528+Rafostar@users.noreply.github.com> Date: Tue, 22 Dec 2020 15:17:47 +0100 Subject: [PATCH] Flatpak: fix distorted gstreamer-vaapi colors with GLX on AMD #10 --- ...er-vaapi-glx-select-8-bit-color-size.patch | 83 +++++++++++++++++++ .../gstreamer-1.0/gstreamer-vaapi.json | 4 + 2 files changed, 87 insertions(+) create mode 100644 pkgs/flatpak/gstreamer-1.0/gstreamer-vaapi-glx-select-8-bit-color-size.patch diff --git a/pkgs/flatpak/gstreamer-1.0/gstreamer-vaapi-glx-select-8-bit-color-size.patch b/pkgs/flatpak/gstreamer-1.0/gstreamer-vaapi-glx-select-8-bit-color-size.patch new file mode 100644 index 00000000..5648cad9 --- /dev/null +++ b/pkgs/flatpak/gstreamer-1.0/gstreamer-vaapi-glx-select-8-bit-color-size.patch @@ -0,0 +1,83 @@ +From 65fc08032a41ae8779d1845dce2c00b1efa2955c Mon Sep 17 00:00:00 2001 +From: Rafostar +Date: Tue, 22 Dec 2020 15:08:21 +0100 +Subject: [PATCH] glx: Iterate over FBConfig and select 8 bit color size + +--- + gst-libs/gst/vaapi/gstvaapiutils_glx.c | 40 ++++++++++++++++++++++++-- + 1 file changed, 38 insertions(+), 2 deletions(-) + +diff --git a/gst-libs/gst/vaapi/gstvaapiutils_glx.c b/gst-libs/gst/vaapi/gstvaapiutils_glx.c +index ccd7832b..f73106c2 100644 +--- a/gst-libs/gst/vaapi/gstvaapiutils_glx.c ++++ b/gst-libs/gst/vaapi/gstvaapiutils_glx.c +@@ -301,9 +301,17 @@ gl_create_context (Display * dpy, int screen, GLContextState * parent) + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, ++ GLX_ALPHA_SIZE, 8, + None + }; + ++ const GLint rgba_colors[4] = { ++ GLX_RED_SIZE, ++ GLX_GREEN_SIZE, ++ GLX_BLUE_SIZE, ++ GLX_ALPHA_SIZE ++ }; ++ + cs = malloc (sizeof (*cs)); + if (!cs) + goto error; +@@ -333,11 +341,38 @@ gl_create_context (Display * dpy, int screen, GLContextState * parent) + if (!fbconfigs) + goto error; + +- /* Find out a GLXFBConfig compatible with the parent context */ ++ /* Find out a 8 bit GLXFBConfig compatible with the parent context */ + for (n = 0; n < n_fbconfigs; n++) { ++ gboolean sizes_correct = FALSE; ++ int cn; ++ + status = glXGetFBConfigAttrib (parent->display, + fbconfigs[n], GLX_FBCONFIG_ID, &val); +- if (status == Success && val == fbconfig_id) ++ if (status != Success) ++ goto error; ++ if (val != fbconfig_id) ++ continue; ++ ++ /* Iterate over RGBA sizes in fbconfig */ ++ for (cn = 0; cn < 4; cn++) { ++ int size = 0; ++ ++ status = glXGetFBConfigAttrib (parent->display, ++ fbconfigs[n], rgba_colors[cn], &size); ++ if (status != Success) ++ goto error; ++ ++ /* Last check is for alpha ++ * and alpha is optional */ ++ if (cn == 3) { ++ if (size == 0 || size == 8) { ++ sizes_correct = TRUE; ++ break; ++ } ++ } else if (size != 8) ++ break; ++ } ++ if (sizes_correct) + break; + } + if (n == n_fbconfigs) +@@ -809,6 +844,7 @@ gl_create_pixmap_object (Display * dpy, guint width, guint height) + GLX_RED_SIZE, 8, + GLX_GREEN_SIZE, 8, + GLX_BLUE_SIZE, 8, ++ GLX_ALPHA_SIZE, 8, + GL_NONE, + }; + +-- +2.28.0 + diff --git a/pkgs/flatpak/gstreamer-1.0/gstreamer-vaapi.json b/pkgs/flatpak/gstreamer-1.0/gstreamer-vaapi.json index 4b4d5e1a..3603e04f 100644 --- a/pkgs/flatpak/gstreamer-1.0/gstreamer-vaapi.json +++ b/pkgs/flatpak/gstreamer-1.0/gstreamer-vaapi.json @@ -12,6 +12,10 @@ "url": "https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi.git", "tag": "1.18.1", "commit": "f9e925af3645439f7b7a4580700fcd6ce17fc1c9" + }, + { + "type": "patch", + "path": "gstreamer-vaapi-glx-select-8-bit-color-size.patch" } ] }