4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
8 * Sanghyun Lee <sanghyunnim.lee@samsung.com>
9 * Juyoung Kim <j0.kim@samsung.com>
10 * Vitaliy Cherepanov <v.cherepanov@samsung.com>
12 * This library is free software; you can redistribute it and/or modify it under
13 * the terms of the GNU Lesser General Public License as published by the
14 * Free Software Foundation; either version 2.1 of the License, or (at your option)
17 * This library is distributed in the hope that it will be useful, but WITHOUT ANY
18 * WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
20 * License for more details.
22 * You should have received a copy of the GNU Lesser General Public License
23 * along with this library; if not, write to the Free Software Foundation, Inc., 51
24 * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
42 #define NO_RETURN_FORMAT "%s"
43 #define NO_RETURN_VALUE 0
44 #define APITYPE_INIT 0
45 #define APITYPE_CONTEXT 1
46 #define APITYPE_NO_CONTEXT 2
48 char contextValue[256];
50 #define PACK_GL_ADD(GL_api_type, GL_elapsed_time, GL_context_value) \
52 BUF_PTR = pack_int32(BUF_PTR, (uint32_t)GL_api_type); \
53 BUF_PTR = pack_int64(BUF_PTR, (uint64_t)GL_elapsed_time); \
54 BUF_PTR = pack_string(BUF_PTR, GL_context_value); \
58 #define BEFORE(FUNCNAME) \
59 DECLARE_VARIABLE_STANDARD_NORET; \
60 GLenum error = GL_NO_ERROR; \
61 static methodType FUNCNAME ## p = 0; \
63 int32_t vAPI_ID = API_ID_ ## FUNCNAME; \
64 uint64_t start_nsec = get_current_nsec(); \
67 if (lib_handle[LIBGLES20] == ((void *) 0)) { \
68 lib_handle[LIBGLES20] = dlopen(lib_string[LIBGLES20], RTLD_LAZY); \
69 if (lib_handle[LIBGLES20] == ((void *) 0)) { \
70 char perror_msg[128]; \
71 sprintf(perror_msg, "dlopen failed : %s", \
72 lib_string[LIBGLES20]); \
76 probeInfo_t tempProbeInfo; \
77 setProbePoint(&tempProbeInfo); \
79 char maxValString[64]; \
81 glGetIntegerv(GL_MAX_VERTEX_ATTRIBS, &maxVal[0]); \
82 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &maxVal[1]); \
83 sprintf(maxValString, "%d,%d", maxVal[0], maxVal[1]); \
84 PREPARE_LOCAL_BUF(); \
85 PACK_COMMON_BEGIN(MSG_PROBE_GL, vAPI_ID, "", 0); \
86 PACK_COMMON_END(1, 0, 0); \
87 PACK_GL_ADD(APITYPE_INIT, 0, maxValString); \
91 tmpPtr = dlsym(lib_handle[LIBGLES20], #FUNCNAME); \
92 if (tmpPtr == NULL || dlerror() != NULL) { \
93 perror("dlsym failed : " #FUNCNAME); \
97 memcpy(&FUNCNAME##p, &tmpPtr, sizeof(tmpPtr)); \
102 #define BEFORE_EGL(FUNCNAME) \
103 DECLARE_VARIABLE_STANDARD_NORET; \
104 GLenum error = GL_NO_ERROR; \
105 static methodType FUNCNAME ## p = 0; \
107 int32_t vAPI_ID = API_ID_ ## FUNCNAME; \
108 uint64_t start_nsec = get_current_nsec(); \
111 if (lib_handle[LIBEGL] == ((void *) 0)) { \
112 lib_handle[LIBEGL] = dlopen(lib_string[LIBEGL], RTLD_LAZY | RTLD_GLOBAL); \
113 if (lib_handle[LIBEGL] == ((void *) 0)) { \
114 char perror_msg[128]; \
115 sprintf(perror_msg, "dlopen failed : %s", \
116 lib_string[LIBEGL]); \
117 perror(perror_msg); \
122 tmpPtr = dlsym(lib_handle[LIBEGL], #FUNCNAME); \
123 if (tmpPtr == NULL || dlerror() != NULL) { \
124 perror("dlsym failed : " #FUNCNAME); \
128 memcpy(&FUNCNAME##p, &tmpPtr, sizeof(tmpPtr)); \
133 #define BEFORE_OSP_UIFW(FUNCNAME) \
134 DECLARE_VARIABLE_STANDARD_NORET; \
135 GLenum error = GL_NO_ERROR; \
136 static methodType FUNCNAME ## p = 0; \
138 int32_t vAPI_ID = API_ID_ ## FUNCNAME; \
139 uint64_t start_nsec = get_current_nsec(); \
142 if (lib_handle[LIBOSP_UIFW] == ((void *) 0)) { \
143 lib_handle[LIBOSP_UIFW] = dlopen(lib_string[LIBOSP_UIFW], RTLD_LAZY); \
144 if (lib_handle[LIBOSP_UIFW] == ((void *) 0)) { \
145 char perror_msg[128]; \
146 sprintf(perror_msg, "dlopen failed : %s", \
147 lib_string[LIBOSP_UIFW]); \
148 perror(perror_msg); \
153 tmpPtr = dlsym(lib_handle[LIBOSP_UIFW], #FUNCNAME); \
154 if (tmpPtr == NULL || dlerror() != NULL) { \
155 perror("dlsym failed : " #FUNCNAME); \
159 memcpy(&FUNCNAME##p, &tmpPtr, sizeof(tmpPtr)); \
164 #define AFTER(RET_VAL, APITYPE, CONTEXT_VAL, INPUTFORMAT, ...) \
165 POST_PACK_PROBEBLOCK_BEGIN(); \
166 PREPARE_LOCAL_BUF(); \
167 PACK_COMMON_BEGIN(MSG_PROBE_GL, vAPI_ID, INPUTFORMAT, __VA_ARGS__);\
168 PACK_COMMON_END(RET_VAL, error, blockresult); \
169 PACK_GL_ADD(APITYPE, get_current_nsec() - start_nsec, CONTEXT_VAL); \
171 POST_PACK_PROBEBLOCK_END()
173 #define AFTER_NO_PARAM(RETVAL, APITYPE, CONTEXTVALUE) \
174 AFTER(RETVAL, APITYPE, CONTEXTVALUE, "", 0)
176 #endif /* DA_GLES20_H_ */