PeriDyno 1.0.0
Loading...
Searching...
No Matches
dyno::VkContext Class Reference

#include <VkContext.h>

Classes

struct  MemoryPoolInfo
 

Public Types

enum  MemPoolType { DevicePool , HostPool , UniformPool , EndType }
 

Public Member Functions

 VkContext (VkPhysicalDevice physicalDevice)
 
 ~VkContext ()
 
VkResult createLogicalDevice (VkPhysicalDeviceFeatures enabledFeatures, std::vector< const char * > enabledExtensions, void *pNextChain, bool useSwapChain=true, VkQueueFlags requestedQueueTypes=VK_QUEUE_GRAPHICS_BIT|VK_QUEUE_COMPUTE_BIT)
 
void createPipelineCache ()
 
VkDevice deviceHandle ()
 
VkQueue graphicsQueueHandle ()
 
VkQueue computeQueueHandle ()
 
VkQueue transferQueueHandle ()
 
VkPhysicalDevice physicalDeviceHandle ()
 
VkPipelineCache pipelineCacheHandle ()
 
bool isComputeQueueSpecial ()
 
uint32_t getMemoryType (uint32_t typeBits, VkMemoryPropertyFlags properties, VkBool32 *memTypeFound=nullptr) const
 
uint32_t getQueueFamilyIndex (VkQueueFlagBits queueFlags) const
 
VkResult createBuffer (VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, VkDeviceSize size, VkBuffer *buffer, VkDeviceMemory *memory, void *data=nullptr)
 
VkResult createBuffer (VkBufferUsageFlags usageFlags, VkMemoryPropertyFlags memoryPropertyFlags, std::shared_ptr< vks::Buffer > &buffer, VkDeviceSize size, const void *data=nullptr)
 
VkResult createBuffer (uint32_t poolType, std::shared_ptr< vks::Buffer > &buffer, const void *data=nullptr)
 
VkResult createMemoryPool (VkInstance instance, uint32_t apiVerion)
 
void copyBuffer (vks::Buffer *src, vks::Buffer *dst, VkQueue queue, VkBufferCopy *copyRegion=nullptr)
 
VkCommandPool createCommandPool (uint32_t queueFamilyIndex, VkCommandPoolCreateFlags createFlags=VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)
 
VkCommandBuffer createCommandBuffer (VkCommandBufferLevel level, VkCommandPool pool, bool begin=false)
 
VkCommandBuffer createCommandBuffer (VkCommandBufferLevel level, bool begin=false)
 
void flushCommandBuffer (VkCommandBuffer commandBuffer, VkQueue queue, VkCommandPool pool, bool free=true)
 
void flushCommandBuffer (VkCommandBuffer commandBuffer, VkQueue queue, bool free=true)
 
bool extensionSupported (std::string extension)
 
VkFormat getSupportedDepthFormat (bool checkSamplingSupport)
 
 operator VkDevice () const
 

Public Attributes

VkPhysicalDevice physicalDevice
 Physical device representation.
 
VkDevice logicalDevice
 Logical device representation (application's view of the device)
 
VkPhysicalDeviceProperties properties
 Properties of the physical device including limits that the application can check against.
 
VkPhysicalDeviceFeatures features
 Features of the physical device that an application can use to check if a feature is supported.
 
VkPhysicalDeviceFeatures enabledFeatures
 Features that have been enabled for use on the physical device.
 
VkPhysicalDeviceMemoryProperties memoryProperties
 Memory types and heaps of the physical device.
 
std::vector< VkQueueFamilyProperties > queueFamilyProperties
 Queue family properties of the physical device.
 
std::vector< std::string > supportedExtensions
 List of extensions supported by the device.
 
VkCommandPool commandPool = VK_NULL_HANDLE
 Default command pool for the graphics queue family index.
 
VkQueue graphicsQueue
 
VkQueue computeQueue
 
VkQueue transferQueue
 
bool enableDebugMarkers = false
 Set to true when the debug marker extension is detected.
 
VkPipelineCache pipelineCache
 Contains queue family indices.
 
struct { 
 
   uint32_t   graphics 
 
   uint32_t   compute 
 
   uint32_t   transfer 
 
queueFamilyIndices 
 
std::map< VkFlags, MemoryPoolInfopoolMap
 
VmaAllocator g_Allocator
 
bool useMemoryPool = false
 

Detailed Description

Definition at line 16 of file VkContext.h.

Member Enumeration Documentation

◆ MemPoolType

Enumerator
DevicePool 
HostPool 
UniformPool 
EndType 

Definition at line 94 of file VkContext.h.

Constructor & Destructor Documentation

◆ VkContext()

dyno::VkContext::VkContext ( VkPhysicalDevice physicalDevice)
explicit

Default constructor

Parameters
physicalDevicePhysical device that is to be used

Definition at line 12 of file VkContext.cpp.

Here is the call graph for this function:

◆ ~VkContext()

dyno::VkContext::~VkContext ( )

Default destructor

Note
Frees the logical device

Definition at line 52 of file VkContext.cpp.

Member Function Documentation

◆ computeQueueHandle()

VkQueue dyno::VkContext::computeQueueHandle ( )
inline

Definition at line 28 of file VkContext.h.

◆ copyBuffer()

void dyno::VkContext::copyBuffer ( vks::Buffer * src,
vks::Buffer * dst,
VkQueue queue,
VkBufferCopy * copyRegion = nullptr )

Copy buffer data from src to dst using VkCmdCopyBuffer

Parameters
srcPointer to the source buffer to copy from
dstPointer to the destination buffer to copy to
queuePointer
copyRegion(Optional) Pointer to a copy region, if NULL, the whole buffer is copied
Note
Source and destination pointers must have the appropriate transfer usage flags set (TRANSFER_SRC / TRANSFER_DST)

Definition at line 576 of file VkContext.cpp.

Here is the call graph for this function:

◆ createBuffer() [1/3]

VkResult dyno::VkContext::createBuffer ( uint32_t poolType,
std::shared_ptr< vks::Buffer > & buffer,
const void * data = nullptr )

Create a buffer on the device wth memory allocated from memory pool

Parameters
poolTypememory type
bufferPointer to a vk::Vulkan buffer object
dataPointer to the data that should be copied to the buffer after creation (optional, if not set, no data is copied over)
Returns
VK_SUCCESS if buffer handle and memory have been created and (optionally passed) data has been copied

Definition at line 461 of file VkContext.cpp.

Here is the call graph for this function:

◆ createBuffer() [2/3]

VkResult dyno::VkContext::createBuffer ( VkBufferUsageFlags usageFlags,
VkMemoryPropertyFlags memoryPropertyFlags,
std::shared_ptr< vks::Buffer > & buffer,
VkDeviceSize size,
const void * data = nullptr )

Create a buffer on the device

Parameters
usageFlagsUsage flag bit mask for the buffer (i.e. index, vertex, uniform buffer)
memoryPropertyFlagsMemory properties for this buffer (i.e. device local, host visible, coherent)
bufferPointer to a vk::Vulkan buffer object
sizeSize of the buffer in bytes
dataPointer to the data that should be copied to the buffer after creation (optional, if not set, no data is copied over)
Returns
VK_SUCCESS if buffer handle and memory have been created and (optionally passed) data has been copied

Definition at line 404 of file VkContext.cpp.

Here is the call graph for this function:

◆ createBuffer() [3/3]

VkResult dyno::VkContext::createBuffer ( VkBufferUsageFlags usageFlags,
VkMemoryPropertyFlags memoryPropertyFlags,
VkDeviceSize size,
VkBuffer * buffer,
VkDeviceMemory * memory,
void * data = nullptr )

Create a buffer on the device

Parameters
usageFlagsUsage flag bit mask for the buffer (i.e. index, vertex, uniform buffer)
memoryPropertyFlagsMemory properties for this buffer (i.e. device local, host visible, coherent)
sizeSize of the buffer in byes
bufferPointer to the buffer handle acquired by the function
memoryPointer to the memory handle acquired by the function
dataPointer to the data that should be copied to the buffer after creation (optional, if not set, no data is copied over)
Returns
VK_SUCCESS if buffer handle and memory have been created and (optionally passed) data has been copied

Definition at line 346 of file VkContext.cpp.

Here is the call graph for this function:

◆ createCommandBuffer() [1/2]

VkCommandBuffer dyno::VkContext::createCommandBuffer ( VkCommandBufferLevel level,
bool begin = false )

Definition at line 640 of file VkContext.cpp.

Here is the call graph for this function:

◆ createCommandBuffer() [2/2]

VkCommandBuffer dyno::VkContext::createCommandBuffer ( VkCommandBufferLevel level,
VkCommandPool pool,
bool begin = false )

Allocate a command buffer from the command pool

Parameters
levelLevel of the new command buffer (primary or secondary)
poolCommand pool from which the command buffer will be allocated
(Optional)begin If true, recording on the new command buffer will be started (vkBeginCommandBuffer) (Defaults to false)
Returns
A handle to the allocated command buffer

Definition at line 626 of file VkContext.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createCommandPool()

VkCommandPool dyno::VkContext::createCommandPool ( uint32_t queueFamilyIndex,
VkCommandPoolCreateFlags createFlags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT )

Create a command pool for allocation command buffers from

Parameters
queueFamilyIndexFamily index of the queue to create the command pool for
createFlags(Optional) Command pool creation flags (Defaults to VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT)
Note
Command buffers allocated from the created pool can only be submitted to a queue with the same family index
Returns
A handle to the created command buffer

Definition at line 606 of file VkContext.cpp.

Here is the caller graph for this function:

◆ createLogicalDevice()

VkResult dyno::VkContext::createLogicalDevice ( VkPhysicalDeviceFeatures enabledFeatures,
std::vector< const char * > enabledExtensions,
void * pNextChain,
bool useSwapChain = true,
VkQueueFlags requestedQueueTypes = VK_QUEUE_GRAPHICS_BIT | VK_QUEUE_COMPUTE_BIT )

Create the logical device based on the assigned physical device, also gets default queue family indices

Parameters
enabledFeaturesCan be used to enable certain features upon device creation
pNextChainOptional chain of pointer to extension structures
useSwapChainSet to false for headless rendering to omit the swapchain device extensions
requestedQueueTypesBit flags specifying the queue types to be requested from the device
Returns
VkResult of the device creation call

Definition at line 175 of file VkContext.cpp.

Here is the call graph for this function:

◆ createMemoryPool()

VkResult dyno::VkContext::createMemoryPool ( VkInstance instance,
uint32_t apiVerion )

Create memory pool from all type

Parameters
instanceVulkan instance
apiVersionVulkan api version
Returns
VK_SUCCESS if memory pool has been created.

Definition at line 504 of file VkContext.cpp.

Here is the call graph for this function:

◆ createPipelineCache()

void dyno::VkContext::createPipelineCache ( )

Definition at line 327 of file VkContext.cpp.

Here is the caller graph for this function:

◆ deviceHandle()

VkDevice dyno::VkContext::deviceHandle ( )
inline

Definition at line 26 of file VkContext.h.

Here is the caller graph for this function:

◆ extensionSupported()

bool dyno::VkContext::extensionSupported ( std::string extension)

Check if an extension is supported by the (physical device)

Parameters
extensionName of the extension to check
Returns
True if the extension is supported (present in the list read at device creation time)

Definition at line 695 of file VkContext.cpp.

Here is the caller graph for this function:

◆ flushCommandBuffer() [1/2]

void dyno::VkContext::flushCommandBuffer ( VkCommandBuffer commandBuffer,
VkQueue queue,
bool free = true )

Definition at line 683 of file VkContext.cpp.

Here is the call graph for this function:

◆ flushCommandBuffer() [2/2]

void dyno::VkContext::flushCommandBuffer ( VkCommandBuffer commandBuffer,
VkQueue queue,
VkCommandPool pool,
bool free = true )

Finish command buffer recording and submit it to a queue

Parameters
commandBufferCommand buffer to flush
queueQueue to submit the command buffer to
poolCommand pool on which the command buffer has been created
free(Optional) Free the command buffer once it has been submitted (Defaults to true)
Note
The queue that the command buffer is submitted to must be from the same family index as the pool it was allocated from
Uses a fence to ensure command buffer has finished executing

Definition at line 656 of file VkContext.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getMemoryType()

uint32_t dyno::VkContext::getMemoryType ( uint32_t typeBits,
VkMemoryPropertyFlags properties,
VkBool32 * memTypeFound = nullptr ) const

Get the index of a memory type that has all the requested property bits set

Parameters
typeBitsBit mask with bits set for each memory type supported by the resource to request for (from VkMemoryRequirements)
propertiesBit mask of properties for the memory type to request
(Optional)memTypeFound Pointer to a bool that is set to true if a matching memory type has been found
Returns
Index of the requested memory type
Exceptions
Throwsan exception if memTypeFound is null and no memory type could be found that supports the requested properties

Definition at line 87 of file VkContext.cpp.

Here is the caller graph for this function:

◆ getQueueFamilyIndex()

uint32_t dyno::VkContext::getQueueFamilyIndex ( VkQueueFlagBits queueFlags) const

Get the index of a queue family that supports the requested queue flags

Parameters
queueFlagsQueue flags to find a queue family index for
Returns
Index of the queue family index that matches the flags
Exceptions
Throwsan exception if no queue family index could be found that supports the requested flags

Definition at line 125 of file VkContext.cpp.

Here is the caller graph for this function:

◆ getSupportedDepthFormat()

VkFormat dyno::VkContext::getSupportedDepthFormat ( bool checkSamplingSupport)

Select the best-fit depth format for this device from a list of possible depth (and stencil) formats

Parameters
checkSamplingSupportCheck if the format can be sampled from (e.g. for shader reads)
Returns
The depth format that best fits for the current device
Exceptions
Throwsan exception if no depth format fits the requirements

Definition at line 709 of file VkContext.cpp.

◆ graphicsQueueHandle()

VkQueue dyno::VkContext::graphicsQueueHandle ( )
inline

Definition at line 27 of file VkContext.h.

Here is the caller graph for this function:

◆ isComputeQueueSpecial()

bool dyno::VkContext::isComputeQueueSpecial ( )

Definition at line 71 of file VkContext.cpp.

◆ operator VkDevice()

dyno::VkContext::operator VkDevice ( ) const
inline

Definition at line 89 of file VkContext.h.

◆ physicalDeviceHandle()

VkPhysicalDevice dyno::VkContext::physicalDeviceHandle ( )
inline

Definition at line 31 of file VkContext.h.

Here is the caller graph for this function:

◆ pipelineCacheHandle()

VkPipelineCache dyno::VkContext::pipelineCacheHandle ( )
inline

Definition at line 33 of file VkContext.h.

◆ transferQueueHandle()

VkQueue dyno::VkContext::transferQueueHandle ( )
inline

Definition at line 29 of file VkContext.h.

Member Data Documentation

◆ commandPool

VkCommandPool dyno::VkContext::commandPool = VK_NULL_HANDLE

Default command pool for the graphics queue family index.

Definition at line 71 of file VkContext.h.

◆ compute

uint32_t dyno::VkContext::compute

Definition at line 86 of file VkContext.h.

◆ computeQueue

VkQueue dyno::VkContext::computeQueue

Definition at line 74 of file VkContext.h.

◆ enableDebugMarkers

bool dyno::VkContext::enableDebugMarkers = false

Set to true when the debug marker extension is detected.

Definition at line 77 of file VkContext.h.

◆ enabledFeatures

VkPhysicalDeviceFeatures dyno::VkContext::enabledFeatures

Features that have been enabled for use on the physical device.

Definition at line 63 of file VkContext.h.

◆ features

VkPhysicalDeviceFeatures dyno::VkContext::features

Features of the physical device that an application can use to check if a feature is supported.

Definition at line 61 of file VkContext.h.

◆ g_Allocator

VmaAllocator dyno::VkContext::g_Allocator

Definition at line 109 of file VkContext.h.

◆ graphics

uint32_t dyno::VkContext::graphics

Definition at line 85 of file VkContext.h.

◆ graphicsQueue

VkQueue dyno::VkContext::graphicsQueue

Definition at line 73 of file VkContext.h.

◆ logicalDevice

VkDevice dyno::VkContext::logicalDevice

Logical device representation (application's view of the device)

Definition at line 57 of file VkContext.h.

◆ memoryProperties

VkPhysicalDeviceMemoryProperties dyno::VkContext::memoryProperties

Memory types and heaps of the physical device.

Definition at line 65 of file VkContext.h.

◆ physicalDevice

VkPhysicalDevice dyno::VkContext::physicalDevice

Physical device representation.

Definition at line 55 of file VkContext.h.

◆ pipelineCache

VkPipelineCache dyno::VkContext::pipelineCache

Contains queue family indices.

Definition at line 81 of file VkContext.h.

◆ poolMap

std::map<VkFlags, MemoryPoolInfo> dyno::VkContext::poolMap

Definition at line 108 of file VkContext.h.

◆ properties

VkPhysicalDeviceProperties dyno::VkContext::properties

Properties of the physical device including limits that the application can check against.

Definition at line 59 of file VkContext.h.

◆ [struct]

struct { ... } dyno::VkContext::queueFamilyIndices

◆ queueFamilyProperties

std::vector<VkQueueFamilyProperties> dyno::VkContext::queueFamilyProperties

Queue family properties of the physical device.

Definition at line 67 of file VkContext.h.

◆ supportedExtensions

std::vector<std::string> dyno::VkContext::supportedExtensions

List of extensions supported by the device.

Definition at line 69 of file VkContext.h.

◆ transfer

uint32_t dyno::VkContext::transfer

Definition at line 87 of file VkContext.h.

◆ transferQueue

VkQueue dyno::VkContext::transferQueue

Definition at line 75 of file VkContext.h.

◆ useMemoryPool

bool dyno::VkContext::useMemoryPool = false

Definition at line 110 of file VkContext.h.


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