From 9ef2e68bf405ebab616f164ee8e92a52e8262883 Mon Sep 17 00:00:00 2001 From: Antoine Damhet Date: Tue, 1 Sep 2020 12:47:53 +0200 Subject: [PATCH] update patches and target DMA-BUF support Signed-off-by: Antoine Damhet --- .SRCINFO | 50 +- 0001-deps-glad-Add-EGL.patch | 4 +- ...engl-Rename-gl-x11.c-to-gl-x11-glx.c.patch | 4 +- ...-libobs-opengl-Factor-out-GLX-winsys.patch | 4 +- ...-opengl-Introduce-the-X11-EGL-winsys.patch | 4 +- ...-deps-glad-Make-X11-required-as-well.patch | 4 +- ...Install-qtbase5-private-dev-on-Linux.patch | 4 +- ...e-X11-specific-code-to-obs-nix-x11.c.patch | 4 +- ...oduce-the-concept-of-a-Unix-platform.patch | 4 +- ...-UI-Set-the-Unix-platform-on-startup.patch | 4 +- ...ure-Fail-to-load-when-running-on-EGL.patch | 4 +- 0011-libobs-Add-a-Wayland-platform.patch | 4 +- ...y-to-use-the-platform-display-if-ava.patch | 4 +- ...gl-Introduce-an-EGL-Wayland-renderer.patch | 15 +- ...etrieve-Wayland-surface-from-QWindow.patch | 4 +- ...troy-display-when-becoming-invisible.patch | 4 +- ...-obs_display-when-QTToGSWindow-fails.patch | 4 +- ...Rename-callback-to-match-signal-name.patch | 4 +- ...gnore-Always-On-Top-on-Wayland-platf.patch | 4 +- ...play-CreateDisplay-public-and-allow-.patch | 4 +- ...ose-and-PlatformSurface-events-to-cr.patch | 4 +- ...Add-Linux-only-device_texture_create.patch | 275 ++++++++++ ...deps-glad-Add-DMA-BUF-EGL-extensions.patch | 185 +++++++ ...plement-DMA-BUF-importing-on-EGL-ren.patch | 469 ++++++++++++++++++ ...-libobs-opengl-Create-GLES2-contexts.patch | 40 ++ PKGBUILD | 50 +- 26 files changed, 1074 insertions(+), 86 deletions(-) create mode 100644 0021-libobs-graphics-Add-Linux-only-device_texture_create.patch create mode 100644 0022-deps-glad-Add-DMA-BUF-EGL-extensions.patch create mode 100644 0023-libobs-opengl-Implement-DMA-BUF-importing-on-EGL-ren.patch create mode 100644 0024-libobs-opengl-Create-GLES2-contexts.patch diff --git a/.SRCINFO b/.SRCINFO index a8cee24..8eab3f6 100644 --- a/.SRCINFO +++ b/.SRCINFO @@ -1,7 +1,7 @@ pkgbase = obs-studio-wayland pkgdesc = Free, open source software for live streaming and recording (with wayland patches) pkgver = 25.0.8 - pkgrel = 4 + pkgrel = 5 url = https://obsproject.com arch = x86_64 license = GPL2 @@ -55,28 +55,36 @@ pkgbase = obs-studio-wayland source = 0018-UI-Disable-and-ignore-Always-On-Top-on-Wayland-platf.patch source = 0019-UI-Make-OBSQTDisplay-CreateDisplay-public-and-allow-.patch source = 0020-UI-Check-for-Expose-and-PlatformSurface-events-to-cr.patch + source = 0021-libobs-graphics-Add-Linux-only-device_texture_create.patch + source = 0022-deps-glad-Add-DMA-BUF-EGL-extensions.patch + source = 0023-libobs-opengl-Implement-DMA-BUF-importing-on-EGL-ren.patch + source = 0024-libobs-opengl-Create-GLES2-contexts.patch sha512sums = a97c03dc218a4e03e48f6a7dc82b4a59ebeee2039f17be66bb847681ce9ff3d25e6e015be4af78fe44739f6fad5089b6e683d7657c2e4fde8e547df9a2594a08 sha512sums = 1ff0e088eed61554268009f3d8c5a23c0888bfbe860d6cb288ddf348108446c152fd87e2cb8f54613a88378d8474550632c90f924005d5e0343bf1a801339ccc - sha512sums = c322fb6dbe90bd3b9d298867731388ef306f3dbf038b2cb0f3f262c52981200ae949db6917b50c751b6920a40eef4b4fa8108ef5db9b83575ff3556024fa8f79 - sha512sums = 78670b678538cc43cc484e377c14bce6a55cb36be00c8db485e1e084b6eafd1833cae376b1f618b329dd2c4d50fa1de53c6bf252932edce97253f4b19f229500 - sha512sums = 9aaf118e233d6e7eda5f72b77eefedb641e11ddf0daff0463ae25cc4440de8e52903813215ec6bf33f82eb3c11febd166ce3859bfbe4044cd5e09a018ceb391c - sha512sums = 662438ef6e95dc8262403c931c8a749a6204bf4857f76e6fccee5084dcbe2ca693309ca078170e25d13be1cfd4d4a8746cbfc318c473d0ea52b332adb5e90c61 - sha512sums = c2be03913d95f8f449c9c9df6df8be41956923baf28f30091dc9a836c9e37d4e84ee930730edf2d3cc162886809d3a42e0fd4d79fd84f27a77c9e08802de6947 - sha512sums = 9b4722003418f27cbe7efed102b1a69aeb1cb9782d4249b14a7a7f10d0bce725465bda459cfd77e0e577e93f46b2ca0604f48c9a3c19e4a7b0d31b3386f0a8cf - sha512sums = 854482e4dc52293b2b488988bc05fa1835346780aa0213e4e102ece971d630fadc33d5941424673050eed7b5aba017cebe3248e62f3fb69483f389bca7aede39 - sha512sums = 8c5a049babe4804ab2b701591ab2ed9e597e974279431d728461807df5a37361164ce21b36d832017daa6e967bac545dc7c25f17433f4f6eef9c937da35ede34 - sha512sums = 5055c4bdd282743e7971be8eccce627eb0e1eb607bdf7f306748cd7898fcf08eaf64d870e753940682dac1691a6c959a539a032bae104b9d1a6fe4ca2e16187f - sha512sums = 00b1909e225e479483fd1b23053dbff5630526d927e5df7eb9fe3c340f27bf343d64796ee66e37b4e7f3f6bab8649ad93fa76b6b2a4628e31b1894cab417f247 - sha512sums = 5b33e379d789ae1e17354a210531498765ee64773f0a457f505de480b10c9adfa9116e121e8a31757fbc0bc241c71fd9921ac796b7c4b038f4dea2cf0a04aa48 - sha512sums = b0b9d213d39cbcfdbb83f61352c8488b6a95d414f4299d6e7e729aa485f911d60ef4f047ca13d006dc77b1c43a7f49db381fec5c1e695e3ec9da0e6eab99bb61 - sha512sums = 6dee9847d4d98704f393f1f788f2a0c22b630a3e4021846afa356ba2bb4be664e0b6e0f4b3ee2e58d889e7d33a90b516b91ad6bc6b2c241c22245be68ca098b7 - sha512sums = 01953fc6cd1a5789a6fa5be076da53ba5e8f56418b9f2badca3af6221acf72107e4f73a06a082b20894fdd18aa5263668411d72f4ef237af81f3f2ed86a63be8 - sha512sums = e5ad79d67b15b5b245b8f06da0321d221d47aa91297b2c8a6c941c2a49b78e413edf3c6fac08bdcf573fa4cdf1632d8ba1b1ad5697ae67ece96b0fd1f4264a91 - sha512sums = 7b93c07e21efc66ef444db68e25b4f66e7b3acd111b70dc8c6c39a6ebcff29b3238a749693134a59d568757732c93a8c39f1624686161b967828f6ef267b4ac6 - sha512sums = ff4e3e8b463a054df5a9b57b670971d2ba4dd4345e0cf7455d2d1d4dd8d911390533fdd42bfd027c3726a717e91ebb0cdf8855f47be065581179fa225f831d22 - sha512sums = 4fe456675224ab8692828ef022aae35899027ecbc98c70c47621e9b0e9839b332a5b1548736515ae09b3fcbe46ad17c35cd1338310d96e68db3337cc9dc2a2ee - sha512sums = e1358bdb7455aeae737c33a9180e225de288a25df16337ab2ed2a51e8ca6df66d89b863d1539a43a3c409b372a19cdbb5be37f842fc9320fb7046eabf69fcaba - sha512sums = cd3ab0c4c71e7c289732530dfb3230ebb35a4021335b3a0ad9bce5ec8c9ad352cb7b2fbb3ed1d6c5d7d9c32f27a90f5cfb2b1a00426def1f712d679da68f5795 + sha512sums = c4e653fc744000e0b178848b21f326065dbc83966876594fd349be9b847382afabd0321081e83f3ef094fe067c97d8200817a6cd752df260874bc943271a8658 + sha512sums = 2359bb8f074e5e5676eefe4c655d79611c901f0c8316275ced4d711be42f74ea29d0167ad018f51064fb8a51535969ae742c576a8afe9d710116f7379a1ee67d + sha512sums = 019fd92b51cb432d81d4265e85751040aeedc1f466181c2e2ec14c253335b1a23571e961ce6415e045fa51ea15731de6e540664276cdd76a3ce198d56cb13eac + sha512sums = 2f3186d862a78d41496e5a43dd01f5b56edac9873ea309bdcc8c9a83083437e7a252ef0d7373f403dc70ee4f1be8ae6fc430d710b80222ada7ae3ce16b8103ea + sha512sums = 457534c7ffb7dd0064b143cdfe472d079251ebe891885372127cbff2b6cb70e7d1e55a2da7956c5b6d940e03f8efa57265453fa23a8fb9fa92e4b2c33c959316 + sha512sums = 2af83bba2aa2dd2aed11f9a4f431d9aaeae7c6154c921247510e91bb523cede756d0777fe522a5a6db81a9a6989769a839f365e698511890308c5a0ec6e695ec + sha512sums = 3f8094c9e577d81bfc9222e436947aa890ce81b2f0e3e43f979a7192cc3e1ca35ca63949e061cecdc6be0579636b6a8e0d8ba21a05a0e11a94ba42210fff851a + sha512sums = d0ff4c1bcb156b2c81be38682d4f99b1388d25521f7981016e850f1e8989d0bfe0d3d71d4ec18382f861ca889bcdfb27dd4d73ca7f763f997a5e388bbc8bdcbc + sha512sums = 061f7122d5ff8a98dd4ef875c2d7dc60a2dc30627a01a960bd78539e6c7f2bcbfda48f9f42f9f61434f6263686641af2cfb4d6971682be542b6c6f037986e6da + sha512sums = a91815239465656a0ab5902e524277659e0e3ab953d0539bc8ead8f65b3a279a801c02635aad541f871f5007943af704c8c64fec90534c66fe6e418d24787300 + sha512sums = e3bdcdae93fa134c1174bf84152385ae28eb7fd82504331f4dccfd46b6565eb605b63acd4972bed08bbe765c7e213b93d94077a9fafcfe33064b4a526f02f7a6 + sha512sums = f134c9fed318fde1d11f59e56676cc512bdea81df6a5ce90202759b300405d02981b6586e090cbae65fb730ca352c3942eeec636bb7d5a571475a815f73be89d + sha512sums = 530846836b8efc6b7549fb6d2b4288ac9782420fd8e51c988d579f701bc4a1f58b7f941d472ad7d4ab07869e45dfc905c3927a3ad735178a109881ed02ffdb77 + sha512sums = 014a9dd855e696a33e3b5c8f8a11ec6cf1edc6e0e6478cc5f11530c5535a1d1dfaaa75c5a3de258178e1ab16256fb8303b18c8a69407febe58a7d860b2396fda + sha512sums = afb5a5b0cfa09407efe6924b37f8c3b26ccf244acc4a99fcee0eb6705855d2dc8589ecbdb2fcf9066c9ec6d947a6810f58efe34362aa451af4cdf7fa30f2e4e4 + sha512sums = 5a09040d91bf293389c328f758416f29840eaf6b0acd78adf14b47fc48c417fb1b02ab97dc90c7d8381bc9ffa817cbc6acc83fd318ba85d73d39ae8f4f7a35e1 + sha512sums = d1ed4b6bb07b2da105e2d69c5af1d61bcd39f141c2500e606f251f2220632f4173d3b3de9e2c88dd0bf2e230cba291cda50fb3a7ca89ff391d0e5e36b2e4aa2f + sha512sums = c5b82ddaad7bcc5608168a318e6dde9a0aa0d1dc789d29751a9b22bec2b68288c71e5719c620073ee3c8d9bbf63d60e1634a351cc155b8f2b823d0cbc83cf578 + sha512sums = c9d1e42cb87964b764a70044aa828c8d712c709d9e1245f644e8aa2f4576cd33c78e81b9b736d39939959aa3811fe4a9cb6970c8278c22d3f5b7f48d43ae1d55 + sha512sums = a9893913797b503249d182ebbac0452827a837187e7817c46ab76df5d004ada810c2ff8523518d408daf396a4c72f707777a3dadeca598f404b074581f0125e8 + sha512sums = 848bcf4f525cca508131960fe6bb2757b0975065f680da9c8d692b5ea28b4c5cca7c2e71f1498c8425c0549fc23a41895638da9e1c433d05e6425ea36dc3ec1b + sha512sums = 71e11ef607a0371c378db0d50155530d2a918ca47fe15dd29dab36f50dda4a8e7a487f3600b4b03a240db4e84b73c5b49186ca275fb1968de8f15c8d16e8a813 + sha512sums = 73b82cd530e26d3751de9d3e54da0994cbd5d7c9e5ceed7088d50ef4eda8a8c36d30812e8e4a82be014813ed09aefcfa14e7361189a7b4cf763f20aa2ebda7b7 + sha512sums = 1442f7918df45b37e9b3bef05573d4f8c7224f950a85fd0b6200a2ca70b377344ecf37ed69b5474453f584d0992b446383b1a708c326e993a9c815882ba4232f pkgname = obs-studio-wayland diff --git a/0001-deps-glad-Add-EGL.patch b/0001-deps-glad-Add-EGL.patch index a546270..53a3fbf 100644 --- a/0001-deps-glad-Add-EGL.patch +++ b/0001-deps-glad-Add-EGL.patch @@ -1,7 +1,7 @@ -From 4521189274e652de6d2098337038c412501c570d Mon Sep 17 00:00:00 2001 +From 48e3ddab8d44f1bb5c0430aef3b480c3c73a342d Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 9 Mar 2020 13:10:16 -0300 -Subject: [PATCH 01/20] deps-glad: Add EGL +Subject: [PATCH 01/24] deps-glad: Add EGL The code is generated by https://glad.dav1d.de/ --- diff --git a/0002-libobs-opengl-Rename-gl-x11.c-to-gl-x11-glx.c.patch b/0002-libobs-opengl-Rename-gl-x11.c-to-gl-x11-glx.c.patch index 2a0e728..eed81e4 100644 --- a/0002-libobs-opengl-Rename-gl-x11.c-to-gl-x11-glx.c.patch +++ b/0002-libobs-opengl-Rename-gl-x11.c-to-gl-x11-glx.c.patch @@ -1,7 +1,7 @@ -From 1367a881c16592a486229ac024df2cf08fb43b7a Mon Sep 17 00:00:00 2001 +From 3e53cda423e6969a8e7d842c5f1b0fe58f2ccfd6 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 9 Mar 2020 13:19:31 -0300 -Subject: [PATCH 02/20] libobs-opengl: Rename gl-x11.c to gl-x11-glx.c +Subject: [PATCH 02/24] libobs-opengl: Rename gl-x11.c to gl-x11-glx.c This is in preparation for the future abstraction layer (gl-x11-*) and also to match the actual name of the windowing system. When diff --git a/0003-libobs-opengl-Factor-out-GLX-winsys.patch b/0003-libobs-opengl-Factor-out-GLX-winsys.patch index 8e4728a..73b5e69 100644 --- a/0003-libobs-opengl-Factor-out-GLX-winsys.patch +++ b/0003-libobs-opengl-Factor-out-GLX-winsys.patch @@ -1,7 +1,7 @@ -From 9394af80060680154a3c00e8ea23cced0d06179d Mon Sep 17 00:00:00 2001 +From e1eb076e87330b4cc197ae9f88cb1ede215dea71 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 9 Mar 2020 16:46:37 -0300 -Subject: [PATCH 03/20] libobs-opengl: Factor out GLX winsys +Subject: [PATCH 03/24] libobs-opengl: Factor out GLX winsys Move the GLX-related code to gl-x11-glx, and introduce gl-nix as a winsys-agnostic abstraction layer. gl-nix serves as the runtime diff --git a/0004-libobs-opengl-Introduce-the-X11-EGL-winsys.patch b/0004-libobs-opengl-Introduce-the-X11-EGL-winsys.patch index 4f20851..351d4e4 100644 --- a/0004-libobs-opengl-Introduce-the-X11-EGL-winsys.patch +++ b/0004-libobs-opengl-Introduce-the-X11-EGL-winsys.patch @@ -1,7 +1,7 @@ -From 12ef68d9914bd4aec60ef9bdf77f67099534a208 Mon Sep 17 00:00:00 2001 +From 1219e3656bd1cd07dccb454684e3e535c9de732d Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 9 Mar 2020 17:35:49 -0300 -Subject: [PATCH 04/20] libobs-opengl: Introduce the X11/EGL winsys +Subject: [PATCH 04/24] libobs-opengl: Introduce the X11/EGL winsys Introduce the EGL/X11 winsys, and use it when the OBS_USE_EGL environment variable is defined. This variable is only temporary, for future commits diff --git a/0005-deps-glad-Make-X11-required-as-well.patch b/0005-deps-glad-Make-X11-required-as-well.patch index b4c02b8..73bbd34 100644 --- a/0005-deps-glad-Make-X11-required-as-well.patch +++ b/0005-deps-glad-Make-X11-required-as-well.patch @@ -1,7 +1,7 @@ -From ce73c0d635a4cff3ab254235c48e8ebe0b371cef Mon Sep 17 00:00:00 2001 +From 0be95c8ba491b168db8b44319e53af10e0646c07 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 11 Apr 2020 23:49:05 -0300 -Subject: [PATCH 05/20] deps/glad: Make X11 required as well +Subject: [PATCH 05/24] deps/glad: Make X11 required as well To keep consistency with the EGL line --- diff --git a/0006-ci-Install-qtbase5-private-dev-on-Linux.patch b/0006-ci-Install-qtbase5-private-dev-on-Linux.patch index 3c2ba44..e83c953 100644 --- a/0006-ci-Install-qtbase5-private-dev-on-Linux.patch +++ b/0006-ci-Install-qtbase5-private-dev-on-Linux.patch @@ -1,7 +1,7 @@ -From 74515e17f35d9afb75a9ea7ec024e36782b168f6 Mon Sep 17 00:00:00 2001 +From 4056740eb1ba8de4eb0b4ec6621c48e3ca5fb314 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 6 Mar 2020 16:22:01 -0300 -Subject: [PATCH 06/20] ci: Install qtbase5-private-dev on Linux +Subject: [PATCH 06/24] ci: Install qtbase5-private-dev on Linux List this dependency both under CI/install-dependencies-linux.sh, and .github/workflows/main.yml. diff --git a/0007-libobs-nix-Move-X11-specific-code-to-obs-nix-x11.c.patch b/0007-libobs-nix-Move-X11-specific-code-to-obs-nix-x11.c.patch index e5e1c41..a82e27a 100644 --- a/0007-libobs-nix-Move-X11-specific-code-to-obs-nix-x11.c.patch +++ b/0007-libobs-nix-Move-X11-specific-code-to-obs-nix-x11.c.patch @@ -1,7 +1,7 @@ -From 7301a59e6b593bc6d016d3de74e80c1b1361b508 Mon Sep 17 00:00:00 2001 +From 7aa2fd8902ede3ad5eabe3e0152d9688d12cf9bb Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 6 Mar 2020 17:24:33 -0300 -Subject: [PATCH 07/20] libobs/nix: Move X11-specific code to obs-nix-x11.c +Subject: [PATCH 07/24] libobs/nix: Move X11-specific code to obs-nix-x11.c Currently, obs-nix.c is highly tied to the X11 display server. It includes X11 headers directly, and make use diff --git a/0008-libobs-Introduce-the-concept-of-a-Unix-platform.patch b/0008-libobs-Introduce-the-concept-of-a-Unix-platform.patch index 78fc20e..f42e271 100644 --- a/0008-libobs-Introduce-the-concept-of-a-Unix-platform.patch +++ b/0008-libobs-Introduce-the-concept-of-a-Unix-platform.patch @@ -1,7 +1,7 @@ -From 6e1eef3b6dd72ca2e7ab212e0eb69685347787ea Mon Sep 17 00:00:00 2001 +From 53d14fdc3ddcd1e5232e9eb3dbd6cb993893b4b1 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 6 Mar 2020 17:50:41 -0300 -Subject: [PATCH 08/20] libobs: Introduce the concept of a Unix platform +Subject: [PATCH 08/24] libobs: Introduce the concept of a Unix platform This is a Unix-specific code. The only available platforms at this point are the X11/GLX and X11/EGL platforms. diff --git a/0009-UI-Set-the-Unix-platform-on-startup.patch b/0009-UI-Set-the-Unix-platform-on-startup.patch index 7dc914f..15e2063 100644 --- a/0009-UI-Set-the-Unix-platform-on-startup.patch +++ b/0009-UI-Set-the-Unix-platform-on-startup.patch @@ -1,7 +1,7 @@ -From 9f0f337d03700defaa24fc77cf2f4fbd861b8fd4 Mon Sep 17 00:00:00 2001 +From a80131faaa1fad9aff4c4cbe79d49016ff24a6e7 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 7 Apr 2020 23:17:02 -0300 -Subject: [PATCH 09/20] UI: Set the Unix platform on startup +Subject: [PATCH 09/24] UI: Set the Unix platform on startup Move the OBS_USE_EGL environment variable check to obs-app.cpp, and set the OBS platform to be either OBS_NIX_PLATFORM_X11_GLX diff --git a/0010-linux-capture-Fail-to-load-when-running-on-EGL.patch b/0010-linux-capture-Fail-to-load-when-running-on-EGL.patch index 0d69dcf..c010cb3 100644 --- a/0010-linux-capture-Fail-to-load-when-running-on-EGL.patch +++ b/0010-linux-capture-Fail-to-load-when-running-on-EGL.patch @@ -1,7 +1,7 @@ -From 56c897b64464170cdcf6ad0cdd6de7a3b9addff1 Mon Sep 17 00:00:00 2001 +From 7f6041c7cb282d5354ad4afc545341f1437d1b46 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 8 Apr 2020 23:58:43 -0300 -Subject: [PATCH 10/20] linux-capture: Fail to load when running on EGL +Subject: [PATCH 10/24] linux-capture: Fail to load when running on EGL Right now, linux-capture hard-depends on GLX. Disable it when running under EGL. diff --git a/0011-libobs-Add-a-Wayland-platform.patch b/0011-libobs-Add-a-Wayland-platform.patch index 11bce62..e5402a1 100644 --- a/0011-libobs-Add-a-Wayland-platform.patch +++ b/0011-libobs-Add-a-Wayland-platform.patch @@ -1,7 +1,7 @@ -From f2c169236834251a78e8185b78fdec628762535f Mon Sep 17 00:00:00 2001 +From 4f0e966291fc8f6780f1ff6439ada95e63847b95 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Fri, 6 Mar 2020 18:53:42 -0300 -Subject: [PATCH 11/20] libobs: Add a Wayland platform +Subject: [PATCH 11/24] libobs: Add a Wayland platform Introduce the OBS_NIX_PLATFORM_WAYLAND enum value, and try to detect it when OBS Studio runs by looking into the platform name. diff --git a/0012-libobs-opengl-Try-to-use-the-platform-display-if-ava.patch b/0012-libobs-opengl-Try-to-use-the-platform-display-if-ava.patch index b4997e7..2bf9892 100644 --- a/0012-libobs-opengl-Try-to-use-the-platform-display-if-ava.patch +++ b/0012-libobs-opengl-Try-to-use-the-platform-display-if-ava.patch @@ -1,7 +1,7 @@ -From ff3dbf578c696659433bc30c039c4e2e5d10765a Mon Sep 17 00:00:00 2001 +From 8c482e031d9891e13d787653135651426661b3b6 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Sat, 11 Apr 2020 23:32:16 -0300 -Subject: [PATCH 12/20] libobs-opengl: Try to use the platform display if +Subject: [PATCH 12/24] libobs-opengl: Try to use the platform display if available We need to ensure we're running all X11 code on the same display. diff --git a/0013-libobs-opengl-Introduce-an-EGL-Wayland-renderer.patch b/0013-libobs-opengl-Introduce-an-EGL-Wayland-renderer.patch index 401282f..4bae847 100644 --- a/0013-libobs-opengl-Introduce-an-EGL-Wayland-renderer.patch +++ b/0013-libobs-opengl-Introduce-an-EGL-Wayland-renderer.patch @@ -1,16 +1,16 @@ -From b6d1651ad733f0b59c442ceb29c3e936554df5b5 Mon Sep 17 00:00:00 2001 +From c5e9210a3b0d5a19cfc1b74ea400f049d4983992 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 9 Mar 2020 21:09:11 -0300 -Subject: [PATCH 13/20] libobs-opengl: Introduce an EGL/Wayland renderer +Subject: [PATCH 13/24] libobs-opengl: Introduce an EGL/Wayland renderer Introduce a new Wayland/EGL renderer. --- libobs-opengl/CMakeLists.txt | 23 +++ libobs-opengl/gl-nix.c | 7 +- libobs-opengl/gl-nix.h | 1 + - libobs-opengl/gl-wayland-egl.c | 339 +++++++++++++++++++++++++++++++++ + libobs-opengl/gl-wayland-egl.c | 342 +++++++++++++++++++++++++++++++++ libobs-opengl/gl-wayland-egl.h | 22 +++ - 5 files changed, 391 insertions(+), 1 deletion(-) + 5 files changed, 394 insertions(+), 1 deletion(-) create mode 100644 libobs-opengl/gl-wayland-egl.c create mode 100644 libobs-opengl/gl-wayland-egl.h @@ -87,10 +87,10 @@ index f5532719..741154da 100644 #include "gl-subsystem.h" diff --git a/libobs-opengl/gl-wayland-egl.c b/libobs-opengl/gl-wayland-egl.c new file mode 100644 -index 00000000..28e8b1c0 +index 00000000..aad6993e --- /dev/null +++ b/libobs-opengl/gl-wayland-egl.c -@@ -0,0 +1,339 @@ +@@ -0,0 +1,342 @@ +/****************************************************************************** + Copyright (C) 2019 by Jason Francis + @@ -404,6 +404,9 @@ index 00000000..28e8b1c0 +{ + struct gl_platform *plat = device->plat; + struct gl_windowinfo *wi = device->cur_swap->wi; ++ if (eglSwapInterval(plat->display, 0) == EGL_FALSE) { ++ blog(LOG_ERROR, "eglSwapInterval failed"); ++ } + if (eglSwapBuffers(plat->display, wi->egl_surface) == EGL_FALSE) { + blog(LOG_ERROR, "eglSwapBuffers failed"); + } diff --git a/0014-UI-Retrieve-Wayland-surface-from-QWindow.patch b/0014-UI-Retrieve-Wayland-surface-from-QWindow.patch index cdb9bc6..5017f0c 100644 --- a/0014-UI-Retrieve-Wayland-surface-from-QWindow.patch +++ b/0014-UI-Retrieve-Wayland-surface-from-QWindow.patch @@ -1,7 +1,7 @@ -From ffe8b9083f11be627dbfabaf5034d1976d03551a Mon Sep 17 00:00:00 2001 +From e628aba53a2c4e327460d9b005ecef56bf54ee72 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Mon, 9 Mar 2020 21:23:37 -0300 -Subject: [PATCH 14/20] UI: Retrieve Wayland surface from QWindow +Subject: [PATCH 14/24] UI: Retrieve Wayland surface from QWindow On Wayland, we want to query the window's underlying platform for the Wayland surface, instead of foolishly diff --git a/0015-UI-Destroy-display-when-becoming-invisible.patch b/0015-UI-Destroy-display-when-becoming-invisible.patch index 36ad3aa..cb894e3 100644 --- a/0015-UI-Destroy-display-when-becoming-invisible.patch +++ b/0015-UI-Destroy-display-when-becoming-invisible.patch @@ -1,7 +1,7 @@ -From 64ab8a3f8e7bc6826dcf2a378e32e4dabb7eadba Mon Sep 17 00:00:00 2001 +From 334bad8172f854d14e3079f03349d16a4ce2df73 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Tue, 18 Aug 2020 19:38:29 -0300 -Subject: [PATCH 15/20] UI: Destroy display when becoming invisible +Subject: [PATCH 15/24] UI: Destroy display when becoming invisible When a window is made invisible, then visible again, the obs_display is reused. Turns out, QT destroys the wl_surface diff --git a/0016-UI-Don-t-create-obs_display-when-QTToGSWindow-fails.patch b/0016-UI-Don-t-create-obs_display-when-QTToGSWindow-fails.patch index 01899b0..f07addd 100644 --- a/0016-UI-Don-t-create-obs_display-when-QTToGSWindow-fails.patch +++ b/0016-UI-Don-t-create-obs_display-when-QTToGSWindow-fails.patch @@ -1,7 +1,7 @@ -From 107533c8298418360acbbbf7b51aa9ea1ffc30a0 Mon Sep 17 00:00:00 2001 +From 7b989da443d84cca425c3669f072e413825bc657 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 19 Aug 2020 10:11:08 -0300 -Subject: [PATCH 16/20] UI: Don't create obs_display when QTToGSWindow fails +Subject: [PATCH 16/24] UI: Don't create obs_display when QTToGSWindow fails Right after showing the OBSQTDisplay widget, it may happen that a wl_surface is not yet created and attached to the window. When this diff --git a/0017-UI-Rename-callback-to-match-signal-name.patch b/0017-UI-Rename-callback-to-match-signal-name.patch index 477e80c..eb9e54e 100644 --- a/0017-UI-Rename-callback-to-match-signal-name.patch +++ b/0017-UI-Rename-callback-to-match-signal-name.patch @@ -1,7 +1,7 @@ -From bd07471e8298f4b71c69d6a25ded5293141fd4fc Mon Sep 17 00:00:00 2001 +From c69023203d043f4ed5d600911a11dacce1331b4f Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 19 Aug 2020 13:08:01 -0300 -Subject: [PATCH 17/20] UI: Rename callback to match signal name +Subject: [PATCH 17/24] UI: Rename callback to match signal name The sizeChanged callback is connected to the screenChanged signal, and evidently the naming doesn't match. Rename the callback to diff --git a/0018-UI-Disable-and-ignore-Always-On-Top-on-Wayland-platf.patch b/0018-UI-Disable-and-ignore-Always-On-Top-on-Wayland-platf.patch index 79ad1ae..0e11e9c 100644 --- a/0018-UI-Disable-and-ignore-Always-On-Top-on-Wayland-platf.patch +++ b/0018-UI-Disable-and-ignore-Always-On-Top-on-Wayland-platf.patch @@ -1,7 +1,7 @@ -From d4b8722c46a5ff92ed2688e8f67e33c8af9d2de0 Mon Sep 17 00:00:00 2001 +From f385ff60cf00ed6bac84483bd5da9aa84638bb14 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Wed, 19 Aug 2020 15:09:26 -0300 -Subject: [PATCH 18/20] UI: Disable and ignore Always On Top on Wayland +Subject: [PATCH 18/24] UI: Disable and ignore Always On Top on Wayland platforms This is a dangerous operation on Wayland, and is crashing not only diff --git a/0019-UI-Make-OBSQTDisplay-CreateDisplay-public-and-allow-.patch b/0019-UI-Make-OBSQTDisplay-CreateDisplay-public-and-allow-.patch index 3509756..1ccd4cc 100644 --- a/0019-UI-Make-OBSQTDisplay-CreateDisplay-public-and-allow-.patch +++ b/0019-UI-Make-OBSQTDisplay-CreateDisplay-public-and-allow-.patch @@ -1,7 +1,7 @@ -From 484ff6702e4c230a4769cdb7289c013de9b12b58 Mon Sep 17 00:00:00 2001 +From e6406c1fb4fcd81383dd11847d0a21908a030877 Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 20 Aug 2020 11:57:19 -0300 -Subject: [PATCH 19/20] UI: Make OBSQTDisplay::CreateDisplay() public and allow +Subject: [PATCH 19/24] UI: Make OBSQTDisplay::CreateDisplay() public and allow forcing creation This will be used by a new event filter, added only when running as a Wayland diff --git a/0020-UI-Check-for-Expose-and-PlatformSurface-events-to-cr.patch b/0020-UI-Check-for-Expose-and-PlatformSurface-events-to-cr.patch index 1191439..bab2a3e 100644 --- a/0020-UI-Check-for-Expose-and-PlatformSurface-events-to-cr.patch +++ b/0020-UI-Check-for-Expose-and-PlatformSurface-events-to-cr.patch @@ -1,7 +1,7 @@ -From db7ed40e1e0c566d4c6bed53c283327c9d55ce4c Mon Sep 17 00:00:00 2001 +From af18bb55d32a6794cd6ce2dd5f16d9a8e6bc700e Mon Sep 17 00:00:00 2001 From: Georges Basile Stavracas Neto Date: Thu, 20 Aug 2020 11:58:45 -0300 -Subject: [PATCH 20/20] UI: Check for Expose and PlatformSurface events to +Subject: [PATCH 20/24] UI: Check for Expose and PlatformSurface events to create display This is a workaround for QWaylandWindow never becoming exposed, or diff --git a/0021-libobs-graphics-Add-Linux-only-device_texture_create.patch b/0021-libobs-graphics-Add-Linux-only-device_texture_create.patch new file mode 100644 index 0000000..2927e47 --- /dev/null +++ b/0021-libobs-graphics-Add-Linux-only-device_texture_create.patch @@ -0,0 +1,275 @@ +From 35142e4c7c0ff41dfd869dbcdcef05ebc47102d3 Mon Sep 17 00:00:00 2001 +From: Georges Basile Stavracas Neto +Date: Thu, 12 Mar 2020 23:50:18 -0300 +Subject: [PATCH 21/24] libobs/graphics: Add Linux-only + device_texture_create_from_dmabuf + +The implementation are stubs as of now +--- + libobs-opengl/gl-nix.c | 11 +++++++++++ + libobs-opengl/gl-nix.h | 6 ++++++ + libobs-opengl/gl-wayland-egl.c | 21 +++++++++++++++++++++ + libobs-opengl/gl-x11-egl.c | 21 +++++++++++++++++++++ + libobs-opengl/gl-x11-glx.c | 21 +++++++++++++++++++++ + libobs/graphics/device-exports.h | 10 ++++++++++ + libobs/graphics/graphics-imports.c | 2 ++ + libobs/graphics/graphics-internal.h | 6 ++++++ + libobs/graphics/graphics.c | 19 +++++++++++++++++++ + libobs/graphics/graphics.h | 9 +++++++++ + 10 files changed, 126 insertions(+) + +diff --git a/libobs-opengl/gl-nix.c b/libobs-opengl/gl-nix.c +index 6c272c3d..acbd154a 100644 +--- a/libobs-opengl/gl-nix.c ++++ b/libobs-opengl/gl-nix.c +@@ -123,3 +123,14 @@ extern void device_present(gs_device_t *device) + { + gl_vtable->device_present(device); + } ++ ++extern struct gs_texture *device_texture_create_from_dmabuf( ++ gs_device_t *device, unsigned int width, unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, const int *fds, ++ const uint32_t *strides, const uint32_t *offsets, ++ const uint64_t *modifiers) ++{ ++ return gl_vtable->device_texture_create_from_dmabuf( ++ device, width, height, color_format, n_planes, fds, strides, ++ offsets, modifiers); ++} +diff --git a/libobs-opengl/gl-nix.h b/libobs-opengl/gl-nix.h +index 741154da..3038c0cf 100644 +--- a/libobs-opengl/gl-nix.h ++++ b/libobs-opengl/gl-nix.h +@@ -53,4 +53,10 @@ struct gl_winsys_vtable { + gs_swapchain_t *swap); + + void (*device_present)(gs_device_t *device); ++ ++ struct gs_texture *(*device_texture_create_from_dmabuf)( ++ gs_device_t *device, unsigned int width, unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, ++ const int *fds, const uint32_t *strides, ++ const uint32_t *offsets, const uint64_t *modifiers); + }; +diff --git a/libobs-opengl/gl-wayland-egl.c b/libobs-opengl/gl-wayland-egl.c +index aad6993e..3968736d 100644 +--- a/libobs-opengl/gl-wayland-egl.c ++++ b/libobs-opengl/gl-wayland-egl.c +@@ -319,6 +319,25 @@ static void gl_wayland_egl_device_present(gs_device_t *device) + } + } + ++static struct gs_texture *gl_wayland_egl_device_texture_create_from_dmabuf( ++ gs_device_t *device, unsigned int width, unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, const int *fds, ++ const uint32_t *strides, const uint32_t *offsets, ++ const uint64_t *modifiers) ++{ ++ UNUSED_PARAMETER(device); ++ UNUSED_PARAMETER(width); ++ UNUSED_PARAMETER(height); ++ UNUSED_PARAMETER(color_format); ++ UNUSED_PARAMETER(n_planes); ++ UNUSED_PARAMETER(fds); ++ UNUSED_PARAMETER(strides); ++ UNUSED_PARAMETER(offsets); ++ UNUSED_PARAMETER(modifiers); ++ ++ return NULL; ++} ++ + static const struct gl_winsys_vtable egl_wayland_winsys_vtable = { + .windowinfo_create = gl_wayland_egl_windowinfo_create, + .windowinfo_destroy = gl_wayland_egl_windowinfo_destroy, +@@ -334,6 +353,8 @@ static const struct gl_winsys_vtable egl_wayland_winsys_vtable = { + .update = gl_wayland_egl_update, + .device_load_swapchain = gl_wayland_egl_device_load_swapchain, + .device_present = gl_wayland_egl_device_present, ++ .device_texture_create_from_dmabuf = ++ gl_wayland_egl_device_texture_create_from_dmabuf, + }; + + const struct gl_winsys_vtable *gl_wayland_egl_get_winsys_vtable(void) +diff --git a/libobs-opengl/gl-x11-egl.c b/libobs-opengl/gl-x11-egl.c +index 47b8e420..7a9c5975 100644 +--- a/libobs-opengl/gl-x11-egl.c ++++ b/libobs-opengl/gl-x11-egl.c +@@ -634,6 +634,25 @@ static void gl_x11_egl_device_present(gs_device_t *device) + get_egl_error_string()); + } + ++static struct gs_texture *gl_x11_egl_device_texture_create_from_dmabuf( ++ gs_device_t *device, unsigned int width, unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, const int *fds, ++ const uint32_t *strides, const uint32_t *offsets, ++ const uint64_t *modifiers) ++{ ++ UNUSED_PARAMETER(device); ++ UNUSED_PARAMETER(width); ++ UNUSED_PARAMETER(height); ++ UNUSED_PARAMETER(color_format); ++ UNUSED_PARAMETER(n_planes); ++ UNUSED_PARAMETER(fds); ++ UNUSED_PARAMETER(strides); ++ UNUSED_PARAMETER(offsets); ++ UNUSED_PARAMETER(modifiers); ++ ++ return NULL; ++} ++ + static const struct gl_winsys_vtable egl_x11_winsys_vtable = { + .windowinfo_create = gl_x11_egl_windowinfo_create, + .windowinfo_destroy = gl_x11_egl_windowinfo_destroy, +@@ -649,6 +668,8 @@ static const struct gl_winsys_vtable egl_x11_winsys_vtable = { + .update = gl_x11_egl_update, + .device_load_swapchain = gl_x11_egl_device_load_swapchain, + .device_present = gl_x11_egl_device_present, ++ .device_texture_create_from_dmabuf = ++ gl_x11_egl_device_texture_create_from_dmabuf, + }; + + const struct gl_winsys_vtable *gl_x11_egl_get_winsys_vtable(void) +diff --git a/libobs-opengl/gl-x11-glx.c b/libobs-opengl/gl-x11-glx.c +index a562b564..802be3ef 100644 +--- a/libobs-opengl/gl-x11-glx.c ++++ b/libobs-opengl/gl-x11-glx.c +@@ -579,6 +579,25 @@ static void gl_x11_glx_device_present(gs_device_t *device) + glXSwapBuffers(display, window); + } + ++static struct gs_texture *gl_x11_glx_device_texture_create_from_dmabuf( ++ gs_device_t *device, unsigned int width, unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, const int *fds, ++ const uint32_t *strides, const uint32_t *offsets, ++ const uint64_t *modifiers) ++{ ++ UNUSED_PARAMETER(device); ++ UNUSED_PARAMETER(width); ++ UNUSED_PARAMETER(height); ++ UNUSED_PARAMETER(color_format); ++ UNUSED_PARAMETER(n_planes); ++ UNUSED_PARAMETER(fds); ++ UNUSED_PARAMETER(strides); ++ UNUSED_PARAMETER(offsets); ++ UNUSED_PARAMETER(modifiers); ++ ++ return NULL; ++} ++ + static const struct gl_winsys_vtable glx_winsys_vtable = { + .windowinfo_create = gl_x11_glx_windowinfo_create, + .windowinfo_destroy = gl_x11_glx_windowinfo_destroy, +@@ -594,6 +613,8 @@ static const struct gl_winsys_vtable glx_winsys_vtable = { + .update = gl_x11_glx_update, + .device_load_swapchain = gl_x11_glx_device_load_swapchain, + .device_present = gl_x11_glx_device_present, ++ .device_texture_create_from_dmabuf = ++ gl_x11_glx_device_texture_create_from_dmabuf, + }; + + const struct gl_winsys_vtable *gl_x11_glx_get_winsys_vtable(void) +diff --git a/libobs/graphics/device-exports.h b/libobs/graphics/device-exports.h +index 9b4e14b7..06ae4885 100644 +--- a/libobs/graphics/device-exports.h ++++ b/libobs/graphics/device-exports.h +@@ -166,6 +166,16 @@ EXPORT void device_debug_marker_begin(gs_device_t *device, + const float color[4]); + EXPORT void device_debug_marker_end(gs_device_t *device); + ++#if __linux__ ++ ++EXPORT gs_texture_t *device_texture_create_from_dmabuf( ++ gs_device_t *device, unsigned int width, unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, const int *fds, ++ const uint32_t *strides, const uint32_t *offsets, ++ const uint64_t *modifiers); ++ ++#endif ++ + #ifdef __cplusplus + } + #endif +diff --git a/libobs/graphics/graphics-imports.c b/libobs/graphics/graphics-imports.c +index 0d3c2593..1b5b6fda 100644 +--- a/libobs/graphics/graphics-imports.c ++++ b/libobs/graphics/graphics-imports.c +@@ -216,6 +216,8 @@ bool load_graphics_imports(struct gs_exports *exports, void *module, + GRAPHICS_IMPORT_OPTIONAL(device_stagesurface_create_nv12); + GRAPHICS_IMPORT_OPTIONAL(device_register_loss_callbacks); + GRAPHICS_IMPORT_OPTIONAL(device_unregister_loss_callbacks); ++#elif __linux__ ++ GRAPHICS_IMPORT(device_texture_create_from_dmabuf); + #endif + + return success; +diff --git a/libobs/graphics/graphics-internal.h b/libobs/graphics/graphics-internal.h +index 4154688c..4e8f4e53 100644 +--- a/libobs/graphics/graphics-internal.h ++++ b/libobs/graphics/graphics-internal.h +@@ -315,6 +315,12 @@ struct gs_exports { + gs_device_t *device, const struct gs_device_loss *callbacks); + void (*device_unregister_loss_callbacks)(gs_device_t *device, + void *data); ++#elif __linux__ ++ struct gs_texture *(*device_texture_create_from_dmabuf)( ++ gs_device_t *device, unsigned int width, unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, ++ const int *fds, const uint32_t *strides, ++ const uint32_t *offsets, const uint64_t *modifiers); + #endif + }; + +diff --git a/libobs/graphics/graphics.c b/libobs/graphics/graphics.c +index 902ba4b6..ea403ac8 100644 +--- a/libobs/graphics/graphics.c ++++ b/libobs/graphics/graphics.c +@@ -1358,6 +1358,25 @@ gs_texture_t *gs_texture_create(uint32_t width, uint32_t height, + levels, data, flags); + } + ++#if __linux__ ++ ++gs_texture_t *gs_texture_create_from_dmabuf(unsigned int width, ++ unsigned int height, ++ enum gs_color_format color_format, ++ uint32_t n_planes, const int *fds, ++ const uint32_t *strides, ++ const uint32_t *offsets, ++ const uint64_t *modifiers) ++{ ++ graphics_t *graphics = thread_graphics; ++ ++ return graphics->exports.device_texture_create_from_dmabuf( ++ graphics->device, width, height, color_format, n_planes, fds, ++ strides, offsets, modifiers); ++} ++ ++#endif ++ + gs_texture_t *gs_cubetexture_create(uint32_t size, + enum gs_color_format color_format, + uint32_t levels, const uint8_t **data, +diff --git a/libobs/graphics/graphics.h b/libobs/graphics/graphics.h +index 341a55d1..b60ee9fd 100644 +--- a/libobs/graphics/graphics.h ++++ b/libobs/graphics/graphics.h +@@ -892,6 +892,15 @@ EXPORT gs_stagesurf_t *gs_stagesurface_create_nv12(uint32_t width, + EXPORT void gs_register_loss_callbacks(const struct gs_device_loss *callbacks); + EXPORT void gs_unregister_loss_callbacks(void *data); + ++#elif __linux__ ++ ++EXPORT gs_texture_t * ++gs_texture_create_from_dmabuf(unsigned int width, unsigned int height, ++ enum gs_color_format color_format, ++ uint32_t n_planes, const int *fds, ++ const uint32_t *strides, const uint32_t *offsets, ++ const uint64_t *modifiers); ++ + #endif + + /* inline functions used by modules */ +-- +2.28.0 + diff --git a/0022-deps-glad-Add-DMA-BUF-EGL-extensions.patch b/0022-deps-glad-Add-DMA-BUF-EGL-extensions.patch new file mode 100644 index 0000000..c641816 --- /dev/null +++ b/0022-deps-glad-Add-DMA-BUF-EGL-extensions.patch @@ -0,0 +1,185 @@ +From 81ec6cf5002e4f381d6fdcc82bc7ac1189628f53 Mon Sep 17 00:00:00 2001 +From: Georges Basile Stavracas Neto +Date: Thu, 12 Mar 2020 23:57:23 -0300 +Subject: [PATCH 22/24] deps-glad: Add DMA-BUF EGL extensions + +--- + deps/glad/include/glad/glad_egl.h | 63 +++++++++++++++++++++++++++++-- + deps/glad/src/glad_egl.c | 25 ++++++++++-- + 2 files changed, 81 insertions(+), 7 deletions(-) + +diff --git a/deps/glad/include/glad/glad_egl.h b/deps/glad/include/glad/glad_egl.h +index ac07814e..98cbd010 100644 +--- a/deps/glad/include/glad/glad_egl.h ++++ b/deps/glad/include/glad/glad_egl.h +@@ -7,21 +7,24 @@ + APIs: egl=1.5 + Profile: - + Extensions: ++ EGL_EXT_image_dma_buf_import, ++ EGL_EXT_image_dma_buf_import_modifiers, + EGL_EXT_platform_wayland, + EGL_EXT_platform_x11, + EGL_KHR_create_context, + EGL_KHR_create_context_no_error, + EGL_KHR_platform_wayland, +- EGL_KHR_platform_x11 ++ EGL_KHR_platform_x11, ++ EGL_MESA_image_dma_buf_export + Loader: True + Local files: False + Omit khrplatform: False + Reproducible: False + + Commandline: +- --api="egl=1.5" --generator="c" --spec="egl" --extensions="EGL_EXT_platform_wayland,EGL_EXT_platform_x11,EGL_KHR_create_context,EGL_KHR_create_context_no_error,EGL_KHR_platform_wayland,EGL_KHR_platform_x11" ++ --api="egl=1.5" --generator="c" --spec="egl" --extensions="EGL_EXT_image_dma_buf_import,EGL_EXT_image_dma_buf_import_modifiers,EGL_EXT_platform_wayland,EGL_EXT_platform_x11,EGL_KHR_create_context,EGL_KHR_create_context_no_error,EGL_KHR_platform_wayland,EGL_KHR_platform_x11" + Online: +- https://glad.dav1d.de/#language=c&specification=egl&loader=on&api=egl%3D1.5&extensions=EGL_EXT_platform_wayland&extensions=EGL_EXT_platform_x11&extensions=EGL_KHR_create_context&extensions=EGL_KHR_create_context_no_error&extensions=EGL_KHR_platform_wayland&extensions=EGL_KHR_platform_x11 ++ https://glad.dav1d.de/#language=c&specification=egl&loader=on&api=egl%3D1.5&extensions=EGL_EXT_image_dma_buf_import&extensions=EGL_EXT_image_dma_buf_import_modifiers&extensions=EGL_EXT_platform_wayland&extensions=EGL_EXT_platform_x11&extensions=EGL_KHR_create_context&extensions=EGL_KHR_create_context_no_error&extensions=EGL_KHR_platform_wayland&extensions=EGL_KHR_platform_x11 + */ + + +@@ -339,6 +342,39 @@ EGLDisplay eglGetPlatformDisplay(EGLenum platform, void *native_display, const E + EGLSurface eglCreatePlatformWindowSurface(EGLDisplay dpy, EGLConfig config, void *native_window, const EGLAttrib *attrib_list); + EGLSurface eglCreatePlatformPixmapSurface(EGLDisplay dpy, EGLConfig config, void *native_pixmap, const EGLAttrib *attrib_list); + EGLBoolean eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags); ++#define EGL_LINUX_DMA_BUF_EXT 0x3270 ++#define EGL_LINUX_DRM_FOURCC_EXT 0x3271 ++#define EGL_DMA_BUF_PLANE0_FD_EXT 0x3272 ++#define EGL_DMA_BUF_PLANE0_OFFSET_EXT 0x3273 ++#define EGL_DMA_BUF_PLANE0_PITCH_EXT 0x3274 ++#define EGL_DMA_BUF_PLANE1_FD_EXT 0x3275 ++#define EGL_DMA_BUF_PLANE1_OFFSET_EXT 0x3276 ++#define EGL_DMA_BUF_PLANE1_PITCH_EXT 0x3277 ++#define EGL_DMA_BUF_PLANE2_FD_EXT 0x3278 ++#define EGL_DMA_BUF_PLANE2_OFFSET_EXT 0x3279 ++#define EGL_DMA_BUF_PLANE2_PITCH_EXT 0x327A ++#define EGL_YUV_COLOR_SPACE_HINT_EXT 0x327B ++#define EGL_SAMPLE_RANGE_HINT_EXT 0x327C ++#define EGL_YUV_CHROMA_HORIZONTAL_SITING_HINT_EXT 0x327D ++#define EGL_YUV_CHROMA_VERTICAL_SITING_HINT_EXT 0x327E ++#define EGL_ITU_REC601_EXT 0x327F ++#define EGL_ITU_REC709_EXT 0x3280 ++#define EGL_ITU_REC2020_EXT 0x3281 ++#define EGL_YUV_FULL_RANGE_EXT 0x3282 ++#define EGL_YUV_NARROW_RANGE_EXT 0x3283 ++#define EGL_YUV_CHROMA_SITING_0_EXT 0x3284 ++#define EGL_YUV_CHROMA_SITING_0_5_EXT 0x3285 ++#define EGL_DMA_BUF_PLANE3_FD_EXT 0x3440 ++#define EGL_DMA_BUF_PLANE3_OFFSET_EXT 0x3441 ++#define EGL_DMA_BUF_PLANE3_PITCH_EXT 0x3442 ++#define EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT 0x3443 ++#define EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT 0x3444 ++#define EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT 0x3445 ++#define EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT 0x3446 ++#define EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT 0x3447 ++#define EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT 0x3448 ++#define EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT 0x3449 ++#define EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT 0x344A + #define EGL_PLATFORM_WAYLAND_EXT 0x31D8 + #define EGL_PLATFORM_X11_EXT 0x31D5 + #define EGL_PLATFORM_X11_SCREEN_EXT 0x31D6 +@@ -359,6 +395,18 @@ EGLBoolean eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags); + #define EGL_PLATFORM_WAYLAND_KHR 0x31D8 + #define EGL_PLATFORM_X11_KHR 0x31D5 + #define EGL_PLATFORM_X11_SCREEN_KHR 0x31D6 ++#ifndef EGL_EXT_image_dma_buf_import ++#define EGL_EXT_image_dma_buf_import 1 ++#endif ++#ifndef EGL_EXT_image_dma_buf_import_modifiers ++#define EGL_EXT_image_dma_buf_import_modifiers 1 ++typedef EGLBoolean (APIENTRYP PFNEGLQUERYDMABUFFORMATSEXTPROC)(EGLDisplay dpy, EGLint max_formats, EGLint *formats, EGLint *num_formats); ++GLAPI PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT; ++#define eglQueryDmaBufFormatsEXT glad_eglQueryDmaBufFormatsEXT ++typedef EGLBoolean (APIENTRYP PFNEGLQUERYDMABUFMODIFIERSEXTPROC)(EGLDisplay dpy, EGLint format, EGLint max_modifiers, EGLuint64KHR *modifiers, EGLBoolean *external_only, EGLint *num_modifiers); ++GLAPI PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT; ++#define eglQueryDmaBufModifiersEXT glad_eglQueryDmaBufModifiersEXT ++#endif + #ifndef EGL_EXT_platform_wayland + #define EGL_EXT_platform_wayland 1 + #endif +@@ -377,6 +425,15 @@ EGLBoolean eglWaitSync(EGLDisplay dpy, EGLSync sync, EGLint flags); + #ifndef EGL_KHR_platform_x11 + #define EGL_KHR_platform_x11 1 + #endif ++#ifndef EGL_MESA_image_dma_buf_export ++#define EGL_MESA_image_dma_buf_export 1 ++typedef EGLBoolean (APIENTRYP PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC)(EGLDisplay dpy, EGLImageKHR image, int *fourcc, int *num_planes, EGLuint64KHR *modifiers); ++GLAPI PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC glad_eglExportDMABUFImageQueryMESA; ++#define eglExportDMABUFImageQueryMESA glad_eglExportDMABUFImageQueryMESA ++typedef EGLBoolean (APIENTRYP PFNEGLEXPORTDMABUFIMAGEMESAPROC)(EGLDisplay dpy, EGLImageKHR image, int *fds, EGLint *strides, EGLint *offsets); ++GLAPI PFNEGLEXPORTDMABUFIMAGEMESAPROC glad_eglExportDMABUFImageMESA; ++#define eglExportDMABUFImageMESA glad_eglExportDMABUFImageMESA ++#endif + + #ifdef __cplusplus + } +diff --git a/deps/glad/src/glad_egl.c b/deps/glad/src/glad_egl.c +index e3cd1fc2..f2343b75 100644 +--- a/deps/glad/src/glad_egl.c ++++ b/deps/glad/src/glad_egl.c +@@ -1,25 +1,28 @@ + /* + +- EGL loader generated by glad 0.1.33 on Mon Mar 9 17:01:26 2020. ++ EGL loader generated by glad 0.1.33 on Fri Mar 13 03:53:53 2020. + + Language/Generator: C/C++ + Specification: egl + APIs: egl=1.5 + Profile: - + Extensions: ++ EGL_EXT_image_dma_buf_import, ++ EGL_EXT_image_dma_buf_import_modifiers, + EGL_EXT_platform_wayland, + EGL_EXT_platform_x11, + EGL_KHR_platform_wayland, +- EGL_KHR_platform_x11 ++ EGL_KHR_platform_x11, ++ EGL_MESA_image_dma_buf_export + Loader: True + Local files: False + Omit khrplatform: False + Reproducible: False + + Commandline: +- --api="egl=1.5" --generator="c" --spec="egl" --extensions="EGL_EXT_platform_wayland,EGL_EXT_platform_x11,EGL_KHR_platform_wayland,EGL_KHR_platform_x11" ++ --api="egl=1.5" --generator="c" --spec="egl" --extensions="EGL_EXT_image_dma_buf_import,EGL_EXT_image_dma_buf_import_modifiers,EGL_EXT_platform_wayland,EGL_EXT_platform_x11,EGL_KHR_platform_wayland,EGL_KHR_platform_x11,EGL_MESA_image_dma_buf_export" + Online: +- https://glad.dav1d.de/#language=c&specification=egl&loader=on&api=egl%3D1.5&extensions=EGL_EXT_platform_wayland&extensions=EGL_EXT_platform_x11&extensions=EGL_KHR_platform_wayland&extensions=EGL_KHR_platform_x11 ++ https://glad.dav1d.de/#language=c&specification=egl&loader=on&api=egl%3D1.5&extensions=EGL_EXT_image_dma_buf_import&extensions=EGL_EXT_image_dma_buf_import_modifiers&extensions=EGL_EXT_platform_wayland&extensions=EGL_EXT_platform_x11&extensions=EGL_KHR_platform_wayland&extensions=EGL_KHR_platform_x11&extensions=EGL_MESA_image_dma_buf_export + */ + + #include +@@ -31,6 +34,18 @@ int gladLoadEGL(void) { + return gladLoadEGLLoader((GLADloadproc)eglGetProcAddress); + } + ++PFNEGLQUERYDMABUFFORMATSEXTPROC glad_eglQueryDmaBufFormatsEXT = NULL; ++PFNEGLQUERYDMABUFMODIFIERSEXTPROC glad_eglQueryDmaBufModifiersEXT = NULL; ++PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC glad_eglExportDMABUFImageQueryMESA = NULL; ++PFNEGLEXPORTDMABUFIMAGEMESAPROC glad_eglExportDMABUFImageMESA = NULL; ++static void load_EGL_EXT_image_dma_buf_import_modifiers(GLADloadproc load) { ++ glad_eglQueryDmaBufFormatsEXT = (PFNEGLQUERYDMABUFFORMATSEXTPROC)load("eglQueryDmaBufFormatsEXT"); ++ glad_eglQueryDmaBufModifiersEXT = (PFNEGLQUERYDMABUFMODIFIERSEXTPROC)load("eglQueryDmaBufModifiersEXT"); ++} ++static void load_EGL_MESA_image_dma_buf_export(GLADloadproc load) { ++ glad_eglExportDMABUFImageQueryMESA = (PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC)load("eglExportDMABUFImageQueryMESA"); ++ glad_eglExportDMABUFImageMESA = (PFNEGLEXPORTDMABUFIMAGEMESAPROC)load("eglExportDMABUFImageMESA"); ++} + static int find_extensionsEGL(void) { + return 1; + } +@@ -43,6 +58,8 @@ int gladLoadEGLLoader(GLADloadproc load) { + find_coreEGL(); + + if (!find_extensionsEGL()) return 0; ++ load_EGL_EXT_image_dma_buf_import_modifiers(load); ++ load_EGL_MESA_image_dma_buf_export(load); + return 1; + } + +-- +2.28.0 + diff --git a/0023-libobs-opengl-Implement-DMA-BUF-importing-on-EGL-ren.patch b/0023-libobs-opengl-Implement-DMA-BUF-importing-on-EGL-ren.patch new file mode 100644 index 0000000..118de8a --- /dev/null +++ b/0023-libobs-opengl-Implement-DMA-BUF-importing-on-EGL-ren.patch @@ -0,0 +1,469 @@ +From 8b047f19f5351382da17951a24923ca195fb5002 Mon Sep 17 00:00:00 2001 +From: Georges Basile Stavracas Neto +Date: Sat, 14 Mar 2020 14:26:02 -0300 +Subject: [PATCH 23/24] libobs-opengl: Implement DMA-BUF importing on EGL + renderers + +This is currently extremely limited. It only supports XRGB8888 +DMA-BUFs for now, which seems to be a sensible default. +--- + libobs-opengl/CMakeLists.txt | 1 + + libobs-opengl/gl-egl-common.c | 340 +++++++++++++++++++++++++++++++++ + libobs-opengl/gl-egl-common.h | 14 ++ + libobs-opengl/gl-wayland-egl.c | 18 +- + libobs-opengl/gl-x11-egl.c | 15 +- + 5 files changed, 367 insertions(+), 21 deletions(-) + create mode 100644 libobs-opengl/gl-egl-common.c + create mode 100644 libobs-opengl/gl-egl-common.h + +diff --git a/libobs-opengl/CMakeLists.txt b/libobs-opengl/CMakeLists.txt +index 0f694b6c..c434c65f 100644 +--- a/libobs-opengl/CMakeLists.txt ++++ b/libobs-opengl/CMakeLists.txt +@@ -49,6 +49,7 @@ else() + ${X11_XCB_LIBRARIES}) + + set(libobs-opengl_PLATFORM_SOURCES ++ gl-egl-common.c + gl-nix.c + gl-x11-egl.c + gl-x11-glx.c) +diff --git a/libobs-opengl/gl-egl-common.c b/libobs-opengl/gl-egl-common.c +new file mode 100644 +index 00000000..8688af6b +--- /dev/null ++++ b/libobs-opengl/gl-egl-common.c +@@ -0,0 +1,340 @@ ++/****************************************************************************** ++ Copyright (C) 2020 by Georges Basile Stavracas Neto ++ ++ This program is free software: you can redistribute it and/or modify ++ it under the terms of the GNU General Public License as published by ++ the Free Software Foundation, either version 2 of the License, or ++ (at your option) any later version. ++ ++ This program is distributed in the hope that it will be useful, ++ but WITHOUT ANY WARRANTY; without even the implied warranty of ++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ GNU General Public License for more details. ++ ++ You should have received a copy of the GNU General Public License ++ along with this program. If not, see . ++******************************************************************************/ ++ ++#include "gl-egl-common.h" ++ ++#include ++#include ++ ++#include ++ ++#if defined(__linux__) ++ ++#include ++#include ++typedef unsigned int drm_handle_t; ++ ++#else ++ ++#include ++#include ++#include ++typedef int8_t __s8; ++typedef uint8_t __u8; ++typedef int16_t __s16; ++typedef uint16_t __u16; ++typedef int32_t __s32; ++typedef uint32_t __u32; ++typedef int64_t __s64; ++typedef uint64_t __u64; ++typedef size_t __kernel_size_t; ++typedef unsigned long drm_handle_t; ++ ++#endif ++ ++typedef void(APIENTRYP PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)( ++ GLenum target, GLeglImageOES image); ++static PFNGLEGLIMAGETARGETTEXTURE2DOESPROC glEGLImageTargetTexture2DOES; ++ ++/* copied from drm_fourcc.h */ ++ ++#define fourcc_code(a, b, c, d) \ ++ ((__u32)(a) | ((__u32)(b) << 8) | ((__u32)(c) << 16) | \ ++ ((__u32)(d) << 24)) ++#define DRM_FORMAT_INVALID 0 ++#define DRM_FORMAT_R8 fourcc_code('R', '8', ' ', ' ') /* [7:0] R */ ++#define DRM_FORMAT_R16 \ ++ fourcc_code('R', '1', '6', ' ') /* [15:0] R little endian */ ++#define DRM_FORMAT_RG88 \ ++ fourcc_code('R', 'G', '8', '8') /* [15:0] R:G 8:8 little endian */ ++#define DRM_FORMAT_ABGR8888 \ ++ fourcc_code('A', 'B', '2', \ ++ '4') /* [31:0] A:B:G:R 8:8:8:8 little endian */ ++#define DRM_FORMAT_ABGR2101010 \ ++ fourcc_code('A', 'B', '3', \ ++ '0') /* [31:0] A:B:G:R 2:10:10:10 little endian */ ++#define DRM_FORMAT_ABGR16161616F \ ++ fourcc_code('A', 'B', '4', \ ++ 'H') /* [63:0] A:B:G:R 16:16:16:16 little endian */ ++#define DRM_FORMAT_ARGB8888 \ ++ fourcc_code('A', 'R', '2', \ ++ '4') /* [31:0] A:R:G:B 8:8:8:8 little endian */ ++#define DRM_FORMAT_XRGB8888 \ ++ fourcc_code('X', 'R', '2', \ ++ '4') /* [31:0] x:R:G:B 8:8:8:8 little endian */ ++ ++static bool find_gl_extension(const char *extension) ++{ ++ GLint n, i; ++ ++ glGetIntegerv(GL_NUM_EXTENSIONS, &n); ++ for (i = 0; i < n; i++) { ++ const char *e = (char *)glGetStringi(GL_EXTENSIONS, i); ++ if (extension && strcmp(e, extension) == 0) ++ return true; ++ } ++ return false; ++} ++ ++static bool init_egl_image_target_texture_2d_ext(void) ++{ ++ static bool initialized = false; ++ ++ if (!initialized) { ++ initialized = true; ++ ++ if (!find_gl_extension("GL_OES_EGL_image")) { ++ blog(LOG_ERROR, "No GL_OES_EGL_image"); ++ return false; ++ } ++ ++ glEGLImageTargetTexture2DOES = ++ (PFNGLEGLIMAGETARGETTEXTURE2DOESPROC)eglGetProcAddress( ++ "glEGLImageTargetTexture2DOES"); ++ } ++ ++ if (!glEGLImageTargetTexture2DOES) ++ return false; ++ ++ return true; ++} ++ ++static inline enum gs_color_format gs_format_to_drm_format(uint32_t drm_format) ++{ ++ switch (drm_format) { ++ case GS_R8: ++ return DRM_FORMAT_R8; ++ case GS_RGBA: ++ return DRM_FORMAT_ABGR8888; ++ case GS_BGRX: ++ return DRM_FORMAT_XRGB8888; ++ case GS_BGRA: ++ return DRM_FORMAT_ARGB8888; ++ case GS_R10G10B10A2: ++ return DRM_FORMAT_ABGR2101010; ++ case GS_R16: ++ return DRM_FORMAT_R16; ++ case GS_RGBA16F: ++ return DRM_FORMAT_ABGR16161616F; ++ case GS_R8G8: ++ return DRM_FORMAT_RG88; ++ case GS_A8: ++ case GS_R16F: ++ case GS_RGBA16: ++ case GS_RG16F: ++ case GS_R32F: ++ case GS_RG32F: ++ case GS_RGBA32F: ++ case GS_DXT1: ++ case GS_DXT3: ++ case GS_DXT5: ++ case GS_UNKNOWN: ++ return DRM_FORMAT_INVALID; ++ } ++ ++ return DRM_FORMAT_INVALID; ++} ++ ++static EGLImageKHR ++create_dmabuf_egl_image(EGLDisplay egl_display, unsigned int width, ++ unsigned int height, uint32_t drm_format, ++ uint32_t n_planes, const int *fds, ++ const uint32_t *strides, const uint32_t *offsets, ++ const uint64_t *modifiers) ++{ ++ EGLAttrib attribs[47]; ++ int atti = 0; ++ ++ /* This requires the Mesa commit in ++ * Mesa 10.3 (08264e5dad4df448e7718e782ad9077902089a07) or ++ * Mesa 10.2.7 (55d28925e6109a4afd61f109e845a8a51bd17652). ++ * Otherwise Mesa closes the fd behind our back and re-importing ++ * will fail. ++ * https://bugs.freedesktop.org/show_bug.cgi?id=76188 ++ * */ ++ ++ attribs[atti++] = EGL_WIDTH; ++ attribs[atti++] = width; ++ attribs[atti++] = EGL_HEIGHT; ++ attribs[atti++] = height; ++ attribs[atti++] = EGL_LINUX_DRM_FOURCC_EXT; ++ attribs[atti++] = drm_format; ++ ++ if (n_planes > 0) { ++ attribs[atti++] = EGL_DMA_BUF_PLANE0_FD_EXT; ++ attribs[atti++] = fds[0]; ++ attribs[atti++] = EGL_DMA_BUF_PLANE0_OFFSET_EXT; ++ attribs[atti++] = offsets[0]; ++ attribs[atti++] = EGL_DMA_BUF_PLANE0_PITCH_EXT; ++ attribs[atti++] = strides[0]; ++ if (modifiers) { ++ attribs[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_LO_EXT; ++ attribs[atti++] = modifiers[0] & 0xFFFFFFFF; ++ attribs[atti++] = EGL_DMA_BUF_PLANE0_MODIFIER_HI_EXT; ++ attribs[atti++] = modifiers[0] >> 32; ++ } ++ } ++ ++ if (n_planes > 1) { ++ attribs[atti++] = EGL_DMA_BUF_PLANE1_FD_EXT; ++ attribs[atti++] = fds[1]; ++ attribs[atti++] = EGL_DMA_BUF_PLANE1_OFFSET_EXT; ++ attribs[atti++] = offsets[1]; ++ attribs[atti++] = EGL_DMA_BUF_PLANE1_PITCH_EXT; ++ attribs[atti++] = strides[1]; ++ if (modifiers) { ++ attribs[atti++] = EGL_DMA_BUF_PLANE1_MODIFIER_LO_EXT; ++ attribs[atti++] = modifiers[1] & 0xFFFFFFFF; ++ attribs[atti++] = EGL_DMA_BUF_PLANE1_MODIFIER_HI_EXT; ++ attribs[atti++] = modifiers[1] >> 32; ++ } ++ } ++ ++ if (n_planes > 2) { ++ attribs[atti++] = EGL_DMA_BUF_PLANE2_FD_EXT; ++ attribs[atti++] = fds[2]; ++ attribs[atti++] = EGL_DMA_BUF_PLANE2_OFFSET_EXT; ++ attribs[atti++] = offsets[2]; ++ attribs[atti++] = EGL_DMA_BUF_PLANE2_PITCH_EXT; ++ attribs[atti++] = strides[2]; ++ if (modifiers) { ++ attribs[atti++] = EGL_DMA_BUF_PLANE2_MODIFIER_LO_EXT; ++ attribs[atti++] = modifiers[2] & 0xFFFFFFFF; ++ attribs[atti++] = EGL_DMA_BUF_PLANE2_MODIFIER_HI_EXT; ++ attribs[atti++] = modifiers[2] >> 32; ++ } ++ } ++ ++ if (n_planes > 3) { ++ attribs[atti++] = EGL_DMA_BUF_PLANE3_FD_EXT; ++ attribs[atti++] = fds[3]; ++ attribs[atti++] = EGL_DMA_BUF_PLANE3_OFFSET_EXT; ++ attribs[atti++] = offsets[3]; ++ attribs[atti++] = EGL_DMA_BUF_PLANE3_PITCH_EXT; ++ attribs[atti++] = strides[3]; ++ if (modifiers) { ++ attribs[atti++] = EGL_DMA_BUF_PLANE3_MODIFIER_LO_EXT; ++ attribs[atti++] = modifiers[3] & 0xFFFFFFFF; ++ attribs[atti++] = EGL_DMA_BUF_PLANE3_MODIFIER_HI_EXT; ++ attribs[atti++] = modifiers[3] >> 32; ++ } ++ } ++ ++ attribs[atti++] = EGL_NONE; ++ ++ return eglCreateImage(egl_display, EGL_NO_CONTEXT, ++ EGL_LINUX_DMA_BUF_EXT, 0, attribs); ++} ++ ++struct gs_texture * ++gl_egl_create_dmabuf_image(EGLDisplay egl_display, unsigned int width, ++ unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, ++ const int *fds, const uint32_t *strides, ++ const uint32_t *offsets, const uint64_t *modifiers) ++{ ++ struct gs_texture *texture = NULL; ++ EGLImage egl_image; ++ uint32_t drm_format; ++ ++ if (!init_egl_image_target_texture_2d_ext()) ++ return NULL; ++ ++ drm_format = gs_format_to_drm_format(color_format); ++ if (drm_format == DRM_FORMAT_INVALID) { ++ blog(LOG_ERROR, "Invalid or unsupported image format"); ++ return NULL; ++ } ++ ++ egl_image = create_dmabuf_egl_image(egl_display, width, height, ++ DRM_FORMAT_ARGB8888, n_planes, fds, ++ strides, offsets, modifiers); ++ if (egl_image == EGL_NO_IMAGE) { ++ blog(LOG_ERROR, "Cannot create EGLImage: %s", ++ gl_egl_error_to_string(eglGetError())); ++ return NULL; ++ } ++ ++ texture = gs_texture_create(width, height, color_format, 1, NULL, ++ GS_DYNAMIC); ++ const GLuint gltex = *(GLuint *)gs_texture_get_obj(texture); ++ ++ glBindTexture(GL_TEXTURE_2D, gltex); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); ++ glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); ++ ++ glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, egl_image); ++ ++ glBindTexture(GL_TEXTURE_2D, 0); ++ eglDestroyImage(egl_display, egl_image); ++ ++ return texture; ++} ++ ++const char *gl_egl_error_to_string(EGLint error_number) ++{ ++ switch (error_number) { ++ case EGL_SUCCESS: ++ return "The last function succeeded without error."; ++ break; ++ case EGL_NOT_INITIALIZED: ++ return "EGL is not initialized, or could not be initialized, for the specified EGL display connection."; ++ break; ++ case EGL_BAD_ACCESS: ++ return "EGL cannot access a requested resource (for example a context is bound in another thread)."; ++ break; ++ case EGL_BAD_ALLOC: ++ return "EGL failed to allocate resources for the requested operation."; ++ break; ++ case EGL_BAD_ATTRIBUTE: ++ return "An unrecognized attribute or attribute value was passed in the attribute list."; ++ break; ++ case EGL_BAD_CONTEXT: ++ return "An EGLContext argument does not name a valid EGL rendering context."; ++ break; ++ case EGL_BAD_CONFIG: ++ return "An EGLConfig argument does not name a valid EGL frame buffer configuration."; ++ break; ++ case EGL_BAD_CURRENT_SURFACE: ++ return "The current surface of the calling thread is a window, pixel buffer or pixmap that is no longer valid."; ++ break; ++ case EGL_BAD_DISPLAY: ++ return "An EGLDisplay argument does not name a valid EGL display connection."; ++ break; ++ case EGL_BAD_SURFACE: ++ return "An EGLSurface argument does not name a valid surface (window, pixel buffer or pixmap) configured for GL rendering."; ++ break; ++ case EGL_BAD_MATCH: ++ return "Arguments are inconsistent (for example, a valid context requires buffers not supplied by a valid surface)."; ++ break; ++ case EGL_BAD_PARAMETER: ++ return "One or more argument values are invalid."; ++ break; ++ case EGL_BAD_NATIVE_PIXMAP: ++ return "A NativePixmapType argument does not refer to a valid native pixmap."; ++ break; ++ case EGL_BAD_NATIVE_WINDOW: ++ return "A NativeWindowType argument does not refer to a valid native window."; ++ break; ++ case EGL_CONTEXT_LOST: ++ return "A power management event has occurred. The application must destroy all contexts and reinitialise OpenGL ES state and objects to continue rendering. "; ++ break; ++ default: ++ return "Unknown error"; ++ break; ++ } ++} +diff --git a/libobs-opengl/gl-egl-common.h b/libobs-opengl/gl-egl-common.h +new file mode 100644 +index 00000000..35811387 +--- /dev/null ++++ b/libobs-opengl/gl-egl-common.h +@@ -0,0 +1,14 @@ ++#pragma once ++ ++#include "gl-nix.h" ++ ++#include ++ ++const char *gl_egl_error_to_string(EGLint error_number); ++ ++struct gs_texture * ++gl_egl_create_dmabuf_image(EGLDisplay egl_display, unsigned int width, ++ unsigned int height, ++ enum gs_color_format color_format, uint32_t n_planes, ++ const int *fds, const uint32_t *strides, ++ const uint32_t *offsets, const uint64_t *modifiers); +diff --git a/libobs-opengl/gl-wayland-egl.c b/libobs-opengl/gl-wayland-egl.c +index 3968736d..299fe7ea 100644 +--- a/libobs-opengl/gl-wayland-egl.c ++++ b/libobs-opengl/gl-wayland-egl.c +@@ -17,6 +17,8 @@ + + #include "gl-wayland-egl.h" + ++#include "gl-egl-common.h" ++ + #include + #include + +@@ -325,17 +327,11 @@ static struct gs_texture *gl_wayland_egl_device_texture_create_from_dmabuf( + const uint32_t *strides, const uint32_t *offsets, + const uint64_t *modifiers) + { +- UNUSED_PARAMETER(device); +- UNUSED_PARAMETER(width); +- UNUSED_PARAMETER(height); +- UNUSED_PARAMETER(color_format); +- UNUSED_PARAMETER(n_planes); +- UNUSED_PARAMETER(fds); +- UNUSED_PARAMETER(strides); +- UNUSED_PARAMETER(offsets); +- UNUSED_PARAMETER(modifiers); +- +- return NULL; ++ struct gl_platform *plat = device->plat; ++ ++ return gl_egl_create_dmabuf_image(plat->display, width, height, ++ color_format, n_planes, fds, strides, ++ offsets, modifiers); + } + + static const struct gl_winsys_vtable egl_wayland_winsys_vtable = { +diff --git a/libobs-opengl/gl-x11-egl.c b/libobs-opengl/gl-x11-egl.c +index 7a9c5975..d56f6b71 100644 +--- a/libobs-opengl/gl-x11-egl.c ++++ b/libobs-opengl/gl-x11-egl.c +@@ -29,6 +29,7 @@ + + #include + ++#include "gl-egl-common.h" + #include "gl-x11-egl.h" + + #include +@@ -640,17 +641,11 @@ static struct gs_texture *gl_x11_egl_device_texture_create_from_dmabuf( + const uint32_t *strides, const uint32_t *offsets, + const uint64_t *modifiers) + { +- UNUSED_PARAMETER(device); +- UNUSED_PARAMETER(width); +- UNUSED_PARAMETER(height); +- UNUSED_PARAMETER(color_format); +- UNUSED_PARAMETER(n_planes); +- UNUSED_PARAMETER(fds); +- UNUSED_PARAMETER(strides); +- UNUSED_PARAMETER(offsets); +- UNUSED_PARAMETER(modifiers); ++ struct gl_platform *plat = device->plat; + +- return NULL; ++ return gl_egl_create_dmabuf_image(plat->edisplay, width, height, ++ color_format, n_planes, fds, strides, ++ offsets, modifiers); + } + + static const struct gl_winsys_vtable egl_x11_winsys_vtable = { +-- +2.28.0 + diff --git a/0024-libobs-opengl-Create-GLES2-contexts.patch b/0024-libobs-opengl-Create-GLES2-contexts.patch new file mode 100644 index 0000000..19a8def --- /dev/null +++ b/0024-libobs-opengl-Create-GLES2-contexts.patch @@ -0,0 +1,40 @@ +From c526b2ac87ce5cb26db187bbd612b90bb35605fa Mon Sep 17 00:00:00 2001 +From: Georges Basile Stavracas Neto +Date: Fri, 28 Aug 2020 09:43:24 -0300 +Subject: [PATCH 24/24] libobs-opengl: Create GLES2 contexts + +They are required for importing DMA-BUF images. +--- + libobs-opengl/gl-wayland-egl.c | 2 +- + libobs-opengl/gl-x11-egl.c | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/libobs-opengl/gl-wayland-egl.c b/libobs-opengl/gl-wayland-egl.c +index 299fe7ea..33352dfb 100644 +--- a/libobs-opengl/gl-wayland-egl.c ++++ b/libobs-opengl/gl-wayland-egl.c +@@ -27,7 +27,7 @@ + static const EGLint config_attribs[] = {EGL_SURFACE_TYPE, + EGL_WINDOW_BIT, + EGL_RENDERABLE_TYPE, +- EGL_OPENGL_BIT, ++ EGL_OPENGL_ES2_BIT, + EGL_STENCIL_SIZE, + 0, + EGL_DEPTH_SIZE, +diff --git a/libobs-opengl/gl-x11-egl.c b/libobs-opengl/gl-x11-egl.c +index d56f6b71..40e6a7f8 100644 +--- a/libobs-opengl/gl-x11-egl.c ++++ b/libobs-opengl/gl-x11-egl.c +@@ -62,7 +62,7 @@ static const EGLint ctx_config_attribs[] = {EGL_STENCIL_SIZE, + EGL_ALPHA_SIZE, + 8, + EGL_RENDERABLE_TYPE, +- EGL_OPENGL_BIT, ++ EGL_OPENGL_ES2_BIT, + EGL_SURFACE_TYPE, + EGL_WINDOW_BIT | EGL_PBUFFER_BIT, + EGL_NONE}; +-- +2.28.0 + diff --git a/PKGBUILD b/PKGBUILD index fa7e2cf..1af0297 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -7,7 +7,7 @@ pkgname=$_pkgname-wayland provides=("$_pkgname") conflicts=("$_pkgname") pkgver=25.0.8 -pkgrel=4 +pkgrel=5 pkgdesc="Free, open source software for live streaming and recording (with wayland patches)" arch=('x86_64') url="https://obsproject.com" @@ -46,29 +46,37 @@ source=( 0018-UI-Disable-and-ignore-Always-On-Top-on-Wayland-platf.patch 0019-UI-Make-OBSQTDisplay-CreateDisplay-public-and-allow-.patch 0020-UI-Check-for-Expose-and-PlatformSurface-events-to-cr.patch + 0021-libobs-graphics-Add-Linux-only-device_texture_create.patch + 0022-deps-glad-Add-DMA-BUF-EGL-extensions.patch + 0023-libobs-opengl-Implement-DMA-BUF-importing-on-EGL-ren.patch + 0024-libobs-opengl-Create-GLES2-contexts.patch ) sha512sums=('a97c03dc218a4e03e48f6a7dc82b4a59ebeee2039f17be66bb847681ce9ff3d25e6e015be4af78fe44739f6fad5089b6e683d7657c2e4fde8e547df9a2594a08' '1ff0e088eed61554268009f3d8c5a23c0888bfbe860d6cb288ddf348108446c152fd87e2cb8f54613a88378d8474550632c90f924005d5e0343bf1a801339ccc' - 'c322fb6dbe90bd3b9d298867731388ef306f3dbf038b2cb0f3f262c52981200ae949db6917b50c751b6920a40eef4b4fa8108ef5db9b83575ff3556024fa8f79' - '78670b678538cc43cc484e377c14bce6a55cb36be00c8db485e1e084b6eafd1833cae376b1f618b329dd2c4d50fa1de53c6bf252932edce97253f4b19f229500' - '9aaf118e233d6e7eda5f72b77eefedb641e11ddf0daff0463ae25cc4440de8e52903813215ec6bf33f82eb3c11febd166ce3859bfbe4044cd5e09a018ceb391c' - '662438ef6e95dc8262403c931c8a749a6204bf4857f76e6fccee5084dcbe2ca693309ca078170e25d13be1cfd4d4a8746cbfc318c473d0ea52b332adb5e90c61' - 'c2be03913d95f8f449c9c9df6df8be41956923baf28f30091dc9a836c9e37d4e84ee930730edf2d3cc162886809d3a42e0fd4d79fd84f27a77c9e08802de6947' - '9b4722003418f27cbe7efed102b1a69aeb1cb9782d4249b14a7a7f10d0bce725465bda459cfd77e0e577e93f46b2ca0604f48c9a3c19e4a7b0d31b3386f0a8cf' - '854482e4dc52293b2b488988bc05fa1835346780aa0213e4e102ece971d630fadc33d5941424673050eed7b5aba017cebe3248e62f3fb69483f389bca7aede39' - '8c5a049babe4804ab2b701591ab2ed9e597e974279431d728461807df5a37361164ce21b36d832017daa6e967bac545dc7c25f17433f4f6eef9c937da35ede34' - '5055c4bdd282743e7971be8eccce627eb0e1eb607bdf7f306748cd7898fcf08eaf64d870e753940682dac1691a6c959a539a032bae104b9d1a6fe4ca2e16187f' - '00b1909e225e479483fd1b23053dbff5630526d927e5df7eb9fe3c340f27bf343d64796ee66e37b4e7f3f6bab8649ad93fa76b6b2a4628e31b1894cab417f247' - '5b33e379d789ae1e17354a210531498765ee64773f0a457f505de480b10c9adfa9116e121e8a31757fbc0bc241c71fd9921ac796b7c4b038f4dea2cf0a04aa48' - 'b0b9d213d39cbcfdbb83f61352c8488b6a95d414f4299d6e7e729aa485f911d60ef4f047ca13d006dc77b1c43a7f49db381fec5c1e695e3ec9da0e6eab99bb61' - '6dee9847d4d98704f393f1f788f2a0c22b630a3e4021846afa356ba2bb4be664e0b6e0f4b3ee2e58d889e7d33a90b516b91ad6bc6b2c241c22245be68ca098b7' - '01953fc6cd1a5789a6fa5be076da53ba5e8f56418b9f2badca3af6221acf72107e4f73a06a082b20894fdd18aa5263668411d72f4ef237af81f3f2ed86a63be8' - 'e5ad79d67b15b5b245b8f06da0321d221d47aa91297b2c8a6c941c2a49b78e413edf3c6fac08bdcf573fa4cdf1632d8ba1b1ad5697ae67ece96b0fd1f4264a91' - '7b93c07e21efc66ef444db68e25b4f66e7b3acd111b70dc8c6c39a6ebcff29b3238a749693134a59d568757732c93a8c39f1624686161b967828f6ef267b4ac6' - 'ff4e3e8b463a054df5a9b57b670971d2ba4dd4345e0cf7455d2d1d4dd8d911390533fdd42bfd027c3726a717e91ebb0cdf8855f47be065581179fa225f831d22' - '4fe456675224ab8692828ef022aae35899027ecbc98c70c47621e9b0e9839b332a5b1548736515ae09b3fcbe46ad17c35cd1338310d96e68db3337cc9dc2a2ee' - 'e1358bdb7455aeae737c33a9180e225de288a25df16337ab2ed2a51e8ca6df66d89b863d1539a43a3c409b372a19cdbb5be37f842fc9320fb7046eabf69fcaba' - 'cd3ab0c4c71e7c289732530dfb3230ebb35a4021335b3a0ad9bce5ec8c9ad352cb7b2fbb3ed1d6c5d7d9c32f27a90f5cfb2b1a00426def1f712d679da68f5795') + 'c4e653fc744000e0b178848b21f326065dbc83966876594fd349be9b847382afabd0321081e83f3ef094fe067c97d8200817a6cd752df260874bc943271a8658' + '2359bb8f074e5e5676eefe4c655d79611c901f0c8316275ced4d711be42f74ea29d0167ad018f51064fb8a51535969ae742c576a8afe9d710116f7379a1ee67d' + '019fd92b51cb432d81d4265e85751040aeedc1f466181c2e2ec14c253335b1a23571e961ce6415e045fa51ea15731de6e540664276cdd76a3ce198d56cb13eac' + '2f3186d862a78d41496e5a43dd01f5b56edac9873ea309bdcc8c9a83083437e7a252ef0d7373f403dc70ee4f1be8ae6fc430d710b80222ada7ae3ce16b8103ea' + '457534c7ffb7dd0064b143cdfe472d079251ebe891885372127cbff2b6cb70e7d1e55a2da7956c5b6d940e03f8efa57265453fa23a8fb9fa92e4b2c33c959316' + '2af83bba2aa2dd2aed11f9a4f431d9aaeae7c6154c921247510e91bb523cede756d0777fe522a5a6db81a9a6989769a839f365e698511890308c5a0ec6e695ec' + '3f8094c9e577d81bfc9222e436947aa890ce81b2f0e3e43f979a7192cc3e1ca35ca63949e061cecdc6be0579636b6a8e0d8ba21a05a0e11a94ba42210fff851a' + 'd0ff4c1bcb156b2c81be38682d4f99b1388d25521f7981016e850f1e8989d0bfe0d3d71d4ec18382f861ca889bcdfb27dd4d73ca7f763f997a5e388bbc8bdcbc' + '061f7122d5ff8a98dd4ef875c2d7dc60a2dc30627a01a960bd78539e6c7f2bcbfda48f9f42f9f61434f6263686641af2cfb4d6971682be542b6c6f037986e6da' + 'a91815239465656a0ab5902e524277659e0e3ab953d0539bc8ead8f65b3a279a801c02635aad541f871f5007943af704c8c64fec90534c66fe6e418d24787300' + 'e3bdcdae93fa134c1174bf84152385ae28eb7fd82504331f4dccfd46b6565eb605b63acd4972bed08bbe765c7e213b93d94077a9fafcfe33064b4a526f02f7a6' + 'f134c9fed318fde1d11f59e56676cc512bdea81df6a5ce90202759b300405d02981b6586e090cbae65fb730ca352c3942eeec636bb7d5a571475a815f73be89d' + '530846836b8efc6b7549fb6d2b4288ac9782420fd8e51c988d579f701bc4a1f58b7f941d472ad7d4ab07869e45dfc905c3927a3ad735178a109881ed02ffdb77' + '014a9dd855e696a33e3b5c8f8a11ec6cf1edc6e0e6478cc5f11530c5535a1d1dfaaa75c5a3de258178e1ab16256fb8303b18c8a69407febe58a7d860b2396fda' + 'afb5a5b0cfa09407efe6924b37f8c3b26ccf244acc4a99fcee0eb6705855d2dc8589ecbdb2fcf9066c9ec6d947a6810f58efe34362aa451af4cdf7fa30f2e4e4' + '5a09040d91bf293389c328f758416f29840eaf6b0acd78adf14b47fc48c417fb1b02ab97dc90c7d8381bc9ffa817cbc6acc83fd318ba85d73d39ae8f4f7a35e1' + 'd1ed4b6bb07b2da105e2d69c5af1d61bcd39f141c2500e606f251f2220632f4173d3b3de9e2c88dd0bf2e230cba291cda50fb3a7ca89ff391d0e5e36b2e4aa2f' + 'c5b82ddaad7bcc5608168a318e6dde9a0aa0d1dc789d29751a9b22bec2b68288c71e5719c620073ee3c8d9bbf63d60e1634a351cc155b8f2b823d0cbc83cf578' + 'c9d1e42cb87964b764a70044aa828c8d712c709d9e1245f644e8aa2f4576cd33c78e81b9b736d39939959aa3811fe4a9cb6970c8278c22d3f5b7f48d43ae1d55' + 'a9893913797b503249d182ebbac0452827a837187e7817c46ab76df5d004ada810c2ff8523518d408daf396a4c72f707777a3dadeca598f404b074581f0125e8' + '848bcf4f525cca508131960fe6bb2757b0975065f680da9c8d692b5ea28b4c5cca7c2e71f1498c8425c0549fc23a41895638da9e1c433d05e6425ea36dc3ec1b' + '71e11ef607a0371c378db0d50155530d2a918ca47fe15dd29dab36f50dda4a8e7a487f3600b4b03a240db4e84b73c5b49186ca275fb1968de8f15c8d16e8a813' + '73b82cd530e26d3751de9d3e54da0994cbd5d7c9e5ceed7088d50ef4eda8a8c36d30812e8e4a82be014813ed09aefcfa14e7361189a7b4cf763f20aa2ebda7b7' + '1442f7918df45b37e9b3bef05573d4f8c7224f950a85fd0b6200a2ca70b377344ecf37ed69b5474453f584d0992b446383b1a708c326e993a9c815882ba4232f') prepare() { cd $_pkgname-$pkgver