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

Side by Side Diff: components/mus/gles2/command_buffer_local.cc

Issue 1331843005: Implemented new fence syncs which replaces the old sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Reverted mojo readme, changed wait() to take a pointer Created 5 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "components/mus/gles2/command_buffer_local.h" 5 #include "components/mus/gles2/command_buffer_local.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "components/mus/gles2/command_buffer_local_client.h" 8 #include "components/mus/gles2/command_buffer_local_client.h"
9 #include "components/mus/gles2/gpu_memory_tracker.h" 9 #include "components/mus/gles2/gpu_memory_tracker.h"
10 #include "components/mus/gles2/mojo_gpu_memory_buffer.h" 10 #include "components/mus/gles2/mojo_gpu_memory_buffer.h"
(...skipping 14 matching lines...) Expand all
25 namespace mus { 25 namespace mus {
26 26
27 const unsigned int GL_MAP_CHROMIUM = 0x78F1; 27 const unsigned int GL_MAP_CHROMIUM = 0x78F1;
28 28
29 CommandBufferLocal::CommandBufferLocal(CommandBufferLocalClient* client, 29 CommandBufferLocal::CommandBufferLocal(CommandBufferLocalClient* client,
30 gfx::AcceleratedWidget widget, 30 gfx::AcceleratedWidget widget,
31 const scoped_refptr<GpuState>& gpu_state) 31 const scoped_refptr<GpuState>& gpu_state)
32 : widget_(widget), 32 : widget_(widget),
33 gpu_state_(gpu_state), 33 gpu_state_(gpu_state),
34 client_(client), 34 client_(client),
35 next_fence_sync_release_(1),
35 weak_factory_(this) {} 36 weak_factory_(this) {}
36 37
37 CommandBufferLocal::~CommandBufferLocal() { 38 CommandBufferLocal::~CommandBufferLocal() {
38 command_buffer_.reset(); 39 command_buffer_.reset();
39 if (decoder_.get()) { 40 if (decoder_.get()) {
40 bool have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get()); 41 bool have_context = decoder_->GetGLContext()->MakeCurrent(surface_.get());
41 decoder_->Destroy(have_context); 42 decoder_->Destroy(have_context);
42 decoder_.reset(); 43 decoder_.reset();
43 } 44 }
44 } 45 }
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 DCHECK(result); 86 DCHECK(result);
86 87
87 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); 88 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get()));
88 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(), 89 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(),
89 decoder_.get())); 90 decoder_.get()));
90 decoder_->set_engine(scheduler_.get()); 91 decoder_->set_engine(scheduler_.get());
91 decoder_->SetResizeCallback( 92 decoder_->SetResizeCallback(
92 base::Bind(&CommandBufferLocal::OnResize, base::Unretained(this))); 93 base::Bind(&CommandBufferLocal::OnResize, base::Unretained(this)));
93 decoder_->SetWaitSyncPointCallback( 94 decoder_->SetWaitSyncPointCallback(
94 base::Bind(&CommandBufferLocal::OnWaitSyncPoint, base::Unretained(this))); 95 base::Bind(&CommandBufferLocal::OnWaitSyncPoint, base::Unretained(this)));
96 decoder_->SetFenceSyncReleaseCallback(base::Bind(
97 &CommandBufferLocal::OnFenceSyncRelease, base::Unretained(this)));
98 decoder_->SetWaitFenceSyncCallback(
99 base::Bind(&CommandBufferLocal::OnWaitFenceSync, base::Unretained(this)));
95 100
96 gpu::gles2::DisallowedFeatures disallowed_features; 101 gpu::gles2::DisallowedFeatures disallowed_features;
97 102
98 // TODO(piman): attributes. 103 // TODO(piman): attributes.
99 std::vector<int32> attrib_vector; 104 std::vector<int32> attrib_vector;
100 if (!decoder_->Initialize(surface_, context_, false /* offscreen */, 105 if (!decoder_->Initialize(surface_, context_, false /* offscreen */,
101 gfx::Size(1, 1), disallowed_features, 106 gfx::Size(1, 1), disallowed_features,
102 attrib_vector)) 107 attrib_vector))
103 return false; 108 return false;
104 109
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
213 gpu::CommandBufferNamespace CommandBufferLocal::GetNamespaceID() const { 218 gpu::CommandBufferNamespace CommandBufferLocal::GetNamespaceID() const {
214 NOTIMPLEMENTED(); 219 NOTIMPLEMENTED();
215 return gpu::CommandBufferNamespace::INVALID; 220 return gpu::CommandBufferNamespace::INVALID;
216 } 221 }
217 222
218 uint64_t CommandBufferLocal::GetCommandBufferID() const { 223 uint64_t CommandBufferLocal::GetCommandBufferID() const {
219 NOTIMPLEMENTED(); 224 NOTIMPLEMENTED();
220 return 0; 225 return 0;
221 } 226 }
222 227
228 uint64_t CommandBufferLocal::GenerateFenceSyncRelease() {
229 return next_fence_sync_release_++;
230 }
231
232 bool CommandBufferLocal::IsFenceSyncRelease(uint64_t release) {
233 return release > 0 && release < next_fence_sync_release_;
234 }
235
236 bool CommandBufferLocal::IsFenceSyncFlushed(uint64_t release) {
237 return IsFenceSyncRelease(release);
238 }
239
223 void CommandBufferLocal::PumpCommands() { 240 void CommandBufferLocal::PumpCommands() {
224 if (!decoder_->MakeCurrent()) { 241 if (!decoder_->MakeCurrent()) {
225 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); 242 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason());
226 command_buffer_->SetParseError(::gpu::error::kLostContext); 243 command_buffer_->SetParseError(::gpu::error::kLostContext);
227 return; 244 return;
228 } 245 }
229 scheduler_->PutChanged(); 246 scheduler_->PutChanged();
230 } 247 }
231 248
232 void CommandBufferLocal::OnResize(gfx::Size size, float scale_factor) { 249 void CommandBufferLocal::OnResize(gfx::Size size, float scale_factor) {
(...skipping 13 matching lines...) Expand all
246 return true; 263 return true;
247 if (gpu_state_->sync_point_manager()->IsSyncPointRetired(sync_point)) 264 if (gpu_state_->sync_point_manager()->IsSyncPointRetired(sync_point))
248 return true; 265 return true;
249 scheduler_->SetScheduled(false); 266 scheduler_->SetScheduled(false);
250 gpu_state_->sync_point_manager()->AddSyncPointCallback( 267 gpu_state_->sync_point_manager()->AddSyncPointCallback(
251 sync_point, base::Bind(&CommandBufferLocal::OnSyncPointRetired, 268 sync_point, base::Bind(&CommandBufferLocal::OnSyncPointRetired,
252 weak_factory_.GetWeakPtr())); 269 weak_factory_.GetWeakPtr()));
253 return scheduler_->scheduled(); 270 return scheduler_->scheduled();
254 } 271 }
255 272
273 void CommandBufferLocal::OnFenceSyncRelease(uint64_t release) {
274 // TODO(dyen): Implement once CommandBufferID has been figured out and
275 // we have a SyncPointClient. It would probably look like what is commented
276 // out below:
277 // if (!sync_point_client_->client_state()->IsFenceSyncReleased(release))
278 // sync_point_client_->ReleaseFenceSync(release);
279 NOTIMPLEMENTED();
280 }
281
282 bool CommandBufferLocal::OnWaitFenceSync(
283 gpu::CommandBufferNamespace namespace_id,
284 uint64_t command_buffer_id,
285 uint64_t release) {
286 gpu::SyncPointManager* sync_point_manager = gpu_state_->sync_point_manager();
287 DCHECK(sync_point_manager);
288
289 scoped_refptr<gpu::SyncPointClientState> release_state =
290 sync_point_manager->GetSyncPointClientState(namespace_id,
291 command_buffer_id);
292
293 if (!release_state)
294 return true;
295
296 if (release_state->IsFenceSyncReleased(release))
297 return true;
298
299 // TODO(dyen): Implement once CommandBufferID has been figured out and
300 // we have a SyncPointClient. It would probably look like what is commented
301 // out below:
302 // scheduler_->SetScheduled(false);
303 // sync_point_client_->Wait(
304 // release_state.get(),
305 // release,
306 // base::Bind(&CommandBufferLocal::OnSyncPointRetired,
307 // weak_factory_.GetWeakPtr()));
308 NOTIMPLEMENTED();
309 return scheduler_->scheduled();
310 }
311
256 void CommandBufferLocal::OnParseError() { 312 void CommandBufferLocal::OnParseError() {
257 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); 313 gpu::CommandBuffer::State state = command_buffer_->GetLastState();
258 OnContextLost(state.context_lost_reason); 314 OnContextLost(state.context_lost_reason);
259 } 315 }
260 316
261 void CommandBufferLocal::OnContextLost(uint32_t reason) { 317 void CommandBufferLocal::OnContextLost(uint32_t reason) {
262 if (client_) 318 if (client_)
263 client_->DidLoseContext(); 319 client_->DidLoseContext();
264 } 320 }
265 321
266 void CommandBufferLocal::OnSyncPointRetired() { 322 void CommandBufferLocal::OnSyncPointRetired() {
267 scheduler_->SetScheduled(true); 323 scheduler_->SetScheduled(true);
268 } 324 }
269 325
270 } // namespace mus 326 } // namespace mus
OLDNEW
« no previous file with comments | « components/mus/gles2/command_buffer_local.h ('k') | content/common/gpu/client/command_buffer_proxy_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698