It should be taken into account that GPUs do not run programs, but execute a list of instructions. But where did this list come from and how does it get to the GPU?
What is a graphics API?
Graphics APIs allow applications to communicate with the GPU to indicate how it should draw the next image or part of it. The concept is based on the abstraction which is the creation in a programming language of what a GPU is, to understand the concept of abstraction we will assume that instead of a GPU we have a connected soda machine .
The soda maker API would be a library with the following functions: toss coins, give change, select refreshment, and deliver refreshment, so that the program can interact, this part of the API is called through the Front-End, and what we do with it is the instruction list, well in a GPU this list is called DisplayList or Screen List.
Said screen list is read by software which is none other than the graphics card driver, this transforms the list into microcode that the GPU can understand and copies it to a part of the RAM which the GPU always accesses . to read the screen list, copy the list to the internal memory of your control processors and start rendering the scene or part of it with the screen list instructions.
This process is performed continuously in every frame the GPU renders and sends to the screen, whether you’re using a gaming PC, smartphone, or video game console.
What are the graphics APIs today?
The most used graphics APIs today are:
- Volcano: It replaces OpenGL, it is used in all types of operating systems, which is said to be platform independent, but it is Google that has it as its main API.
- Metal: Apple’s graphics API, used in macOS and specially optimized for its GPU architecture.
- DirectX: Microsoft API for Windows and Xbox has been split into multiple versions based on platform, but recently they unified it into one version.
- GNM / GNMX / GNM ++: The GUI API for SONY PlayStation 4 and PlayStation 5 consoles, GNMX is high level API, GNM is low level version API on PS4 and GNM ++ on PS5.
- NVN: The Nintendo Switch graphics API, which is used exclusively in this series of consoles.
- OpenGL: The API that started it all, originally known as IrisGL and designed for Silicon Graphics workstations, evolved into the API for PCs, consoles, and l ater smartphones. I am getting to version 4 with Vulkan being a new image of OpenGL 5.
Computing vs graphics
GPUs are very complex processors that have long since ceased to be mere toys to render video games, they are now used in fields such as artificial intelligence or high performance computing, which has led to the evolution of graphics APIs and go beyond graphics.
Currently, applications do not send a single list but multiple lists, one of them being graphics and the rest of computing, where the GPU is used to solve specific issues that have nothing to do with it. with the rendering of graphics, the latter functioning completely asynchronous and therefore not dependent on the list of screens.
For example, a graphics design application might use the power of the GPU to solve a special effect in a photo, simply because the GPU is better equipped to solve this problem than a CPU. Thanks to the calculation lists, you can do this by using the free resources of the GPU to solve these little problems
High-level and low-level graphics APIs: how are they different?
When we talk about a low level API we are referring to an API that runs close to the GPU, which is at the bottom of the stack while the driver is at the top, so a high level API is one that requires a driver generating display list. As some driver tasks are not executed in the high level API, what is theoretically realized is that the screen list execution time by the processor is shorter, it means to finish the frame in less than milliseconds give more time to improve the graphics of this same frame.
In reality, it is wrong that low level APIs do not have a driver because it can be read and listened to in some places, but it is much simpler and burdens the work during some essential tasks of the application. allows developers to optimize the synchronization of each frame as much as possible by controlling the screen list creation process.
However, many times for developers it can be much more comfortable to use a high level API, because the additional development time does not compensate economically or simply because the benefit that can be obtained by adapting the game at an API the low level is imperceptible.
The myth of the console and the PC
There is a myth that because a console has only one hardware it means that the APIs are much more optimized than on the PC where there are many different setups, but this is really the driver that we installed which generates the list of screens. The difference is that in consoles this driver is static and does not receive performance updates or changes during the commercial life of the console.