blob: 400c642d3819261aab30a5163a6b3fcaeee9e412 [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 Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060039 PFN_vkDbgMsgCallback func;
Chia-I Wu15d86772015-02-21 14:00:17 +080040 void *user_data;
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060041 VkFlags flags;
Chia-I Wu15d86772015-02-21 14:00:17 +080042
43 struct icd_instance_logger *next;
44};
45
46struct icd_instance {
47 char *name;
48
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060049 VkAllocCallbacks alloc_cb;
Chia-I Wu15d86772015-02-21 14:00:17 +080050
51 struct icd_instance_logger *loggers;
52};
53
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060054struct icd_instance *icd_instance_create(const VkApplicationInfo *app_info,
55 const VkAllocCallbacks *alloc_cb);
Chia-I Wu15d86772015-02-21 14:00:17 +080056void icd_instance_destroy(struct icd_instance *instance);
57
Chia-I Wu15d86772015-02-21 14:00:17 +080058static inline void *icd_instance_alloc(const struct icd_instance *instance,
59 size_t size, size_t alignment,
Courtney Goeltzenleuchter382489d2015-04-10 08:34:15 -060060 VkSystemAllocType type)
Chia-I Wu15d86772015-02-21 14:00:17 +080061{
62 return instance->alloc_cb.pfnAlloc(instance->alloc_cb.pUserData,
63 size, alignment, type);
64}
65
66static 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 Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060072VkResult 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
78VkResult icd_instance_destroy_logger(
79 struct icd_instance *instance,
80 const VkDbgMsgCallback msg_obj);
Chia-I Wu15d86772015-02-21 14:00:17 +080081
82void icd_instance_log(const struct icd_instance *instance,
Courtney Goeltzenleuchter1c7c65d2015-06-10 17:39:03 -060083 VkFlags msg_flags,
Tony Barbourde4124d2015-07-03 10:33:54 -060084 VkDbgObjectType obj_type,
85 uint64_t src_object,
Chia-I Wu15d86772015-02-21 14:00:17 +080086 size_t location, int32_t msg_code,
87 const char *msg);
88
89#ifdef __cplusplus
90}
91#endif
92
93#endif /* ICD_INSTANCE_H */