blob: 36e27d2b56fa93c6a76d61f9101718eb897b9762 [file] [log] [blame] [view]
Miguel Casas32c29a432021-10-05 17:41:431# VA-API
Miguel Casase575c9852018-12-20 17:41:152
3This page documents tracing and debugging the Video Acceleration API (VaAPI or
Miguel Casas32c29a432021-10-05 17:41:434VA-API) on ChromeOS. VA-API is an open-source library and API specification,
Miguel Casase575c9852018-12-20 17:41:155providing access to graphics hardware acceleration capabilities for video and
Miguel Casas32c29a432021-10-05 17:41:436image processing. VA-API is used on ChromeOS on both Intel and AMD platforms.
Miguel Casase575c9852018-12-20 17:41:157
8[TOC]
9
Miguel Casas32c29a432021-10-05 17:41:4310VA-API is implemented by a generic `libva` library, developed upstream on
11the [VaAPI GitHub repository], from which ChromeOS is a downstream client via
12the [libva] package. Several backends are available for it, notably the legacy
13[Intel i965], the modern [Intel iHD] and the [AMD].
Miguel Casase575c9852018-12-20 17:41:1514
Miguel Casas32c29a432021-10-05 17:41:4315![](https://i.imgur.com/skS8Ged.png)
Miguel Casase575c9852018-12-20 17:41:1516
17[VaAPI GitHub repository]: https://github.com/intel/libva
John Palmer046f9872021-05-24 01:24:5618[libva]: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/x11-libs/libva/
Miguel Casas32c29a432021-10-05 17:41:4319[Intel i965]: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/x11-libs/libva-intel-driver/
20[Intel iHD]: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/x11-libs/libva-intel-media-driver/
John Palmer046f9872021-05-24 01:24:5621[AMD]: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/media-libs/libva-amdgpu-driver/
Miguel Casase575c9852018-12-20 17:41:1522
Miguel Casas32c29a432021-10-05 17:41:4323## `libva` tracing
24
25The environment variable `LIBVA_TRACE=/path/to/file` can be exposed to libva to
26store tracing information (see [va_trace.c]). `libva` will create a number of
27e.g. `libva.log.033807.thd-0x00000b25 ` files (one per thread) with a list of
28the actions taken and semi-disassembled parameters.
29
30[va_trace.c]: https://github.com/intel/libva/blob/64520e9ec90ed30e016d7c633d746b3bf538c702/va/va_trace.c#L59
31
Jianhui Daiaa455032023-12-05 18:06:1932## `libva` logging
Miguel Casas32c29a432021-10-05 17:41:4333
34The environment variable `LIBVA_MESSAGING_LEVEL=0` (or `1` or `2`) can be used
35to configure increasing logging verbosity to stdout (see [va.c]). Chromium uses
36a level `0` by default in `vaapi_wrapper.cc`.
37
38[va.c]: https://github.com/intel/libva/blob/2ece7099061ba4ea821545c8b6712b5c421c4dea/va/va.c#L194
39
Jianhui Daiaa455032023-12-05 18:06:1940## Tracing power consumption
Miguel Casas32c29a432021-10-05 17:41:4341
42Power consumption is available on ChromeOS test/dev images via the command line
43binary [`dump_intel_rapl_consumption`]; this tool averages the power
44consumption of the four SoC domains over a configurable period of time, usually
45a few seconds. These domains are, in the order presented by the tool:
46
47* `pkg`: estimated power consumption of the whole SoC; in particular, this is a
48 superset of pp0 and pp1, including all accessory silicon, e.g. video
49 processing.
50* `pp0`: CPU set.
51* `pp1`/`gfx`: Integrated GPU or GPUs.
52* `dram`: estimated power consumption of the DRAM, from the bus activity.
53
54
55`dump_intel_rapl_consumption` results should be a subset and of the same
56numerical value as those produced with e.g. `turbostat`. Note that despite the
57name, the tool works on AMD platforms as well, since they provide the same type
58of measurement registers, albeit a subset of Intel's. Googlers can read more
59about this topic under [go/power-consumption-meas-in-intel].
60
61`dump_intel_rapl_consumption` is usually run while a given workload is active
62(e.g. a video playback) with an interval larger than a second to smooth out all
63kinds of system services that would show up in smaller periods, e.g. WiFi.
64
65```shell
66dump_intel_rapl_consumption --interval_ms=2000 --repeat --verbose
67```
68
69E.g. on a nocturne main1, the average power consumption while playing back the
70first minute of a 1080p VP9 [video], the average consumptions in watts are:
71
72|`pkg` |`pp0` |`pp1`/`gfx` |`dram`|
73| ---: | ---: | ---: | ---: |
74| 2.63 | 1.44 | 0.29 | 0.87 |
75
76As can be seen, `pkg` ~= `pp0` + `pp1` + 1W, this extra watt is the cost of all
77the associated silicon, e.g. bridges, bus controllers, caches, and the media
78processing engine.
79
80
81[`dump_intel_rapl_consumption`]: https://chromium.googlesource.com/chromiumos/platform2/+/main/power_manager/tools/dump_intel_rapl_consumption.cc
82[video]: https://commons.wikimedia.org/wiki/File:Big_Buck_Bunny_4K.webm
83[go/power-consumption-meas-in-intel]: http://go/power-consumption-meas-in-intel
84
Miguel Casase575c9852018-12-20 17:41:1585## Verifying VaAPI installation and usage
86
87### <a name="verify-driver"></a> Verify the VaAPI is correctly installed and can be loaded
88
89`vainfo` is a small command line utility used to enumerate the supported
90operation modes; it's developed in the [libva-utils] repository, but more
91concretely available on ChromeOS dev images ([media-video/libva-utils] package)
92and under Debian systems ([vainfo]). `vainfo` will try to load the appropriate
93backend driver for the system and/or GPUs and fail if it cannot find/load it.
94
95[libva-utils]: https://github.com/intel/libva-utils
John Palmer046f9872021-05-24 01:24:5696[media-video/libva-utils]: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/main/media-video/libva-utils
Miguel Casase575c9852018-12-20 17:41:1597[vainfo]: https://packages.debian.org/sid/main/vainfo
98
99### <a name="verify-vaapi"></a> Verify the VaAPI supports and/or uses a given codec
100
101A few steps are customary to verify the support and use of a given codec.
102
103To verify that the build and platform supports video acceleration, launch
104Chromium and navigate to `chrome://gpu`, then:
105* Search for the "Video Acceleration Information" Section: this should
106 enumerate the available accelerated codecs and resolutions.
107* If this section is empty, oftentimes the "Log Messages" Section immediately
108 below might indicate an associated error, e.g.:
109
110 > vaInitialize failed: unknown libva error
111
112 that can usually be reproduced with `vainfo`, see the [previous
113 section](#verify-driver).
114
115To verify that a given video is being played back using the accelerated video
116decoding backend:
117* Navigate to a url that causes a video to be played. Leave it playing.
118* Navigate to the `chrome://media-internals` tab.
119 * Find the entry associated to the video-playing tab.
120 * Scroll down to "`Player Properties`" and check the "`video_decoder`" entry:
121 it should say "GpuVideoDecoder".
122
Jianhui Daiaa455032023-12-05 18:06:19123## VaAPI on Linux
Miguel Casase575c9852018-12-20 17:41:15124
Jianhui Daiaa455032023-12-05 18:06:19125VA-API on Linux is not supported, but it can be enabled using the flags below,
126and it might work on certain configurations -- but there's no guarantees.
Miguel Casase575c9852018-12-20 17:41:15127
Miguel Casase575c9852018-12-20 17:41:15128* To support proprietary codecs such as, e.g. H264/AVC1, add the options
Jianhui Daiaa455032023-12-05 18:06:19129 `proprietary_codecs = true` and `ffmpeg_branding = "Chrome"` to the GN args
130 (please refer to the [Setting up the build] Section).
Miguel Casase575c9852018-12-20 17:41:15131* Build Chromium as usual.
132
133At this point you should make sure the appropriate VA driver backend is working
134correctly; try running `vainfo` from the command line and verify no errors show
Jianhui Daiaa455032023-12-05 18:06:19135up, see the [previous section](#verify-driver).
Miguel Casase575c9852018-12-20 17:41:15136
Jianhui Dai2afb19b2024-07-04 23:34:56137The following feature switch controls video encoding (see [media
138switches](https://source.chromium.org/chromium/chromium/src/+/main:media/base/media_switches.cc)
139for more details):
Robert Mader54822102024-10-02 19:21:17140* `--enable-features=AcceleratedVideoEncoder`
Jianhui Daiaa455032023-12-05 18:06:19141
142The following two arguments are optional:
Corentin Walleze660b152020-07-15 16:07:54143* `--ignore-gpu-blocklist`
Jianhui Daiaa455032023-12-05 18:06:19144* `--disable-gpu-driver-bug-workaround`
145
Robert Mader54822102024-10-02 19:21:17146The following feature can improve performance when using EGL/Wayland:
147* `--enable-features=AcceleratedVideoDecodeLinuxZeroCopyGL`
148
Jianhui Daiaa455032023-12-05 18:06:19149The NVIDIA VaAPI drivers are known to not support Chromium (see
150[crbug.com/1492880](https://crbug.com/1492880)). This feature switch is
151provided for developers to test VaAPI drivers on NVIDIA GPUs:
152* `--enable-features=VaapiOnNvidiaGPUs`, disabled by default
Miguel Casase575c9852018-12-20 17:41:15153
Jianhui Dai2afb19b2024-07-04 23:34:56154### VaAPI on Linux with OpenGL
155
Miguel Casase575c9852018-12-20 17:41:15156```shell
Jianhui Daiaa455032023-12-05 18:06:19157./out/gn/chrome --use-gl=angle --use-angle=gl \
Robert Mader54822102024-10-02 19:21:17158--enable-features=AcceleratedVideoEncoder,AcceleratedVideoDecodeLinuxGL,VaapiOnNvidiaGPUs \
Jianhui Dai2afb19b2024-07-04 23:34:56159--ignore-gpu-blocklist --disable-gpu-driver-bug-workaround
160```
161
162### VaAPI on Linux with Vulkan
163
164```shell
165./out/gn/chrome --use-gl=angle --use-angle=vulkan \
Robert Mader54822102024-10-02 19:21:17166--enable-features=AcceleratedVideoEncoder,VaapiOnNvidiaGPUs,VaapiIgnoreDriverChecks,Vulkan,DefaultANGLEVulkan,VulkanFromANGLE \
Jianhui Daiaa455032023-12-05 18:06:19167--ignore-gpu-blocklist --disable-gpu-driver-bug-workaround
Miguel Casase575c9852018-12-20 17:41:15168```
169
Jianhui Daiaa455032023-12-05 18:06:19170Refer to the [previous section](#verify-vaapi) to verify support and use of the VaAPI.
Julien Isorce0a0dd3a2019-01-24 18:05:59171
Tom Anderson9f5be0792019-12-19 20:54:32172[Setting up the build]: https://chromium.googlesource.com/chromium/src/+/HEAD/docs/linux/build_instructions.md#setting-up-the-build
Jianhui Daiaa455032023-12-05 18:06:19173