Vulkan support

For code related discussions and questions
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Vulkan support

Post 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.
Jorzi
Regular
Regular
Posts: 2063
Joined: 11 Apr 2010, 00:14

Re: Vulkan support

Post by Jorzi »

Just to make sure, what kind of hardware does vulkan run on? The same as directx 12?
ImageImage
-insert deep philosophical statement here-
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Vulkan support

Post 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.
User avatar
Tzeentch
Trained
Trained
Posts: 300
Joined: 14 Oct 2012, 14:24

Re: Vulkan support

Post 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.
Cyp
Evitcani
Evitcani
Posts: 784
Joined: 17 Jan 2010, 23:35

Re: Vulkan support

Post 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.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Vulkan support

Post 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.
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Vulkan support

Post 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.
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Vulkan support

Post by Per »

Yes, a lot of funky fixed function hacks are littered around the codebase...
User avatar
Ezio
Trained
Trained
Posts: 306
Joined: 24 Apr 2010, 16:42

Re: Vulkan support

Post 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.
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Vulkan support

Post 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.
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Vulkan support

Post 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.
Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Vulkan support

Post 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).
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: Vulkan support

Post by Per »

Very cool!
User avatar
MaNGusT
Art contributor
Posts: 1152
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: Vulkan support

Post by MaNGusT »

And very dark and blurry :D just joking. Good to see that it works.
Image
User avatar
Tzeentch
Trained
Trained
Posts: 300
Joined: 14 Oct 2012, 14:24

Re: Vulkan support

Post by Tzeentch »

I have to ask... why are you doing all this Vincent? Should be cool.
Post Reply