| Fling Engine 0.00.1 Fling Engine is a game engine written in Vulkan

Instance.h
Go to the documentation of this file.
1 #pragma once
2
3 #include "FlingVulkan.h"
4 #include "NonCopyable.hpp"
5
6 namespace Fling
7 {
11 class Instance : NonCopyable
12 {
13 public:
14
15 explicit Instance();
16
17 ~Instance();
18
19 const VkInstance& GetRawVkInstance() const { return m_Instance; }
20
21 bool IsValidationEnabled() const { return m_EnableValidationLayers; }
22
23 UINT32 EnabledValidationLayerCount() const { return static_cast<UINT32>(m_ValidationLayers.size()); }
24
25 const std::vector<const char*>& GetEnabledValidationLayers() const { return m_ValidationLayers; }
26
27 const std::vector<const char*>& GetEnabledExtensions() const { return m_DeviceExtensions; };
28
29 private:
30
32 VkInstance m_Instance = VK_NULL_HANDLE;
33
38 UINT8 m_EnableValidationLayers : 1;
39
43 void CreateInstance();
44
45 std::vector<const char*> GetRequiredExtensions();
46
47 bool CheckValidationLayerSupport();
48
49 #if FLING_DEBUG
50 // Debug messenger callbacks ---------------------------
52 VkDebugUtilsMessengerEXT m_DebugMessenger = VK_NULL_HANDLE;
53
54 static VKAPI_ATTR VkBool32 VKAPI_CALL DebugCallback(
55 VkDebugUtilsMessageSeverityFlagBitsEXT t_messageSeverity,
56 VkDebugUtilsMessageTypeFlagsEXT t_messageType,
57 const VkDebugUtilsMessengerCallbackDataEXT* t_CallbackData,
58 void* t_UserData
59 );
60
61 VkResult CreateDebugUtilsMessengerEXT(
62 VkInstance instance,
63 const VkDebugUtilsMessengerCreateInfoEXT* pCreateInfo,
64 const VkAllocationCallbacks* pAllocator,
65 VkDebugUtilsMessengerEXT* pDebugMessenger
66 );
67
68 void DestroyDebugUtilsMessengerEXT(
69 VkInstance instance,
70 VkDebugUtilsMessengerEXT debugMessenger,
71 const VkAllocationCallbacks* pAllocator
72 );
73
78 void SetupDebugMessages();
79 #endif
80
82 const std::vector<const char*> m_ValidationLayers =
83 {
84 "VK_LAYER_LUNARG_standard_validation"
85 };
86
88 const std::vector<const char*> m_DeviceExtensions =
89 {
90 VK_KHR_SWAPCHAIN_EXTENSION_NAME
91 };
92
93 };
94 } // namespace Fling
Fling::Instance::GetRawVkInstance
const VkInstance & GetRawVkInstance() const
Definition: Instance.h:19
Fling::Instance::IsValidationEnabled
bool IsValidationEnabled() const
Definition: Instance.h:21
FlingVulkan.h
Fling::Instance::GetEnabledValidationLayers
const std::vector< const char * > & GetEnabledValidationLayers() const
Definition: Instance.h:25
Fling::Instance::m_ValidationLayers
const std::vector< const char * > m_ValidationLayers
The validation layers that we want to look for on this instance.
Definition: Instance.h:82
Fling::Instance::GetEnabledExtensions
const std::vector< const char * > & GetEnabledExtensions() const
Definition: Instance.h:27
Fling::Instance::CreateInstance
void CreateInstance()
Create the VkInstance of this object and application information.
Definition: Instance.cpp:20
Fling::Instance
The instance is a representation of this application graphics instance in Vulkan. ...
Definition: Instance.h:11
NonCopyable.hpp
Fling::Instance::EnabledValidationLayerCount
UINT32 EnabledValidationLayerCount() const
Definition: Instance.h:23
Fling::Instance::m_Instance
VkInstance m_Instance
The Vulkan instance.
Definition: Instance.h:32
Fling::Instance::m_DeviceExtensions
const std::vector< const char * > m_DeviceExtensions
Device extension support for the swap chain.
Definition: Instance.h:88
UINT8
uint8_t UINT8
Definition: FlingTypes.h:11
Fling::NonCopyable
Class that removes the copy operator and constructor.
Definition: NonCopyable.hpp:10
Fling::Instance::GetRequiredExtensions
std::vector< const char * > GetRequiredExtensions()
Definition: Instance.cpp:111
UINT32
uint32_t UINT32
Definition: FlingTypes.h:13
Fling
Definition: Engine.h:29
Fling::Instance::CheckValidationLayerSupport
bool CheckValidationLayerSupport()
Definition: Instance.cpp:80
Fling::Instance::m_EnableValidationLayers
UINT8 m_EnableValidationLayers
If this instance has validation layers enabled.
Definition: Instance.h:38
Fling::Instance::~Instance
~Instance()
Definition: Instance.cpp:201
Fling::Instance::Instance
Instance()
Definition: Instance.cpp:8