Skip to content

Sponza on the CPU

You'll grow your software rasterizer until it draws a quarter-million-triangle atrium, textured and lit, at thirty frames a second with no GPU at all.

About

Your Software Teapot drew a few thousand flat triangles. Sponza, the free atrium scene everyone benchmarks on, has about 260,000 of them with textures, and drawing it fast on a CPU means learning everything a GPU does for you: near-plane clipping, perspective-correct texture coordinates, mipmaps, tiled rasterization that fits in cache, and spreading the work across every core. The constraint is what makes the badge. Thirty frames a second at 1280 by 720 on a modern laptop is a fair target, and getting there is a season of profiling. If you want to know why the GPU is shaped the way it is, this is how you find out.

At a glance

Per requirement
50 XP
Completion bonus
600 XP
Requirements
6
Takes
A season
Skill level
Advanced (years of practice)
Cost
Free
Supplies
Nothing special
Where
At home
Other people
On your own
Locked for now
Earn two more Rare badges in Graphics Programming to open this one. Log in to see how far along you are.

Requirements

  1. 1
    Load Sponza with its textures and draw it, however slowly. Parse the OBJ and MTL files and load the textures. The first frame may take seconds. Take a screenshot with the triangle count and the frame time. Photo
  2. 2
    Clip triangles against the near plane so the camera can walk through doorways. Without clipping, triangles behind the camera explode across the screen. Clip in homogeneous space before the perspective divide. Film the camera walking through an archway without artifacts. Video
  3. 3
    Interpolate texture coordinates perspective-correctly and add mipmaps. Interpolate u over w, v over w and 1 over w across the triangle, then divide. The floor tiles stop bending. Take a screenshot of the floor before and after. Photo
  4. 4
    Profile and get a ten times speedup from where you started. Use perf, Instruments, or a sampling profiler in your language. Write down the top three hot spots before and after. Take a screenshot of the profiler and your notes. Photo
  5. 5
    Split the screen into tiles and render them on all cores. Bin the triangles into tiles, give each thread a tile, and let the tiles stay in cache. Print the speedup over one core. Take a screenshot with the core count and the frame time. Photo
  6. 6
    Hit 30 frames a second at 1280 by 720 and fly through the atrium. Name the CPU. Film thirty seconds of flying through Sponza with the frame time on screen. Video