zaps166 / QMPlay2

QMPlay2 is a video and audio player which can play most formats and codecs.
GNU Lesser General Public License v3.0
851 stars 176 forks source link

"Vulkan" not active despite all controllers installed (Ryzen + Radeon) #663

Closed RafaelLinux closed 11 months ago

RafaelLinux commented 11 months ago

I had installed AMD and Vulkans necessary libraries, but openSUSE repository installed QMPlay2 application show "Vulkan" as "Not active" (see issue for more info about installed libraries). AppImage version, however, does show "Vulkan" as "active".

All Vulkan for console applications works fine (vkgears vkcube vkcubepp vkcube-wayland vkmark vkbasalt) despite I'm using Wayland yet, so I don't know why QMP2 doesn't show it as active.

zaps166 commented 11 months ago

Could you find libvulkan.so.1 or libvulkan.so (you can use whereis command) and start with QT_VULKAN_LIB=/path/to/libvulkan.so.1 QMPlay2?

RafaelLinux commented 11 months ago

I needed to use "locate" instead "whereis" (maybe cause last one only search for executables) and among all "libvulkan.so", I choosed the /usr .... one:

cmd> QT_VULKAN_LIB=/usr/lib/libvulkan.so.1 QMPlay2
[19 oct 2023 20:25:56.360] Failed to load /usr/lib/libvulkan.so.1: No se puede cargar la biblioteca /usr/lib/libvulkan.so.1: (/usr/lib/libvulkan.so.1: clase ELF errónea: ELFCLASS32)
[19 oct 2023 20:25:56.374] initInstance: No Vulkan library available
[19 oct 2023 20:25:56.374] Failed to create platform Vulkan instance
[19 oct 2023 20:25:56.374] Vulkan is unable to work with QMPlay2 on this platform: Can't create Vulkan instance: ErrorInitializationFailed

However, if I try cmd> QT_VULKAN_LIB=/usr/lib64/libvulkan.so.1 QMPlay2 , no errors and Vulkan is autoenabled in QMP2!!! Why it doesn't load correctly that library? I know not all distros use same paths for libraries, but it's supposed to be found if application is compiled in same distro.

zaps166 commented 11 months ago

Why it doesn't load correctly that library? I know not all distros use same paths for libraries, but it's supposed to be found if application is compiled in same distro.

QMPlay2 uses Qt for this, so it looks like it's a Qt bug. do you have as well? If you don't have libvulkan.so openSUSE packager should patch Qt5 or just do a symlink: sudo ln -s /usr/lib64/libvulkan.so.1 /usr/lib64/libvulkan.so.

Maybe this can help: https://github.com/qt/qtbase/commit/888b75aa12e2cf35ee760bcf5cb1ed60fe0c0770 but it's Qt6. Also I can't see this change in Wayland platform https://github.com/qt/qtwayland/blob/dev/src/client/qwaylandvulkaninstance.cpp.

RafaelLinux commented 11 months ago

Well, I don't see Qt bug cause. In fact, all vulkan-tools applications works fine. If I do vulkaninfo --summary, it show no errors:

vulkaninfo --summary
WARNING: [Loader Message] Code 0 : terminator_CreateInstance: Failed to CreateInstance in ICD 1.  Skipping ICD.
WARNING: [Loader Message] Code 0 : terminator_CreateInstance: Failed to CreateInstance in ICD 2.  Skipping ICD.
==========
VULKANINFO
==========

Vulkan Instance Version: 1.3.261

Instance Extensions: count = 23
-------------------------------
VK_EXT_acquire_drm_display             : extension revision 1
VK_EXT_acquire_xlib_display            : extension revision 1
VK_EXT_debug_report                    : extension revision 10
VK_EXT_debug_utils                     : extension revision 2
VK_EXT_direct_mode_display             : extension revision 1
VK_EXT_display_surface_counter         : extension revision 1
VK_EXT_surface_maintenance1            : extension revision 1
VK_EXT_swapchain_colorspace            : extension revision 4
VK_KHR_device_group_creation           : extension revision 1
VK_KHR_display                         : extension revision 23
VK_KHR_external_fence_capabilities     : extension revision 1
VK_KHR_external_memory_capabilities    : extension revision 1
VK_KHR_external_semaphore_capabilities : extension revision 1
VK_KHR_get_display_properties2         : extension revision 1
VK_KHR_get_physical_device_properties2 : extension revision 2
VK_KHR_get_surface_capabilities2       : extension revision 1
VK_KHR_portability_enumeration         : extension revision 1
VK_KHR_surface                         : extension revision 25
VK_KHR_surface_protected_capabilities  : extension revision 1
VK_KHR_wayland_surface                 : extension revision 6
VK_KHR_xcb_surface                     : extension revision 6
VK_KHR_xlib_surface                    : extension revision 6
VK_LUNARG_direct_driver_loading        : extension revision 1

Instance Layers: count = 12
---------------------------
VK_LAYER_FROG_gamescope_wsi_x86_64 Gamescope WSI (XWayland Bypass) Layer (x86_64) 1.3.221  version 1
VK_LAYER_INTEL_nullhw              INTEL NULL HW                                  1.1.73   version 1
VK_LAYER_KHRONOS_validation        Khronos Validation Layer                       1.3.261  version 1
VK_LAYER_MANGOAPP_overlay          Mangoapp Layer                                 1.3.0    version 1
VK_LAYER_MANGOHUD_overlay_x86_64   Vulkan Hud Overlay                             1.3.0    version 1
VK_LAYER_MESA_device_select        Linux device selection layer                   1.3.211  version 1
VK_LAYER_MESA_overlay              Mesa Overlay layer                             1.3.211  version 1
VK_LAYER_VALVE_steam_fossilize_32  Steam Pipeline Caching Layer                   1.3.207  version 1
VK_LAYER_VALVE_steam_fossilize_64  Steam Pipeline Caching Layer                   1.3.207  version 1
VK_LAYER_VALVE_steam_overlay_32    Steam Overlay Layer                            1.3.207  version 1
VK_LAYER_VALVE_steam_overlay_64    Steam Overlay Layer                            1.3.207  version 1
VK_LAYER_VKBASALT_post_processing  a post processing layer                        1.3.223  version 1

Devices:
========
GPU0:
        apiVersion         = 1.3.255
        driverVersion      = 23.2.1
        vendorID           = 0x1002
        deviceID           = 0x7480
        deviceType         = PHYSICAL_DEVICE_TYPE_DISCRETE_GPU
        deviceName         = AMD Radeon Graphics (RADV GFX1102)
        driverID           = DRIVER_ID_MESA_RADV
        driverName         = radv
        driverInfo         = Mesa 23.2.1
        conformanceVersion = 1.3.0.0
        deviceUUID         = 00000000-0700-0000-0000-000000000000
        driverUUID         = 414d442d-4d45-5341-2d44-525600000000

CPU-X, requires libvulkan.so.1 too, and it seems working: imagen

However, I found that all "Chrome" based web browsers require that library too, but all they INCLUDE it under their own directories (ms-edge, brave, vivaldi, chrome, chromium, ...). Even VisualCodeStudio have it under it's own directory:

/opt/brave.com/brave/libvulkan.so.1
/opt/google/chrome/libvulkan.so.1
/opt/microsoft/msedge/libvulkan.so.1
/opt/vivaldi/libvulkan.so.1
/usr/lib/libvulkan.so.1
/usr/lib/libvulkan.so.1.3.261
/usr/lib64/libvulkan.so.1
/usr/lib64/libvulkan.so.1.3.261
/usr/lib64/chromium/libvulkan.so.1
/usr/lib64/opera/libvulkan.so.1
/usr/share/code/libvulkan.so.1
zaps166 commented 11 months ago

vulkan-tools are not Qt5 applications. The question was for libvulkan.so, not for libvulkan.so.1. Do you have libvulkan.so?

RafaelLinux commented 11 months ago

I'm sorry. I thought maybe libvulkan.so.1 was a link to libvulkan.so. There is no trace of libvulkan.so but in Steam folder (not system folders). Anyway, remember that if I load libvulkan.so.1 as environment variable (as you certainly suggested) , QT_VULKAN_LIB=/usr/lib64/libvulkan.so.1 QMPlay2 QMP2 display NO errors and shows Vulkan as active. So I begin to think that it's related to the way each Linux distro names libraries. Someones name it libvulkan.so and others name it libvulkan.so.1.

zaps166 commented 11 months ago

Ok, Qt bug confirmed. Maybe I shouldn't rely on Qt and load Vulkan manually...

RafaelLinux commented 11 months ago

Perfect!!! What release I should wait to have this patch? And, should I (try to) report Qt this bug cause is a headache for any programmer relying in that Qt library? Thanks

zaps166 commented 11 months ago

I'll release soon.

It's already fixed in Qt 6.3.0 for X11. You can report issue for Qt Wayland to do same as here. You can also report for openSUSE packagers to symlink libvulkan.so to libvulkan.so.1 or apply this into Qt 5.15.x.

RafaelLinux commented 11 months ago

Thank you for all detailed info. I'll report to them, to avoid this issues that are not applications developers related but are a headache for both, users and programmers ;)

zaps166 commented 11 months ago

It's not only openSUSE, Fedora the same, see: https://github.com/zaps166/QMPlay2/issues/549#issuecomment-1685399623

I'll keep this fix for QMPlay2, thanks for report!

RafaelLinux commented 11 months ago

It's already fixed in Qt 6.3.0 for X11. You can report issue for Qt Wayland to do same as here. You can also report for openSUSE packagers to symlink libvulkan.so to libvulkan.so.1 or apply this into Qt 5.15.x.

Created an issue in KDE. I don't know if I was explicit enough they will understand my explanations.

zaps166 commented 11 months ago

You should report it here: https://bugreports.qt.io

Just say it should use libvulkan.so.1 as well, same as https://bugreports.qt.io/browse/QTBUG-101592, but for Wayland platform.

RafaelLinux commented 11 months ago

Lazslo did it for me (I'll remove my thread from qt.io)

Realex-fire commented 3 months ago

Hello @zaps166. Could you please check the https://github.com/zaps166/QMPlay2/commit/4f1c64af05f09e3bd9cafe063721faa99a2b45d4 commit with AppImage again? I am getting an unavailable Vulkan on the latest Fedora with your AppImage:

Failed to load vulkan: Cannot load library vulkan: (vulkan: cannot open shared object file: No such file or directory)
initInstance: No Vulkan library available
Failed to create platform Vulkan instance
Vulkan is unable to work with QMPlay2 on this platform: Can't create Qt Vulkan instance: ErrorInitializationFailed

Perhaps in this case it is necessary to specify the full path to libvulkan.so.1 in your code or return the section:

if [ -z ${QT_VULKAN_LIB+x} ]; then
    if [ -e /usr/lib/x86_64-linux-gnu/libvulkan.so.1 ]; then
        export QT_VULKAN_LIB=/usr/lib/x86_64-linux-gnu/libvulkan.so.1
    elif [ -e /usr/lib64/libvulkan.so.1 ]; then
        export QT_VULKAN_LIB=/usr/lib64/libvulkan.so.1
    fi
fi

to the AppRun file in your AppImage?

PS: I also noticed that there is no file libqgnomeplatformtheme.so in your AppImage. For me, this causes sometimes random crashes of X11 with GNOME (out of scope bug). But maybe you should include this library in your AppImage?

Thanks.

zaps166 commented 3 months ago

@Realex-fire

4f1c64af05f09e3bd9cafe063721faa99a2b45d4 is no longer relevant. This code has been changed entirely. Qt is no longer loading libvulkan.so library. By default the code tries dlopen( "libvulkan.so", RTLD_NOW | RTLD_LOCAL ), next tries dlopen( "libvulkan.so.1", RTLD_NOW | RTLD_LOCAL ) and use QT_VULKAN_LIB as fallback if all fails. I guess dlopen should load it automatically... Why Fedora is different?

libqgnomeplatformtheme.so - without this library, Qt shouldn't crash. Do you have backtrace (I guess stripped release binaries will be hard to read)?

Realex-fire commented 3 months ago

Qt shouldn't crash.

I haven't investigated the problem in detail, but it's just a video driver bug with Qt apps on GNOME. I gave the information that if, for some reason, you want to include libqgnomeplatformtheme.so in AppImage, this might help (for me it prevents crash).

Why Fedora is different?

dlopen( "libvulkan.so.1", RTLD_NOW | RTLD_LOCAL ) works correctly, I checked it separately. Probably the QVulkanInstance version of m_qVulkanInstance->create() in your AppImage cannot find /usr/lib64/libvulkan.so.1, or dlopen works differently in AppImage, or is it some kind of Fedora "feature"? Please check it when you have time.

zaps166 commented 3 months ago

Probably the QVulkanInstance version of m_qVulkanInstance->create() in your AppImage cannot find /usr/lib64/libvulkan.so.1

I no longer use m_qVulkanInstance->create().

dlopen( "libvulkan.so.1", RTLD_NOW | RTLD_LOCAL ) works correctly, I checked it separately.

So it must work on AppImage, too. What AppImage do you use, the newest?

Realex-fire commented 3 months ago

I no longer use m_qVulkanInstance->create().

https://github.com/zaps166/QMPlay2/blob/935a51ecf20afe48145af7f9aa7c413c79e85fe9/src/qmplay2/vulkan/VulkanInstance.cpp#L375

In the "master" branch, but I'm probably missing something.

So it must work on AppImage, too. What AppImage do you use, the newest?

Yes, the newest.

zaps166 commented 3 months ago

In the "master" branch, but I'm probably missing something.

Oups, I mean:

Initializes the Vulkan library and creates a new or adopts and existing Vulkan instance.

In this case it now just adopts existing Vulkan instance, so Qt no longer looks for library.

Loading of Vulkan library is here. It goes here. If QT_VULKAN_LIB is empty or doesn't exist, it loads the default, see here. So I don't understand why it doesn't work for you where you checked manually dlopen and it worked :astonished: . I think I have to run Fedora and check what's going on...

Realex-fire commented 3 months ago

I think I have to run Fedora and check what's going on...

You can use your latest AppImage and the latest Fedora 40 live iso. The problem must be present.

zaps166 commented 3 months ago

Reproduced, strange...

Why it looks like macOS? I pressed Cmd+Space to find terminal and nothing :rofl:

zaps166 commented 3 months ago

I'll look at this later, for me looks like Qt issue. I need to read Qt code and see why it tries to load library when I set instance manually.

Realex-fire commented 3 months ago

OK, thanks. I hope there is some workaround that will always work reliably.

zaps166 commented 3 months ago

It's because Qt doesn't have API to pass vkGetInstanceProcAddr function, so it still needs to load the library... I missed it.

zaps166 commented 3 months ago

Done, AppImage has -2 suffix. Thanks for the info.

Realex-fire commented 3 months ago

Thanks a lot, it's working now.

RafaelLinux commented 1 month ago

I have this issue still at date. "Vulkan" doesn't appear as "Active" in QMPlay2 24.06.16, despite I had Vulkan installed like I reported (now, version 1.3.278). I supposed it was solved :(

zaps166 commented 1 month ago

I have this issue still at date. "Vulkan" doesn't appear as "Active" in QMPlay2 24.06.16, despite I had Vulkan installed like I reported (now, version 1.3.278). I supposed it was solved :(

Could you give me more details, also about libvulkan.so* libraries. Do you use AppImage?

RafaelLinux commented 1 month ago

The truth is that there are no changes (except version) with respect to the data that I already put when I opened this thread last year, that's why I had not provided that information. It is basically the same and the problem seems to remain the same, related to the name of the library QMPlay2 is looking for.

I'm using the official openSUSE Tumbleweed repositories version, which always has the most updated version of QMPlay2.

These are all libvulkan.so present in my system

/opt/google/chrome/libvulkan.so.1
/opt/microsoft/msedge/libvulkan.so.1
/usr/lib/libvulkan.so.1
/usr/lib/libvulkan.so.1.3.290
/usr/lib64/libvulkan.so.1
/usr/lib64/libvulkan.so.1.3.290
/usr/lib64/chromium/libvulkan.so.1
/usr/lib64/opera/libvulkan.so.1
/usr/share/code/libvulkan.so.1
zaps166 commented 1 month ago

You need this: 74ee99ccb5b75e92c4bf46de66a26ab00e8e4b84 - please ask openSUSE package maintainer to apply this patch. I fixed this after last release, however AppImage contains this patch already. It'll be fixed in next release, too.