jpbruyere / vkvg

Vulkan 2D graphics library
https://jpbruyere.github.io/vkvg/
MIT License
773 stars 33 forks source link

Is vkvg Wayland-native like Cairo-gl? #58

Open Rubo3 opened 2 years ago

Rubo3 commented 2 years ago

You can make Cairo-gl Wayland-native thanks to its EGL backend, as shown here: https://jan.newmarch.name/Wayland/Cairo. Can you do the same with vkvg?

jpbruyere commented 2 years ago

https://www.phoronix.com/scan.php?page=news_item&px=Vulkan-Wayland-Compositor-Near : there are some efforts to make vulan-wayland bridges, this should pose no problems to create a wayland surface with vkvg, it's surely a good task to put on the roadmap...

Rubo3 commented 2 years ago

Thanks, it's great to see that! However I was talking about Wayland clients, I saw in this Reddit thread https://www.reddit.com/r/vulkan/comments/gs8wy7/vulkan_and_egl/fsk0d8d that it seems to be possible to draw with Vulkan on Wayland surfaces without EGL, here is some code https://github.com/krOoze/Hello_Triangle/blob/master/src/WSI/Wayland.h

jpbruyere commented 2 years ago

I've made some test on wayland today, and there is no problem, and it's quiet faster than under X. Maybe weston will become my first desktop env... GLFW handles natively wayland...

Rubo3 commented 2 years ago

I've made some test on wayland today, and there is no problem, and it's quiet faster than under X.

True, I ran some tests too. Now I'm studying what can be ported from vkh to vkvg to mimic the behaviour of cairo-gl. I see your tests/common/test.c and tests/common/vkengine.c are quite useful to understand the structure of a program which draws to an on-screen surface. It's quite simpler than Vulkan's HelloTriangle haha.

GLFW handles natively wayland...

Yeah it's amazing, I didn't even have to recompile or link against Wayland.

jpbruyere commented 2 years ago

I've not included vkengine in vkh because of glfw dependancy, but I use it everywhere. Maybe I should include it to vkh and add a build option. Or maybe make a separate git repo for vkengine and build it with cmake as an object library...

Rubo3 commented 2 years ago

Maybe I should include it to vkh and add a build option.

What about integrating it to vkh and adding a build option to include the GLFW-dependent code?

jpbruyere commented 2 years ago

Yes, it would be better than to copy vkengine.* each time I start a vulkan app.

tmathews commented 4 months ago

Perhaps we can do it without GLFW using the technique described here: https://amini-allight.org/post/using-wayland-with-vulkan. It looks like it would be a lot more work? But this is something that I'll be investigating for my own projects as I don't use GLFW, but my own wrapper for Wayland protocols. To me this is advantageous as it offers me more control for my applications.

jpbruyere commented 4 months ago

From the point of view of vkvg, only vulkan context objects (Application, devices, queue) are required. Having an application launched under wayland looks straightforward with your link.

https://registry.khronos.org/vulkan/specs/1.3-extensions/html/vkspec.html#platformCreateSurface_wayland

Creating a valid vulkan surface with VK_KHR_wayland_surface instance extension is the only point of interest from the point of view if vkvg.

tmathews commented 4 months ago

Thanks for pointing this out. I will try to get a working example for my purposes. Would it be ideal to have this kind of example in vkvg for demonstration purposes?

jpbruyere commented 4 months ago

Sure it would be great to have a working example!

tmathews commented 4 months ago

I'm happy to say I finally got something working: https://github.com/tmathews/wayland-vulkan-vkvg. There are a lot of errors at the moment and it's very messy, I hacked until I sort of understood what was happening.