1 /**************************************************************************
3 * Copyright 2013-2014 RAD Game Tools and Valve Software
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
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 THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 **************************************************************************/
26 // File: vogl_ctypes.h
30 //----------------------------------------------------------------------------------------------------------------------
32 //----------------------------------------------------------------------------------------------------------------------
33 typedef void (*vogl_void_func_ptr_t)(void);
36 struct gl_ctype_sizeof
44 struct gl_ctype_sizeof<void>
52 struct gl_ctype_sizeof<_XDisplay>
60 struct gl_ctype_sizeof<_cl_context>
68 struct gl_ctype_sizeof<_cl_event>
76 // vogl_trace_ptr_value is large enough to hold any trace pointer, or any trace GLintptr, GLsizeiptr, or ptrdiff_t
77 typedef uint64_t vogl_trace_ptr_value;
79 //----------------------------------------------------------------------------------------------------------------------
81 //----------------------------------------------------------------------------------------------------------------------
85 #define DEF_TYPE(name, ctype) name,
86 #include "gl_glx_ctypes.inc"
91 //----------------------------------------------------------------------------------------------------------------------
93 //----------------------------------------------------------------------------------------------------------------------
94 struct vogl_ctype_desc_t
97 vogl_ctype_t m_pointee_ctype; // will be VOGL_VOID if not valid
100 int m_size; // will be 0 for void, -1 for opaque types, note this is the size of the ctype in the current process!
102 uint m_loki_type_flags; // see loki::TypeTraits::typeFlags
105 bool m_is_opaque_pointer; // true if the pointer points to an opaque type of unknown/undefind size
106 bool m_is_pointer_diff; // true if the size of this ctype varies depending on 32/64-bit compilation (intptr_t, or ptrdiff_t)
107 bool m_is_opaque_type; // true if the data type is opaque (not well defined or useful to tracing/replaying, probably varies in size in 32-bit vs 64-bit)
110 //----------------------------------------------------------------------------------------------------------------------
112 //----------------------------------------------------------------------------------------------------------------------
116 vogl_ctypes(); // purposely do nothing here, because this object is initialized before global construction time
117 vogl_ctypes(uint trace_ptr_size)
119 init(trace_ptr_size);
123 void init(uint trace_ptr_size);
125 inline uint get_pointer_size() const
127 return m_pointer_size;
130 void change_pointer_sizes(uint trace_ptr_size);
132 inline const vogl_ctype_desc_t &operator[](vogl_ctype_t ctype) const
134 VOGL_ASSERT(ctype < VOGL_NUM_CTYPES);
135 return m_vogl_ctype_descs[ctype];
137 inline vogl_ctype_desc_t &operator[](vogl_ctype_t ctype)
139 VOGL_ASSERT(ctype < VOGL_NUM_CTYPES);
140 return m_vogl_ctype_descs[ctype];
143 inline const vogl_ctype_desc_t &get_desc(vogl_ctype_t ctype) const
145 return (*this)[ctype];
147 inline vogl_ctype_desc_t &get_desc(vogl_ctype_t ctype)
149 return (*this)[ctype];
152 // Returns VOGL_VOID if not valid
153 inline vogl_ctype_t get_pointee_ctype(vogl_ctype_t ctype) const
155 return (*this)[ctype].m_pointee_ctype;
158 inline const char *get_name(vogl_ctype_t ctype) const
160 return (*this)[ctype].m_pName;
162 inline const char *get_ctype_name(vogl_ctype_t ctype) const
164 return (*this)[ctype].m_pCType;
166 inline int get_size(vogl_ctype_t ctype) const
168 return (*this)[ctype].m_size;
170 inline uint get_loki_type_flags(vogl_ctype_t ctype) const
172 return (*this)[ctype].m_loki_type_flags;
174 inline bool is_pointer(vogl_ctype_t ctype) const
176 return (*this)[ctype].m_is_pointer;
178 inline bool is_opaque_pointer(vogl_ctype_t ctype) const
180 return (*this)[ctype].m_is_opaque_pointer;
183 vogl_ctypes &operator=(const vogl_ctypes &other);
186 vogl_ctype_desc_t m_vogl_ctype_descs[VOGL_NUM_CTYPES];
190 extern vogl_ctypes g_vogl_process_gl_ctypes;
192 //----------------------------------------------------------------------------------------------------------------------
194 //----------------------------------------------------------------------------------------------------------------------
195 void vogl_dump_gl_ctypes();
196 void vogl_init_gl_ctypes();
198 #endif // VOGL_CTYPES_H