blob: 43f3179cd4cfc51a448e9e62ce17e95b5c16bc20 [file] [log] [blame]
Chia-I Wu15d86772015-02-21 14:00:17 +08001/*
2 * XGL
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
35extern "C" {
36#endif
37
38struct icd_instance_logger {
39 XGL_DBG_MSG_CALLBACK_FUNCTION func;
40 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
52 XGL_ALLOC_CALLBACKS alloc_cb;
53
54 struct icd_instance_logger *loggers;
55};
56
57struct icd_instance *icd_instance_create(const XGL_APPLICATION_INFO *app_info,
58 const XGL_ALLOC_CALLBACKS *alloc_cb);
59void icd_instance_destroy(struct icd_instance *instance);
60
61XGL_RESULT icd_instance_set_bool(struct icd_instance *instance,
62 XGL_DBG_GLOBAL_OPTION option, bool yes);
63
64static inline void *icd_instance_alloc(const struct icd_instance *instance,
65 size_t size, size_t alignment,
66 XGL_SYSTEM_ALLOC_TYPE type)
67{
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
78XGL_RESULT icd_instance_add_logger(struct icd_instance *instance,
79 XGL_DBG_MSG_CALLBACK_FUNCTION func,
80 void *user_data);
81XGL_RESULT icd_instance_remove_logger(struct icd_instance *instance,
82 XGL_DBG_MSG_CALLBACK_FUNCTION func);
83
84void icd_instance_log(const struct icd_instance *instance,
85 XGL_DBG_MSG_TYPE msg_type,
86 XGL_VALIDATION_LEVEL validation_level,
87 XGL_BASE_OBJECT src_object,
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 */