HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RV_Instance.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: RV_Instance.h ( RV Library, C++)
7  *
8  * COMMENTS:
9  * Main interface to Vulkan
10  */
11 #ifndef RV_Instance_h
12 #define RV_Instance_h
13 
14 #include "RV_API.h"
15 
16 #include "RV_Type.h"
17 
18 #include "RV_VK.h"
19 
20 #include <UT/UT_UniquePtr.h>
21 #include <UT/UT_Array.h>
22 
23 class rv_InstanceData;
24 
26 class RV_Render;
27 class RV_VKQueue;
28 class RV_VKCommandPool;
29 class RV_VKCommandBuffer;
30 class RV_VKCommandBufferAllocator;
31 class RV_VKExt;
32 class RV_VKMemAllocator;
33 class UT_WorkBuffer;
34 
35 /// Handle to the main interface of Vulkan
37 {
38 public:
39  /// The global vulkan instance. May be null if it hasn't been created yet.
40  static RV_Instance* getInstance();
41  /// Destroy the global instance. For system exit.
42  static void destroyInstance();
43  /// The exit callback that's called when the vulkan instance is about to be
44  /// destroyed.
45  static void exitCallback(void*);
46 
47  /// Create the global vulkan instance. Used only at startup.
48  static RV_Instance* create();
49 
50  ~RV_Instance();
51 
52  /// Set up Vulkan once the instance is created
53  bool initializeDevice();
54 
55  /// Get the raw vulkan device assocated with this instance.
56  VkDevice getDevice();
57  /// Get the raw vulkan physical device assocated with this instance.
58  VkPhysicalDevice getPhysicalDevice();
59  /// Get the raw vulkan instance.
60  VkInstance getVkInst();
61 
62  /// Raw Vulkan memory properties of the physical device
63  const VkPhysicalDeviceMemoryProperties* getMemoryProps() const;
64 
65  /// Our Vulkan memory allocator implementation
66  RV_VKMemAllocator& getMemAllocator() { return *myAllocator; }
67  /// Our Vulkan descriptor set allocator
68  RV_DescriptorAllocator& getDescAllocator(){return *myDescriptorAllocator;}
69 
70  /// Get text information about the current driver and device
71  void fetchDriverInfo(UT_WorkBuffer &info);
72 
75 
76  static const uint32_t requestedInstanceVersion;
77  static uint32_t getInstanceVersion();
78 
79  /// The Vulkan version as implemented by the device driver
80  uint32_t getDeviceVersion();
81  /// The vendor of the device (AMD, Intel, NVidia, MoltenVK)
82  RV_GraphicsDevice getDeviceVendor() const;
83 
84  /// Maximum supported number of color samples in a multisample framebuffer
85  int getMaxColorSamples() const;
86  /// Maximum supported number of depth samples in a multisample framebuffer
87  int getMaxDepthSamples() const;
88 
89  /// Object containing function pointers to Vulkan extensions
90  RV_VKExt* getExt() { return myExtensions.get(); }
91 
92  /// Query if the given Vulkan extension is enabled in the device
93  bool extEnabled( const char* vk_ext_name ) const;
94 
95  /// Block until the device has finished all commands (Call with care!)
96  void waitDeviceIdle();
97 
98  /// returns a pointer to a VkPhysicalDevice*Features structure or
99  /// a nullptr if feature is not found
100  const void* getPhysicalDeviceFeatures(VkStructureType feature_type) const;
101 
102 private:
103  RV_Instance();
104 
107  UT_UniquePtr<RV_DescriptorAllocator> myDescriptorAllocator;
108 
109  UT_UniquePtr<RV_VKExt> myExtensions;
110 
111  UT_Array<const char*> myEnabledDevExtensions;
112  UT_Array<const char*> myEnabledInstExtensions;
113 };
114 
115 #endif
VkStructureType
Definition: vulkan_core.h:208
RV_VKMemAllocator & getMemAllocator()
Our Vulkan memory allocator implementation.
Definition: RV_Instance.h:66
static const uint32_t requestedInstanceVersion
Definition: RV_Instance.h:76
RV_DescriptorAllocator & getDescAllocator()
Our Vulkan descriptor set allocator.
Definition: RV_Instance.h:68
std::unique_ptr< T, Deleter > UT_UniquePtr
A smart pointer for unique ownership of dynamically allocated objects.
Definition: UT_UniquePtr.h:39
RV_GraphicsDevice
Definition: RV_Type.h:70
UT_UniquePtr< RV_Render > myRender
Definition: RV_Instance.h:74
#define RV_API
Definition: RV_API.h:10
Handle to the main interface of Vulkan.
Definition: RV_Instance.h:36
RV_VKExt * getExt()
Object containing function pointers to Vulkan extensions.
Definition: RV_Instance.h:90
UT_UniquePtr< RV_VKQueue > myGraphicsQueue
Definition: RV_Instance.h:73