vulkan_test2

view src/vku.h @ 9:5fbfd7f8fc24

minor
author John Tsiombikas <nuclear@member.fsf.org>
date Fri, 22 Jun 2018 02:40:22 +0300
parents 1dd2c7398afc
children e17abe477616
line source
1 #ifndef VKU_H_
2 #define VKU_H_
4 #ifdef __unix__
5 #define VK_USE_PLATFORM_XLIB_KHR
6 #endif
8 #include <vulkan/vulkan.h>
10 VkInstance vk;
11 VkDevice vkdev;
12 VkQueue vkq;
13 VkCommandPool vkcmdpool;
14 VkCommandBuffer vkcmdbuf; /* primary command buffer */
16 VkImage *swapchain_images;
17 int next_swapchain_image;
20 struct vku_buffer {
21 VkBuffer buf;
22 VkDeviceMemory mem_pool;
23 int mem_start, mem_size;
24 };
26 int vku_have_extension(const char *name);
27 int vku_have_device_extension(const char *name);
29 int vku_create_dev(void);
30 void vku_cleanup(void);
32 VkCommandBuffer vku_alloc_cmdbuf(VkCommandPool pool, VkCommandBufferLevel level);
33 void vku_free_cmdbuf(VkCommandPool pool, VkCommandBuffer buf);
35 void vku_begin_cmdbuf(VkCommandBuffer buf, unsigned int flags);
36 void vku_end_cmdbuf(VkCommandBuffer buf);
37 void vku_reset_cmdbuf(VkCommandBuffer buf);
39 void vku_submit_cmdbuf(VkQueue q, VkCommandBuffer buf, VkFence done_fence);
41 VkSwapchainKHR vku_create_swapchain(VkSurfaceKHR surf, int xsz, int ysz, int n,
42 VkPresentModeKHR pmode, VkSwapchainKHR prev);
43 VkImage *vku_get_swapchain_images(VkSwapchainKHR sc, int *count);
44 int vku_get_next_image(VkSwapchainKHR sc);
45 void vku_present(VkSwapchainKHR sc, int img_idx);
47 struct vku_buffer *vku_create_buffer(int sz, unsigned int usage);
48 void vku_destroy_buffer(struct vku_buffer *buf);
50 void vku_cmd_copybuf(VkCommandBuffer cmdbuf, VkBuffer dest, int doffs,
51 VkBuffer src, int soffs, int size);
53 /* platform-specific */
54 #ifdef VK_USE_PLATFORM_XLIB_KHR
55 #include <X11/Xlib.h>
56 int vku_xlib_usable_visual(Display *dpy, VisualID vid);
57 VkSurfaceKHR vku_xlib_create_surface(Display *dpy, Window win);
58 #endif
60 #endif /* VKU_H_ */