Foray Library
rapid prototyping framework for crossplatform development of vulkan hardware ray tracing applications
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
foray::base::VulkanDevice Class Reference

Wraps selection and creation of a vulkan logical device. More...

#include <foray_vulkandevice.hpp>

Classes

struct  DefaultFeatures
 

Public Types

using BeforePhysicalDeviceSelectFunctionPointer = std::function< void(vkb::PhysicalDeviceSelector &)>
 Function called after default configuration and before action with physical device selector.
 
using BeforeDeviceBuildFunctionPointer = std::function< void(vkb::DeviceBuilder &)>
 Function called after default configuration and before action with device builder.
 

Public Member Functions

 VulkanDevice ()=default
 
 VulkanDevice (core::Context *context, BeforePhysicalDeviceSelectFunctionPointer beforePhysicalDeviceSelectFunc, BeforeDeviceBuildFunctionPointer beforeDeviceBuildFunc)
 
 operator bool () const
 
 operator VkDevice () const
 
 operator VkPhysicalDevice () const
 
 operator vkb::Device & ()
 
 operator const vkb::Device & () const
 
VulkanDeviceSetBeforePhysicalDeviceSelectFunc (BeforePhysicalDeviceSelectFunctionPointer beforePhysicalDeviceSelectFunc)
 Set the function called after default configuration and before action with physical device selector.
 
VulkanDeviceSetBeforeDeviceBuildFunc (BeforeDeviceBuildFunctionPointer beforeDeviceBuildFunc)
 Set the function called after default configuration and before action with device builder.
 
void Create ()
 Create logical device by invoking SelectPhysicalDevice(..,) and BuildDevice()
 
void SelectPhysicalDevice ()
 If mSetDefaultCapabilitiesToDeviceSelector is set, configures defaults. If mBeforePhysicalDeviceSelectFunc is set, invokes it. Finally, selects device.
 
void BuildDevice ()
 If mEnableDefaultDeviceFeatures is set, configures defaults. If mBeforeDeviceBuildFunc is set, invokes it. Builds device.
 
bool Exists () const
 
void Destroy ()
 
 ~VulkanDevice ()
 

Protected Attributes

BeforePhysicalDeviceSelectFunctionPointer mBeforePhysicalDeviceSelectFunc = nullptr
 
BeforeDeviceBuildFunctionPointer mBeforeDeviceBuildFunc = nullptr
 
bool mSetDefaultCapabilitiesToDeviceSelector = true
 Requires present capability, prefers dedicated devices. Enables VK_KHR_ACCELERATION_STRUCTURE, VK_KHR_RAY_TRACING_PIPELINE and VK_KHR_SYNCHRONIZATION_2 extensions (plus extensions those depend on). Enables samplerAnisotropy feature.
 
bool mEnableDefaultDeviceFeatures = true
 Enables features listed in mDefaultFeatures member.
 
bool mEnableDefaultPhysicalDeviceFeatures = true
 Enables features a few physical device features (anisotrophy, etc.)
 
bool mShowConsoleDeviceSelectionPrompt = false
 If enabled, prompts the user in the console to select a device if multiple suitable devices are present. If disabled, selects the first index.
 
core::ContextmContext = nullptr
 
vkb::PhysicalDevice mPhysicalDevice
 
vkb::Device mDevice
 
vkb::DispatchTable mDispatchTable
 
struct foray::base::VulkanDevice::DefaultFeatures mDefaultFeatures = {}
 
VkPhysicalDeviceFeatures mPhysicalDeviceFeatures {}
 

Detailed Description

Wraps selection and creation of a vulkan logical device.

Member Typedef Documentation

◆ BeforeDeviceBuildFunctionPointer

using foray::base::VulkanDevice::BeforeDeviceBuildFunctionPointer = std::function<void(vkb::DeviceBuilder&)>

Function called after default configuration and before action with device builder.

◆ BeforePhysicalDeviceSelectFunctionPointer

using foray::base::VulkanDevice::BeforePhysicalDeviceSelectFunctionPointer = std::function<void(vkb::PhysicalDeviceSelector&)>

Function called after default configuration and before action with physical device selector.

Constructor & Destructor Documentation

◆ VulkanDevice() [1/2]

foray::base::VulkanDevice::VulkanDevice ( )
default

◆ VulkanDevice() [2/2]

foray::base::VulkanDevice::VulkanDevice ( core::Context context,
BeforePhysicalDeviceSelectFunctionPointer  beforePhysicalDeviceSelectFunc,
BeforeDeviceBuildFunctionPointer  beforeDeviceBuildFunc 
)
inline
Parameters
beforePhysicalDeviceSelectFuncFunction called after default configuration and before action with physical device selector
beforeDeviceBuildFuncFunction called after default configuration and before action with device builder

◆ ~VulkanDevice()

foray::base::VulkanDevice::~VulkanDevice ( )

Member Function Documentation

◆ BuildDevice()

void foray::base::VulkanDevice::BuildDevice ( )

If mEnableDefaultDeviceFeatures is set, configures defaults. If mBeforeDeviceBuildFunc is set, invokes it. Builds device.

Remarks
Will throw std::exception if building fails

◆ Create()

void foray::base::VulkanDevice::Create ( )

Create logical device by invoking SelectPhysicalDevice(..,) and BuildDevice()

Remarks
Will throw std::exception on selection or build failure

◆ Destroy()

void foray::base::VulkanDevice::Destroy ( )

◆ Exists()

bool foray::base::VulkanDevice::Exists ( ) const
inline

◆ operator bool()

foray::base::VulkanDevice::operator bool ( ) const
inline

◆ operator const vkb::Device &()

foray::base::VulkanDevice::operator const vkb::Device & ( ) const
inline

◆ operator vkb::Device &()

foray::base::VulkanDevice::operator vkb::Device & ( )
inline

◆ operator VkDevice()

foray::base::VulkanDevice::operator VkDevice ( ) const
inline

◆ operator VkPhysicalDevice()

foray::base::VulkanDevice::operator VkPhysicalDevice ( ) const
inline

◆ SelectPhysicalDevice()

void foray::base::VulkanDevice::SelectPhysicalDevice ( )

If mSetDefaultCapabilitiesToDeviceSelector is set, configures defaults. If mBeforePhysicalDeviceSelectFunc is set, invokes it. Finally, selects device.

Remarks
Will throw std::exception if no selection could be made

◆ SetBeforeDeviceBuildFunc()

VulkanDevice & foray::base::VulkanDevice::SetBeforeDeviceBuildFunc ( BeforeDeviceBuildFunctionPointer  beforeDeviceBuildFunc)

Set the function called after default configuration and before action with device builder.

◆ SetBeforePhysicalDeviceSelectFunc()

VulkanDevice & foray::base::VulkanDevice::SetBeforePhysicalDeviceSelectFunc ( BeforePhysicalDeviceSelectFunctionPointer  beforePhysicalDeviceSelectFunc)

Set the function called after default configuration and before action with physical device selector.

Member Data Documentation

◆ mBeforeDeviceBuildFunc

BeforeDeviceBuildFunctionPointer foray::base::VulkanDevice::mBeforeDeviceBuildFunc = nullptr
protected

◆ mBeforePhysicalDeviceSelectFunc

BeforePhysicalDeviceSelectFunctionPointer foray::base::VulkanDevice::mBeforePhysicalDeviceSelectFunc = nullptr
protected

◆ mContext

core::Context* foray::base::VulkanDevice::mContext = nullptr
protected

◆ mDefaultFeatures

struct foray::base::VulkanDevice::DefaultFeatures foray::base::VulkanDevice::mDefaultFeatures = {}
protected

◆ mDevice

vkb::Device foray::base::VulkanDevice::mDevice
protected

◆ mDispatchTable

vkb::DispatchTable foray::base::VulkanDevice::mDispatchTable
protected

◆ mEnableDefaultDeviceFeatures

bool foray::base::VulkanDevice::mEnableDefaultDeviceFeatures = true
protected

Enables features listed in mDefaultFeatures member.

◆ mEnableDefaultPhysicalDeviceFeatures

bool foray::base::VulkanDevice::mEnableDefaultPhysicalDeviceFeatures = true
protected

Enables features a few physical device features (anisotrophy, etc.)

◆ mPhysicalDevice

vkb::PhysicalDevice foray::base::VulkanDevice::mPhysicalDevice
protected

◆ mPhysicalDeviceFeatures

VkPhysicalDeviceFeatures foray::base::VulkanDevice::mPhysicalDeviceFeatures {}
protected

◆ mSetDefaultCapabilitiesToDeviceSelector

bool foray::base::VulkanDevice::mSetDefaultCapabilitiesToDeviceSelector = true
protected

Requires present capability, prefers dedicated devices. Enables VK_KHR_ACCELERATION_STRUCTURE, VK_KHR_RAY_TRACING_PIPELINE and VK_KHR_SYNCHRONIZATION_2 extensions (plus extensions those depend on). Enables samplerAnisotropy feature.

◆ mShowConsoleDeviceSelectionPrompt

bool foray::base::VulkanDevice::mShowConsoleDeviceSelectionPrompt = false
protected

If enabled, prompts the user in the console to select a device if multiple suitable devices are present. If disabled, selects the first index.


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