My study notes
I hope you will find my notes useful in case you intend to study more about engine and graphics programming.
C++
-
ISOCPP C++ Super-FAQ
-
ISOCPP C++ Core Guidelines
-
Marshall Cline’s FAQ (OLD)
-
Mirror of 2006 version: http://www.dietmar-kuehl.de/mirror/c++-faq/
-
Mirror of 2003 version: https://www.cs.rit.edu/~mjh/docs/c++-faq/
-
C++ Super-FAQ
Questions in round brackets are the ones I find more important or difficult to grasp at first. The numbers are a reference inside the 29/07/2011 Marshall Cline’s C++ FAQ.
-
Classes and Inheritance: Classes and Objects
-
7.7 - Can a method directly access the
non-public
members of another instance of its class?
-
-
Beyond Classes: Inline functions
-
9.1 - What’s the deal with
inline
functions? -
9.5 - Why should I use
inline
functions instead of plain old#define
macros? -
9.6 - How do you tell the compiler to make a non-member function
inline
? -
9.7 - How do you tell the compiler to make a member function
inline
? -
9.8 - Is there another way to tell the compiler to make a member function
inline
? -
9.9 - With
inline
member functions that are defined outside the class, is it best to put theinline
keyword next to the declaration within the class body, next to the definition outside the class body, or both?
-
-
Classes and Inheritance: Constructors
-
10.3 - Can one constructor of a class call another constructor of the same class to initialize the
this
object? -
10.4 - Is the default constructor for
Fred
alwaysFred::Fred()
? -
(10.5) - Which constructor gets called when I create an array of
Fred
objects? -
10.6 - Should my constructors use "initialization lists" or "assignment"?
-
10.8 - What is the "Named Constructor Idiom"?
-
(10.9) - Does return-by-value mean extra copies and extra overhead?
-
10.10 - What about returning a local variable by value? Does the local exist as a separate object, or does it get optimized away?
-
(10.14) - What’s the "
static
initialization order 'fiasco' (problem)"? -
10.20 - What is the "Named Parameter Idiom"?
-
(10.22) - What is the purpose of the
explicit
keyword?
-
-
General Topics: Memory Management
-
16.4 - Why should I use
new
instead of trustworthy oldmalloc()
? -
16.8 - Do I need to check for null before
delete p
? -
16.10 - In
p = new Fred()
, does theFred
memory "leak" if the Fred constructor throws an exception? -
16.21 - How can I force objects of my class to always be created via
new
rather than as local, namespace-scope, global, orstatic
?
-
-
Beyond Classes: Exceptions and Error Handling
-
17.2 - I’m still not convinced: a 4-line code snippet shows that return-codes aren’t any worse than exceptions; why should I therefore use exceptions on an application that is orders of magnitude larger?
-
17.3 - How do exceptions simplify my function return type and parameter types?
-
17.4 - What does it mean that exceptions separate the "good path" (or "happy path") from the "bad path"?
-
17.8 - How can I handle a constructor that fails?
-
17.9 - How can I handle a destructor that fails?
-
17.10 - How should I handle resources if my constructors may throw exceptions?
-
-
General Topics: Const Correctness
-
18.5 - What’s the difference between “
const X* p
”, “X* const p
” and “const X* const p
”? -
18.7 - Does “
C& const x
” make any sense? -
18.10 - What is a "
const
member function"? -
18.12 - What’s the deal with "
const
-overloading"? -
(18.13) - What do I do if I want a
const
member function to make an "invisible" change to a data member? -
18.15 - Why does the compiler allow me to change an
int
after I’ve pointed at it with aconst int*
?
-
-
Classes and Inheritance: Inheritance —
virtual
functions-
20.3 - What’s the difference between how
virtual
and non-virtual
member functions are called? -
20.4 - What happens in the hardware when I call a virtual function? How many layers of indirection are there? How much overhead is there?
-
20.5 - How can a member function in my derived class call the same function from its base class?
-
20.6 - I have a heterogeneous list of objects, and my code needs to do class-specific things to the objects. Seems like this ought to use dynamic binding but can’t figure it out. What should I do?
-
(20.7) - When should my destructor be
virtual
? -
20.8 - What is a "
virtual
constructor"?
-
-
Classes and Inheritance: Inheritance — Proper Inheritance and Substitutability
-
(21.4) - Is an array of
Derived
a kind-of array ofBase
? -
21.6 - Is a
Circle
a kind-of anEllipse
? -
21.8 - But I have a Ph.D. in Mathematics, and I’m sure a Circle is a kind of an Ellipse! Does this mean Marshall Cline is stupid? Or that C++ is stupid? Or that OO is stupid?
-
21.12 - If
SortedList
has exactly the same public interface asList
, isSortedList
a kind-ofList
?
-
-
Classes and Inheritance: Inheritance — what your mother never told you
-
23.1 - Is it okay for a non-
virtual
function of the base class to call avirtual
function? -
23.3 - Should I use protected virtuals instead of public virtuals?
-
23.4 - When should someone use private virtuals?
-
23.5 - When my base class’s constructor calls a
virtual
function on itsthis
object, why doesn’t my derived class’s override of thatvirtual
function get invoked? -
(23.9) - What’s the meaning of,
Warning: Derived::f(char) hides Base::f(double)
?
-
-
Classes and Inheritance: Inheritance —
private
andprotected
inheritance -
Classes and Inheritance: Inheritance — Multiple and Virtual Inheritance
-
Overview Topics: Coding Standards
-
27.10 - Are there any lint-like guidelines for C++?
-
-
Overview Topics: Newbie Questions & Answers
-
29.5 - What are the criteria for choosing between
short
/int
/long
data types? -
29.7 - Why would I use a
const
variable /const
identifier as opposed to#define
? -
29.17 - Why doesn’t my floating-point comparison work?
-
29.18 - Why is
cos(x) != cos(y)
even thoughx == y
? (Or sine or tangent or log or just about any other floating point computation) -
(29.19) - What is the type of an enumeration such as
enum Color
? Is it of typeint
? -
29.20 - If an enumeration type is distinct from any other type, what good is it? What can you do with it?
-
-
-
35.2 - What’s the syntax / semantics for a "class template"?
-
35.3 - What’s the syntax / semantics for a "function template"?
-
35.4 - How do I explicitly select which version of a function template should get called?
-
(35.7) - My template function does something special when the template type
T
isint
orstd::string
; how do I write my template so it uses the special code whenT
is one of those specific types? -
35.9 - But most of the code in my template function is the same; is there some way to get the benefits of template specialization without duplicating all that source code?
-
35.11 - So templates are overloading, right?
-
35.16 - Why do I get linker errors when I use template friends?
-
35.18 - Why am I getting errors when my template-derived-class uses a nested type it inherits from its template-base-class?
-
35.19 - Why am I getting errors when my template-derived-class uses a member it inherits from its template-base-class?
-
35.22 - Follow-up to previous: can I pass in the underlying structure and the element-type separately?
-
Topics
A list of concepts, ideas, idioms, patterns and keywords to understand and remember. The numbers in round brackets are a reference inside the 29/07/2011 Marshall Cline’s C++ FAQ.
-
Operator overloading (Section 13)
-
explicit
constructor (10.22) -
Qualifiers:
const
(29.7) /mutable
(18.13) /volatile
/restrict
-
v-table mechanism (20.4)
-
Pure virtual member functions (22.4) (can have an implementation), abstract base classes (Section 22)
-
Covariant Return Types and "virtual constructor" (20.8, 22.5, HOWTO: Covariant Return Types in C++)
-
Template Method pattern and private virtuals (23.4) (Virtuality by Herb Sutter)
-
Private inheritance (24.2, 24.3) (Uses and Abuses of Inheritance, Part 1 by Herb Sutter)
-
Static initialization order "fiasco" (10.14)
-
Meyer’s singleton (10.16)
-
One Definition Rule (ODR)
-
Different kind of casts: C style,
static_cast
,dynamic_cast
,const_cast
andreinterpret_cast
-
Run-Time Type Information (RTTI)
-
SOLID principles
More topics
A second list of concepts to keep in mind, only a bit harder this time. As before, the numbers in round brackets are a reference inside the 29/07/2011 Marshall Cline’s C++ FAQ.
For optimizations have also a look at Optimizing software in C++ and at the other free optimization books by Agner Fog. Another free C++ book is The C++ Annotations.
-
Placement new (11.10)
-
Diamond problem (25.8, 25.9) and multiple inheritance (Section 25)
-
Hiding rule (23.9, 23.3), C++: rationale behind hiding rule
-
Templates (Section 35)
-
Rule of Three / five / zero, special member functions
-
Return value optimization (NRVO, RVO) (10.9) / Copy elision (C++ Cargo Cults, RVO and Copy Elision, 9.8 of C++ Annotations)
-
Copy-and-swap idiom (Why do we need the copy-and-swap idiom?, public friend swap member function )
-
Argument-dependant lookup or Koenig lookup (4.1.2.2 of C++ Annotations)
-
Substitution Failure Is Not An Error (SFINAE) (35.11, 21.15 of C++ Annotations)
-
Proxy template (35.22), in C++11 you would employ the Type alias declaration with
using
-
Type traits, concepts, tag dispatching (Generic Programming Techniques)
-
Optimizing compiler (Tail call, Constant folding, Dead code elimination, …)
-
Empty base optimization, The "Empty Member" C++ Optimization
C++11
The book "Effective Modern C++" by Scott Meyers is a must-have. Chapters and items are references to this book.
-
Delegating constructors (supersede 10.3, 7.4.1 of C++ Annotations)
-
Rvalues (C++ Rvalue References Explained by Thomas Becker, 3.3.2 and 3.3.3 of C++ Annotations)
-
Auto keyword (Chapter 2,
auto
in Super-FAQ, 3.3.7 of C++ Annotations) and type deduction (Chapter 1) -
Move semantics (9.7 of C++ Annotations), Rule of Five
-
Reference collapsing (Item 28)
-
Reference qualifiers
-
Forwarding AKA universal references (Universal References in C++11 by Scott Meyers)
-
Perfect forwarding (22.5.2 of C++ Annotations)
-
Enum classes (Item 10,
enum class
in Super-FAQ, 3.3.4 of C++ Annotations) -
Range-based for loops and issues with
auto
and copying objects around (Range-for
statement in Super-FAQ, 3.3.9 of C++ Annotations) -
List initialization, initializer lists (Initializer lists in Super-FAQ, 3.3.5 of C++ Annotations)
-
Lambdas (Chapter 6, Lambdas in Super-FAQ, 11.11 of C++ Annotations)
-
Lambdas: From C11 to C20, Part 1 by Bartłomiej Filipek
-
Lambdas: From C11 to C20, Part 2 by Bartłomiej Filipek
-
IIFE for Complex Initialization by Bartłomiej Filipek
-
Design patterns and OOP
-
Meyer’s singleton
-
C++ 'Type Erasure' Explained by Dave Kilian
Math and geometry
Books
Read about the same math concepts on more than one book. Some books are targeted to game developers, like:
-
"Essential Mathematics for Games and Interactive Applications" by James M. Van Verth and Lars M. Bishop
-
"3D Math Primer for Graphics and Game Development" by Fletcher Dunn and Ian Parberry
-
"Mathematics for 3D Game Programming and Computer Graphics" by Eric Lengyel and John Flynt
Topics
-
Trigonometry
-
Vectors and matrices
-
Rendering pipeline
-
OpenGL transformations and matrices:
Algorithms and more
-
Sorting and data structures (lists, arrays, hash tables)
-
About hash tables: linear probing, quadratic probing, leapfrog probing, double hashing, cuckoo hashing, hopscotch hashing
-
-
Floating point (29.17 and Random ASCII blog)
-
Tricks With the Floating-Point Format (representation)
-
Comparing Floating Point Numbers, 2012 Edition (ULP comparison)
-
That’s Not Normal–the Performance of Odd Floats (hole around zero, denormals)
-
-
"Programming from the Ground Up" (PDF) by Jonathan Bartlett
-
Call stack, relocating code, dynamic libraries, data / bss / text segments
-
-
Virtual memory, paging, TLB, MMU, mmap
CPU
Important links from Wikipedia about the architecture of a CPU. One of the book you could read to learn more on the subject is "Computer Architecture: A Quantitative Approach" by David A. Patterson.
-
Instruction pipelining, Classic RISC pipeline → (fetch, decode, execute, memory access, writeback), Branch predication
-
Instruction-level parallelism, Out-of-order execution, Register renaming, Register spilling, Superscalar processor, VLIW (Very Long Instruction Word), Barrell processor
-
Hazard (computer architecture) → (RAW, WAR, WAW data hazards, pipeline bubbling, register forwarding)
-
Speculative execution, Instruction prefetch, Prefetch input queue
-
CPU cache, Cache replacement policies, Translation Lookaside Buffer (TLB), Scratchpad memory
-
Cache coherence (MESI protocol, MOESI protocol), Bus snooping, Write combining
-
Multiply–accumulate operation → (Fused multiply–add)
Multi-threading
One of the book on the topic is "The Art of Multiprocessor Programming" by Maurice Herlihy and Nir Shavit
-
Critical section, mutex, semaphore, Producer-consumer problem, Dining philosophers problem, Priority inversion, race condition
-
Atomics and lock-free programming (Preshing on Programming), memory barriers, memory models, Benaphore, Compare-and-swap, ABA problem, Load-link/store-conditional, acquire and release semantics (Load-Acquire/Store-Release in the ARM Reference Manual)
-
Cache coherency, MOESI protocol, MESIF protocol, false sharing, branch misprediction, scratchpad memory
-
CPUs: How is branch prediction implemented in microprocessors?
-
Single Producer / Multiple Consumer
-
Lock-free queues
-
Aligning AoS to cache line size to avoid false sharing
More topics
-
Load-Hit-Stores and the
__restrict
keyword by Elan Ruskin -
Sponsored Feature: Common Performance Issues in Game Programming by Becky Heineman
Graphics
-
Advanced Graphics Course 2021/22 from Universiteit Utrecht
Mobile GPUs architecture
The book "OpenGL ES 3.0 Programming Guide" by Dan Ginsburg and Budirijanto Purnomo is a must-have.
-
Performance Tuning for Tile-Based Architectures (PDF), from chapter 23 of the "OpenGL Insights" book
-
GPU Framebuffer Memory: Understanding Tiling by Samsung
-
Moving Mobile Graphics SIGGRAPH Courses
ARM Mali
-
The Mali GPU: An Abstract Machine
-
Killing Pixels - A New Optimization for Shading on ARM Mali GPUs (Forward Pixel Kill)
-
How low can you go? Building low-power, low-bandwidth ARM Mali GPUs (Transaction elimination)
-
Mali Performance
-
Benchmarking floating-point precision in mobile GPUs
-
Efficient Rendering with Tile Local Storage (PDF) (SIGGRAPH 2014)
-
ARM Unveils Next Generation Bifrost GPU Architexture & Mali-G71: The New High-End Mali
Desktop GPUs architecture
-
From Shader Code to a Teraflop: How GPU Shader Cores Work (PDF) by Kayvon Fatahalian (SIGGRAPH 2010)
-
Scheduling the Graphics Pipeline (PDF) by Jonathan Ragan-Kelley (SIGGRAPH 2011)
-
Triangles Are Precious - Let’s Treat Them With Care (PDF) by Dominik Baumeister (AMD)
-
A trip through the Graphics Pipeline 2011: Index by Fabian "ryg" Giesen
-
Gentle introduction to GPUs inner workings by Adrian Jurczak
Nvidia GeForce
-
NVIDIA Tesla: A Unified Graphics and Computing Architecture from IEEE Micro, March-April 2008
-
A History of Nvidia Stream Multiprocessor by Fabien Sanglard
-
Fermi: The First Complete GPU Computing Architecture by Peter N. Glaskowsky
Graphics techniques
-
Real-Time Many-Light Management and Shadows with Clustered Shading a SIGGRAPH 2015 Course
-
Practical Realtime Strategies for Accurate Indirect Occlusion (PDF) by Jorge Jimenez, Xian-Chun Wu, Angelo Pesce and Adrian Jarabo
-
An Introduction To Real-Time Subsurface Scattering by Matt Pettineo
-
Precomputed Global Illumination in Frostbite by Yuriy O’Donnell at GDC 2018
-
Real-time Raytracing for Interactive Global Illumination Workflows in Frostbite by Sébastien Hillaire at GDC 2018
-
The Visibility Buffer: A Cache-Friendly Approach to Deferred Shading by Christopher A. Burns and Warren A. Hunt (Intel)
-
Anti-aliased Alpha Test: The Esoteric Alpha To Coverage by Ben Golus
Physically Based Rendering
-
SIGGRAPH 2012 Course: Practical Physically Based Shading in Film and Game Production
-
SIGGRAPH 2013 Course: Physically Based Shading in Theory and Practice
-
SIGGRAPH 2016 Course: Physically Based Shading in Theory and Practice
-
Real-Time Polygonal-Light Shading with Linearly Transformed Cosines
-
Learn OpenGL: PBR Theory, Lighting, Diffuse irradiance, Specular IBL
-
Physically Based Rendering Algorithms: A Comprehensive Study In Unity3D
Graphics Studies of Games
-
Deus Ex: Human Revolution - Graphics Study by Adrian Courreges
-
Supreme Commander - Graphics Study by Adrian Courreges
-
GTA V - Graphics Study by Adrian Courreges
-
DOOM (2016) - Graphics Study by Adrian Courreges
-
Metal Gear Solid V - Graphics Study by Adrian Courreges
-
DOOM Eternal - Graphics Study by Simon Coenen
-
Hallucinations re: the rendering of Cyberpunk 2077 by Angelo Pesce
-
The Rendering of Castlevania Lords of Shadow 2 by Emilio López
-
The Rendering of Middle Earth: Shadow of Mordor by Emilio López
-
The Rendering of Rise of the Tomb Raider by Emilio López
-
The Rendering of Jurassic World: Evolution by Emilio López
-
The Rendering of Mafia: Definitive Edition by Emilio López
-
Behind the Pretty Frames: God of War by Muhammad A. Moniem
-
Behind the Pretty Frames: Elden Ring by Muhammad A. Moniem
-
Behind the Pretty Frames: Resident Evil by Muhammad A. Moniem
-
Behind the Pretty Frames: Diablo IV by Muhammad A. Moniem
-
Teardown Frame Teardown: Rendering analysis by Steven "Acko"
-
Breakdown: Syndicate (2012) - The greasy bloom finally demystified by Léna "Froyok" Piquet
Older resources
-
Variance Shadow Maps (PDF) by William Donnelly and Andrew Lauritzen
-
Iterative Parallax Mapping with Slope Information (PDF) by Mátyás Premecz
-
A Simple and Practical Approach to SSAO by José María Méndez
-
Advanced Depth of Field (PDF) by Thorsten Scheuermann
-
Order your graphics draw calls around! from the Real-Time Collision Detection blog
Vulkan
-
Vulkan in 30 minutes by Baldur Karlsson
-
Vulkan Samples on GitHub
-
Vulkan Renderpasses on GPUOpen
-
Yet another blog explaining Vulkan synchronization by Hans-Kristian Arntzen
-
Writing an efficient Vulkan renderer by Arseny Kapoulkine
-
Getting started on mobile and Best practices for Arm GPUs (PDF) by Pete Harris (ARM)
-
Battle-tested Optimisations for Mobile (PDF) by Ralph Potter (Samsung)
-
Some Seriously Explicit Lessons in Vulkan (Video) by Croteam and Samsung at Reboot 2019
More topics
-
GLSL: Center or Centroid? (Or When Shaders Attack!) by Bill Licea-Kane (AMD)
-
Texture filtering (PDF) (Mipmap selection with derivatives) by Steve Marschner
-
How are mipmap levels computed in Metal? replied by Nathan Reed
-
Reflecting a Vector (Vector reflection with vector projection and dot product)
-
Gram-Schmidt orthogonalization with vector projection and dot product
-
id Tech 5 Challanges - From Texture Virtualization to Massive Parallelization (PDF) by J.M.P. van Wavewer (id Software) (virtual texturing, sparse resources, parallel job system)
-
Approaching Zero Driver Overhead in OpenGL (PDF) (GDC Vault video), persistent mapping
-
Beyond Porting (PDF) (Steam Dev Days video) by Cass Everitt and John McDonald (NVIDIA) (persistent mapping, texture arrays, sparse and bindless textures)
-
Rendering deferred lights using Stencil culling algorithm by Yuriy O’Donnell
-
Depth Precision Visualized by Nathan Reed (NVIDIA)
-
What are screen space derivatives and when would I use them?
-
gl_HelperInvocation - OpenGL 4 Reference Pages
-
Life of a triangle - NVIDIA’s logical pipeline by Christoph Kubisch
-
1 - Signal Processing Primer by Matt Pettineo
-
2 - Applying Sampling Theory To Real-Time Graphics by Matt Pettineo
-
3 - A Quick Overview of MSAA by Matt Pettineo
-
4 - Experimenting With Reconstruction Filters for MSAA Resolve by Matt Pettineo
-
Breaking Down Barriers - Part 1: What’s a Barrier? by Matt Pettineo
-
Breaking Down Barriers - Part 2: Synchronizing GPU Threads by Matt Pettineo
-
Breaking Down Barriers - Part 3: Multiple Command Processors by Matt Pettineo
-
Breaking Down Barriers - Part 4: GPU Preemption by Matt Pettineo
-
Breaking Down Barriers - Part 5: Back to the Real World by Matt Pettineo
-
Breaking Down Barriers - Part 6: Experimenting with Overlap and Preemption by Matt Pettineo
-
Introduction to compute shaders by Matthäus G. Chajdas
-
More compute shaders by Matthäus G. Chajdas
-
Even more compute shaders by Matthäus G. Chajdas
-
The Elusive Frame Timing by Alen Ladavac
-
Intro to GPU Scalarization: Part 1 by Francesco Cifariello Ciardi
-
Intro to GPU Scalarization: Part 2 - Scalarize All the Lights by Francesco Cifariello Ciardi
-
Why Geometry Shaders Are Slow (Unless you’re Intel) by Joshua Barczak
-
Optimizing GPU occupancy and resource usage with large thread groups by Sebastian Aaltonen
-
Temporal AA and the Quest for the Holy Trail by Emilio López
Data Oriented Design
-
Pitfalls of Object Oriented Programming (PDF) by Tony Albrecht (SCEE)
-
Typical C++ Bullshit by Mike Acton (Insomniac Games)
-
Culling the Battlefield by Daniel Collin (Frostbite)
-
Multiprocessor Game Loops by Jason Gregory (Naughty Dog)
-
Parallelizing the Naughty Dog Engine Using Fibers (PDF) (GDC Vault video) by Christian Gyrling (Naughty Dog)
-
Memory Optimization (PDF) by Christer Ericson (Sony Santa Monica)
-
Introduction to Data Oriented Design by Daniel Collin (DICE)
-
Data Locality (cache miss, branch misprediction, pipeline flush) from Game Programming Patterns by Robert Nystrom
-
Performance - Physics Optimization Strategies (PDF) by Sergiy Migdalskiy (Valve)
-
Roundup: Recent sketches on concurrency, data design and performance by Mike Acton (Insomniac Games)
-
Optimizing Software Occlusion Culling - Index by Fabian "ryg" Giesen
-
Practical Examples in Data Oriented Design by Niklas Frykholm (BitSquid)
-
What is Data-Oriented Game Engine Design? by David Davidović
-
Data-Oriented Design (Or Why You Might Be Shooting Yourself in The Foot With OOP) by Noel Llopis
-
Data-Oriented Design book by Richard Fabian
-
Mike Acton’s review of
OgreNode.cpp
-
Memory, Cache, CPU optimization resources by Omar Cornut
-
Entity Component Systems & Data Oriented Design (PDF) by Aras Pranckevičius (Unity Technologies)
-
Caches everywhere by Nicholas Frechette