Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(155)

Side by Side Diff: ui/gl/gl_fence_arb.cc

Issue 2408543003: Loosen the GLFenceARB assertions when glClientWaitSync fails. (Closed)
Patch Set: Preemptive rebase. Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ui/gl/gl_fence_arb.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/gl/gl_fence_arb.h" 5 #include "ui/gl/gl_fence_arb.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "ui/gl/gl_bindings.h" 8 #include "ui/gl/gl_bindings.h"
9 #include "ui/gl/gl_context.h"
9 10
10 namespace gl { 11 namespace gl {
11 12
12 namespace { 13 namespace {
13 14
14 std::string GetGLErrors() { 15 std::string GetGLErrors() {
15 // Clears and logs all current gl errors. 16 // Clears and logs all current gl errors.
16 std::string accumulated_errors; 17 std::string accumulated_errors;
17 GLenum error; 18 GLenum error;
18 while ((error = glGetError()) != GL_NO_ERROR) { 19 while ((error = glGetError()) != GL_NO_ERROR) {
(...skipping 14 matching lines...) Expand all
33 // Handle the case where FenceSync failed. 34 // Handle the case where FenceSync failed.
34 if (!sync_) 35 if (!sync_)
35 return true; 36 return true;
36 37
37 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); 38 DCHECK_EQ(GL_TRUE, glIsSync(sync_));
38 // We could potentially use glGetSynciv here, but it doesn't work 39 // We could potentially use glGetSynciv here, but it doesn't work
39 // on OSX 10.7 (always says the fence is not signaled yet). 40 // on OSX 10.7 (always says the fence is not signaled yet).
40 // glClientWaitSync works better, so let's use that instead. 41 // glClientWaitSync works better, so let's use that instead.
41 GLenum result = glClientWaitSync(sync_, 0, 0); 42 GLenum result = glClientWaitSync(sync_, 0, 0);
42 if (result == GL_WAIT_FAILED) { 43 if (result == GL_WAIT_FAILED) {
43 LOG(FATAL) << "Failed to wait for GLFence. error code:" << GetGLErrors(); 44 HandleClientWaitFailure();
45 return false;
44 } 46 }
45 return result != GL_TIMEOUT_EXPIRED; 47 return result != GL_TIMEOUT_EXPIRED;
46 } 48 }
47 49
48 void GLFenceARB::ClientWait() { 50 void GLFenceARB::ClientWait() {
49 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); 51 DCHECK_EQ(GL_TRUE, glIsSync(sync_));
50 GLenum result = 52 GLenum result =
51 glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); 53 glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED);
52 DCHECK_NE(static_cast<GLenum>(GL_TIMEOUT_EXPIRED), result); 54 DCHECK_NE(static_cast<GLenum>(GL_TIMEOUT_EXPIRED), result);
53 if (result == GL_WAIT_FAILED) { 55 if (result == GL_WAIT_FAILED) {
54 LOG(FATAL) << "Failed to wait for GLFence. error code:" << GetGLErrors(); 56 HandleClientWaitFailure();
55 } 57 }
56 } 58 }
57 59
58 void GLFenceARB::ServerWait() { 60 void GLFenceARB::ServerWait() {
59 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); 61 DCHECK_EQ(GL_TRUE, glIsSync(sync_));
60 glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED); 62 glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED);
61 } 63 }
62 64
63 GLFenceARB::~GLFenceARB() { 65 GLFenceARB::~GLFenceARB() {
64 if (sync_) { 66 if (sync_) {
65 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); 67 DCHECK_EQ(GL_TRUE, glIsSync(sync_));
66 glDeleteSync(sync_); 68 glDeleteSync(sync_);
67 } 69 }
68 } 70 }
69 71
70 void GLFenceARB::Invalidate() { 72 void GLFenceARB::Invalidate() {
71 sync_ = 0; 73 sync_ = 0;
72 } 74 }
73 75
76 void GLFenceARB::HandleClientWaitFailure() {
77 DCHECK(GLContext::GetCurrent());
78 if (GLContext::GetCurrent()->WasAllocatedUsingRobustnessExtension()) {
79 // This function pointer is only set if one of the robustness
80 // extensions was available.
81 DCHECK(g_driver_gl.fn.glGetGraphicsResetStatusARBFn);
82 DCHECK(g_driver_gl.fn.glGetGraphicsResetStatusARBFn() != GL_NO_ERROR);
83 LOG(ERROR) << "Failed to wait for GLFence; context was lost. Error code: "
84 << GetGLErrors();
85 } else {
86 // There's no provision for reporting these failures higher up the
87 // stack and thereby losing the context (or exiting the GPU
88 // process) more cooperatively. Some of this code is called from
89 // deep call stacks. Report the wait failure and crash with a log
90 // message.
91 LOG(FATAL) << "Failed to wait for GLFence. Error code: " << GetGLErrors();
92 }
93 }
94
74 } // namespace gl 95 } // namespace gl
OLDNEW
« no previous file with comments | « ui/gl/gl_fence_arb.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698