I have identified at least two issues preventing FreeSync from working nicely in gnome-shell (and probably other composited desktops). These issues are related to the 00-mesa-defaults.conf
file from the mesa source code, which 1, does not exist where mesa expects it to be, and 2, must be customized for nixos since the rules are by process-name and many binaries are renamed when they are packaged for nixos.
This probably affects things other than FreeSync too, because there are a lot of other application-specific workarounds in this file.
When FreeSync is enabled, gnome-shell should run at a fixed refresh-rate, and only games should be running at variable rates. Sadly, despite fixing both of the issues I found locally, gnome-shell is still running at a variable refresh-rate, and I have yet to find the third issue that is causing this. I’m out of ideas
Issue 1:
The options from the file /run/opengl-driver/share/drirc.d/00-mesa-defaults.conf
are ignored because mesa cant find it.
This can be observed with the command strace -f gnome-shell |& grep drirc.d
On my system, it looks for
/nix/store/nzkkagmvyg8xbraqd58jcddn09i9xjah-mesa-20.0.2/share/drirc.d
, which does not exist.
The correct location is pointed to by the symlink /run/opengl-driver/share
.
$ strace -f gnome-shell |& grep drirc.d
[pid 19550] openat(AT_FDCWD, "/nix/store/nzkkagmvyg8xbraqd58jcddn09i9xjah-mesa-20.0.2/share/drirc.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
[pid 19550] openat(AT_FDCWD, "/nix/store/nzkkagmvyg8xbraqd58jcddn09i9xjah-mesa-20.0.2/share/drirc.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
[pid 19550] openat(AT_FDCWD, "/nix/store/nzkkagmvyg8xbraqd58jcddn09i9xjah-mesa-20.0.2/share/drirc.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
[pid 19550] openat(AT_FDCWD, "/nix/store/nzkkagmvyg8xbraqd58jcddn09i9xjah-mesa-20.0.2/share/drirc.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
[pid 19550] openat(AT_FDCWD, "/nix/store/nzkkagmvyg8xbraqd58jcddn09i9xjah-mesa-20.0.2/share/drirc.d", O_RDONLY|O_NONBLOCK|O_CLOEXEC|O_DIRECTORY) = -1 ENOENT (No such file or directory)
$ ls -la /nix/store/nzkkagmvyg8xbraqd58jcddn09i9xjah-mesa-20.0.2/
total 8154
dr-xr-xr-x 3 root root 3 May 31 15:42 .
drwxrwxr-t 1623 root nixbld 9745 May 31 02:43 ..
dr-xr-xr-x 2 root root 8 Dec 31 1969 lib
$ ls -la /run/opengl-driver/share/drirc.d/
total 26
dr-xr-xr-x 2 root root 3 May 31 02:39 .
dr-xr-xr-x 5 root root 6 May 31 01:17 ..
-r--r--r-- 1 root root 27440 May 31 02:39 00-mesa-defaults.conf
Issue 2:
The binary names in 00-mesa-defaults.conf
are incorrect.
Mesa uses its util_get_process_name()
function to get the current process name. I have verified (with GDB) that the name it finds is .gnome-shell-wrapped
. This means it will ignore all the rules in 00-mesa-defaults.conf
configured for the binary “gnome-shell”, most notably for me, the rule disabling adaptive_sync.