simplification/taylorization and fix
[vulkan-misc.git] / 2d / blit / vk_app.h
blob4c5043247667e9b7b5663351fde37c67bca735bb
1 #ifndef VK_APP_H
2 #define VK_APP_H
3 /*
4 * this is public domain without any warranties of any kind
5 * Sylvain BERTRAND
6 */
7 /*
8 * this is the simplification and taylorization of vk api for the specific
9 * uses of the app.
11 #define vk_get_dev_q() \
12 app_surf.dev.dl_vk_get_dev_q(app_surf.dev.vk, app_surf.dev.phydev.q_fam, 0, &app_surf.dev.q)
14 #define vk_create_cp(info) \
15 r = app_surf.dev.dl_vk_create_cp(app_surf.dev.vk, info, 0, &app_surf.dev.cp)
17 #define vk_create_swpchn(info) \
18 r = app_surf.dev.dl_vk_create_swpchn(app_surf.dev.vk, info, 0, &app_surf.dev.swpchn.vk)
20 #define vk_get_swpchn_imgs() \
21 r = app_surf.dev.dl_vk_get_swpchn_imgs(app_surf.dev.vk, app_surf.dev.swpchn.vk, &app_surf.dev.swpchn.imgs_n, app_surf.dev.swpchn.imgs)
23 #define vk_create_img(info, img) \
24 r = app_surf.dev.dl_vk_create_img(app_surf.dev.vk, info, 0, img)
26 #define vk_get_img_mem_rqmts(...) \
27 r = app_surf.dev.dl_vk_get_img_mem_rqmts(app_surf.dev.vk,##__VA_ARGS__)
29 #define vk_alloc_mem(info, dev_mem) \
30 r = app_surf.dev.dl_vk_alloc_mem(app_surf.dev.vk, info, 0, dev_mem)
32 #define vk_bind_img_mem(infos) \
33 r = app_surf.dev.dl_vk_bind_img_mem(app_surf.dev.vk, app_surf.dev.swpchn.imgs_n, infos)
35 #define vk_map_mem(dev_mem, data) \
36 r = app_surf.dev.dl_vk_map_mem(app_surf.dev.vk, dev_mem, 0, vk_whole_sz, 0, data)
38 #define vk_alloc_cbs(info) \
39 r = app_surf.dev.dl_vk_alloc_cbs(app_surf.dev.vk, info, app_surf.dev.cbs)
41 #define vk_begin_cb(...) \
42 r = app_surf.dev.dl_vk_begin_cb(__VA_ARGS__)
44 #define vk_end_cb(...) \
45 r = app_surf.dev.dl_vk_end_cb(__VA_ARGS__)
47 #define vk_cmd_pl_barrier(cb, b) \
48 app_surf.dev.dl_vk_cmd_pl_barrier(cb, vk_pl_stage_top_of_pipe_bit, vk_pl_stage_top_of_pipe_bit, 0, 0, 0, 0, 0, 1, b)
50 #define vk_q_submit(info) \
51 r = app_surf.dev.dl_vk_q_submit(app_surf.dev.q, 1, info, 0)
53 #define vk_q_wait_idle() \
54 r = app_surf.dev.dl_vk_q_wait_idle(app_surf.dev.q)
56 #define vk_get_img_subrsrc_layout(...) \
57 app_surf.dev.dl_vk_get_img_subrsrc_layout(app_surf.dev.vk, ##__VA_ARGS__)
59 #define vk_acquire_next_img(...) \
60 r = app_surf.dev.dl_vk_acquire_next_img(app_surf.dev.vk,##__VA_ARGS__)
62 #define vk_reset_cb(cb) \
63 r = app_surf.dev.dl_vk_reset_cb(cb, 0)
65 #define vk_cmd_blit_img(cb, src_img, dst_img, region) \
66 app_surf.dev.dl_vk_cmd_blit_img(cb, src_img, vk_img_layout_general, dst_img, vk_img_layout_present, 1, region, 0)
68 #define vk_q_present(info) \
69 r = app_surf.dev.dl_vk_q_present(app_surf.dev.q, info)
71 #define vk_create_sem(info, sem) \
72 r = app_surf.dev.dl_vk_create_sem(app_surf.dev.vk, info, 0, sem)
73 /******************************************************************************/
74 /* cherry picked from nyanvk/syms_global.h */
75 #define VK_GLOBAL_SYMS \
76 static void *(*dl_vk_get_instance_proc_addr)(void *instance, u8 *name); \
77 static void *(*dl_vk_get_dev_proc_addr)(void *dev, u8 *name); \
78 static s32 (*dl_vk_enumerate_instance_version)(u32 *version); \
79 static s32 (*dl_vk_enumerate_instance_layer_props)( \
80 u32 *props_n, \
81 struct vk_layer_props_t *props); \
82 static s32 (*dl_vk_enumerate_instance_ext_props)( \
83 u8 *layer_name, \
84 u32 *props_n, \
85 struct vk_ext_props_t *props); \
86 static s32 (*dl_vk_create_instance)( \
87 struct vk_instance_create_info_t *info, \
88 void *allocator, \
89 void **instance); \
90 static s32 (*dl_vk_enumerate_phydevs)( \
91 void *instance, \
92 u32 *phydevs_n, \
93 void **phydevs); \
94 static s32 (*dl_vk_enumerate_dev_ext_props)( \
95 void *phydev, \
96 u8 *layer_name, \
97 u32 *props_n, \
98 struct vk_ext_props_t *props); \
99 static void (*dl_vk_get_phydev_props)( \
100 void *phydev, \
101 struct vk_phydev_props_t *props); \
102 static s32 (*dl_vk_create_dev)( \
103 void *phydev, \
104 struct vk_dev_create_info_t *create_info, \
105 void *allocator, \
106 void **dev); \
107 static void (*dl_vk_get_phydev_q_fam_props)( \
108 void *phydev, \
109 u32 *q_fam_props_n, \
110 struct vk_q_fam_props_t *props); \
111 static s32 (*dl_vk_create_xcb_surf)( \
112 void *instance, \
113 struct vk_xcb_surf_create_info_t *info, \
114 void *allocator, \
115 void **surf); \
116 static s32 (*dl_vk_get_phydev_surf_support)( \
117 void *phydev, \
118 u32 q_fam, \
119 void *surf, \
120 u32 *supported); \
121 static s32 (*dl_vk_get_phydev_surf_texel_mem_blk_confs)( \
122 void *phydev, \
123 struct vk_phydev_surf_info_t *info, \
124 u32 *confs_n, \
125 struct vk_surf_texel_mem_blk_conf_t *confs); \
126 static void (*dl_vk_get_phydev_mem_props)( \
127 void *phydev, \
128 struct vk_phydev_mem_props_t *props); \
129 static s32 (*dl_vk_get_phydev_surf_caps)( \
130 void *phydev, \
131 struct vk_phydev_surf_info_t *info, \
132 struct vk_surf_caps_t *caps); \
133 static s32 (*dl_vk_get_phydev_surf_present_modes)( \
134 void *phydev, \
135 void *surf, \
136 u32 *modes_n, \
137 u32 *modes);
138 /******************************************************************************/
139 #define vk_get_instance_proc_addr dl_vk_get_instance_proc_addr
141 #define vk_get_dev_proc_addr dl_vk_get_dev_proc_addr
143 #define vk_enumerate_instance_version \
144 r = dl_vk_enumerate_instance_version
146 #define vk_enumerate_instance_layer_props \
147 r = dl_vk_enumerate_instance_layer_props
149 #define vk_enumerate_instance_ext_props(...) \
150 r = dl_vk_enumerate_instance_ext_props(0,##__VA_ARGS__)
152 #define vk_create_instance(info) \
153 r = dl_vk_create_instance(info, 0, &app_instance)
155 #define vk_enumerate_phydevs(...) \
156 r = dl_vk_enumerate_phydevs(app_instance,##__VA_ARGS__)
158 #define vk_enumerate_dev_ext_props(phydev, props_n, props) \
159 r = dl_vk_enumerate_dev_ext_props(phydev, 0, props_n, props)
161 #define vk_get_phydev_props dl_vk_get_phydev_props
163 #define vk_create_dev(info) \
164 r = dl_vk_create_dev(app_surf.dev.phydev.vk, info, 0, &app_surf.dev.vk)
166 #define vk_get_phydev_q_fam_props dl_vk_get_phydev_q_fam_props
168 #define vk_create_xcb_surf(info) \
169 r = dl_vk_create_xcb_surf(app_instance, info, 0, &app_surf.vk)
171 #define vk_get_phydev_surf_support(phydev, q_fam, supported) \
172 r = dl_vk_get_phydev_surf_support(phydev, q_fam, app_surf.vk, supported)
174 #define vk_get_phydev_surf_texel_mem_blk_confs(info, ...) \
175 r = dl_vk_get_phydev_surf_texel_mem_blk_confs(app_surf.dev.phydev.vk, info, ##__VA_ARGS__)
177 #define vk_get_phydev_mem_props dl_vk_get_phydev_mem_props
179 #define vk_get_phydev_surf_caps(info) \
180 r = dl_vk_get_phydev_surf_caps(app_surf.dev.phydev.vk, info, &app_tmp_surf_caps)
182 #define vk_get_phydev_surf_present_modes() \
183 r = dl_vk_get_phydev_surf_present_modes(app_surf.dev.phydev.vk, app_surf.vk, &app_tmp_present_modes_n, app_tmp_present_modes)
184 #endif