Merge "opengles renderer: added CHECK_GL_ERROR defie for gl debugging"

This commit is contained in:
David Turner
2011-07-03 05:24:11 -07:00
committed by Android Code Review
7 changed files with 48 additions and 6 deletions

View File

@@ -3,9 +3,11 @@
#include<GLES/glext.h>
#include<GLES2/gl2.h>
#include<GLES2/gl2ext.h>
#include <OpenglCodecCommon/ErrorLog.h>
bool GLESvalidate::textureEnum(GLenum e,unsigned int maxTex) {
if (!((e >= GL_TEXTURE0) && (e <= (GL_TEXTURE0 + maxTex)))) ERR("GLESvalidate::textureEnum: e = 0x%X max %d\n", e, maxTex);
return e >= GL_TEXTURE0 && e <= (GL_TEXTURE0 + maxTex);
}
@@ -27,6 +29,7 @@ bool GLESvalidate::pixelType(GLEScontext * ctx, GLenum type) {
case GL_FLOAT:
return true;
}
ERR("Error: GLESvalidate::pixelType 0x%X\n", type);
return false;
}
@@ -54,6 +57,7 @@ bool GLESvalidate::pixelFrmt(GLEScontext* ctx ,GLenum format) {
case GL_LUMINANCE_ALPHA:
return true;
}
ERR("Error: GLESvalidate::pixelFrmt 0x%X\n", format);
return false;
}
@@ -104,6 +108,7 @@ bool GLESvalidate::textureTargetEx(GLenum target) {
case GL_TEXTURE_2D:
return true;
}
ERR("GLESvalidate::textureTargetEx 0x%X\n", target);
return false;
}

View File

@@ -48,12 +48,14 @@
#define SET_ERROR_IF(condition,err) if((condition)) { \
fprintf(stderr, "%s:%s:%d error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
ctx->setGLerror(err); \
return; \
}
#define RET_AND_SET_ERROR_IF(condition,err,ret) if((condition)) { \
fprintf(stderr, "%s:%s:%d error 0x%x\n", __FILE__, __FUNCTION__, __LINE__, err); \
ctx->setGLerror(err); \
return ret; \
}

View File

@@ -71,7 +71,7 @@ int RenderThread::Main()
long long dt = GetCurrentTimeMS() - stats_t0;
if (dt > 1000) {
float dts = (float)dt / 1000.0f;
printf("Used Bandwidth %5.3f MB/s\n", ((float)stats_totalBytes / dts) / (1024.0f*1024.0f));
//printf("Used Bandwidth %5.3f MB/s\n", ((float)stats_totalBytes / dts) / (1024.0f*1024.0f));
stats_totalBytes = 0;
stats_t0 = GetCurrentTimeMS();
}

View File

@@ -22,6 +22,7 @@
#include "GL2Dispatch.h"
#include <stdio.h>
#include <string.h>
#include "GLErrorLog.h"
WindowSurface::WindowSurface() :
m_fbObj(0),

View File

@@ -92,8 +92,12 @@ int main(int argc, char *argv[])
printUsage(argv[0]);
}
printf("renderer pid %d , press any key to continue...\n", getpid());
#if 0 //Enable to attach gdb to renderer on startup
fprintf(stderr, "renderer pid %d , press any key to continue...\n", getpid());
getchar();
#else
fprintf(stderr, "renderer pid %d \n", getpid());
#endif
#ifdef _WIN32
WSADATA wsaData;

View File

@@ -595,6 +595,9 @@ int ApiGen::genDecoderImpl(const std::string &filename)
\tif (len < 8) return pos; \n\
\tunsigned char *ptr = (unsigned char *)buf;\n\
\tbool unknownOpcode = false; \n\
#ifdef CHECK_GL_ERROR \n\
\tchar lastCall[256] = {0}; \n\
#endif \n\
\twhile ((len - pos >= 8) && !unknownOpcode) { \n\
\t\tvoid *params[%u]; \n\
\t\tint opcode = *(int *)ptr; \n\
@@ -747,6 +750,9 @@ int ApiGen::genDecoderImpl(const std::string &filename)
} // pass;
fprintf(fp, "\t\t\t}\n");
fprintf(fp, "#ifdef CHECK_GL_ERROR\n");
fprintf(fp, "\t\t\tsprintf(lastCall, \"%s\");\n", e->name().c_str());
fprintf(fp, "#endif\n");
fprintf(fp, "\t\t\tbreak;\n");
delete [] tmpBufOffset;
@@ -754,6 +760,12 @@ int ApiGen::genDecoderImpl(const std::string &filename)
fprintf(fp, "\t\t\tdefault:\n");
fprintf(fp, "\t\t\t\tunknownOpcode = true;\n");
fprintf(fp, "\t\t} //switch\n");
if (strstr(m_basename.c_str(), "gl")) {
fprintf(fp, "#ifdef CHECK_GL_ERROR\n");
fprintf(fp, "\tint err = this->glGetError();\n");
fprintf(fp, "\tif (err) printf(\"%s Error: 0x%%X in %%s\\n\", err, lastCall);\n", m_basename.c_str());
fprintf(fp, "#endif\n");
}
fprintf(fp, "\t} // while\n");
fprintf(fp, "\treturn pos;\n");
fprintf(fp, "}\n");

View File

@@ -0,0 +1,18 @@
#ifndef __GL_ERROR_LOG_H__
#define __GL_ERROR_LOG_H__
#include "ErrorLog.h"
#ifdef CHECK_GL_ERROR
void dbg(){}
#define GET_GL_ERROR(gl) \
{ \
int err = gl.glGetError(); \
if (err) { dbg(); ERR("Error: 0x%X in %s (%s:%d)\n", err, __FUNCTION__, __FILE__, __LINE__); } \
}
#else
#define GET_GL_ERROR(gl)
#endif
#endif //__GL_ERROR_LOG_H__