Skip to content
Tech News
← Back to articles

Anatomy of a Texture

read original more articles
Why This Matters

This article is a technical deep-dive into how texture data is physically laid out in memory across gaming platforms, revealing surprising complexity behind something consumers take for granted in game graphics. It matters to the industry because engine developers, porting studios, and hardware vendors must precisely handle block compression, texel ordering, mips, and tiling to ensure games run correctly across PC and consoles, and mistakes here can cause visual bugs or performance issues.

Key Takeaways

Anatomy of a Texture

Introduction

Last year I had to write code which converted texture data between gaming platforms. Going into it, I seriously underestimated the complexity of texture memory layouts.

I'm currently working on a team at 505 Games porting a custom PC game engine to consoles. One of the many challenges faced has been around texture conversion. I knew there were a lot of complexities and subtleties to it. I recognized most of them in isolation. But, it wasn't until I had to write working code which handled all these details in tandem that the full complexity really sank in. And so, I thought this would make for an interesting blog post!

This blog post will explain the complexity of texture memory layout, along with why it is necessary. This will be done through the lens of someone trying to debug the calculation of memory addresses for each part of a console texture. Due to the subject matter, this post will have to get a little bit more technical.

I will assume an understanding of programming fundamentals, memory layouts, as well as familiarity with basic video game technology and digital imagery.

Throughout this article we'll use a 1024x1024 RGBA texture using BC7 as an example. For illustration purposes, let's use a simple wood texture.

Figure 1. 1024x1024 Example texture

Converting this texture between platforms requires us to keep track of a lot of details. For the purpose of this article I will explain the following: block compression, texel ordering, mips, and texture tiles. There are other details such as pitch, depth, and texture array index. These mainly require simple offsets which are slightly annoying but do not add any interesting theory, so I will ignore them.

Here is what that image would look like if we ignore all of these complications and interpret the result as a simple stream of color values:

... continue reading