VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
vex::VulkanContext Struct Reference

Struct holding all vulkan data, like device, surface, swapchain, images, views, and more. More...

#include <context.hpp>

Public Member Functions

VkCommandBuffer beginSingleTimeCommands ()
 Function to begin single time command, used for stuff like creating vulkan image when loading textures.
void endSingleTimeCommands (VkCommandBuffer commandBuffer)
 Function to end single time command.
bool isValidFrameIndex (uint32_t frameIndex) const
 Validates a frame index against MAX_FRAMES_IN_FLIGHT.
bool isValidImageIndex (uint32_t imageIndex) const
 Validates an image index against swapchain image count.
void validateSyncObjectSizes () const
 Asserts that all frame-dependent synchronization vectors are properly sized.

Public Attributes

VkInstance instance
VkPhysicalDevice physicalDevice
VkDevice device
VkQueue graphicsQueue
VkQueue presentQueue
VmaAllocator allocator
VkSurfaceKHR surface
VkSwapchainKHR swapchain = VK_NULL_HANDLE
std::vector< VkImage > swapchainImages
VkFormat swapchainImageFormat
VkExtent2D swapchainExtent
std::vector< VkImageView > swapchainImageViews
VkImage depthImage = VK_NULL_HANDLE
VmaAllocation depthAllocation = VK_NULL_HANDLE
VkImageView depthImageView = VK_NULL_HANDLE
VkFormat depthFormat
VkImage lowResColorImage = VK_NULL_HANDLE
VmaAllocation lowResColorAlloc = VK_NULL_HANDLE
VkImageView lowResColorView = VK_NULL_HANDLE
VkImage compositeImage = VK_NULL_HANDLE
VmaAllocation compositeAlloc = VK_NULL_HANDLE
VkImageView compositeView = VK_NULL_HANDLE
VkImage uiImage = VK_NULL_HANDLE
VmaAllocation uiAlloc = VK_NULL_HANDLE
VkImageView uiView = VK_NULL_HANDLE
VkFormat lowResColorFormat = VK_FORMAT_UNDEFINED
VkImage accumImage = VK_NULL_HANDLE
VmaAllocation accumAlloc = VK_NULL_HANDLE
VkImageView accumView = VK_NULL_HANDLE
VkImage revealImage = VK_NULL_HANDLE
VmaAllocation revealAlloc = VK_NULL_HANDLE
VkImageView revealView = VK_NULL_HANDLE
VkImage gameViewImage = VK_NULL_HANDLE
VmaAllocation gameViewAlloc = VK_NULL_HANDLE
VkImageView gameViewView = VK_NULL_HANDLE
VkImage colorLutImage = VK_NULL_HANDLE
VmaAllocation colorLutAllocation = VK_NULL_HANDLE
VkImageView colorLutView = VK_NULL_HANDLE
VkPipelineLayout pipelineLayout
std::vector< VkCommandPool > commandPools
std::vector< VkCommandBuffer > commandBuffers
VkCommandPool singleTimePool
uint32_t graphicsQueueFamily
uint32_t presentQueueFamily
uint32_t currentFrame = 0
 Current frame index for triple-buffering.
uint32_t currentImageIndex = 0
 Current swapchain image index (acquired from vkAcquireNextImageKHR).
uint32_t MAX_FRAMES_IN_FLIGHT = 3
 Maximum frames in flight (triple-buffering).
std::vector< VkSemaphore > imageAvailableSemaphores
 Synchronization semaphores - must be sized to MAX_FRAMES_IN_FLIGHT.
std::vector< VkSemaphore > renderFinishedSemaphores
 Render finished semaphores - must be sized to MAX_FRAMES_IN_FLIGHT.
std::vector< VkFence > inFlightFences
 In-flight fences - must be sized to MAX_FRAMES_IN_FLIGHT.
VkDescriptorSetLayout descriptorSetLayout = VK_NULL_HANDLE
VkDescriptorSetLayout uboDescriptorSetLayout = VK_NULL_HANDLE
VkDescriptorSetLayout textureDescriptorSetLayout = VK_NULL_HANDLE
VkDescriptorSetLayout screenDescriptorSetLayout = VK_NULL_HANDLE
VkDescriptorSetLayout particleDescriptorSetLayout = VK_NULL_HANDLE
vex_map< std::string, uint32_t > textureIndices
uint32_t nextTextureIndex = 0
std::queue< uint32_t > recycledTextureIndices
glm::uvec2 currentRenderResolution
environment m_environment
bool supportsMultiDraw = false
bool supportsIndirectDraw = false
bool supportsBindlessTextures = false
bool supportsShaderDrawParameters = false
VkDescriptorSetLayout bindlessDescriptorSetLayout = VK_NULL_HANDLE
VkDescriptorPool bindlessDescriptorPool = VK_NULL_HANDLE
VkDescriptorSet bindlessDescriptorSet = VK_NULL_HANDLE
uint32_t maxDrawIndirectCount = 1
uint32_t maxMultiDrawCount = 1
bool requestSwapchainRecreation = false
uint32_t vulkanVersion = 0

Detailed Description

Struct holding all vulkan data, like device, surface, swapchain, images, views, and more.

Todo
cleanup

Definition at line 26 of file context.hpp.

Member Function Documentation

◆ beginSingleTimeCommands()

VkCommandBuffer vex::VulkanContext::beginSingleTimeCommands ( )
inline

Function to begin single time command, used for stuff like creating vulkan image when loading textures.

Returns
VkCommandBuffer

Definition at line 84 of file context.hpp.

◆ endSingleTimeCommands()

void vex::VulkanContext::endSingleTimeCommands ( VkCommandBuffer commandBuffer)
inline

Function to end single time command.

Parameters
VkCommandBuffercommandBuffer - The command buffer to end.

Definition at line 104 of file context.hpp.

◆ isValidFrameIndex()

bool vex::VulkanContext::isValidFrameIndex ( uint32_t frameIndex) const
inline

Validates a frame index against MAX_FRAMES_IN_FLIGHT.

Parameters
frameIndex- The frame index to validate
Returns
true if frameIndex is valid (< MAX_FRAMES_IN_FLIGHT), false otherwise

Definition at line 156 of file context.hpp.

◆ isValidImageIndex()

bool vex::VulkanContext::isValidImageIndex ( uint32_t imageIndex) const
inline

Validates an image index against swapchain image count.

Parameters
imageIndex- The image index to validate
Returns
true if imageIndex is valid (< swapchainImages.size()), false otherwise

Definition at line 169 of file context.hpp.

◆ validateSyncObjectSizes()

void vex::VulkanContext::validateSyncObjectSizes ( ) const
inline

Asserts that all frame-dependent synchronization vectors are properly sized.

Should be called after swapchain creation to verify consistency

Definition at line 181 of file context.hpp.

Member Data Documentation

◆ accumAlloc

VmaAllocation vex::VulkanContext::accumAlloc = VK_NULL_HANDLE

Definition at line 60 of file context.hpp.

◆ accumImage

VkImage vex::VulkanContext::accumImage = VK_NULL_HANDLE

Definition at line 59 of file context.hpp.

◆ accumView

VkImageView vex::VulkanContext::accumView = VK_NULL_HANDLE

Definition at line 61 of file context.hpp.

◆ allocator

VmaAllocator vex::VulkanContext::allocator

Definition at line 32 of file context.hpp.

◆ bindlessDescriptorPool

VkDescriptorPool vex::VulkanContext::bindlessDescriptorPool = VK_NULL_HANDLE

Definition at line 209 of file context.hpp.

◆ bindlessDescriptorSet

VkDescriptorSet vex::VulkanContext::bindlessDescriptorSet = VK_NULL_HANDLE

Definition at line 210 of file context.hpp.

◆ bindlessDescriptorSetLayout

VkDescriptorSetLayout vex::VulkanContext::bindlessDescriptorSetLayout = VK_NULL_HANDLE

Definition at line 208 of file context.hpp.

◆ colorLutAllocation

VmaAllocation vex::VulkanContext::colorLutAllocation = VK_NULL_HANDLE

Definition at line 72 of file context.hpp.

◆ colorLutImage

VkImage vex::VulkanContext::colorLutImage = VK_NULL_HANDLE

Definition at line 71 of file context.hpp.

◆ colorLutView

VkImageView vex::VulkanContext::colorLutView = VK_NULL_HANDLE

Definition at line 73 of file context.hpp.

◆ commandBuffers

std::vector<VkCommandBuffer> vex::VulkanContext::commandBuffers

Definition at line 78 of file context.hpp.

◆ commandPools

std::vector<VkCommandPool> vex::VulkanContext::commandPools

Definition at line 77 of file context.hpp.

◆ compositeAlloc

VmaAllocation vex::VulkanContext::compositeAlloc = VK_NULL_HANDLE

Definition at line 51 of file context.hpp.

◆ compositeImage

VkImage vex::VulkanContext::compositeImage = VK_NULL_HANDLE

Definition at line 50 of file context.hpp.

◆ compositeView

VkImageView vex::VulkanContext::compositeView = VK_NULL_HANDLE

Definition at line 52 of file context.hpp.

◆ currentFrame

uint32_t vex::VulkanContext::currentFrame = 0

Current frame index for triple-buffering.

This wraps around at MAX_FRAMES_IN_FLIGHT. Always validate bounds before using it to index into frame-dependent arrays.

Definition at line 124 of file context.hpp.

◆ currentImageIndex

uint32_t vex::VulkanContext::currentImageIndex = 0

Current swapchain image index (acquired from vkAcquireNextImageKHR).

Should be validated against swapchainImages.size() before use

Definition at line 128 of file context.hpp.

◆ currentRenderResolution

glm::uvec2 vex::VulkanContext::currentRenderResolution

Definition at line 199 of file context.hpp.

◆ depthAllocation

VmaAllocation vex::VulkanContext::depthAllocation = VK_NULL_HANDLE

Definition at line 42 of file context.hpp.

◆ depthFormat

VkFormat vex::VulkanContext::depthFormat

Definition at line 44 of file context.hpp.

◆ depthImage

VkImage vex::VulkanContext::depthImage = VK_NULL_HANDLE

Definition at line 41 of file context.hpp.

◆ depthImageView

VkImageView vex::VulkanContext::depthImageView = VK_NULL_HANDLE

Definition at line 43 of file context.hpp.

◆ descriptorSetLayout

VkDescriptorSetLayout vex::VulkanContext::descriptorSetLayout = VK_NULL_HANDLE

Definition at line 147 of file context.hpp.

◆ device

VkDevice vex::VulkanContext::device

Definition at line 29 of file context.hpp.

◆ gameViewAlloc

VmaAllocation vex::VulkanContext::gameViewAlloc = VK_NULL_HANDLE

Definition at line 68 of file context.hpp.

◆ gameViewImage

VkImage vex::VulkanContext::gameViewImage = VK_NULL_HANDLE

Definition at line 67 of file context.hpp.

◆ gameViewView

VkImageView vex::VulkanContext::gameViewView = VK_NULL_HANDLE

Definition at line 69 of file context.hpp.

◆ graphicsQueue

VkQueue vex::VulkanContext::graphicsQueue

Definition at line 30 of file context.hpp.

◆ graphicsQueueFamily

uint32_t vex::VulkanContext::graphicsQueueFamily

Definition at line 118 of file context.hpp.

◆ imageAvailableSemaphores

std::vector<VkSemaphore> vex::VulkanContext::imageAvailableSemaphores

Synchronization semaphores - must be sized to MAX_FRAMES_IN_FLIGHT.

Array size must equal MAX_FRAMES_IN_FLIGHT. Validate index bounds before access.

Definition at line 137 of file context.hpp.

◆ inFlightFences

std::vector<VkFence> vex::VulkanContext::inFlightFences

In-flight fences - must be sized to MAX_FRAMES_IN_FLIGHT.

Array size must equal MAX_FRAMES_IN_FLIGHT. Validate index bounds before access.

Definition at line 145 of file context.hpp.

◆ instance

VkInstance vex::VulkanContext::instance

Definition at line 27 of file context.hpp.

◆ lowResColorAlloc

VmaAllocation vex::VulkanContext::lowResColorAlloc = VK_NULL_HANDLE

Definition at line 47 of file context.hpp.

◆ lowResColorFormat

VkFormat vex::VulkanContext::lowResColorFormat = VK_FORMAT_UNDEFINED

Definition at line 57 of file context.hpp.

◆ lowResColorImage

VkImage vex::VulkanContext::lowResColorImage = VK_NULL_HANDLE

Definition at line 46 of file context.hpp.

◆ lowResColorView

VkImageView vex::VulkanContext::lowResColorView = VK_NULL_HANDLE

Definition at line 48 of file context.hpp.

◆ m_environment

environment vex::VulkanContext::m_environment

Definition at line 201 of file context.hpp.

◆ MAX_FRAMES_IN_FLIGHT

uint32_t vex::VulkanContext::MAX_FRAMES_IN_FLIGHT = 3

Maximum frames in flight (triple-buffering).

This is set dynamically during swapchain creation. Always use for bounds checking: index < MAX_FRAMES_IN_FLIGHT

Definition at line 133 of file context.hpp.

◆ maxDrawIndirectCount

uint32_t vex::VulkanContext::maxDrawIndirectCount = 1

Definition at line 212 of file context.hpp.

◆ maxMultiDrawCount

uint32_t vex::VulkanContext::maxMultiDrawCount = 1

Definition at line 213 of file context.hpp.

◆ nextTextureIndex

uint32_t vex::VulkanContext::nextTextureIndex = 0

Definition at line 195 of file context.hpp.

◆ particleDescriptorSetLayout

VkDescriptorSetLayout vex::VulkanContext::particleDescriptorSetLayout = VK_NULL_HANDLE

Definition at line 151 of file context.hpp.

◆ physicalDevice

VkPhysicalDevice vex::VulkanContext::physicalDevice

Definition at line 28 of file context.hpp.

◆ pipelineLayout

VkPipelineLayout vex::VulkanContext::pipelineLayout

Definition at line 75 of file context.hpp.

◆ presentQueue

VkQueue vex::VulkanContext::presentQueue

Definition at line 31 of file context.hpp.

◆ presentQueueFamily

uint32_t vex::VulkanContext::presentQueueFamily

Definition at line 119 of file context.hpp.

◆ recycledTextureIndices

std::queue<uint32_t> vex::VulkanContext::recycledTextureIndices

Definition at line 197 of file context.hpp.

◆ renderFinishedSemaphores

std::vector<VkSemaphore> vex::VulkanContext::renderFinishedSemaphores

Render finished semaphores - must be sized to MAX_FRAMES_IN_FLIGHT.

Array size must equal MAX_FRAMES_IN_FLIGHT. Validate index bounds before access.

Definition at line 141 of file context.hpp.

◆ requestSwapchainRecreation

bool vex::VulkanContext::requestSwapchainRecreation = false

Definition at line 214 of file context.hpp.

◆ revealAlloc

VmaAllocation vex::VulkanContext::revealAlloc = VK_NULL_HANDLE

Definition at line 64 of file context.hpp.

◆ revealImage

VkImage vex::VulkanContext::revealImage = VK_NULL_HANDLE

Definition at line 63 of file context.hpp.

◆ revealView

VkImageView vex::VulkanContext::revealView = VK_NULL_HANDLE

Definition at line 65 of file context.hpp.

◆ screenDescriptorSetLayout

VkDescriptorSetLayout vex::VulkanContext::screenDescriptorSetLayout = VK_NULL_HANDLE

Definition at line 150 of file context.hpp.

◆ singleTimePool

VkCommandPool vex::VulkanContext::singleTimePool

Definition at line 80 of file context.hpp.

◆ supportsBindlessTextures

bool vex::VulkanContext::supportsBindlessTextures = false

Definition at line 205 of file context.hpp.

◆ supportsIndirectDraw

bool vex::VulkanContext::supportsIndirectDraw = false

Definition at line 204 of file context.hpp.

◆ supportsMultiDraw

bool vex::VulkanContext::supportsMultiDraw = false

Definition at line 203 of file context.hpp.

◆ supportsShaderDrawParameters

bool vex::VulkanContext::supportsShaderDrawParameters = false

Definition at line 206 of file context.hpp.

◆ surface

VkSurfaceKHR vex::VulkanContext::surface

Definition at line 33 of file context.hpp.

◆ swapchain

VkSwapchainKHR vex::VulkanContext::swapchain = VK_NULL_HANDLE

Definition at line 35 of file context.hpp.

◆ swapchainExtent

VkExtent2D vex::VulkanContext::swapchainExtent

Definition at line 38 of file context.hpp.

◆ swapchainImageFormat

VkFormat vex::VulkanContext::swapchainImageFormat

Definition at line 37 of file context.hpp.

◆ swapchainImages

std::vector<VkImage> vex::VulkanContext::swapchainImages

Definition at line 36 of file context.hpp.

◆ swapchainImageViews

std::vector<VkImageView> vex::VulkanContext::swapchainImageViews

Definition at line 39 of file context.hpp.

◆ textureDescriptorSetLayout

VkDescriptorSetLayout vex::VulkanContext::textureDescriptorSetLayout = VK_NULL_HANDLE

Definition at line 149 of file context.hpp.

◆ textureIndices

vex_map<std::string, uint32_t> vex::VulkanContext::textureIndices

Definition at line 194 of file context.hpp.

◆ uboDescriptorSetLayout

VkDescriptorSetLayout vex::VulkanContext::uboDescriptorSetLayout = VK_NULL_HANDLE

Definition at line 148 of file context.hpp.

◆ uiAlloc

VmaAllocation vex::VulkanContext::uiAlloc = VK_NULL_HANDLE

Definition at line 55 of file context.hpp.

◆ uiImage

VkImage vex::VulkanContext::uiImage = VK_NULL_HANDLE

Definition at line 54 of file context.hpp.

◆ uiView

VkImageView vex::VulkanContext::uiView = VK_NULL_HANDLE

Definition at line 56 of file context.hpp.

◆ vulkanVersion

uint32_t vex::VulkanContext::vulkanVersion = 0

Definition at line 216 of file context.hpp.


The documentation for this struct was generated from the following file: