- Graphics pipeline: The sequence of steps that converts 3D scene data into a 2D image. It consists of the application stage, geometry stage, rasterization stage, and pixel stage. Each stage performs specific operations like vertex processing, primitive assembly, and fragment shading.
- Application stage: The CPU prepares scene data, including geometry, transformations, and textures. This stage handles collision detection, physics simulations, and input processing before sending draw calls to the GPU. Efficient batching reduces overhead.
- Geometry stage: Transforms vertices from object space to screen space through model, view, and projection matrices. Clipping removes primitives outside the view frustum, and back-face culling discards polygons facing away from the camera to reduce workload.
- Rasterization stage: Converts geometric primitives (triangles) into fragments or pixels. For each triangle, the rasterizer determines which pixels are covered and interpolates vertex attributes like color, normal, and texture coordinates across the pixel grid.
- Pixel stage: Also called the fragment shader, it computes the final color of each pixel using interpolated attributes, textures, and lighting calculations. Output is written to a framebuffer, which may include depth, stencil, and color buffers.
- Programmable versus fixed pipeline: Modern GPUs allow custom shader programs for vertex, geometry, tessellation, and fragment stages, replacing fixed-function units. This flexibility enables advanced effects like tessellation, geometry amplification, and deferred shading.
- Memory bandwidth and latency: Each pipeline stage accesses GPU memory, and bandwidth bottlenecks can limit performance. Techniques like vertex caching, texture compression, and depth pre-pass help reduce memory traffic and improve fill rates.
- Parallel execution: The pipeline exploits massive parallelism by processing vertices and fragments independently. GPUs contain hundreds of cores that execute the same shader on different data (SIMD style). Understanding wavefronts or warps helps optimize occupancy.
- Draw call overhead: Each draw call issued by the CPU incurs overhead for command buffer submission, state validation, and GPU context switching. Batching multiple objects into a single draw call via instancing, dynamic batching, or merging meshes reduces this overhead. Excessive draw calls can stall the pipeline, limiting frame rates in complex scenes.
- Pipeline synchronization: Modern rendering pipelines require explicit synchronization between stages when resources are read and written concurrently. Barriers or fences ensure that writes to a render target complete before subsequent reads, preventing data hazards. Proper synchronization avoids visual artifacts and race conditions, especially in multi-pass rendering with compute shaders.
Principle: Pipeline Balance
Definition: Ensuring that each stage of the rendering pipeline has a balanced workload so that no stage becomes a bottleneck. An unbalanced pipeline causes stalling and underutilization of GPU resources.
Application: In a scene with many small triangles, the geometry stage may be overloaded, while the pixel stage is idle. To balance, use level-of-detail (LOD) techniques to reduce triangles far from the camera, or shift work to compute shaders for post-processing. Monitor pipeline statistics using GPU profiling tools to identify the slowest stage and apply targeted optimizations.
Harmony: Monochromatic for GPU Core Visualization
- The graphics pipeline has four major stages: application, geometry, rasterization, and pixel.
- Each stage performs specific tasks and can be programmable via shaders.
- Pipeline balance prevents bottlenecks by ensuring even workload distribution.
- Memory bandwidth and parallel execution are critical performance factors.
- Modern GPUs use SIMD architectures to process many fragments simultaneously.