VPP  0.8
A high-level modern C++ API for Vulkan
vpp::Instance Class Reference

Represents the instance of Vulkan system. More...

#include <vppInstance.hpp>

Public Member Functions

 ~Instance ()
 Destructor.
 
VkInstance handle () const
 Retrieves Vulkan handle for the instance.
 
bool valid () const
 Checks whether instance creation has succeeded.
 
const std::set< std::string > & enabledExtensions () const
 Retrieves the names of enabled extensions.
 
VkResult enumeratePhysicalDevices (PhysicalDevices *pResult) const
 Gets a list of physical devices in the system.
 

Static Public Member Functions

static SVulkanVersion getLatestAvailableVulkanVersion ()
 Gets newest Vulkan version available on the system. More...
 
static SVulkanVersion supportedVersion ()
 Gets the minimum of two versions: latest available and requested by user.
 
static VkResult enumerateExtensions (ExtensionProperties *pResult)
 Gets a list of available Vulkan extensions for the instance.
 
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.

Instance is created by means of createInstance() special function.

An example:

int main()
{
#ifdef MY_DEBUG_BUILD
const bool bValidation = true;
#else
const bool bValidation = false;
#endif
vpp::Instance myInstance = createInstance().validation ( bValidation );
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 );
}

Member Function Documentation

◆ getLatestAvailableVulkanVersion()

static SVulkanVersion vpp::Instance::getLatestAvailableVulkanVersion ( )
static

Gets newest Vulkan version available on the system.

Caution: on systems where there is no Vulkan driver installed, it might still return version 1.0. Try creating instance and check valid() method on it in order to determine if Vulkan is supported at all.


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