Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

qsv: fix Arc on Linux #4958

Merged
merged 3 commits into from Feb 26, 2023
Merged

qsv: fix Arc on Linux #4958

merged 3 commits into from Feb 26, 2023

Conversation

galinart
Copy link
Contributor

@galinart galinart commented Feb 22, 2023

Should help to fix #4775

Requires the following configuration:

  1. Add user to the render group
    https://dgpu-docs.intel.com/installation-guides/ubuntu/ubuntu-jammy-arc.html#step-5-configuring-permissions

  2. Updated 6.2-rc* or 6.2 kernel from https://kernel.ubuntu.com/~kernel-ppa/mainline/

cd /tmp
 
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.2-rc6/amd64/linux-headers-6.2.0-060200rc6_6.2.0-060200rc6.202301292330_all.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.2-rc6/amd64/linux-headers-6.2.0-060200rc6-generic_6.2.0-060200rc6.202301292330_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.2-rc6/amd64/linux-image-unsigned-6.2.0-060200rc6-generic_6.2.0-060200rc6.202301292330_amd64.deb
wget -c https://kernel.ubuntu.com/~kernel-ppa/mainline/v6.2-rc6/amd64/linux-modules-6.2.0-060200rc6-generic_6.2.0-060200rc6.202301292330_amd64.deb
 
# Install latest mainline kernel
sudo dpkg -i *.deb
 
# Reboot system after latest mainline kernel upgrade
sudo reboot
  1. Update the latest Mesa drivers and other packages
sudo -E add-apt-repository ppa:oibaf/graphics-drivers -y
 
# Update packages list
sudo apt-get update
# Upgrade packages
sudo apt-get upgrade
# Reboot the system if needed
sudo reboot
  1. Install latest FW for Arc
git clone https://github.com/intel-gpu/intel-gpu-firmware.git
cd intel-gpu-firmware
sudo mkdir -p /lib/firmware/updates/i915/
sudo cp firmware/*.bin /lib/firmware/updates/i915/
 
sudo update-initramfs -u -k all
sudo reboot
  1. Check that HuC is working correctly and FW loaded
sudo dmesg | grep HuC
[    4.187853] i915 0000:00:02.0: [drm] HuC firmware i915/tgl_huc.bin version 7.9.3
[    4.202323] i915 0000:00:02.0: [drm] HuC authenticated
[    4.340129] i915 0000:03:00.0: [drm] HuC firmware i915/dg2_huc_gsc.bin version 7.10.3
[    4.853691] i915 0000:03:00.0: [drm] HuC authenticated

sudo cat /sys/kernel/debug/dri/1/gt/uc/huc_info
HuC firmware: i915/dg2_huc_gsc.bin
        status: RUNNING
        version: found 7.10.3
        uCode: 0 bytes
        RSA: 0 bytes
HuC status: 0x00164001
  1. Install Flatpak Nightly packages https://github.com/HandBrake/handbrake-snapshots/releases/tag/lin

Tested on AlderLake + Arc graphics system:

intel@intel:~/artem/HandBrake-new/build$ flatpak run --command=HandBrakeCLI fr.handbrake.ghb -i ~/artem/bbb_sunflower_2160p_60fps_normal.mp4 --enable-qsv-decoding -e qsv_av1 -xgpu=1 -o output.mp4

[15:50:49] Compile-time hardening features are enabled
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /app/extensions/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0

[15:50:49] qsv: is available on this system
Cannot load libnvidia-encode.so.1
[15:50:49] hb_init: starting libhb thread
[15:50:49] thread 7f6bc67fc640 started ("libhb")
HandBrake 20230222120422-b4460a12e-fix-linux-2 (2023022201) - Linux x86_64 - https://handbrake.fr
24 CPUs detected
Opening /home/intel/artem/bbb_sunflower_2160p_60fps_normal.mp4...

[15:50:49] CPU: 12th Gen Intel(R) Core(TM) i9-12900
[15:50:49]  - Intel microarchitecture Alder Lake performance hybrid architecture
[15:50:49]  - logical processor count: 24
[15:50:49] Intel Quick Sync Video support: yes

[15:50:49] Intel Quick Sync Video integrated adapter with index 0 and renderD128
[15:50:49] Impl mfx-gen library path: /app/extensions/IntelMediaSDK/lib/libmfx-gen.so.1.2.8
[15:50:49]  - Intel Media SDK hardware: API 2.8 (minimum: 1.3)
[15:50:49]  - Decode support:  h264 hevc (8bit: yes, 10bit: yes) av1 (8bit: yes, 10bit: yes)
[15:50:49]  - H.264 encoder: yes
[15:50:49]     - preferred implementation: hardware (any) via ANY
[15:50:49]     - capabilities (hardware):  lowpower breftype vsinfo chromalocinfo opt1 opt2+mbbrc+extbrc+trellis+repeatpps+ib_adapt+nmpslice
[15:50:49]  - H.265 encoder: yes (8bit: yes, 10bit: yes)
[15:50:49]     - preferred implementation: hardware (any) via ANY
[15:50:49]     - capabilities (hardware):  lowpower bpyramid vsinfo masteringinfo cllinfo opt1
[15:50:49]  - AV1 encoder: no

[15:50:49] Intel Quick Sync Video discrete adapter with index 1 and renderD129
[15:50:49] Impl mfx-gen library path: /app/extensions/IntelMediaSDK/lib/libmfx-gen.so.1.2.8
[15:50:49]  - Intel Media SDK hardware: API 2.8 (minimum: 1.3)
[15:50:49]  - Decode support:  h264 hevc (8bit: yes, 10bit: yes) av1 (8bit: yes, 10bit: yes)
[15:50:49]  - H.264 encoder: yes
[15:50:49]     - preferred implementation: hardware (any) via ANY
[15:50:49]     - capabilities (hardware):  lowpower breftype icq vsinfo chromalocinfo opt1 opt2+mbbrc+extbrc+trellis+repeatpps+ib_adapt+nmpslice
[15:50:49]  - H.265 encoder: yes (8bit: yes, 10bit: yes)
[15:50:49]     - preferred implementation: hardware (any) via ANY
[15:50:49]     - capabilities (hardware):  lowpower bpyramid vsinfo masteringinfo cllinfo opt1
[15:50:49]  - AV1 encoder: yes (8bit: yes, 10bit: yes)
[15:50:49]     - preferred implementation: hardware (any) via ANY
[15:50:49]     - capabilities (hardware):  lowpower bpyramid vsinfo opt1 av1bitstream

[15:50:49] hb_scan: path=/home/intel/artem/bbb_sunflower_2160p_60fps_normal.mp4, title_index=1
udfread ERROR: ECMA 167 Volume Recognition failed
disc.c:333: failed opening UDF image /home/intel/artem/bbb_sunflower_2160p_60fps_normal.mp4
disc.c:437: error opening file BDMV/index.bdmv
disc.c:437: error opening file BDMV/BACKUP/index.bdmv
[15:50:49] bd: not a bd - trying as a stream/file instead
libdvdread: Encrypted DVD support unavailable.
libdvdread: DVDOpenFileUDF:UDFFindFile /VIDEO_TS/VIDEO_TS.IFO failed
libdvdread: Can't open file VIDEO_TS.IFO.
libdvdnav: vm: vm: failed to read VIDEO_TS.IFO
[15:50:49] dvd: not a dvd - trying as a stream/file instead
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/intel/artem/bbb_sunflower_2160p_60fps_normal.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2013-12-17T16:40:26.000000Z
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
    composer        : Sacha Goedegebure
  Duration: 00:10:34.53, start: 0.000000, bitrate: 8487 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 3840x2160 [SAR 1:1 DAR 16:9], 8002 kb/s, 60 fps, 60 tbr, 60k tbn (default)
    Metadata:
      creation_time   : 2013-12-17T16:40:26.000000Z
      handler_name    : GPAC ISO Video Handler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)
    Metadata:
      creation_time   : 2013-12-17T16:40:28.000000Z
      handler_name    : GPAC ISO Audio Handler
      vendor_id       : [0][0][0][0]
  Stream #0:2[0x3](und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)
    Metadata:
      creation_time   : 2013-12-17T16:40:28.000000Z
      handler_name    : GPAC ISO Audio Handler
      vendor_id       : [0][0][0][0]
    Side data:
      audio service type: main
[15:50:49] scan: decoding previews for title 1
[15:50:49] scan: audio 0x1: mp3float, rate=48000Hz, bitrate=160000 Unknown (MP3) (2.0 ch) (160 kbps)
[15:50:49] scan: audio 0x2: ac3, rate=48000Hz, bitrate=320000 Unknown (AC3) (5.1 ch) (320 kbps)
Scanning title 1 of 1, preview 8, 80.00 %[15:50:49] scan: 10 previews, 3840x2160, 60.000 fps, autocrop = 0/0/0/0, aspect 16:9, PAR 1:1, color profile: 1-1-1, chroma location: left
[15:50:49] scan: supported video decoders: avcodec qsv
[15:50:49] libhb: scan thread found 1 valid title(s)
+ Using preset: CLI Default
+ title 1:
  + stream: /home/intel/artem/bbb_sunflower_2160p_60fps_normal.mp4
  + duration: 00:10:34
  + size: 3840x2160, pixel aspect: 1/1, display aspect: 1.78, 60.000 fps
  + autocrop: 0/0/0/0
  + chapters:
    + 1: duration 00:10:34
  + audio tracks:
    + 1, Unknown (MP3) (2.0 ch) (160 kbps) (iso639-2: und)
    + 2, Unknown (AC3) (5.1 ch) (320 kbps) (iso639-2: und), 48000Hz, 320000bps
  + subtitle tracks:
[15:50:50] Starting work at: Wed Feb 22 15:50:50 2023

[15:50:50] 1 job(s) to process
[15:50:50] json job:
{
    "Audio": {
        "AudioList": [
            {
                "Bitrate": 128,
                "CompressionLevel": -1.0,
                "DRC": 0.0,
                "DitherMethod": "auto",
                "Encoder": "av_aac",
                "Gain": 0.0,
                "Mixdown": "stereo",
                "NormalizeMixLevel": false,
                "PresetEncoder": "av_aac",
                "Quality": -3.0,
                "Samplerate": 0,
                "Track": 0
            }
        ],
        "CopyMask": [
            "copy:aac",
            "copy:ac3",
            "copy:eac3",
            "copy:dtshd",
            "copy:dts",
            "copy:mp3",
            "copy:truehd",
            "copy:flac"
        ],
        "FallbackEncoder": "av_aac"
    },
    "Destination": {
        "AlignAVStart": false,
        "ChapterList": [
            {
                "Duration": {
                    "Hours": 0,
                    "Minutes": 10,
                    "Seconds": 34,
                    "Ticks": 57107999
                },
                "Name": ""
            }
        ],
        "ChapterMarkers": false,
        "File": "/dev/null",
        "InlineParameterSets": false,
        "Mp4Options": {
            "IpodAtom": false,
            "Mp4Optimize": false
        },
        "Mux": "m4v"
    },
    "Filters": {
        "FilterList": [
            {
                "ID": 7,
                "Settings": {
                    "mode": 0
                }
            },
            {
                "ID": 14,
                "Settings": {
                    "crop-bottom": 0,
                    "crop-left": 0,
                    "crop-right": 0,
                    "crop-top": 0,
                    "height": 2160,
                    "width": 3840
                }
            }
        ]
    },
    "Metadata": {
        "Artist": "Blender Foundation 2008, Janus Bager Kristensen 2013",
        "Comment": "Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net",
        "Composer": "Sacha Goedegebure",
        "Genre": "Animation",
        "Name": "Big Buck Bunny, Sunflower version"
    },
    "PAR": {
        "Den": 1,
        "Num": 1
    },
    "SequenceID": 0,
    "Source": {
        "Angle": 0,
        "Path": "/home/intel/artem/bbb_sunflower_2160p_60fps_normal.mp4",
        "Range": {
            "End": 1,
            "Start": 1,
            "Type": "chapter"
        },
        "Title": 1
    },
    "Subtitle": {
        "Search": {
            "Burn": true,
            "Default": false,
            "Enable": false,
            "Forced": false
        },
        "SubtitleList": []
    },
    "Video": {
        "ChromaLocation": 1,
        "ColorInputFormat": 0,
        "ColorMatrix": 1,
        "ColorOutputFormat": 0,
        "ColorPrimaries": 1,
        "ColorRange": 0,
        "ColorTransfer": 1,
        "Encoder": "qsv_av1",
        "HardwareDecode": 0,
        "Options": "gpu=1",
        "QSV": {
            "AdapterIndex": 1,
            "AsyncDepth": 0,
            "Decode": true
        },
        "Quality": 22.0,
        "Turbo": false,
        "TwoPass": false
    }
}

[15:50:50] qsv: discrete qsv adapter with index 1 has been selected
[15:50:50] Starting Task: Encoding Pass
[15:50:50] Skipping vfr filter
[15:50:50] Skipping crop/scale filter
[15:50:50] job configuration:
[15:50:50]  * source
[15:50:50]    + /home/intel/artem/bbb_sunflower_2160p_60fps_normal.mp4
[15:50:50]    + title 1, chapter(s) 1 to 1
[15:50:50]    + container: mov,mp4,m4a,3gp,3g2,mj2
[15:50:50]    + data rate: 8487 kbps
[15:50:50]  * destination
[15:50:50]    + /dev/null
[15:50:50]    + container: MPEG-4 (libavformat)
[15:50:50]  * video track
[15:50:50]    + decoder: h264_qsv 8-bit (yuv420p)
[15:50:50]      + bitrate 8002 kbps
[15:50:50]    + filters
[15:50:50]      + Format (format=nv12)
[15:50:50]    + Output geometry
[15:50:50]      + storage dimensions: 3840 x 2160
[15:50:50]      + pixel aspect ratio: 1 : 1
[15:50:50]      + display dimensions: 3840 x 2160
[15:50:50]    + encoder: AV1 (Intel Media SDK)
[15:50:50]      + options: gpu=1
[15:50:50]      + quality: 22.00 (QP)
[15:50:50]      + color profile: 1-1-1
[15:50:50]      + chroma location: left
[15:50:50]  * audio track 1
[15:50:50]    + decoder: Unknown (MP3) (2.0 ch) (160 kbps) (track 1, id 0x1)
[15:50:50]      + bitrate: 160 kbps, samplerate: 48000 Hz
[15:50:50]    + mixdown: Stereo
[15:50:50]    + encoder: AAC (libavcodec)
[15:50:50]      + bitrate: 128 kbps, samplerate: 48000 Hz
[15:50:50] sync: expecting 38071 video frames
libva info: VA-API version 1.17.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /app/extensions/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0

[15:50:50] encqsvInit: using encode-only (LowPower) path
[15:50:50] encqsvInit: AV1 Main profile @ level 5.1
[15:50:50] encqsvInit: TargetUsage 4 AsyncDepth 6
[15:50:50] encqsvInit: GopRefDist 8 GopPicSize 64 NumRefFrame 4 IdrInterval 0
[15:50:50] encqsvInit: BFramesMax 7 BRefType pyramid
[15:50:50] encqsvInit: RateControlMethod CQP with QPI 22 QPP 24 QPB 26

libva info: VA-API version 1.17.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /app/extensions/lib/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_17
libva info: va_openDriver() returns 0
libva info: VA-API version 1.17.0

Encoding: task 1 of 1, 0.00 %[15:50:50] sync: first pts audio 0x1 is 0
[15:50:50] sync: first pts video is 3000
[15:50:50] sync: Chapter 1 at frame 1 time 3000
[15:50:50] qsv_enc_init: using 'hardware (2) via VAAPI' implementation, API: 2.8

NOTE: If you would like to run HandBrake out of Flatpak you need to build and install Intel Media Stack on your own https://github.com/oneapi-src/oneVPL-intel-gpu/releases

export LIBVA_DRIVERS_PATH=<path-contains-iHD_drv_video.so>
export LIBVA_DRIVER_NAME=iHD

# Ensure that linker find the correct libraries from the Intel Media Stack you built, not system ones
LD_LIBRARY_PATH=/opt/intel/mediasdk/lib/:/usr/lib/x86_64-linux-gnu/dri:/usr/lib/x86_64-linux-gnu/ ./HandBrakeCLI -i ~/bbb_sunflower_2160p_60fps_normal.mp4 --enable-qsv-decoding -e qsv_h265 -xgpu=1 -o out.mp4

@galinart galinart requested a review from sr55 February 22, 2023 14:57
@galinart galinart added this to the 1.6.2 milestone Feb 22, 2023
@galinart galinart added the Bug label Feb 22, 2023
@sr55 sr55 merged commit eea640f into HandBrake:master Feb 26, 2023
sr55 pushed a commit that referenced this pull request Mar 10, 2023
* qsv: fix Arc on Linux

* qsv: update Flatpak plugin

* qsv: fix memory leak of mfxLoader

(cherry picked from commit eea640f)
@galad87 galad87 modified the milestones: 1.6.2, 1.7.0 Sep 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

Successfully merging this pull request may close these issues.

Update Intel Media plugin to 22.6.4 for Arc GPUs
3 participants