Page 1 of 5

Vulkan support

Posted: 27 Sep 2016, 01:37
by Vincent
I'm intending to add a Vulkan backend to Warzone 2100. Obviously the goal is not to reduce cpu overhead since the game doesn't draw a lot of thing on screen at the moment (there's around 100-200 draw call per frame), but to improve current code architecture. WZ codebase could be described as state oriented : everything is stored in globals and almost every functions have side effect. This was likely guided by the constraints of C before 99 but it makes hard to reason on code by devs and compiler.
Vulkan API makes multithreading of graphic code possible and I'd like to take advantage of this and extract some code that can be threaded in wz2100 code. It's likely to improve wz2100 code by making more explicit which variables a given function is using or modifying, having more pure functions...To ensure compatibility with gl such functions would be run in sequential mode if it does touch openGL context.

Re: Vulkan support

Posted: 27 Sep 2016, 18:15
by Jorzi
Just to make sure, what kind of hardware does vulkan run on? The same as directx 12?

Re: Vulkan support

Posted: 27 Sep 2016, 22:24
by Vincent
Yes, it runs on Nvidia/AMD cards released after 2012 and Intel Skylake (core iX-6xxx) and Broadwell (core iX-5XXX) on Windows and Linux. Linux drivers have some sort of support for Haswell and Ivy Bridge too but it's considered experimental.

On Android side afaik only Galaxy S7 and Note 7 and latest Nexus phones support Vulkan. I think no tablet does yet.

Obviously GL renderer will be kept.

Re: Vulkan support

Posted: 28 Sep 2016, 09:09
by Tzeentch
How do you find time to do this?

Good. Multi threads what we need. Tons of sync overhead from messages being displayed and half the time warzone doesn't run on older systems unless you get download for intel driver on cpu.

Re: Vulkan support

Posted: 28 Sep 2016, 18:34
by Cyp
Is there any fallback wrapper for Vulkan → OpenGL so it runs everywhere if Vulkan is not present? Haven't looked at Vulkan at all, but given how archaic some parts of OpenGL seem, I'd expect it to be better.

Re: Vulkan support

Posted: 28 Sep 2016, 20:34
by Per
I would not object to having a Vulkan backend, in addition to an OpenGL backend, but removing the OpenGL backend in favour of Vulkan at this point is way premature, given the early and buggy state of Vulkan drivers. Also, unfortunately, the big challenge and most of the work is changing the design of the rendering so that it aligns with modern GPU architectures. That is work that has to be done for either backend, and is where we should start.

Re: Vulkan support

Posted: 13 Oct 2016, 22:43
by Vincent
Actually adding Vulkan support is taking more time than I initially expected. I have basic 2d menu support atm but the modifications are huge.
The issue is that wz2100 quietly assumes OpenGL support in a lot of place. Blending depth stencil modifications are often spread in separate place and texture binding too.

Re: Vulkan support

Posted: 13 Oct 2016, 23:16
by Per
Yes, a lot of funky fixed function hacks are littered around the codebase...

Re: Vulkan support

Posted: 14 Oct 2016, 12:34
by Ezio
you push it to your github master Vinc?, i'd like to test it too.
i used vulkan with dota 2 although from my experience with it, when i jump from one place to another by clicking map my fps drops 60 -> 20 or even lower. and spike like that are bad for strategy game.

Re: Vulkan support

Posted: 15 Oct 2016, 18:30
by Vincent
There's nothing to see currently, only the menu is displayed so it's hard to know how well performance will be. Plus there are a lot of glitches (no alpha blending so black boxes around letter for instance).

I can't comment on Dota2, I'm also having some very small freeze especially at the beginning of games. I don't know if that's because of some technical choice of Valve or if it's just because it's still work in progress (afaik the fastest backend is the dx9 one). In my opinion the best Vulkan game availble at the moment is Doom 2016, it's faster to use Vulkan than GL on every hardware vendor and frame stuttering is almost eliminated.

Re: Vulkan support

Posted: 24 Oct 2016, 03:46
by Vincent
I'm making some progress on the 3d part (terrain rendering actually). Hopefully I can have something "good enough" in a week or 2 that could be candidate for merge. Since I'm focusing on introducing a layer between current code and GL callbacks it won't actually bring any performance difference ; however having a cross API basis as quick as possible in the engine will help rewrite some part of the code in a more "explicit" way and show some multithreading opportunities.

Re: Vulkan support

Posted: 26 Oct 2016, 00:59
by Vincent
Here a screenshot of work in progress :
wzvulkan.PNG
There's a lot to do, 3d interface is not working, particles shadows and construction effects are missing. And there are some bugs, terrain layers are not properly blended (hence the dark tone).

Re: Vulkan support

Posted: 26 Oct 2016, 01:09
by Per
Very cool!

Re: Vulkan support

Posted: 26 Oct 2016, 15:48
by MaNGusT
And very dark and blurry :D just joking. Good to see that it works.

Re: Vulkan support

Posted: 26 Oct 2016, 20:23
by Tzeentch
I have to ask... why are you doing all this Vincent? Should be cool.