VPP  0.7
A high-level modern C++ API for Vulkan
Public Types | Public Member Functions | Static Public Member Functions | List of all members
vpp::Instance Class Reference

Represents the instance of Vulkan system. More...

#include <vppInstance.hpp>

Public Types

enum  EFlags { NO_FLAGS, VALIDATION }
 Flags for instance creation. More...
 

Public Member Functions

 Instance (unsigned int flags=0)
 The constructor. More...
 
 ~Instance ()
 Destructor.
 
VkInstance handle () const
 Retrieves Vulkan handle for the instance.
 
bool valid () const
 Checks whether instance creation has succeeded.
 
VkResult enumeratePhysicalDevices (PhysicalDevices *pResult) const
 Gets a list of physical devices in the system.
 

Static Public Member Functions

static VkResult enumerateExtensions (ExtensionProperties *pResult)
 Gets a list of available Vulkan extensions.
 
static DebugReportergetDebugReporter ()
 Gets currently registered debug reporter, or zero if there is no one.
 

Detailed Description

Represents the instance of Vulkan system.

The instance is the root object of entire Vulkan system. The main purpose is to provide access to physical devices in the system as well as the list of available Vulkan extensions.

There can be only one instance object per program. You can construct multiple ones, but all of them will point to the same object internally. Do not create many instances from different threads however, this operation is not thread safe. Best practice is to create just one, from your main thread and keep its life time until the end of the program. You can pass the Instance object by value, also to other threads.

This object is reference-counted and may be passed by value.

Member Enumeration Documentation

◆ EFlags

Flags for instance creation.

Enumerator
NO_FLAGS 

All options disabled.

VALIDATION 

Enable Vulkan validation.

Constructor & Destructor Documentation

◆ Instance()

vpp::Instance::Instance ( unsigned int  flags = 0)
explicit

The constructor.

Takes optional flags.

An example:

int main()
{
#ifdef MY_DEBUG_BUILD
static const unsigned int vppFlags = vpp::Instance::VALIDATION;
#else
static const unsigned int vppFlags = 0u;
#endif
vpp::Instance myInstance ( vppFlags );
if ( ! myInstance.valid() )
{
// Can't create instance - maybe this system does not support Vulkan.
return -1;
}
vpp::PhysicalDevices physicalDevices;
if ( myInstance.enumeratePhysicalDevices ( & physicalDevices ) != VK_SUCCESS
|| physicalDevices.empty() )
{
// No Vulkan-capable devices found.
return -1;
}
// Optionally handle multiple devices. Here we just pick the first one.
const vpp::PhysicalDevice hPhysicalDevice = physicalDevices [ 0 ];
// Application main loop routine.
return runApplication ( myInstance, hPhysicalDevice );
}

The documentation for this class was generated from the following file: