GPU Graphics
Explore GPU programming ideas and graphics through CPU-based Python models. Work with indexing, transforms, rasterisation, and rendering before building a triangle renderer.
What helps
Python Foundations are the starting point for new programmers. Later graphics projects use vectors, matrices, and geometry. These lessons model GPU concepts without executing on GPU hardware.
Python pathway
Programming Foundations / Practice rooms / Track curriculum and enrollment
The GPU Programming Model
Model per-index callbacks, blocks, grids, guards and array operations in CPU Python/NumPy. Assemble an AXPY launcher and compare its values with a reference expression. This is a partial CUDA indexing model, without GPU scheduling or hardware execution.
- From Serial to Parallel: 5 lessons
- Threads and Indices: 5 lessons
- Writing Kernels: 5 lessons
- The Grid and Launch Configuration: 5 lessons
- Capstone: A Kernel Engine: 5 lessons
Data-Parallel Patterns
Compute maps, reductions, scans, gathers and scatters in NumPy. Distinguish ideal parallel dependency depth from execution time, then compose an energy-share pipeline from squaring, summing and division.
- The Map Pattern: 5 lessons
- The Reduce Pattern: 5 lessons
- The Scan Pattern: 5 lessons
- Gather and Scatter: 5 lessons
- Capstone: Composing Patterns: 5 lessons
Memory Models and Tiling
Use explicit latency, transaction and traffic models to reason about locality. Implement a CPU blur with copied tile halos, verify its values and report a padded logical-read ratio. Hardware latency and acceleration are not measured here.
- Memory Spaces: 5 lessons
- Memory Coalescing: 5 lessons
- Shared Memory and Tiling: 5 lessons
- Arithmetic Intensity and the Roofline: 5 lessons
- Capstone: Optimizing a Kernel: 5 lessons
Linear Algebra and GPU Models
Build vector operations, matrix-vector products and scalar/blocked matrix multiplication in CPU NumPy. Verify partial tiles and matrix shapes, then report the result with a nominal full-tile traffic factor. The code does not allocate GPU shared memory.
- Vector Operations: 5 lessons
- The Matrix-Vector Product: 5 lessons
- Naive Matrix Multiply: 5 lessons
- Tiled Matrix Multiply: 5 lessons
- Capstone: A Matmul Engine: 5 lessons
Vectors and Transforms
Use vectors, matrices and homogeneous coordinates to compose model, fixed-view camera and perspective transforms. The final output is normalized device coordinates; clipping and viewport mapping are separate steps.
- 3D Vectors: 5 lessons
- Matrices: 5 lessons
- The Transforms: 5 lessons
- Homogeneous Coordinates: 5 lessons
- Capstone: The MVP Pipeline: 5 lessons
The Rasterization Pipeline
Build a CPU screen-space triangle renderer with closed-edge integer samples, barycentric color interpolation and a depth buffer. Assemble actual overlapping triangles and display the resulting image.
- Triangles: 5 lessons
- Barycentric Coordinates: 5 lessons
- The Rasterizer: 5 lessons
- The Z-Buffer: 5 lessons
- Capstone: A Triangle Renderer: 5 lessons
Ray Tracing
Trace primary camera rays against one sphere, select the nearest forward intersection and apply local diffuse/ambient shading. Assemble and display a CPU grayscale image. Reflections, cast shadows and GPU ray-tracing hardware are outside this implementation.
- Rays: 5 lessons
- Ray-Sphere Intersection: 5 lessons
- Shading: 5 lessons
- The Camera: 5 lessons
- Capstone: Rendering a Sphere: 5 lessons
Shader Concepts and Image Processing
Use CPU arrays for coordinate patterns, color maps and neighborhood filters. Distinguish unflipped cross-correlation from mathematical convolution, then display a grayscale/blur/Sobel-x pipeline with explicit cropping and magnitude mapping.
- Pixel Shaders: 5 lessons
- Color Operations: 5 lessons
- Image Convolution: 5 lessons
- Applying Filters to Images: 5 lessons
- Capstone: A Filter Pipeline: 5 lessons
Particles and Physics Models
Represent particle state in NumPy, compare integration rules and calculate gravity, drag, springs and direct all-pairs forces. Assemble a seeded CPU fireworks simulation with post-step positions, matching life values and a fading trajectory display.
- Particle State: 5 lessons
- Numerical Integration: 5 lessons
- Forces: 5 lessons
- N-Body Simulation: 5 lessons
- Capstone: A Fireworks Simulation: 5 lessons
Capstone: A CPU Triangle Renderer
Assemble an outward tetrahedron, camera transforms, perspective depth, flat lighting and depth-tested rasterization into a displayed image. The renderer uses CPU Python/NumPy. It does not combine ray tracing or particles, clip crossing polygons, or execute GPU kernels.
- The Scene: 5 lessons
- The Geometry Pipeline: 5 lessons
- Rasterizing the Scene: 5 lessons
- Shading the Surface: 5 lessons
- Capstone: Render a Scene: 5 lessons