V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
xxgirl2
V2EX  ›  硬件

关于 ubuntu 下浏览器的硬件加速问题

  •  
  •   xxgirl2 · 2018-08-21 22:09:37 +08:00 · 5468 次点击
    这是一个创建于 2046 天前的主题,其中的信息可能已经有所发展或是发生改变。

    我使用的是 Chrome Stable,保持更新。 系统是 Windows 8.1 和 xubuntu 双系统。 主芯片是 AMD A4-3300M (见笑了)。

    在 Windows 下,Chrome 可以正常获得 GPU 加速。 在 ubuntu 下,mplayer 能低占用 CPU,正常使用 GPU 加速,但 Chrome 不能。 ubuntu 自带的 firefox 播放视频也会吃大量 CPU。

    不知有没有人知道这是为何。

    附:

    使用 lsmod | grep rad 的结果是

    radeon               1470464  12
    i2c_algo_bit           16384  1 radeon
    ttm                   102400  1 radeon
    drm_kms_helper        172032  1 radeon
    drm                   397312  8 radeon,ttm,drm_kms_helper
    

    使用 lsmod | grep amd 的结果是

    kvm_amd                86016  0
    kvm                   598016  1 kvm_amd
    

    可见驱动是旧硬件的 radeon,而非常见的 amdgpu。

    chrome://flag 里强行开了 GPU 相关的 flag,chrome://gpu 里的结果虽然已经显示为支持硬解,但实际运行效果并没有变化。

    7 条回复    2018-08-22 20:33:23 +08:00
    iwtbauh
        1
    iwtbauh  
       2018-08-22 09:21:05 +08:00 via Android
    发一下
    dpkg -l | grep xserver-xorg-video-
    dpkg -l | grep libva
    dpkg -l | grep vdpau
    glxinfo | grep OpenGL
    vainfo
    vdpauinfo

    “吃大量 CPU ” 是吃多少 CPU ?

    安装一个 radeontop,然后看看放视频的时候 GPU 的使用率。
    iwtbauh
        2
    iwtbauh  
       2018-08-22 09:22:45 +08:00 via Android
    另外还有

    id
    ls -l /dev/dri/
    iwtbauh
        3
    iwtbauh  
       2018-08-22 10:44:21 +08:00 via Android
    抱歉,经过我的搜索后 我发现 chrome 和 firefox 都不支持在 Linux 上加速视频解码。但是可以对渲染进行硬件加速。

    chromium 存在一个非官方的补丁以启用视频解码加速,如果有需要可以自行编译打过补丁的 chromium。

    所以,不用担心,[[chrome,chromium 和 firefox 都会使用 GPU 来加速渲染,不会影响你的网页浏览体验,只有播放视频的解码部分才会不使用硬件加速。]] 但是你用浏览器看视频的时间应该不会很多吧?如果需要看网络上的视频时,运行 mpv 或者 vlc 打开网络串流即可,它们有很好的视频解码硬件加速支持。
    xxgirl2
        4
    xxgirl2  
    OP
       2018-08-22 17:50:10 +08:00
    @iwtbauh 静态的检测结果如下:
    ```
    aya@aya-NC4AS13:~$ dpkg -l | grep xserver-xorg-video-
    ii xserver-xorg-video-all 1:7.7+19ubuntu7.1 amd64 X.Org X server -- output driver metapackage
    ii xserver-xorg-video-amdgpu 18.0.1-1 amd64 X.Org X server -- AMDGPU display driver
    ii xserver-xorg-video-ati 1:18.0.1-1 amd64 X.Org X server -- AMD/ATI display driver wrapper
    ii xserver-xorg-video-fbdev 1:0.4.4-1build6 amd64 X.Org X server -- fbdev display driver
    ii xserver-xorg-video-intel 2:2.99.917+git20171229-1 amd64 X.Org X server -- Intel i8xx, i9xx display driver
    ii xserver-xorg-video-nouveau 1:1.0.15-2 amd64 X.Org X server -- Nouveau display driver
    ii xserver-xorg-video-qxl 0.1.5-2build1 amd64 X.Org X server -- QXL display driver
    ii xserver-xorg-video-radeon 1:18.0.1-1 amd64 X.Org X server -- AMD/ATI Radeon display driver
    ii xserver-xorg-video-vesa 1:2.3.4-1build3 amd64 X.Org X server -- VESA display driver
    ii xserver-xorg-video-vmware 1:13.2.1-1build1 amd64 X.Org X server -- VMware display driver
    aya@aya-NC4AS13:~$ dpkg -l | grep libva
    ii libva-drm2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- DRM runtime
    ii libva-wayland2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- Wayland runtime
    ii libva-x11-2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- X11 runtime
    ii libva2:amd64 2.1.0-3 amd64 Video Acceleration (VA) API for Linux -- runtime
    ii libvamp-hostsdk3v5:amd64 2.7.1~repack0-1 amd64 helper library for Vamp hosts written in C++
    ii libvariable-magic-perl 0.62-1 amd64 module to associate user-defined magic to variables from Perl
    aya@aya-NC4AS13:~$ dpkg -l | grep vdpau
    ii libvdpau1:amd64 1.1.1-3ubuntu1 amd64 Video Decode and Presentation API for Unix (libraries)
    ii mesa-vdpau-drivers:amd64 18.0.5-0ubuntu0~18.04.1 amd64 Mesa VDPAU video acceleration drivers
    ii vdpau-driver-all:amd64 1.1.1-3ubuntu1 amd64 Video Decode and Presentation API for Unix (driver metapackage)
    ii vdpauinfo 1.0-3 amd64 Video Decode and Presentation API for Unix (vdpauinfo utility)
    aya@aya-NC4AS13:~$ glxinfo | grep OpenGL
    OpenGL vendor string: X.Org
    OpenGL renderer string: AMD SUMO (DRM 2.50.0 / 4.15.0-32-lowlatency, LLVM 6.0.0)
    OpenGL core profile version string: 3.3 (Core Profile) Mesa 18.0.5
    OpenGL core profile shading language version string: 3.30
    OpenGL core profile context flags: (none)
    OpenGL core profile profile mask: core profile
    OpenGL core profile extensions:
    OpenGL version string: 3.0 Mesa 18.0.5
    OpenGL shading language version string: 1.30
    OpenGL context flags: (none)
    OpenGL extensions:
    OpenGL ES profile version string: OpenGL ES 3.1 Mesa 18.0.5
    OpenGL ES profile shading language version string: OpenGL ES GLSL ES 3.10
    OpenGL ES profile extensions:
    aya@aya-NC4AS13:~$ vainfo
    libva info: VA-API version 1.1.0
    libva info: va_getDriverName() returns 0
    libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/r600_drv_video.so
    libva info: Found init function __vaDriverInit_1_1
    libva info: va_openDriver() returns 0
    vainfo: VA-API version: 1.1 (libva 2.1.0)
    vainfo: Driver version: mesa gallium vaapi
    vainfo: Supported profile and entrypoints
    VAProfileMPEG2Simple : VAEntrypointVLD
    VAProfileMPEG2Main : VAEntrypointVLD
    VAProfileVC1Simple : VAEntrypointVLD
    VAProfileVC1Main : VAEntrypointVLD
    VAProfileVC1Advanced : VAEntrypointVLD
    VAProfileH264ConstrainedBaseline: VAEntrypointVLD
    VAProfileH264Main : VAEntrypointVLD
    VAProfileH264High : VAEntrypointVLD
    VAProfileNone : VAEntrypointVideoProc
    aya@aya-NC4AS13:~$ vdpauinfo
    display: :0.0 screen: 0
    API version: 1
    Information string: G3DVL VDPAU Driver Shared Library version 1.0

    Video surface:

    name width height types
    -------------------------------------------
    420 16384 16384 NV12 YV12
    422 16384 16384 UYVY YUYV
    444 16384 16384 Y8U8V8A8 V8U8Y8A8

    Decoder capabilities:

    name level macbs width height
    ----------------------------------------------------
    MPEG1 --- not supported ---
    MPEG2_SIMPLE 3 9216 2048 1152
    MPEG2_MAIN 3 9216 2048 1152
    H264_BASELINE 41 9216 2048 1152
    H264_MAIN 41 9216 2048 1152
    H264_HIGH 41 9216 2048 1152
    VC1_SIMPLE 1 9216 2048 1152
    VC1_MAIN 2 9216 2048 1152
    VC1_ADVANCED 4 9216 2048 1152
    MPEG4_PART2_SP 3 9216 2048 1152
    MPEG4_PART2_ASP 5 9216 2048 1152
    DIVX4_QMOBILE --- not supported ---
    DIVX4_MOBILE --- not supported ---
    DIVX4_HOME_THEATER --- not supported ---
    DIVX4_HD_1080P --- not supported ---
    DIVX5_QMOBILE --- not supported ---
    DIVX5_MOBILE --- not supported ---
    DIVX5_HOME_THEATER --- not supported ---
    DIVX5_HD_1080P --- not supported ---
    H264_CONSTRAINED_BASELINE 0 9216 2048 1152
    H264_EXTENDED --- not supported ---
    H264_PROGRESSIVE_HIGH --- not supported ---
    H264_CONSTRAINED_HIGH --- not supported ---
    H264_HIGH_444_PREDICTIVE --- not supported ---
    HEVC_MAIN --- not supported ---
    HEVC_MAIN_10 --- not supported ---
    HEVC_MAIN_STILL --- not supported ---
    HEVC_MAIN_12 --- not supported ---
    HEVC_MAIN_444 --- not supported ---

    Output surface:

    name width height nat types
    ----------------------------------------------------
    B8G8R8A8 16384 16384 y NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 A4I4 I4A4 A8I8 I8A8
    R8G8B8A8 16384 16384 y NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 A4I4 I4A4 A8I8 I8A8
    R10G10B10A2 16384 16384 y NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 A4I4 I4A4 A8I8 I8A8
    B10G10R10A2 16384 16384 y NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 A4I4 I4A4 A8I8 I8A8

    Bitmap surface:

    name width height
    ------------------------------
    B8G8R8A8 16384 16384
    R8G8B8A8 16384 16384
    R10G10B10A2 16384 16384
    B10G10R10A2 16384 16384
    A8 16384 16384

    Video mixer:

    feature name sup
    ------------------------------------
    DEINTERLACE_TEMPORAL y
    DEINTERLACE_TEMPORAL_SPATIAL -
    INVERSE_TELECINE -
    NOISE_REDUCTION y
    SHARPNESS y
    LUMA_KEY y
    HIGH QUALITY SCALING - L1 y
    HIGH QUALITY SCALING - L2 -
    HIGH QUALITY SCALING - L3 -
    HIGH QUALITY SCALING - L4 -
    HIGH QUALITY SCALING - L5 -
    HIGH QUALITY SCALING - L6 -
    HIGH QUALITY SCALING - L7 -
    HIGH QUALITY SCALING - L8 -
    HIGH QUALITY SCALING - L9 -

    parameter name sup min max
    -----------------------------------------------------
    VIDEO_SURFACE_WIDTH y 48 2048
    VIDEO_SURFACE_HEIGHT y 48 1152
    CHROMA_TYPE y
    LAYERS y 0 4

    attribute name sup min max
    -----------------------------------------------------
    BACKGROUND_COLOR y
    CSC_MATRIX y
    NOISE_REDUCTION_LEVEL y 0.00 1.00
    SHARPNESS_LEVEL y -1.00 1.00
    LUMA_KEY_MIN_LUMA y
    LUMA_KEY_MAX_LUMA y


    aya@aya-NC4AS13:~$
    aya@aya-NC4AS13:~$ id
    uid=1000(aya) gid=1000(aya) groups=1000(aya),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),118(lpadmin),126(sambashare)
    aya@aya-NC4AS13:~$ ls -l /dev/dr
    dri/ drm_dp_aux0 drm_dp_aux1
    aya@aya-NC4AS13:~$ ls -l /dev/dri/
    total 0
    drwxr-xr-x 2 root root 80 8 月 20 07:34 by-path
    crw-rw----+ 1 root video 226, 0 8 月 20 07:34 card0
    crw-rw----+ 1 root video 226, 128 8 月 20 07:34 renderD128
    ```

    radeontop 楼下接
    xxgirl2
        5
    xxgirl2  
    OP
       2018-08-22 18:01:41 +08:00
    @iwtbauh radeontop 结果:
    首先 CPU 是双核。
    本地用 mplayer 播放 h.264 视频,1.2kbps [email protected],CPU 占 20%,Graphic Pipe 占用 30%。
    本地用 mplayer 播放 h.264 视频,4.2kbps [email protected],CPU 占 60%,Graphic Pipe 占用 30%。
    B 站视频,6.0kbps 1080P@30fps,CPU 占 100%,Graphic Pipe 大于等于 55%。
    B 站视频,1.5kbps 720P@30fps,CPU 占 60%,Graphic Pipe 大于等于 55%。
    xxgirl2
        6
    xxgirl2  
    OP
       2018-08-22 18:21:08 +08:00
    @iwtbauh 相关 patch 的关键字是不是 va-api ?比如这个链接: https://ubuntuforums.org/showthread.php?t=2377851
    iwtbauh
        7
    iwtbauh  
       2018-08-22 20:33:23 +08:00   ❤️ 1
    @xxgirl2 #6

    https://chromium-review.googlesource.com/c/chromium/src/+/532294

    以及这个 ppa: https://launchpad.net/~saiarcot895/+archive/ubuntu/chromium-beta (本人没有用过此 ppa,无法保证 ppa 中的启用视频解码加速的预编译 chromium-browser 质量)
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5080 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:16 · PVG 09:16 · LAX 18:16 · JFK 21:16
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.