# Compiling Mesa 22.2 with codec support (the easy way)

**URL:** <https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390>\
**Category:** Community contributions\
**Created:** [August 18, 2022, 7:05pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390 "2022-08-18T19:05:22Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [August 18, 2022, 7:05pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/1 "2022-08-18T19:05:23Z")

</div>

**EDIT: Looks like the Arch maintainers have included the necessary build flags so this wont be necessary, but this is still useful as a basic guide to easily building mesa with additional flags**

This year Mesa made some changes to 22.2 that effectively removes hardware encode/decode support from AMD and Intel GPUs/ Mesa in the default configuration.

> **[meson: add a video codec support option (!15258) · Merge requests · Mesa /...](https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15258)**
>
> This allows to turn on/off all hw implementations for a specific video codec across the tree. Patent encumbered codecs can cause problems for distributions due to the nature...

This means there is a high chance that unless Arch devs decide to not care and add the flags for the codecs back or you decide to use AMDGPU-Pro going forward you may not have support for H264/H265(HEVC)/VC1 hardware encoding/decoding on a GPU using Mesa/VAAPI.

The problem with this comes down to apparently nobody knowing who tf is supposed to pay the license fee/ if its paid for most GPUs in regards to Mesa. In theory your AMD/Intel/Nvidia GPU should already be paid for license wise but this may not trickle down to the OSS drivers and overall its just a fat mess of stupid thanks to MPEG-LA being giant pieces of shit.

So, what to do then? how can you actually use all your GPU and its features? Well since licenses dont apply to the code itself they can have support in the code and you compile it yourself.

* * *

**Currently the Arch Repo isnt on 22.2 so this isnt needed yet, if you folow these directions as of 08/18/2022 you will not get mesa 22.2**

1. First, you need to get the package build from Arch repos here [https://github.com/archlinux/svntogit-packages/tree/packages/mesa](https://github.com/archlinux/svntogit-packages/tree/packages/mesa) you can click _Code_ and download zip OR using git clone in a directory you made for building it. I believe EOS includes git on default so you should be able to just run this

builddir is just a generic name for what ever you name the directory youll be building in, i wouldnt call it builddir personally but you do you.

I.E

`mkdir builddir`  
`cd builddir`  
`git clone --single-branch --branch packages/mesa https://github.com/archlinux/svntogit-packages.git`

1. Now you need to navigate to the pkgbuild for this, we will use terminal but you can use your file manager of choice and open a terminal there. assuming you followed the initial steps you should already be in your builddir

`cd svntogit-packages/trunk`

1. Now you need to edit the pkgbuild, Ill be using nano in this example but use w/e editor youre comfortable with and know how to use. This wont include how to use nano though

`nano PKGBUILD`

navigate to the section of the pkgbuild just above

```auto
 # Print config
  meson configure build

```

youll see build flags like `-D valgrind=enabled`

add this just after valgrind  
`-D video-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec`

it should now look like

```auto
    -D shared-glapi=enabled \
    -D microsoft-clc=disabled \
    -D valgrind=enabled \
    -D video-codecs=h264dec,h264enc,h265dec,h265enc,vc1dec

```

1. after editing the pkgbuild you may now run

`makepkg -si`

from inside the same directory as the pkgbuild, this will pull in needed depends and build/install the package.

* * *

This all may not even end up being needed based on how things go, but luckily Arch PKGBUILDs make fixing the issue incredibly easy. If not being needed, great! otherwise its going to require you as the user to do the work yourself. Since this will likely also propagate to Flatpaks also I look into how best handle that situation and add a guide here for that also.

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [August 18, 2022, 7:17pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/2 "2022-08-18T19:17:13Z")

</div>

added a note that as of this day (08/18/2022) this doesnt build Mesa 22.2

This will change when arch repo moves to 22.2 and this guide is for when that happens/if this is an issue.

---

<div class="post-metadata">

**Author:** ![mrvictory](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mrvictory](https://forum.endeavouros.com/u/mrvictory)\
**Post date:** [August 18, 2022, 7:19pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/3 "2022-08-18T19:19:20Z")

</div>

I am quite sure Arch maintainers will include support for whatever necessary and take care of us, just like how they did with glibc 2.36 EAC conflict and Linux 5.18 & Nvidia driver conflict.

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [August 18, 2022, 7:21pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/4 "2022-08-18T19:21:42Z")

</div>

> [@mrvictory](#):
>
> I am quite sure Arch maintainers will include support for whatever necessary and take care of us, just like how they did with glibc 2.36 EAC conflict and Linux 5.18 & Nvidia driver conflict.

glibc didnt come with the risk on the MPEG-LA going after them legally, afaik Debian doesnt give af and includes the codec flags for mesa but i cant say for 100% sure Arch will do the same as there is an open bugreport on it currently and i dont know the discussion being had about it.

Best case is Mesa disappears from Repos in regions the patent is valid and they do it anyway hosting in other countries for that package, worst we build it ourselves. They may also not care all together and just continue as usual adding the flags in, idk.

> **[FS#74615 : \[mesa\] mesa 22.2+ requires changes for HW accelaration](https://bugs.archlinux.org/task/74615?project=1&string=mesa)**
>
> Flyspray, a Bug Tracking System written in PHP.

---

<div class="post-metadata">

**Author:** ![mrvictory](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/m/7993a0/32.png) [@mrvictory](https://forum.endeavouros.com/u/mrvictory)\
**Post date:** [August 18, 2022, 7:31pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/5 "2022-08-18T19:31:55Z")

</div>

Well, VLC, ffmpeg etc. are in official repos and Debian which is more strict has included the flags, so why wouldn’t Arch?

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [August 18, 2022, 7:35pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/6 "2022-08-18T19:35:48Z")

</div>

> [@mrvictory](#):
>
> Well, VLC, ffmpeg etc. are in official repos and Debian which is more strict has included the flags, so why wouldn’t Arch?

this is just an in case, i dont have the answer and i honeslty cant answer this question. Id prefer to keep that discussion elsewhere though so as to keep the guide thread clean for support requests if needed.

VLC, ffmpeg, and others i know have been hosted outside the patent regions to get around the issue, but i cant 100% say what will happening going forward. Flatpak will likely not include them and neither will several other distros so when i do the flatpak part this will still be useful.

---

<div class="post-metadata">

**Author:** ![anon49550872](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@anon49550872](https://forum.endeavouros.com/u/anon49550872)\
**Post date:** [September 20, 2022, 11:42pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/7 "2022-09-20T23:42:00Z")

</div>

- Support for building Mesa with select video codecs disabled out of software patent concerns.

> **[Mesa 22.2 Released With AMD RDNA3 Prep, Intel Arc Graphics, Many Vulkan...](https://www.phoronix.com/news/Mesa-22.2-Released)**
>
> The belated Mesa 22.2 was unexpectedly released today for providing the very latest open-source Linux graphics driver support not only for Intel and AMD Radeon graphics hardware but also the reverse-engineered Nouveau (NVIDIA) driver and the many...

---

<div class="post-metadata">

**Author:** ![I0F](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/i0f/32/47182_2.png) [@I0F](https://forum.endeavouros.com/u/I0F)\
**Post date:** [September 21, 2022, 7:17am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/8 "2022-09-21T07:17:20Z")

</div>

Do I understand correctly, that it’s not possible to build Mesa with codecs at all from now on?

---

<div class="post-metadata">

**Author:** ![anon49550872](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@anon49550872](https://forum.endeavouros.com/u/anon49550872)\
**Post date:** [September 21, 2022, 8:31am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/9 "2022-09-21T08:31:23Z")

</div>

I suppose we will need to follow the tutorial in the 1st post here, to include the codecs…

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [September 21, 2022, 8:32am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/10 "2022-09-21T08:32:31Z")

</div>

No, OP is instructions on how to do it. Its still there just not on by default

---

<div class="post-metadata">

**Author:** ![anon49550872](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@anon49550872](https://forum.endeavouros.com/u/anon49550872)\
**Post date:** [September 21, 2022, 8:35am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/11 "2022-09-21T08:35:13Z")

</div>

Speaking of that, you included h264, h265, vc1, and not vp9 or av1?

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [September 21, 2022, 8:36am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/12 "2022-09-21T08:36:35Z")

</div>

Av1 AFAIK has no issues and neither should vp9. They aren’t held back by patents so are enabled by default

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [September 21, 2022, 8:39am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/13 "2022-09-21T08:39:54Z")

</div>

@I0F @anon49550872

keep in mind that the Arch maintainers may handle this for you. This thread will be updated based on how its handled by the maintainers and if it is needed or not.

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [September 26, 2022, 11:45am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/14 "2022-09-26T11:45:31Z")

</div>

@I0F @anon49550872 @mrvictory

Checking the testing mesa release it looks like thing will be good to go for codecs in 22.2

---

<div class="post-metadata">

**Author:** ![I0F](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/i0f/32/47182_2.png) [@I0F](https://forum.endeavouros.com/u/I0F)\
**Post date:** [September 26, 2022, 1:24pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/15 "2022-09-26T13:24:20Z")

</div>

Thanks for keeping us up to date on this.

---

<div class="post-metadata">

**Author:** ![BS86](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/bs86/32/18119_2.png) [@BS86](https://forum.endeavouros.com/u/BS86)\
**Post date:** [September 26, 2022, 2:36pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/16 "2022-09-26T14:36:26Z")

</div>

the package itself has some major issues though

> **[FS#76019 : \[mesa\] 22.2.0-1 rendering breakage](https://bugs.archlinux.org/task/76019?project=1&string=mesa)**
>
> Flyspray, a Bug Tracking System written in PHP.

The first time since 2016 (my switch to free drivers) that I had to revert a mesa update xD

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [September 28, 2022, 4:13pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/17 "2022-09-28T16:13:34Z")

</div>

Fedora disabled it as is expected

> **[Fedora Linux Disabling Mesa's H.264 / H.265 / VC1 VA-API Support Over Legal...](https://www.phoronix.com/news/Fedora-Disable-Bad-VA-API)**
>
> For Fedora Linux users currently making use of Mesa's VA-API support with the open-source AMD graphics driver or similar and using it to speed-up H.264, H.265, or VC1 decoding, you may soon be out of luck and will have to fall-back to either using...

The people in the comments seem to think flatpak will be fine but flatpak folks seem likely to follow a similar path to Fedora looking at their mesa-git and related issues.

If Flatpak drops it I’ll figure a way for building mesa Flatpak on Arch in an easy way

---

<div class="post-metadata">

**Author:** ![anon49550872](https://forum.endeavouros.com/letter_avatar_proxy/v4/letter/a/b2d939/32.png) [@anon49550872](https://forum.endeavouros.com/u/anon49550872)\
**Post date:** [September 30, 2022, 1:29am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/18 "2022-09-30T01:29:06Z")

</div>

[AUR mesa-git](https://aur.archlinux.org/packages/mesa-git) is compiling with all the codecs automatically.  
I suppose that this could also be an option ?

```auto
$ mpv The\ Simpsons\ Movie\ -\ Trailer.mp4 
 (+) Video --vid=1 (*) (h264 1280x544 23.976fps)
 (+) Audio --aid=1 (*) (aac 2ch 48000Hz)
[vo/gpu/wayland] GNOME's wayland compositor lacks support for the idle inhibit protocol. This means the screen can blank during playback.
Cannot load libcuda.so.1
Using hardware decoding (vaapi).
AO: [pulse] 48000Hz stereo 2ch float
VO: [gpu] 1280x544 vaapi[nv12]
AV: 00:00:03 / 00:02:17 (3%) A-V: -0.017 DS: 6.314/23

```

---

<div class="post-metadata">

**Author:** ![Echoa](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/echoa/32/77553_2.png) [@Echoa](https://forum.endeavouros.com/u/Echoa)\
**Post date:** [September 30, 2022, 6:26am UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/19 "2022-09-30T06:26:01Z")

</div>

Im avoiding AUR simply to allow for a better level of trust in the package build. If it comes directly from the Arch maintainers/repo or another trusted sourceyou can be confident its what you would get from a normal install and then providing instructions to make the needed changes.

---

<div class="post-metadata">

**Author:** ![BS86](https://forum.endeavouros.com/user_avatar/forum.endeavouros.com/bs86/32/18119_2.png) [@BS86](https://forum.endeavouros.com/u/BS86)\
**Post date:** [September 30, 2022, 2:44pm UTC](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390/20 "2022-09-30T14:44:18Z")

</div>

> [@anon49550872](#):
>
> [AUR mesa-git](https://aur.archlinux.org/packages/mesa-git) is compiling with all the codecs automatically.

Arch includes the codecs, so why use the AUR?

@Echoa is talking about Fedora, and the AUR is not available there.

[Next page](https://forum.endeavouros.com/t/compiling-mesa-22-2-with-codec-support-the-easy-way/30390.md?page=2)
