Index: ui/gl/gl_fence_arb.cc |
diff --git a/ui/gl/gl_fence_arb.cc b/ui/gl/gl_fence_arb.cc |
index da13f107880d8ae0c996218af9d75fad46470932..05bda6b588f2eb219ae2abfcda444070a7a469cf 100644 |
--- a/ui/gl/gl_fence_arb.cc |
+++ b/ui/gl/gl_fence_arb.cc |
@@ -4,11 +4,26 @@ |
#include "ui/gl/gl_fence_arb.h" |
+#include "base/strings/stringprintf.h" |
#include "ui/gl/gl_bindings.h" |
#include "ui/gl/gl_context.h" |
namespace gfx { |
+namespace { |
+ |
+std::string GetGLErrors() { |
+ // Clears and logs all current gl errors. |
+ std::string accumulated_errors; |
+ GLenum error; |
+ while ((error = glGetError()) != GL_NO_ERROR) { |
+ accumulated_errors += base::StringPrintf("0x%x ", error); |
+ } |
+ return accumulated_errors; |
+} |
+ |
+} // namespace |
+ |
GLFenceARB::GLFenceARB(bool flush) { |
sync_ = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); |
DCHECK_EQ(GL_TRUE, glIsSync(sync_)); |
@@ -28,13 +43,22 @@ bool GLFenceARB::HasCompleted() { |
// We could potentially use glGetSynciv here, but it doesn't work |
// on OSX 10.7 (always says the fence is not signaled yet). |
// glClientWaitSync works better, so let's use that instead. |
- return glClientWaitSync(sync_, 0, 0) != GL_TIMEOUT_EXPIRED; |
+ GLenum result = glClientWaitSync(sync_, 0, 0); |
+ if (result == GL_WAIT_FAILED) { |
+ LOG(FATAL) << "Failed to wait for GLFence. error code:" << GetGLErrors(); |
+ } |
+ return result != GL_TIMEOUT_EXPIRED; |
} |
void GLFenceARB::ClientWait() { |
DCHECK_EQ(GL_TRUE, glIsSync(sync_)); |
if (!flush_event_.get() || flush_event_->IsSignaled()) { |
- glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); |
+ GLenum result = |
+ glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); |
+ DCHECK_NE(static_cast<GLenum>(GL_TIMEOUT_EXPIRED), result); |
+ if (result == GL_WAIT_FAILED) { |
+ LOG(FATAL) << "Failed to wait for GLFence. error code:" << GetGLErrors(); |
+ } |
} else { |
LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping..."; |
} |