MSDN

DirectX Rendering Pipeline Concepts

The DirectX rendering pipeline is a series of stages that a 3D model or scene must pass through to be rendered on the screen. Understanding this pipeline is fundamental to graphics programming with DirectX.

Overview

The pipeline can be broadly divided into two main categories: the programmable pipeline and the fixed-function pipeline. Modern DirectX versions primarily utilize the programmable pipeline, allowing developers to customize behavior at various stages using shaders.

Simplified DirectX Rendering Pipeline Diagram

A conceptual representation of the DirectX rendering pipeline.

Key Stages of the Pipeline

1. Input Assembler (IA) Stage

This stage is responsible for fetching vertex data from memory and organizing it into primitives (points, lines, triangles). It reads data from vertex buffers and index buffers, which contain information like vertex positions, normals, texture coordinates, etc.

2. Vertex Shader (VS) Stage

The vertex shader is a programmable stage that operates on each vertex individually. Its primary tasks include:

The output of the vertex shader is typically clip-space coordinates and other data to be interpolated across the primitive.

3. (Optional) Tessellation Stages

These stages, if used, allow for dynamic subdivision of primitives, enabling more detailed geometry at runtime. They include:

4. Geometry Shader (GS) Stage

This optional programmable stage can operate on entire primitives (points, lines, triangles) and can:

It's often used for effects like instancing or generating fur/grass.

5. Rasterizer (RS) Stage

The rasterizer takes the primitives output by the vertex, tessellation, or geometry shader and determines which screen pixels each primitive covers. It performs:

6. Pixel Shader (PS) Stage (also known as Fragment Shader)

This is another crucial programmable stage that operates on each fragment generated by the rasterizer. Its main responsibilities include:

7. Output Merger (OM) Stage

The final stage before a pixel is written to a render target (like the back buffer). It performs operations such as:

Programmable vs. Fixed-Function

Historically, graphics hardware had a fixed-function pipeline with predefined capabilities. The advent of programmable shaders (vertex, geometry, pixel, hull, domain) in DirectX gave developers unprecedented control over the rendering process. This flexibility is key to achieving modern graphical fidelity and custom visual effects.

Further Reading