Programmable Graphics Rendering pipeline

Source: Internet
Author: User
Tags dashed line

Other articles:

OpenGL: Rendering Pipeline theory

OpenGL rendering Pipeline

OpenGL ES 2.0 rendering pipeline


The shader program is divided into two categories: vertex shader program (vertex shader) and fragment shader program (fragment shader). To clearly explain the meaning of vertex coloring and fragment coloring, we start with the elaboration of two components on the GPU: Programmable Vertex Processor (programmable vertex processor, also known as vertex shader) and Programmable Fragment Processor (programmable fragment processor, also known as fragment shader).

Vertex and fragment processors are separated into programmable units, a programmable vertex processor is a hardware unit that can run a vertex program, and a programmable fragment processor is a unit that can run a fragment program.

Vertex and fragment processors have very powerful parallel computing capabilities and are very good at matrices (no higher than 4-step) calculations, and fragment processors can also query texture information at high speeds (the vertex processor is not yet, which is a development direction for the vertex processor).

As mentioned above, the vertex program runs on the vertex processor, and the fragment program runs on the fragment processor, which controls exactly which process the GPU renders. Figure 8 shows the programmable graphics rendering pipeline.

Compare the previous chapter in Figure 3. In the GPU rendering pipeline, you can see that the vertex shader controls the vertex coordinate conversion process; The fragment shader controls the pixel color calculation process. This distinguishes between vertex shader and fragment coloring programs: Vertex program is responsible for vertex coordinate transformation; Fragment Program is responsible for pixel color calculation; the output of the former is the input of the latter.

Figure 9 shows the input/output of the programmable graphics hardware at this stage. The input register holds the INPUT element information, the output register holds the processed entity information, and the texture buffer stores the texture data, and most of the programmable graphics hardware currently supports only the fragment processor to process the texture; constants entered from the external host program are placed in the constant register Temporary registers hold temporary data generated by the coloring program during execution.

3.2 Vertex Shader Program

Vertex shader Program (vertex shader) and fragment shader program (fragment shader) were Programmable Vertex Processor (programmable vertex processor) and Programmable Performed by the Fragment Processo (programmable fragment processor).

The vertex shader extracts the entity information (vertex position, normal vector, texture coordinate, etc.)from the GPU front-end Module (register), and completes the operation of vertex coordinate space transformation, normal vector space transformation, illumination calculation , and finally transfers the computed data to the specified register. The fragment shader then obtains the required data, usually "texture coordinates, illumination information, etc.", and calculates the color of each fragment based on this information and the texture information passed from the application (if any), and finally sends the processed data to the raster Operation module.

Figure 10 shows the process of data processing in the vertex shader and pixel shader. The element information set in the application (vertex position coordinates, color, texture coordinates, etc.) is passed into vertex buffer, and the texture information is passed to texture buffer. The dashed line indicates that data transfer is not yet implemented. The current vertex program cannot handle texture information, and texture information can only be read in the fragment program.

Vertex shaders and fragment shaders are usually present at the same time, interacting with each other, and the former outputs as input to the latter. However, it is possible to have only vertex coloring programs. If there is only a vertex shader, then only the input vertices are manipulated, and the points inside the vertices are automatically interpolated by the hardware default. For example, enter a triangular patch, the vertex shader program Phong light calculation, calculate only three vertices of the light color, and triangle patch interior point color according to the hardware default algorithm (Gourand shading or fast phong shading) interpolation, if the graphics hardware is more advanced, The default processing algorithm is good (fast Phong shading), the effect will be better, if the graphics hardware using the Gourand shading algorithm, there will be a Mach band effect (stripe).

The Fragment coloring program is a separate color calculation for each fragment, and the algorithm is written by itself, not only controllable, but also can achieve better results.

Because the GPU processes the data in parallel, each data executes once shader the program. That is, each vertex data executes one vertex program at a time, and each fragment executes one fragment program at a time.

3.3 Fragment Shader Program

The fragment shader has a separate color calculation for each fragment, and the final output color value is the color that the fragment eventually displays. It can be said that the vertex shader program mainly for geometric operations, and the fragment shader program mainly for the final color values to calculate .

The fragment shader also has a prominent feature: the ability to retrieve textures. for GPUs, textures are equivalent to arrays, which means that if you want to do general-purpose calculations, such as array sorting, string retrieval, and so on, you must use the fragment coloring program. Having the vertex shader also has the ability to retrieve textures is one of the current research directions.

Attached: What is a fragment. What's different about fragments and pixels. The so-called fragment is the data collection of all three-dimensional vertices after rasterization, which has not been compared with the depth value, and the pixels displayed on the screen are compared in depth.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.