Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Vulkan support [APK included]#596

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
sfan5 wants to merge4 commits intomaster
base:master
Choose a base branch
Loading
fromsfan5/vk
Open

Vulkan support [APK included]#596

sfan5 wants to merge4 commits intomasterfromsfan5/vk

Conversation

@sfan5
Copy link
Member

@sfan5sfan5 commentedSep 6, 2022
edited
Loading

Opening this PR to keep track of the required changes to merge Vulkan support.

Checklist:

  • Figure out if we can avoid bumping the API minimum¹ (no)
  • Upstream fixes so that source patching is not needed anymore
  • Config UI to switch between opengl/vulkan
  • There should be a check whether vulkan works before users can enable it

¹ Raising the API to 24 would lose us 0.5% of our Google Play install base.

⬇️ APK Download ⬇️

🔨 Bugs?

If you want to report a problem make sure to include the logcat output, or your report will useless.

If the player does not launch at all make sure you havesupport for Vulkan 1.3 or newer on your device.

Note thatHW+ will not work with Vulkan enabled due to missing support for this in mpv and/or libplacebo.

satmandu, shahidanjan, sorrowSAD, and GrabbenD reacted with hooray emojiFarisR99, SeveredPinky, Edwin-Zarco, Jamie666123, Idesmi, and shahidanjan reacted with eyes emoji
@sfan5sfan5 added the feature labelSep 6, 2022
@sfan5sfan5 changed the titleVulkan supportVulkan support [APK included]Sep 7, 2022
@sfan5
Copy link
MemberAuthor

Added an APK for people wanting to test. It defaults to vo_gpu + Vulkan, vo_gpu_next is present too (both vk and gl) and you can switch by editing mpv.conf as usual.

@eko5624
Copy link

eko5624 commentedSep 8, 2022
edited
Loading

Added an APK for people wanting to test. It defaults to vo_gpu + Vulkan, vo_gpu_next is present too (both vk and gl) and you can switch by editing mpv.conf as usual.

Device: HuaWei Mate 20 pro
OS: harmonyOS 2.0

MPV crashed when open a file. My mpv.config as below:

vo=gpugpu-context=autogpu-api=vulkanhwdec=mediacodec-copy
AndrewKeYanzhe reacted with thumbs up emoji

@sfan5
Copy link
MemberAuthor

I can only diagnose issues withlogcat output.

@eko5624
Copy link

I can only diagnose issues withlogcat output.

mpv.log

@sfan5
Copy link
MemberAuthor

Looks like you're missing support for timeline semaphores which means your phone/GPU is not supported.

AndrewKeYanzhe reacted with thumbs up emoji

@eko5624
Copy link

Ok, thanks for your explaining.

@rohitghali
Copy link

Any updates on this? And, api is already bumped up right? Can strike off the first check box.

@sfan5
Copy link
MemberAuthor

I will revisit this sometime to work on the rest.
The purpose of the first box is to find out if we can get Vulkan working on newer devicesand keep the API level the same.

@xdilemite
Copy link

I'm looking forward to getting a new modern build once the vulkan issue is fixed. Here's an old debug build from the source with working vulkan.mpv_vukan.apk

@rohitghali
Copy link

I'm looking forward to getting a new modern build once the vulkan issue is fixed. Here's an old debug build from the source with working vulkan.mpv_vukan.apk

How old is this?

@xdilemite
Copy link

I'm looking forward to getting a new modern build once the vulkan issue is fixed. Here's an old debug build from the source with working vulkan.mpv_vukan.apk

How old is this?

2019 but vulkan works.

@sfan5
Copy link
MemberAuthor

Vulkan fails to initialize

No surprise,this project might be able to work around the requirement in the future but I haven't investigated that yet.

OpenGL ES seems to be completely broken

I can't see any settings being applied in the log but you probably forgot to setgpu-context=android

mpv-android-2023-01-14_2.apk work again

Again no surprise as this is a totally regular build.

@sfan5
Copy link
MemberAuthor

gpu-api=opengl &gpu-context=android works for me here.

@sommio
Copy link

sommio commentedApr 11, 2023
edited
Loading

Thankfully, it is more stable than master when I usevo=gpu-next &gpu-context=android &gpu-api=opengl in Kirin 810 + EMUI 12 (Android 10), although it doesn't work when I usevo=gpu-next &gpu-context=auto &gpu-api=vulkan

I can't even applyscale=lanzous anddeband=yes for master, I highly recommend usingvo=gpu-next &gpu-context=android &gpu-api=opengl in master by default

@hooke007hooke007 mentioned this pull requestApr 16, 2023
@syphyr
Copy link
Contributor

When building libplacebo, the build fails when the android toolchain tries to include <shaderc/shaderc.h>. This fixes the issue:syphyr@b8c7260

All of the other pkg-config files have a prefix of "/usr/local". The shaderc pkg-config was the only one with a prefix of "/usr". There must have been some conflict with the Android toolchain and the search path.

@syphyr
Copy link
Contributor

Even though vulkan does not seem to be supported on my older Android tablet, I also wanted to mention that vo=gpu-next seems to work better than vo=gpu.

@sommiosommio mentioned this pull requestMay 23, 2023
@syphyr
Copy link
Contributor

syphyr commentedMay 23, 2023
edited
Loading

There are actually two separate issues i encountered when building libplacebo.

The first issue is that $prefix_dir/lib does not get created for shaderc, so it fails copying libs.

The second issue is with the path inside the shaderc pkgconfig file mentioned previously.

Edit: my build machine does not have any local shaderc.h files, so maybe that is why I'm noticing this problem with the pkgconfig file.

@sfan5
Copy link
MemberAuthor

I tested this branch just yesterday and there were no issues with shaderc.
libplacebo did not want to build however as it requires Vulkan loader 1.3.0. With that patched up I found out that Vulkan doesn't work on my device as it requires 1.2.0 minimum.
Very few Android devices have that at all so I'm kind of doubting how much sense trying to support Vulkan makes.

@syphyr
Copy link
Contributor

I tested this branch just yesterday and there were no issues with shaderc. libplacebo did not want to build however as it requires Vulkan loader 1.3.0. With that patched up I found out that Vulkan doesn't work on my device as it requires 1.2.0 minimum. Very few Android devices have that at all so I'm kind of doubting how much sense trying to support Vulkan makes.

The issue i had with the include path for shaderc.h might be because of a difference with my build environment.

I also just started noticing that vo=gpu-next is causing random freezing in the video playback, but the audio keeps going.

@alakittty
Copy link

@sfan5 the shaderrc problem is there when building with the github actions build, but is fixed with syphrs patch, yesterday i forked mpv-android to do some dilly-dallying.

Btw how to build arm64v8a with gh actions?

@syphyr
Copy link
Contributor

Btw how to build arm64v8a with gh actions?

It looks like you need to add a line before this one to build arm64 variant.

./buildall.sh --arch arm64 mpv

./buildall.sh -n mpv|| {

@syphyr
Copy link
Contributor

syphyr commentedJun 1, 2023
edited
Loading

When building libplacebo separately, the build fails when shaderc attempts to copy libs to$prefix_dir. This fixes the issue:

syphyr@0825121

The Android NDK r25c contains shaderc v2022.1. The official Google shaderc repo has updated to v2023.5. This commit builds libplacebo with latest official google shaderc repo with updated 3rdparty libs. Also, using the google shaderc repo allows for including faster bugfixes and pinning versions.

syphyr@46f92aa

Edit: Updated links to include fixing copying shaderc header files. Whencopy -r was used, the shaderc header files were not getting copied into the correct subdirectory.

FarisR99 reacted with thumbs up emoji

@Doc-4
Copy link

Doc-4 commentedMar 25, 2025
edited
Loading

Happy to help if possible if it's within my ability to do. I'm willing to do just about anything other than wipe or root the phone. Backtrace with symbols means app compiled for debugging or something, yeah?

@Vladdrako
Copy link

Compiled mpv from@syphyr repo with Vulkan enabled. Device is Lenovo XiaoXin Pad 2022 SMD680 Adreno 610 with Mesa Turnip Driver 25.1, ZUI15 Android 13. Driver reports v1.3.311, but it is 1.4. Works, but with huge framedrops. Herelogs

@peerless2012
Copy link

Does this need hwdec_aimagereader.c in mpv support vulkan too? In the mapper function, it should map codec frame to vulkan texture?

@sfan5
Copy link
MemberAuthor

Zero-copy hwdec is not supported with Vulkan. It could be implemented viaVK_ANDROID_external_memory_android_hardware_buffer but that probably needs to happen inside libplacebo.

@peerless2012
Copy link

Why not in hwdec_aimagereader.c? It seems cuda support both gl and vulkan texture mapping.

@sfan5
Copy link
MemberAuthor

what do you mean? how does cuda get involved here?
hwdec_aimagereader contains an implementation that works on OpenGL only.

@peerless2012
Copy link

TBO, I am not familiar with this. I am developing hwdec on another platform, and when impl gl, i do just like android do. When I want to impl vulkan mode, I don't know how to do, the only thing is I find out cuda support both gl and vulkan, so I am asking if android and my new platform could do like cuda do or not.

sfan5 reacted with confused emoji

@master255
Copy link

I have tested three versions (standard one, and the two in the topic header) of MPV on a Hisense Vidda C2 Ultra Android 11 projector and all versions play the 4k Lindsey Stirling - I Wonder As I Wander.webm clip as a slide show. It uses VP9 and Opus codecs.
At the same time VLC player plays video very smoothly and with increased brightness. Maybe with HDR.

Waiting for new versions for testing.

@sfan5
Copy link
MemberAuthor

Log file?

@master255
Copy link

master255 commentedJul 20, 2025
edited
Loading

@sfan5 The projector has ADB logs turned off completely. SU is off. So I don't know where to get the logs.

You can send me 100500 versions to test. And I'll tell you which one works.

@sfan5
Copy link
MemberAuthor

That's unfortunate, but then there will be no fix. It's not possible to fix something that isn't known.

@master255
Copy link

@sfan5 On galaxy s22U phone the video does not slow down and shows exactly the same as VLC. But on the big screen of the projector slideshow.
The projector is Chinese and that's why logs are blocked there. But this projector is now the most popular TV solution for home.
It's up to you to decide - is your player only for phones or for big screens too?
I will test different versions of mpv. And will report back with results if there are any.

@sfan5
Copy link
MemberAuthor

It's up to you to decide - is your player only for phones or for big screens too?

mpv-android is targeted at exactly those devices and use cases that I can make work in my spare time and motivation,not a single bit more than that.
If you think you can argue me into spending time on this you are mistaken.

dexaltat and khazardstudent reacted with thumbs up emoji

@peerless2012
Copy link

what do you mean? how does cuda get involved here? hwdec_aimagereader contains an implementation that works on OpenGL only.

Do you know what i mean?

@Doc-4
Copy link

Nothing useful in there unfortunately. Only chance at debugging this would be a backtrace with symbols, which isn't trivial.

Coming back to this, probably don't spend any effort looking into this. It fixed itself sometime between when I last tested it and now, it must have been an upstream issue. (AOSP, GrapheneOS, maybe some library if one's used? I wouldn't know which.)

@Doc-4
Copy link

Doc-4 commentedAug 10, 2025
edited
Loading

So I'm back, you should be aware that HW+ decoding is broken for me on the latest VK build and branch built from source, but works fine on the latest non-vk stable release. I'm not sure if this is a bug or a consequence of how this branch works, some things I read implied it's the latter.

On a semi-related note, high bitrate HDR HEVC videos run way worse on this build than the older vulkan build or the latest stable master release (HDR tonemapped rather than native on the stable one).

More importantly, I spent several hours troubleshooting the build process on 3 distros, Ubuntu, Debian, and Fedora (all in WSL2), followed the instructions for building to the letter, and all of them fail without manual intervention for different reasons. I'd try to fix it myself but I don't understand the intended process well enough, so I've documented the issues I've found below:

The download.sh doesn't install jinja2 or jsonschema though it seems they're needed, and once things are mostly working, Ubuntu and Debian fail when checking things about the available vulkan versions. Debian failed checking something about vulkan for libplacebo's build, and Ubuntu later when it got to MPV, reporting that vulkan is out of date (I don't believe the versions in the NDK or deps are). I gave up on Debian at this point.

Fedora had issues downloading the dependencies, I had to follow the link to some of them and unpack them manually, then verified they were all present. The script on Fedora asks for latest openjdk devel regardless of 21.0.8 being present, and trying to use the version it wanted causes problems I was unable to resolve when getting to building mpv-android itself, such needing a flag to bypass something unnamed which I passed to java but the part immediately following mpv's build failed for another reason I didn't fully understand, it seemed related to a mismatch between gradle and something else.

Complete!
Error: missing Java Development Kit.
Install it using e.g. sudo yum install java-latest-openjdk-devel
~/mpv-android/buildscripts$ java --version
openjdk 21.0.8 2025-07-15
OpenJDK Runtime Environment (Red_Hat-21.0.8.0.9-1) (build 21.0.8+9)
OpenJDK 64-Bit Server VM (Red_Hat-21.0.8.0.9-1) (build 21.0.8+9, mixed mode, sharing)****

Something seems to be faulty about the version check on vulkan in debian based distros, I only got it to build on Ubuntu by first replacing the vulkan headers files downloaded with latest ones found elsewhere (I believe there are two sets present in the build here, one within the NDK and one within libplacebo), and modified the build script to skip that single check and got a successful, working build (can play video well and successfully utilize vulkan features like HDR.) I did not check the results of skipping the check without replacing the files. Absolutely nothing I did to the environment or files seemed to fix it detecting that version 1.3.0 was the only one available.

Please test the buildscript on a blank install of ubuntu (the one that was the least troublesome overall) and verify any issues for yourself.

@master255
Copy link

@sfan5 Good news. My new Vidda C3 Ultra projector shows ADB logs. I will send them soon.

@sfan5
Copy link
MemberAuthor

you should be aware that HW+ decoding is broken for me on the latest VK build and branch built from source, but works fine on the latest non-vk stable release.

HW+ has never worked for Vulkan.

The download.sh doesn't install jinja2 or jsonschema though it seems they're needed, and once things are mostly working, Ubuntu and Debian fail when checking things about the available vulkan versions. Debian failed checking something about vulkan for libplacebo's build, and Ubuntu later when it got to MPV, reporting that vulkan is out of date (I don't believe the versions in the NDK or deps are). I gave up on Debian at this point.

You can see that the CI indeed fails with an error (it works for me locally), but that doesn't match any of your descriptions:https://github.com/mpv-android/mpv-android/actions/runs/16883601860/job/47825477007?pr=596
Looks like some bug with pkg-config. Might investigate it later.

The script on Fedora asks for latest openjdk devel regardless of 21.0.8 being present

JRE and JDK are not the same. Make sure javac is available.

and trying to use the version it wanted causes problems I was unable to resolve when getting to building mpv-android itself,

Could be, I use Java 17 myself. The build instructions are best-effort and not tested to the letter regularly.

Doc-4 reacted with thumbs up emoji

@Doc-4
Copy link

Doc-4 commentedAug 11, 2025
edited
Loading

I'll try using 17 for future builds. The one recommended on Fedora was 24 (but I believe that particular package is updated to the latest as released), Ubuntu I think 21.

I'm sure I didn't mistake JRE for JDK on Fedora, though perhaps the openjdk version I installed was missing javac? I don't know if not all JDK packages are more or less equal with stuff like that.

Yeah, the CI error isn't one I ran into, shaderc never failed to build. It may be unrelated, but I see that it mentions armv7a. I only told it to build 64bit in my tests.

@sfan5
Copy link
MemberAuthor

It now builds successfully in CI as you can see. Compared to building the normal mpv-android nothing special should be needed (except python3 itself).

Doc-4 reacted with thumbs up emoji

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

2 more reviewers

@Jamie666123Jamie666123Jamie666123 approved these changes

@Gdakgdak22Gdakgdak22Gdakgdak22 approved these changes

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Labels

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

17 participants

@sfan5@eko5624@rohitghali@xdilemite@sommio@syphyr@alakittty@qq528@Jamie666123@obscenelyvague@kasper93@Doc-4@Vladdrako@peerless2012@master255@Gdakgdak22

[8]ページ先頭

©2009-2025 Movatter.jp