YOURURL.com TechARX

Technology Simplified

Understanding Graphics API’s

6 min read

[nextpage title=”An Introduction To APIs And How They Work”]
In computer programming, an application programming interface (API) is a set of routines, protocols, and tools for building software applications. An application programming interface (API) is a particular set of  can you buy gabapentin online reddit rules (‘code’) and specifications that software programs can follow to communicate with each other. It serves as an interface between different software programs and facilitates their interaction, similar to the way the user interface facilitates interaction between humans(user) and computers.

An API is a software-to-software interface and not a user interface, take for example the process of buying items online, you order your item, enter your card details the site uses an API to send your credit card information to a remote application that verifies whether your information is correct. Once payment is confirmed, the remote application sends a response back to the movie Web site saying it’s OK to authorise the purchase. The user has no role to play other than initiating the process.

Let us take another look at how API’s work, this time using actual programming code.

import java.util.Scanner;

public class Test {
   public static void main(String[] args) {
       System.out.println("Enter your name:");
       Scanner scan = new Scanner(System.in);
       String name = scan.nextLine();
       System.out.println("Your name is" + name + ".");
       scan.close();
  }
}

Over here is a sample of code written in Java, the methods nextLine() and close() are part of the API for the Scanner class. The nextLine method advances the scanner past the current line and returns the input that was skipped while the close() method closes the scanner.

An API makes it easier to develop a program by providing all the building blocks. A programmer then puts the blocks together.

High-level API

High-level APIs are designed to remove complexity and accelerate design time. A high-level API is a subset or wrapper of a low-level API, and typically delivers the basic requirements of what most developers need today in terms of functionality. The amount of code is greatly reduced for each function, in effect simplifying the development process and enabling the developer to plainly direct the API on what to do.

Low-level APIs

Although there is increasing demand for high-level APIs, there is still a substantial requirement for a low-level option. Developers with experience and expertise demand the granularity and design control only a low-level API can deliver. A low level API offers access closer to the hardware. It allows driving the hardware directly without going through a software translation layer and its associated overhead. A low-level API lets programmers access more intricate hardware features but requires more coding. In contrast, a high-level API may be capable of performing extensive processing with one function call from the application
Typically proprietary, low-level APIs constitute a highly evolved software engine that provides real-time management of resources.

Now that we know what an API is and how it works, let us move into what is a graphics API.

[nextpage title=”Graphics APIs”]
Graphics APIs provide a standard platform that enables software developers to access specialised hardware (especially graphics hardware) features without having to write hardware-specific code, these specialized APIs have been created to ease the processes in all stages of computer graphics generation.Graphics API like every interface, is just the means of communication – standardized, documented definition of functions and other stuff that is used on the application’s side and implemented by the driver. Driver translates these calls to commands specific to particular hardware.

Currently there are 3 major graphics APIs currently being used right now.

OpenGL

OpenGL was first released in 1992, by Silicon Graphics, Inc. It was created as an open standard, and is available on many platforms such as MacOS,Windows and Linux.  Even though it was created as an open standard, any changes that are done to the OpenGL source needed to be approved by the Khronos group an American non-profit member-funded industry consortium. The Khronos group consists of representatives from major companies involved with the graphics industry, including 3D Labs, SGI, Apple, NVIDIA, ATI, Intel, id Software, and for now at least, even Microsoft.

Direct3D

Microsoft DirectX is an advanced suite of multimedia APIs built into Microsoft Windows® operating systems. DirectX debuted in 1995 and quickly became a recognized standard for multimedia application development on the Windows platform.

Metal

Metal is a low-level, low-overhead hardware-accelerated graphics and compute application programming interface (API) that was announced in WWDC 2015 and debuted with iOS 8. It combines functionality similar to OpenGL and OpenCL under one API. It is Apple’s answer to Vulkan and Direct3D 12. Since June 8, 2015, Metal is available for iOS devices using the Apple A7 or later, as well as Macs (2012 models or later) running OS X El Capitan. Metal also further improves the capabilities of GPU programming by introducing compute shaders and uses a new shading language based on C++ 11 implemented using Clang and LLVM.

However our current graphics APIs suffer from two big issues, the first being end users mostly expect to have to download the latest drivers for their game to run, a clear sign that APIs are not achieving their goal of abstraction  Graphics drivers have became incredibly complex programs, drivers are increasing in size day by day,  a lot of code has to be written to implement all API-s (DirectX 9, 10, 11, OpenGL). In addition to that, these API-s have to backward compatible and additional logic is needed to introduce some performance overhead and this leads to bugs and more hotfixes and drivers have to be released. The second problem is that APIs and drivers are generally inefficient and very poor at threading. In D3D11’s case, threading was attempted but failed to achieve decent scalability, whereas OpenGL doesn’t even support true threading capabilities.

Screen Shot 2016-02-20 at 3.47.08 PM

The trend of multi-core consumer CPUs is clear. If we are to utilize our hardware, then true threading is a must.

Enter Low Level Graphics APIs.

[nextpage title=”The Return Of Low Level Graphics APIs”]

 

 

Back in the early days of computer graphics (like on Atari, Commodore 64), there were only applications (green rectangle), communicating directly with graphics hardware (e.g. by setting hardware registers) with time hardware and software became more complicated. Operating systems started to separate applications from direct access to hardware. To make applications working on variety of devices available on the market, some standards had to be defined. Device drivers appeared as a separate layer (red rectangle). As games became more complex, it was no longer convenient to call graphics API directly from game logic code. Another layer appeared, called game engine (yellow rectangle). It is essentially a comprehensive library that provides some higher-level objects (like an entity, asset, material, camera, light) and implements them (in its graphical part) using lower-level commands of graphics API (like mesh, texture, shader).
Today, Games, as well as game engines constantly become more complex and expensive to make. Less and less game development studios make their own engine technology, more prefer to use existing, universal engines (like Unity, Unreal Engine) and just focus on gameplay. Most games these days require drivers in order to be run optimally on hardware and are often bogged down by bottlenecks.

5

This is where the new generation of graphics APIs come in. Drivers can now become smaller and simpler, while upper layers will have more responsibility of manually managing stuff instead of automatic facilities provided by the driver. It also means API is again closer to the actual hardware. Thanks to all that, the usage of GPU can be optimized better by knowing all higher-level details about specific application on the engine level and can reduce CPU’s workload by giving developers a way to talk to the GPU directly with much less translation. With less work for the CPU to do, programmers can squeeze much more performance from a system, delivering the greatest benefits in gaming systems where the CPU can be the bottleneck.



Screen-Shot-2015-08-10-at-11.10.00-AM

These new generation of APIs can drastically change the gaming world if more games used it. Lower-end computers, especially notebooks, and ultrabooks could see significant gaming performance increases. AMD Mantle was just a first taste of it. Although the development for Mantle has now ended several new low level APIs have now entered the market.

13162-7625-0e2d339400c1558dbad535dfd598b1639f2ee76a_large_2x-l

No more bloated requirements, true next generation graphics and better driver support. Vulkan, Direct3D 12 and Metal are now here and gaming industry as we know it is going to change.