3 ms·
Probably the most alien artefact I ever created was the core abstraction of a C++ game engine that used the curiously recurring template pattern in combination
by jiggawatts 4y ago
Probably the most alien artefact I ever created was the core abstraction of a C++ game engine that used the curiously recurring template pattern in combination with multiple inheritance.
The idea was to be able to switch between DirectX and OpenGL renderers, or restart the renderer from scratch on failure (i.e.: recoverable GPU driver crash, GPU unplug, restore from sleep, etc...). The problem with using a naive OO v-table based abstraction for this is that it incurs indirect call overheads on every call, including calls that are internal to each implementation. So with some clever template programming and multiple inheritance, I got to have my cake and eat it too: calls within a hierarchy of classes specialised for one back-end were always direct inline-able calls, but you could have shared code that was abstracted across different back-ends.
I opened that source file about a decade later and thought: "What crazy person came up with this madness!?" and then saw my name in the commit history. I was the mad one. The call was coming from inside the house.