Bug 109107

Summary: gallium/st/va: change va max_profiles when using Radeon VCN Hardware
Product: Mesa Reporter: zhoulei <mfk530>
Component: OtherAssignee: mesa-dev
Status: RESOLVED FIXED QA Contact: mesa-dev
Severity: normal    
Priority: medium    
Version: git   
Hardware: All   
OS: All   
See Also: https://bugs.freedesktop.org/show_bug.cgi?id=109648
Whiteboard:
i915 platform: i915 features:
Attachments: attachment-18775-0.html
attachment-9686-0.html

Description zhoulei 2018-12-20 01:11:34 UTC
Now va_profiles is assignd to PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH - PIPE_VIDEO_PROFILE_UNKNOWN,
but it supports more profiles when using AMD VCN hardware like RAVEN APU.

chromium-vaapi's hardware decoder is broken caused by profile number checking.
Comment 1 zhoulei 2018-12-21 01:19:33 UTC
More details:

In function VASupportedProfiles::GetSupportedVAProfiles,
https://github.com/chromium/chromium/blob/master/media/gpu/vaapi/vaapi_wrapper.cc#L571

const int max_profiles = vaMaxNumProfiles(va_display_);
vaMaxNumProfiles will return (PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH - PIPE_VIDEO_PROFILE_UNKNOWN) in mesa.

 int num_supported_profiles;
  VAStatus va_res = vaQueryConfigProfiles(va_display_, &supported_profiles[0],
                                          &num_supported_profiles);
  VA_SUCCESS_OR_RETURN(va_res, "vaQueryConfigProfiles failed", false);
  if (num_supported_profiles < 0 || num_supported_profiles > max_profiles) {
    LOG(ERROR) << "vaQueryConfigProfiles returned: " << num_supported_profiles;
    return false;
  }

(num_supported_profiles > max_profiles) is true when using RAVEN APU, so hardware decoder is failed.
Comment 2 Michael Eagle 2019-02-01 20:59:45 UTC
Created attachment 143273 [details]
attachment-18775-0.html

Hi,

I am not sure if this is related with regards to what is causing hardware
accelerated decoding on my Raven laptop not to work.

Fedora repos:
che-mesa, rpmfusion, fedora-rawhide-kernel-nodebug
Mesa-git installed is build from: sha 9279a28

chromium-vaapi package from rpmfusion repo, started with the following
command:
chromium-vaapi --enable-plugins --enable-extensions --enable-user-scripts
--enable-printing --enable-accelerated-video
--enable-native-gpu-memory-buffers --enable-accelerated-mjpeg-decode
-nable-gpu-rasterization --disable-gpu-driver-bug-workarounds --enable-sync
--flag-switches-begin --enable-accelerated-mjpeg-decode
--enable-accelerated-video --enable-zero-copy --ignore-gpu-blacklist
--enable-features=VizDisplayCompositor --flag-switches-end

----------------
chrome://gpu/

Native GpuMemoryBuffers: Hardware accelerated
Hardware Protected Video Decode: Hardware accelerated
Video Decode: Hardware accelerated
WebGL: Hardware accelerated
WebGL2: Hardware accelerated
-------------

chrome://media-internals/

video_codec_name vp9
video_dds         false
video_decoder VpxVideoDecoder

so, as the VpxVideoDecoder, it means the gpu hardware acceleration is not
working.
------------
Log:
[18642:18642:0201/223152.683850:ERROR:vaapi_wrapper.cc(568)] :
vaQueryConfigProfiles returned: 14
[18642:18642:0201/223152.683943:ERROR:vaapi_wrapper.cc(568)] :
vaQueryConfigProfiles returned: 14
[18642:18642:0201/223152.771320:ERROR:sandbox_linux.cc(364)] :
InitializeSandbox() called with multiple threads in process gpu-process.
[18642:18642:0201/224233.934476:ERROR:buffer_manager.cc(491)] :
[GroupMarkerNotSet(crbug.com/242999)!:C0B874BB39390000]GL ERROR
:GL_INVALID_OPERATION : glBufferData: <- error from previous GL command

Specs:
I am using HP 15-cp0001na laptop with Ryzen 2700u:

inxi -G
Graphics:  Device-1: AMD Raven Ridge [Radeon Vega Series / Radeon Vega
Mobile Series] driver: amdgpu v: kernel
Display: x11 server: Fedora Project X.org 1.20.3 driver: amdgpu tty: N/A
OpenGL: renderer: AMD RAVEN (DRM 3.27.0 5.0.0-0.rc4.git0.1.fc30.x86_64 LLVM
9.0.0) v: 4.5 Mesa 19.1.0-devel
------
dmesg
[    3.119158] amdgpu 0000:04:00.0: ring vcn_dec uses VM inv eng 1 on hub 1
[    3.119166] amdgpu 0000:04:00.0: ring vcn_enc0 uses VM inv eng 4 on hub 1
[    3.119170] amdgpu 0000:04:00.0: ring vcn_enc1 uses VM inv eng 5 on hub 1
[    3.119173] amdgpu 0000:04:00.0: ring vcn_jpeg uses VM inv eng 6 on hub 1

vainfo
----
libva info: VA-API version 1.3.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
libva info: Found init function __vaDriverInit_1_3
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.3 (libva 2.3.0)
vainfo: Driver version: Mesa Gallium driver 19.1.0-devel for AMD RAVEN (DRM
3.27.0, 5.0.0-0.rc4.git0.1.fc30.x86_64, LLVM 9.0.0)
vainfo: Supported profile and entrypoints
      VAProfileMPEG2Simple            : VAEntrypointVLD
      VAProfileMPEG2Main              : VAEntrypointVLD
      VAProfileVC1Simple              : VAEntrypointVLD
      VAProfileVC1Main                : VAEntrypointVLD
      VAProfileVC1Advanced            : VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointVLD
      VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
      VAProfileH264Main               : VAEntrypointVLD
      VAProfileH264Main               : VAEntrypointEncSlice
      VAProfileH264High               : VAEntrypointVLD
      VAProfileH264High               : VAEntrypointEncSlice
      VAProfileHEVCMain               : VAEntrypointVLD
      VAProfileHEVCMain               : VAEntrypointEncSlice
      VAProfileHEVCMain10             : VAEntrypointVLD
      VAProfileJPEGBaseline           : VAEntrypointVLD
      VAProfileVP9Profile0            : VAEntrypointVLD
      VAProfileVP9Profile2            : VAEntrypointVLD
      VAProfileNone                   : VAEntrypointVideoProc

Possibly related:
https://sea-region.github.com/saiarcot895/chromium-ubuntu-build/issues/39

Thanks in advance!



On Fri, Dec 21, 2018 at 3:19 AM <bugzilla-daemon@freedesktop.org> wrote:

> *Comment # 1 <https://bugs.freedesktop.org/show_bug.cgi?id=109107#c1> on
> bug 109107 <https://bugs.freedesktop.org/show_bug.cgi?id=109107> from
> zhoulei <mfk530@gmail.com> *
>
> More details:
>
> In function VASupportedProfiles::GetSupportedVAProfiles,https://github.com/chromium/chromium/blob/master/media/gpu/vaapi/vaapi_wrapper.cc#L571
>
> const int max_profiles = vaMaxNumProfiles(va_display_);
> vaMaxNumProfiles will return (PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH -
> PIPE_VIDEO_PROFILE_UNKNOWN) in mesa.
>
>  int num_supported_profiles;
>   VAStatus va_res = vaQueryConfigProfiles(va_display_, &supported_profiles[0],
>                                           &num_supported_profiles);
>   VA_SUCCESS_OR_RETURN(va_res, "vaQueryConfigProfiles failed", false);
>   if (num_supported_profiles < 0 || num_supported_profiles > max_profiles) {
>     LOG(ERROR) << "vaQueryConfigProfiles returned: " << num_supported_profiles;
>     return false;
>   }
>
> (num_supported_profiles > max_profiles) is true when using RAVEN APU, so
> hardware decoder is failed.
>
> ------------------------------
> You are receiving this mail because:
>
>    - You are the assignee for the bug.
>    - You are the QA Contact for the bug.
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev
>
Comment 3 zhoulei 2019-02-11 08:09:19 UTC
sorry for my late reply.

I have already fixed this problem using this ugly mesa patch below. But how to fix this problem in the end depends on the Mesa team.

--- a/src/gallium/state_trackers/va/context.c
+++ b/src/gallium/state_trackers/va/context.c
@@ -175,7 +175,7 @@ VA_DRIVER_INIT_FUNC(VADriverContextP ctx)
    ctx->version_minor = 1;
    *ctx->vtable = vtable;
    *ctx->vtable_vpp = vtable_vpp;
-   ctx->max_profiles = PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH - PIPE_VIDEO_PROFILE_UNKNOWN;
+   ctx->max_profiles = PIPE_VIDEO_PROFILE_VP9_PROFILE2 - PIPE_VIDEO_PROFILE_UNKNOWN;
    ctx->max_entrypoints = 2;
    ctx->max_attributes = 1;
    ctx->max_image_formats = VL_VA_MAX_IMAGE_FORMATS;
Comment 4 zhoulei 2019-02-11 08:21:34 UTC
(In reply to Michael Eagle from comment #2)
> Created attachment 143273 [details]
> attachment-18775-0.html
> 
> Hi,
> 
> I am not sure if this is related with regards to what is causing hardware
> accelerated decoding on my Raven laptop not to work.
> 
> Fedora repos:
> che-mesa, rpmfusion, fedora-rawhide-kernel-nodebug
> Mesa-git installed is build from: sha 9279a28
> 
> chromium-vaapi package from rpmfusion repo, started with the following
> command:
> chromium-vaapi --enable-plugins --enable-extensions --enable-user-scripts
> --enable-printing --enable-accelerated-video
> --enable-native-gpu-memory-buffers --enable-accelerated-mjpeg-decode
> -nable-gpu-rasterization --disable-gpu-driver-bug-workarounds --enable-sync
> --flag-switches-begin --enable-accelerated-mjpeg-decode
> --enable-accelerated-video --enable-zero-copy --ignore-gpu-blacklist
> --enable-features=VizDisplayCompositor --flag-switches-end
> 
> ----------------
> chrome://gpu/
> 
> Native GpuMemoryBuffers: Hardware accelerated
> Hardware Protected Video Decode: Hardware accelerated
> Video Decode: Hardware accelerated
> WebGL: Hardware accelerated
> WebGL2: Hardware accelerated
> -------------
> 
> chrome://media-internals/
> 
> video_codec_name vp9
> video_dds         false
> video_decoder VpxVideoDecoder
> 
> so, as the VpxVideoDecoder, it means the gpu hardware acceleration is not
> working.
> ------------
> Log:
> [18642:18642:0201/223152.683850:ERROR:vaapi_wrapper.cc(568)] :
> vaQueryConfigProfiles returned: 14
> [18642:18642:0201/223152.683943:ERROR:vaapi_wrapper.cc(568)] :
> vaQueryConfigProfiles returned: 14
> [18642:18642:0201/223152.771320:ERROR:sandbox_linux.cc(364)] :
> InitializeSandbox() called with multiple threads in process gpu-process.
> [18642:18642:0201/224233.934476:ERROR:buffer_manager.cc(491)] :
> [GroupMarkerNotSet(crbug.com/242999)!:C0B874BB39390000]GL ERROR
> :GL_INVALID_OPERATION : glBufferData: <- error from previous GL command
> 
> Specs:
> I am using HP 15-cp0001na laptop with Ryzen 2700u:
> 
> inxi -G
> Graphics:  Device-1: AMD Raven Ridge [Radeon Vega Series / Radeon Vega
> Mobile Series] driver: amdgpu v: kernel
> Display: x11 server: Fedora Project X.org 1.20.3 driver: amdgpu tty: N/A
> OpenGL: renderer: AMD RAVEN (DRM 3.27.0 5.0.0-0.rc4.git0.1.fc30.x86_64 LLVM
> 9.0.0) v: 4.5 Mesa 19.1.0-devel
> ------
> dmesg
> [    3.119158] amdgpu 0000:04:00.0: ring vcn_dec uses VM inv eng 1 on hub 1
> [    3.119166] amdgpu 0000:04:00.0: ring vcn_enc0 uses VM inv eng 4 on hub 1
> [    3.119170] amdgpu 0000:04:00.0: ring vcn_enc1 uses VM inv eng 5 on hub 1
> [    3.119173] amdgpu 0000:04:00.0: ring vcn_jpeg uses VM inv eng 6 on hub 1
> 
> vainfo
> ----
> libva info: VA-API version 1.3.0
> libva info: va_getDriverName() returns 0
> libva info: Trying to open /usr/lib64/dri/radeonsi_drv_video.so
> libva info: Found init function __vaDriverInit_1_3
> libva info: va_openDriver() returns 0
> vainfo: VA-API version: 1.3 (libva 2.3.0)
> vainfo: Driver version: Mesa Gallium driver 19.1.0-devel for AMD RAVEN (DRM
> 3.27.0, 5.0.0-0.rc4.git0.1.fc30.x86_64, LLVM 9.0.0)
> vainfo: Supported profile and entrypoints
>       VAProfileMPEG2Simple            : VAEntrypointVLD
>       VAProfileMPEG2Main              : VAEntrypointVLD
>       VAProfileVC1Simple              : VAEntrypointVLD
>       VAProfileVC1Main                : VAEntrypointVLD
>       VAProfileVC1Advanced            : VAEntrypointVLD
>       VAProfileH264ConstrainedBaseline: VAEntrypointVLD
>       VAProfileH264ConstrainedBaseline: VAEntrypointEncSlice
>       VAProfileH264Main               : VAEntrypointVLD
>       VAProfileH264Main               : VAEntrypointEncSlice
>       VAProfileH264High               : VAEntrypointVLD
>       VAProfileH264High               : VAEntrypointEncSlice
>       VAProfileHEVCMain               : VAEntrypointVLD
>       VAProfileHEVCMain               : VAEntrypointEncSlice
>       VAProfileHEVCMain10             : VAEntrypointVLD
>       VAProfileJPEGBaseline           : VAEntrypointVLD
>       VAProfileVP9Profile0            : VAEntrypointVLD
>       VAProfileVP9Profile2            : VAEntrypointVLD
>       VAProfileNone                   : VAEntrypointVideoProc
> 
> Possibly related:
> https://sea-region.github.com/saiarcot895/chromium-ubuntu-build/issues/39
> 
> Thanks in advance!
> 
> 
> 
> On Fri, Dec 21, 2018 at 3:19 AM <bugzilla-daemon@freedesktop.org> wrote:
> 
> > *Comment # 1 <https://bugs.freedesktop.org/show_bug.cgi?id=109107#c1> on
> > bug 109107 <https://bugs.freedesktop.org/show_bug.cgi?id=109107> from
> > zhoulei <mfk530@gmail.com> *
> >
> > More details:
> >
> > In function VASupportedProfiles::GetSupportedVAProfiles,https://github.com/chromium/chromium/blob/master/media/gpu/vaapi/vaapi_wrapper.cc#L571
> >
> > const int max_profiles = vaMaxNumProfiles(va_display_);
> > vaMaxNumProfiles will return (PIPE_VIDEO_PROFILE_MPEG4_AVC_HIGH -
> > PIPE_VIDEO_PROFILE_UNKNOWN) in mesa.
> >
> >  int num_supported_profiles;
> >   VAStatus va_res = vaQueryConfigProfiles(va_display_, &supported_profiles[0],
> >                                           &num_supported_profiles);
> >   VA_SUCCESS_OR_RETURN(va_res, "vaQueryConfigProfiles failed", false);
> >   if (num_supported_profiles < 0 || num_supported_profiles > max_profiles) {
> >     LOG(ERROR) << "vaQueryConfigProfiles returned: " << num_supported_profiles;
> >     return false;
> >   }
> >
> > (num_supported_profiles > max_profiles) is true when using RAVEN APU, so
> > hardware decoder is failed.
> >
> > ------------------------------
> > You are receiving this mail because:
> >
> >    - You are the assignee for the bug.
> >    - You are the QA Contact for the bug.
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/mesa-dev
> >

You can try this patch and recompile mesa. I am using Ryzen5 2400G and this works.
Comment 5 leoxsliu 2019-02-12 16:33:42 UTC
The fixe is in Mesa master branch, also includes fix for playing VP9 with Chromium. Please make sure run with "allow_rgb10_configs=false" for now.
Comment 6 Michael Eagle 2019-02-12 20:39:18 UTC
Created attachment 143367 [details]
attachment-9686-0.html

I can confirm that now chrome is no longer printing

ERROR:vaapi_wrapper.cc(568)] : vaQueryConfigProfiles returned: 14

in terminal, and chrome://media-internals/ reports:
video_decoder GpuVideoDecoder

So, GPU acceleration is working.

And, indeed, without allow_rgb10_configs=false , the video is messed up.

Thank you much for fixing this!

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.