API Documentation
Loading...
Searching...
No Matches
VulkanInstance.h
Go to the documentation of this file.
1/*--------------------------------------------------------------------------------------------
2Copyright (c) 2019, NDEVR LLC
3tyler.parke@ndevr.org
4 __ __ ____ _____ __ __ _______
5 | \ | | | __ \ | ___|\ \ / / | __ \
6 | \ | | | | \ \ | |___ \ \ / / | |__) |
7 | . \| | | |__/ / | |___ \ V / | _ /
8 | |\ |_|_____/__|_____|___\_/____| | \ \
9 |__| \__________________________________| \__\
10
11Subject to the terms of the Enterprise+ Agreement, NDEVR hereby grants
12Licensee a limited, non-exclusive, non-transferable, royalty-free license
13(without the right to sublicense) to use the API solely for the purpose of
14Licensee's internal development efforts to develop applications for which
15the API was provided.
16
17The above copyright notice and this permission notice shall be included in all
18copies or substantial portions of the Software.
19
20THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
21INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
22PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
23FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
24OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
25DEALINGS IN THE SOFTWARE.
26
27Library: Graphics
28File: VulkanInstance
29Included in API: True
30Author(s): Tyler Parke
31 *-----------------------------------------------------------------------------------------**/
32#pragma once
33#include "VulkanDefines.h"
34#include "VulkanDefines.h"
35#include "Base/Headers/RWLock.h"
36#include "Base/Headers/String.h"
39#include "Base/Headers/Time.h"
40#include "Base/Headers/UUID.h"
42#include <vulkan/vulkan.h>
43
44#define VK_DEFINE_HANDLE(object) typedef struct object##_T* object;
45#if !defined(DEFINE_NON_DISPATCHABLE_HANDLE)
46 #if defined(__LP64__) || defined(_WIN64) || (defined(__x86_64__) && !defined(__ILP32__) ) || defined(_M_X64) || defined(__ia64) || defined (_M_IA64) || defined(__aarch64__) || defined(__powerpc64__)
47 #define DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef struct object##_T *object;
48 #else
49 #define DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object;
50 #endif
51#endif
52
53
59
61
65struct VkApplicationInfo;
66namespace NDEVR
67{
68 struct SwapChainSupportDetails;
69 class File;
70 class Log;
71 class WindowInstance;
72 struct Module;
73 //Executes a Vulkan command and handles the results, throwing an exception if necessary.
74 extern VkResult vkExecute(VkResult result, const char* error_message);
75
76 /**--------------------------------------------------------------------------------------------------
77 \brief The connection between the NDEVR API and the Vulkan library. See:
78 https://vulkan-tutorial.com/Drawing_a_triangle/Setup/Instance
79 Creating this connection involves specifying some details about NDEVR library to the driver.
80 **/
82 {
83 public:
85 VulkanInstance(VulkanInstance&& instance) noexcept;
86 static void setupModule(Module& module);
89 virtual ~VulkanInstance();
90 bool isValid() const;
91 virtual void init();
92 void setLog(ProgressInfo* log);
93 ProgressInfo* log() { return m_log; }
94
95 void cleanup();
96 const String& surfaceType() const;
97
98 VkInstance vkInstance() const { lib_assert(m_vk_instance, "Instance not yet created, but access is attempted"); return m_vk_instance; }
99
103 bool supportsValidation() const { return m_supports_validation; };
104 const Buffer<String>& validationLayers() const { return m_validation_layers; };
105 const Buffer<VkPhysicalDevice>& physicalDevices() const { return m_available_physical_devices; };
106 virtual uint04 deviceSuitableScore(VkPhysicalDevice device);//0 = not suitable
107 bool isSoftwareRendered() const;
108 protected:
109 virtual VkResult createVkInstance(const VkInstanceCreateInfo& create_info);
110 virtual VkInstanceCreateInfo createInfo();
111 virtual VkApplicationInfo applicationInfo(const String& app_name);
112 virtual uint04 setupExtensions(const char**& extensions);
113 virtual uint04 setupLayers(const char**& layers);
115 public:
119 protected:
120 bool checkLayerSupport(const String& layer);
121 bool checkExtensionSupport(const String& layer);
124 virtual void setupInstance();
126 virtual void setAvailableLayerInfo();
127 virtual void setupDebug();
128
129
130 virtual VkSurfaceFormatKHR chooseSwapSurfaceFormat(const Buffer<VkSurfaceFormatKHR, uint04, ObjectAllocator<true>>& availableFormats);
131 Time creationTime() const { return m_creation_time; }
132 public:
134 protected:
138
142
146 bool m_is_init = false;
147 bool m_is_software_rendered = false;
151 };
152
153
154}
uint64_t VkImageView
Definition ImageResources.h:41
#define lib_assert(expression, message)
Definition LibAssert.h:61
uint64_t VkSurfaceKHR
Definition VulkanInstance.h:62
uint64_t VkCommandPool
Definition VulkanInstance.h:63
#define VK_DEFINE_HANDLE(object)
Definition VulkanInstance.h:44
#define DEFINE_NON_DISPATCHABLE_HANDLE(object)
Definition VulkanInstance.h:49
struct VkPhysicalDevice_T * VkPhysicalDevice
Definition VulkanInstance.h:55
struct VkQueue_T * VkQueue
Definition VulkanInstance.h:57
struct VkInstance_T * VkInstance
Definition VulkanInstance.h:54
struct VkDevice_T * VkDevice
Definition VulkanInstance.h:56
struct VkCommandBuffer_T * VkCommandBuffer
Definition VulkanInstance.h:58
uint64_t VkDebugReportCallbackEXT
Definition VulkanInstance.h:60
The equivelent of std::vector but with a bit more control. The basic array unit of the library.
Definition Buffer.hpp:56
Provides a modifiable pointer that has shared ownership of a dynamically allocated object.
Definition Pointer.hpp:320
Definition MemoryManager.h:261
A light-weight base class for Log that allows processes to update, without the need for additional in...
Definition ProgressInfo.hpp:48
The core String class for the NDEVR API.
Definition String.h:69
Represents a timestamp with utilities for manipulation and conversion.
Definition Time.h:54
The connection between the NDEVR API and the Vulkan library. See: https://vulkan-tutorial....
Definition VulkanInstance.h:82
const Buffer< String > & validationLayers() const
Definition VulkanInstance.h:104
virtual uint04 setupLayers(const char **&layers)
const String & surfaceType() const
virtual void setAvailablePhysicalDevices()
VkInstance vkInstance() const
Definition VulkanInstance.h:98
Buffer< VkLayerProperties, uint04, ObjectAllocator< true > > m_available_layer_info
Definition VulkanInstance.h:140
virtual VkApplicationInfo applicationInfo(const String &app_name)
String vulkanLibUsed() const
virtual VkSurfaceFormatKHR chooseSwapSurfaceFormat(const Buffer< VkSurfaceFormatKHR, uint04, ObjectAllocator< true > > &availableFormats)
virtual uint04 deviceSuitableScore(VkPhysicalDevice device)
bool checkLayerSupport(const String &layer)
Buffer< String > m_validation_layers
Definition VulkanInstance.h:144
void setLog(ProgressInfo *log)
bool isValid() const
ProgressInfo * log()
Definition VulkanInstance.h:93
virtual void setAvailableExtensionInfo()
static Module VulkanBackupModule()
bool supportsTriangleFan() const
bool isSoftwareRendered() const
bool supportsKHRSwapchain() const
static String SoftwareRenderedVulkanLib()
const Buffer< VkPhysicalDevice > & physicalDevices() const
Definition VulkanInstance.h:105
virtual void init()
Buffer< VkPhysicalDevice > m_available_physical_devices
Definition VulkanInstance.h:141
static void setupModule(Module &module)
ProgressInfo * m_log
Definition VulkanInstance.h:136
virtual void setupDebug()
bool checkExtensionSupport(const String &layer)
bool supportsValidation() const
Definition VulkanInstance.h:103
virtual void setupInstance()
String m_surface_type
Definition VulkanInstance.h:149
virtual uint04 setupExtensions(const char **&extensions)
bool m_supports_validation
Definition VulkanInstance.h:145
Buffer< String > m_extensions
Definition VulkanInstance.h:143
bool m_supports_tri_fan
Definition VulkanInstance.h:148
Buffer< VkExtensionProperties, uint04, ObjectAllocator< true > > m_available_extension_info
Definition VulkanInstance.h:139
VkDebugReportCallbackEXT m_debug_callback
Definition VulkanInstance.h:137
virtual VkInstanceCreateInfo createInfo()
Time m_creation_time
Definition VulkanInstance.h:150
static DynamicPointer< VulkanInstance > & DefaultVulkanInstance()
static Buffer< VulkanInstance * > s_instances
Definition VulkanInstance.h:133
VulkanInstance(VulkanInstance &&instance) noexcept
static String HardwareRenderedVulkanLib()
virtual void setAvailableLayerInfo()
Time creationTime() const
Definition VulkanInstance.h:131
virtual VkResult createVkInstance(const VkInstanceCreateInfo &create_info)
VkInstance m_vk_instance
Definition VulkanInstance.h:135
Definition ACIColor.h:37
VkResult vkExecute(VkResult result, const char *error_message)
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
Definition BaseValues.hpp:96
Base class for extensions, typically added as external DLL's that can modify or enhance the behavior ...
Definition ModuleManager.h:59