Bug 101254 - VDPAU videos don't start playing with r600 gallium driver
Summary: VDPAU videos don't start playing with r600 gallium driver
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/Gallium/r600 (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: Default DRI bug account
QA Contact: Default DRI bug account
Depends on:
Reported: 2017-05-31 15:54 UTC by joeri.exelmans
Modified: 2017-06-12 21:00 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:

mpv verbose output till the point where the application becomes unresponsive (11.51 KB, text/plain)
2017-05-31 15:54 UTC, joeri.exelmans
vdpauinfo (3.86 KB, text/plain)
2017-06-01 15:59 UTC, joeri.exelmans
latest mpv (from git) verbose output - same problem (12.63 KB, text/plain)
2017-06-01 18:05 UTC, joeri.exelmans
possible fix (936 bytes, patch)
2017-06-07 12:48 UTC, Marek Olšák
Details | Splinter Review

Description joeri.exelmans 2017-05-31 15:54:26 UTC
Created attachment 131606 [details]
mpv verbose output till the point where the application becomes unresponsive

Hardware: AMD Fusion E-450 (PALM)
Driver version (xf86-video-ati): 1:7.9.99+git1705240733.d80d01~gd~x

Playing a video in mpv with the '--hwdec=vdpau' option, the player window is created but the application becomes unresponsive and the video never starts. Similarly in Kodi, playing a video with VDPAU enabled causes Kodi to become unresponsive to user input and the video never starts.

Strangely, VLC can still play videos with VDPAU enabled.

I'm automatically getting the latest git updates through the Oibaf Ubuntu PPA. The problem first occurred somewhere in March or April, when VDPAU videos /sometimes/ wouldn't start or took a long time to start (as opposed to the current situation where videos no longer start at all) and going back to the much older Ubuntu 'stock' driver solves the problem.

I'm not sure if it's a bug in the xf86-video-ati driver or some other component. If someone can tell me which component is likely to cause the problem, I can track the git commit that started the problem.
Comment 1 Michel Dänzer 2017-06-01 03:19:50 UTC
Mesa or the kernel is more likely.
Comment 2 joeri.exelmans 2017-06-01 15:59:20 UTC
Created attachment 131645 [details]
Comment 3 joeri.exelmans 2017-06-01 16:40:49 UTC
Wasn't aware that Mesa offered both a VDPAU and a VAAPI driver.
mpv + VAAPI works fine, mpv + VDPAU is broken.
Comment 4 Andy Furniss 2017-06-01 17:17:29 UTC
mpv 0.14.0 (C) 2000-2015

Does it work with current mpv?
Comment 5 joeri.exelmans 2017-06-01 18:05:12 UTC
Created attachment 131648 [details]
latest mpv (from git) verbose output - same problem

Same problem with latest mpv from git. Video never starts.
Comment 6 Andy Furniss 2017-06-01 20:14:27 UTC
(In reply to joeri.exelmans from comment #5)
> Created attachment 131648 [details]
> latest mpv (from git) verbose output - same problem
> Same problem with latest mpv from git. Video never starts.

OK, that's me out of ideas. I can't reproduce this on my R9 285 card.

FWIW with current ffmpeg, vaapi is not a good workaround as it will eventually use all memory. Older ffmpeg won't.
Comment 7 joeri.exelmans 2017-06-06 15:43:40 UTC
I used this guide (https://pkg-xorg.alioth.debian.org/howto/build-mesa.html) to  build the mesa project with git version 84012262ea70435507d3b88ddbc0f621781ec275 (Mar 21 2017), and I can use VDPAU again in Kodi.

The configure command that I used:
./configure --enable-vdpau --enable-va --with-gallium-drivers=r600 --with-dri-drivers=radeon --enable-llvm --enable-dri3 --with-llvm-prefix=/usr/lib/llvm-4.0 --enable-gles1 --enable-gles2 --enable-glx-tls

The environment variables when running Kodi:
export LD_LIBRARY_PATH=lib
(lib being in the mesa git project dir)

So Kodi works, VLC already worked, but mpv is still broken. The movie starts playing (cause I can hear the audio), which is an improvement, but the player window is entirely blue + a lot of opengl errors in stdout. Maybe because old mesa + new mpv is a bad idea, or maybe I did something wrong building mesa.

I'll continue to search for the specific commit that broke VDPAU in Kodi.
Comment 8 H4nN1baL 2017-06-07 08:05:03 UTC
I have this same problem but in r600g since 2017-05-17, my report in mpv:

In my case, the issue only manifest using: 'mpv --vo=opengl --hwdec=vdpau'

I think this other issue is also related:
Comment 9 joeri.exelmans 2017-06-07 08:38:43 UTC
Interesting, probably a bug in the r600 gallium driver then. Mpv with --hwdec=vdpau-copy (instead of --hwdec=vdpau) seems to work for me as well. Maybe VLC also uses that method.

So far I've built Mesa git versions

84012262ea70435507d3b88ddbc0f621781ec275 (Tue Mar 21 23:15:05 2017 +0100)
566f2ed5716297ce60ca10c57aeddc406835c430 (Fri Apr 14 23:39:15 2017 +0200)
9db9b2e8cd0a0d250c6251a2fef17198616519e7 (Wed May 3 18:37:28 2017 +0200)

and they all work with Kodi and VDPAU.

The blue screen in mpv could be a bug in mpv 0.25 or Mesa still. My guess is mpv because never had that problem with mpv 0.14 from Ubuntu repository.
Comment 10 joeri.exelmans 2017-06-07 08:42:47 UTC
Edited summary, changed component Drivers/Gallium/radeonsi -> Drivers/Gallium/r600
Comment 11 H4nN1baL 2017-06-07 10:45:41 UTC
 I use mpv 0.25.0-9-g18703b55d until an update of padoka PPA broke vdpau. After that I have been recompiling ffmpeg and mpv regularly to see if any updates fix the issue, but so far all the results have been unfruitful.
 I even did some downgrades to mpv, but I also did not succeed.

 The only thing that I not tried is to use an older version of ffmpeg compiled with the old vdpau API (--enable-gpl --enable-version3) with an mpv version prior to this: https://github.com/mpv-player/mpv/commit/f59371de2170141fc28540d03c4e7ecc62844ebf
Comment 12 joeri.exelmans 2017-06-07 11:42:01 UTC
Okay, I found the (series of) commits that break VDPAU in Kodi and mpv.

They were added to the master branch on 2017-05-15 11:01:33 (GMT), all authored by Marek Olšák <marek.olsak@amd.com>.

This is the last commit that works:

Summary: gallium/radeon: require both WRITE and FLUSH_EXPLICIT in buffer_flush_region

Next there are a number of commits, all by Marek Olšák that won't compile because an include is missing:

Summary: gallium/radeon: unwrap a context if we get a wrapped one

Summary: gallium/radeon: handle TC_TRANSFER_MAP_THREADED_UNSYNC

Summary: gallium/radeon: handle other map buffer flags from the threaded context

The next commit fixes the missing include and hence compiles, but has the bug that this thread is about:

Summary: gallium/radeon: subclass threaded_resource
Comment 13 Marek Olšák 2017-06-07 12:48:56 UTC
Created attachment 131771 [details] [review]
possible fix

Can you try this patch?
Comment 14 joeri.exelmans 2017-06-07 13:49:04 UTC
With the patch, VDPAU works again.

Is it a fix or does it simply disable a feature?
Comment 15 Marek Olšák 2017-06-07 20:08:40 UTC
It's the real fix.
Comment 16 joeri.exelmans 2017-06-07 21:08:30 UTC

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.