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 | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame^] | 39 | PFN_vkDbgMsgCallback func; |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 40 | void *user_data; |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame^] | 41 | VkFlags flags; |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 42 | |
| 43 | struct icd_instance_logger *next; |
| 44 | }; |
| 45 | |
| 46 | struct icd_instance { |
| 47 | char *name; |
| 48 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 49 | VkAllocCallbacks alloc_cb; |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 50 | |
| 51 | struct icd_instance_logger *loggers; |
| 52 | }; |
| 53 | |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 54 | struct icd_instance *icd_instance_create(const VkApplicationInfo *app_info, |
| 55 | const VkAllocCallbacks *alloc_cb); |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 56 | void icd_instance_destroy(struct icd_instance *instance); |
| 57 | |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 58 | static inline void *icd_instance_alloc(const struct icd_instance *instance, |
| 59 | size_t size, size_t alignment, |
Courtney Goeltzenleuchter | 382489d | 2015-04-10 08:34:15 -0600 | [diff] [blame] | 60 | VkSystemAllocType type) |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 61 | { |
| 62 | return instance->alloc_cb.pfnAlloc(instance->alloc_cb.pUserData, |
| 63 | size, alignment, type); |
| 64 | } |
| 65 | |
| 66 | static inline void icd_instance_free(const struct icd_instance *instance, |
| 67 | void *ptr) |
| 68 | { |
| 69 | instance->alloc_cb.pfnFree(instance->alloc_cb.pUserData, ptr); |
| 70 | } |
| 71 | |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame^] | 72 | VkResult icd_instance_create_logger(struct icd_instance *instance, |
| 73 | VkFlags msg_flags, |
| 74 | PFN_vkDbgMsgCallback func, |
| 75 | void *user_data, |
| 76 | VkDbgMsgCallback *msg_obj); |
| 77 | |
| 78 | VkResult icd_instance_destroy_logger( |
| 79 | struct icd_instance *instance, |
| 80 | const VkDbgMsgCallback msg_obj); |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 81 | |
| 82 | void icd_instance_log(const struct icd_instance *instance, |
Courtney Goeltzenleuchter | 1c7c65d | 2015-06-10 17:39:03 -0600 | [diff] [blame^] | 83 | VkFlags msg_flags, |
| 84 | VkObjectType obj_type, |
Mike Stroyan | 230e625 | 2015-04-17 12:36:38 -0600 | [diff] [blame] | 85 | VkObject src_object, |
Chia-I Wu | 15d8677 | 2015-02-21 14:00:17 +0800 | [diff] [blame] | 86 | size_t location, int32_t msg_code, |
| 87 | const char *msg); |
| 88 | |
| 89 | #ifdef __cplusplus |
| 90 | } |
| 91 | #endif |
| 92 | |
| 93 | #endif /* ICD_INSTANCE_H */ |