what API does, and how it does it?

721 views

I’ve always just clicked the box to use newest directx and now I saw a new API named Vulkan enter the market. What these software actually do with gpu to make flashy things in your monitor?

In: Technology

3 Answers

Anonymous 0 Comments

The way things get drawn on your computer screen is that your computer has a range of memory that’s dedicated to storing the pixels on the screen. 60 times per second, your graphics card takes whatever’s in that chunk of memory and sends it all to your display using your DVI or HDMI cable.

Let’s say your screen is 1920 x 1024 pixels large. The memory would be 1920 x 1024 x 4 bytes large, with 4 bytes for each pixel – one byte each for red, green, and blue. The last byte is used internally for transparency but ignored by your display. A byte stores numbers from 0 to 255, where 255 is bright and 0 is dark.

To turn the entire screen blue, the computer needs to write 0, 0, 255, 0 into all of the pixels in memory.

Pretend that the memory was a giant whiteboard and you needed to write all of those values on it.

Your CPU is like a superfast writer holding a single dry-erase marker. Your CPU can scribble a billion numbers per second, but despite that amazing speed it can only write one number at a time.

Your GPU is like a hundred third graders holding dry erase markers led by a teacher. The third graders aren’t quite as fast at writing, but they’re very obedient. The teacher can call out instructions and they can all grab a different corner of the whiteboard and fill in their section as fast as they can.

Even though each individual third grader on the GPU isn’t quite as fast as your CPU, because there are a hundred of them all working in parallel, they can turn the whole screen blue in a fraction of the time.

GPUs aren’t better or worse than CPUs. There are some things GPUs do really well – things that you can easily parallelize. There are other things CPUs do really well – complex calculations that can’t be split up into small pieces.

Finally, let’s get to an API.

The people making a game want to make use of your GPU to draw their fancy graphics on the screen as quickly as possible, so you can have more realistic graphics and more frames per second.

The problem is, there are so many different GPUs, and they keep coming up with new ones every year. Every GPU works a little differently and has different specs.

In the analogy, imagine that it’s different classes of students with different number of students, and teachers who speak different languages.

The API is the abstraction over all of this. You just tell the API what you want to draw, and the API translates that to whatever specific GPU you have.

OpenGL and DirectX were the most popular APIs for many years, but they were getting less efficient at translating things for modern GPUs. They weren’t doing a good job of keeping them busy, and they didn’t know how to work well with multi-core CPUs.

Vulkan is a new API that solves these problems. The graphics code of games have to be rewritten to use Vulkan instead but if they do, they can potentially get some better performance.

Hope that helps!

You are viewing 1 out of 3 answers, click here to view all answers.