Lone Henchman

Sometimes about tools, sometimes about graphics, sometimes I just ramble.

Vulkan Memory Types

September 07, 2025
This post continues the series Memory and Caching, following How Cache Impacts Software.

Picking up the discussion on memory and caching: how does this all interact with an external processor such as a GPU? GPUs are an intersting addition to this discussion because their operation is very memory-bound and very very multi-core. They also run alongside CPUs. This makes things ...complicated.

A quick overview:

And this list could go on...

How do we deal with this?

The old answer to this question was "we don't, the graphics driver is made of tiny demons who figure it all out for us". But, as it turned out, tiny demons require special care and feeding (and sometimes they have to be paid!), so let's look at the current state of things.

Modern APIs like Vulkan expose this stuff to applications as a set of different memory types.

A memory type contains three bits of information:

The Vulkan memory API

In Vulanese, that's all wrapped up in this:

typedef struct VkMemoryType {
    VkMemoryPropertyFlags    propertyFlags;
    uint32_t                 heapIndex;
} VkMemoryType;

heapIndex tells us which heap this is associated with. propertyFlags tell us the memory's overall performance characteristics and how the CPU may and may not interact with it.

Memory type flags

These tell us (well, these strongly suggest) the location of the memory:

Caching flags

The rest of the flags have to do with how this memory will interact with the CPU's memory caches:

Sometimes there will be only one option in this regard. Sometimes drivers will offer multiple options, and the software chooses whichever it prefers. In such a case:

Secret driver sauce

As mentioned, a memory type may also contain hidden data. It manifests to applications as a cluster of memory types which share the same heapIndex and have exactly the same propertyFlags but which report different compatibility with Vulkan's resource types, as reported by functions like vkGetBufferMemoryRequirements or vkGetImageMemoryRequirements (specifically the memoryTypeBits field in their output structures).

Other flags

There are a few more property flags which aren't often used:

This post is part of the series Memory and Caching.