The rendering architecture in OpenGL is shown below

It is mainly divided into two modules

  • Client: refers to common iOS code and OpenGL API methods, which are run on the CPU
  • Server: refers to the underlying rendering processing of OpenGL, which runs on the GPU

The architecture analysis

  • In the client, the method in OpenGL API is called by iOS code, and the data related to graphics rendering is transmitted to the vertex shader and chip shader in the server through the channel, and then handed over to GPU for processing.
  • The server receives the transferred data through the channel with the client, and renders it to the corresponding shader, and renders the final result to the screen

The data transfer

As can be seen from the figure, there are three channels for data transfer between client and server

  • Attributes
  • Uniform
  • Texture Data
The name of the channel The parameter types Passable shader
Attributes Frequently changing data: texture coordinates, lighting normals, vertex coordinates, color data Vertex shader
Uniform Data that do not change very often Vertex shader, slice shader
Texture Data texture Vertex shader, slice shader

Attributes

  • The Attributes channel can only pass data directly to the vertex shader, not directly to the slice shader, but indirectly to the slice shader through the vertex shader.
  • Passing Attributes is usually data that changes frequently, such as colors, vertices, and so on.
  • Attribute passes parameters like color data, vertex coordinates, texture coordinates, lighting normals, and so on.

Uniform

  • Uniform passes can be passed to both vertex shaders and fragment shaders.
  • Uniform data is usually passed in batches that do not change very often.

Texture Data

  • Texture Data, like Unoform, can pass Data to vertex and slice shaders.
  • Since vertex shaders are mainly for vertex data, it doesn’t make much sense for us to pass texture data. The logic of texture processing is mainly carried out in the chip shader.