SDL_ADDVULKANRENDERSEMAPHORES(3)

πŸ’… SDL_AddVulkanRenderSemaphores

okay bestie, welcome to the SDL_AddVulkanRenderSemaphores(3) page, straight out of the SDL3 function lineup ✨ pull up a chair, we're doing Vulkan sync today and honestly? it's giving choreography 🩰


🌸 NAME

SDL_AddVulkanRenderSemaphores β€” add a set of synchronization semaphores for the current frame. no cap, that's the whole job πŸŽ€


✨ SYNOPSIS

#include <SDL3/SDL_render.h>

bool SDL_AddVulkanRenderSemaphores(SDL_Renderer *renderer, Uint32 wait_stage_mask, Sint64 wait_semaphore, Sint64 signal_semaphore);

πŸ¦‹ DESCRIPTION

so here's the vibe: the Vulkan renderer is gonna wait for wait_semaphore before it submits rendering commands, and then it's gonna signal signal_semaphore after the rendering commands for this frame are done. it's a whole "you go first, then I go" moment, very polite, very demure 🫢

you should call this every single frame that you want semaphore synchronization. like, each frame, bestie, not just when you feel like it.

and here's the tea: the Vulkan renderer may have multiple frames in flight on the GPU at the same time 😭 so you can't just have one semaphore and call it a day β€” you should have multiple semaphores that are used for synchronization. if you're wondering "how many though??" β€” querying SDL_PROP_RENDERER_VULKAN_SWAPCHAIN_IMAGE_COUNT_NUMBER will give you the maximum number of semaphores you'll need. it literally tells you the number, slay πŸ‘‘


πŸŽ€ FUNCTION PARAMETERS

  • renderer β€” the rendering context. your main character, the whole point of the operation πŸ’œ
  • wait_stage_mask β€” the VkPipelineStageFlags for the wait. it's the mask, it's in charge of the when πŸ•
  • wait_semaphore β€” a VkSempahore to wait on before rendering the current frame, or 0 if not needed. (yes that's literally how it's spelled up in here, no notes πŸ’€)
  • signal_semaphore β€” a VkSempahore that SDL will signal when rendering for the current frame is complete, or 0 if not needed. also spellable-with-a-typo, also valid πŸ”₯

🌈 RETURN VALUE

returns true on success or false on failure πŸ’– and if it's a false?? call SDL_GetError() for more information, because the error message is right there waiting for you, don't leave it on read πŸ™ˆ


⭐ THREAD SAFETY

it is NOT safe to call this function from two threads at once. not even a little bit. keep it to one thread, bestie, this is a monogamous function πŸ’…

πŸ‘‘ AVAILABILITY

this function is available since SDL 3.2.0. so if you're on anything older, it's simply not there yet, and that's the vibe check result 🌸


Simple Directmedia Layer made this one, it's tagged SDL 3.4.18, and the manual page itself is SDL_AddVulkanRenderSemaphores(3) πŸ¦‹ mwah, go sync those semaphores, you're doing amazing sweetie πŸ’–βœ¨

πŸ“¦ where this page comes from