Graphics‎ > ‎

Graphic API

Glide will rise again

The interface to a graphical system. For the details of how the hardware works look at the GPU section. There are also pages on how to Debug Graphics and to Optimize Graphics.

3D: Low Level
Vulkan - 2016, DirectX12 - 2015 and Metal - 2014

Low Level API's that aim fit the current GPU systems better then the old graphic API's such as OpenGL/DirectX. This is done by getting rid of most of the state management and handing that responsibility over to the application instead.

Immutable objects
Many objects are created in full before they are used. It makes it possible to verify everything at creation time. Create functions take a structure with everything there is to know about the new object. In DirectX12 the structures are namned *_DESC and in Vulkan *CreateInfo.

Command Buffers
The API is used by the CPU to write commands to memory. The memory area is called a command buffer. Only the driver know the exact format of the commands as they depend on the GPU. Once we are done building the command buffer we submitt or queue it for execution. The CPU can then start building a new command buffer and the GPU will begin reading and processing commands from the completed buffer when it reach it in the queue. Command buffers can be recorded at the same time on more then one thread. The GPU always consume in the order submitted to a queue but there can be more then one queue available.
  • Free-threaded record/submit. There is no global context but you need to make sure to not access a object at the same time as another thread.
  • No state inheritance across buffers.
  • D3D12: ID3D12CommandList and ID3D12CommandQuueue
  • Metal: MTLCommandBuffer and MTLCommandQueue
  • Vulkan: VkCmdBuffer and VkCmdQueue
Pipeline State Objects
A PSO is a single object that encapsulates almost the entire GPU state. Instead of micromanaging state changes one switch the whole state directly. The PSO contain the shaders for all the stages so one PSO is needed for every combination of shaders. Resource bindings such as vertex/index/constants buffers and textures are not part of the PSO.
  • D3D12: ID3D12PipelineState

3D: State Machine
  Direct3D - 1995 and OpenGL - 1992

Before the programmable GPU the graphic card was a glorified fixed function state machine. It was configured by enabling and disabling certain features. If you need texture mapping set the texture flag, is blending your thing set all the parameters you need for it. So that's what the API's like OpenGL and DirectX did. They let you set all the states or put them in objects to make it possible to change some of them at the same time. When it's finally time to draw something on the GPU all these states are checked, validated and merged to create the current state that will be used for the rendering. Everyone using one of these API's ask 'why is nothing displayed, what state flag did i miss' once a week.
3D: Obsolete
Mantle - 2014 and Glide - 1996

Old and ancient 3D API's that are no longer in use.

3D: Software
Software : 19xx

Without any GPU to help out one needs to use software rendering. The rendering is done on the CPU and then moved to the video memory for display.

SFML - 2007
SDL - 1998