iGPU won't decode video

So I have been unable to get hardware acceleration on my iGPU correctly, I have a dedicated Nvidia card which I can confirm works, but when I try to run video on my iGPU, it can’t display framerates above 30 without extreme stutter. I tried manually setting up my xorg.conf file without any luck, after doing so, I either get xorg crashes or boot into my Nvidia card. I also tried declaring which drivers to use as environment variables, specifically following what is said on Hardware video acceleration - ArchWiki and configuring driver names. I have all relevant drivers installed and have tried both declaring and removing VDPAU_DRIVER variables. VAAPI is listed as working but web browsers seem to default to VDPAU.

inxi -G output with GPU active

Graphics:  Device-1: Intel UHD Graphics driver: i915 v: kernel 
           Device-2: NVIDIA TU117M [GeForce GTX 1650 Ti Mobile] driver: nvidia v: 455.38 
           Device-3: Quanta HP True Vision HD Camera type: USB driver: uvcvideo 
           Display: x11 server: X.Org 1.20.9 driver: intel,nvidia resolution: 3840x2160~60Hz 
           OpenGL: renderer: GeForce GTX 1650 Ti with Max-Q Design/PCIe/SSE2 v: 4.6.0 NVIDIA 455.38

and if I have the iGPU running, xrandr --listproviders gives

Providers: number : 2
Provider 0: id: 0x1b8 cap: 0x1, Source Output crtcs: 4 outputs: 5 associated providers: 1 name:NVIDIA-0
Provider 1: id: 0x1e9 cap: 0xb, Source Output, Sink Output, Sink Offload crtcs: 4 outputs: 4 associated providers: 1 name:Intel

and if on iGPU

When I try to use xrandr --setprovideroffloadsink 1 0 I get

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  140 (RANDR)
  Minor opcode of failed request:  34 (RRSetProviderOffloadSink)
  Value in failed request:  0x1e9
  Serial number of failed request:  16
  Current serial number in output stream:  17

Regardless if I’m on my Nvidia or Intel already.
Using this command doesn’t seem to change anything

xrandr --setprovideroutputsource Intel NVIDIA-0

And if I run it on the iGPU and swap the outputsources I get

X Error of failed request:  BadValue (integer parameter out of range for operation)
  Major opcode of failed request:  140 (RANDR)
  Minor opcode of failed request:  35 (RRSetProviderOutputSource)
  Value in failed request:  0x257
  Serial number of failed request:  16
  Current serial number in output stream:  17

If I’m booted into the Nvidia card, vdpau info gives

display: :0   screen: 0
API version: 1
Information string: NVIDIA VDPAU Driver Shared Library  455.38  Thu Oct 22 05:57:08 UTC 2020
Video surface:
name   width height types
420     8192  8192  NV12 YV12 
422     8192  8192  UYVY YUYV 
444     8192  8192  NV24 YV24 
420_16  8192  8192  P010 P016 
422_16  8192  8192  UYVY YUYV 
444_16  8192  8192  Y_U_V_444_16 
Decoder capabilities:
name                        level macbs width height
MPEG1                           0 65536  4096  4096
MPEG2_SIMPLE                    3 65536  4096  4096
MPEG2_MAIN                      3 65536  4096  4096
H264_BASELINE                  51 65536  4096  4096
H264_MAIN                      51 65536  4096  4096
H264_HIGH                      51 65536  4096  4096
VC1_SIMPLE                      1  8190  2048  2048
VC1_MAIN                        2  8190  2048  2048
VC1_ADVANCED                    4  8190  2048  2048
MPEG4_PART2_SP                  3  8192  2048  2048
MPEG4_PART2_ASP                 5  8192  2048  2048
DIVX4_QMOBILE                   0  8192  2048  2048
DIVX4_MOBILE                    0  8192  2048  2048
DIVX4_HOME_THEATER              0  8192  2048  2048
DIVX4_HD_1080P                  0  8192  2048  2048
DIVX5_QMOBILE                   0  8192  2048  2048
DIVX5_MOBILE                    0  8192  2048  2048
DIVX5_HOME_THEATER              0  8192  2048  2048
DIVX5_HD_1080P                  0  8192  2048  2048
H264_CONSTRAINED_BASELINE      51 65536  4096  4096
H264_EXTENDED                  51 65536  4096  4096
H264_PROGRESSIVE_HIGH          51 65536  4096  4096
H264_CONSTRAINED_HIGH          51 65536  4096  4096
H264_HIGH_444_PREDICTIVE       51 65536  4096  4096
VP9_PROFILE_0                   1 262144  8192  8192
VP9_PROFILE_1                  --- not supported ---
VP9_PROFILE_2                   1 262144  8192  8192
VP9_PROFILE_3                  --- not supported ---
HEVC_MAIN                      153 262144  8192  8192
HEVC_MAIN_10                   153 262144  8192  8192
HEVC_MAIN_STILL                --- not supported ---
HEVC_MAIN_12                   153 262144  8192  8192
HEVC_MAIN_444                  153 262144  8192  8192
HEVC_MAIN_444_10               153 262144  8192  8192
HEVC_MAIN_444_12               153 262144  8192  8192

and if I am on GPU and run it through prime, I get the same output. If I switch GPU to Intel and run it, I get

display: :0   screen: 0
API version: 1
Information string: OpenGL/VAAPI backend for VDPAU
Video surface:
name   width height types
420     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
422     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
444     4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
420_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
422_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
444_16  4096  4096  NV12 YV12 UYVY YUYV Y8U8V8A8 V8U8Y8A8 NV24 YV24 P010 P016 Y_U_V_444_16 
Decoder capabilities:
name                        level macbs width height
MPEG1                          --- not supported ---
MPEG2_SIMPLE                   --- not supported ---
MPEG2_MAIN                     --- not supported ---
H264_BASELINE                  51 16384  2048  2048
H264_MAIN                      51 16384  2048  2048
H264_HIGH                      51 16384  2048  2048
VC1_SIMPLE                     --- not supported ---
VC1_MAIN                       --- not supported ---
VC1_ADVANCED                   --- not supported ---
MPEG4_PART2_SP                 --- not supported ---
MPEG4_PART2_ASP                --- not supported ---
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      51 16384  2048  2048
H264_EXTENDED                  --- not supported ---
H264_PROGRESSIVE_HIGH          --- not supported ---
H264_CONSTRAINED_HIGH          --- not supported ---
H264_HIGH_444_PREDICTIVE       --- not supported ---
VP9_PROFILE_0                  --- not supported ---
VP9_PROFILE_1                  --- not supported ---
VP9_PROFILE_2                  --- not supported ---
VP9_PROFILE_3                  --- 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 ---
HEVC_MAIN_444_10               --- not supported ---
HEVC_MAIN_444_12               --- not supported ---
Segmentation fault (core dumped)

My xorg.conf

Section "ServerLayout"
	Identifier "layout"
	Screen 0 "iGPU"
	Option "AllowNVIDIAGPUScreens"
EndSection

Section "Device"
	Identifier "nvidia"
    Driver "nvidia"
	BusID "PCI:1:0:0"
    Option "AllowEmptyInitialConfiguration"
EndSection

Section "Screen"
	Identifier "nvidia"
	Device "nvidia"
EndSection

Section "Device"
	Identifier "iGPU"
	Driver "intel"
	BusID "PCI:0:2:0"
EndSection

Section "Screen"
	Identifier "iGPU"
	Device "iGPU"
	Option "DRI" "3"
EndSection

I’m skipping some of the output since you can see the main thing there, but whatever I do, I can’t get Youtube or other streaming services to play smoothly unless I’m using my dedicated GPU but I don’t want it running constantly and killing battery. Any idea what I’m doing wrong here?

Edit: Found that after running xrandr --setprovideroutputsource 1 0 while on iGPU will cause it to render with the Nvidia card for some applications (like glmark2), but it won’t decode video or render my web browser. glmark2 lists the wrong card running too but only when booted with iGPU (ie intel says it’s nvidia, nvidia says its intel). If I run xrandr --setprovideroutputsource 0 1 I get a similar error to running --setprovideroffloadsink

Perhaps this helps you out.

It doesn’t seem to. It’s possible I don’t understand how the system determines which GPU to use but it seems to be I either run on the nvidia card primarily and drain power or I run on the intel card and get poor video performance due to a driver issue that seems to be related to GPU switching. As a side note, optimus-manager doesn’t work for me either, even if I remove all my xorg.conf files