You are not logged in.

#1 2024-10-22 23:53:00

Uster
Member
Registered: 2024-05-08
Posts: 6

[SOLVED]Problems with vulkan development in wayland

Have anyone the same problem?
I was following this tutorial: https://vulkan-tutorial.com/Development_environment
what in resume is: sudo pacman -S shaderc glfw glm vulkan devel
make a Makefile:

CFLAGS = -std=c++17 -O2
LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi

VulkanTest: main.cpp
	g++ $(CFLAGS) -o VulkanTest main.cpp $(LDFLAGS)

.PHONY: test clean

test: VulkanTest
	./VulkanTest

clean:
	rm -f VulkanTest

and a main.cpp

#define GLFW_INCLUDE_VULKAN
#include <GLFW/glfw3.h>

#define GLM_FORCE_RADIANS
#define GLM_FORCE_DEPTH_ZERO_TO_ONE
#include <glm/vec4.hpp>
#include <glm/mat4x4.hpp>

#include <iostream>

int main() {
    glfwInit();

    glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API);
    GLFWwindow* window = glfwCreateWindow(800, 600, "Vulkan window", nullptr, nullptr);

    uint32_t extensionCount = 0;
    vkEnumerateInstanceExtensionProperties(nullptr, &extensionCount, nullptr);

    std::cout << extensionCount << " extensions supported\n";

    glm::mat4 matrix;
    glm::vec4 vec;
    auto test = matrix * vec;

    while(!glfwWindowShouldClose(window)) {
        glfwPollEvents();
    }

    glfwDestroyWindow(window);

    glfwTerminate();

    return 0;
}

when i run make test:

$ make test
./VulkanTest
24 extensions supported
        
^Cmake: *** [Makefile:10: test] Interrupt

I have to stop, it doesn't show a window, so Ctrl+C, i'm in sway
I have the next maybe relevant packages:

archlinux-xdg-menu
arm-none-eabi-gcc
base
base-devel
brightnessctl
btrfs-progs
clang
cppcheck
darkman
foot
gammastep
git
glfw
glm
gnu-free-fonts
intel-media-driver
intel-ucode
libpulse
libva-intel-driver
pacman-contrib
pipewire
pipewire-alsa
pipewire-jack
pipewire-pulse
pkgstats
playerctl
qbittorrent
qt5-wayland
qt6-wayland
sway
swaybg
swayidle
swayimg
swaylock
swaync
syncthing
vulkan-extra-layers
vulkan-extra-tools
vulkan-html-docs
vulkan-intel
vulkan-tools
vulkan-utility-libraries
vulkan-validation-layers
wget
wireplumber
wireshark-qt
wmenu
xdg-desktop-portal-gtk
xorg-xeyes
xorg-xwayland

Last edited by Uster (2024-10-27 00:06:56)

Offline

#2 2024-10-23 09:17:21

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,236

Re: [SOLVED]Problems with vulkan development in wayland

Run (and post the output of) vulkaninfo --summary to verify your vulkan setup is correct.
also run vkcube .

LDFLAGS = -lglfw -lvulkan -ldl -lpthread -lX11 -lXxf86vm -lXrandr -lXi

That code is for X and sway will run it through xwayland .
Have you tried to run it in a real X-session ?


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#3 2024-10-23 22:00:40

Uster
Member
Registered: 2024-05-08
Posts: 6

Re: [SOLVED]Problems with vulkan development in wayland

==========
VULKANINFO
==========

Vulkan Instance Version: 1.3.295


Instance Extensions: count = 24
-------------------------------
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_headless_surface                : 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 = 4
--------------------------
VK_LAYER_KHRONOS_validation Khronos Validation Layer   1.3.290  version 1
VK_LAYER_LUNARG_api_dump    LunarG API dump layer      1.3.250  version 2
VK_LAYER_LUNARG_monitor     Execution Monitoring Layer 1.3.250  version 1
VK_LAYER_LUNARG_screenshot  LunarG image capture layer 1.3.250  version 1

Devices:
========
GPU0:
	apiVersion         = 1.2.289
	driverVersion      = 24.2.5
	vendorID           = 0x8086
	deviceID           = 0x22b1
	deviceType         = PHYSICAL_DEVICE_TYPE_INTEGRATED_GPU
	deviceName         = Intel(R) HD Graphics 400 (BSW)
	driverID           = DRIVER_ID_INTEL_OPEN_SOURCE_MESA
	driverName         = Intel open-source Mesa driver
	driverInfo         = Mesa 24.2.5-arch1.1
	conformanceVersion = 1.2.0.0
	deviceUUID         = 8680b122-3500-0000-0002-000000000000
	driverUUID         = ba5c738d-0628-4bab-2892-92685839fcba

vkcube works, after set it up my slowly gnome with some work, make test work in gnome-xorg, but not gnome-wayland.

Offline

#4 2024-10-24 11:20:43

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 13,236

Re: [SOLVED]Problems with vulkan development in wayland

Setup looks fine.

Since it works in pure X there are likely changes needed to LDFLAGS or includes to get the example to run under wayland .

The tutorial is aimed at cross platform functionality.
Is your goal to learn vulkan programming or are you targeting vulkan on wayland exclusively ?

If the 2nd you may be better off looking at programming vulkan using the GTK4 or Qt6 toolkits then a crossplatform tutorial.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2024-10-24 13:16:21

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,330
Website

Re: [SOLVED]Problems with vulkan development in wayland

Well it definitely cant work when you're linking to X11 for all the windowing functions.

While glfw supports drawing on wayland surfaces, I'm pretty sure it doesn't have anything builtin for creating wayland surfaces and interacting with compositors.  I've only seen examples of client programs written using typical wayland code for creating the surfaces and interacting with the compositor, then only after the compositor has provided a wayland surface does the client call vkCreateWaylandSurfaceKHR to get a vulkan reference too it.

Note that the "boiler plate" code to just get a wayland surface for this kind of task can be in the range 1000 loc or more.  I once wrote a library (nkk) to handle this without relying on one of the big toolkits, but it didn't gain much traction so I haven't really maintained it - feel free to look it up as an example if you'd like.

Otherwise you pretty much need to either write the 1000+ lines of wayland boilerplate yourself, or rely on GTK or QT for all of that.

If you do want to learn to write vulkan/wayland clients from scratch, I'd definitely advise to do each one individually first: write vulkan code for X11 to learn vulkan, as X11 window creation is trivial, then write some simple wayland clients without worrying about vulkan/gl at all, just get some surfaces (aka windows) to show up on the screen and be able to be resized.  Then you can combine the two (if your sanity remains in tact).

Last edited by Trilby (2024-10-27 01:31:21)


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2024-10-27 00:05:36

Uster
Member
Registered: 2024-05-08
Posts: 6

Re: [SOLVED]Problems with vulkan development in wayland

Thanks for the replys.
Yes, I'm looking to learn vulkan, I tried in fedora kde, and and works, in arch plasma to. it dosen't show windows but i see it in the bar, so thats it, i will learn there in case of problem, or x11...

Offline

Board footer

Powered by FluxBB