Computer GraphicsUnit 27 min read

Graphics Hardware: GPUs, Rasterization, Framebuffers & Pipelines

Unit 2 of Computer Graphics explores the hardware components that render 2D/3D graphics—from GPUs and framebuffers to rasterization pipelines—with real-world examples like game engines and eSewa’s UI animations.

TAKEAWAYS:

  • GPUs accelerate rendering via parallel processing (e.g., NVIDIA’s CUDA cores in gaming laptops).
  • Rasterization converts vector shapes into pixels (e.g., Daraz’s product thumbnails).
  • Framebuffers store pixel data for display (like a digital canvas in Photoshop).
  • Pipeline stages (vertex → fragment → blending) mirror how Ncell’s app renders icons.
  • Hardware trade-offs: Cost vs. performance (e.g., mobile GPUs vs. desktop GPUs).
  • Real-world impact: From YouTube’s video decoding to Pathao’s driver UI updates.

1. Graphics Hardware Overview

Computer graphics hardware consists of specialized components that process and display visual data. The core components include:

  • GPU (Graphics Processing Unit): Handles rendering tasks (parallel processing).
  • CPU (Central Processing Unit): Manages logic and coordinates tasks.
  • Framebuffer: Memory storing pixel data for the display.
  • Display Controller: Converts digital signals to video output.

Why GPUs? GPUs excel at parallel processing, making them ideal for rendering millions of pixels per frame. Unlike CPUs (optimized for sequential tasks), GPUs have thousands of smaller cores designed for graphics workloads.


2. GPU Architecture

Key Components

  1. Vertex Processing Unit (VPU)

    • Handles 3D coordinates, transformations, and lighting.
    • Example: In Call of Duty, VPU calculates bullet trajectories.
  2. Geometry Processing Unit (GPU)

    • Renders primitives (points, lines, polygons).
    • Example: Minecraft’s block rendering relies on this.
  3. Rasterization Unit

    • Converts primitives into pixels (rasterization).
    • Example: eSewa’s transaction history icons are rasterized here.
  4. Fragment Processing Unit (FPU)

    • Applies textures, shading, and blending.
    • Example: YouTube’s video frames use FPU for color correction.
  5. Memory Hierarchy

    • VRAM (Video RAM): Stores textures and framebuffers.
    • Cache: Speeds up repeated data access.

GPU vs. CPU

Feature GPU CPU
Cores Thousands (parallel) Few (sequential)
Clock Speed Lower (~1 GHz) Higher (~3–5 GHz)
Strength Graphics, AI, parallel tasks General computing, logic
Example Use Fortnite rendering Excel calculations

3. Rasterization Pipeline

The rasterization pipeline converts 3D models into 2D pixels. It consists of 6 stages:

flowchart LR
    A["Vertex Shader"] --> B["Tessellation"]
    B --> C["Geometry Shader"]
    C --> D["Rasterization"]
    D --> E["Fragment Shader"]
    E --> F["Blending"]

Step-by-Step Trace (Example: A 3D Cube)

  1. Vertex Shader

    • Input: 8 vertices of a cube.
    • Output: Transformed vertices (e.g., rotated by 45°).
    • Real-world: Pathao’s driver app rotates the map based on user location.
  2. Tessellation

    • Subdivides polygons (e.g., a cube face into smaller triangles).
    • Why? Smoother curves (e.g., Assassin’s Creed’s hair).
  3. Geometry Shader

    • Generates new geometry (e.g., adding particles to explosions).
    • Example: Daraz’s "Add to Cart" animation uses dynamic geometry.
  4. Rasterization

    • Converts triangles into pixels (scanline conversion).
    • Worked Example:
      • Triangle vertices: (0,0), (2,0), (1,2).
      • Rasterize using Bresenham’s algorithm (see Unit 3).
      • Output: Pixels at (1,1), (1,0), (0,1), (2,1).
  5. Fragment Shader

    • Applies textures/colors to pixels.
    • Example: Ncell’s app background gradient.
  6. Blending

    • Combines fragments (e.g., transparency in Pokémon GO’s Pokéball).

4. Framebuffer and Display

The framebuffer is a memory buffer storing pixel data (RGB + depth). It acts like a digital canvas.

Framebuffer Structure

Channel Purpose Example
Color RGB values (24–32 bits) YouTube’s video pixels
Depth Z-buffer (distance from camera) GTA V’s 3D depth rendering
Stencil Masking (e.g., cutouts) Photoshop’s layer effects

5. Real-World Applications

Example 1: eSewa’s UI Animations

  • Hardware Used: Mobile GPU (e.g., Snapdragon 8 Gen 2).
  • Process:
    1. Vertex shader renders button shapes.
    2. Fragment shader applies gradients.
    3. Framebuffer updates display at 60 FPS.

Example 2: Daraz’s Product Thumbnails

  • Hardware Used: Cloud GPUs (AWS EC2).
  • Process:
    • Rasterization converts 3D product models into 2D thumbnails.
    • Framebuffer stores thumbnails for fast loading.

Example 3: Ncell’s App Icons

  • Hardware Used: Smartphone GPU (e.g., Apple A16).
  • Process:
    • Icons are pre-rendered textures loaded into the framebuffer.
    • GPU handles smooth scrolling animations.

6. Performance Optimization Techniques

Technique Description Example
Level of Detail (LOD) Simplifies distant objects. Minecraft’s far-away trees.
Culling Skips hidden faces (backface culling). Fortnite’s building interiors.
Texture Compression Reduces VRAM usage. Google Maps’s satellite tiles.
Multi-threading Uses CPU/GPU parallelism. Blender’s render farms.

7. Exam Tip

  • Focus on:
    • GPU vs. CPU differences (parallel vs. sequential).
    • Rasterization pipeline stages (vertex → fragment).
    • Framebuffer channels (RGB, depth, stencil).
  • Avoid:
    • Memorizing exact GPU specs (e.g., NVIDIA’s core counts).
    • Overcomplicating math (e.g., depth buffer equations).
  • Practice:
    • Trace a simple triangle through the pipeline.
    • Compare mobile vs. desktop GPU trade-offs.

8. Worked Example: Rasterizing a Line

Problem: Rasterize the line from (0,0) to (4,2) using Bresenham’s algorithm. Solution:

  1. Calculate slope: .
  2. Use Bresenham’s error term:
    • Initial error .
    • For each step, update error and decide pixel placement.
  3. Pixels selected: (0,0), (1,0), (2,1), (3,1), (4,2).

Visualization:

graph TD
    A["(0,0)"] --> B["(1,0)"]
    B --> C["(2,1)"]
    C --> D["(3,1)"]
    D --> E["(4,2)"]

Real-world tie: This is how Pathao’s route lines are drawn on the map.


9. Common Pitfalls

  • Misunderstanding GPUs: Thinking they replace CPUs (they complement them).
  • Ignoring Framebuffer: Forgetting depth/stencil buffers in exams.
  • Overlooking LOD: Assuming all objects need high detail (they don’t).

10. Summary Table

Component Role Real-World Example
GPU Parallel rendering NVIDIA RTX in gaming PCs
CPU Logic/coordination Intel Core i9 in workstations
Framebuffer Pixel storage eSewa’s transaction history
Rasterization Vector → pixels Daraz’s product images
Shaders Textures/lighting YouTube’s video effects

Final Note: Master the pipeline stages and GPU-CPU roles. Use real-world apps (eSewa, Daraz) to visualize concepts. Practice tracing simple shapes through the rasterizer!

Based on the PU BE Computer (PU) syllabus for Computer Graphics, unit 2.

Discussion

Loading…