OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "gpu/command_buffer/service/gpu_scheduler.h" | 5 #include "gpu/command_buffer/service/gpu_scheduler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/callback.h" | 8 #include "base/callback.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 | 55 |
56 DCHECK(IsScheduled()); | 56 DCHECK(IsScheduled()); |
57 | 57 |
58 CommandBuffer::State state = command_buffer_->GetState(); | 58 CommandBuffer::State state = command_buffer_->GetState(); |
59 parser_->set_put(state.put_offset); | 59 parser_->set_put(state.put_offset); |
60 if (state.error != error::kNoError) | 60 if (state.error != error::kNoError) |
61 return; | 61 return; |
62 | 62 |
63 // Check that the GPU has passed all fences. | 63 // Check that the GPU has passed all fences. |
64 if (!unschedule_fences_.empty()) { | 64 if (!unschedule_fences_.empty()) { |
65 if (glGenFencesNV) { | 65 if (gfx::g_GL_NV_fence) { |
66 while (!unschedule_fences_.empty()) { | 66 while (!unschedule_fences_.empty()) { |
67 if (glTestFenceNV(unschedule_fences_.front().fence)) { | 67 if (glTestFenceNV(unschedule_fences_.front().fence)) { |
68 glDeleteFencesNV(1, &unschedule_fences_.front().fence); | 68 glDeleteFencesNV(1, &unschedule_fences_.front().fence); |
69 unschedule_fences_.front().task.Run(); | 69 unschedule_fences_.front().task.Run(); |
70 unschedule_fences_.pop(); | 70 unschedule_fences_.pop(); |
71 } else { | 71 } else { |
72 SetScheduled(false); | 72 SetScheduled(false); |
73 MessageLoop::current()->PostDelayedTask( | 73 MessageLoop::current()->PostDelayedTask( |
74 FROM_HERE, | 74 FROM_HERE, |
75 base::Bind(&GpuScheduler::SetScheduled, AsWeakPtr(), true), | 75 base::Bind(&GpuScheduler::SetScheduled, AsWeakPtr(), true), |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 // PutChanged will treat the fence as having been crossed and thereby not | 174 // PutChanged will treat the fence as having been crossed and thereby not |
175 // poll indefinately. See spec: | 175 // poll indefinately. See spec: |
176 // http://www.opengl.org/registry/specs/NV/fence.txt | 176 // http://www.opengl.org/registry/specs/NV/fence.txt |
177 // | 177 // |
178 // What should happen if TestFenceNV is called for a name before SetFenceNV | 178 // What should happen if TestFenceNV is called for a name before SetFenceNV |
179 // is called? | 179 // is called? |
180 // We generate an INVALID_OPERATION error, and return TRUE. | 180 // We generate an INVALID_OPERATION error, and return TRUE. |
181 // This follows the semantics for texture object names before | 181 // This follows the semantics for texture object names before |
182 // they are bound, in that they acquire their state upon binding. | 182 // they are bound, in that they acquire their state upon binding. |
183 // We will arbitrarily return TRUE for consistency. | 183 // We will arbitrarily return TRUE for consistency. |
184 if (glGenFencesNV) { | 184 if (gfx::g_GL_NV_fence) { |
185 glGenFencesNV(1, &fence.fence); | 185 glGenFencesNV(1, &fence.fence); |
186 glSetFenceNV(fence.fence, GL_ALL_COMPLETED_NV); | 186 glSetFenceNV(fence.fence, GL_ALL_COMPLETED_NV); |
187 } | 187 } |
188 | 188 |
189 glFlush(); | 189 glFlush(); |
190 | 190 |
191 fence.task = task; | 191 fence.task = task; |
192 | 192 |
193 unschedule_fences_.push(fence); | 193 unschedule_fences_.push(fence); |
194 } | 194 } |
195 | 195 |
196 GpuScheduler::UnscheduleFence::UnscheduleFence() : fence(0) { | 196 GpuScheduler::UnscheduleFence::UnscheduleFence() : fence(0) { |
197 } | 197 } |
198 | 198 |
199 GpuScheduler::UnscheduleFence::~UnscheduleFence() { | 199 GpuScheduler::UnscheduleFence::~UnscheduleFence() { |
200 } | 200 } |
201 | 201 |
202 } // namespace gpu | 202 } // namespace gpu |
OLD | NEW |