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<GLES/glext.h>
#include<GLES2/gl2.h> #include<GLES2/gl2.h>
#include<GLES2/gl2ext.h> #include<GLES2/gl2ext.h>
#include <OpenglCodecCommon/ErrorLog.h>
bool GLESvalidate::textureEnum(GLenum e,unsigned int maxTex) { 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); return e >= GL_TEXTURE0 && e <= (GL_TEXTURE0 + maxTex);
} }
@@ -14,7 +16,7 @@ bool GLESvalidate::pixelType(GLEScontext * ctx, GLenum type) {
(type == GL_UNSIGNED_INT_24_8_OES) ) (type == GL_UNSIGNED_INT_24_8_OES) )
return true; return true;
if (ctx && if (ctx &&
(ctx->getCaps()->GL_ARB_HALF_FLOAT_PIXEL || ctx->getCaps()->GL_NV_HALF_FLOAT) && (ctx->getCaps()->GL_ARB_HALF_FLOAT_PIXEL || ctx->getCaps()->GL_NV_HALF_FLOAT) &&
(type == GL_HALF_FLOAT_OES)) (type == GL_HALF_FLOAT_OES))
return true; return true;
@@ -27,6 +29,7 @@ bool GLESvalidate::pixelType(GLEScontext * ctx, GLenum type) {
case GL_FLOAT: case GL_FLOAT:
return true; return true;
} }
ERR("Error: GLESvalidate::pixelType 0x%X\n", type);
return false; return false;
} }
@@ -54,6 +57,7 @@ bool GLESvalidate::pixelFrmt(GLEScontext* ctx ,GLenum format) {
case GL_LUMINANCE_ALPHA: case GL_LUMINANCE_ALPHA:
return true; return true;
} }
ERR("Error: GLESvalidate::pixelFrmt 0x%X\n", format);
return false; return false;
} }
@@ -80,8 +84,8 @@ bool GLESvalidate::drawMode(GLenum mode) {
} }
bool GLESvalidate::drawType(GLenum mode) { bool GLESvalidate::drawType(GLenum mode) {
return mode == GL_UNSIGNED_BYTE || return mode == GL_UNSIGNED_BYTE ||
mode == GL_UNSIGNED_SHORT || mode == GL_UNSIGNED_SHORT ||
mode == GL_UNSIGNED_INT; mode == GL_UNSIGNED_INT;
} }
@@ -103,7 +107,8 @@ bool GLESvalidate::textureTargetEx(GLenum target) {
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES: case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES:
case GL_TEXTURE_2D: case GL_TEXTURE_2D:
return true; return true;
} }
ERR("GLESvalidate::textureTargetEx 0x%X\n", target);
return false; return false;
} }

View File

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

View File

@@ -71,7 +71,7 @@ int RenderThread::Main()
long long dt = GetCurrentTimeMS() - stats_t0; long long dt = GetCurrentTimeMS() - stats_t0;
if (dt > 1000) { if (dt > 1000) {
float dts = (float)dt / 1000.0f; 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_totalBytes = 0;
stats_t0 = GetCurrentTimeMS(); stats_t0 = GetCurrentTimeMS();
} }

View File

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

View File

@@ -92,8 +92,12 @@ int main(int argc, char *argv[])
printUsage(argv[0]); 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(); getchar();
#else
fprintf(stderr, "renderer pid %d \n", getpid());
#endif
#ifdef _WIN32 #ifdef _WIN32
WSADATA wsaData; WSADATA wsaData;

View File

@@ -595,6 +595,9 @@ int ApiGen::genDecoderImpl(const std::string &filename)
\tif (len < 8) return pos; \n\ \tif (len < 8) return pos; \n\
\tunsigned char *ptr = (unsigned char *)buf;\n\ \tunsigned char *ptr = (unsigned char *)buf;\n\
\tbool unknownOpcode = false; \n\ \tbool unknownOpcode = false; \n\
#ifdef CHECK_GL_ERROR \n\
\tchar lastCall[256] = {0}; \n\
#endif \n\
\twhile ((len - pos >= 8) && !unknownOpcode) { \n\ \twhile ((len - pos >= 8) && !unknownOpcode) { \n\
\t\tvoid *params[%u]; \n\ \t\tvoid *params[%u]; \n\
\t\tint opcode = *(int *)ptr; \n\ \t\tint opcode = *(int *)ptr; \n\
@@ -747,6 +750,9 @@ int ApiGen::genDecoderImpl(const std::string &filename)
} // pass; } // pass;
fprintf(fp, "\t\t\t}\n"); 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"); fprintf(fp, "\t\t\tbreak;\n");
delete [] tmpBufOffset; delete [] tmpBufOffset;
@@ -754,6 +760,12 @@ int ApiGen::genDecoderImpl(const std::string &filename)
fprintf(fp, "\t\t\tdefault:\n"); fprintf(fp, "\t\t\tdefault:\n");
fprintf(fp, "\t\t\t\tunknownOpcode = true;\n"); fprintf(fp, "\t\t\t\tunknownOpcode = true;\n");
fprintf(fp, "\t\t} //switch\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, "\t} // while\n");
fprintf(fp, "\treturn pos;\n"); fprintf(fp, "\treturn pos;\n");
fprintf(fp, "}\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__