Game Dev at 30 – Pt 2


Last week, we took a sweeping overview of how computer games and graphics, for all the magic in the worlds they present to us, are really just computer programs running on computing devices just like any other program. Today, we’ll talk about how programmers use abstractions to tame the complexity of managing all the nuts and bolts of pumping data to pixels on the screen to make a game.

Low-Level “Systems” and the GPU

Many of us are likely familiar with the basic mechanics of the CPU – registers, cache memory, data buses and the like. Essentially, we have a physical machine to which we provide instructions via increasingly higher levels: opcodes, assembly, systems languages like C, and so on. For the GPU, it’s a fairly analogous story. The GPU (graphics processing unit) accepts input data over a bus, and performs computations according to instructions provided to it. The main difference being that the GPU is highly optimized in hardware to perform those calculations on data massively in parallel. While in the CPU space, only a few well-known players create processors in the consumer market (Intel, AMD, etc.) and do so by adhering to one of a few architectures with corresponding instruction sets (x86, Arm). In the GPU world, the dominant players are NVIDIA and AMD, each with their own corresponding architectures.

Whereas it’s possible to program the CPU “manually” by writing a program in an assembly language, the GPU manufacturers frown on that kind of bare-metal access to the GPU hardware. Rather, there is an open standard set of system-level APIs for interfacing with GPUs that is common among manufacturers. If you’ve heard of OpenGL, OpenCL, Vulkan, etc., that’s what these are. Generally speaking, they provide an API in a systems-level language like C++ that allows one to pass along data and specify calculations on the GPU as if it were a block of memory accessible by the CPU. Most have convenience functions for performing matrix algebra, specifying texture mappings, etc., but there is nevertheless a substantial amount of effort in setting up and tearing down specific state for the GPU.

Rather than interface with graphics APIs directly, game programmers typically take advantage of one of a few different game engines. Most provide the ability to specify game logic and even graphics behaviors in a higher level scripting language, but in reality the game engines extend far beyond that, encompassing something of an IDE, programming framework, and simulator rolled into one. The two main players in game engines are Unity and Unreal Engine. Unity provides the ability to specify game and graphic functions visually in the IDE as well as use C# for scripting. Likewise, Unreal Engine provides an API in C++ as well as a pure visual coding environment called Blueprints which allows game developers to develop whole games in a drag and drop interface.

We’ll do an overview of how Unity in the next installment.

Print Friendly, PDF & Email

Leave a Reply

Your email address will not be published. Required fields are marked *