aboutsummaryrefslogtreecommitdiffstats
path: root/emulator/opengl/host
diff options
context:
space:
mode:
authorKen Mixter <kmixter@google.com>2013-12-06 15:43:45 -0800
committerDavid 'Digit' Turner <digit@google.com>2014-05-21 11:54:11 +0200
commita2520d787431c9b48cf30091187f429f5ff4ecaa (patch)
treef3e28daf24ee49a4960f10ce46a3b18006e269ad /emulator/opengl/host
parentb22dbfb00380ef5b4dfd5b9ca72c4b408878ae87 (diff)
downloadsdk-a2520d787431c9b48cf30091187f429f5ff4ecaa.zip
sdk-a2520d787431c9b48cf30091187f429f5ff4ecaa.tar.gz
sdk-a2520d787431c9b48cf30091187f429f5ff4ecaa.tar.bz2
emulator/opengl: A few debugging, stability improvements to emugl
* Zero output parameters so that errors don't return random data (even if the target code was careful to zero its output parameters.) Spec says that we will not modify values in case of an error, which is not currently possible, but at least this means we return deterministic values. * Similarly, avoid passing uninitialized data if an error occurs during getting the viewport. * Fix a bug where glGetError may be called when NULL is decoded in CHECK_GL_ERROR mode. * Output more information about the stream in DEBUG_PRINTOUT mode to help separate from multiple streams. Change-Id: I31706b92642efe4c7ed38d178b49e72835a9c9a6
Diffstat (limited to 'emulator/opengl/host')
-rw-r--r--emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp2
-rw-r--r--emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp2
-rw-r--r--emulator/opengl/host/tools/emugen/ApiGen.cpp8
3 files changed, 8 insertions, 4 deletions
diff --git a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
index 3443f59..dd74750 100644
--- a/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
+++ b/emulator/opengl/host/libs/Translator/GLES_CM/GLEScmImp.cpp
@@ -2227,7 +2227,7 @@ void glDrawTexOES (T x, T y, T z, T width, T height) {
int numClipPlanes;
- GLint viewport[4];
+ GLint viewport[4] = {};
z = (z>1 ? 1 : (z<0 ? 0 : z));
T vertices[4*3] = {
diff --git a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
index f4280e1..532ffe7 100644
--- a/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
+++ b/emulator/opengl/host/libs/libOpenglRender/ColorBuffer.cpp
@@ -204,7 +204,7 @@ bool ColorBuffer::blitFromCurrentReadBuffer()
// save current viewport and match it to the current
// colorbuffer size
//
- GLint vport[4];
+ GLint vport[4] = {};
s_gl.glGetIntegerv(GL_VIEWPORT, vport);
s_gl.glViewport(0, 0, m_width, m_height);
diff --git a/emulator/opengl/host/tools/emugen/ApiGen.cpp b/emulator/opengl/host/tools/emugen/ApiGen.cpp
index 6d6742d..2e4c8d1 100644
--- a/emulator/opengl/host/tools/emugen/ApiGen.cpp
+++ b/emulator/opengl/host/tools/emugen/ApiGen.cpp
@@ -821,7 +821,8 @@ int ApiGen::genDecoderImpl(const std::string &filename)
}
} else if (pass == PASS_DebugPrint) {
fprintf(fp, "#ifdef DEBUG_PRINTOUT\n");
- fprintf(fp, "\t\t\tfprintf(stderr,\"%s: %s(%s)\\n\"", m_basename.c_str(), e->name().c_str(), printString.c_str());
+ fprintf(fp, "\t\t\tfprintf(stderr,\"%s(%%p): %s(%s)\\n\", stream",
+ m_basename.c_str(), e->name().c_str(), printString.c_str());
if (e->vars().size() > 0 && !e->vars()[0].isVoid()) fprintf(fp, ",");
}
@@ -878,6 +879,9 @@ int ApiGen::genDecoderImpl(const std::string &filename)
} else if (pass == PASS_MemAlloc) {
fprintf(fp, "\t\t\tunsigned char *tmpPtr%u = &tmpBuf[%s];\n",
(unsigned)j, tmpBufOffset[j].c_str());
+ fprintf(fp, "\t\t\tmemset(tmpPtr%u, 0, %s);\n",
+ (unsigned)j,
+ toString(v->type()->bytes()).c_str());
} else if (pass == PASS_FunctionCall) {
if (v->nullAllowed()) {
fprintf(fp, "tmpPtr%uSize == 0 ? NULL : (%s)(tmpPtr%u)",
@@ -937,7 +941,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
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, "\tint err = lastCall[0] ? this->glGetError() : GL_NO_ERROR;\n");
fprintf(fp, "\tif (err) fprintf(stderr, \"%s Error: 0x%%X in %%s\\n\", err, lastCall);\n", m_basename.c_str());
fprintf(fp, "#endif\n");
}