Issues preventing proper FreeSync support

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 :frowning:

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.

After more studying, I have discovered that my meddling was causing the second issue. After rolling back the the “fix” for Issue 2 everything works perfectly. :man_facepalming:

I will investigate Issue 1 to see if a fix PR is within my ability.

the files are located in the “drivers” output

$ nix-build -A mesa.drivers
/nix/store/rpnax7fhi4np89fpzlcf2s79mfx458q6-mesa-20.0.2-drivers
$ ls ./result-drivers/share/drirc.d/
00-mesa-defaults.conf

seeing as this output only “saves” 4kb, I think the conf should just be loaded into the default “out” output

$ du -hd0 ./result-drivers
4.0K	./result-drivers

GitHub issue: Mesa DriConf defaults are being ignored · Issue #89421 · NixOS/nixpkgs · GitHub
GitHub PR (draft): mesa: Set datadir so that the path to the DriConf defaults is correct by primeos · Pull Request #89657 · NixOS/nixpkgs · GitHub

2 Likes