4 * this is public domain without any warranties of any kind
7 /* XXX: KEEP AN EYE ON ABBREVIATIONS */
11 #include "app_core_types.h"
15 #include "app_state.c"
17 #include "namespace/vk_syms.c"
19 static void *loader_g
; /* we put the dl handle in vk namespace */
21 static void *(*vk_get_instance_proc_addr
)(void *instance
, u8
*name
);
22 static void *(*vk_get_dev_proc_addr
)(void *dev
, u8
*name
);
24 /* we don't support vk 1.0 (too broken), then the following must exist */
25 static s32 (*vk_enumerate_instance_version
)(u32
*version
);
27 static s32 (*vk_enumerate_instance_layer_props
)(
29 struct vk_layer_props_t
*props
);
31 static s32 (*vk_enumerate_instance_ext_props
)(
34 struct vk_ext_props_t
*props
);
36 static s32 (*vk_create_instance
)(
37 struct vk_instance_create_info_t
*info
,
41 static s32 (*vk_enumerate_phydevs
)(
46 static s32 (*vk_enumerate_dev_ext_props
)(
50 struct vk_ext_props_t
*props
);
52 static void (*vk_get_phydev_props
)(
54 struct vk_phydev_props_t
*props
);
56 static s32 (*vk_create_dev
)(
58 struct vk_dev_create_info_t
*create_info
,
62 static void (*vk_get_phydev_q_fam_props
)(
65 struct vk_q_fam_props_t
*props
);
67 static s32 (*vk_create_xcb_surf
)(
69 struct vk_xcb_surf_create_info_t
*info
,
73 static s32 (*vk_get_phydev_surf_support
)(
79 static s32 (*vk_get_phydev_surf_texel_mem_blk_confs
)(
81 struct vk_phydev_surf_info_t
*info
,
83 struct vk_surf_texel_mem_blk_conf_t
*confs
);
84 static void (*vk_get_phydev_mem_props
)(
86 struct vk_phydev_mem_props_t
*props
);
88 static s32 (*vk_get_phydev_surf_caps
)(
90 struct vk_phydev_surf_info_t
*info
,
91 struct vk_surf_caps_t
*caps
);
93 static s32 (*vk_get_phydev_surf_present_modes
)(
98 /*----------------------------------------------------------------------------*/
99 #define INSTANCE_STATIC_SYM(x,y) \
100 y = vk_get_instance_proc_addr(0, #x); \
102 LOG("0:MAIN:FATAL:unable to find vulkan " #x "\n"); \
105 static void instance_static_syms(void)
107 INSTANCE_STATIC_SYM(vkEnumerateInstanceVersion
,
108 vk_enumerate_instance_version
);
109 INSTANCE_STATIC_SYM(vkEnumerateInstanceExtensionProperties
,
110 vk_enumerate_instance_ext_props
);
111 INSTANCE_STATIC_SYM(vkEnumerateInstanceLayerProperties
,
112 vk_enumerate_instance_layer_props
);
113 INSTANCE_STATIC_SYM(vkCreateInstance
, vk_create_instance
);
115 #undef INSTANCE_STATIC_SYM
116 /*----------------------------------------------------------------------------*/
117 #define INSTANCE_SYM(x,y) \
118 y = vk_get_instance_proc_addr(app_instance, #x); \
120 LOG("0:MAIN:FATAL:unable to find vulkan " #x "\n"); \
123 static void instance_syms(void)
125 INSTANCE_SYM(vkEnumeratePhysicalDevices
, vk_enumerate_phydevs
);
126 INSTANCE_SYM(vkEnumerateDeviceExtensionProperties
,
127 vk_enumerate_dev_ext_props
);
128 INSTANCE_SYM(vkGetPhysicalDeviceProperties2
, vk_get_phydev_props
);
129 INSTANCE_SYM(vkGetPhysicalDeviceQueueFamilyProperties2
,
130 vk_get_phydev_q_fam_props
);
131 INSTANCE_SYM(vkCreateDevice
, vk_create_dev
);
132 /* wsi related -------------------------------------------------------*/
133 INSTANCE_SYM(vkGetPhysicalDeviceSurfaceSupportKHR
,
134 vk_get_phydev_surf_support
);
135 INSTANCE_SYM(vkGetPhysicalDeviceSurfaceFormats2KHR
,
136 vk_get_phydev_surf_texel_mem_blk_confs
);
137 INSTANCE_SYM(vkCreateXcbSurfaceKHR
, vk_create_xcb_surf
);
138 INSTANCE_SYM(vkGetPhysicalDeviceMemoryProperties2
,
139 vk_get_phydev_mem_props
);
140 INSTANCE_SYM(vkGetPhysicalDeviceSurfaceCapabilities2KHR
,
141 vk_get_phydev_surf_caps
);
142 INSTANCE_SYM(vkGetPhysicalDeviceSurfacePresentModesKHR
,
143 vk_get_phydev_surf_present_modes
);
144 INSTANCE_SYM(vkGetPhysicalDeviceSurfacePresentModesKHR
,
145 vk_get_phydev_surf_present_modes
);
146 /*--------------------------------------------------------------------*/
149 /*----------------------------------------------------------------------------*/
150 #define DEV_SYM(x,y) \
151 app_surf.dev.dl_##y = vk_get_dev_proc_addr(app_surf.dev.vk, #x); \
152 if (app_surf.dev.dl_##y == 0) { \
153 LOG("0:MAIN:FATAL:unable to find vulkan device " #x "\n"); \
156 static void dev_syms(void)
158 DEV_SYM(vkGetDeviceQueue
, vk_get_dev_q
);
159 DEV_SYM(vkCreateCommandPool
, vk_create_cmdpool
);
160 DEV_SYM(vkCreateSwapchainKHR
, vk_create_swpchn
);
161 DEV_SYM(vkGetSwapchainImagesKHR
, vk_get_swpchn_imgs
);
162 DEV_SYM(vkCreateImage
, vk_create_img
);
163 DEV_SYM(vkGetImageMemoryRequirements2KHR
, vk_get_img_mem_rqmts
);
164 DEV_SYM(vkAllocateMemory
, vk_alloc_mem
);
165 DEV_SYM(vkBindImageMemory2KHR
, vk_bind_img_mem
);
166 DEV_SYM(vkMapMemory
, vk_map_mem
);
167 DEV_SYM(vkAllocateCommandBuffers
, vk_alloc_cmdbufs
);
168 DEV_SYM(vkFreeCommandBuffers
, vk_free_cmdbufs
);
169 DEV_SYM(vkBeginCommandBuffer
, vk_begin_cmdbuf
);
170 DEV_SYM(vkEndCommandBuffer
, vk_end_cmdbuf
);
171 DEV_SYM(vkCmdPipelineBarrier
, vk_cmd_pipeline_barrier
);
172 DEV_SYM(vkQueueSubmit
, vk_q_submit
);
173 DEV_SYM(vkQueueWaitIdle
, vk_q_wait_idle
);
174 DEV_SYM(vkGetImageSubresourceLayout
, vk_get_img_subrsrc_layout
);
175 DEV_SYM(vkAcquireNextImage2KHR
, vk_acquire_next_img
);
176 DEV_SYM(vkCreateFence
, vk_create_fence
);
177 DEV_SYM(vkResetCommandBuffer
, vk_reset_cmdbuf
);
178 DEV_SYM(vkCmdBlitImage
, vk_cmd_blit_img
);
179 DEV_SYM(vkWaitForFences
, vk_wait_for_fences
);
180 DEV_SYM(vkResetFences
, vk_reset_fences
);
181 DEV_SYM(vkQueuePresentKHR
, vk_q_present
);
182 DEV_SYM(vkCreateSemaphore
, vk_create_sem
);
185 /*----------------------------------------------------------------------------*/
186 #define DLSYM(x, y) \
187 y = dlsym(loader_g, #x); \
189 LOG("0:MAIN:FATAL:%s:unable to find " #x "\n", dlerror()); \
192 static void loader_syms(void)
194 DLSYM(vkGetInstanceProcAddr
, vk_get_instance_proc_addr
);
195 DLSYM(vkGetDeviceProcAddr
, vk_get_dev_proc_addr
);
198 /*----------------------------------------------------------------------------*/
199 static void load_vk_loader(void)
201 /* no '/' in the shared dynamic lib path name, then standard lookup */
202 loader_g
= dlopen("libvulkan.so.1", RTLD_LAZY
);
204 LOG("0:MAIN:FATAL:%s:unable to load the vulkan loader dynamic shared library\n", dlerror());
209 #include "namespace/vk_syms.c"
211 #endif /* VK_SYMS_C */