Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Vulkan's VkMemoryHeapFlagBits missing values?

At Vulkan specs 1.0.9 (pg. 180), we have the following:

typedef struct VkMemoryHeap {
  VkDeviceSize size;
  VkMemoryHeapFlags flags;
} VkMemoryHeap;

and this description:

• size is the total memory size in bytes in the heap.

• flags is a bitmask of attribute flags for the heap. The bits specified in flags are:

typedef enum VkMemoryHeapFlagBits {
VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001,
} VkMemoryHeapFlagBits;

But when I query VkPhysicalDeviceMemoryProperties I've got flags with zero values. My code matches the output from Vulkan SDK vkjson_info.exe tool, which output a JSON file with properties from my GPU.

Is something missing here ?

like image 518
Alex Byrth Avatar asked Apr 20 '16 16:04

Alex Byrth


1 Answers

No. It is perfectly valid for VkMemoryHeap::flags to be 0. A particular flag is either present or absent; it's not an enumeration where the value can attain one of a small number of different possibilities. Usually, flags are independent of one another.

That's how bitflags work; they represent boolean conditions. A particular flag is either present or absent. If a flag is present, then the object attains the meaning that the flag defines. If it is absent, then the object doesn't have that meaning.

A heap with VK_MEMORY_HEAP_DEVICE_LOCAL_BIT means exactly what the specification says it means: "the heap corresponds to device local memory". A heap without that flag set means that heap does not "correspond to device local memory".

The specification requires that at least one heap have this flag set. But that's all.

like image 156
Nicol Bolas Avatar answered Nov 19 '22 05:11

Nicol Bolas