Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ispc-raster

ispc-raster is a CPU software rasterizer: C++ builds scenes and geometry, while ISPC runs tile-based rasterization and fragment shading. It exports PNG / PPM images, supports a GLFW live preview with a terminal editor, and includes a repeatable benchmark suite.

Detailed design notes are in docs/architecture.md.

Usage

Build the renderer:

make
./build/ispc-raster --png --shader blinn-phong --output out/lit

The renderer accepts cube and OBJ assets under assets/. Command-line scene composition remains useful for automation:

./build/ispc-raster --add assets/model.obj \
  --object-transform 1 0.5 0 0 0 0.3 0 1 1 1 \
  --shader normal --save-scene out/example.rscene --png

./build/ispc-raster --scene out/example.rscene --png

# Faceted Blinn-Phong: one constant normal per triangle.
./build/ispc-raster --shader blinn-phong-flat --png

For the live editor, build with GLFW/OpenGL and run --preview:

make PREVIEW=1
./build/ispc-raster-preview --preview

The terminal menu can load/create scenes, browse numbered assets, add objects, edit translation/rotation/scale/material, edit camera position/target/Euler rotation, change lights, export images, and save scenes. Scene files retain asset IDs, per-object materials, camera, light, and model matrices.

blinn-phong-flat is an opt-in faceted material. It uses a view-space face normal for each triangle, avoiding normal interpolation and per-pixel normal normalization. Use regular blinn-phong for smooth OBJ normals.

Benchmark

benchmark/ is a separate executable plus JSON/plotting tools. --instances accepts a comma-separated cube-count range; the suite uses 64,256,1024 and 500 measured frames by default.

make benchmark
./build/ispc-raster-bench \
  --scene default,cube-grid,cube-cloud,offscreen,obj \
  --shader vertex-color,blinn-phong \
  --resolution 512x512 --warmup 100 --frames 500 \
  --instances 64,256,1024 --seed 42 --json out/benchmark/results.json

bash benchmark/scripts/run_suite.sh
python3 benchmark/scripts/plot_frame_times.py out/benchmark/results.json
python3 benchmark/scripts/plot_stages.py out/benchmark/results.json

The benchmark excludes image encoding and reports total frame, clear, vertex, geometry, raster, binning, payload, and raster/fragment times. raster/fragment is the tile loop plus ISPC coverage, depth, interpolation, shading, and writes; binning builds tile lists and payload packs the optional batch ABI. default is a small correctness baseline, cube-grid measures regular visible instancing, cube-cloud stresses overlap/fragment work, offscreen measures object culling, and obj-instances stresses indexed OBJ geometry. Triangles are binned by screen tile before dispatch. Python plotting requires matplotlib.

Tile rasterization uses OpenMP by default in the Make build. Tune its worker count for a stable benchmark with OMP_NUM_THREADS, or build serially with make PARALLEL=0.

The default raster path uses direct ISPC tile dispatch. The experimental indexed batch path can be compared with RASTER_BATCH_MODE=batch; benchmark both modes with the same OMP_NUM_THREADS before using it for a workload.

For a self-contained run that creates .venv-benchmark, installs plotting dependencies, benchmarks, and writes charts, use:

bash benchmark/scripts/quick_benchmark.sh

Override its workload without editing the script, for example:

INSTANCES=1024 FRAMES=500 RESOLUTIONS=1920x1080 \
  bash benchmark/scripts/quick_benchmark.sh

Reference result

This snapshot was recorded on a 13th Gen Intel Core i7-13650HX (20 logical CPUs), with OMP_NUM_THREADS=8, 512×512, seed 42, 100 warmup frames, and 500 measured frames. Values are milliseconds (p50 / p95) and are a regression baseline, not a hardware-GPU comparison.

Binning and Raster/fragment are p50 stage times. The latter includes tile iteration plus ISPC coverage, depth, interpolation, shading, and framebuffer writes; it is normally the dominant raster cost.

Scene Shader Triangles submitted / rasterized Frame p50 / p95 Binning p50 Raster/fragment p50
default vertex-color 12 / 6 0.193 / 0.251 0.008 0.096
default blinn-phong 12 / 6 0.303 / 0.360 0.007 0.208
cube-grid (256) vertex-color 1,080 / 449 0.737 / 1.112 0.107 0.233
cube-cloud (256) blinn-phong 2,484 / 1,057 2.185 / 7.145 0.263 0.906
offscreen (256) vertex-color 0 / 0 0.122 / 0.178 0.000 0.003
assets/model.obj vertex-color 10,174 / 5,884 2.702 / 3.739 0.132 0.301

Keep CPU governor, build flags, scene, resolution, seed, warmup, and measured frame count fixed when comparing runs.

About

A soft raster base on ispc. My concurrent programming and graphics practice.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages