luna engine
software engine
Loading...
Searching...
No Matches
luna::vulkan::vulkanDevice Class Reference

#include <vulkanDevice.h>

Inheritance diagram for luna::vulkan::vulkanDevice:
Collaboration diagram for luna::vulkan::vulkanDevice:

Classes

struct  deviceHandles
 

Public Member Functions

 vulkanDevice (const ref< vulkan::window > &Window)
 
virtual ~vulkanDevice ()
 
void createContext () override
 creates the device context. More...
 
void destroyContext () override
 
VkViewport getViewport ()
 returns the swapchain viewport. More...
 
VkRect2D getScissor ()
 returns the swapchain scissor. More...
 
VkFormat getSwapFormat ()
 returns the swapchain format. More...
 
uint32_t getQueueIndex (const vkb::QueueType &type)
 returns the queue index. More...
 
VkQueue getQueue (const vkb::QueueType &type)
 returns a queue based on the requested type . More...
 
VkResult createFramebuffers (VkRenderPass renderPass)
 creates the appropriate framebuffers for the swapchain. More...
 
deviceHandles getDeviceHandles ()
 
- Public Member Functions inherited from luna::renderer::device
virtual ~device ()
 
virtual void createContext ()=0
 
virtual void destroyContext ()=0
 

Public Attributes

ref< vulkan::vulkanSwapchainswapchain
 
- Public Attributes inherited from luna::renderer::device
ref< vulkan::windowwindow
 this is the reference to the main window. More...
 

Private Member Functions

primaryHelperFunctions helper functions used to create the device
VkResult createInstance ()
 creates the vulkan instance. More...
 
VkResult pickPhysicalDevice ()
 picks the most powerful rendering device. More...
 
VkResult createLogicalDevice ()
 creates the logical device. More...
 

Private Attributes

std::vector< float > queuePriorities = { 0.99f }
 
VkSurfaceKHR surface = VK_NULL_HANDLE
 
deviceHandles deviceHandle
 
vulkan::queueFamilyIndices queueFamily
 
std::vector< VkDeviceQueueCreateInfo > queueCreateInfos
 
VkPhysicalDeviceFeatures supportedFeatures {}
 

secondaryHelperFunctions helper functions used by the primary helper functions

std::vector< const char * > getRequiredExtensions ()
 checks if all requested validation layers are supported. More...
 
VkDeviceQueueCreateInfo * createQueues ()
 rates the gpu based on expected performance with a score. More...
 
static VKAPI_ATTR VkBool32 VKAPI_CALL vulkanDevice::debugCallback (VkDebugUtilsMessageSeverityFlagBitsEXT messageSeverity, VkDebugUtilsMessageTypeFlagsEXT messageTypes, const VkDebugUtilsMessengerCallbackDataEXT *pCallbackData, void *pUserData)
 the debug callback function for vulkan debug and error catching. More...
 

Detailed Description

this is the vulkan device class and creates a rendering context.

ref<device> rederingDevice = std::make_shared<device>(new vulkanDevice(window));
Definition: vulkanDevice.h:17
Definition: window.h:40
std::shared_ptr< T > ref
Definition: core.h:49

Constructor & Destructor Documentation

◆ vulkanDevice()

luna::vulkan::vulkanDevice::vulkanDevice ( const ref< vulkan::window > &  Window)

@creates a vulkan device using the ref to the main window.

Parameters
Window

◆ ~vulkanDevice()

luna::vulkan::vulkanDevice::~vulkanDevice ( )
virtual

Member Function Documentation

◆ createContext()

void luna::vulkan::vulkanDevice::createContext ( )
overridevirtual

creates the device context.

Implements luna::renderer::device.

◆ createFramebuffers()

VkResult luna::vulkan::vulkanDevice::createFramebuffers ( VkRenderPass  renderPass)

creates the appropriate framebuffers for the swapchain.

Parameters
renderPass
Returns
VK_SUCCESS when buffer creation whas succesful

◆ createInstance()

VkResult luna::vulkan::vulkanDevice::createInstance ( )
private

creates the vulkan instance.

Returns
VK_SUCCESS when creation whas succesful.
VK_ERROR_LAYER_NOT_PRESENT when a requested validation layer is not supported

◆ createLogicalDevice()

VkResult luna::vulkan::vulkanDevice::createLogicalDevice ( )
private

creates the logical device.

Returns
VK_SUCCES
for VK_ERROR look at the vulkan documentation: https://registry.khronos.org/vulkan/specs/1.3-extensions/man/html/vkCreateDevice.html

◆ createQueues()

VkDeviceQueueCreateInfo * luna::vulkan::vulkanDevice::createQueues ( )
private

rates the gpu based on expected performance with a score.

Parameters
devicethe physicalDevice(GPU) to be rated
Returns
int the score the physical device has.

◆ destroyContext()

void luna::vulkan::vulkanDevice::destroyContext ( )
overridevirtual

detroys the device context.

Implements luna::renderer::device.

◆ getDeviceHandles()

vulkanDevice::deviceHandles luna::vulkan::vulkanDevice::getDeviceHandles ( )

#brief returns the device subhandles.

Returns
deviceHandles struct

◆ getQueue()

VkQueue luna::vulkan::vulkanDevice::getQueue ( const vkb::QueueType &  type)
inline

returns a queue based on the requested type .

Parameters
vkb::QueueTypetype

◆ getQueueIndex()

uint32_t luna::vulkan::vulkanDevice::getQueueIndex ( const vkb::QueueType &  type)
inline

returns the queue index.

Parameters
vkb:QueueTypetype

◆ getRequiredExtensions()

std::vector< const char * > luna::vulkan::vulkanDevice::getRequiredExtensions ( )
private

checks if all requested validation layers are supported.

Parameters
validationLayersrequested validation layers.
Returns
VK_SUCCES when all requested validation layers are supported.
VK_ERROR_LAYER_NOT_PRESENT when a requested validation layer is not supported.

◆ getScissor()

VkRect2D luna::vulkan::vulkanDevice::getScissor ( )
inline

returns the swapchain scissor.

◆ getSwapFormat()

VkFormat luna::vulkan::vulkanDevice::getSwapFormat ( )
inline

returns the swapchain format.

◆ getViewport()

VkViewport luna::vulkan::vulkanDevice::getViewport ( )
inline

returns the swapchain viewport.

◆ pickPhysicalDevice()

VkResult luna::vulkan::vulkanDevice::pickPhysicalDevice ( )
private

picks the most powerful rendering device.

Returns
VK_SUCCES when suitable physical device(GPU) was found.
VK_ERROR_DEVICE_LOST when no suitable physical device(GPU) could be found.
VK_ERROR_INCOMPATIBLE_DRIVER when the driver version is outdated or incompatible.

◆ vulkanDevice::debugCallback()

static VKAPI_ATTR VkBool32 VKAPI_CALL luna::vulkan::vulkanDevice::vulkanDevice::debugCallback ( VkDebugUtilsMessageSeverityFlagBitsEXT  messageSeverity,
VkDebugUtilsMessageTypeFlagsEXT  messageTypes,
const VkDebugUtilsMessengerCallbackDataEXT *  pCallbackData,
void *  pUserData 
)
staticprivate

the debug callback function for vulkan debug and error catching.

Parameters
messageSeverity
messageTypes
pCallbackData
pUserData
Returns

Member Data Documentation

◆ deviceHandle

deviceHandles luna::vulkan::vulkanDevice::deviceHandle
private

◆ queueCreateInfos

std::vector<VkDeviceQueueCreateInfo> luna::vulkan::vulkanDevice::queueCreateInfos
private

◆ queueFamily

vulkan::queueFamilyIndices luna::vulkan::vulkanDevice::queueFamily
private

◆ queuePriorities

std::vector<float> luna::vulkan::vulkanDevice::queuePriorities = { 0.99f }
private

◆ supportedFeatures

VkPhysicalDeviceFeatures luna::vulkan::vulkanDevice::supportedFeatures {}
private

◆ surface

VkSurfaceKHR luna::vulkan::vulkanDevice::surface = VK_NULL_HANDLE
private

◆ swapchain

ref<vulkan::vulkanSwapchain> luna::vulkan::vulkanDevice::swapchain

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