comparison DPF-Prymula-audioplugins/dpf/dgl/src/pugl-upstream/include/pugl/vulkan.h @ 3:84e66ea83026

DPF-Prymula-audioplugins-0.231015-2
author prymula <prymula76@outlook.com>
date Mon, 16 Oct 2023 21:53:34 +0200
parents
children
comparison
equal deleted inserted replaced
2:cf2cb71d31dd 3:84e66ea83026
1 // Copyright 2012-2020 David Robillard <d@drobilla.net>
2 // SPDX-License-Identifier: ISC
3
4 /*
5 Note that this header includes Vulkan headers, so if you are writing a
6 program or plugin that dynamically loads vulkan, you should first define
7 `VK_NO_PROTOTYPES` before including it.
8 */
9
10 #ifndef PUGL_VULKAN_H
11 #define PUGL_VULKAN_H
12
13 #include "pugl/pugl.h"
14
15 #include <vulkan/vulkan_core.h>
16
17 #include <stdint.h>
18
19 PUGL_BEGIN_DECLS
20
21 /**
22 @defgroup vulkan Vulkan
23 Vulkan graphics support.
24
25 Vulkan support differs from OpenGL because almost all most configuration is
26 done using the Vulkan API itself, rather than by setting view hints to
27 configure the context. Pugl only provides a minimal loader for loading the
28 Vulkan library, and a portable function to create a Vulkan surface for a
29 view, which hides the platform-specific implementation details.
30
31 @ingroup pugl
32 @{
33 */
34
35 /**
36 Dynamic Vulkan loader.
37
38 This can be used to dynamically load the Vulkan library. Applications or
39 plugins should not link against the Vulkan library, but instead use this at
40 runtime. This ensures that things will work on as many systems as possible,
41 and allows errors to be handled gracefully.
42
43 This is not a "loader" in the sense of loading all the required Vulkan
44 functions (which is the application's responsibility), but just a minimal
45 implementation to portably load the Vulkan library and get the two functions
46 that are used to load everything else.
47
48 Note that this owns the loaded Vulkan library, so it must outlive all use of
49 the Vulkan API.
50
51 @see https://www.khronos.org/registry/vulkan/specs/1.0/html/chap4.html
52 */
53 typedef struct PuglVulkanLoaderImpl PuglVulkanLoader;
54
55 /**
56 Create a new dynamic loader for Vulkan functions.
57
58 This dynamically loads the Vulkan library and gets the load functions from
59 it.
60
61 @return A new Vulkan loader, or null on failure.
62 */
63 PUGL_API
64 PuglVulkanLoader*
65 puglNewVulkanLoader(PuglWorld* world);
66
67 /**
68 Free a loader created with puglNewVulkanLoader().
69
70 Note that this closes the Vulkan library, so no Vulkan objects or API may be
71 used after this is called.
72 */
73 PUGL_API
74 void
75 puglFreeVulkanLoader(PuglVulkanLoader* loader);
76
77 /**
78 Return the `vkGetInstanceProcAddr` function.
79
80 @return Null if the Vulkan library does not contain this function (which is
81 unlikely and indicates a broken system).
82 */
83 PUGL_API
84 PFN_vkGetInstanceProcAddr
85 puglGetInstanceProcAddrFunc(const PuglVulkanLoader* loader);
86
87 /**
88 Return the `vkGetDeviceProcAddr` function.
89
90 @return Null if the Vulkan library does not contain this function (which is
91 unlikely and indicates a broken system).
92 */
93 PUGL_API
94 PFN_vkGetDeviceProcAddr
95 puglGetDeviceProcAddrFunc(const PuglVulkanLoader* loader);
96
97 /**
98 Return the Vulkan instance extensions required to draw to a PuglView.
99
100 This simply returns static strings, it does not access Vulkan or the window
101 system. The returned array always contains at least "VK_KHR_surface".
102
103 @param[out] count The number of extensions in the returned array.
104 @return An array of extension name strings.
105 */
106 PUGL_API
107 const char* const*
108 puglGetInstanceExtensions(uint32_t* count);
109
110 /**
111 Create a Vulkan surface for a Pugl view.
112
113 @param vkGetInstanceProcAddr Accessor for Vulkan functions.
114 @param view The view the surface is to be displayed on.
115 @param instance The Vulkan instance.
116 @param allocator Vulkan allocation callbacks, may be NULL.
117 @param[out] surface Pointed to a newly created Vulkan surface.
118 @return `VK_SUCCESS` on success, or a Vulkan error code.
119 */
120 PUGL_API
121 VkResult
122 puglCreateSurface(PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr,
123 PuglView* view,
124 VkInstance instance,
125 const VkAllocationCallbacks* allocator,
126 VkSurfaceKHR* surface);
127
128 /**
129 Vulkan graphics backend.
130
131 Pass the returned value to puglSetBackend() to draw to a view with Vulkan.
132 */
133 PUGL_CONST_API
134 const PuglBackend*
135 puglVulkanBackend(void);
136
137 /**
138 @}
139 */
140
141 PUGL_END_DECLS
142
143 #endif // PUGL_VULKAN_H