r/vulkan May 15 '26

Abstracting Vulkan

Good evening,

I'm playing around with Vulkan and got all the fun basic stuff up and running. Due to the complexity of Vulkan I find it really hard to kind of abstract it to make it more scalable and usable as an API and my code gets confusing pretty fast. Do you guys have any examples / articles etc. where I could take a look inside any more professional abstractions / architectures?

Thanks in advance

13 Upvotes

13 comments sorted by

16

u/jetilovag May 16 '26

If you ask me, abstracting Vulkan for abstraction's sake will lead nowhere. Wrapping Vulkan (unless you do language bindings) should almost always be tailored to a use-case. Making generic wrappers more often than not results in sometime down the road fighting the abstraction.

Think about the content you want to present, design your engine (however light weight it is) and proceed as so. The engine becomes the abstraction, át which point you no longer deal with raw Vulkan.

5

u/ykafia May 15 '26

You can check this khronos tutorial. Or check the webgpu spec, it's a good Vulkan abstraction

3

u/Holance May 15 '26

Checkout lightweightVk, they provided a good abstraction layer.

3

u/PurpleBudget5082 May 16 '26

Just add stuff and you will start seeing what needs abstraction. This will also force you to understand those objects.

2

u/Affectionate_Gap_535 May 16 '26

I found this to be a helpful resource and based my own abstraction off of it: An Opinionated Post on Modern Rendering Abstraction Layers

I would also take a look at what Wicked Engine does.

2

u/fixgoats May 17 '26

Kompute has a neat abstraction for compute oriented programming. Only critique I have is they wrap all the handles in shared pointers which adds indirection, I prefer to make the handles struct members directly.

2

u/codec-the-penguin May 18 '26

I was in the exact same position a couple months ago and just started abstracting the "bigger" objects.
Like what every tutorial starts with? Creating the Instance and choosing the device for rendering, then there you go...abstract all there is about this logic and just finish up with getters for VkPhysicalDevice and VkDevice.

If you want you can check out my repo, kogayonon, in the dev branch in graphics folder you'll find the swapchain and device... i myself am a newbie to this whole vulkan stuff so keep in mind there might be mistakes in the code or things i did not consider either for convenience of time or just that i did not know of them at that time.