HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_Instance Class Reference

Handle to the main interface of Vulkan. More...

#include <RV_Instance.h>

Public Types

using RenderCallback = UT_Function< void(RV_Instance *)>
 

Public Member Functions

void addPostRenderCB (const RenderCallback &callback)
 
void finishRendering (RV_Render *r)
 
 ~RV_Instance ()
 
bool initializeDevice ()
 Set up Vulkan once the instance is created. More...
 
VkDevice getDevice ()
 Get the raw vulkan device assocated with this instance. More...
 
VkPhysicalDevice getPhysicalDevice ()
 Get the raw vulkan physical device assocated with this instance. More...
 
VkInstance getVkInst ()
 Get the raw vulkan instance. More...
 
const
VkPhysicalDeviceMemoryProperties
getMemoryProps () const
 Raw Vulkan memory properties of the physical device. More...
 
const
VkPhysicalDeviceAccelerationStructurePropertiesKHR
getAccelStructProps () const
 Raw Vulkan acceleration structure properties of the physical device. More...
 
const VkPhysicalDeviceLimitsgetVulkanDeviceLimits () const
 Raw Vulkan acceleration structure properties of the physical device. More...
 
void getDeviceUUID (uint8(&uuid)[16]) const
 Vulkan device UUID, used to match devices for cross-API interop. More...
 
RV_VKQueue & getGraphicsQueue ()
 Main Queue supporting graphics, compute and transfer. More...
 
RV_VKMemAllocator & getMemAllocator ()
 Our Vulkan memory allocator implementation. More...
 
RV_DescriptorAllocatorgetDescAllocator ()
 Our Vulkan descriptor set allocator. More...
 
void fetchDriverInfo (UT_WorkBuffer &info)
 Get text information about the current driver and device. More...
 
uint32_t getDeviceVersion ()
 The Vulkan version as implemented by the device driver. More...
 
RV_GraphicsDevice getDeviceVendor () const
 The vendor of the device (AMD, Intel, NVIDIA, MoltenVK) More...
 
const UT_StringHolderdeviceName () const
 
int getMaxColorSamples () const
 Maximum supported number of color samples in a multisample framebuffer. More...
 
int getMaxDepthSamples () const
 Maximum supported number of depth samples in a multisample framebuffer. More...
 
int getMaxTextureSize2D () const
 Maximum size of 2D texture. More...
 
int getMaxTextureSize3D () const
 Maximum size of 3D texture. More...
 
float getLineWidthGranularity () const
 Granularity of Line width setting. More...
 
UT_Vector2F getLineWidthRange () const
 Range of Line width setting. More...
 
float getPointSizeGranularity () const
 Granularity of Point Size setting. More...
 
UT_Vector2F getPointSizeRange () const
 Range of Point Size setting. More...
 
RV_VKExtgetExt ()
 Object containing function pointers to Vulkan extensions. More...
 
bool extEnabled (const char *vk_ext_name) const
 Query if the given Vulkan extension is enabled in the device. More...
 
bool getFeatureStruct (VkBaseOutStructure *out_feature_struct, exint feature_struct_size_bytes) const
 Query the features enabled on the RV_Instance's VkDevice. Copies the feature flags used in device creation into out_feature_struct and returns true, if a feature struct with the matching sType was used. If a matching struct wasn't used, returns false. More...
 
bool useLinearTilingForGLInterop () const
 Query restriction for GL to Vulkan interop texture. If true, must use linear textures. More...
 
bool supportsSampleLocations (int aa) const
 Query if custom sample locations can be used for the given MSAA level. More...
 
void waitDeviceIdle ()
 Block until the device has finished all commands (Call with care!) More...
 
const VE_PhysicalDeviceFeaturesgetPhysicalDeviceFeatures () const
 
RV_ResourceID registerImage (RV_VKImage *img)
 
void clearImage (RV_VKImage *img)
 
bool validateImage (RV_ResourceID id, bool allow_pending_delete=false) const
 
void setDeletePending (RV_VKImage *img)
 
RV_ResourceID registerBuffer (RV_VKBuffer *buf)
 
void clearBuffer (RV_VKBuffer *buf)
 
bool validateBuffer (RV_ResourceID id, bool allow_pending_delete=false) const
 
void setDeletePending (RV_VKBuffer *buf)
 
RV_ResourceID registerAccelStruct (RV_VKAccelerationStructure *accel_struct)
 
void clearAccelStruct (RV_VKAccelerationStructure *accel_struct)
 
bool validateAccelStruct (RV_ResourceID id, bool allow_pending_delete=false) const
 
void setDeletePending (RV_VKAccelerationStructure *accel_struct)
 
RV_ResourceID registerSet (RV_VKDescriptorSet *set)
 
void clearSet (RV_VKDescriptorSet *set)
 
bool validateSet (RV_ResourceID id, bool allow_pending_delete=false) const
 
void setDeletePending (RV_VKDescriptorSet *set)
 
void printIDs () const
 

Static Public Member Functions

static RV_InstancegetInstance ()
 The global vulkan instance, creating it if it hasn't been created yet. More...
 
static bool hasInstance ()
 Returns whether the global vulkan instance exists. More...
 
static void destroyInstance ()
 Destroy the global instance. For system exit. More...
 
static void exitCallback (void *)
 The callback that's called on app exit to destroy the global instance. More...
 
static void addPostCreateCB (bool(*cb)(RV_Instance *))
 add callbacks to be called as soon as instance is created More...
 
static bool hasPostCreateCBs ()
 
static void addPreDestroyCB (bool(*cb)(RV_Instance *))
 
static bool hasPreDestroyCBs ()
 
static void addExtraDeviceExtension (const char *ext_name, VkBaseOutStructure *feature_struct=nullptr, exint struct_size_bytes=0)
 Request extensions or features to be enabled on the Vulkan device Can be called before the RV_Instance is created to add extra device extensions to be enabled, if supported on the selected device. Can pass in a feature struct with the extension, to enable extension-specific features. More...
 
static bool hasExtraDeviceExtension (const char *ext_name, VkBaseOutStructure *feature_struct=nullptr, exint feature_struct_size_bytes=0)
 
static void addExtraInstanceExtension (const char *ext_name)
 
static RV_Instancecreate ()
 Create the global vulkan instance. Used only at startup. More...
 
static uint32_t getInstanceVersion ()
 
static bool usingDebugValidation ()
 True if the debug validation layers are active. More...
 
static bool usingVulkanMultithreading ()
 True if Vulkan multithreading env var is set to true. More...
 

Detailed Description

Handle to the main interface of Vulkan.

Definition at line 44 of file RV_Instance.h.

Member Typedef Documentation

add callback to be called when current rendering is finished. Typed as a UT_Function instead of function ptr , so capturing lambdas can be used as callbacks

Definition at line 109 of file RV_Instance.h.

Constructor & Destructor Documentation

RV_Instance::~RV_Instance ( )

Member Function Documentation

static void RV_Instance::addExtraDeviceExtension ( const char *  ext_name,
VkBaseOutStructure feature_struct = nullptr,
exint  struct_size_bytes = 0 
)
static

Request extensions or features to be enabled on the Vulkan device Can be called before the RV_Instance is created to add extra device extensions to be enabled, if supported on the selected device. Can pass in a feature struct with the extension, to enable extension-specific features.

Core features can be also requested by passing the appropriate struct (e.g. VkPhysicalDeviceFeatures2, VkPhysicalDeviceVulkan11Features, etc.) with nullptr as the name. Features from any extensions promoted to Core in Vulkan 1.1, 1.2, or 1.3 should be requested using the Core Vulkan features struct, NOT the extension specific struct.

After the instance is created, it should be queried wtih extEnabled() and 'getFeatureStruct()' to confirm whether the requested extensions and features were supported

Parameters
ext_namethe name of the extension
feature_structThe feature struct for the extension, with desired features flags enabled. It can be 'nullptr' if the extension doesn't have features
struct_size_bytesthe size in bytes of the feature struct
static void RV_Instance::addExtraInstanceExtension ( const char *  ext_name)
static

Can be called before the RV_Instance is created to add extra instance extensions to be enabled (if supported) on the selected device

static void RV_Instance::addPostCreateCB ( bool(*)(RV_Instance *)  cb)
static

add callbacks to be called as soon as instance is created

void RV_Instance::addPostRenderCB ( const RenderCallback callback)
static void RV_Instance::addPreDestroyCB ( bool(*)(RV_Instance *)  cb)
static

add callbacks to be called before the instance is destroyed. the list is cleared after the instance is destroyed, so they must be re-added for a new instance

void RV_Instance::clearAccelStruct ( RV_VKAccelerationStructure accel_struct)
void RV_Instance::clearBuffer ( RV_VKBuffer buf)
void RV_Instance::clearImage ( RV_VKImage img)
void RV_Instance::clearSet ( RV_VKDescriptorSet set)
static RV_Instance* RV_Instance::create ( )
static

Create the global vulkan instance. Used only at startup.

static void RV_Instance::destroyInstance ( )
static

Destroy the global instance. For system exit.

const UT_StringHolder& RV_Instance::deviceName ( ) const
inline

Definition at line 160 of file RV_Instance.h.

static void RV_Instance::exitCallback ( void )
static

The callback that's called on app exit to destroy the global instance.

bool RV_Instance::extEnabled ( const char *  vk_ext_name) const

Query if the given Vulkan extension is enabled in the device.

void RV_Instance::fetchDriverInfo ( UT_WorkBuffer info)

Get text information about the current driver and device.

void RV_Instance::finishRendering ( RV_Render r)

notification from active RV_Render that current rendering tasks are about to flushed

const VkPhysicalDeviceAccelerationStructurePropertiesKHR* RV_Instance::getAccelStructProps ( ) const

Raw Vulkan acceleration structure properties of the physical device.

RV_DescriptorAllocator& RV_Instance::getDescAllocator ( )
inline

Our Vulkan descriptor set allocator.

Definition at line 148 of file RV_Instance.h.

VkDevice RV_Instance::getDevice ( )

Get the raw vulkan device assocated with this instance.

void RV_Instance::getDeviceUUID ( uint8(&)  uuid[16]) const

Vulkan device UUID, used to match devices for cross-API interop.

RV_GraphicsDevice RV_Instance::getDeviceVendor ( ) const

The vendor of the device (AMD, Intel, NVIDIA, MoltenVK)

uint32_t RV_Instance::getDeviceVersion ( )

The Vulkan version as implemented by the device driver.

RV_VKExt* RV_Instance::getExt ( )
inline

Object containing function pointers to Vulkan extensions.

Definition at line 193 of file RV_Instance.h.

bool RV_Instance::getFeatureStruct ( VkBaseOutStructure out_feature_struct,
exint  feature_struct_size_bytes 
) const

Query the features enabled on the RV_Instance's VkDevice. Copies the feature flags used in device creation into out_feature_struct and returns true, if a feature struct with the matching sType was used. If a matching struct wasn't used, returns false.

RV_VKQueue& RV_Instance::getGraphicsQueue ( )
inline

Main Queue supporting graphics, compute and transfer.

Definition at line 144 of file RV_Instance.h.

static RV_Instance* RV_Instance::getInstance ( )
static

The global vulkan instance, creating it if it hasn't been created yet.

static uint32_t RV_Instance::getInstanceVersion ( )
static
float RV_Instance::getLineWidthGranularity ( ) const

Granularity of Line width setting.

UT_Vector2F RV_Instance::getLineWidthRange ( ) const

Range of Line width setting.

int RV_Instance::getMaxColorSamples ( ) const

Maximum supported number of color samples in a multisample framebuffer.

int RV_Instance::getMaxDepthSamples ( ) const

Maximum supported number of depth samples in a multisample framebuffer.

int RV_Instance::getMaxTextureSize2D ( ) const

Maximum size of 2D texture.

int RV_Instance::getMaxTextureSize3D ( ) const

Maximum size of 3D texture.

RV_VKMemAllocator& RV_Instance::getMemAllocator ( )
inline

Our Vulkan memory allocator implementation.

Definition at line 146 of file RV_Instance.h.

const VkPhysicalDeviceMemoryProperties* RV_Instance::getMemoryProps ( ) const

Raw Vulkan memory properties of the physical device.

VkPhysicalDevice RV_Instance::getPhysicalDevice ( )

Get the raw vulkan physical device assocated with this instance.

const VE_PhysicalDeviceFeatures& RV_Instance::getPhysicalDeviceFeatures ( ) const

Returns the physical device features that have been enabled on our device

float RV_Instance::getPointSizeGranularity ( ) const

Granularity of Point Size setting.

UT_Vector2F RV_Instance::getPointSizeRange ( ) const

Range of Point Size setting.

VkInstance RV_Instance::getVkInst ( )

Get the raw vulkan instance.

const VkPhysicalDeviceLimits* RV_Instance::getVulkanDeviceLimits ( ) const

Raw Vulkan acceleration structure properties of the physical device.

static bool RV_Instance::hasExtraDeviceExtension ( const char *  ext_name,
VkBaseOutStructure feature_struct = nullptr,
exint  feature_struct_size_bytes = 0 
)
static

Query if an extension has been added to the Extra Extension list. If the appropriate feature struct is supplied, it will be filled with requested features. Parameters same as 'addExtraDeviceExtension()'

static bool RV_Instance::hasInstance ( )
static

Returns whether the global vulkan instance exists.

static bool RV_Instance::hasPostCreateCBs ( )
static
static bool RV_Instance::hasPreDestroyCBs ( )
static
bool RV_Instance::initializeDevice ( )

Set up Vulkan once the instance is created.

void RV_Instance::printIDs ( ) const
RV_ResourceID RV_Instance::registerAccelStruct ( RV_VKAccelerationStructure accel_struct)
RV_ResourceID RV_Instance::registerBuffer ( RV_VKBuffer buf)
RV_ResourceID RV_Instance::registerImage ( RV_VKImage img)

register - called on creation, to get a Unique ID for the resource clear - called on destruction validate - can be called to check if the ID's resource is still valid setDeletePending - flags the resource as being queued for deletion by

RV_ResourceID RV_Instance::registerSet ( RV_VKDescriptorSet set)
void RV_Instance::setDeletePending ( RV_VKImage img)
void RV_Instance::setDeletePending ( RV_VKBuffer buf)
void RV_Instance::setDeletePending ( RV_VKAccelerationStructure accel_struct)
void RV_Instance::setDeletePending ( RV_VKDescriptorSet set)
bool RV_Instance::supportsSampleLocations ( int  aa) const

Query if custom sample locations can be used for the given MSAA level.

bool RV_Instance::useLinearTilingForGLInterop ( ) const

Query restriction for GL to Vulkan interop texture. If true, must use linear textures.

static bool RV_Instance::usingDebugValidation ( )
static

True if the debug validation layers are active.

static bool RV_Instance::usingVulkanMultithreading ( )
static

True if Vulkan multithreading env var is set to true.

bool RV_Instance::validateAccelStruct ( RV_ResourceID  id,
bool  allow_pending_delete = false 
) const
bool RV_Instance::validateBuffer ( RV_ResourceID  id,
bool  allow_pending_delete = false 
) const
bool RV_Instance::validateImage ( RV_ResourceID  id,
bool  allow_pending_delete = false 
) const
bool RV_Instance::validateSet ( RV_ResourceID  id,
bool  allow_pending_delete = false 
) const
void RV_Instance::waitDeviceIdle ( )

Block until the device has finished all commands (Call with care!)


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