Bug 271136 - graphics/mesa-devel: Correct way to tell Xorg which driver to use
Summary: graphics/mesa-devel: Correct way to tell Xorg which driver to use
Status: Open
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Some People
Assignee: Jan Beich
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-04-29 19:03 UTC by Alexander Vereeken
Modified: 2023-04-30 09:04 UTC (History)
1 user (show)

See Also:
jbeich: maintainer-feedback+


Attachments
Add mesa-devel support to wine-wow64.sh (5.52 KB, patch)
2023-04-29 22:33 UTC, Jan Beich
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Alexander Vereeken 2023-04-29 19:03:17 UTC
Hello,

i do current use mesa-devel to workaround a bug in RADV which affects the shader compilation in Wine.

When i want to start Xorg then it fails to load the GLX extension and it segfaults, but when i do remove the libs from mesa-dri and replace them with the -devel one, then the GLX extension gets loaded and Xorg works again.

Is there a more elegant way to configure this, that Xorg is using the dri-devel libs but without removing the stable ones?

Thank you in advance and for maintaining this :)
Comment 1 Jan Beich freebsd_committer freebsd_triage 2023-04-29 20:14:27 UTC
mesa-devel package installs /usr/local/etc/libmap.d/mesa-devel.conf which overrides mesa-{libs,dri}. For example, /usr/local/lib/xorg/modules/extensions/.xorg/libglx.so calls into libGLX.so from libglvnd which later calls into libGLX_mesa.so that libmap.conf(5) translate into libGLX_mesa-devel.so calls.

I don't use Wine but the issue is likely due to 32-bit libs. Does copying /etc/libmap.conf into /etc/libmap32.conf help ? If not try adjusting "includedir" to point to 32-bit PREFIX used by 32-bit mesa-devel.

Vulkan, VAAPI, VDPAU overrides /usr/local/etc/libmap.d/mesa-devel.conf contain absolute paths because that's how their dispatchers work. For example,

$ cat /usr/local/share/vulkan/icd.d/radeon_icd.i386.json
{
    "ICD": {
        "api_version": "1.3.230",
        "library_path": "/usr/local/lib/libvulkan_radeon.so"
    },
    "file_format_version": "1.0.0"
}

$ pkg which -qo /usr/local/share/vulkan/icd.d/radeon_icd.i386.json
graphics/mesa-dri

How does this currently work for 32-bit Wine *without* mesa-devel? /usr/local/lib/ on amd64 contains 64-bit libs, so there's probably some magic that translates it to where 32-bits are located.
Comment 2 Jan Beich freebsd_committer freebsd_triage 2023-04-29 20:58:26 UTC
(In reply to Jan Beich from comment #1)
> How does this currently work for 32-bit Wine *without* mesa-devel?

Nevermind. emulators/wine/files/wine-wow64.sh sets LD_32_LIBMAP. Remove /etc/libmap32.conf (suggested in comment 1) and try the following instead:

$ export LD_32_LIBMAP=$(sed "s,/usr/local,$HOME/.i386-wine-pkg&,2" /usr/local/etc/libmap.d/mesa-devel.conf)
Comment 3 Jan Beich freebsd_committer freebsd_triage 2023-04-29 22:33:30 UTC
Created attachment 241864 [details]
Add mesa-devel support to wine-wow64.sh

Here's an example fix. I've only tested via glxgears, eglgears_x11, vkcube-xcb but not Wine. 

libmap.conf(5) bits are generic for other ports e.g.,

$ rg -lg Makefile libmap.d | sed s,/Makefile,,
devel/sdl12-compat
graphics/mesa-devel
graphics/mesa-libs
multimedia/jellyfin
x11/nvidia-driver

Of those only mesa-* and nvidia-driver are relevant to wine*. Also, nvidia-driver >= 410.057 uses libglvnd instead of libmap.conf(5).
Comment 4 Jan Beich freebsd_committer freebsd_triage 2023-04-29 23:09:18 UTC
Oops, mixing Xorg and Wine in the same bug was a mistake. I'll file a separate bug for the Wine fix.

(In reply to Alexander Vereeken from comment #0)
> When i want to start Xorg then it fails to load the GLX extension and it segfaults

Maybe caused by libmap.conf(5) sorting order where both mesa-libs and mesa-devel define libGLX_indirect.so.0. However, libGLX_indirect.so.0 isn't supposed to be used unless Xorg failed to set up GLX_EXT_libglvnd uses indirect GLX (disabled by default > 10 years ago for security reasons).

Does adding the following to xorg.conf help?

  Section "ServerFlags"
  Option  "AIGLX" "off"
  EndSection

I do test X11 regularly but not via Xorg. When mesa-devel is installed nothing seems to use mesa-libs bits which is easy to test by simply removing libGLX_mesa.so and libEGL_mesa.so. If libmap.conf(5) didn't work GLX/EGL apps would fail due to missing libraries.
Comment 5 Jan Beich freebsd_committer freebsd_triage 2023-04-29 23:46:18 UTC
Comment on attachment 241864 [details]
Add mesa-devel support to wine-wow64.sh

Moved to bug 271140
Comment 6 Alexander Vereeken 2023-04-30 00:42:01 UTC
Hello, thank you for reply and will try out your suggestions.

Oh didn't had thought about the 32-bit games but good catch.

The issue that I had originally that if i use stable mesa that games with much shaders can hang with virtual_setup_exception stack overflow, if they get cached for the first times.

If such an hang occurs the game audio continues but the picture is frozen and some games do close with : "120 sec timeout after waiting for renderer.
Comment 7 Alexander Vereeken 2023-04-30 09:04:21 UTC
So, i have tried out the AIGLX flag and it doesn't work.

Xorg still trys to load AIGLX stuff.