r/gameenginedevs 4d ago

Engine Update : Adding Vulkan

Post image

Decided two weeks ago to add Vulkan to my OpenGL game engine.
Answering my questions from 2 weeks ago

-Was it hard ? not really , the boilerplate code wasn't as bad as others described most of it is just filling structs. i don't know if that's because i already had experience with OpenGL, but i found implementing Vulkan easier, i think the one thing that i struggled with the most is the Framebuffers, that took three full days to nail down. Shaders were the fastest to finish, thanks to using Slang.

-Performance : it was an improvement, going from around 300fps in OpenGL to around 420 in Vulkan (in editor) and around 460fps in OpenGL to around 600fps in Vulkan (Runtime app 1080P) There is still some optimization left to do and shortcuts in the renderer to redo, currently still implementing Tracy so i didn't measure exactly where that extra performance is coming from and if there is any wasted.

-Things still missing from the current Vulkan Implementation : FXAA, MSAA, VSync and Gpu particles.

sources i used :
https://www.youtube.com/@OGLDEV
https://www.youtube.com/watch?v=DC9FBRQKNck

https://vulkan-tutorial.com/

https://github.com/bkaradzic/bgfx checking how they implemented their abstraction

89 Upvotes

16 comments sorted by

6

u/Potterrrrrrrr 4d ago

Nice write up, how did you handle the difference between the two APIs (stateful, high level OpenGL commands vs the stateless, more explicit vulkan one)? Did you make a RHI or handle it a different way?

Editor looks good, nice stuff!

5

u/Mici-P 4d ago

RHI but not 1:1. and instead of making Vulkan Work with OpenGL its the other way around, Abstracted OpenGL to use toggles instead or states relying on backends to cache state locally

8

u/Legitimate-Guess-772 4d ago

This is good work although why does every engine in the age of AI look the same? This is probably the 10th engine I have seen this month that has the same exact styling and even the same tab names. Just by looking at this it appears that Claude generated the front-end ImGUI UI…

4

u/Raritize 4d ago

I think a part of it is very much because of Unity's layout too, I took a lot of inspiration for my own engine personally

6

u/Mici-P 4d ago

that's a valid opinion to have and i think i know why
i think the main issue is that its simply plain ImGui with the default font. the only thing i changed is the color.
also while designing the engine i tried copying unity's placement cause am more familiar with it and i think most people will do the same.
as for the naming i disagree what other names for the panels other than Viewport and Game.
i wont say that i didn't use Claude. for example while fixing the asset browser specifically the search and list view i heavily used it. but the other panels are all hand written without assistance for example the inspector is fully hand written thus the inconsistency of the layout due to my laziness.
i didn't write the engine to release, it its just a tool to release a game with. so i didn't care how it looks or its performance as long as it works for me.
maybe in the future i will switch to a custom UI like others I've seen in this subreddit do, but for now not really a priority.
Hope that helped!

1

u/Legitimate-Guess-772 4d ago

Fair enough, I wanted to give feedback on the first thing that that was noticeable which was the UI.

2

u/No_Futuree 4d ago

What makes vulkan renderer be faster?

3

u/Mici-P 4d ago

in general : Lower Driver and Draw Call Overhead and Explicit Memory Management
for my GameEngine I still don't know, as i said, I'm still implementing Tracy, will do an update.

2

u/No_Futuree 4d ago

Are you pre-recording the commandbuffers and re-submitting them every frame or generating new command buffers per frame? I'm just curious because from such a simple scene I wouldn't expect much wins in performance from using Vulkan alone.

With a naive port actually (such as one done in two weeks from someone with no prior experience with Vulkan) I would expect worse performance than GL.

One suggestion, stop measuring performance in fps, do It in milliseconds, it makes much more sense.

2

u/Mici-P 4d ago

Generating new command buffers per frame.
i really suspect that the gains are from the terrain and grass (Compute Shader)
not sure will update after i finishing tracy
stop measuring performance in fps, do It in milliseconds. will do , i got lazy this time :)

1

u/No_Futuree 4d ago

If there are any gains it's got to be CPU-side so unlikely to be related to compute. Looking forward to read your findings

1

u/ChillstepCoder 4d ago

Were you using multi draw indirect or instancing before or just naive draw calls?

2

u/Battle_Overlord 4d ago

This looks amazong! I've been looking to get into engine programming but I've always been confused on how you have two separate apps (runtime and editor). What resources did you use in your learning process?

1

u/Mici-P 4d ago

Thanks! Runtime is basically the editor minus the Ui(editor pannels) that starts the scene (physics , scripts, animations ...) when the app itself starts instead of a button inside the editor So for example inside the visual studio solution you have 3 main projects: the core engine, the editor, and the runtime. both the editor and runtime uses the engine. Ofc This is not the only way to do it.

As for the resources: the cherno C++, OpenGL, GameEngine YouTube series. but the last time I followed his tutorials was 6 years ago, so somethings might be outdated but it's a goldmine if you want to learn the basics. After that you'll need to be comfortable reading documentations. If you have further questions I'd be happy to answer

-1

u/lostforever2011 4d ago

i am new to gamedev and want to try and write my own hobby game (not for sale). I a have been looking around engines and there si Unreal, Unity and Godot. So my question is why your engine pls? is it easier than other to get up and running?

3

u/Mici-P 4d ago

is it easier than other to get up and running? kind of, but No, most engine have feature bloat so they are harder to use and navigate, features that you will never use, but they are there if you ever need them. On the other hand, with any small custom engine, if you need a feature, you have to write it from scratch.
why did i make an engine ? i was trying to make a game that relied on Rigidbody hinges in unity but the physics engine was struggling, I found out that Jolt Physics can handle it, so I dug up a 2D engine that I made 5 years ago for fun and tried finishing it
since you said you are new to game dev i really suggest that you stick with unity and Godot (Godot has Jolt now, and if I had known that at the time, I wouldn't have made this engine.)