# Intel graphics, iris, mesa, gallium3d, vaapi.

## pigeon768

As some of you may be aware, Intel has been busy over the past year or so rewriting their driver stack to use mesa's gallium3d layers. Unfortunately, this support isn't well documented in Gentoo-land. As near as I can tell, this is how to get up and running with this driver stack in Gentoo:  Update to at least `media-libs/mesa-20`, `media-libs/gmmlib-19.4.1`, `x11-libs/libva-2.6.1`. Some of these are `~arch`.

 In `/etc/portage/make.conf`, set `VIDEO_CARDS=""`.

 Set USE="-classic gallium d3d9 vaapi"

 In /etc/portage/package.use, set `media-libs/mesa video_cards_iris`,`x11-libs/libdrm video_cards_intel`, `x11-base/xorg-server -minimal`

 If you want to build `xorg-server` with `USE=minimal`, set `x11-base/xorg-drivers video_cards_i965`. But ideally, you should be using the modesetting driver built into xorg-server. YMMV.

 `emerge x11-libs/libva-intel-media-driver`. Currently, the version in portage is out of date. Copy the 18.4.1 ebuild to 19.4.0r in your local portage repo. It will work fine.

 create `/etc/env.d/50vaapi`, and in it, put `LIBVA_DRIVER_NAME=iHD`

 I am 99% sure nothing else will need `video_cards_intel` or `video_cards_i965`, but I'm not positive.

Kernel, opengl, vulkan configurations mostly follow what's documented on the wiki.

I do not know if/how to get opencl running under iris.Last edited by pigeon768 on Sun Mar 22, 2020 6:56 pm; edited 2 times in total

----------

## dmpogo

 *pigeon768 wrote:*   

> As some of you may be aware, Intel has been busy over the past year or so rewriting their driver stack to use mesa's gallium3d layers. Unfortunately, this support isn't well documented in Gentoo-land. As near as I can tell, this is how to get up and running with this driver stack in Gentoo: 
> 
>  In `/etc/portage/make.conf`, set `VIDEO_CARDS=""`.
> 
>  Set USE="-classic gallium d3d9 vaapi"
> ...

 

What intel chipsets will this work on ?

----------

## pigeon768

Gen8 (Broadwell) or later. Basically, everything that has been released since 2014. The last new release of a GPU not supported by the Iris driver was in 2013.

Obviously i965+classic will need to be kept around indefinitely, but iris+classic should be the default.

----------

## grumblebear

I have done basically the same.

Set VIDEO_CARDS="intel iris" because intel is needed for some other packages.

In package.use put 

```
media-libs/mesa -classic -video_cards_intel
```

... and 

```
x11-base/xorg-drivers video_cards_i965
```

 to get rid of the no longer needed xf86-video-intel driver.

I have commented on this issue in this closed bug but got no attention so far.

For best results use Mesa 20. Since then upstream has selected iris as the new default driver for supported Intel hardware.

----------

## pigeon768

Good note on mesa-20. I updated my post.

Note that you don't need any `xf86-video-*` drivers for intel. The modesetting driver is the recommended option. xorg-server includes the modesetting driver unless you have USE=minimal set. I'll have to update my post again.

Which packages need VIDEO_CARDS=intel besides libdrm? We should sort all this out, then put it up on the wiki.

----------

## grumblebear

 *pigeon768 wrote:*   

> Note that you don't need any `xf86-video-*` drivers for intel. The modesetting driver is the recommended option. xorg-server includes the modesetting driver unless you have USE=minimal set. I'll have to update my post again.

 

That's why you should install xorg-drivers with video_cards_i965. If you look at the mentioned bug report, you will see that this flag just prevents pulling of xf86-video-intel.

 *pigeon768 wrote:*   

> Which packages need VIDEO_CARDS=intel besides libdrm? We should sort all this out, then put it up on the wiki.

 

You can get a list of all packages with 

```
quse video_cards_intel
```

 or 

```
quse -I video_cards_intel
```

 for just the installed packages.

----------

## dmpogo

 *pigeon768 wrote:*   

> 
> 
> [*] If you want to build `xorg-server` with `USE=minimal`, set `x11-base/xorg-drivers video_cards_i965`. But ideally, you should be using the modesetting driver built into xorg-server. YMMV.
> 
> 

 

video_cards_i965 is using modesetting driver

----------

## pigeon768

Oof, you're right.

This configuration is not ideal. This is a problem, because every new computer of the past 7 years needs to pretzel themselves to have a correct configuration.

What should this look like? Maybe replace i915 with intel_g3, replace i965 with intel_g4, and iris with intel_g8? Are generation 2 and below supported?

----------

## grumblebear

I think it would be best to just set VIDEO_CARDS="intel iris" for "newer" hardware as I have done and state that clearly in the wiki. That means leaving everything as it is with the second flag mainly for (and matching what is used in) mesa and the "intel" flag for everything else.

The meta package xorg-drivers should be changed to pull xf86-video-intel only for i915 as I have proposed in my last comment.

----------

## dmpogo

 *grumblebear wrote:*   

> I think it would be best to just set VIDEO_CARDS="intel iris" for "newer" hardware as I have done and state that clearly in the wiki. That means leaving everything as it is with the second flag mainly for (and matching what is used in) mesa and the "intel" flag for everything else.
> 
> The meta package xorg-drivers should be changed to pull xf86-video-intel only for i915 as I have proposed in my last comment.

 

Well, maybe in future, currently 'iris' will not overwrite 'intel' ( as 'i965' does ) your combination will pull xf86-video-intel.   And it is strange to pull intel driver for i915 but not for 'intel' itself.

Basically, you want to depreciate  classical, non-modesetting driver for all but the old cards ?  That is a bit drastic.

----------

## setun-90

Great work getting this started, pigeon768. I would never have known about the Iris driver without this post.

That said, I would like to give a heads-up: after switching to the Iris driver, I get a weird GPU page fault at the end of the day that freezes sway and forces me to pkill it and restart it. Given that it happens once at the end of the day, I don't know whether this is even a bug and not some misconfig on my part; I have dmesg logs nevertheless. I have HD Graphics 620 on an i7-8565U.

Keep up the good work nevertheless.

----------

## mu0n

Thanks for this discussion!  :Smile: 

I've an Intel Corporation UHD Graphics 620 (rev 07) on a DELL XPS 13 9370 (i.e., architecture Intel(R) Core(TM) i7-8550U CPU @ 1.80GHz) running kernel v5.8.0 and this is what I did to get the UHD graphics to work on it with OpenGL, Vulkan, and OpenCL.

In /etc/portage/make.conf ensure:

 It is okay for any/all of these USE flags to be set globally: 

```
wayland gles2 vaapi opengl vulkan
```

 It is NOT okay for the opencl USE flag to be set globally. Why? media-libs/mesa fails to build with opencl set as it insists on libclc which requires AMD or NVIDIA, and, globally the opencl USE flag also pulls in libclc which requires an AMD or NVIDIA GPU.

 Set VIDEO_CARDS to be 

```
""
```

 or the more accurate, 

```
"iris"
```

. Subsequent settings below will ensure all is okay, i.e., omitting intel and i965.

Note that I have these packages in my world file. Some of these might be otherwise pulled in (I've not sorted such out yet):

 dev-libs/intel-neo

 x11-libs/libva-intel-media-driver

 x11-apps/igt-gpu-tools

 dev-util/vulkan-tools

 media-libs/vulkan-loader

I summarized the earlier posts in this thread to be a single file with settings in /etc/portage/package.use/intel:

```
x11-libs/libva X drm opengl utils vdpau

# Per https://forums.gentoo.org/viewtopic-t-1110144-start-0.html

media-libs/mesa video_cards_iris -video_cards_intel -video_cards_i965 -classic gallium d3d9

x11-libs/libdrm video_cards_intel

x11-base/xorg-server -minimal

# Ensure xf86-video-intel does not get pulled in...

#x11-base/xorg-drivers video_cards_i965 -video_cards_intel

x11-base/xorg-drivers -video_cards_intel

# NOTE: quse -I video_cards_intel | awk -F: '{ print $1 }' | uniq

sys-power/pm-utils video_cards_intel

x11-apps/igt-gpu-tools video_cards_intel overlay

x11-libs/libdrm video_cards_intel

# NOTE: quse -I video_cards_i965 | awk -F: '{ print $1 }' | uniq

# USE opencl-related...

dev-libs/intel-neo l0

dev-util/spirv-llvm-translator tools

# RUN: quse -I opencl | awk -F: '{ P="" ; if ($1 ~ /mesa/) P="-"; print $1" "P"opencl"; }' | uniq

media-gfx/blender opencl cycles

media-gfx/imagemagick opencl

media-libs/mesa -opencl

media-libs/opencv opencl

media-libs/x264 opencl

media-video/ffmpeg opencl

#

# NOTE:

#   mesa v20.1.5 with opencl requires:

#     dev-libs/libclc-0.2.0_pre20191024

#   which results in mesa outputting:

#     >>> Running pre-merge checks for media-libs/mesa-20.1.5

#      * Ignoring USE=opencl     since VIDEO_CARDS does not contain r600 or radeonsi

#      * Ignoring USE=vaapi      since VIDEO_CARDS does not contain r600, radeonsi, or nouveau

#   AND it fails to build, thus, -opencl is required.

#

# USE vulkan-related...

media-libs/vulkan-loader layers

dev-util/vulkan-tools cube -wayland

```

Do adjust your settings for the entries immediately following the NOTE and RUN commands as required for your system.

Ensure that iHD graphics is selected with for libva:

```
echo "LIBVA_DRIVER_NAME=iHD" >/etc/env.d/50vaapi

env-update
```

and set /etc/X11/xorg.conf.d/20-intel.conf to use the modesetting driver:

```
Section "Device"

    Identifier  "modesetting"

    Driver      "modesetting"

EndSection

```

Update the required packages:

```
emerge -uDNav @world
```

Ensure that these packages are also installed, if not, emerge them directly:

 dev-libs/intel-neo

 x11-libs/libva-intel-media-driver

 x11-apps/igt-gpu-tools

 dev-util/vulkan-tools

 media-libs/vulkan-loader

Optional: "clean house" and re-emerge world to ensure all is good.

```
emerge -av --depclean

emerge -uDNav @world
```

e.g., x11-drivers/xf86-video-intel will be removed (if not remove it: it is no longer needed)

Reboot and then test things, e.g. run:

 vkcube

 vkcubepp

 vulkaninfo

 emerge -av x11-apps/mesa-progs # if needed

 glxgears

Hopefully this works for others and helps bring more sanity to Intel UHD users!  :Smile: 

----------

## CaptainBlood

@muon: Nice sum up  :Very Happy: 

I"m almost there, except for

```
dev-util/intel-graphics-compiler-1.0.4111
```

which fails at link step:

```
FAILED: IGC/Gentoo/libigc.so.1.0.1
```

Additionally log file shows:

```
CMake Warning (dev) in CMakeLists.txt:

  No project() command is present.  The top-level CMakeLists.txt file must

  contain a literal, direct call to the project() command.  Add a line of

  code such as

    project(ProjectName)

  near the top of the file, but after cmake_minimum_required().

  CMake is pretending there is a "project(Project)" command on the first

  line.

This warning is for project developers.  Use -Wno-dev to suppress it.

-- The C compiler identification is GNU 9.3.0

-- The CXX compiler identification is GNU 9.3.0

-- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc

-- Check for working C compiler: /usr/bin/x86_64-pc-linux-gnu-gcc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Detecting C compile features

-- Detecting C compile features - done

-- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++

-- Check for working CXX compiler: /usr/bin/x86_64-pc-linux-gnu-g++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Detecting CXX compile features

-- Detecting CXX compile features - done

CMake Deprecation Warning at IGC/CMakeLists.txt:41 (cmake_policy):

  The OLD behavior for policy CMP0043 will be removed from a future version

  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

CMake Deprecation Warning at IGC/CMakeLists.txt:43 (cmake_policy):

  The OLD behavior for policy CMP0054 will be removed from a future version

  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all

  policies are deprecated and that a policy should be set to OLD only under

  specific short-term circumstances.  Projects should be ported to the NEW

  behavior and not rely on setting a policy to OLD.

CMake Warning at IGC/CMakeLists.txt:1910 (message):

  CMAKE_BUILD_TYPE: Unknown build configuration.  The following

  configurations are available: Debug;Release.

  The "Release" configuration will be used.

  This value has meaning only for single-configuration generators (like

  Make).  It will be ignored for MSVC/XCode.

CMake Warning at IGC/CMakeLists.txt:1970 (message):

  IGC_OPTION__ARCHITECTURE_TARGET: Target architecture is not specified.

  Trying to deduce it from context.

-- ================================ IGC Project ================================

-- Build type:  Gentoo (single-configuration generator)

-- Build tools: OFF

-- LLVM dir:    

-- 

-- Output directory:

--    "/var/tmp/portage/dev-util/intel-graphics-compiler-1.0.4111/work/intel-graphics-compiler-1.0.4111_build-abi_x86_64.amd64/IGC/Gentoo"

-- Install root directory:

--    "/usr"

-- Architecture:

--  - target: Linux64    (detected: Linux64)

--  - host:   Linux64    (detected: Linux64)

-- 

-- Cross-compilation needed: NO

-- Cross-compilation set:    FALSE

-- 

-- Advanced:

--  - Link BiF resources:              ON

--  - Building Windows Universal:      

-- =============================================================================

-- [IGC] LLVM targets are not defined. Searching for LLVM.

-- [IGC] Using system LLVM 10.0.1

-- [IGC] Link against found LLVM dylib /usr/lib/llvm/10/lib64/libLLVM-10.so

Use InstCombiner from LLVM

-- [IGC\BiFModule] : opencl-clang will be taken from system

-- [IGC\BiFModule] Found clang-10 executable: /usr/lib/llvm/10/bin/clang-10

-- Configuring Intel Gen Assembler (IGA) Component

--  - GED_BRANCH:           GED_external

--  - CMAKE_CXX_COMPILER:   /usr/bin/x86_64-pc-linux-gnu-g++

fatal: not a git repository (or any parent up to mount point /var/tmp)

Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

fatal: not a git repository (or any parent up to mount point /var/tmp)

Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

GIT_DIRTY = 128

--  - IGA_VERSION_SUFFIX:    

-- Found BISON: /usr/bin/bison (found version "3.7.1") 

-- Found FLEX: /usr/bin/flex (found version "2.6.4") 

[check-igc] LIT tests disabled. Missing igc_opt target.

CMake Warning (dev) at CMakeLists.txt:11 (set):

  Cannot set "IGC__IGC_TARGETS": current scope has no parent.

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:12 (set):

  Cannot set "IGC_LIBRARY_NAME": current scope has no parent.

This warning is for project developers.  Use -Wno-dev to suppress it.

CMake Warning (dev) at CMakeLists.txt:13 (set):

  Cannot set "FCL_LIBRARY_NAME": current scope has no parent.

This warning is for project developers.  Use -Wno-dev to suppress it.

-- <<< Gentoo configuration >>>

Build type      Gentoo

Install path    /usr

Compiler flags:

C               -march=native -mtune=native   -O2             -pipe

C++             -march=native -mtune=native   -O2             -pipe

Linker flags:

Executable      -Wl,-O1 -Wl,--as-needed

Module          -Wl,-O1 -Wl,--as-needed

Shared          -Wl,-O1 -Wl,--as-needed

-- Configuring done
```

Which clang did you used? (clang:10 here).

Did tou succeeded building at first shot?

[Edit] Vanilla ld seems used here... Maybe lld is required? ld-gold?

Maybe you have a idea what's missing here?

Thks 4 ur attention, interest & support.

----------

## mu0n

I am running ~amd64 (i.e., testing) --but my gcc-config -l shows I have GCC 9.3.0 as the default (not GCC 10.2.0-r1 as such is not amd64 "stable" yet).

I used Clang 10.0.1 (i.e., latest in slot 10).

Everything worked the first time.

Vanilla ld (/usr/x86_64-pc-linux-gnu/binutils-bin/2.34/ld).

I had zero issues building such. If using the gold linker, try switching to vanilla.

----------

## CaptainBlood

Thks 4 replying,

I've just succeeded, HD tmpfs & ld-gold here...

I think I didn't have enough RAM.

Currently building intel-neo.

Will rebuild forthcoming version with vanilla ld.

My apolologizes, I should have fixed that prior to posting.

I first came back to that post to remove my post  :Laughing: 

I take this opportunity for a few questions:

 - intel-neo: l0 USE flag, any practical interest?

 - intel-neo: vaapi USE flag activated, any technical issue?

 - x11-drivers/xf86-video-intel here, any technical issue?

Thks 4 ur attention, interest & support.

----------

## mu0n

For intel-neo both USE="l0 vaapi" are set.

I've not played with any settings --my goal was to take the discussion, get it to work, and then summarize such on this forum.

Things appear to work very well for me. I am using the laptop + two DisplayPort monitors with the Intel card from the DELL XPS 13 and performance is excellent. Programs like Blender compile with the OpenCL flag (set on the package itself) and it appears to run properly as well.  :Smile: 

If you've specific USE flags and tests in mind, please detail / discuss such incl. what should be expected as a test result.

----------

## Atha

Hello!

First of all, sorry to hijack this thread, but I found that it's actually the main topic, so I'll just go for it:

My hardware: Intel 3rd Gen Core CPU, i.e. Ivy Bridge. IGP is the only graphics card, so no switching to do.

Graphics card: Intel HD Graphics 4000.

I have the following in /etc/portage/make.conf: VIDEO_CARDS="intel i965 fbdev vesa dummy", except for "fbdev vesa dummy" this is as described in https://wiki.gentoo.org/wiki/Intel i.e. "intel i965".

My question is what VIDEO_CARDS actually does to x11-drivers/xf86-video-intel, because though I do have it installed (cannot remember how, but it seems to be not in the @world file) every run of emerge --depclean wants to get rid of it.

According to man 4 intel: intel supports the i810, i810-DC100, i810e, i815, i830M, 845G, 852GM, 855GM, 865G, 915G, 915GM, 945G, 945GM, 965G, 965Q, 946GZ, 965GM,  945GME,  G33,  Q33, Q35,  G35,  GM45, G45, Q45, G43, G41 chipsets, Pineview-M in Atom N400 series, Pineview-D in Atom D400/D500 series, Intel(R) HD Graphics, Intel(R) Iris(TM) Graphics, Intel(R) Iris(TM) Pro Graphics.

From /var/log/Xorg.0.log I see that my X server is using the modesetting driver included in x11-base/xorg-server, which is most likely the preferred way considerung I am running a Linux kernel with KMS enabled. But why would VIDEO_CARDS not still be honored from the xorg-packages, since clearly x11-drivers/xf86-video-intel is the dedicated driver for configurations without KMS? It could be considered a legitimate fallback option...

Thanks!

[UPDATE]

Oh, sorry for the noise, I just found the reason on the Gentoo Wiki  page:

Important

Beginning with x11-base/xorg-drivers-1.19, the x11-base/xorg-drivers package (in addition to the mesa package) includes support for the i965 USE flag. This will omit selection of the deprecating x11-drivers/xf86-video-intel driver in favor of the more maintained, generic modesetting DDX driver built into x11-base/xorg-server.

I think it's wrong, but what do I know. I'll just add it to my @world...

Sorry for writing before thinking...   :Embarassed: 

----------

