diff --git a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp index 2b487e923..a734858eb 100644 --- a/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp +++ b/tools/emulator/opengl/host/libs/Translator/GLcommon/GLESvalidate.cpp @@ -3,9 +3,11 @@ #include #include #include +#include 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; } diff --git a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h index 08b1a0738..1485f7506 100644 --- a/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h +++ b/tools/emulator/opengl/host/libs/Translator/include/GLcommon/GLESmacros.h @@ -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; \ } diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp index 5725cde1f..af2363ffd 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp +++ b/tools/emulator/opengl/host/libs/libOpenglRender/RenderThread.cpp @@ -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(); } diff --git a/tools/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp b/tools/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp index 0b12604be..8bf7ab2cd 100644 --- a/tools/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp +++ b/tools/emulator/opengl/host/libs/libOpenglRender/WindowSurface.cpp @@ -22,6 +22,7 @@ #include "GL2Dispatch.h" #include #include +#include "GLErrorLog.h" WindowSurface::WindowSurface() : m_fbObj(0), diff --git a/tools/emulator/opengl/host/renderer/main.cpp b/tools/emulator/opengl/host/renderer/main.cpp index 128f96df3..5f338b48e 100644 --- a/tools/emulator/opengl/host/renderer/main.cpp +++ b/tools/emulator/opengl/host/renderer/main.cpp @@ -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; diff --git a/tools/emulator/opengl/host/tools/emugen/ApiGen.cpp b/tools/emulator/opengl/host/tools/emugen/ApiGen.cpp index 9dfa0e292..9818e5db4 100644 --- a/tools/emulator/opengl/host/tools/emugen/ApiGen.cpp +++ b/tools/emulator/opengl/host/tools/emugen/ApiGen.cpp @@ -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"); diff --git a/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h b/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h new file mode 100644 index 000000000..3f30b2299 --- /dev/null +++ b/tools/emulator/opengl/shared/OpenglCodecCommon/GLErrorLog.h @@ -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__