Monado OpenXR Runtime
vk_submit_helpers.h File Reference

Helper utilities for Vulkan queue submission with mixed binary and timeline semaphores. More...

#include "util/u_logging.h"
#include "vk/vk_helpers.h"
#include <assert.h>
Include dependency graph for vk_submit_helpers.h:

Go to the source code of this file.

Data Structures

struct  vk_semaphore_list_wait
 Accumulator for wait semaphores to be used in VkSubmitInfo. More...
 
struct  vk_semaphore_list_signal
 Accumulator for signal semaphores to be used in VkSubmitInfo. More...
 
struct  vk_submit_info_builder
 Builder for VkSubmitInfo with optional timeline semaphore support. More...
 

Macros

#define VK_SEMAPHORE_LIST_MAX_COUNT   4
 Maximum number of semaphores that can be accumulated in semaphore lists. More...
 

Functions

static void vk_semaphore_list_wait_add_binary (struct vk_semaphore_list_wait *list, VkSemaphore semaphore, VkPipelineStageFlags stage)
 Add a binary wait semaphore to the list. More...
 
static void vk_semaphore_list_wait_add_timeline (struct vk_semaphore_list_wait *list, VkSemaphore semaphore, uint64_t value, VkPipelineStageFlags stage)
 Add a timeline wait semaphore to the list with a specific value. More...
 
static void vk_semaphore_list_signal_add_binary (struct vk_semaphore_list_signal *list, VkSemaphore semaphore)
 Add a binary signal semaphore to the list. More...
 
static void vk_semaphore_list_signal_add_timeline (struct vk_semaphore_list_signal *list, VkSemaphore semaphore, uint64_t value)
 Add a timeline signal semaphore to the list with a specific value. More...
 
void vk_submit_info_builder_prepare (struct vk_submit_info_builder *builder, const struct vk_semaphore_list_wait *wait_semaphores, const VkCommandBuffer *command_buffers, uint32_t command_buffer_count, const struct vk_semaphore_list_signal *signal_semaphores, const void *next)
 Prepare a VkSubmitInfo from wait and signal semaphore lists. More...
 

Detailed Description

Helper utilities for Vulkan queue submission with mixed binary and timeline semaphores.

Author
Jakob Bornecrantz tborn.nosp@m.ecra.nosp@m.ntz@n.nosp@m.vidi.nosp@m.a.com

Usage Example

// Initialize semaphore lists
// Add semaphores (mix of binary and timeline)
if (present_complete != VK_NULL_HANDLE) {
vk_semaphore_list_wait_add_binary(&wait_sems, present_complete, VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT);
}
vk_semaphore_list_signal_add_timeline(&signal_sems, render_complete, frame_id);
// Prepare submit info
struct vk_submit_info_builder builder;
vk_submit_info_builder_prepare(&builder, &wait_sems, &cmd, 1, &signal_sems, NULL);
// Submit to queue
ret = vk->vkQueueSubmit(queue, 1, &builder.submit_info, fence);
void vk_submit_info_builder_prepare(struct vk_submit_info_builder *builder, const struct vk_semaphore_list_wait *wait_semaphores, const VkCommandBuffer *command_buffers, uint32_t command_buffer_count, const struct vk_semaphore_list_signal *signal_semaphores, const void *next)
Prepare a VkSubmitInfo from wait and signal semaphore lists.
Definition: vk_submit_helpers.c:15
static void vk_semaphore_list_signal_add_timeline(struct vk_semaphore_list_signal *list, VkSemaphore semaphore, uint64_t value)
Add a timeline signal semaphore to the list with a specific value.
Definition: vk_submit_helpers.h:208
static void vk_semaphore_list_wait_add_binary(struct vk_semaphore_list_wait *list, VkSemaphore semaphore, VkPipelineStageFlags stage)
Add a binary wait semaphore to the list.
Definition: vk_submit_helpers.h:125
#define XRT_STRUCT_INIT
Very small default init for structs that works in both C and C++.
Definition: xrt_compiler.h:239
A very simple implementation of a fence primitive.
Definition: comp_sync.c:36
Accumulator for signal semaphores to be used in VkSubmitInfo.
Definition: vk_submit_helpers.h:85
Accumulator for wait semaphores to be used in VkSubmitInfo.
Definition: vk_submit_helpers.h:61
Builder for VkSubmitInfo with optional timeline semaphore support.
Definition: vk_submit_helpers.h:104

Macro Definition Documentation

◆ VK_SEMAPHORE_LIST_MAX_COUNT

#define VK_SEMAPHORE_LIST_MAX_COUNT   4

Maximum number of semaphores that can be accumulated in semaphore lists.

Should be enough for typical compositor use cases.