OLD | NEW |
---|---|
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 "ui/gl/gl_bindings.h" | 7 #include "ui/gl/gl_bindings.h" |
8 #include "ui/gl/gl_context.h" | 8 #include "ui/gl/gl_context.h" |
9 | 9 |
10 namespace gfx { | 10 namespace gfx { |
(...skipping 10 matching lines...) Expand all Loading... | |
21 | 21 |
22 bool GLFenceARB::HasCompleted() { | 22 bool GLFenceARB::HasCompleted() { |
23 // Handle the case where FenceSync failed. | 23 // Handle the case where FenceSync failed. |
24 if (!sync_) | 24 if (!sync_) |
25 return true; | 25 return true; |
26 | 26 |
27 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); | 27 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); |
28 // We could potentially use glGetSynciv here, but it doesn't work | 28 // We could potentially use glGetSynciv here, but it doesn't work |
29 // on OSX 10.7 (always says the fence is not signaled yet). | 29 // on OSX 10.7 (always says the fence is not signaled yet). |
30 // glClientWaitSync works better, so let's use that instead. | 30 // glClientWaitSync works better, so let's use that instead. |
31 return glClientWaitSync(sync_, 0, 0) != GL_TIMEOUT_EXPIRED; | 31 GLenum result = glClientWaitSync(sync_, 0, 0); |
32 if (result == GL_WAIT_FAILED) { | |
33 NOTREACHED(); | |
no sievers
2014/11/03 19:05:02
How about LOG(FATAL) instead (and removing NOTREAC
dshwang
2014/11/04 13:55:08
Yes, I used FATAL, but I'm afraid of it can crash
no sievers
2014/11/04 19:12:56
That's good in a way, because we will get crash re
| |
34 LOG(ERROR) << "Fail to wait for legal GLFence. error code:" << glGetError(); | |
no sievers
2014/11/03 19:05:03
You have to loop over it until it stops returning
dshwang
2014/11/04 13:55:08
Most existing code don't do loop-checking. I think
no sievers
2014/11/04 19:12:56
The problem is that you cannot clear the previous
| |
35 } | |
36 return result != GL_TIMEOUT_EXPIRED; | |
no sievers
2014/11/03 19:05:02
If you return explicitly above, you can DCHECK_NE(
dshwang
2014/11/04 13:55:08
even if we don't set a timeout, GL_TIMEOUT_EXPIRED
| |
32 } | 37 } |
33 | 38 |
34 void GLFenceARB::ClientWait() { | 39 void GLFenceARB::ClientWait() { |
35 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); | 40 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); |
36 if (!flush_event_.get() || flush_event_->IsSignaled()) { | 41 if (!flush_event_.get() || flush_event_->IsSignaled()) { |
37 glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); | 42 glClientWaitSync(sync_, GL_SYNC_FLUSH_COMMANDS_BIT, GL_TIMEOUT_IGNORED); |
dshwang
2014/11/04 13:55:08
Added DCHECK_NE(result, GL_TIMEOUT_EXPIRED) here
| |
38 } else { | 43 } else { |
39 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping..."; | 44 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping..."; |
40 } | 45 } |
41 } | 46 } |
42 | 47 |
43 void GLFenceARB::ServerWait() { | 48 void GLFenceARB::ServerWait() { |
44 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); | 49 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); |
45 if (!flush_event_.get() || flush_event_->IsSignaled()) { | 50 if (!flush_event_.get() || flush_event_->IsSignaled()) { |
46 glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED); | 51 glWaitSync(sync_, 0, GL_TIMEOUT_IGNORED); |
47 } else { | 52 } else { |
48 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping..."; | 53 LOG(ERROR) << "Trying to wait for uncommitted fence. Skipping..."; |
49 } | 54 } |
50 } | 55 } |
51 | 56 |
52 GLFenceARB::~GLFenceARB() { | 57 GLFenceARB::~GLFenceARB() { |
53 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); | 58 DCHECK_EQ(GL_TRUE, glIsSync(sync_)); |
54 glDeleteSync(sync_); | 59 glDeleteSync(sync_); |
55 } | 60 } |
56 | 61 |
57 } // namespace gfx | 62 } // namespace gfx |
OLD | NEW |