Repository navigation
Android: custom Vulkan driver packages (Turnip) on Adreno - #19955
Open
Davey-Hughes wants to merge 3 commits into
Open
Davey-Hughes wants to merge 3 commits into
Davey-Hughes wants to merge 3 commits into
Conversation
The files of bylaws/libadrenotools 8fae8ce and its linkernsbypass submodule that load a custom Vulkan driver into its own linker namespace on Android, unmodified, with their licenses. README.md names the commits, the files and what was left out. Nothing builds them yet.
Sideloaded arm64 builds can load a Vulkan driver package (a zip with meta.json and one .so, such as Mesa's Turnip) on Adreno GPUs with Android 9 or later, through libadrenotools. The new video_vulkan_driver_path setting names the zip; empty is the system driver, and core, content-directory and game overrides carry it. The package is checked and extracted to internal storage once per version. Packages from any vendor are accepted. Only Mesa ones have been tested, so any other vendor logs that it is untested and that its load cannot be confirmed. A Mesa package that leaves the stock Qualcomm driver running, as the loader does when the custom library fails to load, counts as failed. When the custom driver fails to create an instance, a device or the first swapchain, the context is redone on the system driver in the same process. A driver that takes the process down during its init is turned off for that core until it is picked again, and a "Safe start" launcher shortcut starts RetroArch once on the system driver. Play Store, Quest and API 16 builds do not carry any of it. Co-authored-by: lim2222 <johnlky222@gmail.com>
Settings > Video > Output gains a Custom Vulkan Driver row on builds and devices that can load one. OK opens a browser for driver zips in <system>/vulkan_drivers, Start goes back to the system driver, and the sublabel says when the chosen driver crashed during its last start and is off for the running core. While RetroArch runs from the Safe start shortcut, the row reads "System (Safe start)" and the sublabel names the driver the next normal start uses. The choice applies at the next Vulkan start; picking a driver never restarts video. Co-authored-by: lim2222 <johnlky222@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Guidelines
C89_BUILD=1Description
Sideloaded arm64 Android builds can load a Vulkan driver package, such as Mesa's Turnip, on Adreno GPUs instead of the system driver. The main use is cores the stock driver renders badly. On an Adreno 740, for example, the stock driver draws stripe garbage for paraLLEl-RDP in Mupen64Plus-Next (SM64, OoT, MK64), and T30, a Turnip build, renders all three correctly.
Related feature requests: #15472, #18143.
Commits
video_vulkan_driver_path, that names a zip holdingmeta.jsonand one.so. An empty value means the system driver, and overrides carry it. The package is checked and extracted to internal storage once per version. This commit also adds the fallbacks, the crash state and the Safe start shortcut. The package logic is platform-free (gfx/common/vulkan_custom_driver.c), and a unit sample and a CI job cover it.<system>/vulkan_drivers, and Start goes back to the system driver. The sublabel says when the chosen driver crashed. A new choice takes effect at the next Vulkan start, and picking one never restarts video.No driver is bundled. Users download a package (for example a Turnip build, in the same zip format the AdrenoTools-based emulators load) and copy it to
<system>/vulkan_drivers/. If wanted, an online updater source can follow in a later PR.Gating
HAVE_ADRENOTOOLS. The API 16 build passesHAVE_ADRENOTOOLS=0..sofiles) from outside Play. That is why the Play builds already get cores through Play Feature Delivery. The Quest build is also a Play build (PLAY_STORE_BUILD=1). On Quest, the OpenXR runtime also does swapchain interop on RetroArch'sVkDevice, which nobody has tested with Turnip.Android.mksetsHAVE_ADRENOTOOLSonly when neitherPLAY_STORE_BUILDnorHAVE_OPENXRis set, and the Play and Quest APKs carry no adrenotools symbols./dev/kgsl-3d0) and Android 9 (API 28) or later. Elsewhere the row is hidden, and a synced-in value is ignored with an OSD message.libadrenotools.soloads only when a custom driver is first opened, so its linkernsbypass constructor, which remapsdlopen's code page, never runs for users who don't pick a driver.Fallbacks and crash state
meta.json,.socount, not arm64 ELF, over 64 MiB, missing)Each case shows an OSD message once per path per session. A crash after the first swapchain is not caught. For that, the user presses Start on the row or uses Safe start.
Safe start is a launcher shortcut (Android 7.1+), added before the first custom load. It starts RetroArch once on the system driver, restarting the process if needed, and leaves the saved value alone. Meanwhile the row reads "System (Safe start)".
Vendor policy (please weigh in)
Packages from any vendor load. Only Mesa Turnip was tested. The non-Mesa path was checked with a Turnip build relabelled
"vendor": "Qualcomm".How it works:
vendoris required inmeta.json. A package counts as Mesa when it says "Mesa" (any case).Why: Qualcomm driver repacks are widely used with other Android emulators, so refusing them outright would turn those users away. But a repack reports the same driverID as the stock driver. The Mesa check would mark every repack as failed, because the driverID can't tell a working repack from a silent fallback. We also considered comparing against the stock driver's version, saved from an earlier system-driver run. That needs a prior run and more saved state, and it misfires when a repack has the same version as the stock driver. So other vendors load unverified, and the log says so rather than claiming the custom driver is running.
Qualcomm repacks are proprietary blobs taken from other devices. If you'd rather not load them, Mesa-only is a small change to the package check.
Known issues
Testing
samples/gfx/vulkan_custom_driver: 315 checks covering the package checks,meta.json, the crash state and session limits. It passes on Linux under ASan+UBSan, and in a mingw-w64 build under wine. The newvulkan-custom-driverCI job runs it.C89_BUILD=1on touched objects and--disable-threadsboth pass. Local runs of the covering CI jobs fail only where master does.AYN Thor (Adreno 740, Android 13), with T30 and "Mesa Turnip driver v26.0.0 - R8". The comparison, the bad packages, pruning and Safe start through its intent extra were rerun on this branch's final commits. The switching, closing-content and Safe start UI checks ran on the build before the final review fixes.
.so(no GPU);"vendor": "Qualcomm"loads and runs, logging both warnings once per init.Credit
Built from lim2222's proof of concept, https://github.com/lim2222/RetroArch-Turnip (branch
feature/android-turnip-driver). lim2222 is co-author of commits 2 and 3.Related Issues
[Any issues this pull request may be addressing]
Related Pull Requests
[Any other PRs from related repositories that might be needed for this pull request to work]
Reviewers
[If possible @mention all the people that should review your pull request]