Vulkan Helpers

Small personal helper library for [Vulkan](https://www.khronos.org/vulkan/) usage in **c**. Simplify several common tasks, as image or buffers handling, swapchain initialization, etc. **vkh** is used by [vkvg] internally and also to speed up vulkan context creation in samples. ### Building from source ```bash git clone https://github.com/jpbruyere/vkhelpers.git cd vkhelpers mkdir build cd build cmake .. make && make install ``` ### Adding vkh to your CMake project - clone vkh as a subdirectory of your root dir. - in your main CMakeFile, add `add_subdirectory (vkhelpers)` - add to your **TARGET_INCLUDE_DIRECTORIES** `${CMAKE_CURRENT_SOURCE_DIR}/vkhelpers/include` and if you want to bypass opaque pointers and be able to address fields of internal structures, add also `${CMAKE_CURRENT_SOURCE_DIR}/vkhelpers/src`. - to link vkh staticaly, add to **TARGET_LINK_LIBRARIES** `vkh_static` or `vkh_shared` to link it as a shared library. ### Quick howto: ##### Create instance ```c #include "vkh.h" #include "vkh_phyinfo.h" void init_vulkan () { const char* layers [] = {"VK_LAYER_KHRONOS_validation"}; const char* exts [] = {"VK_EXT_debug_utils"}; VkhApp app = vkh_app_create ("appname", 1, layers, 1, exts); ``` ##### Select physical device **VkhPhyInfo** is an helper structure that will store common usefull physical device informations, queues flags, memory properties in a single call for all the devices present on the machine. ```c VkhPhyInfo* phys = vkh_app_get_phyinfos (e->app, &phyCount, surf); ``` Once you have an array of VkhPhyInfo's, you have several functions to inspect available devices: ```c for (uint i=0; iapp, pi, &device_info); ``` ##### The Presenter VkhPresenter will help getting rapidly something on screen, it handles the swapchain. ```c VkhPresenter present = vkh_presenter_create (dev, pi->pQueue, surf, width, height, VK_FORMAT_B8G8R8A8_UNORM, VK_PRESENT_MODE_MAILBOX_KHR); //create a blitting command buffer per swapchain images with vkh_presenter_build_blit_cmd (present, vkvg_surface_get_vk_image(surf), width, height); while (running) { if (!vkh_presenter_draw (present)) //on draw failed, swapchain is automatically rebuilt vkh_presenter_build_blit_cmd (present, vkvg_surface_get_vk_image(surf), width, height); } ``` ##### Creating Images TODO ##### Creating Buffers TODO