diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/vkh.h | 72 |
1 files changed, 60 insertions, 12 deletions
diff --git a/include/vkh.h b/include/vkh.h index 512b40b..3e9a95b 100644 --- a/include/vkh.h +++ b/include/vkh.h @@ -116,14 +116,6 @@ typedef enum VkhMemoryUsage { #define VKH_MO 0x00100000 #define VKH_GO 0x40000000 -#define VK_CHECK_RESULT(f) \ - { \ - VkResult res = (f); \ - if (res != VK_SUCCESS) { \ - fprintf(stderr, "Fatal : VkResult is %d in %s at line %d\n", res, __FILE__, __LINE__); \ - assert(res == VK_SUCCESS); \ - } \ - } #ifndef vkh_public #ifdef VKH_SHARED_BUILD #if (defined(_WIN32) || defined(_WIN64)) @@ -138,6 +130,47 @@ typedef enum VkhMemoryUsage { #endif #endif + +#define VKH_LOG_ERR 0x00000001 +#define VKH_LOG_DEBUG 0x00000002 +#define VKH_LOG_INFO 0x00000004 +#define VKH_LOG_FULL 0xffffffff + +#ifdef DEBUG +extern uint32_t vkh_log_level; +#endif + +#ifndef LOG +#ifdef DEBUG +#define LOG(level, ...) \ + { \ + if ((vkh_log_level) & (level)) \ + fprintf(stdout, __VA_ARGS__); \ + } +#else +#define LOG +#endif +#endif + +#define VK_CHECK_RESULT(f) \ + { \ + VkResult res = (f); \ + if (res != VK_SUCCESS) { \ + LOG(VKH_LOG_ERR, "Fatal : VkResult is %d in %s at line %d\n", res, __FILE__, __LINE__); \ + assert(res == VK_SUCCESS); \ + } \ + } + +#define VKH_CHECK_RESULT(status, f) \ + { \ + status = (f); \ + if (status != VK_SUCCESS) { \ + LOG(VKH_LOG_ERR, "Fatal : VkResult is %d in %s at line %d\n", status, __FILE__, __LINE__); \ + assert(status == VK_SUCCESS); \ + } \ + } + + typedef struct _vkh_app_t *VkhApp; typedef struct _vkh_phy_t *VkhPhyInfo; typedef struct _vkh_device_t *VkhDevice; @@ -153,10 +186,23 @@ vkh_public VkhApp vkh_app_create(uint32_t version_major, uint32_t version_mi uint32_t enabledLayersCount, const char **enabledLayers, uint32_t ext_count, const char *extentions[]); vkh_public void vkh_app_destroy(VkhApp app); +/** + * @brief Get current status of vkh application + * @param app + * @return VkResult + */ +vkh_public VkResult vkh_app_status (VkhApp app); vkh_public VkInstance vkh_app_get_inst(VkhApp app); // VkPhysicalDevice vkh_app_select_phy (VkhApp app, VkPhysicalDeviceType preferedPhyType); vkh_public VkhPhyInfo *vkh_app_get_phyinfos(VkhApp app, uint32_t *count, VkSurfaceKHR surface); vkh_public void vkh_app_free_phyinfos(uint32_t count, VkhPhyInfo *infos); +/** + * @brief Add a Debug utils messenger to this VkhApp. It will be destroyed on VkhApp end. + * @param VKH application pointer containing vkInstance. + * @param Message type flags + * @param Message severity flags. + * @param optional message callback, if null a default one which print to stdout is configured. + */ vkh_public void vkh_app_enable_debug_messenger(VkhApp app, VkDebugUtilsMessageTypeFlagsEXT typeFlags, VkDebugUtilsMessageSeverityFlagsEXT severityFlags, PFN_vkDebugUtilsMessengerCallbackEXT callback); @@ -194,6 +240,7 @@ vkh_public bool vkh_phyinfo_try_get_extension_properties(VkhPhyInfo phy, const c *************/ vkh_public VkhDevice vkh_device_create(VkhApp app, VkhPhyInfo phyInfo, VkDeviceCreateInfo *pDevice_info); vkh_public VkhDevice vkh_device_import(VkInstance inst, VkPhysicalDevice phy, VkDevice vkDev); +vkh_public VkResult vkh_device_status(VkhDevice dev); vkh_public void vkh_device_destroy(VkhDevice dev); vkh_public void vkh_device_init_debug_utils(VkhDevice dev); vkh_public VkDevice vkh_device_get_vkdev(VkhDevice dev); @@ -209,7 +256,7 @@ vkh_public void vkh_device_set_object_name(VkhDevice dev, VkObjectType objectTyp vkh_public VkSampler vkh_device_create_sampler(VkhDevice dev, VkFilter magFilter, VkFilter minFilter, VkSamplerMipmapMode mipmapMode, VkSamplerAddressMode addressMode); -vkh_public void vkh_device_destroy_sampler(VkhDevice dev, VkSampler sampler); +vkh_public void vkh_device_destroy_sampler(VkhDevice dev, VkSampler sampler); /**************** * VkhPresenter * @@ -217,9 +264,9 @@ vkh_public void vkh_device_destroy_sampler(VkhDevice dev, VkSampler sampler vkh_public VkhPresenter vkh_presenter_create(VkhDevice dev, uint32_t presentQueueFamIdx, VkSurfaceKHR surface, uint32_t width, uint32_t height, VkFormat preferedFormat, VkPresentModeKHR presentMode); -vkh_public void vkh_presenter_destroy(VkhPresenter r); -vkh_public bool vkh_presenter_draw(VkhPresenter r); -vkh_public bool vkh_presenter_acquireNextImage(VkhPresenter r, VkFence fence, VkSemaphore semaphore); +vkh_public void vkh_presenter_destroy(VkhPresenter r); +vkh_public bool vkh_presenter_draw(VkhPresenter r); +vkh_public bool vkh_presenter_acquireNextImage(VkhPresenter r, VkFence fence, VkSemaphore semaphore); vkh_public void vkh_presenter_build_blit_cmd(VkhPresenter r, VkImage blitSource, uint32_t width, uint32_t height); vkh_public void vkh_presenter_create_swapchain(VkhPresenter r); vkh_public void vkh_presenter_get_size(VkhPresenter r, uint32_t *pWidth, uint32_t *pHeight); @@ -229,6 +276,7 @@ vkh_public void vkh_presenter_get_size(VkhPresenter r, uint32_t *pWidth, uint32_ vkh_public VkhImage vkh_image_import(VkhDevice pDev, VkImage vkImg, VkFormat format, uint32_t width, uint32_t height); vkh_public VkhImage vkh_image_create(VkhDevice pDev, VkFormat format, uint32_t width, uint32_t height, VkImageTiling tiling, VkhMemoryUsage memprops, VkImageUsageFlags usage); +vkh_public VkResult vkh_image_status(VkhImage img); vkh_public VkhImage vkh_image_ms_create(VkhDevice pDev, VkFormat format, VkSampleCountFlagBits num_samples, uint32_t width, uint32_t height, VkhMemoryUsage memprops, VkImageUsageFlags usage); |