Merge "opengles renderer: added CHECK_GL_ERROR defie for gl debugging"
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -14,7 +16,7 @@ bool GLESvalidate::pixelType(GLEScontext * ctx, GLenum type) {
|
||||
(type == GL_UNSIGNED_INT_24_8_OES) )
|
||||
return true;
|
||||
|
||||
if (ctx &&
|
||||
if (ctx &&
|
||||
(ctx->getCaps()->GL_ARB_HALF_FLOAT_PIXEL || ctx->getCaps()->GL_NV_HALF_FLOAT) &&
|
||||
(type == GL_HALF_FLOAT_OES))
|
||||
return true;
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -80,8 +84,8 @@ bool GLESvalidate::drawMode(GLenum mode) {
|
||||
}
|
||||
|
||||
bool GLESvalidate::drawType(GLenum mode) {
|
||||
return mode == GL_UNSIGNED_BYTE ||
|
||||
mode == GL_UNSIGNED_SHORT ||
|
||||
return mode == GL_UNSIGNED_BYTE ||
|
||||
mode == GL_UNSIGNED_SHORT ||
|
||||
mode == GL_UNSIGNED_INT;
|
||||
}
|
||||
|
||||
@@ -103,7 +107,8 @@ bool GLESvalidate::textureTargetEx(GLenum target) {
|
||||
case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_OES:
|
||||
case GL_TEXTURE_2D:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
ERR("GLESvalidate::textureTargetEx 0x%X\n", target);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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; \
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "GL2Dispatch.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "GLErrorLog.h"
|
||||
|
||||
WindowSurface::WindowSurface() :
|
||||
m_fbObj(0),
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
18
tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h
Normal file
18
tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h
Normal 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__
|
||||
Reference in New Issue
Block a user