what API does, and how it does it?

715 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!

Anonymous 0 Comments

It’s an Application Programming Interface. Basically a list of technical specifications about how to get something done.

The real life equivalent would be a set of forms and rules about how to submit those forms. “Fill in the name here, address there, mail this to that address, attach payment for $20, expect an answer in two weeks”.

In this case it’s a bunch of technical specifications about how to get the video card to draw something for you. How to tell it “I want an object this shape, here, and with this particular texture”. How is that data encoded, how it’s sent to the card, etc.

As technology evolves so does the way to best communicate with it. Early cards had limitations that needed to be taken into account. Modern cards have better capabilities. So ways to deal with old limits aren’t needed anymore, the hardware has room for more flexibility, etc, and that means the way you talk to it is also different.

Normally we just slightly change the spec over time, but sometimes it turns out we’d be better off if we started from scratch and rethought the whole thing. Eg, we throw out the entire “mail the form to this address” system, and put up a website instead.

Anonymous 0 Comments

the API is basically the middle man between your software and your hardware offering a set of commands that make programming the Hardware easier.

This is a huge time and headache saver for programmers that now dont need to program for every variation on hardware possible, instead they can program for a certain feature set and be safe in the knowledge that as long as the hardware is capable of doing the required instruction, the software runs.

in the case of DirectX is essentially acts a set of instructions a developer can use to instruct their software on how to leverage a GPU, no matter what brand or what it can actually do, Microsoft made this possible with DX by enforcing a set of GPU capabilities that have to be met for the hardware to be certified to use a certain version f the API.

Vulkan does the same thing but unlike direct X its not proprietary, so developers have a lil mroe freedom on what to do with it