Geometry-Shader Object

A geometry-shader object processes entire primitives. Use the following syntax to declare a geometry-shader object.


void ShaderName (

  PrimitiveType DataType Name [ NumElements ],

  inout StreamOutputObject





[in] Declaration for the maximum number of vertices to create.

  • [maxvertexcount()] - required keyword; brackets and parenthesis are required characters for correct syntax.
  • NumVerts - An integer number representing the number of vertices.

[in] An ASCII string that contains a unique name for the geometry-shader function.

PrimitiveType DataType Name [ NumElements ]

PrimitiveType - Primitive type, which determines the order of the primitive data.

Primitive TypeDescription
pointPoint list
lineLine list or line strip
triangleTriangle list or triangle strip
lineadjLine list with adjacency or line strip with adjacency
triangleadjTriangle list with adjacency or triangle strip with adjacency


DataType - [in] An input data type; can be any HLSL data type.

Name - Argument name; this is an ASCII string.

NumElements - Array size of the input, which depends on the PrimitiveType as shown in the following table.

Primitive TypeNumElements


You operate on only one point at a time.



A line requires two vertices.



A triangle requires three vertices.



A lineadj has two ends; therefore, it requires four vertices.



A triangleadj borders three more triangles; therefore, it requires six vertices.



The declaration of the stream-output object.

Return Value



The following diagram shows the various primitive types for a geometry shader object.

Illustration of the various primitive types for a geometry shader object

The following diagram shows geometry shader invocations.

Illustration of geometry shader invocations


This example is from exercise 1 from the Direct3D 10 Shader Model 4.0 Workshop.

void GSScene( triangleadj GSSceneIn input[6], inout TriangleStream<PSSceneIn> OutputStream )
    PSSceneIn output = (PSSceneIn)0;

    for( uint i=0; i<6; i+=2 )
        output.Pos = input[i].Pos;
        output.Norm = input[i].Norm;
        output.Tex = input[i].Tex;
        OutputStream.Append( output );

Minimum Shader Model

This object is supported in the following shader models.

Shader ModelSupported
Shader Model 4 and higher shader modelsyes


Related topics

Shader Model 4