8.1 - Geometry shader
An important number of the previously described extensions have implications at the GLSL level but also with the API
that allows the interaction between the CPU and the GPU. The GL_EXT_gpu_shader4 extension handles these changes
and GL_EXT_geometry_shader4 is in charge of integrating into OpenGL the geometry shader notion which, just for
recalling, should be called "primitive shader" according to the OpenGL terminology. The geometry shaders bring new
geometric shapes to describe the neighborhood of each primitive, which allows for example to apply the triangle subdivision [1].
Contrarily to Direct3D 10, the syntax of the geometry shaders is not snaky. In fact, it is the same than the one that
has been used till now for the vertex shaders and the fragment shaders with this famous unification function,
which means that all the functionalities are available for all the shaders.
Besides, there are only two functions available on the geometry shader: EmitVertex() and EndPrimitive() whose working
is easily understandable when referring to the immediate mode of OpenGL. EmitVertex() is then equivalent to glVertex*()
and EndPrimitive() is equivalent to glEnd(). glBegin() is implicit, when we go in a geometry shader, we may consider
that a call of this type is done, also after each call to EndPrimitive(). Data that have been given to each newly created
vertex correspond to the values given to the varying variables.
8.2 - Language update
At the GLSL level, we have to deal with two new functions, round and truncate, as well as a revaluation of integers.
They are now coded on 32 bits, the bit-to-bit operators are supported, the abs, sign, min, max and clamp functions fully
support integers and new unsigned integer types are available: unsigned int, uvec2, uvec3 et uvec4 and a big number of new
samplers for texture representation with integers. Regarding functions for the textures, it is a real bleeding,
like the one for the "texture fetch", to get the dimensions, access to the texture array, without take into account two new notions:
the first is the gradiant (partial derivateon each component) and the second is the offset, that allows to offset the texture coordinates
by a sum
Editor's Notes
- [1]: Triangles subdivision is only one of the numerous applications of the geometry shaders.
In 2001-2002, ATI had integrated into radeon the Trueform technology which can be seen as a limited and fixed version of the G80's geometry shaders.
For more information about Trueform see the following article: ATI TRUFORM Technology - Powering the next generation Radeon.