vulkan_test2

view src/vku.h @ 13:d34f84bede17

pipeline madness
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 25 Jun 2018 08:00:57 +0300
parents e17abe477616
children 9fb6c24691ea
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;
19 VkViewport vkvport;
20 VkRenderPass vkrpass;
23 struct vku_buffer {
24 VkBuffer buf;
25 VkDeviceMemory mem_pool;
26 int mem_start, mem_size;
27 };
29 int vku_have_extension(const char *name);
30 int vku_have_device_extension(const char *name);
32 int vku_create_dev(void);
33 void vku_cleanup(void);
35 VkCommandBuffer vku_alloc_cmdbuf(VkCommandPool pool, VkCommandBufferLevel level);
36 void vku_free_cmdbuf(VkCommandPool pool, VkCommandBuffer buf);
38 void vku_begin_cmdbuf(VkCommandBuffer buf, unsigned int flags);
39 void vku_end_cmdbuf(VkCommandBuffer buf);
40 void vku_reset_cmdbuf(VkCommandBuffer buf);
42 void vku_submit_cmdbuf(VkQueue q, VkCommandBuffer buf, VkFence done_fence);
44 VkSwapchainKHR vku_create_swapchain(VkSurfaceKHR surf, int xsz, int ysz, int n,
45 VkPresentModeKHR pmode, VkSwapchainKHR prev);
46 VkImage *vku_get_swapchain_images(VkSwapchainKHR sc, int *count);
47 int vku_get_next_image(VkSwapchainKHR sc);
48 void vku_present(VkSwapchainKHR sc, int img_idx);
50 struct vku_buffer *vku_create_buffer(int sz, unsigned int usage);
51 void vku_destroy_buffer(struct vku_buffer *buf);
53 void vku_cmd_copybuf(VkCommandBuffer cmdbuf, VkBuffer dest, int doffs,
54 VkBuffer src, int soffs, int size);
56 VkRenderPass vku_create_renderpass(VkFormat cfmt, VkFormat dsfmt);
57 void vku_destroy_renderpass(VkRenderPass rpass);
59 /* platform-specific */
60 #ifdef VK_USE_PLATFORM_XLIB_KHR
61 #include <X11/Xlib.h>
62 int vku_xlib_usable_visual(Display *dpy, VisualID vid);
63 VkSurfaceKHR vku_xlib_create_surface(Display *dpy, Window win);
64 #endif
66 #endif /* VKU_H_ */