sync-ing asm and dis for minimal shaders
[vulkan-misc.git] / 2d / kickstart / vk_syms.c
blob5b83b0fcf4a1d79eaf5b150ff09faee66c402cd3
1 #ifndef VK_SYMS_C
2 #define VK_SYMS_C
3 /*
4 * this is public domain without any warranties of any kind
5 * Sylvain BERTRAND
6 */
7 /* XXX: KEEP AN EYE ON ABBREVIATIONS */
8 #include <dlfcn.h>
9 #include <stdlib.h>
11 #include "app_core_types.h"
12 #include "vk_types.h"
13 #include "log.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)(
28 u32 *props_n,
29 struct vk_layer_props_t *props);
31 static s32 (*vk_enumerate_instance_ext_props)(
32 u8 *layer_name,
33 u32 *props_n,
34 struct vk_ext_props_t *props);
36 static s32 (*vk_create_instance)(
37 struct vk_instance_create_info_t *info,
38 void *allocator,
39 void **instance);
41 static s32 (*vk_enumerate_phydevs)(
42 void *instance,
43 u32 *phydevs_n,
44 void **phydevs);
46 static s32 (*vk_enumerate_dev_ext_props)(
47 void *phydev,
48 u8 *layer_name,
49 u32 *props_n,
50 struct vk_ext_props_t *props);
52 static void (*vk_get_phydev_props)(
53 void *phydev,
54 struct vk_phydev_props_t *props);
56 static s32 (*vk_create_dev)(
57 void *phydev,
58 struct vk_dev_create_info_t *create_info,
59 void *allocator,
60 void **dev);
62 static void (*vk_get_phydev_q_fam_props)(
63 void *phydev,
64 u32 *q_fam_props_n,
65 struct vk_q_fam_props_t *props);
67 static s32 (*vk_create_xcb_surf)(
68 void *instance,
69 struct vk_xcb_surf_create_info_t *info,
70 void *allocator,
71 void **surf);
73 static s32 (*vk_get_phydev_surf_support)(
74 void *phydev,
75 u32 q_fam,
76 void *surf,
77 u32 *supported);
79 static s32 (*vk_get_phydev_surf_texel_mem_blk_confs)(
80 void *phydev,
81 struct vk_phydev_surf_info_t *info,
82 u32 *confs_n,
83 struct vk_surf_texel_mem_blk_conf_t *confs);
84 static void (*vk_get_phydev_mem_props)(
85 void *phydev,
86 struct vk_phydev_mem_props_t *props);
88 static s32 (*vk_get_phydev_surf_caps)(
89 void *phydev,
90 struct vk_phydev_surf_info_t *info,
91 struct vk_surf_caps_t *caps);
93 static s32 (*vk_get_phydev_surf_present_modes)(
94 void *phydev,
95 void *surf,
96 u32 *modes_n,
97 u32 *modes);
98 /*----------------------------------------------------------------------------*/
99 #define INSTANCE_STATIC_SYM(x,y) \
100 y = vk_get_instance_proc_addr(0, #x); \
101 if (y == 0) { \
102 LOG("0:MAIN:FATAL:unable to find vulkan " #x "\n"); \
103 exit(1); \
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); \
119 if (y == 0) { \
120 LOG("0:MAIN:FATAL:unable to find vulkan " #x "\n"); \
121 exit(1); \
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 /*--------------------------------------------------------------------*/
148 #undef INSTANCE_SYM
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"); \
154 exit(1); \
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);
184 #undef DEVICE_SYM
185 /*----------------------------------------------------------------------------*/
186 #define DLSYM(x, y) \
187 y = dlsym(loader_g, #x); \
188 if (y == 0) { \
189 LOG("0:MAIN:FATAL:%s:unable to find " #x "\n", dlerror()); \
190 exit(1); \
192 static void loader_syms(void)
194 DLSYM(vkGetInstanceProcAddr, vk_get_instance_proc_addr);
195 DLSYM(vkGetDeviceProcAddr, vk_get_dev_proc_addr);
197 #undef DLSYM
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);
203 if (loader_g == 0) {
204 LOG("0:MAIN:FATAL:%s:unable to load the vulkan loader dynamic shared library\n", dlerror());
205 exit(1);
208 #define CLEANUP
209 #include "namespace/vk_syms.c"
210 #undef CLEANUP
211 #endif /* VK_SYMS_C */