Vulkan context¶
Owns the Vulkan instance, the physical and logical device, the swapchain, queue families and synchronization primitives.
-
class VulkanContext¶
Public Functions
-
VkQueue getBackgroundQueue()¶
A queue for long work next to the frames, e.g. on a worker thread: a queue of its own when the device has a second graphics and compute queue, otherwise the graphics queue. Buffers and images are then shared by both queue families. Compile a graph with getBackgroundQueueFamily() to submit it here.
-
void submitImmediate(const std::function<void(VkCommandBuffer)> &record, VkQueue queue = VK_NULL_HANDLE)¶
Records commands into a one-time command buffer, submits it to
queueand waits for it to finish. Safe to call from several threads.- Parameters:
record – Records the commands into the command buffer it is given.
queue – The graphics queue (the default) or the background queue. Work on a worker thread passes the background queue, so that it does not wait behind the frames.
-
void cancelRender(uint32_t imageIndex)¶
Completes an acquired frame without graph submission and waits for device completion. Consumes image availability and signals the frame fence; windowed contents are discarded.
-
VkQueue getBackgroundQueue()¶
-
struct QueueFamilyIndices¶
Buffers¶
See Buffers for buffer allocation, memory placement and the
klartraum::VulkanBuffer API.
Shader and asset files¶
Shaders are loaded by relative paths such as shaders/gsplat/gsplat_projection.comp.spv;
see Building for how they are found.
-
std::vector<char> klartraum::readFile(const std::string &filename)¶
Reads a whole file into memory.
A relative path that does not exist relative to the current working directory is looked up relative to the asset root (see setAssetRoot()), so the library’s built-in shader paths such as
shaders/gsplat/...resolve from any working directory.
-
void klartraum::setAssetRoot(const std::string &directory)¶
Sets the directory that relative paths passed to readFile() fall back to.
That is a directory with the compiled shaders in its
shaders/subdirectory. While it is empty (the default), theKLARTRAUM_ASSET_DIRenvironment variable is used, and without that the build directory of Klartraum.
-
std::string klartraum::getAssetRoot()¶
The asset root set by setAssetRoot(), else
KLARTRAUM_ASSET_DIR, else the build directory of Klartraum.