1bf215546Sopenharmony_ci/* 2bf215546Sopenharmony_ci * Copyright © 2021 Intel Corporation 3bf215546Sopenharmony_ci * 4bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 5bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"), 6bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation 7bf215546Sopenharmony_ci * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8bf215546Sopenharmony_ci * and/or sell copies of the Software, and to permit persons to whom the 9bf215546Sopenharmony_ci * Software is furnished to do so, subject to the following conditions: 10bf215546Sopenharmony_ci * 11bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next 12bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the 13bf215546Sopenharmony_ci * Software. 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 18bf215546Sopenharmony_ci * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19bf215546Sopenharmony_ci * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20bf215546Sopenharmony_ci * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21bf215546Sopenharmony_ci * IN THE SOFTWARE. 22bf215546Sopenharmony_ci */ 23bf215546Sopenharmony_ci 24bf215546Sopenharmony_ci#include "vk_instance.h" 25bf215546Sopenharmony_ci 26bf215546Sopenharmony_ci#ifdef __cplusplus 27bf215546Sopenharmony_ciextern "C" { 28bf215546Sopenharmony_ci#endif 29bf215546Sopenharmony_ci 30bf215546Sopenharmony_ci/* __VK_ARG_N(...) returns the number of arguments provided to it */ 31bf215546Sopenharmony_ci#define __VK_ARG_SEQ(_1,_2,_3,_4,_5,_6,_7,_8,N,...) N 32bf215546Sopenharmony_ci#define __VK_ARG_N(...) __VK_ARG_SEQ(__VA_ARGS__,8,7,6,5,4,3,2,1,0) 33bf215546Sopenharmony_ci 34bf215546Sopenharmony_ci#define VK_LOG_OBJS(...) \ 35bf215546Sopenharmony_ci __VK_ARG_N(__VA_ARGS__), (const void*[]){__VA_ARGS__} 36bf215546Sopenharmony_ci 37bf215546Sopenharmony_ci#define VK_LOG_NO_OBJS(instance) 0, (const void**)instance 38bf215546Sopenharmony_ci 39bf215546Sopenharmony_ci#define vk_logd(objects_macro, format, ...) \ 40bf215546Sopenharmony_ci __vk_log(VK_DEBUG_UTILS_MESSAGE_SEVERITY_VERBOSE_BIT_EXT, \ 41bf215546Sopenharmony_ci VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, \ 42bf215546Sopenharmony_ci objects_macro, __FILE__, __LINE__, format, ## __VA_ARGS__) 43bf215546Sopenharmony_ci 44bf215546Sopenharmony_ci#define vk_logi(objects_macro, format, ...) \ 45bf215546Sopenharmony_ci __vk_log(VK_DEBUG_UTILS_MESSAGE_SEVERITY_INFO_BIT_EXT, \ 46bf215546Sopenharmony_ci VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, \ 47bf215546Sopenharmony_ci objects_macro, __FILE__, __LINE__, format, ## __VA_ARGS__) 48bf215546Sopenharmony_ci 49bf215546Sopenharmony_ci#define vk_logw(objects_macro, format, ...) \ 50bf215546Sopenharmony_ci __vk_log(VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT, \ 51bf215546Sopenharmony_ci VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, \ 52bf215546Sopenharmony_ci objects_macro, __FILE__, __LINE__, format, ## __VA_ARGS__) 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_ci#define vk_loge(objects_macro, format, ...) \ 55bf215546Sopenharmony_ci __vk_log(VK_DEBUG_UTILS_MESSAGE_SEVERITY_ERROR_BIT_EXT, \ 56bf215546Sopenharmony_ci VK_DEBUG_UTILS_MESSAGE_TYPE_GENERAL_BIT_EXT, \ 57bf215546Sopenharmony_ci objects_macro, __FILE__, __LINE__, format, ## __VA_ARGS__) 58bf215546Sopenharmony_ci 59bf215546Sopenharmony_ci#define vk_perf(objects_macro, format, ...) \ 60bf215546Sopenharmony_ci __vk_log(VK_DEBUG_UTILS_MESSAGE_SEVERITY_WARNING_BIT_EXT, \ 61bf215546Sopenharmony_ci VK_DEBUG_UTILS_MESSAGE_TYPE_PERFORMANCE_BIT_EXT, \ 62bf215546Sopenharmony_ci objects_macro, __FILE__, __LINE__, format, ## __VA_ARGS__) 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci#define __vk_log(severity, type, object_count, \ 65bf215546Sopenharmony_ci objects_or_instance, file, line, format, ...) \ 66bf215546Sopenharmony_ci __vk_log_impl(severity, type, object_count, objects_or_instance, \ 67bf215546Sopenharmony_ci file, line, format, ## __VA_ARGS__) 68bf215546Sopenharmony_ci 69bf215546Sopenharmony_civoid PRINTFLIKE(7, 8) 70bf215546Sopenharmony_ci__vk_log_impl(VkDebugUtilsMessageSeverityFlagBitsEXT severity, 71bf215546Sopenharmony_ci VkDebugUtilsMessageTypeFlagsEXT types, 72bf215546Sopenharmony_ci int object_count, 73bf215546Sopenharmony_ci const void **objects_or_instance, 74bf215546Sopenharmony_ci const char *file, 75bf215546Sopenharmony_ci int line, 76bf215546Sopenharmony_ci const char *format, 77bf215546Sopenharmony_ci ...); 78bf215546Sopenharmony_ci 79bf215546Sopenharmony_ci#define vk_error(obj, error) \ 80bf215546Sopenharmony_ci __vk_errorf(obj, error, __FILE__, __LINE__, NULL) 81bf215546Sopenharmony_ci 82bf215546Sopenharmony_ci#define vk_errorf(obj, error, ...) \ 83bf215546Sopenharmony_ci __vk_errorf(obj, error, __FILE__, __LINE__, __VA_ARGS__) 84bf215546Sopenharmony_ci 85bf215546Sopenharmony_ciVkResult 86bf215546Sopenharmony_ci__vk_errorv(const void *_obj, VkResult error, 87bf215546Sopenharmony_ci const char *file, int line, 88bf215546Sopenharmony_ci const char *format, va_list va); 89bf215546Sopenharmony_ci 90bf215546Sopenharmony_ciVkResult PRINTFLIKE(5, 6) 91bf215546Sopenharmony_ci__vk_errorf(const void *_obj, VkResult error, 92bf215546Sopenharmony_ci const char *file, int line, 93bf215546Sopenharmony_ci const char *format, ...); 94bf215546Sopenharmony_ci 95bf215546Sopenharmony_ci#ifdef __cplusplus 96bf215546Sopenharmony_ci} 97bf215546Sopenharmony_ci#endif