Vulkan support

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

Re: Vulkan support

Post by Vincent » 26 Sep 2017, 22:35

yes I was thinking about normal on terrain, I added them when implementing dynamic lighting. When Vulkan branch get merged I can start to import dynamic lighting related code again.

BTW there should be some appveyor generated installer for the vulkan branch soon.

Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Vulkan support

Post by Vincent » 02 Nov 2017, 00:24

MaNGusT wrote: As for the terrain, yeah, I think we could generate normals at load time and place all map's tris in one smooth group (no sharp edges). When I will get a test build whith these improvements, I can start to work on terrain normal maps.
When I was creating current diffuse textures for terrain, I did some experiments in editor with normal maps, looked awesome and was easy for me to edit them in a 2d software.
Do you have a normal map (in tangent space) for the terrain of the main map of campaign alpha ? Something crude, I need a map to check that everything works correctly.

User avatar
MaNGusT
Art contributor
Posts: 1039
Joined: 22 Sep 2006, 10:31
Location: Polar region, Russia

Re: Vulkan support

Post by MaNGusT » 02 Nov 2017, 21:39

Vincent wrote:Do you have a normal map (in tangent space) for the terrain of the main map of campaign alpha ? Something crude, I need a map to check that everything works correctly.
Hmm. I could make one, but I need to know directions of +-xyz(rgb). I could make a texture with a classic directions, btw. :hmm:
I think 1-2 textures will be enough for your tests.
Image

User avatar
MaNGusT
Art contributor
Posts: 1039
Joined: 22 Sep 2006, 10:31
Location: Polar region, Russia

Re: Vulkan support

Post by MaNGusT » 03 Nov 2017, 22:31

The 1st one. Just for your tests, not final.
Sorry, it's not that fast to create NM from diffuse maps that will look good enough.
I will make and upload two more textures later.
page-84-tiles-arizona-NM.png
It can be normalized to reduce the strangeness of a bump effect.
Image

User avatar
MaNGusT
Art contributor
Posts: 1039
Joined: 22 Sep 2006, 10:31
Location: Polar region, Russia

Re: Vulkan support

Post by MaNGusT » 05 Nov 2017, 16:01

terrain.png
Preview
terrain.png (859.9 KiB) Viewed 4245 times
page-82-yellow-sand-arizona-NM.png
Image

User avatar
moltengear
Trained
Trained
Posts: 147
Joined: 22 Jul 2017, 15:05

Re: Vulkan support

Post by moltengear » 07 Nov 2017, 18:02

it seems to me that it would be nice to create a 4th version of the pie format.
It would be nice if there was a numeric identifier, not just the name of the texture.
Does the texture need a full range of transparency? + normal vectors.

Vincent
Trained
Trained
Posts: 103
Joined: 06 Aug 2016, 17:24

Re: Vulkan support

Post by Vincent » 20 Nov 2017, 19:45

I'm a bit busy atm so I didn't make any progress but I'm still interested in the feature

pastdue
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 217
Joined: 13 Aug 2017, 17:44

Re: Vulkan support

Post by pastdue » 12 Jul 2019, 21:37

Picking up on this, I've been working with Vincent's gfx_api and Vulkan backend patches (rebased on the current master branch, with refactoring, fixes, and enhancements). Some help testing would be greatly appreciated.

For anyone running Windows, here are new (beta) Vulkan-supporting builds:

New Builds (2019-07-13a)
Full Installer (Windows x86): https://ci.appveyor.com/api/buildjobs/b ... taller.zip
Portable Build (Windows x86): https://ci.appveyor.com/api/buildjobs/b ... rtable.zip

To start with the Vulkan backend, run:
warzone2100.exe --vulkan

To enable additional 3D-graphics-related logging, use:
warzone2100.exe --vulkan --debug=3d
(We'll need this extra logging information if you have any issues.)

(IMPORTANT: These builds default to the OpenGL backend if --vulkan is not specified. They support both the existing OpenGL backend and the new Vulkan backend.)

You will, of course, need a graphics card & drivers that support Vulkan. (Vulkan 1.0 support should be all that's required.)

I'm very curious about any feedback. Does it work / not work on your system? How does the performance compare to the (default) OpenGL backend?

The changes since vlj's original Vulkan patch are too many to list, but the highlights are:
- Support the changed gfx_api interface (and other WZ changes since vlj's original patch)
- Require only C++11
- Limit requirements to the "Vulkan Portable Subset"
- Compile on all supported compilers
- Work on non-Windows platforms, in addition to Windows
- Use dynamic loading of Vulkan APIs / libraries
- Support the new backend_Impl_Factory
- Handle many more recommended practices for initializing Vulkan
- Handle systems with multiple GPUs
- Query and handle instance / device / etc features, extensions and limits
- Provide more comprehensive device selection / surface creation / initialization (etc)
- Handle separate graphics and presentation queues
- Handle swapchain minImageCount / maxImageCount
- Handle *many* more error conditions (ex. re-creating swapchain, lost surface)
- Support live window resizing
- Restructure the render pass (and barriers / related)
- Fix bugs / restructure based on the latest Vulkan validation layers
- Rebuild graphics pipelines if necessary
- Handle generating mipmaps
- Handle cleanup and shutdown (and destroying resources in the proper order)
- Clamp drawableSize to VkSurfaceCapabilitiesKHR minImageExtent / maxImageExtent
- Use Vulkan Memory Allocator
- Run on MoltenVK (Vulkan -> Metal)
- Support Multisample Anti-aliasing (MSAA)

Some things that currently don't work in Vulkan mode:
- Toggling vsync (vsync is always enabled)
- Built-in screenshot support
- Using the debug-mode "Make a performance measurement sample" key binding

Some differences in Vulkan mode:
- "Fullscreen" is the so-called "borderless windowed fullscreen" / "fullscreen desktop" mode, instead of the classic / old-fashioned "exclusive" full-screen. As such, the fullscreen resolution will always be the same as your desktop resolution. If you'd like to change the size at which the UI (etc) renders, use the "Display Scaling" option in the Video Options menu.
- Mods that use custom shaders will not load the custom shaders (ex. ArtRev mod). They will need to be updated to also provide Vulkan shaders (instructions coming in the future).

EDIT:
Compiling notes:
  • Only the CMake build toolchain (currently) supports the Vulkan backend
  • You will likely want to install the Vulkan SDK. See: https://vulkan.lunarg.com/sdk/home
    • Some distros may have a package for this, but you will need both: (a) recent Vulkan SDK headers, and (b) glslc (to compile the shaders)
  • SDL2 must be compiled with Vulkan support enabled. Some Linux distros (especially older releases) compile SDL2 without Vulkan support - to fix, you'll need to compile SDL2 from source (and make sure Vulkan support is enabled)
Last edited by pastdue on 13 Jul 2019, 15:16, edited 5 times in total.

User avatar
andrvaut
Trained
Trained
Posts: 161
Joined: 02 Jan 2016, 12:44

Re: Vulkan support

Post by andrvaut » 12 Jul 2019, 23:22

ubuntu 18.04, nvidia 1050ti, driver nvidia-430
git hash 2c70abf6810ba26149516f260b35ad3448c93e71
compile without error.
if start

Code: Select all

./src/warzone2100 --vulkan

Code: Select all

error "Warzone was not compiled with the Vulkan backend enabled. Aborting."
vaut ΣΑ [GN], ru streamer.
Tournaments channel: https://www.youtube.com/channel/UCzusNa-54ydodtSz2TdHFww

pastdue
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 217
Joined: 13 Aug 2017, 17:44

Re: Vulkan support

Post by pastdue » 12 Jul 2019, 23:28

@andrvaut: I added some compiling tips above. (You'll need to use the CMake build toolchain for now, and you'll have to ensure that the SDL2 library was compiled with Vulkan support enabled.)

User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 817
Joined: 26 Sep 2016, 19:56

Re: Vulkan support

Post by Berserk Cyborg » 13 Jul 2019, 00:52

Yo, this is pretty slick! I tested the linked build on Windows 10 (upgraded to the latest graphics driver available). Can't say I see much wrong. Performance was good.

Code: Select all

info    |17:24:46: [VkBuf::update:1279] Attempt to upload to buffer more than once per frame
info    |17:24:46: [VkBuf::update:1279] Assert in Warzone: C:\projects\warzone2100\lib\ivis_opengl\gfx_api_vk.cpp:1279 (flag == update_flag::non_overlapping_updates_promise || (lastUploaded_FrameNum != current_FrameNum)), last script event: '<none>'
I get this a few times. It can can be reproduced by opening the debug menu or by keeping the research window open.

- The research bar's yellow "progress bar" is on top of the timers (but not for ally research).
- Minimap trapezoid "viewing window" is a bit too opaque.
- Minimap is really blurry.

logs.zip
(40.4 KiB) Downloaded 33 times

pastdue
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 217
Joined: 13 Aug 2017, 17:44

Re: Vulkan support

Post by pastdue » 13 Jul 2019, 01:00

Berserk Cyborg wrote:
13 Jul 2019, 00:52
Yo, this is pretty slick! I tested the linked build on Windows 10 (upgraded to the latest graphics driver available). Can't say I see much wrong. Performance was good.
Thank you for testing! If you have a chance, I'm very interested in performance comparisons vs. the default OpenGL mode. (I like to start a New Campaign - Beta Campaign, and zoom out all the way to get a fairly consistent sample with a decent amount going on.)

Note: Vulkan anti-aliasing will differ from OpenGL anti-aliasing in implementation, so I'm also curious about performance with anti-aliasing on and off for both.
Berserk Cyborg wrote:
13 Jul 2019, 00:52

Code: Select all

info    |17:24:46: [VkBuf::update:1279] Attempt to upload to buffer more than once per frame
info    |17:24:46: [VkBuf::update:1279] Assert in Warzone: C:\projects\warzone2100\lib\ivis_opengl\gfx_api_vk.cpp:1279 (flag == update_flag::non_overlapping_updates_promise || (lastUploaded_FrameNum != current_FrameNum)), last script event: '<none>'
I get this a few times. It can can be reproduced by opening the debug menu or by keeping the research window open.
Thank you. If you find any other ways of triggering that assert, please let me know. (Have already fixed a bunch.)
Berserk Cyborg wrote:
13 Jul 2019, 00:52
- The research bar's yellow "progress bar" is on top of the timers (but not for ally research). [Fixed build soon.]
- Minimap trapezoid "viewing window" is a bit too opaque. [Fixed build soon.]
- Minimap is really blurry. [Fixed build soon.]
Do those issues go away with the same build when running in OpenGL mode (without --vulkan specified)? There's a lot of additional gfx_api wrapping work in these builds, so it's possible some of those issues could be a result of that. (In fact, the minimap one might be is related to texture filtering.)
Last edited by pastdue on 13 Jul 2019, 13:27, edited 1 time in total.

User avatar
Berserk Cyborg
Code contributor
Code contributor
Posts: 817
Joined: 26 Sep 2016, 19:56

Re: Vulkan support

Post by Berserk Cyborg » 13 Jul 2019, 02:08

pastdue wrote:
13 Jul 2019, 01:00
Thank you for testing! If you have a chance, I'm very interested in performance comparisons vs. the default OpenGL mode. (I like to start a New Campaign - Beta Campaign, and zoom out all the way to get a fairly consistent sample with a decent amount going on.)

Note: Vulkan anti-aliasing will differ from OpenGL anti-aliasing in implementation, so I'm also curious about performance with anti-aliasing on and off for both.
FWIW, The Vulkan backend is able to maintain 60 FPS at 100x speed(?), for OpenGL it drops to 18 and everything starts flashing and unit movement is jittery. With Vulkan everything more or less stays smooth. Antialiasing (I can get up to 8x) doesn't appear to have any negative performance impact, using both backends. According to the FPS counter, anyway. And, if I had to "eyeball it" then it would hold true.

However, using Fullscreen (1920x1080), the Vulkan backend drops to 30 FPS and 100x speeds drop down to 12 FPS and it gets laggy and flashy like the OpenGL backend.
pastdue wrote:
13 Jul 2019, 01:00
Do those issues go away with the same build when running in OpenGL mode (without --vulkan specified)? There's a lot of additional gfx_api wrapping work in these builds, so it's possible some of those issues could be a result of that. (In fact, the minimap one might be is related to texture filtering.)
The research time using Vulkan turns non-bold and gets obscured by the bar. OpenGL displays it correctly.

User avatar
WZ2100ModsFAn
Trained
Trained
Posts: 366
Joined: 15 Apr 2018, 17:25
Location: United States.

Re: Vulkan support

Post by WZ2100ModsFAn » 13 Jul 2019, 04:13

pastdue wrote:
12 Jul 2019, 21:37
Picking up on this, I've been working with Vincent's gfx_api and Vulkan backend patches (rebased on the current master branch, with refactoring, fixes, and enhancements). Some help testing would be greatly appreciated.

For anyone running Windows, here are new (beta) Vulkan-supporting builds:

Full Installer (Windows x86): https://ci.appveyor.com/api/buildjobs/j ... taller.zip
Portable Build (Windows x86): https://ci.appveyor.com/api/buildjobs/j ... rtable.zip

To start with the Vulkan backend, run:
warzone2100.exe --vulkan
Starting er up with the vulkan API worked perfectly when showing in game and in the main menu.
I use Ubuntu GamePack By UALinux for gaming. Best Ubuntu Distro for Warzone :D

pastdue
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 217
Joined: 13 Aug 2017, 17:44

Re: Vulkan support

Post by pastdue » 13 Jul 2019, 15:23

I've updated the post above with new builds (2019-07-13a).

These builds should fix:
Berserk Cyborg wrote:
13 Jul 2019, 00:52
- The research bar's yellow "progress bar" is on top of the timers (but not for ally research).
- Minimap trapezoid "viewing window" is a bit too opaque.
- Minimap is really blurry.
Additionally, they:
- Add more debug logging
- Improve selection of the surface format (fixes an issue reported by Berg that could result in the entire interface being too "light" / washed-out)
- Improve some error messaging around backend initialization

You'll still see the occasional "Attempt to upload to buffer more than once per frame" assert (haven't gotten to all of those yet).

Post Reply