Bug 221540 - graphics/mesa-dri: enable Vulkan drivers
Summary: graphics/mesa-dri: enable Vulkan drivers
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-x11 mailing list
URL:
Keywords: patch, patch-ready
Depends on:
Blocks: 222175
  Show dependency treegraph
 
Reported: 2017-08-15 13:08 UTC by Jan Beich
Modified: 2018-10-20 21:40 UTC (History)
3 users (show)

See Also:
zeising: maintainer-feedback?


Attachments
Part 1 (Mesa 17.2) - Build anv and radv (8.71 KB, patch)
2017-08-15 13:08 UTC, Jan Beich
no flags Details | Diff
Part 1 (Mesa 17.2) - Build anv and radv (8.94 KB, patch)
2017-09-21 03:59 UTC, Jan Beich
no flags Details | Diff
Part 1 (Mesa 17.1) - Build anv and radv (8.49 KB, patch)
2017-09-21 04:52 UTC, Jan Beich
no flags Details | Diff
[don't land] anv hacks for Mesa 17.2 (2.32 KB, patch)
2017-09-22 05:13 UTC, Jan Beich
no flags Details | Diff
Part 1 (Mesa 17.3) - Build anv and radv (9.52 KB, patch)
2017-10-23 17:14 UTC, Jan Beich
no flags Details | Diff
[dont'land] anv hacks for Mesa 17.3 (2.39 KB, patch)
2017-10-23 17:16 UTC, Jan Beich
no flags Details | Diff
Part 2 - Add WAYLAND option (1.13 KB, patch)
2017-10-23 19:20 UTC, Greg V
no flags Details | Diff
Part 1 (Mesa 17.3) - Build anv and radv (9.53 KB, patch)
2017-12-04 12:53 UTC, Jan Beich
no flags Details | Diff
Part 1 (Mesa 17.3) - Build anv and radv (9.65 KB, patch)
2017-12-08 19:40 UTC, Jan Beich
no flags Details | Diff
Part 1 (Mesa 17.2) - Build anv and radv (9.51 KB, patch)
2017-12-09 18:41 UTC, Jan Beich
zeising: maintainer-approval+
Details | Diff
Part 1 (Mesa 17.3) - Build anv and radv (9.71 KB, patch)
2017-12-09 18:43 UTC, Jan Beich
zeising: maintainer-approval+
Details | Diff
Part 2 - Add WAYLAND option (1.72 KB, patch)
2017-12-28 22:48 UTC, Jan Beich
jbeich: maintainer-approval? (x11)
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jan Beich freebsd_committer 2017-08-15 13:08:04 UTC
Created attachment 185445 [details]
Part 1 (Mesa 17.2) - Build anv and radv
Comment 1 Greg V 2017-09-06 21:52:04 UTC
Yay! Got the demo cube spinning on my RX 480! (as I mentioned in 220982, OpenGL/Xorg doesn't work for me on 17.2.0, so I currently have 17.1.7 and ONLY Vulkan and VDPAU from the 17.2.0 build)

vulkaninfo output: https://gist.github.com/myfreeweb/eca206a059eb396ec23c47f211ddbe58


My WIP patch for the Vulkan ICD loader and stuff: https://github.com/myfreeweb/Vulkan-LoaderAndValidationLayers/tree/freebsd

(validation layers don't compile yet)

On Intel Haswell, it doesn't work, just says that the implementation is incomplete for Haswell.
Comment 2 Greg V 2017-09-07 20:06:16 UTC
With the properly built 17.2.0 packages, the Dolphin Emulator successfully plays The Legend of Zelda: The Wind Waker on Vulkan with the RADV driver! This is the year of FreeBSD on the desktop :D https://i.imgur.com/kJgyAX2.jpg
Comment 3 Greg V 2017-09-09 19:47:08 UTC
I made ports for the Vulkan loader and stuff: bug 222175
Comment 4 Jan Beich freebsd_committer 2017-09-21 03:46:00 UTC
anv (intel) fails vkEnumeratePhysicalDevices due to lack of build-id, mistakenly removed in v0 of the patch. However, vkCreateDevice requires DRM_IOCTL_I915_GEM_USERPTR which is broken.

https://github.com/FreeBSDDesktop/freebsd-base-graphics/issues/132
Comment 5 Jan Beich freebsd_committer 2017-09-21 03:59:36 UTC
Created attachment 186578 [details]
Part 1 (Mesa 17.2) - Build anv and radv
Comment 6 Jan Beich freebsd_committer 2017-09-21 04:52:18 UTC
Created attachment 186579 [details]
Part 1 (Mesa 17.1) - Build anv and radv
Comment 7 Jan Beich freebsd_committer 2017-09-21 05:46:57 UTC
I wonder, if radv is limited to drm-next or would work on FreeBSD releases.

Mesa 17.2 version was build-tested together bug 221540. Mesa 17.1 version testing was less fancy, only on 10.3 i386/amd64, 11.0 i386/amd64, 11.1 i386/amd64, 12.0 i386/amd64/armv6/aarch6.

This can probably land under maintainer timeout given low risk for existing drivers. However, there's no rush before bug 222175 lands.
Comment 8 Jan Beich freebsd_committer 2017-09-22 05:13:30 UTC
Created attachment 186610 [details]
[don't land] anv hacks for Mesa 17.2

Let's try unsynchronized userptr (requires root). Here's my vulkaninfo output: http://sprunge.us/fWUU
cube demo works (sometimes) but rpcs3 hangs. Not very promising. ;\
Comment 9 Greg V 2017-10-20 23:48:55 UTC
I discovered something! To make Vulkan work on Wayland, --with-platforms=x11,drm,wayland needs to be added to mesa-dri too, not just mesa-libs. It enables the VK_KHR_wayland_surface extension in the drivers.
Comment 10 Jan Beich freebsd_committer 2017-10-23 17:14:56 UTC
Created attachment 187400 [details]
Part 1 (Mesa 17.3) - Build anv and radv
Comment 11 Jan Beich freebsd_committer 2017-10-23 17:16:40 UTC
Created attachment 187401 [details]
[dont'land] anv hacks for Mesa 17.3
Comment 12 Greg V 2017-10-23 19:20:01 UTC
Created attachment 187404 [details]
Part 2 - Add WAYLAND option

Here's an extra patch that adds a WAYLAND option to mesa-dri, which enables building the VK_KHR_wayland_surface extension in Vulkan drivers.

BTW, got the cube demo and vulkaninfo working on my Haswell laptop. But only after launching them as root.
Comment 13 Jan Beich freebsd_committer 2017-12-04 12:53:12 UTC
Created attachment 188519 [details]
Part 1 (Mesa 17.3) - Build anv and radv
Comment 14 Greg V 2017-12-04 14:55:08 UTC
(In reply to Jan Beich from comment #13)

Just noticed:

> Partially implement memfd_create() via mkostemp()

We have shm_open(SHM_ANON) for that! memfd is literally SHM_ANON but as a separate syscall because Linux likes making things look complex :)

> ${PYTHON_PKGNAMEPREFIX}mako>0:textproc/py-mako

I think 2.7 is required here? (Or was that not Mesa…) The new flavors feature can help with that.
Comment 15 Jan Beich freebsd_committer 2017-12-08 19:40:11 UTC
Created attachment 188635 [details]
Part 1 (Mesa 17.3) - Build anv and radv

(In reply to Greg V from comment #14)
Like this?
Comment 16 Greg V 2017-12-09 14:13:39 UTC
(In reply to Jan Beich from comment #15)
Yeah, looks good to me.
Comment 17 Niclas Zeising freebsd_committer 2017-12-09 16:35:28 UTC
Looking at this.
Comment 18 Niclas Zeising freebsd_committer 2017-12-09 16:36:35 UTC
There is a lot of patches in this PR.  It would be extremely helpful if you could consolidate the patches and mark any obsoleted patches as such.  Thank you!
Comment 19 Jan Beich freebsd_committer 2017-12-09 16:41:52 UTC
Comment on attachment 186579 [details]
Part 1 (Mesa 17.1) - Build anv and radv

Obsolete after ports r451657.
Comment 20 Jan Beich freebsd_committer 2017-12-09 18:41:11 UTC
Created attachment 188666 [details]
Part 1 (Mesa 17.2) - Build anv and radv

Changes since previous version:
- Rebase
- Use SHM_ANON per comment 14
- Prepare for bug 214864
Comment 21 Jan Beich freebsd_committer 2017-12-09 18:43:36 UTC
Created attachment 188667 [details]
Part 1 (Mesa 17.3) - Build anv and radv

Changes since previous version:
- Prepare for bug 214864
Comment 22 Jan Beich freebsd_committer 2017-12-09 18:59:19 UTC
(In reply to Niclas Zeising from comment #18)
> It would be extremely helpful if you could consolidate the patches
> and mark any obsoleted patches as such.

Not possible. Mesa 17.1, 17.2, 17.3 each require slightly different patches. I've renamed them to reduce confusion. Also, to avoid bisecting pain this should land separately from any unrelated changes.

Before bug 223195 lands:
1. Apply "Part 1 (Mesa 17.2) - Build anv and radv"
2. Apply "Part 2 - Add WAYLAND option"
3. Commit

After bug 223195 lands:
1. Apply "Part 1 (Mesa 17.3) - Build anv and radv"
2. Apply "Part 2 - Add WAYLAND option"
3. Commit
Comment 23 Niclas Zeising freebsd_committer 2017-12-09 20:17:20 UTC
Thank you!
This is helpful too, and made it clearer for me.
One question, out of curiosity, the patches named "anv hacks for", what are those for?  You've tagged them with don't land, but I'm curious anyway.
Comment 24 Jan Beich freebsd_committer 2017-12-09 20:45:22 UTC
(In reply to Niclas Zeising from comment #23)
> out of curiosity, the patches named "anv hacks for", what are those for?

Workarounds for DRM_IOCTL_I915_GEM_USERPTR [1]. Requires root and too unstable but enough to do basic QA for anv. vulkaninfo works, vkquake crashes on vkWaitForFences (needs more hacks).

[1] https://github.com/FreeBSDDesktop/freebsd-base-graphics/issues/132
Comment 25 Niclas Zeising freebsd_committer 2017-12-09 21:00:20 UTC
Approved
Comment 26 Niclas Zeising freebsd_committer 2017-12-17 13:15:43 UTC
Comment on attachment 188666 [details]
Part 1 (Mesa 17.2) - Build anv and radv

Mesa 17.3 has just landed.  Mark this as osolete, since it's for mesa 17.2
Comment 27 Niclas Zeising freebsd_committer 2017-12-17 13:16:31 UTC
I just landed mesa 17.3 in the ports tree.  I'll let that simmer for a little while, and then I'll get to this as well.
Comment 28 commit-hook freebsd_committer 2017-12-27 22:54:28 UTC
A commit references this bug:

Author: jbeich
Date: Wed Dec 27 22:53:47 UTC 2017
New revision: 457430
URL: https://svnweb.freebsd.org/changeset/ports/457430

Log:
  graphics/mesa-dri: enable Vulkan drivers

  PR:		221540
  Tested by:	Greg V
  Approved by:	x11 (zeising)

Changes:
  head/graphics/mesa-dri/Makefile
  head/graphics/mesa-dri/files/patch-src_intel_vulkan_anv__allocator.c
  head/graphics/mesa-dri/files/patch-src_intel_vulkan_anv__device.c
  head/graphics/mesa-dri/files/patch-src_intel_vulkan_anv__gem.c
  head/graphics/mesa-dri/files/patch-src_intel_vulkan_anv__queue.c
  head/graphics/mesa-dri/pkg-plist
Comment 29 Jan Beich freebsd_committer 2017-12-27 22:55:33 UTC
Landed it myself. We need to simmer Vulkan drivers on /head before 2018Q1 branches as well.
Comment 30 Jan Beich freebsd_committer 2017-12-27 23:02:03 UTC
Having this bug fixed in 2018Q1 would simplify MFH of any future patch-level update that may require minor changes to Vulkan patches.
Comment 31 Jan Beich freebsd_committer 2017-12-27 23:04:08 UTC
Oops, forgot about WAYLAND.
Comment 32 Jan Beich freebsd_committer 2017-12-27 23:11:29 UTC
Comment on attachment 187404 [details]
Part 2 - Add WAYLAND option

Hmm, if graphics/mesa-libs is built with WAYLAND=off the following happens:

checking for wayland-client >= 1.11... no
configure: error: Package requirements (wayland-client >= 1.11) were not met:

Package 'wayland-client', required by 'virtual:world', not found
Comment 33 Niclas Zeising freebsd_committer 2017-12-28 06:17:54 UTC
Comment on attachment 187404 [details]
Part 2 - Add WAYLAND option

Looking into this.
Comment 34 Jan Beich freebsd_committer 2017-12-28 22:48:44 UTC
Created attachment 189177 [details]
Part 2 - Add WAYLAND option

Let's add missing deps and IGNORE, assuming other drivers don't use Wayland. 10.3 i386/amd64, 11.1 i386/amd64, 12.0 amd64 are green. 11.1 aarch64/armv6, 12.0 aarch64/armv6/armv7 hit IGNORE e.g.,

=======================<phase: check-sanity   >============================
===>  mesa-dri-17.3.1_1 option WAYLAND is only valid on platforms with Vulkan.
*** Error code 1
Comment 35 commit-hook freebsd_committer 2017-12-30 08:52:38 UTC
A commit references this bug:

Author: jbeich
Date: Sat Dec 30 08:51:33 UTC 2017
New revision: 457591
URL: https://svnweb.freebsd.org/changeset/ports/457591

Log:
  graphics/mesa-dri: unbreak on powerpc* + clang after r457430

  python2.7 ./radv_entrypoints_gen.py \
          --xml ../../../src/vulkan/registry/vk.xml --outdir .
  Traceback (most recent call last):
    File "./radv_entrypoints_gen.py", line 30, in <module>
      from mako.template import Template
  ImportError: No module named mako.template

  PR:		221540
  Reported by:	Mark Millard (via ports@ list)
  Approved by:	portmgr blanket

Changes:
  head/graphics/mesa-dri/Makefile
Comment 36 Niclas Zeising freebsd_committer 2017-12-31 11:31:40 UTC
Thanks for your submission!

We are currently discussing how to handle vulkan drivers and the wayland option and we are working on this.
Comment 37 Eitan Adler freebsd_committer freebsd_triage 2018-05-23 10:28:05 UTC
batch change of PRs untouched in 2018 marked "in progress" back to open.
Comment 38 commit-hook freebsd_committer 2018-10-16 00:01:24 UTC
A commit references this bug:

Author: jbeich
Date: Tue Oct 16 00:00:21 UTC 2018
New revision: 482192
URL: https://svnweb.freebsd.org/changeset/ports/482192

Log:
  graphics/mesa-dri: add WAYLAND option for Vulkan drivers

  PR:		221540
  Submitted by:	Greg V
  Approved by:	maintainer timeout (9 months timeout), zeising (earlier version)

Changes:
  head/graphics/mesa-dri/Makefile
Comment 39 commit-hook freebsd_committer 2018-10-20 21:40:16 UTC
A commit references this bug:

Author: jbeich
Date: Sat Oct 20 21:39:21 UTC 2018
New revision: 482625
URL: https://svnweb.freebsd.org/changeset/ports/482625

Log:
  graphics/mesa-dri: don't forbid WAYLAND on non-x86

  At least aarch64, armv6, armv7 couldn't set OPTIONS_SET+=WAYLAND via make.conf
  (see also bug 227509) despite Wayland itself not having such a limitation.

  =>> Ignoring graphics/mesa-dri: option WAYLAND is only valid on platforms with Vulkan

  PR:		221540
  Pointy hat to:	jbeich (regressed by r482192)

Changes:
  head/graphics/mesa-dri/Makefile