Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mesa: build iris #65017

Closed
wants to merge 1 commit into from
Closed

mesa: build iris #65017

wants to merge 1 commit into from

Conversation

colemickens
Copy link
Member

@colemickens colemickens commented Jul 18, 2019

Motivation for this change

Fixes #65016.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@colemickens
Copy link
Member Author

colemickens commented Jul 18, 2019

I'm not sure this change will work. I don't know meson's build language semantics exactly, but it looks like it overrides the list of drivers completely, if auto is included in the list... https://gitlab.freedesktop.org/mesa/mesa/blob/master/meson.build#L142

EDIT: Ref: #63912 <- this PR removed the logic to determine which drivers to build. I guess we would have to reinstate most of that in order to build iris. It would be nice if upstream would allow ["auto" "iris"] as a way to say "build defaults + iris" but my test build indicates that is not how it works currently.

EDIT2: I'm going to try and patch the meson.build to see if I can get it to add the defaults to the list of gallium drivers instead of replacing the list, thus allowing auto+extras. Not sure though, since auto will still be in the list of drivers and presumably there's not actually a gallium driver named 'auto' to build...

@colemickens
Copy link
Member Author

cc: @worldofpeace

@colemickens colemickens changed the base branch from master to staging July 18, 2019 09:01
@colemickens
Copy link
Member Author

Alright, somehow this works, even though its not pretty. I'm going to build my system with this change and I'll report back.

@@ -5,7 +5,7 @@
, libelf, libvdpau, python3Packages
, libglvnd
, enableRadv ? true
, galliumDrivers ? ["auto"]
, galliumDrivers ? ["auto" "iris" ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"iris" should just be built on linux

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eadwu eadwu mentioned this pull request Jul 18, 2019
10 tasks
@colemickens
Copy link
Member Author

colemickens commented Jul 18, 2019 via email

@matthewbauer
Copy link
Member

@colemickens Was iris built before #63912? If so, we definitely should make sure it stays the same. Otherwise, though, I would prefer to defer to what mesa includes by default. The alternative is that you can build these drivers yourself and add them to opengl extraPackages:

{ pkgs, ... }:
let
  iris = (pkgs.mesa.override {
    galliumDrivers = ["iris"];
    driDrivers = [];
    vulkanDrivers = [];
  });
in {
  hardware.opengl.extraPackages = [ iris ];
}

@worldofpeace
Copy link
Contributor

I think it's perfectly sensible to be able to build iris, and defer to what upstream has as defaults.

The alternative is that you can build these drivers yourself and add them to opengl extraPackages:

Iris is highly desirous atm so I wouldn't want users to just have to do that.

@colemickens
Copy link
Member Author

colemickens commented Jul 18, 2019

I'm fine with building it myself, especially if I don't have to build the world. I'd be happy to document it on the wiki as well. However, I haven't found an override that works yet...

Trying with

  (pkgs.mesa.override {
    galliumDrivers = ["iris"];
    driDrivers = [];
    vulkanDrivers = [];
  });
Native C compiler: /nix/store/b8kdniwlxcppnsil2mq347aibf9hpm5d-gcc-wrapper-7.4.0/bin/cc (gcc 7.4.0 "gcc (GCC) 7.4.0")
Native C++ compiler: /nix/store/b8kdniwlxcppnsil2mq347aibf9hpm5d-gcc-wrapper-7.4.0/bin/c++ (gcc 7.4.0 "g++ (GCC) 7.4.0")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Program pkg-config found: YES (/nix/store/k4k297jyxk2hnhdykdz3mf3lxmmh52rb-pkg-config-0.29.2/bin/pkg-config)

meson.build:647:4: ERROR: Problem encountered: The nine state tracker requires gallium softpipe/llvmpipe.

A full log can be found at /build/mesa-19.1.1/build/meson-logs/meson-log.txt
builder for '/nix/store/bdzjm2s84zgpab0153pbbclr5hhc5inm-mesa-19.1.1.drv' failed with exit code 1
cannot build derivation '/nix/store/njpvcn8jg77rv9ca7p29hmi69q23r18x-opengl-drivers.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/vi050hsljmrj6ajy8ib31375360mxww2-etc-nixos.conf.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/rccf1npijdky3l42zinw8vndbkddfxdd-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/dmyliy2fcrj0raz1677p60qr0ajw53kn-nixos-system-xeep-19.09.git.git.drv': 1 dependencies couldn't be built
error: build of '/nix/store/dmyliy2fcrj0raz1677p60qr0ajw53kn-nixos-system-xeep-19.09.git.git.drv' failed
+ toplevel=

Trying with

  (pkgs.mesa.override {
    galliumDrivers = ["iris" "swrast "virgl" ];
    driDrivers = [];
    vulkanDrivers = [];
  });
Installing /build/mesa-19.1.1/build/meson-private/egl.pc to /nix/store/33vawb681frlh30m14zjva20kij72yw8-mesa-19.1.1/lib/pkgconfig
Installing /build/mesa-19.1.1/build/meson-private/osmesa.pc to /nix/store/33vawb681frlh30m14zjva20kij72yw8-mesa-19.1.1/lib/pkgconfig
Installing /build/mesa-19.1.1/build/meson-private/d3d.pc to /nix/store/33vawb681frlh30m14zjva20kij72yw8-mesa-19.1.1/lib/pkgconfig
Installing /build/mesa-19.1.1/build/meson-private/gl.pc to /nix/store/33vawb681frlh30m14zjva20kij72yw8-mesa-19.1.1/lib/pkgconfig
Running custom install script '/nix/store/7q2pgxz0yhf8b3dywq67x5m41gmhsagh-python3-3.7.3/bin/python3.7 /build/mesa-19.1.1/bin/install_megadrivers.py /build/mesa-19.1.1/build/src/gallium/targets/dri/libgallium_dri.so /nix/store/890sg02rppirhjk35ilk8zs7kqplpisz-mesa-19.1.1-drivers/lib/dri swrast_dri.so kms_swrast_dri.so iris_dri.so virtio_gpu_dri.so'
mv: missing file operand
Try 'mv --help' for more information.
builder for '/nix/store/f1vzhpzyg6s861iynl09mchsr8xh49kz-mesa-19.1.1.drv' failed with exit code 1
cannot build derivation '/nix/store/gwji4kq7rnz4z67j4k0pnzipd6j53hch-opengl-drivers.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/5x2xyb0pnyn6s92278qgn59s1p8xn3x3-etc-nixos.conf.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/25rf2r6nah2l7dmsc2gcy3ahaby6sq6l-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/cplgh5rmypqhxr27dyhyfaxlfwflwf0i-nixos-system-xeep-19.09.git.git.drv': 1 dependencies couldn't be built
error: build of '/nix/store/cplgh5rmypqhxr27dyhyfaxlfwflwf0i-nixos-system-xeep-19.09.git.git.drv' failed

Trying with

  (pkgs.mesa.override {
    galliumDrivers = ["iris" "swrast "virgl" ];
  });
shrinking /nix/store/araywhc9s59jrnd7q5mrgl5kjm6vj0jr-mesa-19.1.1-drivers/lib/libEGL_mesa.so.0.0.0
shrinking /nix/store/araywhc9s59jrnd7q5mrgl5kjm6vj0jr-mesa-19.1.1-drivers/lib/d3d/d3dadapter9.so.1.0.0
strip is /nix/store/glhymgljg23hkyii6dgc5b276ajafm2x-binutils-2.31.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/araywhc9s59jrnd7q5mrgl5kjm6vj0jr-mesa-19.1.1-drivers/lib
patching script interpreter paths in /nix/store/araywhc9s59jrnd7q5mrgl5kjm6vj0jr-mesa-19.1.1-drivers
checking for references to /build/ in /nix/store/araywhc9s59jrnd7q5mrgl5kjm6vj0jr-mesa-19.1.1-drivers...
shrinking RPATHs of ELF executables and libraries in /nix/store/2nvg25k83ykd5v3rzh1lrskhaspa63sm-mesa-19.1.1-osmesa
shrinking /nix/store/2nvg25k83ykd5v3rzh1lrskhaspa63sm-mesa-19.1.1-osmesa/lib/libOSMesa.so.8.0.0
strip is /nix/store/glhymgljg23hkyii6dgc5b276ajafm2x-binutils-2.31.1/bin/strip
stripping (with command strip and flags -S) in /nix/store/2nvg25k83ykd5v3rzh1lrskhaspa63sm-mesa-19.1.1-osmesa/lib
patching script interpreter paths in /nix/store/2nvg25k83ykd5v3rzh1lrskhaspa63sm-mesa-19.1.1-osmesa
checking for references to /build/ in /nix/store/2nvg25k83ykd5v3rzh1lrskhaspa63sm-mesa-19.1.1-osmesa...
substitute(): ERROR: file '/nix/store/rpglpf0b6lhn6yzd8j320m9y6nnqhxhs-mesa-19.1.1-dev/lib/pkgconfig/xatracker.pc' does not exist
builder for '/nix/store/g55qi27yba1kvj1h6lighr8q2jxfh29l-mesa-19.1.1.drv' failed with exit code 1
cannot build derivation '/nix/store/a7w7vi5yj51vgg5f11mmlmyhflv0as66-opengl-drivers.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/f4gxr49m9dv3vlhxil75kskws05ip0ha-etc-nixos.conf.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/520x3laaiyac2an1hcwn683srhirpa8b-etc.drv': 1 dependencies couldn't be built
cannot build derivation '/nix/store/k0v200857268hhyly82l61abl1a5k6zh-nixos-system-xeep-19.09.git.git.drv': 1 dependencies couldn't be built
error: build of '/nix/store/k0v200857268hhyly82l61abl1a5k6zh-nixos-system-xeep-19.09.git.git.drv' failed
+ toplevel=

@colemickens
Copy link
Member Author

Looks like the Nix derivation always copies the XA state tracker pkg-config, and it looks like mesa's meson.build only builds it when certain gallium drivers are included. I'm not sure if this is intentional, or an oversight on upstream's part when they added iris. I've asked in #dri-devel.

This seems to build, at least:

(pkgs.mesa.override {
   galliumDrivers = [ "r300" "r600" "radeonsi" "nouveau" "virgl" "svga" "swrast" "swrast" "virgl" "iris" ];
})  

However, after system activation, I see this:

[cole@xeep:/run/opengl-driver/lib/dri]$ ls /nix/store/w36z32hx86xxxbbdpbkanf42gi0sn9q9-mesa-19.1.1-drivers/lib/dri | rg iris
iris_dri.so

[cole@xeep:/run/opengl-driver/lib/dri]$ ls /run/opengl-driver/lib/dri | rg iris

@colemickens
Copy link
Member Author

cc: @eadwu

@eadwu
Copy link
Member

eadwu commented Jul 18, 2019

Before #63912, iris wasn't built by default. Currently, iris is in a usable state and only by 19.2 should be a viable replacement is what I've read they're aiming for. Personally I haven't experienced any major problems when I used iris in my daily life. The only problem I've actually encountered with iris is with compton which seems to be because of missing GLX extensions.

I'd probably expect iris to be built with auto on supported generations in the future when they finish it up. The way I've been overriding mesa was just copying over the drivers listed in the configuration summary of the build log and prepending iris.

Adding it to hardware.opengl.extraPackages seems to do the trick though it ends up adding more useless libraries to /run/opengl-drivers in my configuration. Is hardware.opengl.s3tcSupport needed anymore since it seems like it was incorporated into mesa? If not then setting hardware.opengl.package = lib.mkDefault (mesa.override { }).drivers; seems like the best solution in my eyes.

/run/opengl-drivers is created by tmpfiles so rebooting would fix the path. Restarting one of the systemd-tmpfiles-* might also do the trick?

@colemickens
Copy link
Member Author

I made this change to my system nixos configuration: colemickens/nixcfg@6a05bda. I rebuilt, and rebooted, and there is still no iris available for me: tree /run/opengl-driver | grep iris -> no results.

@eadwu
Copy link
Member

eadwu commented Jul 18, 2019

You want the $drivers output.

@colemickens
Copy link
Member Author

Thanks for the fast response. Next try: colemickens/nixcfg@a8a0f80

Now I get a collision:

these derivations will be built:
  /nix/store/sqnk6c4np671jgvy6hd3wz3hzvclm7ys-opengl-drivers.drv
  /nix/store/vd5lmbmrbx9hf62bjqw3ib5fzcs83r1k-etc-nixos.conf.drv
  /nix/store/r8iyxcdhqx0m39gciwwyhs96nbfh338y-etc.drv
  /nix/store/vh4vblck4216xbsr2lcf8z4zns255rl5-nixos-system-xeep-19.09.git.git.drv
building '/nix/store/sqnk6c4np671jgvy6hd3wz3hzvclm7ys-opengl-drivers.drv'...
collision between `/nix/store/fpbfc4qmzzywnkxl8mqszpqy8bzmp413-mesa-19.1.1-drivers/lib/libGLX_mesa.so.0.0.0' and `/nix/store/f70lgq6yzjybjazkrjpwayhpldgb7681-mesa-drivers+txc-19.1.1/lib/libGLX_mesa.so.0.0.0'
builder for '/nix/store/sqnk6c4np671jgvy6hd3wz3hzvclm7ys-opengl-drivers.drv' failed with exit code 255

I feel like I ought to know how to get past this, at this point in my NixOS usage. :/

@eadwu
Copy link
Member

eadwu commented Jul 18, 2019

Probably can be solved by setting the priority? Though I would rather use hardware.opengl.package once I make sure about the s3tcSupport option.

@colemickens
Copy link
Member Author

cool, this works: colemickens/nixcfg@5307eca

I am far from an expert, but from what I'm reading we can remove the s3tc stuff: https://arch-dev-public.archlinux.narkive.com/ApEYtwBN/removal-of-lib32-libtxc-dxtn-and-libtxc-dxtn-from-repositories

@colemickens
Copy link
Member Author

(Thank you very much for the guidance @eadwu).

I'm going to go ahead and close this for now. Here's a wiki entry: https://nixos.wiki/wiki/Intel_Graphics (we can correct it if we turn out to be wrong about s3tc stuff, but I figure it can't matter much since it's disabled by default anyway).

@worldofpeace
Copy link
Contributor

@colemickens The example you put in the wiki doesn't point to the drivers output.

@colemickens
Copy link
Member Author

Fixed. Thanks @worldofpeace

@ilya-fedin
Copy link
Contributor

ilya-fedin commented Jan 17, 2020

Can this PR be reopened? It would be nice if mesa with the iris driver will be as a separate entry in all-packages.nix at least. Mesa builds for a very long time on my hardware (Celeron N4000, yes). :(

@vcunat
Copy link
Member

vcunat commented Feb 1, 2020

Upstream is even defaulting to iris on some HW. It will be in mesa >= 20, currently in RC1 phase, so we should soon get it anyway.

@ilya-fedin
Copy link
Contributor

Okay, that's good news

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants