Skip to content

Naming Conventions

Sean Moss edited this page Oct 6, 2020 · 3 revisions

This page contains some notes about how names in the API were translated in the generated API.

Types

Type names in the API take the form "Vk" in TitleCase. The generated API keeps the names, but moves the extension to be the namespace name. Bitmask types (which end in "FlagBits") is changed to "Flags".

Examples:

  • VkExtent3D -> Vk.Extent3D
  • VkSurfaceKHR -> Vk.KHR.Surface
  • VkMemoryAllocateFlagBits -> Vk.MemoryAllocateFlags

Struct Fields

Struct fields are translated into TitleCase to match the standard naming conventions for C# public fields. If they use Hungarian Notation (such as pp for pointer-to-pointer fields), those prefixes are removed from the name. The only time this is not followed is for the sType and pNext fields in "typed" structs, since they are special "internal" (kinda) fields specific to the type and API.

Enum Fields

Enum values are in the form "VK_<ENUM_NAME>_<VALUE_NAME>_<EXTENSION>". Because enums are strongly-typed in C#, we drop the enum type name from the name. The leading "VK_" is also dropped. The remaining name is converted into TitleCase, and the extension is kept at the end. If the resulting name starts with a digit, then an "E" is prepended (following the C++ API convention).

Additionally, the ending "_BIT" is removed from enum values that are used as bitmasks.

Examples:

  • VK_COMPARE_OP_NEVER -> Never (in the CompareOp enum)
  • VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT -> DiscardRectangleEXT (in the DynamicState enum)
  • VK_IMAGE_TYPE_1D -> E1D (in the ImageType enum)
  • VK_MEMORY_ALLOCATE_DEVICE_MASK_BIT -> DeviceMask (in the MemoryAllocateFlags enum)

Constants

Constant values keep their API names, minus the "VK_", and get placed in the Vk.Constants static class. This includes the "*_SPEC_VERSION" and "*_EXTENSION_NAME" constants.

Examples:

  • VK_TRUE -> Vk.Constants.TRUE
  • VK_UUID_SIZE -> Vk.Constants.UUID_SIZE
  • VK_KHR_SURFACE_SPEC_VERSION -> Vk.Constants.KHR_SURFACE_SPEC_VERSION
Clone this wiki locally