wintoys

wintoys.git
git clone git://git.lenczewski.org/wintoys.git
Log | Files | Refs | README

vkdemo.h (1135B)


      1 #ifndef VKDEMO_H
      2 #define VKDEMO_H
      3 
      4 #include <assert.h>
      5 #include <inttypes.h>
      6 #include <limits.h>
      7 #include <stdalign.h>
      8 #include <stdbool.h>
      9 #include <stdint.h>
     10 #include <stdio.h>
     11 #include <string.h>
     12 
     13 #include <vulkan/vulkan.h>
     14 
     15 // NOTE: MSVC UCRT does not support alloca() (or VLAs), so we need to include this header :/
     16 #include <malloc.h>
     17 
     18 #define KiB 1024ULL
     19 #define MiB (1024 * KiB)
     20 #define GiB (1024 * MiB)
     21 #define TiB (1024 * GiB)
     22 
     23 #define ARRLEN(arr) (sizeof (arr) / sizeof (arr)[0])
     24 
     25 #define MIN(a, b) ((a) < (b) ? (a) : (b))
     26 #define MAX(a, b) ((a) > (b) ? (a) : (b))
     27 #define CLAMP(v, min, max) (MIN(MAX(v, min), max))
     28 
     29 struct vkdemo_memory_arena {
     30 	void *ptr;
     31 	uint64_t cap, len;
     32 };
     33 
     34 struct vkdemo_memory {
     35 	struct vkdemo_memory_arena permanent, temporary;
     36 };
     37 
     38 extern bool
     39 vkdemo_init(struct vkdemo_memory *memory, VkInstance vk_instance, VkSurfaceKHR vk_surface, uint32_t width, uint32_t height);
     40 
     41 extern void
     42 vkdemo_update(struct vkdemo_memory *memory);
     43 
     44 extern void
     45 vkdemo_render(struct vkdemo_memory *memory, uint32_t width, uint32_t height);
     46 
     47 extern void
     48 vkdemo_free(struct vkdemo_memory *memory);
     49 
     50 #endif /* VKDEMO_H */