Labs ICT
⭐ Pro Login

Graphics Pipeline

The full rendering pipeline from vertices to pixels

The Graphics Pipeline

The graphics pipeline is the complete sequence of operations from 3D vertex data to the final pixels on screen. Modern GPUs implement this pipeline in hardware for extreme performance.

Pipeline Overview

Graphics Pipeline Stages:

  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚   Vertex    β”‚  Transform vertices
  β”‚  Shader     β”‚  (model-view-projection)
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
         v
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Primitive  β”‚  Assemble primitives
  β”‚  Assembly   β”‚  (triangles, lines, points)
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
         v
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Clipping   β”‚  Remove primitives
  β”‚             β”‚  outside view volume
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
         v
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚ Rasterizer  β”‚  Convert to fragments
  β”‚             β”‚  (potential pixels)
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
         v
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Fragment   β”‚  Compute final pixel
  β”‚  Shader     β”‚  color and depth
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
         v
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Per-Frag   β”‚  Depth test, blending,
  β”‚  Operations β”‚  stencil test
  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜
         v
  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
  β”‚  Framebufferβ”‚  Final image
  β”‚  Output     β”‚
  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Vertex Processing

Vertex Shader (programmable):
  - Transforms vertex positions
  - Computes per-vertex lighting
  - Passes data to fragment shader

  gl_Position = projection * view * model * vec4(position, 1.0);
  fragColor = lightingCalculation(normal, lightDir);

Fixed-function vertex operations:
  - Model-view transformation
  - Projection
  - Viewport mapping

Rasterization

Converts primitives to fragments:

  Input: Triangle vertices (after clipping)
  Output: Fragments (potential pixels)

  For each triangle:
    1. Compute bounding box
    2. For each pixel in bbox:
       - Test if inside triangle
       - Interpolate vertex attributes
         (color, normal, texcoord, depth)
       - Generate fragment with interpolated data

Fragment Processing

Fragment Shader (programmable):
  - Computes final color of each fragment
  - Texture sampling
  - Per-pixel lighting
  - Effects (fog, shadows, reflections)

  outColor = texture(texCoord) * lightColor;

Per-fragment operations:
  - Depth test (Z-buffer)
  - Stencil test
  - Blending (transparency)
  - Logical operations

Early Depth Testing

An optimization where depth testing is performed before the fragment shader. Fragments that fail the depth test are discarded early, saving shader computation.

Standard:
  Fragment Shader β†’ Depth Test

Optimized:
  Depth Test β†’ Fragment Shader (only if depth test passes)

Limitation: Fragment shader cannot modify depth
  (if it does, early depth test is disabled)

πŸ§ͺ Quick Quiz

The graphics pipeline typically processes vertices in which order?