Is Vulkan's VkMemoryHeapFlagBits missing value

2019-04-29 20:37发布

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 ?

1条回答
萌系小妹纸
2楼-- · 2019-04-29 21:01

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.

查看更多
登录 后发表回答