Thursday, September 14, 2017

API Showdown: Vulkan vs OpenGL - A Doomed Comparison


Image result
VS
Image result for OpenGL


You may have heard of Vulkan, not the smarty-pants Star Trek race, but the new-fangled, low-level graphics API. Vulkan has received a lot of hype both for its hopeful efficiency gains as well as its open-source nature, getting out from under the proprietary thumb of Microsoft while still offering cross-platform compatibility.

Efficiency gains? Open-source? Cross-platform? This all sounds well and good, but as with many new technologies, how much of this theoretical horn tooting trickles down to practice? Is the end result really that impressive compared to the tried and true APIs du jour: OpenGL and DirectX? Heck is Vulkan even better at all?


Doomed Comparison

Looking for an answer, I booted up Doom, one of last year's best shooters.  Besides being a critically-and-consumer acclaimed game, it's also one of the first to offer support for both Vulkan and OpenGL, making for a fitting comparison. 

After spending some time in the game and conducting several experiments, the results were simply too meaty not to share.

It all started at the very beginning of the Argent Tower level. I was playing under the default OpenGL renderer when the game started stuttering like a puttering car engine. I checked my stats. The frame rate was definitely dropping.  

Despite multiple reboots, the poor performance persisted and seemed to be tied to a particular overlook (which you will see in the screenshots below).  Whenever I looked out at this area, the frame rate tanked.

This in and of itself isn't too curious. Vast overlooks are infamous for tanking frame rates. What was curious was the CPU and GPU utilization. According to MSI Afterburner, despite my frame rate being relatively low, my CPU and GPU utilization were equally low.

It's one thing for the frame rate to be low and the GPU or CPU cranking at near 100% utilization. That simply means the game is demanding and the CPU and GPU just aren't up to snuff. It's entirely another for the frame rate to be low and the CPU and GPU just twiddling their thumbs at 50% utilization. That just means the game is poorly optimized, the program simply written in a way where the CPU or GPU can't work at their full potential. At this point, it's lack of software optimization, rather than hardware performance holding back the game. This certainly seemed to be the case in this particular scene under OpenGL.


Switching Gears

Given the software-limited nature of the performance dips, I decided to try switching the rendering API. OpenGL was bogging down. What could Vulkan do for me?

In short, a lot. I switched to Vulkan, and it was like night and day. In this particular scene, my frame rates jumped as if they had been given a steroid injection. We're talking from 70fps to 110fps. Not only did my frame rates go up, even better, under Vulkan my CPU and GPU utilization also enjoyed a healthy increase.  These were all great vitals indicating the power hungry program was able to better hook up with the powerful hardware. Given an APIs very purpose is to serve as a link between hardware and software, these kind of metrics are exactly what you would hope for from a good API: High utilization. High frame rate.


Proof In The Pudding

But enough talk. Don't take my word for it. Go see for yourself in the attached screenshots. Take careful note of the MSI Afterburner readouts in the top left of the screen. Most importantly, notice the GPU, CPU, and RENDER stats. I have provided a little key to better parse through the MSI Afterburner readout.

GPU: TEMP, % USAGE, CORE CLOCK
MEM: (Not important here)
RENDER: FPS
CPU: TEMP, % USAGE
RAM: (Not important here)

Note:  All settings Ultra, Resolution 1920x1080x144hz, G-Sync Enabled, Intel Core i5-2400 @3.6Ghz, Nvidia Geforce 970 4GB, 8GB System Ram, Windows 10 64 bit



Scene 1 - Argent Tower (Level Start)


 OpenGL


Vulkan

 


Scene 2 - Argent Tower (Overlook)


OpenGL


Vulkan




Or More Concisely


Scene 1
APIFPSGPU UtilizationCPU Utilization
OpenGL9180%64%
Vulkan10998%75%
% Difference19.78%22.50%17.19%



Scene 2
APIFPSGPU UtilizationCPU Utilization
OpenGL7167%62%
Vulkan10992%92%
% Difference53.52%37.31%48.39%

What it comes to is this:  In each scene, compared to OpenGL, Vulkan shows better frame rate, better CPU utilization, and better GPU utilization. Essentially, Vulkan is able to take significantly better advantage of the hardware. This kind of efficiency is laudable in and of itself. But it's even more impressive when you realize it's not just a bunch of numbers or efficiency for efficiency's sake. It's the power to better utilize existing resources.  It's the power to take the player from lowly lag fest to butter smooth frag fest.  If this example is anything to go by, Vulkan has the potential to pack a game-changing punch.


No comments:

Post a Comment