termux-user-repository / tur

A place for all types of Termux packages.
Other
405 stars 78 forks source link

Do we need mesa-zink here? #926

Open twaik opened 4 months ago

twaik commented 4 months ago

Hello. Just a question: do we need mesa-zink package here? Main repo has mesa with zink enabled and there is freedreno icd with termux-x11 support. Do we need duplcating mesa-zink here?

licy183 commented 4 months ago

mesa 22.0.5 is the last version without kopper, and this makes it possible to run zink over Android's vulkan.

twaik commented 4 months ago

We have wsi-vulkan-layer so kopper should work.

twaik commented 4 months ago

Even if no we have a patch to use zink without kopper with old-fashion copying to shared memory fragment.

licy183 commented 4 months ago

We have wsi-vulkan-layer so kopper should work.

I don't think wsi-vulkan-layer could work on Termux with Android's Vulkan Loader.

For Android's Vulkan Loader, the layer will be searched in /data/local/debug/vulkan or android::GraphicsEnv::getLayerPaths().

https://android.googlesource.com/platform/frameworks/native/+/9ecd5a2566ba9b2aaec7678e26f80fd38706122e/vulkan/libvulkan/layers_extensions.cpp#479

void DiscoverLayers() {
    ATRACE_CALL();

    if (android::GraphicsEnv::getInstance().isDebuggable()) {
        DiscoverLayersInPathList(kSystemLayerLibraryDir);
    }
    if (!android::GraphicsEnv::getInstance().getLayerPaths().empty())
        DiscoverLayersInPathList(android::GraphicsEnv::getInstance().getLayerPaths());
}

android::GraphicsEnv::getLayerPaths() can be controlled by android::GraphicsEnv::setLayerPaths(), but the latter function is designed to be called from the Java side.

https://android.googlesource.com/platform/frameworks/native/+/9ecd5a2566ba9b2aaec7678e26f80fd38706122e/libs/graphicsenv/GraphicsEnv.cpp#653

void GraphicsEnv::setLayerPaths(NativeLoaderNamespace* appNamespace,
                                const std::string& layerPaths) {
    if (mLayerPaths.empty()) {
        mLayerPaths = layerPaths;
        mAppNamespace = appNamespace;
    } else {
        ALOGV("Vulkan layer search path already set, not clobbering with '%s' for namespace %p'",
              layerPaths.c_str(), appNamespace);
    }
}

NativeLoaderNamespace* GraphicsEnv::getAppNamespace() {
    return mAppNamespace;
}

const std::string& GraphicsEnv::getLayerPaths() {
    return mLayerPaths;
}

https://android.googlesource.com/platform/frameworks/base/+/92e7cc4cdb299b515fcde9640ed7ba928475a750/core/jni/android_os_GraphicsEnvironment.cpp#84

void setLayerPaths_native(JNIEnv* env, jobject clazz, jobject classLoader, jstring layerPaths) {
    android::NativeLoaderNamespace* appNamespace = android::FindNativeLoaderNamespaceByClassLoader(
        env, classLoader);
    ScopedUtfChars layerPathsChars(env, layerPaths);
    android::GraphicsEnv::getInstance().setLayerPaths(appNamespace, layerPathsChars.c_str());
}

/data/local/debug/vulkan may not be writable for users and setLayerPaths heavily depends on the Java side.

Even if no we have a patch to use zink without kopper with old-fashion copying to shared memory fragment.

I've tried it but it is much difficult now. Newer mesa requires lots of other extensions and it is a nightmare to revert every commit about using extension beyond the Android Loader.

hansm629 commented 4 months ago

@twaik After applying vulkan-wsi-layer to Xclipse 940 GPU of Exynos2400 I compared mesa 24.0.5 from the main repo and mesa-zink 22.0.5 from the tur repo.

In OpenGL4.6 & OpenGL ES3.2, mesa-zink 22.0.5 showed better performance and compatibility than mesa 24.0.5.