summaryrefslogtreecommitdiffstats
path: root/o3d
diff options
context:
space:
mode:
authortschmelcher@chromium.org <tschmelcher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 00:12:33 +0000
committertschmelcher@chromium.org <tschmelcher@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 00:12:33 +0000
commit4f2fe461d79175b39787686b76d36b7518e132fd (patch)
treec4fcf2c211c23eb89c8cd4509a62fe6dd4071af5 /o3d
parentc8407807eaf80b28aeacfa4dd07bdc26d2f2bf38 (diff)
downloadchromium_src-4f2fe461d79175b39787686b76d36b7518e132fd.zip
chromium_src-4f2fe461d79175b39787686b76d36b7518e132fd.tar.gz
chromium_src-4f2fe461d79175b39787686b76d36b7518e132fd.tar.bz2
Flush GL errors before any operation that checks for GL errors afterwards, so as to prevent operations from spuriously failing due to previous unrelated errors. Fixes a bug on Linux T400s with AMD graphics where we "failed" to create the error texture because of a previous non-fatal error that hadn't been reaped.
TEST=ran a debug build on a Linux T400 with AMD graphics BUG=none Review URL: http://codereview.chromium.org/1912001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'o3d')
-rw-r--r--o3d/core/cross/gl/effect_gl.cc4
-rw-r--r--o3d/core/cross/gl/texture_gl.cc2
-rw-r--r--o3d/core/cross/gl/utils_gl-inl.h14
-rw-r--r--o3d/core/cross/glcommon/utils_glcommon-inl.h64
-rw-r--r--o3d/core/cross/gles2/texture_gles2.cc2
-rw-r--r--o3d/core/cross/gles2/utils_gles2-inl.h11
6 files changed, 71 insertions, 26 deletions
diff --git a/o3d/core/cross/gl/effect_gl.cc b/o3d/core/cross/gl/effect_gl.cc
index b8eabcc..71ce602 100644
--- a/o3d/core/cross/gl/effect_gl.cc
+++ b/o3d/core/cross/gl/effect_gl.cc
@@ -257,12 +257,10 @@ bool EffectGL::LoadFromFXString(const String& effect) {
DLOG(WARNING) << "Effect post-rewrite compile warnings: " << listing;
}
- CHECK_GL_ERROR();
-
// If the program rewrite introduced some syntax or semantic errors, we won't
// know it until we load the program (through a GL error).
// So flush all GL errors first...
- do {} while (glGetError() != GL_NO_ERROR);
+ FlushGlErrors();
// ... Then load the program ...
cgGLLoadProgram(cg_vertex_);
diff --git a/o3d/core/cross/gl/texture_gl.cc b/o3d/core/cross/gl/texture_gl.cc
index f9a11e0..814e7b3 100644
--- a/o3d/core/cross/gl/texture_gl.cc
+++ b/o3d/core/cross/gl/texture_gl.cc
@@ -180,6 +180,7 @@ static bool UpdateGLImageFromBitmap(GLenum target,
GLenum gl_data_type = 0;
GLenum gl_format = GLFormatFromO3DFormat(bitmap.format(), &gl_internal_format,
&gl_data_type);
+ FlushGlErrors();
if (gl_format) {
glTexSubImage2D(target, level, 0, 0, mip_width, mip_height,
gl_format, gl_data_type, mip_data);
@@ -218,6 +219,7 @@ static bool CreateGLImages(GLenum target,
memset(temp_data.get(), 0, size);
for (int i = 0; i < levels; ++i) {
+ FlushGlErrors();
if (gl_format) {
glTexImage2D(target, i, internal_format, mip_width, mip_height,
0, gl_format, type, temp_data.get());
diff --git a/o3d/core/cross/gl/utils_gl-inl.h b/o3d/core/cross/gl/utils_gl-inl.h
index 82ca73f..b6ca8d4 100644
--- a/o3d/core/cross/gl/utils_gl-inl.h
+++ b/o3d/core/cross/gl/utils_gl-inl.h
@@ -33,13 +33,10 @@
#ifndef O3D_CORE_CROSS_GL_UTILS_GL_INL_H_
#define O3D_CORE_CROSS_GL_UTILS_GL_INL_H_
-#include "core/cross/types.h"
+#include "core/cross/glcommon/utils_glcommon-inl.h"
namespace o3d {
-// Define this to debug GL errors. This has a significant performance hit.
-// #define GL_ERROR_DEBUGGING
-
// convert a byte offset into a Vertex Buffer Object into a GLvoid* for
// use with glVertexPointer(), glNormalPointer(), glVertexAttribPointer(),
// etc. after having used a glBindBuffer().
@@ -67,15 +64,6 @@ namespace o3d {
} \
}
-#ifdef GL_ERROR_DEBUGGING
-#define CHECK_GL_ERROR() do { \
- GLenum gl_error = glGetError(); \
- LOG_IF(ERROR, gl_error != GL_NO_ERROR) << "GL Error :" << gl_error; \
-} while(0)
-#else // GL_ERROR_DEBUGGING
-#define CHECK_GL_ERROR() void(0)
-#endif // GL_ERROR_DEBUGGING
-
} // namespace o3d
#endif // O3D_CORE_CROSS_GL_UTILS_GL_INL_H_
diff --git a/o3d/core/cross/glcommon/utils_glcommon-inl.h b/o3d/core/cross/glcommon/utils_glcommon-inl.h
new file mode 100644
index 0000000..a675239
--- /dev/null
+++ b/o3d/core/cross/glcommon/utils_glcommon-inl.h
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2010, Google Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ * * Neither the name of Google Inc. nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+#ifndef O3D_CORE_CROSS_GLCOMMON_UTILS_GLCOMMON_INL_H_
+#define O3D_CORE_CROSS_GLCOMMON_UTILS_GLCOMMON_INL_H_
+
+#include "core/cross/types.h"
+
+namespace o3d {
+
+// Define this to debug GL errors. This has a significant performance hit.
+// #define GL_ERROR_DEBUGGING
+
+#ifdef GL_ERROR_DEBUGGING
+#define CHECK_GL_ERROR() do { \
+ GLenum gl_error = glGetError(); \
+ LOG_IF(ERROR, gl_error != GL_NO_ERROR) << "GL Error: " << gl_error; \
+} while(0)
+#define LOG_FLUSHED_GL_ERROR(gl_error) \
+ LOG(ERROR) << "Flushing unreaped GL error: " << gl_error;
+#else // GL_ERROR_DEBUGGING
+#define CHECK_GL_ERROR() void(0)
+#define LOG_FLUSHED_GL_ERROR(gl_error) void(0)
+#endif // GL_ERROR_DEBUGGING
+
+inline static void FlushGlErrors() {
+ GLenum gl_error;
+ while ((gl_error = glGetError()) != GL_NO_ERROR) {
+ LOG_FLUSHED_GL_ERROR(gl_error);
+ }
+}
+
+} // namespace o3d
+
+#endif // O3D_CORE_CROSS_GLCOMMON_UTILS_GLCOMMON_INL_H_
diff --git a/o3d/core/cross/gles2/texture_gles2.cc b/o3d/core/cross/gles2/texture_gles2.cc
index b4da4e8..7c84cad 100644
--- a/o3d/core/cross/gles2/texture_gles2.cc
+++ b/o3d/core/cross/gles2/texture_gles2.cc
@@ -211,6 +211,7 @@ static bool UpdateGLImageFromBitmap(GLenum target,
GLenum gl_data_type = 0;
GLenum gl_format = GLFormatFromO3DFormat(bitmap.format(), &gl_internal_format,
&gl_data_type);
+ FlushGlErrors();
if (gl_format) {
glTexSubImage2D(target, level, 0, 0, mip_width, mip_height,
gl_format, gl_data_type, mip_data);
@@ -253,6 +254,7 @@ static bool CreateGLImages(GLenum target,
memset(temp_data.get(), 0, size);
for (int i = 0; i < levels; ++i) {
+ FlushGlErrors();
if (gl_format) {
glTexImage2D(target, i, internal_format, mip_width, mip_height,
0, gl_format, type, temp_data.get());
diff --git a/o3d/core/cross/gles2/utils_gles2-inl.h b/o3d/core/cross/gles2/utils_gles2-inl.h
index 2e15e4c..8ca0d48 100644
--- a/o3d/core/cross/gles2/utils_gles2-inl.h
+++ b/o3d/core/cross/gles2/utils_gles2-inl.h
@@ -33,7 +33,7 @@
#ifndef O3D_CORE_CROSS_GLES2_UTILS_GLES2_INL_H_
#define O3D_CORE_CROSS_GLES2_UTILS_GLES2_INL_H_
-#include "core/cross/types.h"
+#include "core/cross/glcommon/utils_glcommon-inl.h"
namespace o3d {
@@ -44,15 +44,6 @@ inline GLvoid* BufferOffset(unsigned i) {
return static_cast<int8 *>(NULL)+(i);
}
-#ifdef GL_ERROR_DEBUGGING
-#define CHECK_GL_ERROR() do { \
- GLenum gl_error = glGetError(); \
- LOG_IF(ERROR, gl_error != GL_NO_ERROR) << "GL Error :" << gl_error; \
-} while(0)
-#else // GL_ERROR_DEBUGGING
-#define CHECK_GL_ERROR() void(0)
-#endif // GL_ERROR_DEBUGGING
-
} // namespace o3d
#endif // O3D_CORE_CROSS_GLES2_UTILS_GLES2_INL_H_