Architecture
New generation of GPU consists of the programmable vertex, pixel, and texture units.
Vertex describes the geometry of an object. Texture specifies the skin covered on
an object. And pixel deals with the view of an object world. Vector and matrix are
representation of 3D world. Initial graphic processing hardware has only the fixed
functions. New programmable GPU allows program to complete complex tasks and generate
photorealistic effects. Unlike traditional CPU, GPU works in the way of SIMD (Single
Instuction stream and Multiple Data stream), that is it applies the same program on
the uniform data.
The GPU workflow is clear for graphic processing from the architecture diagram.
Vertex unit accepts vertice information such as position and normal from the model
through the vertex buffer. Texture unit receives surface information from the model.
GPU pipelines do computing based on the vertice and texture data and output the
results to the pixel unit. Pixel unit complete the lighting and view processing
then output to the frame buffer for display. All the units work along to generate
a shading of 3D world.
Since these units are programmable, there exists an instruction set for each units.
There are corresponding assembly languages for programming on them. Furthermore,
high level languages like Cg and HLSL can compile to generate assembly codes.
To construct a complete shader program, developers need to write a C++ code running
on the main processor, and execute the assembly codes on GPU. Usually you may need
to write 1,000 lines C++ code with 50 lines assembly codes to describe a shader.
And it is difficult to debug and change. Neatware's MCL
(Media Control Language) is a scripting language to write a shader. It is much easy
to learn, to use, and to test a shader.
Vertex Shader
Vertex unit is a programmable T&L pipeline. A vertex shader is a program execution in the
vertex unit. There is only one active vertex shader. You can relates each object with a
vertex shader. For example, you may assign each dolphins with an object vertex shader and
the seafloor as an environment vertex shader.
Pixel Shader
Pixel unit is a programmable pixel pocessing pipeline. Pixel may be use to generate
multiple lighting effects.
Texture Shader
Texture unit handles the texture mapping, sacling, and transform.
|