Bug 215839 - distorted video playback with hybrid GPU (DRI_PRIME=1, Radeon HD 6470M and Intel-GPU)
Summary: distorted video playback with hybrid GPU (DRI_PRIME=1, Radeon HD 6470M and In...
Status: RESOLVED ANSWERED
Alias: None
Product: Drivers
Classification: Unclassified
Component: Video(DRI - non Intel) (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: drivers_video-dri
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-04-15 16:20 UTC by kolAflash
Modified: 2022-04-16 09:39 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.15.28
Subsystem:
Regression: No
Bisected commit-id:


Attachments

Description kolAflash 2022-04-15 16:20:39 UTC
At least Kodi and VLC show garbage when being run with DRI_PRIME=1

I guess this is either a bug in the "radeon" kernel module or in Mesa3D / Gallium.



Hardware:
HP Notebook
Product: LR294EA#ABD
Model: Pavilion g6-1024sg
CPU + integrated graphics: Intel® Core™ i5 ("i915" driver)
Dedicated GPU: Radeon HD 6470M ("radeon" driver)
https://icecat.biz/de-at/p/hp/lr294ea/pavilion-notebooks-0886111633067-g6-1024sg-8025113.html

OS:
Tested Debian-11 (Linux-5.10.106)
manjaro-xfce-21.2.5-minimal-220314-linux515.iso (Linux-5.15.28)
(both running X)

$ cat /sys/kernel/debug/vgaswitcheroo/switch
0:DIS: :DynOff:0000:01:00.0
1:IGD:+:Pwr:0000:00:02.0

Console output (both VLC and Kodi):
radeon: The kernel rejected CS, see dmesg for more information (-22).

dmesg:
[ 2210.372308] radeon 0000:01:00.0: evergreen_surface_check_linear_aligned:214 texture pitch 1920 invalid must be aligned with 256
[ 2210.372320] radeon 0000:01:00.0: evergreen_cs_track_validate_texture:829 texture invalid 0x1dfc3bc1 0x10000437 0x0b200000 0x00000000 0x00000000 0x80020001
[ 2210.372327] [drm:radeon_cs_ioctl [radeon]] *ERROR* Invalid command stream !



I connected an external full HD (1920x1080) monitor and disabled the notebooks internal monitor via xrandr.
(especially in Kodi you may not be able to reproduce slow rendering without an 1920x1080 monitor)
(I want to use the notebook as media computer for my TV)

When running Kodi-19.4 or VLC-3.0.17.3 without specific settings, full HD (1920x1080 H264) videos don't render smoothly.
On Debian-11 additionally Firefox-ESR-91.8 also becomes slow (all CPU cores under heavy load) when playing full HD videos with JavaScript controls.
Try these:
https://www.ardmediathek.de/video/seehund-puma-und-co/fuenf-mann-ueber-bord-215/das-erste/Y3JpZDovL2Rhc2Vyc3RlLmRlL3NlZWh1bmQsIHB1bWEgJmFtcDsgY28uLzI1MDdkNTZlLWI0ZjYtNDAxNS1iYTI1LTE1N2FjOWNjZTE3NA
https://pdvideosdaserste-a.akamaihd.net/int/2021/06/10/6528b8d0-72d0-45b4-9e7c-29dce5bb796a/1920-1_917111.mp4
(caution: baby seals shown compete hard with baby kittens ;-))
In Kodi install the "ARDundZDF" add-on from repo.kodinerds.net and open:
ARDundZDF -> TV-Livestreams -> Überregional (second option) -> Das Erste -> 1920x1080



To solve this for Firefox I simply added "export DRI_PRIME=1" to ~/.profile
Now Firefox-ESR-91.8 on Debian-11 works fine!
But the issue wasn't fixed for Kodi and VLC. Instead they now show complete garbage :-(

For VLC I was able to nail down the problem:
When running VLC without specific settings, video output "OpenGL" and decoding via "VA-API" (without DRM) are being chosen.
So when running VLC with these settings and with DRI_PRIME=1 the output is distorted.

So for VLC the workaround is pretty easy:
Choose any other video decoder (VDPAU, "VA-API video decoder via DRM" or simply "Disable").
In this case the video will playback fine and smooth with and without setting DRI_PRIME=1.
Some other video output methods like "XVideo output (XCB)" also solve the problem while keeping VA-API as video decoder. Actually I also reported a bug to VLC about the questionable default settings:
https://code.videolan.org/videolan/vlc/-/issues/26831

Until now I found no solution for Kodi!



= Notes =

ffplay renders smoothly without further settings. (with and without DRI_PRIME=1)

Maybe related:
https://bugzilla.kernel.org/show_bug.cgi?id=89331
Comment 1 Alex Deucher 2022-04-15 16:30:57 UTC
This is a mesa bug.  I'd suggest filing a bug here: https://gitlab.freedesktop.org/groups/mesa/-/issues
There is either a memory alignment bug in the r600 mesa driver or the intel mesa driver is not allocating memory with the proper alignment requirements for the radeon hardware so when the radeon driver tries to use the buffer the commands get rejected causing the image distortions.
Comment 2 kolAflash 2022-04-15 17:02:54 UTC
Thanks for your assessment Alex!

Here is the Mesa bug:
https://gitlab.freedesktop.org/mesa/mesa/-/issues/6326
I can only set the status of this kernel.org bug to "resolved". But I guess it should be "invalid" or something else!?

I also found a workaround for Kodi:
Settings -> Player
Set UI mode to >= Advanced
Under "Videos" disable
  "Allow hardware acceleration - VAAPI"
Then Kodi will work fine with DRI_PRIME=1
Interestingly even without DRI_PRIME=1 full HD videos now play smooth too.
(maybe Kodi should leave VAAPI disabled by default...)

Note You need to log in before you can comment on or make changes to this bug.