15 #include <vsg/core/ref_ptr.h>
16 #include <vsg/vk/AllocationCallbacks.h>
17 #include <vsg/vk/InstanceExtensions.h>
27 using Names = std::vector<const char*>;
28 using PhysicalDeviceTypes = std::vector<VkPhysicalDeviceType>;
29 using InstanceLayerProperties = std::vector<VkLayerProperties>;
30 using InstanceExtensionProperties = std::vector<VkExtensionProperties>;
33 extern VSG_DECLSPEC InstanceExtensionProperties enumerateInstanceExtensionProperties(
const char* pLayerName =
nullptr);
36 extern VSG_DECLSPEC InstanceLayerProperties enumerateInstanceLayerProperties();
39 extern VSG_DECLSPEC Names validateInstancelayerNames(
const Names& names);
45 Instance(Names instanceExtensions, Names layers, uint32_t vulkanApiVersion = VK_API_VERSION_1_0,
AllocationCallbacks* allocator =
nullptr);
48 const uint32_t apiVersion = VK_API_VERSION_1_0;
50 operator VkInstance()
const {
return _instance; }
51 VkInstance vk()
const {
return _instance; }
53 AllocationCallbacks* getAllocationCallbacks() {
return _allocator.get(); }
54 const AllocationCallbacks* getAllocationCallbacks()
const {
return _allocator.get(); }
56 using PhysicalDevices = std::vector<ref_ptr<PhysicalDevice>>;
57 PhysicalDevices& getPhysicalDevices() {
return _physicalDevices; }
58 const PhysicalDevices& getPhysicalDevices()
const {
return _physicalDevices; }
77 bool getProcAddr(T& procAddress,
const char* pName,
const char* pNameFallback =
nullptr)
const
79 procAddress =
reinterpret_cast<T
>(vkGetInstanceProcAddr(_instance, pName));
80 if (procAddress)
return true;
82 if (pNameFallback) procAddress =
reinterpret_cast<T
>(vkGetInstanceProcAddr(_instance, pNameFallback));
92 PhysicalDevices _physicalDevices;
Adapter class that provides a means of managing the lifetime of VkAllocationCallbacks.
Definition: AllocationCallbacks.h:24
Definition: InstanceExtensions.h:24
Instance encapsulates the VkInstance.
Definition: Instance.h:43
bool getProcAddr(T &procAddress, const char *pName, const char *pNameFallback=nullptr) const
get the address of specified function using vkGetInstanceProcAddr.
Definition: Instance.h:77
std::tuple< ref_ptr< PhysicalDevice >, int, int > getPhysicalDeviceAndQueueFamily(VkQueueFlags queueFlags, Surface *surface, const PhysicalDeviceTypes &deviceTypePreferences={}) const
get a PhysicalDevice and queue family index that supports the specified queueFlags,...
const InstanceExtensions * getExtensions() const
get the extensions structure that holds a range of function pointers to vkInstance extensions
Definition: Instance.h:73
std::pair< ref_ptr< PhysicalDevice >, int > getPhysicalDeviceAndQueueFamily(VkQueueFlags queueFlags, const PhysicalDeviceTypes &deviceTypePreferences={}) const
get a PhysicalDevice and queue family index that supports the specified queueFlags,...
ref_ptr< PhysicalDevice > getPhysicalDevice(VkQueueFlags queueFlags, Surface *surface, const PhysicalDeviceTypes &deviceTypePreferences={}) const
get a PhysicalDevice that supports the specified queueFlags, and presentation of specified surface if...
ref_ptr< PhysicalDevice > getPhysicalDevice(VkQueueFlags queueFlags, const PhysicalDeviceTypes &deviceTypePreferences={}) const
get a PhysicalDevice that supports the specified queueFlags, and presentation of specified surface if...
Surface encapsulates VkSurfaceKHR.
Definition: Surface.h:22