blob: 13a146ba663c4bdbbfcd578e1e7dcf19e2b72d8f [file] [log] [blame]
Chia-I Wu15d86772015-02-21 14:00:17 +08001/*
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -06002 * Vulkan
Chia-I Wu15d86772015-02-21 14:00:17 +08003 *
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
35extern "C" {
36#endif
37
38struct icd_instance_logger {
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060039 VK_DBG_MSG_CALLBACK_FUNCTION func;
Chia-I Wu15d86772015-02-21 14:00:17 +080040 void *user_data;
41
42 struct icd_instance_logger *next;
43};
44
45struct icd_instance {
46 char *name;
47
48 bool debug_echo_enable;
49 bool break_on_error;
50 bool break_on_warning;
51
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060052 VkAllocCallbacks alloc_cb;
Chia-I Wu15d86772015-02-21 14:00:17 +080053
54 struct icd_instance_logger *loggers;
55};
56
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060057struct icd_instance *icd_instance_create(const VkApplicationInfo *app_info,
58 const VkAllocCallbacks *alloc_cb);
Chia-I Wu15d86772015-02-21 14:00:17 +080059void icd_instance_destroy(struct icd_instance *instance);
60
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060061VkResult icd_instance_set_bool(struct icd_instance *instance,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060062 VK_DBG_GLOBAL_OPTION option, bool yes);
Chia-I Wu15d86772015-02-21 14:00:17 +080063
64static inline void *icd_instance_alloc(const struct icd_instance *instance,
65 size_t size, size_t alignment,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060066 VkSystemAllocType type)
Chia-I Wu15d86772015-02-21 14:00:17 +080067{
68 return instance->alloc_cb.pfnAlloc(instance->alloc_cb.pUserData,
69 size, alignment, type);
70}
71
72static 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 Goeltzenleuchter382489d2015-04-10 08:34:15 -060078VkResult icd_instance_add_logger(struct icd_instance *instance,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060079 VK_DBG_MSG_CALLBACK_FUNCTION func,
Chia-I Wu15d86772015-02-21 14:00:17 +080080 void *user_data);
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060081VkResult icd_instance_remove_logger(struct icd_instance *instance,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060082 VK_DBG_MSG_CALLBACK_FUNCTION func);
Chia-I Wu15d86772015-02-21 14:00:17 +080083
84void icd_instance_log(const struct icd_instance *instance,
Courtney Goeltzenleuchter9cc421e2015-04-08 15:36:08 -060085 VK_DBG_MSG_TYPE msg_type,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060086 VkValidationLevel validation_level,
87 VkBaseObject src_object,
Chia-I Wu15d86772015-02-21 14:00:17 +080088 size_t location, int32_t msg_code,
89 const char *msg);
90
91#ifdef __cplusplus
92}
93#endif
94
95#endif /* ICD_INSTANCE_H */