Merge pull request #85253 from primeos/chromium-vaapi

chromium: Build with VA-API but disable it by default
This commit is contained in:
Michael Weiss 2020-04-18 14:20:33 +02:00 committed by GitHub
commit 34643fcf96
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 73 additions and 11 deletions

@ -24,8 +24,13 @@
, libdrm ? null, wayland ? null, mesa_drivers ? null, libxkbcommon ? null # useOzone
# package customization
, useVaapi ? false
, useOzone ? false
, useVaapi ? !(useOzone || stdenv.isAarch64) # Built if supported, but disabled in the wrapper
# VA-API TODOs:
# - Ozone: M81 fails to build due to "ozone_platform_gbm = false"
# - Possible solutions: Write a patch to fix the build (wrong gn dependencies)
# or build with minigbm
# - AArch64: Causes serious regressions (https://github.com/NixOS/nixpkgs/pull/85253#issuecomment-614405879)
, gnomeSupport ? false, gnome ? null
, gnomeKeyringSupport ? false, libgnome-keyring3 ? null
, proprietaryCodecs ? true
@ -127,10 +132,10 @@ let
libXScrnSaver libXcursor libXtst libGLU libGL
pciutils protobuf speechd libXdamage at-spi2-core
jre
] ++ optional gnomeKeyringSupport libgnome-keyring3
] ++ optional useVaapi libva
++ optional gnomeKeyringSupport libgnome-keyring3
++ optionals gnomeSupport [ gnome.GConf libgcrypt ]
++ optionals cupsSupport [ libgcrypt cups ]
++ optional useVaapi libva
++ optional pulseSupport libpulseaudio
++ optionals useOzone [ libdrm wayland mesa_drivers libxkbcommon ];
@ -149,9 +154,9 @@ let
#
# ++ optionals (channel == "dev") [ ( githubPatch "<patch>" "0000000000000000000000000000000000000000000000000000000000000000" ) ]
# ++ optional (versionRange "68" "72") ( githubPatch "<patch>" "0000000000000000000000000000000000000000000000000000000000000000" )
] ++ optionals (useVaapi) ([
# source: https://aur.archlinux.org/cgit/aur.git/tree/vaapi-fix.patch?h=chromium-vaapi
./patches/vaapi-fix.patch
] ++ optionals (useVaapi) ([ # Fixes for the VA-API build:
./patches/enable-vdpau-support-for-nvidia.patch # https://aur.archlinux.org/cgit/aur.git/tree/vdpau-support.patch?h=chromium-vaapi
./patches/enable-video-acceleration-on-linux.patch # Can be controlled at runtime (i.e. without rebuilding Chromium)
] ++ optionals (versionRange "81" "82") [
(githubPatch "5b2ff215473e0526b5b24aeff4ad90d369b21c75" "0n00vh8wfpn2ay5fqsxcsx0zadnv7mihm72bcvnrfzh75nzbg902")
(githubPatch "98e343ab369e4262511b5fce547728e3e5eefba8" "00wwp653jk0k0yvix00vr7ymgck9dj7fxjwx4nc67ynn84dh6064")

@ -6,13 +6,15 @@
, lib
# package customization
# Note: enable* flags should not require full rebuilds (i.e. only affect the wrapper)
, channel ? "stable"
, gnomeSupport ? false, gnome ? null
, gnomeKeyringSupport ? false
, proprietaryCodecs ? true
, enablePepperFlash ? false
, enableWideVine ? false
, useVaapi ? false # test video on radeon, before enabling this
, useVaapi ? false # Deprecated, use enableVaapi instead!
, enableVaapi ? false # Disabled by default due to unofficial support and issues on radeon
, useOzone ? false
, cupsSupport ? true
, pulseSupport ? config.pulseaudio or stdenv.isLinux
@ -33,7 +35,7 @@ let
upstream-info = (callPackage ./update.nix {}).getChannel channel;
mkChromiumDerivation = callPackage ./common.nix ({
inherit gnome gnomeSupport gnomeKeyringSupport proprietaryCodecs cupsSupport pulseSupport useVaapi useOzone;
inherit gnome gnomeSupport gnomeKeyringSupport proprietaryCodecs cupsSupport pulseSupport useOzone;
gnChromium = gn;
} // lib.optionalAttrs (channel != "stable") {
# TODO: Remove after we can update gn for the stable channel (backward incompatible changes):
@ -127,6 +129,14 @@ let
cp -a ${widevineCdm}/WidevineCdm $out/libexec/chromium/
''
else browser;
optionalVaapiFlags = if useVaapi # TODO: Remove after 20.09:
then throw ''
Chromium's useVaapi was replaced by enableVaapi and you don't need to pass
"--ignore-gpu-blacklist" anymore (also no rebuilds are required anymore).
'' else lib.optionalString
(!enableVaapi)
"--add-flags --disable-accelerated-video-decode --add-flags --disable-accelerated-video-encode";
in stdenv.mkDerivation {
name = "chromium${suffix}-${version}";
inherit version;
@ -146,15 +156,14 @@ in stdenv.mkDerivation {
buildCommand = let
browserBinary = "${chromiumWV}/libexec/chromium/chromium";
getWrapperFlags = plugin: "$(< \"${plugin}/nix-support/wrapper-flags\")";
libPath = stdenv.lib.makeLibraryPath ([]
++ stdenv.lib.optional useVaapi libva
);
libPath = stdenv.lib.makeLibraryPath [ libva ];
in with stdenv.lib; ''
mkdir -p "$out/bin"
eval makeWrapper "${browserBinary}" "$out/bin/chromium" \
--add-flags ${escapeShellArg (escapeShellArg commandLineArgs)} \
${optionalVaapiFlags} \
${concatMapStringsSep " " getWrapperFlags chromium.plugins.enabled}
ed -v -s "$out/bin/chromium" << EOF

@ -0,0 +1,48 @@
From b2144fd28e09cd52e7a88a62a9d9b54cf9922f9f Mon Sep 17 00:00:00 2001
From: Michael Weiss <dev.primeos@gmail.com>
Date: Tue, 14 Apr 2020 14:16:10 +0200
Subject: [PATCH] Enable accelerated video decode on Linux
This will enable accelerated video decode on Linux by default (i.e.
without "--ignore-gpu-blacklist"), but on NixOS we'll provide
"--disable-accelerated-video-decode" and
"--disable-accelerated-video-encode" by default to avoid regressions
(e.g. VA-API doesn't work properly for some radeon drivers).
Video acceleration can then be enabled via:
chromium.override { enableVaapi = true; }
without rebuilding Chromium.
---
gpu/config/software_rendering_list.json | 16 ----------------
1 file changed, 16 deletions(-)
diff --git a/gpu/config/software_rendering_list.json b/gpu/config/software_rendering_list.json
index 22712bdbf38f..a06dd19a50e4 100644
--- a/gpu/config/software_rendering_list.json
+++ b/gpu/config/software_rendering_list.json
@@ -336,22 +336,6 @@
]
},
{
- "id": 48,
- "description": "Accelerated video decode is unavailable on Linux",
- "cr_bugs": [137247, 1032907],
- "os": {
- "type": "linux"
- },
- "exceptions": [
- {
- "machine_model_name": ["Chromecast"]
- }
- ],
- "features": [
- "accelerated_video_decode"
- ]
- },
- {
"id": 50,
"description": "Disable VMware software renderer on older Mesa",
"cr_bugs": [145531, 332596, 571899, 629434],
--
2.11.0