~bitfehler/hare-lawa

Demo using Vulkan to render the contents of a Wayland window
The floor is lawa!

refs

master
browse  log 

clone

read-only
https://git.sr.ht/~bitfehler/hare-lawa
read/write
git@git.sr.ht:~bitfehler/hare-lawa

You can also use your local clone with git send-email.

#hare-lawa

The floor is lawa!

This project is a demonstration of how to use Vulkan along with the pure Hare Wayland library to render the contents of a window.

Usually, when using Vulkan with Wayland, you would use the VK_KHR_wayland_surface extension. But this is difficult to do in Hare, because the extension uses the Wayland C library.

So, instead, here is an example of a "headless" rendering to an image buffer, the contents of which are then copied into a shared memory buffer for display. This is obviously not something you would want to use for your next FPS, but it might very well be suitable for retained mode GUIs, e.g. to aid with text rendering? I honestly don't know, but I want to find out :)

If it turns out to be useful, the lawa module will become a helper library for this specific use-case.

The "rendering" currently consists only of clearing the screen, to a color determined by the size of the window. But all the Vulkan setup is there, as is the Wayland/XDG setup, giving the window server-side decorations and reacting to resize events.

The whole thing is also a walking memory leak right now, but that can certainly be fixed.

Vendored Vulkan 1.3 bindings generated with the Hare-enabled glad using the following command:

python -m glad --api vulkan --extensions "VK_EXT_debug_utils" --out-path vk hare

Vendored Wayland protocol definitions can be recreated with hare-wlscanner from hare-wayland (precise location might vary, but you get the idea):

hare-wlscanner < /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml
hare-wlscanner < /usr/share/wayland-protocols/unstable/xdg-decoration/xdg-decoration-unstable-v1.xml

#Requirements

  • A recent version of Hare and hare-wayland
  • A working Vulkan driver (e.g. vulkaninfo should give "some" output)
  • For $reasons, the Wayland server must support wl_shm with color format 0x34324241, aka 'AB24' or 'ABGR8888' (check wayland-info)