Logo

Graphics API

Show lesson content
Graphics API
In this video from ITFreeTraining, I will have a look at graphics APIs. Graphics APIs provide a standardized way for software to access 3D hardware. Nowadays, the software handles access to the APIs very transparently; however, having an understanding of how they work and what they do may help you troubleshoot problems.

Application Programming Interface
To start with, I will first look at what is an Application Programming Interface or API. An API is essentially an interface that defines interactions between software. Rather than attempt to explain what it is, let’s consider some examples.

Let’s say that you have a user that runs some software that displays 3D models. In order for the software to do this, the software calls other software to do it. In this case, it calls the API. Think of the API like a tool kit. It essentially takes high-level requests and processes them.

In this example, the 3D models are transferred to the API to be processed. The API handles the

high-level request. A high-level request is essentially more task driven and is implemented to get a task done rather than specify how it should be done. A low-level request is essentially the steps involved. For example, if you wanted to clean a room, the high-level request would be to clean the room. There may be some guidance there, for example there can’t be anything on the floor or everything needs to be packed away. Low-level functions would be the steps involved like picking up an item and putting it away.

The 3D engine being used will perform a lot of the functions such as reading the 3D models from storage. It may also need to convert them to a structure the API understands. Since the API is like a toolkit, it may do further conversion of the data provided, so for example, breaking it down into smaller parts for the next step. The API may also do tasks like scheduling the requests for processing. In this case, the API may send the 3D different models to three different threads for processing.

So far, the 3D engine only needs to worry about transferring the 3D model to the API in a format that the API understands. You may be thinking this sounds like a function the device driver may handle, however the device driver handles the low-level requests. Low-level requests are the individual steps involved. As with cleaning a room, the low-level requests would be the individual steps involved. In this case, the 3D models are broken down by the API into simple shapes and textures since the device driver can only handle simple requests.

The device driver has direct hardware access to the video card, thus sending instructions and data directly to the video card so an image can be displayed on the monitor. Using this method gives a lot of stability and flexibility.

For those who remember the early days of computing, they may remember how many times computers would crash. Software could directly access hardware and in the process crash a computer. By contrast, in modern computers hardware access is strictly controlled. This limits the ways software can potentially crash the computer making it more stable. This is why software needs to access a device driver in order to access hardware.

The next point to consider is that having a device driver provides a standard way to access hardware. For example, if you changed the video card, you would need a new device driver for that video card. The way the software accesses the device driver has not changed, and thus it provides a standard way to access the video card on the computer.

You may be thinking, if the device driver provides a standard way to access the video card, why do you need an API? The API provides a further layer of standardization but does this at a high level. Let’s look at an example of why that becomes useful.

API Provides Additional Functions
An API also provides additional functions that may not be provided in a device driver; in this example, the API provides software emulation when the hardware does not support it. In this example let’s consider that, as before, our user is running the same software and is attempting to display the same 3D models as before.

If nothing has changed, the software will access the API which will convert and schedule the 3D models into a format that the device driver can understand. The device driver communicates with the video card. The video card in turn displays the image on the monitor. So far nothing has changed from the previous example.

Now let’s consider that the video card has failed. It is going to take a few days to get a replacement video card, but the user wants to keep using the application until a replacement arrives. There are no replacement video cards available, but you remember the CPU has built in video, so you plug the video into the monitor and install the required device driver.

The computer is now up and running, however the problem is that the CPU only has basic video functions and has very limited 3D functionality. The 3D models the software is trying to display can’t be displayed using the hardware in the CPU.

To get around this, the API provides software emulation for the missing 3D video functions. This emulation means that basic video in the CPU is able to display 3D models on the monitor. This of course will be slower than if done via hardware, however the user is able to still use their software until a replacement video card arrives.

The API can also provide software emulation for features that have not even been released in hardware. For example, a hardware manufacturer may be working on a new feature, however they are still working on how it will be implemented in hardware. The developers of the API can implement the feature in software using emulation or put a function in place that does nothing until it is implemented in hardware.

It may seem strange that you would want to implement a function that does nothing, however this allows software developers to create their software to call this function even though it does nothing. When this function is later implemented, the software will be able to take advantage of this feature. Essentially it is like future proofing your software.

You can see in this example, from the software perspective, the process it uses to display the 3D models on the screen has not changed. It uses the API the same way. The API worked out what features the CPU has and does not have. Using this information, the API then worked out what it needed to emulate and what it could do in hardware. This was all done with no changes to the software. The software simply puts the request through, and the API worked out how to complete it.

You can see that an API has a lot of advantages for hardware changes, but it also works with software changes.

Cross OS Support
Using an API, if available for different operating systems, reduces the number of changes required to software to allow it to run on a different operating system. For example, the software in our example is designed to access graphic functions using the API. If the API has been designed to run on different operating systems, this reduces the number of steps required to be changed in the software so that it would run on that operating system.

You can see that using an API gives a lot of flexibility. If the API is available across operating systems, it reduces the amount of work to port software between those operating systems. It provides a standard way for programmers to access graphics functions, without the programmer needing to know what hardware is available on the computer. The API can also provide software emulation if a required feature is not available in hardware. Now that we understand the basics of how an API works, let’s next have a look at an API.

DirectX (Microsoft)
The first graphics API that I will look at is DirectX. DirectX was first released in 1995 and has gone through a number of different versions; when this video was created the newest version was version 12.

With the release of Windows 95, Microsoft realized that graphics support in Windows was not good enough for multimedia, particularly when comparing it with DOS. DOS was a lot faster because it allowed direct access to the hardware. The problem with allowing direct access to the hardware is that it makes the computer less stable and more likely to crash.

DirectX was released in Windows 95 as an addon to improve multimedia support. As the name suggests it provides direct access to the hardware. When they say direct access, there are still controls in place to prevent software from performing operations that may crash the computer. Essentially the DirectX API provides a low overhead way of safely accessing the hardware. Although I will primarily look at graphics, DirectX also allows access to sound, keyboard, mouse and timing functions. The standard Windows API has a lot more overhead; however, for general applications that do not require fast responses, for example fast screen updates, the Windows API works quite well. Thus, DirectX provides the graphics API required for better performance, mostly for multimedia applications.

Nowadays DirectX is part of Windows and updated through Windows Update. It is no longer an addon as it was in Windows 95. It is not something that you can uninstall and if you worked out how to remove it, may cause Windows to not run correctly.

In order for software to use DirectX it has to be coded for a particular version. For example, if your version of Windows supports DirectX 11 and DirectX 12 and your software is coded for DirectX 11, it will not be able to use DirectX 12. In order to get the software to use DirectX 12, the code needs to be modified to support it.

This may seem a strange way of doing it, but it is done for good reasons. Essentially what it means is that each version of DirectX could be completely rewritten, and the interface completely changed. Computers have changed a lot since Windows 95, so having a new API for each version essentially means that DirectX can change as required and does not have to be limited by what was done in a previous version in order to remain compatible. The downside is, that for software to take advantage of a new version of DirectX, coding changes need to be made.

Since DirectX is now part of Windows, different versions of Windows will support different versions of DirectX. For example, Windows 10 supports DirectX 9 and above. For this reason, software needs to support the operating system and the version of DirectX it supports. From a support perspective, with the newer operating systems, you just need to ensure that your Windows is up to date. In some rare cases you may need to manually install an update if you are experiencing a problem with DirectX and an update has not yet been released through Windows Update. This should, however, be rare.

Each version of DirectX introduces new features. With version 12 of DirectX there have been a lot of improvements. I will now look at some of the more important new features.

The first big improvement is better support for low-level programming of graphics cards. The main reason this is important is for programming the cores on the graphics card. Being able to directly program each core allows for better parallel processing. Better control over parallel processing means that better performance can be achieved.

The next big improvement is that there are significantly less draw calls. A draw call is essentially performed each time DirectX is told something about vectors, textures, shaders or anything else in relation to displaying graphics on a screen. One of the ways DirectX reduces this is by allowing a large number of draw calls to be grouped together. The advantage of this is that it reduces the amount of load on the CPU since it has to perform fewer draw calls. The next advantage of grouping the draw calls like this is DirectX is given a group of instructions all at once, and having a group of draw calls all at once allows for better scheduling of draw codes across threads.

To understand this better, consider that you have a restaurant that is selling food to the public. If 100 people were purchasing food and they did it one at a time this would be 100 orders or 100 draw calls. However, if the 100 people got themselves into groups of ten, one person from each group could give the restaurant a call and order for their group, thus you have ten draw calls rather than 100.

Let’s consider what this achieves. If the person taking the orders is the CPU, that person now only has to take one tenth of the orders that they had to take before, thus there is less loading on the CPU. The restaurant is now getting a batch of orders rather than just one. Having a group of orders like this allows for much easier allocation to the workers. For example, it is a simple matter if you have three workers to divide the orders into three and give a third to each worker. You can see why reducing the draw calls reduces CPU overhead and also allows for easier and more efficient scheduling of the workload. Thus, this is one of the big reasons why the current version of DirectX offers better performance over previous versions. This will become more and more important as our 3D worlds become more complicated containing more objects, meaning we need to be more efficient when the graphics cards are drawing these worlds.

The next big improvement is multi-adapter support. Nvidia and AMD both have multi-adapter support in the form of SLI and Crossfire respectively. DirectX works with these directly or it can also use adapters where one or other is not supported – for example, video cards of different models or from different manufacturers. Having said this, you do require a 3D engine to support this. It is difficult to support two video graphics cards of the same type and model. For this reason, there is not a lot of software that supports this feature. We could only find one game that supported this feature. Potentially this is a nice feature, however due to the difficulty of getting it to work and the limited amount of market share that would use it, I doubt we will see much support for it in the future.

I will now have a look at how to determine what version of DirectX you are running.

DxDiag
To determine the version of DirectX you are running and if it is running correctly, Windows includes the DirectX Diagnostic Tool. To use this tool, run DxDiag from the start menu. The first screen gives a lot of general information about the computer. A lot of this information is in other places in Windows, however the most important information is the version of DirectX which is being run. In this case, you can see that the version of DirectX running on this computer is DirectX 12.

At the bottom left of the screen you can see there is a tick box for “Check for WHQL digital signatures”. If this tick box is ticked, the device drivers will be checked to make sure they are Windows Hardware Quality Labs or WHQL drivers. WHQL drivers are device drivers that have been certified by Microsoft labs, indicating that the hardware and other components work as expected with Windows. This does not guarantee there will not be problems, but essentially means the device driver has gone through some additional testing to ensure that it is stable.

The WHQL process takes some time to complete and does have a fee attached to it; a company must pay in order to have the device driver and hardware tested. For this reason, not all device drivers will be tested by a company. You will also find that newer device drivers may not be WHQL compliant because they have not completed the process yet or that the company does not wish to pay the fee to get it done. If the newest device driver is WHQL compliant, happy days, I would suggest using that device driver, but if not, it is an individual choice if you wish to use that device driver. The advantage of using the newer device driver is you get newer features; however, it may not be as stable.

The next tab is the display tab. If you have multiple video cards, which is the case on this computer, there will be multiple display tabs. At the top of the screen is some information on the device driver. Also, at the top is the name of the device driver which is useful for determining which video driver the tab is referring to.

On this screen you can also see the amount of dedicated memory that is present in the graphics adapter. In this case, since the graphics adapter is in the CPU it is only 128 Megabytes. However, it does have access to the memory in the computer but note this memory will not be as fast as dedicated memory is.

On the right-hand side of the screen is information about the device driver. This includes information about the release date. If you find that you are having problems with a device driver, it may be that you are running an old device driver and it needs to be updated.

In this section you can see that this device driver is WHQL certified. If you are experiencing problems and not running a WHQL device driver, it may be worth changing the device driver to a WHQL device driver even if it is an older one.

In the middle of the screen you will notice the DirectX features. DirectX has been around since Windows 95 so is essentially nothing new. The vast majority of device drivers should support these features. If you find a feature is not supported, most likely the operating system has not found a device driver for that graphics adapter and is running a default one. When this is the case you should update the device driver to the correct one.

At the bottom you will notice a notes section. This section will display error messages if there is a problem. For example, if the device driver is not running correctly you may see an error message there.

That is it for the basic settings under the display tab. If I now select the next tab, display 2, you will notice the same settings for the next display adapter, in my case this is my graphics card. Make sure when you run this tool you are looking at the right tab otherwise you maybe troubleshooting the wrong device.

The next tab is the sound tab. Sound is nothing new in a computer and although it has improved since DirectX was first released, it has not really advanced that much when you compare it to graphics. For this reason, generally you will not have too many problems with sound.

For each sound adapter in your computer there will be one sound tab. Since I have two sound adapters on this computer there will be two tabs. There is not much to look at here so I will move on.

The last tab is the input tab. You can see on this tab other devices are listed, for example, mouse and keyboard. DirectX allows low-level access to these devices. This is important because with devices like the keyboard the standard interface will detect keys pressed, however it is not good at detecting when multiple keys are pressed and held at the same time. This is a function that is particularly useful for applications like computer games.

That covers DirectX which is Microsoft technology. Since it is Microsoft technology, it is only available on Windows and other Microsoft products like Xbox. Let’s have a look at some other graphics APIs that you may come across.

Open Graphics Library (Open GL)
The next API that I will look at is Open Graphics Library or OpenGL. Open GL was released in 1992. Since then, there have been several different versions with the latest being version 4.6 released in 2017 when this video was created. Since that release date, it has continued to be updated.

Each new version of OpenGL added new features and offered good backward compatibility. However, during the development of OpenGL, there were some big changes to the way it operated, causing it to go in a different direction then what it had done previously. The result was new features that were not available under the old API and only available in the new API. The problem OpenGL started to experience as hardware changed was that it became harder to support the older API while putting in new changes and also keeping the API performing well. For this reason, it was replaced with a newer API called Vulkan which I will look at next. Essentially OpenGL is now only around for backward compatibility.

The biggest advantage OpenGL has is that it supports all major operating systems, that is Windows Macintosh and Linux. OpenGL comes with the graphics device driver. In order to update OpenGL, update your graphics device driver.

OpenGL is also used with mobile devices. Given that DirectX is only used in Microsoft products, you can see why OpenGL was very popular as DirectX is not an option on these devices.

Back in 1992, computers and hardware were very different from what they are today. For this reason, OpenGL was designed before multi-core GPUs and CPUs. As time passes it becomes harder and harder to keep updating an old API designed originally for different hardware, and this is why OpenGL has now been replaced by Vulkan.

Vulkan
Vulkan is a 3D API designed to use GPUs and CPUs more efficiently. Effectively the Vulkan API supersedes OpenGL and all development is now being done on Vulkan rather than OpenGL. To understand Vulkan, let’s consider the history of it.

To start with, AMD created an API called Mantle. This API was released in 2013. This API was aimed at AMD GPUs. The API did not support all AMD graphics cards, as it focused more on the newer ones at the time. In 2015 development of this API ceased and in 2019 it was discontinued.

Mantle had the objectives of using CPUs and GPUs more efficiently – it did this by removing a lot of the overhead of API calls. It also allowed better low-level programming of the video card. Even though Mantle was discontinued in 2019, this was not the end.

The Mantle project was donated to the Khronos group. The Khronos group is an American non-profit-funded consortium focused on the creation of an open standard for graphics APIs (The Khronos group was responsible for the development of OpenGL).

The Khronos group combined Mantle and OpenGL to develop Vulkan which was released in 2016. Vulkan had the same objectives as Mantle. The big difference is that Vulkan was developed to support all graphics cards, not just those from AMD. Now Vulkan has good support for AMD, Nvidia, Intel and others.

Given the open nature of Vulkan, it is now supported on all the major operating systems. It is also supported on Steam OS and Android. Given that APIs like DirectX were only supported on Microsoft systems, there was a need for an API that is supported on a lot of different operating systems. The advantage of this is that if you are developing a 3D engine, porting it to a different operating system when the API is supported is a lot easier than porting the 3D engine to a new operating system and API.

Vulkan looks like it will have a promising future. Before I finish this video, I want to have a look at one last API.

Metal
The last API that I will look at is Metal. Metal was released in 2014 for Macintosh and first appeared in iOS 8. It was designed for Apple products and designed with the same principals as the other APIs, that is, low-level/low-overhead API for 3D graphics.

Essentially Metal is a competing API to DirectX and Vulkan. Vulkan has been released for Macintosh OS. The problem however is, device driver support may not be available to fully support Vulkan. To allow Vulkan to run, Molten VK was created which allows Vulkan to access the hardware using the Metal API.

MoltenVK was first released as a commercial product in 2016. In 2018, Valve came to an arrangement with the developer of MoltenVK to release it as open source. So essentially, without native device drivers that support Vulkan, MoltenVK provides a work around to get Vulkan to work on Macintosh OS.

I have had a look at all the main current graphics APIs, so I will now have a look at what this all means.

In the Real World
In the real world there are a number of different graphics APIs that are competing for market share. The main point that you need to remember is to update your graphics device drivers and operating system. Updating the device drivers and operating system will make sure that OpenGL, DirectX and Vulkan are up to date. Having the latest versions of these will hopefully give you better performance and also make them more stable due to bug fixes.

The choice of API is ultimately up to the developer to decide which one they will use. Unless you go looking, you probably won’t know which one they are using. Different APIs will give different results; however, if the developer has not programmed support for that API then it won’t be able to use it.

At present it looks like Vulkan is starting to get a lot of market share, at least for the moment. What happens from here will ultimately depend on which API can provide the best performance and features. If one of the APIs starts getting better than the others, developers may make the decision to switch to that API to get better results.

End Screen
That concludes this video from ITFreeTraining on different graphics APIs. I hope you have found this video useful and I hope to see you in other videos from us. Until the next video, I would like to thank you for watching.

References
“The Official CompTIA A+ Core Study Guide (Exam 220-1001)” Chapter 5 Position 128 – 132
“CompTIA A+ Certification exam guide. Tenth edition” Pages 784 – 785
“Vulkan (API)” https://en.wikipedia.org/wiki/Vulkan_(API)
“OpenGL” https://en.wikipedia.org/wiki/OpenGL
“DirectX” https://en.wikipedia.org/wiki/DirectX
“Getting Started” https://www.khronos.org/opengl/wiki/Getting_Started#Windows
“OpenGL” https://en.wikipedia.org/wiki/OpenGL
“Vulkan (API)” https://en.wikipedia.org/wiki/Vulkan_(API)
“Mantle (API)” https://en.wikipedia.org/wiki/Mantle_(API)
“Steam Hardware & Software Survey: April 2020” https://store.steampowered.com/hwsurvey/directx/
“Metal (API)” https://en.wikipedia.org/wiki/Metal_(API)
“Molten VK” https://en.wikipedia.org/wiki/MoltenVK
“Picture: Twin cogs” https://unsplash.com/photos/W3RjW1rnHN0
“Picture: Robot figurine” https://pixabay.com/photos/robot-figurine-toy-mascot-amazon-4004669/
“Picture: Tux” https://commons.wikimedia.org/wiki/File:Tux.svg
“Picture: Windows Logo” https://commons.wikimedia.org/wiki/File:Unofficial_Windows_logo_variant_-_2002%E2%80%932012_(Multicolored).svg
“Picture: MacOS” https://en.wikipedia.org/wiki/File:MacOS_original_logo.svg
“Picture: DirectX logo” https://en.wikipedia.org/wiki/File:Directx9.png
“Picture: Nvidia image logo ” https://en.wikipedia.org/wiki/File:Nvidia_image_logo.svg
“Picture: AMD Logo” https://upload.wikimedia.org/wikipedia/commons/7/7c/AMD_Logo.svg
“Picture: OpenGL logo (Nov14).svg” https://en.wikipedia.org/wiki/File:OpenGL_logo_(Nov14).svg
“Picture: Russian Matroshka” https://en.wikipedia.org/wiki/Matryoshka_doll#/media/File:Russian-Matroshka.jpg
“Picture: Vulkan Logo” https://commons.wikimedia.org/wiki/File:Vulkan_RGB_Dec16.svg
“Picture: AMD Mantle Logo” https://commons.wikimedia.org/wiki/File:AMD_Mantle_Logo.png
“Picture: Steam OS” https://hy.wikipedia.org/wiki/%D5%8A%D5%A1%D5%BF%D5%AF%D5%A5%D6%80:SteamOSLogo.jpg
“Picture: Android new logo” https://commons.wikimedia.org/wiki/File:Android_new_logo_2019.svg
“Picture: Apple Metal logo” https://commons.wikimedia.org/wiki/File:Apple_Metal_logo,_version_2.png
“Picture: Molten VK-Logo-Banner” https://en.wikipedia.org/wiki/File:MoltenVK-Logo-Banner.png

Credits
Trainer: Austin Mason http://ITFreeTraining.com
Voice Talent: HP Lewis http://hplewis.com
Quality Assurance: Brett Batson http://www.pbb-proofreading.uk

Lesson tags: comptiaaplus
Back to: CompTIA A+ > Installing, Configuring, and Troubleshooting Display and Multimedia Devices

Welcome to the ITFreeTraining free course on CompTIA 220-1001 and 220-1002 exams otherwise known as A+. This free training course will take you through all the exam objectives for the A+ exam and help you get ready to take the exam.

Modules

Installing and Configuring PC Components

Lessons

Installing, Configuring, and Troubleshooting Display and Multimedia Devices

Lessons

Installing, Configuring, and Troubleshooting Storage Devices

Lessons

Other Lessons

Memory Timings

Download PowerPointShow lesson contentMemory TimingsIn this video from ITFreeTraining I will look at memory timings. When you purchase a memory module, it will most likely have a whole heap of