Has someone used a 2D library (Skia) with the Vulkan backend?


#1

I’m looking for a way to do good hardware accelerated 2D drawing (mostly rectangles) with Vulkan 1.0. Does anyone have tips to use a 2D library (ideally Skia?) for portable Vulkan logic? My only alternative is OpenGL 3.0.

Josh


#2

dear ImGui has a Vulkan backend. Whilst this is intended as a GUI system, it has drawing primitives which should meet your needs.

For more complex hardware accelerated drawing, you could look at writing a Vulkan backend for NanoVG. I’ve been considering writing one myself but have not had the time to do so yet.


#3

I don’t have the patience to learn Vulkan yet, but I’d try NanoVG in a heartbeat if it got a retained mode Vulkan+window example.


#4

If you don’t want to learn Vulkan yet, is there a reason you need Vulkan over OpenGL? NanoVG’s OpenGL backends work well.


#5

Why do you ask? I don’t want to get off-topic.


#6

Because knowing more about your requirements might help with finding a solution.

For example you mention you need to draw mostly rectangles, which dear imgui is more than capable of. Since that has a Vulkan back end if Vulkan was the main requirement this could be a way to go.

If you really need the complex shape, gradient fill, and rotation capabilities of something like NanoVG then using OpenGL for now and converting it to Vulkan later if needed might be an approach.


#7

Both ImGui and NanoVG ‘are’ stateless APIs, right? Skia reuses parts of the Vulkan pipeline between frames, which is more efficient. I’m not aware of other 2D libraries like it.


#8

If you concerned about performance, then test them. dear ImGUI in particular is heavily tuned for performance and very fast, and if your content doesn’t change then don’t render your frame (this is the optimization I use for power conservation in my editor).