05 March 2015

Vulkan

At GDC 2015 in San Francisco, Khronos announced new API for graphics and compute, previously it was called glNext… but now the official name is “Vulkan”!

I could not resist to write some comments about this new and intriguing standard that can potentially “replace” OpenGL.

The basics

A picture is worth a thousand words:

(from the official Khronos presentation):

Vulkan API info

  • Unified API for mobile, desktop, console and embedded devices.
  • Shaders in SPIR-V format (itermediate language format)
  • Simplified driver with layered approach
  • Multithreaded, app is responsible for synchronization
  • Should be easier to build tools
    • Valve, LunarG, Codeplay and others are
      already driving the development of open
      source Vulkan tools
  • Initial specs and implementations expected this year
  • Will work on any platform that supports OpenGL ES 3.1 and up
  • Initial demos shows something like 410ms per frame for GL version and 90ms for Vulkan

My view

It’s great news! Of course, it’s a pity that we do not have beta drivers for that. We can base our opinions only on theoretic assumptions and some internal technical demos. Vulkan spec is written from scratch and it has almost no blockers. OpenGL API (created in 90s!) needed to maintain a lot of old ideas and creating something fresh become a serious problem. GPUs simple changed and evolved over the recent 25 years!

Tech demos are available, it means that beta drivers are not that far from being published. Everyone mentions that we should see VulkanSDK this year.

Look here for ImgTec Demo screen:

Vulkan demo from Imagination Technologies

Or here for DOTA 2 preview (running on Source 2 Engine!): youtube

Vulkan will hopefully beat DirectX 12, Mantle and Metal. This will not happen immediately - Apple will not be happy to remove Metal support and give Vulkan instead. But all of the big players are active members of the Khronos community. So sooner or later, we should see Vulkan implementations on most of platforms.

There is also a question if Vulkan will be faster than Metal (on iOS) and Mantle? Since it is multiplatform some of the performance can be lost. Metal or Mantle can be closer to the hardware/system.

Below you can find a intro to GLAVE - Debug tool for the Vulkan API.

Layered architecture will enable developers to have a fast path for a final ready product and also include debug/validation layers when doing the development.

SPIR-V as an intermediate language (also for OpenCL 2.1) will greatly reduce steps needed to prepare a shader. Take a look at this very complicated scenario in Unity (described @G-Truc) that handles cross compilation between GLSL and HLSL. With SPIR-V you will compile your shaders into this intermediate format and then ship it with the app binaries. Driver will take that IL code (stream of 32 bit words actually) and finish the compilation process. It will be much faster than when compiling directly from GLSL. Khronos is working on offline tools that will compile from various shader languages into IL format.

Should we forget about OpenGL then?

No! I don't think so! Vulkan gives a lot of power but at the cost of more explicit management. You really need to know what you are doing! Not all will benefit from that.
When the standard is mature enough (one year? two years? more?) programmers will start adopting it in their engines. Game engines will probably do it immediately, but then we should start seeing that also in 3D Editors, Photo Editors, or even office tools... Plus, there will still be a lot of code written in OpenGL (even OpenGL 2.0!) so no one from the GPU vendors will simply say: our driver does not support OpenGL.
Bur for sure, it is a very interesting time for graphics programmers!

And one more thing:

Instead of

glBindBuffer...
glMapBuffer...
glTexture...

we’ll be using:

vkCreateCommandBuffer
vkMapMemory
vkCmdPipelineBarrier
vkCmdBindVertexBuffer

From just that sample command list it looks like we’ll be definitely closer to metal! :)

What do you think about Vulkan?

Bonus: Vulkan Session from GDC 2015

Interested in new blog posts and occasional updates? Please sign up for my free newsletter.

Copyright Bartlomiej Filipek, 2016, Blogger platform
Any opinions expressed herein are in no way representative of those of my employers.
This site contains ads or referral links, which provide me with a commission. Thank you for your understanding.