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.


Tuesday, September 12, 2017

The Storm

It all started late last night.  The rain was pelting.  The wind was howling.  The weather was stewing with all the pent up ferocity of an atmospheric temper tantrum.

I lay in my bed, the covers tightly tucked under my chin.  Even from my cozy cocoon, the presence of the storm was powerfully intimate. I could almost feel the tempest pressing up against the window beside me.  The warmth of my covers felt heightened, juxtaposed against the shower soaked window.  I cracked the window slightly to better hear the rain. The poignant pitter-patter was strangely serene.

I lay my head back into the comfy confines of my pillow, listening to the rain-drop parade.  The winds and rain swelled together in alternating crescendo.  First a measure of relative calm.  Next a bar of vehement volume.  Then, right as the crescendo would approach near-uncomfortable levels, the storm would once again gradually subside.

The pattern of alternating crescendos continued, a torrential tide ebbing and flowing with rhythmic cadence, back and forth amidst the black backdrop of night.

I pulled the covers tighter.  Once again the winds and rains swelled with symphonic crescendo.  This time the crescendo sustained, a line of drummers striking with unrestrained vigor, struggling to maintain their loudest.  The tension mounted.  It felt as if something were about to burst.  Something had to give.  Then, it did.

The crescendo ended in emphatic crash, a pair of cymbals clanging together in the air.  A guttural rumble ripped through the house, traveling through the foundation and spreading up the walls, a thunderous sound felt as much as heard.  

Reflexively, I sat straight up in my bed, eyes and ears open.  My heart pounded.  My mind raced.  What was that?  Thunder?  Rare for Alaska.  An earthquake?  More common, but this seemed different.

I got out of my bed.  My feet hit the cold floor.  Slowly, one by one, lights came on in the pitch black house as the family congregated in the living room, curious.

We made our way toward the wrap-around-deck, the sound of the sliding glass door opening barely audible over the roar of wind and rain.  The deck lights sparsely illuminated the sheets of rain like an under-powered flashlight, barely piercing into the night.  There amidst the wind-tossed rain lay the tangled outline of a silhouette.

We ventured out further, arms hugged across chests for warmth.  There in a twisted mass of splintered wood and corrugated roofing lay the trunk of a tree, nearly completely horizontal.  The wet leaves and branches sprawled out across the deck haphazardly like a rag doll corpse.  The wind-whipped rain rolled down our faces and tugged at our hair as we pushed forward to examine the damage.

Soon it became clear.  Eyeing the length of the tree, we followed the trunk back.  Off in the distance, the base of the tree and roots were unscathed, still resiliently planted in the ground.  The tree hadn't simply fallen.  It had been snapped in half, violently cracked in two like a twig.  The top half of the tree had then careened into the deck, snapping the railing, downing the awning, and taking various chairs and deck ornaments with it, all in one thunderous, house-rumbling fall.

Coming back inside, we could still feel the weight of the wind pressing into the walls of the house.  We looked at each other and smiled nervously, but affectionately.  There's nothing quite like the shared midnight crisis of a storm to spark the bonds of family or renew your awe of nature.  Hugging, we went back to our beds thankful the tree was on the deck and not in the house.