Basic graphics hardware pipeline design

  • Application layer: The game and application layer software developers, through the call API for upper development, no need to consider the portability of the problem.
  • Hardware abstraction layer: abstracts the acceleration function of hardware, encapsulates it to the benefit of application layer development, and develops apis to the application layer.
  • Hardware layer: Hardware drivers are provided to the abstraction layer to realize the effectiveness of the abstraction layer acceleration function.

The detailed process of rendering the pipeline

The application layer

The application program mainly deals with memory and CPU, such as collision detection, scene graph establishment, visual cone clipping and other classical algorithms are executed in this stage. At the end of the phase, geometry data (vertex coordinates, normal vectors, texture coordinates, textures) and so on are transmitted to the graphics hardware via the data bus.

Hardware abstraction layer

In this layer, we are currently using DirectX, OpenGL, and Metal. For this part, mainly some API calls.

The hardware layer

The hardware layer is the most complex and important part of the rendering pipeline. The difference between a programmable pipeline and a fixed pipeline is that the shader can be programmed.

First of all, we understand the fixed pipeline, which is mainly divided into the following stages: vertex transformation → pixel assembly and rasterization → pixel texture mapping and coloring → rasterization operation.

Fixed rendering pipeline flowchart

Programmable pipeline flow chart

The main difference

The programmable pipeline supports editing of vertex shaders and slice shaders.

The relationship between CPU and GPU

Gpus have a highly parallel structure, so they are more efficient than cpus in processing graphical data and complex algorithms.

CPU can only process one data at a time when performing tasks, and there is no parallelism in the real sense, while GPU has multiple processor cores and can process multiple data at a time.

GPU structure

CPU structure

Can gpus replace cpus?

Obviously not. Cpus are good at complex operations such as branch prediction, and Gpus are good at simple operations on large amounts of data. One is complex labor, the other is a lot of parallel work.