2010-10-26 22:21:24 +00:00
|
|
|
/*
|
|
|
|
** Copyright 2010, The Android Open Source Project
|
|
|
|
**
|
|
|
|
** Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
** you may not use this file except in compliance with the License.
|
|
|
|
** You may obtain a copy of the License at
|
|
|
|
**
|
|
|
|
** http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
**
|
|
|
|
** Unless required by applicable law or agreed to in writing, software
|
|
|
|
** distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
** See the License for the specific language governing permissions and
|
|
|
|
** limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#if EGL_TRACE
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include <EGL/egl.h>
|
|
|
|
#include <EGL/eglext.h>
|
|
|
|
|
|
|
|
#include <cutils/log.h>
|
|
|
|
|
2012-10-18 23:16:10 +00:00
|
|
|
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
|
|
|
|
#include <utils/Trace.h>
|
|
|
|
|
|
|
|
#include <utils/CallStack.h>
|
|
|
|
|
2011-05-24 00:26:14 +00:00
|
|
|
#include "egl_tls.h"
|
2010-10-26 22:21:24 +00:00
|
|
|
#include "hooks.h"
|
|
|
|
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
namespace android {
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
struct GLenumString {
|
2013-02-08 19:13:46 +00:00
|
|
|
// The GL_TIMEOUT_IGNORED "enum" doesn't fit in a GLenum, so use GLuint64
|
|
|
|
GLuint64 e;
|
2010-10-26 22:21:24 +00:00
|
|
|
const char* s;
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef GL_ENUM
|
|
|
|
#define GL_ENUM(VAL,NAME) {VAL, #NAME},
|
|
|
|
|
|
|
|
static GLenumString g_enumnames[] = {
|
|
|
|
#include "enums.in"
|
|
|
|
};
|
|
|
|
#undef GL_ENUM
|
|
|
|
|
|
|
|
static int compareGLEnum(const void* a, const void* b) {
|
|
|
|
return ((const GLenumString*) a)->e - ((const GLenumString*) b)->e;
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char* GLEnumToString(GLenum e) {
|
|
|
|
GLenumString key = {e, ""};
|
|
|
|
const GLenumString* result = (const GLenumString*) bsearch(
|
|
|
|
&key, g_enumnames,
|
|
|
|
sizeof(g_enumnames) / sizeof(g_enumnames[0]),
|
|
|
|
sizeof(g_enumnames[0]), compareGLEnum);
|
|
|
|
if (result) {
|
|
|
|
return result->s;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:34:11 +00:00
|
|
|
static const char* GLbooleanToString(GLboolean arg) {
|
|
|
|
return arg ? "GL_TRUE" : "GL_FALSE";
|
|
|
|
}
|
|
|
|
|
2010-10-26 22:21:24 +00:00
|
|
|
static GLenumString g_bitfieldNames[] = {
|
|
|
|
{0x00004000, "GL_COLOR_BUFFER_BIT"},
|
|
|
|
{0x00000400, "GL_STENCIL_BUFFER_BIT"},
|
|
|
|
{0x00000100, "GL_DEPTH_BUFFER_BIT"}
|
|
|
|
};
|
|
|
|
|
2010-10-27 22:34:11 +00:00
|
|
|
class StringBuilder {
|
|
|
|
static const int lineSize = 500;
|
|
|
|
char line[lineSize];
|
|
|
|
int line_index;
|
|
|
|
public:
|
|
|
|
StringBuilder() {
|
|
|
|
line_index = 0;
|
|
|
|
line[0] = '\0';
|
|
|
|
}
|
|
|
|
void append(const char* fmt, ...) {
|
|
|
|
va_list argp;
|
|
|
|
va_start(argp, fmt);
|
|
|
|
line_index += vsnprintf(line + line_index, lineSize-line_index, fmt, argp);
|
|
|
|
va_end(argp);
|
|
|
|
}
|
|
|
|
const char* getString() {
|
|
|
|
line_index = 0;
|
|
|
|
line[lineSize-1] = '\0';
|
|
|
|
return line;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2010-10-26 22:21:24 +00:00
|
|
|
|
|
|
|
static void TraceGLShaderSource(GLuint shader, GLsizei count,
|
|
|
|
const GLchar** string, const GLint* length) {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("const char* shaderSrc[] = {");
|
2010-10-26 22:21:24 +00:00
|
|
|
for (GLsizei i = 0; i < count; i++) {
|
|
|
|
const char* comma = i < count-1 ? "," : "";
|
|
|
|
const GLchar* s = string[i];
|
|
|
|
if (length) {
|
|
|
|
GLint len = length[i];
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD(" \"%*s\"%s", len, s, comma);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD(" \"%s\"%s", s, comma);
|
2010-10-26 22:21:24 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("};");
|
2010-10-26 22:21:24 +00:00
|
|
|
if (length) {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("const GLint* shaderLength[] = {");
|
2010-10-26 22:21:24 +00:00
|
|
|
for (GLsizei i = 0; i < count; i++) {
|
|
|
|
const char* comma = i < count-1 ? "," : "";
|
|
|
|
GLint len = length[i];
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD(" \"%d\"%s", len, comma);
|
2010-10-26 22:21:24 +00:00
|
|
|
}
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("};");
|
|
|
|
ALOGD("glShaderSource(%u, %u, shaderSrc, shaderLength);",
|
2010-10-26 22:21:24 +00:00
|
|
|
shader, count);
|
|
|
|
} else {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("glShaderSource(%u, %u, shaderSrc, (const GLint*) 0);",
|
2010-10-26 22:21:24 +00:00
|
|
|
shader, count);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-10-27 22:34:11 +00:00
|
|
|
static void TraceValue(int elementCount, char type,
|
|
|
|
GLsizei chunkCount, GLsizei chunkSize, const void* value) {
|
|
|
|
StringBuilder stringBuilder;
|
|
|
|
GLsizei count = chunkCount * chunkSize;
|
|
|
|
bool isFloat = type == 'f';
|
|
|
|
const char* typeString = isFloat ? "GLfloat" : "GLint";
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("const %s value[] = {", typeString);
|
2010-10-27 22:34:11 +00:00
|
|
|
for (GLsizei i = 0; i < count; i++) {
|
|
|
|
StringBuilder builder;
|
|
|
|
builder.append(" ");
|
|
|
|
for (int e = 0; e < elementCount; e++) {
|
|
|
|
const char* comma = ", ";
|
|
|
|
if (e == elementCount-1) {
|
|
|
|
if (i == count - 1) {
|
|
|
|
comma = "";
|
|
|
|
} else {
|
|
|
|
comma = ",";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (isFloat) {
|
|
|
|
builder.append("%g%s", * (GLfloat*) value, comma);
|
|
|
|
value = (void*) (((GLfloat*) value) + 1);
|
|
|
|
} else {
|
|
|
|
builder.append("%d%s", * (GLint*) value, comma);
|
|
|
|
value = (void*) (((GLint*) value) + 1);
|
|
|
|
}
|
|
|
|
}
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s", builder.getString());
|
2010-10-27 22:34:11 +00:00
|
|
|
if (chunkSize > 1 && i < count-1
|
|
|
|
&& (i % chunkSize) == (chunkSize-1)) {
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s", ""); // Print a blank line.
|
2010-10-27 22:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("};");
|
2010-10-27 22:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TraceUniformv(int elementCount, char type,
|
|
|
|
GLuint location, GLsizei count, const void* value) {
|
|
|
|
TraceValue(elementCount, type, count, 1, value);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("glUniform%d%c(%u, %u, value);", elementCount, type, location, count);
|
2010-10-27 22:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static void TraceUniformMatrix(int matrixSideLength,
|
|
|
|
GLuint location, GLsizei count, GLboolean transpose, const void* value) {
|
|
|
|
TraceValue(matrixSideLength, 'f', count, matrixSideLength, value);
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("glUniformMatrix%dfv(%u, %u, %s, value);", matrixSideLength, location, count,
|
2010-10-27 22:34:11 +00:00
|
|
|
GLbooleanToString(transpose));
|
|
|
|
}
|
|
|
|
|
2010-10-26 22:21:24 +00:00
|
|
|
static void TraceGL(const char* name, int numArgs, ...) {
|
|
|
|
va_list argp;
|
|
|
|
va_start(argp, numArgs);
|
2010-10-27 22:34:11 +00:00
|
|
|
int nameLen = strlen(name);
|
|
|
|
|
|
|
|
// glShaderSource
|
|
|
|
if (nameLen == 14 && strcmp(name, "glShaderSource") == 0) {
|
2010-10-26 22:21:24 +00:00
|
|
|
va_arg(argp, const char*);
|
|
|
|
GLuint shader = va_arg(argp, GLuint);
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
GLsizei count = va_arg(argp, GLsizei);
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
const GLchar** string = (const GLchar**) va_arg(argp, void*);
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
const GLint* length = (const GLint*) va_arg(argp, void*);
|
2010-10-27 22:34:11 +00:00
|
|
|
va_end(argp);
|
2010-10-26 22:21:24 +00:00
|
|
|
TraceGLShaderSource(shader, count, string, length);
|
2010-10-27 22:34:11 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// glUniformXXv
|
|
|
|
|
|
|
|
if (nameLen == 12 && strncmp(name, "glUniform", 9) == 0 && name[11] == 'v') {
|
|
|
|
int elementCount = name[9] - '0'; // 1..4
|
|
|
|
char type = name[10]; // 'f' or 'i'
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
GLuint location = va_arg(argp, GLuint);
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
GLsizei count = va_arg(argp, GLsizei);
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
const void* value = (const void*) va_arg(argp, void*);
|
2010-10-26 22:21:24 +00:00
|
|
|
va_end(argp);
|
2010-10-27 22:34:11 +00:00
|
|
|
TraceUniformv(elementCount, type, location, count, value);
|
2010-10-26 22:21:24 +00:00
|
|
|
return;
|
|
|
|
}
|
2010-10-27 22:34:11 +00:00
|
|
|
|
|
|
|
// glUniformMatrixXfv
|
|
|
|
|
|
|
|
if (nameLen == 18 && strncmp(name, "glUniformMatrix", 15) == 0
|
|
|
|
&& name[16] == 'f' && name[17] == 'v') {
|
|
|
|
int matrixSideLength = name[15] - '0'; // 2..4
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
GLuint location = va_arg(argp, GLuint);
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
GLsizei count = va_arg(argp, GLsizei);
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
GLboolean transpose = (GLboolean) va_arg(argp, int);
|
|
|
|
va_arg(argp, const char*);
|
|
|
|
const void* value = (const void*) va_arg(argp, void*);
|
|
|
|
va_end(argp);
|
|
|
|
TraceUniformMatrix(matrixSideLength, location, count, transpose, value);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder builder;
|
|
|
|
builder.append("%s(", name);
|
2010-10-26 22:21:24 +00:00
|
|
|
for (int i = 0; i < numArgs; i++) {
|
|
|
|
if (i > 0) {
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append(", ");
|
2010-10-26 22:21:24 +00:00
|
|
|
}
|
|
|
|
const char* type = va_arg(argp, const char*);
|
|
|
|
bool isPtr = type[strlen(type)-1] == '*'
|
|
|
|
|| strcmp(type, "GLeglImageOES") == 0;
|
|
|
|
if (isPtr) {
|
|
|
|
const void* arg = va_arg(argp, const void*);
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("(%s) 0x%08x", type, (size_t) arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else if (strcmp(type, "GLbitfield") == 0) {
|
|
|
|
size_t arg = va_arg(argp, size_t);
|
|
|
|
bool first = true;
|
|
|
|
for (size_t i = 0; i < sizeof(g_bitfieldNames) / sizeof(g_bitfieldNames[0]); i++) {
|
|
|
|
const GLenumString* b = &g_bitfieldNames[i];
|
|
|
|
if (b->e & arg) {
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
} else {
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append(" | ");
|
2010-10-26 22:21:24 +00:00
|
|
|
}
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%s", b->s);
|
2010-10-26 22:21:24 +00:00
|
|
|
arg &= ~b->e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (first || arg != 0) {
|
|
|
|
if (!first) {
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append(" | ");
|
2010-10-26 22:21:24 +00:00
|
|
|
}
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("0x%08x", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
}
|
|
|
|
} else if (strcmp(type, "GLboolean") == 0) {
|
2010-10-27 22:34:11 +00:00
|
|
|
GLboolean arg = va_arg(argp, int);
|
|
|
|
builder.append("%s", GLbooleanToString(arg));
|
2010-10-26 22:21:24 +00:00
|
|
|
} else if (strcmp(type, "GLclampf") == 0) {
|
|
|
|
double arg = va_arg(argp, double);
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%g", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else if (strcmp(type, "GLenum") == 0) {
|
|
|
|
GLenum arg = va_arg(argp, int);
|
|
|
|
const char* s = GLEnumToString(arg);
|
|
|
|
if (s) {
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%s", s);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else {
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("0x%x", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
}
|
|
|
|
} else if (strcmp(type, "GLfixed") == 0) {
|
|
|
|
int arg = va_arg(argp, int);
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("0x%08x", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else if (strcmp(type, "GLfloat") == 0) {
|
|
|
|
double arg = va_arg(argp, double);
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%g", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else if (strcmp(type, "GLint") == 0) {
|
|
|
|
int arg = va_arg(argp, int);
|
|
|
|
const char* s = NULL;
|
|
|
|
if (strcmp(name, "glTexParameteri") == 0) {
|
|
|
|
s = GLEnumToString(arg);
|
|
|
|
}
|
|
|
|
if (s) {
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%s", s);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else {
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%d", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
}
|
|
|
|
} else if (strcmp(type, "GLintptr") == 0) {
|
|
|
|
int arg = va_arg(argp, unsigned int);
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%u", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else if (strcmp(type, "GLsizei") == 0) {
|
|
|
|
int arg = va_arg(argp, size_t);
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%u", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else if (strcmp(type, "GLsizeiptr") == 0) {
|
|
|
|
int arg = va_arg(argp, size_t);
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%u", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else if (strcmp(type, "GLuint") == 0) {
|
|
|
|
int arg = va_arg(argp, unsigned int);
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("%u", arg);
|
2010-10-26 22:21:24 +00:00
|
|
|
} else {
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append("/* ??? %s */", type);
|
2010-10-26 22:21:24 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2010-10-27 22:34:11 +00:00
|
|
|
builder.append(");");
|
2011-12-20 16:23:08 +00:00
|
|
|
ALOGD("%s", builder.getString());
|
2010-10-26 22:21:24 +00:00
|
|
|
va_end(argp);
|
|
|
|
}
|
|
|
|
|
2012-10-18 23:16:10 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Log trace
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2010-10-26 22:21:24 +00:00
|
|
|
#undef TRACE_GL_VOID
|
|
|
|
#undef TRACE_GL
|
|
|
|
|
|
|
|
#define TRACE_GL_VOID(_api, _args, _argList, ...) \
|
|
|
|
static void Tracing_ ## _api _args { \
|
|
|
|
TraceGL(#_api, __VA_ARGS__); \
|
|
|
|
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
|
|
|
|
_c->_api _argList; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TRACE_GL(_type, _api, _args, _argList, ...) \
|
|
|
|
static _type Tracing_ ## _api _args { \
|
2011-03-02 00:08:10 +00:00
|
|
|
TraceGL(#_api, __VA_ARGS__); \
|
2010-10-26 22:21:24 +00:00
|
|
|
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
|
|
|
|
return _c->_api _argList; \
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "../trace.in"
|
|
|
|
}
|
2011-03-02 00:08:10 +00:00
|
|
|
|
2010-10-26 22:21:24 +00:00
|
|
|
#undef TRACE_GL_VOID
|
|
|
|
#undef TRACE_GL
|
|
|
|
|
|
|
|
#define GL_ENTRY(_r, _api, ...) Tracing_ ## _api,
|
|
|
|
EGLAPI gl_hooks_t gHooksTrace = {
|
|
|
|
{
|
|
|
|
#include "entries.in"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{0}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#undef GL_ENTRY
|
|
|
|
|
2011-03-02 00:08:10 +00:00
|
|
|
#undef TRACE_GL_VOID
|
|
|
|
#undef TRACE_GL
|
|
|
|
|
|
|
|
// define the ES 1.0 Debug_gl* functions as Tracing_gl functions
|
|
|
|
#define TRACE_GL_VOID(_api, _args, _argList, ...) \
|
|
|
|
static void Debug_ ## _api _args { \
|
|
|
|
TraceGL(#_api, __VA_ARGS__); \
|
|
|
|
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
|
|
|
|
_c->_api _argList; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TRACE_GL(_type, _api, _args, _argList, ...) \
|
|
|
|
static _type Debug_ ## _api _args { \
|
|
|
|
TraceGL(#_api, __VA_ARGS__); \
|
|
|
|
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
|
|
|
|
return _c->_api _argList; \
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "../debug.in"
|
|
|
|
}
|
|
|
|
|
2012-10-18 23:16:10 +00:00
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
// Systrace
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#undef TRACE_GL_VOID
|
|
|
|
#undef TRACE_GL
|
|
|
|
|
|
|
|
#define TRACE_GL_VOID(_api, _args, _argList, ...) \
|
|
|
|
static void Systrace_ ## _api _args { \
|
|
|
|
ATRACE_NAME(#_api); \
|
|
|
|
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
|
|
|
|
_c->_api _argList; \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TRACE_GL(_type, _api, _args, _argList, ...) \
|
|
|
|
static _type Systrace_ ## _api _args { \
|
|
|
|
ATRACE_NAME(#_api); \
|
|
|
|
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
|
|
|
|
return _c->_api _argList; \
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "../trace.in"
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef TRACE_GL_VOID
|
|
|
|
#undef TRACE_GL
|
|
|
|
|
|
|
|
#define GL_ENTRY(_r, _api, ...) Systrace_ ## _api,
|
|
|
|
EGLAPI gl_hooks_t gHooksSystrace = {
|
|
|
|
{
|
|
|
|
#include "entries.in"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{0}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#undef GL_ENTRY
|
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#undef TRACE_GL_VOID
|
|
|
|
#undef TRACE_GL
|
|
|
|
|
|
|
|
#define CHECK_ERROR(_c, _api) \
|
|
|
|
GLenum status = GL_NO_ERROR; \
|
|
|
|
bool error = false; \
|
|
|
|
while ((status = _c->glGetError()) != GL_NO_ERROR) { \
|
|
|
|
ALOGD("[" #_api "] 0x%x", status); \
|
|
|
|
error = true; \
|
|
|
|
} \
|
|
|
|
if (error) { \
|
|
|
|
CallStack s; \
|
|
|
|
s.update(); \
|
2013-10-26 00:13:57 +00:00
|
|
|
s.log("glGetError:" #_api); \
|
2012-10-18 23:16:10 +00:00
|
|
|
} \
|
|
|
|
|
|
|
|
#define TRACE_GL_VOID(_api, _args, _argList, ...) \
|
|
|
|
static void ErrorTrace_ ## _api _args { \
|
|
|
|
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
|
|
|
|
_c->_api _argList; \
|
|
|
|
CHECK_ERROR(_c, _api); \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define TRACE_GL(_type, _api, _args, _argList, ...) \
|
|
|
|
static _type ErrorTrace_ ## _api _args { \
|
|
|
|
gl_hooks_t::gl_t const * const _c = &getGLTraceThreadSpecific()->gl; \
|
|
|
|
_type _r = _c->_api _argList; \
|
|
|
|
CHECK_ERROR(_c, _api); \
|
|
|
|
return _r; \
|
|
|
|
}
|
|
|
|
|
|
|
|
extern "C" {
|
|
|
|
#include "../trace.in"
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef TRACE_GL_VOID
|
|
|
|
#undef TRACE_GL
|
|
|
|
|
|
|
|
#define GL_ENTRY(_r, _api, ...) ErrorTrace_ ## _api,
|
|
|
|
EGLAPI gl_hooks_t gHooksErrorTrace = {
|
|
|
|
{
|
|
|
|
#include "entries.in"
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{0}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
#undef GL_ENTRY
|
|
|
|
#undef CHECK_ERROR
|
|
|
|
|
2011-03-02 00:08:10 +00:00
|
|
|
#undef TRACE_GL_VOID
|
|
|
|
#undef TRACE_GL
|
|
|
|
|
2010-10-26 22:21:24 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
}; // namespace android
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
#endif // EGL_TRACE
|