ugh
[vktest3] / src / vk.h
index 3f765ac..b9a8fb0 100644 (file)
--- a/src/vk.h
+++ b/src/vk.h
@@ -18,6 +18,37 @@ enum {
        VKQ_XFER                = 8
 };
 
+/* shader types
+ * arranged so that: (1 << VKSDR_FOO) == VK_SHADER_STAGE_FOO_BIT
+ */
+enum {
+       VKSDR_VERTEX    = 0,
+       VKSDR_TESS_CTL  = 1,
+       VKSDR_TESS_EVAL = 2,
+       VKSDR_GEOM              = 3,
+       VKSDR_PIXEL             = 4,
+       VKSDR_COMPUTE   = 5,
+
+       VKSDR_TASK              = 6,
+       VKSDR_MESH              = 7,
+
+       VKSDR_RAYGEN    = 8,
+       VKSDR_ANYHIT    = 9,
+       VKSDR_CLOSESTHIT = 10,
+       VKSDR_MISS              = 11,
+       VKSDR_ISECT             = 12,
+
+       VKSDR_MAX
+};
+#define VKSDR_STAGE(x) (1 << (x))
+
+/* primitives */
+enum {
+       VKPRIM_POINTS           = VK_PRIMITIVE_TOPOLOGY_POINT_LIST,
+       VKPRIM_LINES            = VK_PRIMITIVE_TOPOLOGY_LINE_LIST,
+       VKPRIM_TRIANGLES        = VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST
+};
+
 void vk_init_xwin(Display *dpy, Window win);
 void vk_init_queue(unsigned int qflags, int count);
 
@@ -26,9 +57,23 @@ void vk_cleanup(void);
 
 int vk_reshape(int xsz, int ysz);
 
+/* returns the number of swapchain images */
+int vk_num_swap_images(void);
+VkImageView vk_swap_image(int idx);
+/* returns the image index, or -1 on failure. Pass optional semaphore to signal */
+int vk_next_swap_image(VkSemaphore sem);
+
+int vk_submit(VkQueue q, VkCommandBuffer cmdbuf, VkSemaphore semwait, VkSemaphore semsig);
+int vk_present(VkQueue q, int imgid, VkSemaphore semwait);
+
 int vk_find_qfamily(unsigned int flags);
 VkQueue vk_getq_fam(int fam, int n);
-VkQueue vk_getq(unsigned int flags);
+VkQueue vk_getq(unsigned int flags, int n);
+
+VkCommandBuffer vk_create_cmdbuf_fam(int qfam, int level);
+VkCommandBuffer vk_create_cmdbuf(unsigned int qflags, int level);
+/* return one of the swap-chain command buffers */
+VkCommandBuffer vk_get_cmdbuf(int imgid);
 
 int vk_create_rpass(void);
 void vk_free_rpass(int rp);
@@ -44,6 +89,38 @@ void vk_fb_rpass(int fb, int rpass);
 void vk_fb_images(int fb, int n, ...);
 VkFramebuffer vk_fb(int fb);
 
+int vk_create_pipeln(void);
+void vk_free_pipeln(int pp);
+void vk_pipeln_rpass(int pp, VkRenderPass rp);
+void vk_pipeln_viewport(int pp, int x, int y, int width, int height);
+void vk_pipeln_scissor(int pp, int x, int y, int width, int height);
+void vk_pipeln_shader(int pp, int type, VkShaderModule sdr);
+/* TODO: vertex input */
+void vk_pipeln_prim(int pp, int prim);
+void vk_pipeln_polymode(int pp, int mode);
+void vk_pipeln_cull(int pp, int cull);
+void vk_pipeln_frontface(int pp, int ff);
+void vk_pipeln_linewidth(int pp, int w);
+void vk_pipeln_multisample(int pp, int nsamples);
+void vk_pipeln_colormask(int pp, int r, int g, int b, int a);
+void vk_pipeln_depthmask(int pp, int z);
+void vk_pipeln_stencilmask(int pp, int s);
+void vk_pipeln_zbuffer(int pp, int enable);
+void vk_pipeln_zbuffer_op(int pp, int op);
+void vk_pipeln_stencil(int pp, int enable);
+void vk_pipeln_stencil_op(int pp, int sfail, int zfail, int zpass);
+void vk_pipeln_stencil_func(int pp, int op, unsigned int ref, unsigned int mask);
+void vk_pipeln_blend(int pp, int enable);
+void vk_pipeln_blendfunc(int pp, int src, int dst);
+VkPipeline vk_pipeln(int pp);
+
+VkShaderModule vk_load_shader(const char *fname);
+void vk_free_shader(VkShaderModule sdr);
+
+VkSemaphore vk_create_sem(void);
+void vk_free_sem(VkSemaphore sem);
 
+/* random helpers */
+void vk_rect(VkRect2D *r, int x, int y, int w, int h);
 
 #endif /* VK_H_ */