Vulkan¶
Vulkan graphics support.
Vulkan support differs from OpenGL because almost all most configuration is done using the Vulkan API itself, rather than by setting view hints to configure the context. Pugl only provides a minimal loader for loading the Vulkan library, and a portable function to create a Vulkan surface for a view, which hides the platform-specific implementation details.
-
typedef struct PuglVulkanLoaderImpl PuglVulkanLoader¶
Dynamic Vulkan loader.
This can be used to dynamically load the Vulkan library. Applications or plugins shouldn’t link against the Vulkan library, but instead use this at runtime. This ensures that things will work on as many systems as possible, and allows errors to be handled gracefully.
This isn’t a “loader” in the sense of loading all the required Vulkan functions (which is the application’s responsibility), but just a minimal implementation to portably load the Vulkan library and get the two functions that are used to load everything else.
Note that this owns the loaded Vulkan library, so it must outlive all use of the Vulkan API.
See also: https://www.khronos.org/registry/vulkan/specs/1.0/html/chap4.html
-
VkResult puglCreateSurface(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr, PuglView *view, VkInstance instance, const VkAllocationCallbacks *allocator, VkSurfaceKHR *surface)¶
Create a Vulkan surface for a Pugl view.
- Parameters:
vkGetInstanceProcAddr – Accessor for Vulkan functions.
view – The view the surface is to be displayed on.
instance – The Vulkan instance.
allocator – Vulkan allocation callbacks, may be NULL.
surface – Pointed to a newly created Vulkan surface.
- Returns:
VK_SUCCESSon success, or a Vulkan error code.
-
void puglFreeVulkanLoader(PuglVulkanLoader *loader)¶
Free a loader created with
puglNewVulkanLoader().Note that this closes the Vulkan library, so the Vulkan API can no longer be used.
-
PFN_vkGetDeviceProcAddr puglGetDeviceProcAddrFunc(const PuglVulkanLoader *loader)¶
Return the
vkGetDeviceProcAddrfunction.- Returns:
Null if the Vulkan library does not contain this function (which is unlikely and indicates a broken system).
-
const char *const *puglGetInstanceExtensions(uint32_t *count)¶
Return the Vulkan instance extensions required to draw to a PuglView.
This simply returns static strings, it does not access Vulkan or the window system. The returned array always contains at least “VK_KHR_surface”.
- Parameters:
count – The number of extensions in the returned array.
- Returns:
An array of extension name strings.
-
PFN_vkGetInstanceProcAddr puglGetInstanceProcAddrFunc(const PuglVulkanLoader *loader)¶
Return the
vkGetInstanceProcAddrfunction.- Returns:
Null if the Vulkan library does not contain this function (which is unlikely and indicates a broken system).
-
PuglVulkanLoader *puglNewVulkanLoader(PuglWorld *world, const char *libraryName)¶
Create a new dynamic loader for Vulkan functions.
This dynamically loads the Vulkan library and gets the load functions from it.
- Parameters:
world – The world the returned loader is a part of.
libraryName – The name of the Vulkan library to load, or null. Typically, this is left unset, which will load the standard Vulkan library for the current platform. It can be set to an alternative name, or an absolute path, to support special packaging scenarios or unusual system configurations. This name is passed directly to the underlying platform library loading function (
dlopenorLoadLibrary).
- Returns:
A new Vulkan loader, or null on failure.
-
const PuglBackend *puglVulkanBackend(void)¶
Vulkan graphics backend.
Pass the returned value to
puglSetBackend()to draw to a view with Vulkan.