VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
VulkanBoundsChecking.hpp File Reference

Utilities for bounds checking and validation in Vulkan resource management. More...

#include <cstdint>
#include <vector>
#include <SDL3/SDL.h>
#include <cassert>

Go to the source code of this file.

Namespaces

namespace  vex

Macros

#define VEX_CHECK_FRAME_INDEX(index, maxFrames, funcName)
 Macro for quick frame index validation with early return.
#define VEX_CHECK_FRAME_INDEX_BOOL(index, maxFrames, funcName)
 Macro for quick frame index validation with bool return.
#define VEX_CHECK_IMAGE_INDEX(index, imageCount, funcName)
 Macro for quick image index validation with early return.
#define VEX_CHECK_BOUNDS(index, size, name)
 Macro for quick vector bounds checking with early return.
#define VEX_CHECK_BOUNDS_BOOL(index, size, name)
 Macro for quick vector bounds checking with bool return.

Functions

bool vex::validateVectorBounds (uint32_t index, size_t size, const char *name)
 Validates that an index is within bounds of a vector.
bool vex::validateVectorBounds (size_t index, size_t size, const char *name)
 Validates that an index is within bounds of a vector.
bool vex::validateFrameIndex (uint32_t frameIndex, uint32_t maxFrames)
 Validates that a frame index is valid.
bool vex::validateImageIndex (uint32_t imageIndex, size_t imageCount)
 Validates that an image index is valid.
template<typename T>
vex::safeVectorAccess (const std::vector< T > &vec, size_t index, const char *name, T defaultValue)
 Safely accesses a vector element with bounds checking.
template<typename T>
T * vex::safeVectorAccessPtr (std::vector< T > &vec, size_t index, const char *name)
 Safely accesses a vector element with bounds checking (mutable version).
template<typename T>
bool vex::validateVectorSize (const std::vector< T > &vec, size_t expectedSize, const char *name)
 Validates that a vector is properly sized.
template<typename T>
bool vex::validateVectorMinSize (const std::vector< T > &vec, size_t minSize, const char *name)
 Validates that a vector has minimum required size.
bool vex::validateFrameVectorConsistency (size_t size1, const char *name1, size_t size2, const char *name2, size_t size3, const char *name3)
 Validates that multiple frame-dependent vectors have consistent sizes.
template<typename T>
bool vex::validateNonNullHandles (const std::vector< T > &vec, const char *name)
 Validates that all pointers in a vector are non-null.
void vex::assertSyncObjectConsistency (size_t imageAvailSize, size_t renderFinishedSize, size_t fencesSize, size_t poolsSize, size_t buffersSize, uint32_t expectedSize)
 Asserts that all frame-dependent sync object vectors are properly sized.

Detailed Description

Utilities for bounds checking and validation in Vulkan resource management.

Author
Eryk Roszkowski

Definition in file VulkanBoundsChecking.hpp.

Macro Definition Documentation

◆ VEX_CHECK_BOUNDS

#define VEX_CHECK_BOUNDS ( index,
size,
name )
Value:
do { \
if (!vex::validateVectorBounds(index, size, name)) { \
log(LogLevel::ERROR, "Bounds check failed for %s", name); \
return; \
} \
} while(0)
bool validateVectorBounds(uint32_t index, size_t size, const char *name)
Validates that an index is within bounds of a vector.

Macro for quick vector bounds checking with early return.

Usage: VEX_CHECK_BOUNDS(index, vector.size(), "vectorName")

Definition at line 246 of file VulkanBoundsChecking.hpp.

◆ VEX_CHECK_BOUNDS_BOOL

#define VEX_CHECK_BOUNDS_BOOL ( index,
size,
name )
Value:
do { \
if (!vex::validateVectorBounds(index, size, name)) { \
log(LogLevel::ERROR, "Bounds check failed for %s", name); \
return false; \
} \
} while(0)

Macro for quick vector bounds checking with bool return.

Usage: VEX_CHECK_BOUNDS_BOOL(index, vector.size(), "vectorName")

Definition at line 256 of file VulkanBoundsChecking.hpp.

◆ VEX_CHECK_FRAME_INDEX

#define VEX_CHECK_FRAME_INDEX ( index,
maxFrames,
funcName )
Value:
do { \
if (!vex::validateFrameIndex(index, maxFrames)) { \
log(LogLevel::ERROR, "%s: Aborting due to invalid frame index", funcName); \
return; \
} \
} while(0)
bool validateFrameIndex(uint32_t frameIndex, uint32_t maxFrames)
Validates that a frame index is valid.

Macro for quick frame index validation with early return.

Usage: VEX_CHECK_FRAME_INDEX(frameIndex, context.MAX_FRAMES_IN_FLIGHT, functionName)

Definition at line 216 of file VulkanBoundsChecking.hpp.

◆ VEX_CHECK_FRAME_INDEX_BOOL

#define VEX_CHECK_FRAME_INDEX_BOOL ( index,
maxFrames,
funcName )
Value:
do { \
if (!vex::validateFrameIndex(index, maxFrames)) { \
log(LogLevel::ERROR, "%s: Aborting due to invalid frame index", funcName); \
return false; \
} \
} while(0)

Macro for quick frame index validation with bool return.

Usage: VEX_CHECK_FRAME_INDEX_BOOL(frameIndex, context.MAX_FRAMES_IN_FLIGHT, functionName)

Definition at line 226 of file VulkanBoundsChecking.hpp.

◆ VEX_CHECK_IMAGE_INDEX

#define VEX_CHECK_IMAGE_INDEX ( index,
imageCount,
funcName )
Value:
do { \
if (!vex::validateImageIndex(index, imageCount)) { \
log(LogLevel::ERROR, "%s: Aborting due to invalid image index", funcName); \
return; \
} \
} while(0)
bool validateImageIndex(uint32_t imageIndex, size_t imageCount)
Validates that an image index is valid.

Macro for quick image index validation with early return.

Usage: VEX_CHECK_IMAGE_INDEX(imageIndex, context.swapchainImages.size(), functionName)

Definition at line 236 of file VulkanBoundsChecking.hpp.