Using PVRVk#

PVRVk follows the Vulkan spec, and all operations that would need to be performed in Vulkan are performed with PVRVk. The calls themselves are considerably shortened due to the constructors and default values, while reference counting again dramatically reduces the overhead code required.

For simplifying the operations and tasks themselves see PVRUtils.

Note that with PVRVk, the optimised, per-device function pointers are always called as devices and hold their function pointer tables internally. Function pointers do not need to be retrieved with VkGetDeviceProcaddress or similar, as this happens automatically during construction of the device.

There are obvious usage changes, due to the Object Oriented paradigm followed:

  • Vulkan functions whose first parameter is a Vulkan object become member functions of the class of that object. For example, VkCreateBuffer becomes a member function of pvrvk::Device, so use myDevice->createBuffer().

  • Functions without a dispatchable object as an input parameter object remain global functions in the pvrvk:: namespace. For example, pvrvk::CreateInstance(…).

  • Simple structs like Offset2D are shadowed in the pvrvk:: namespace.

  • VkXXXCreateInfo objects get shadowed bypvrvk:: equivalents with default parameters and potentially setters. Obvious simplifications/automations are done, for instance VK_STRUCTURE_TYPE is never required as it is populated automatically.

  • Vulkan objects are wrapped in C++ reference-counted classes providing them with a proper C++ interface. Usage remains the same and the Vk… prefix is dropped. For example, VkBuffer becomes pvrvk::Buffer.

  • All enums are shadowed by C++ scoped enums (enum class TypeName)

    • The VK_ENUM_*TYPE_NAME*_ prefix of enum members is dropped and replaced by e_. In many cases, for example after dropping VK_ FORMAT_2D, this would become pvrvk::Format::2D which is illegal as it starts with a number.

    • Flags/Bitfields are used like every other enum as bitwise operators are defined for them. VkCreateBufferFlags and VkCreateBufferFlagBits become pvrvk::CreateBufferFlags and are directly passed to corresponding functions.