Graphics Pipelines and GPU Hardware : Lab Notes 1
Intro
To eventually design a 3D GPU, we must learn about 3D GPU micro-architecture. Since the literature on 3D GPU micro-architecture seems to be sparse, we must infer GPU micro-architecture by programmatically interacting with GPUs via Mesa3D and or OpenGL for example.
Good Resources
- Mesa Sources
- Portable GL | A simple yet functionl OpenGL 3 implementation in pure C without a GLSL - instead opting for building shader compute graphs directly in C.
- agx-milestone-1 | Roughly representative of the minimal needed code to support a new GPU device in Mesa.
- ISA of Apple G13 GPU in M1 SOC
- M1 GPU manual driving | some code that operates the M1 GPU by borderline bit-blasting it.
- Modern OpenGL tutorial series and accompanying gitlab repo
Notes
- gpu specific tooling such as compilers and assemblers in top folders like src/panfrost/compiler
- should probably consider getting a device that supports panfrost such as RockPi 4C
Simple Triangle with Portable GL
You may have to adjust include and library paths for your platform
in the following such that the compiler can find SDL2.
wget https://raw.githubusercontent.com/rswinkle/LearnPortableGL/f76a571af299a687035b59c769f85b99ff4e5109/src/1.getting_started/hello_triangle.cpp
wget https://raw.githubusercontent.com/rswinkle/PortableGL/3fd354efd5d8b591d6d937e45f68a17919765853/portablegl.h
g++ hello_triangle.cpp -I ./ -I/opt/local/include/ -L/opt/local/lib/ -lSDL2 -o hello_triangle
./hello_triangleYou should see something like:

Other Notes
- OpenGL uses named buffer objects to abstract away the possible differences in GPU memory space vs host memory spaces. This is probably not needed for unified memory architectures, but it is what it is.