Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 1 | /* |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 2 | * Vulkan |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014-2015 LunarG, Inc. |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a |
| 7 | * copy of this software and associated documentation files (the "Software"), |
| 8 | * to deal in the Software without restriction, including without limitation |
| 9 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| 10 | * and/or sell copies of the Software, and to permit persons to whom the |
| 11 | * Software is furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included |
| 14 | * in all copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
| 19 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| 21 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| 22 | * DEALINGS IN THE SOFTWARE. |
| 23 | * |
| 24 | * Authors: |
| 25 | * Chia-I Wu <olv@lunarg.com> |
| 26 | */ |
| 27 | |
| 28 | #ifndef ICD_INSTANCE_H |
| 29 | #define ICD_INSTANCE_H |
| 30 | |
| 31 | #include "icd-utils.h" |
| 32 | #include "icd.h" |
| 33 | |
| 34 | #ifdef __cplusplus |
| 35 | extern "C" { |
| 36 | #endif |
| 37 | |
| 38 | struct icd_instance_logger { |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 39 | VK_DBG_MSG_CALLBACK_FUNCTION func; |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 40 | void *user_data; |
| 41 | |
| 42 | struct icd_instance_logger *next; |
| 43 | }; |
| 44 | |
| 45 | struct icd_instance { |
| 46 | char *name; |
| 47 | |
| 48 | bool debug_echo_enable; |
| 49 | bool break_on_error; |
| 50 | bool break_on_warning; |
| 51 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame^] | 52 | VkAllocCallbacks alloc_cb; |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 53 | |
| 54 | struct icd_instance_logger *loggers; |
| 55 | }; |
| 56 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame^] | 57 | struct icd_instance *icd_instance_create(const VkApplicationInfo *app_info, |
| 58 | const VkAllocCallbacks *alloc_cb); |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 59 | void icd_instance_destroy(struct icd_instance *instance); |
| 60 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame^] | 61 | VkResult icd_instance_set_bool(struct icd_instance *instance, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 62 | VK_DBG_GLOBAL_OPTION option, bool yes); |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 63 | |
| 64 | static inline void *icd_instance_alloc(const struct icd_instance *instance, |
| 65 | size_t size, size_t alignment, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame^] | 66 | VkSystemAllocType type) |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 67 | { |
| 68 | return instance->alloc_cb.pfnAlloc(instance->alloc_cb.pUserData, |
| 69 | size, alignment, type); |
| 70 | } |
| 71 | |
| 72 | static inline void icd_instance_free(const struct icd_instance *instance, |
| 73 | void *ptr) |
| 74 | { |
| 75 | instance->alloc_cb.pfnFree(instance->alloc_cb.pUserData, ptr); |
| 76 | } |
| 77 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame^] | 78 | VkResult icd_instance_add_logger(struct icd_instance *instance, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 79 | VK_DBG_MSG_CALLBACK_FUNCTION func, |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 80 | void *user_data); |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame^] | 81 | VkResult icd_instance_remove_logger(struct icd_instance *instance, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 82 | VK_DBG_MSG_CALLBACK_FUNCTION func); |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 83 | |
| 84 | void icd_instance_log(const struct icd_instance *instance, |
Courtney Goeltzenleuchter | 9cc421e | 2015-04-08 15:36:08 -0600 | [diff] [blame] | 85 | VK_DBG_MSG_TYPE msg_type, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame^] | 86 | VkValidationLevel validation_level, |
| 87 | VkBaseObject src_object, |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 88 | size_t location, int32_t msg_code, |
| 89 | const char *msg); |
| 90 | |
| 91 | #ifdef __cplusplus |
| 92 | } |
| 93 | #endif |
| 94 | |
| 95 | #endif /* ICD_INSTANCE_H */ |