Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_driver.h" | 5 #include "components/mus/gles2/command_buffer_driver.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "base/memory/shared_memory.h" | 9 #include "base/memory/shared_memory.h" |
| 10 #include "components/mus/gles2/command_buffer_type_conversions.h" | 10 #include "components/mus/gles2/command_buffer_type_conversions.h" |
| 11 #include "components/mus/gles2/gpu_memory_tracker.h" | 11 #include "components/mus/gles2/gpu_memory_tracker.h" |
| 12 #include "components/mus/gles2/gpu_state.h" | 12 #include "components/mus/gles2/gpu_state.h" |
| 13 #include "components/mus/gles2/mojo_buffer_backing.h" | 13 #include "components/mus/gles2/mojo_buffer_backing.h" |
| 14 #include "gpu/command_buffer/common/constants.h" | |
| 15 #include "gpu/command_buffer/common/value_state.h" | 14 #include "gpu/command_buffer/common/value_state.h" |
| 16 #include "gpu/command_buffer/service/command_buffer_service.h" | 15 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 17 #include "gpu/command_buffer/service/context_group.h" | 16 #include "gpu/command_buffer/service/context_group.h" |
| 18 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 17 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 19 #include "gpu/command_buffer/service/gpu_scheduler.h" | 18 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 20 #include "gpu/command_buffer/service/image_factory.h" | 19 #include "gpu/command_buffer/service/image_factory.h" |
| 21 #include "gpu/command_buffer/service/image_manager.h" | 20 #include "gpu/command_buffer/service/image_manager.h" |
| 22 #include "gpu/command_buffer/service/mailbox_manager.h" | 21 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 23 #include "gpu/command_buffer/service/memory_tracking.h" | 22 #include "gpu/command_buffer/service/memory_tracking.h" |
| 24 #include "gpu/command_buffer/service/sync_point_manager.h" | 23 #include "gpu/command_buffer/service/sync_point_manager.h" |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 109 DCHECK(result); | 108 DCHECK(result); |
| 110 | 109 |
| 111 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); | 110 decoder_.reset(::gpu::gles2::GLES2Decoder::Create(context_group.get())); |
| 112 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(), | 111 scheduler_.reset(new gpu::GpuScheduler(command_buffer_.get(), decoder_.get(), |
| 113 decoder_.get())); | 112 decoder_.get())); |
| 114 decoder_->set_engine(scheduler_.get()); | 113 decoder_->set_engine(scheduler_.get()); |
| 115 decoder_->SetResizeCallback( | 114 decoder_->SetResizeCallback( |
| 116 base::Bind(&CommandBufferDriver::OnResize, base::Unretained(this))); | 115 base::Bind(&CommandBufferDriver::OnResize, base::Unretained(this))); |
| 117 decoder_->SetWaitSyncPointCallback(base::Bind( | 116 decoder_->SetWaitSyncPointCallback(base::Bind( |
| 118 &CommandBufferDriver::OnWaitSyncPoint, base::Unretained(this))); | 117 &CommandBufferDriver::OnWaitSyncPoint, base::Unretained(this))); |
| 118 decoder_->SetFenceSyncReleaseCallback(base::Bind( | |
| 119 &CommandBufferDriver::OnFenceSyncRelease, base::Unretained(this))); | |
| 120 decoder_->SetWaitFenceSyncCallback(base::Bind( | |
| 121 &CommandBufferDriver::OnWaitFenceSync, base::Unretained(this))); | |
| 119 | 122 |
| 120 gpu::gles2::DisallowedFeatures disallowed_features; | 123 gpu::gles2::DisallowedFeatures disallowed_features; |
| 121 | 124 |
| 122 const bool offscreen = true; | 125 const bool offscreen = true; |
| 123 std::vector<int32> attrib_vector; | 126 std::vector<int32> attrib_vector; |
| 124 attrib_helper.Serialize(&attrib_vector); | 127 attrib_helper.Serialize(&attrib_vector); |
| 125 if (!decoder_->Initialize(surface_, context_, offscreen, gfx::Size(1, 1), | 128 if (!decoder_->Initialize(surface_, context_, offscreen, gfx::Size(1, 1), |
| 126 disallowed_features, attrib_vector)) | 129 disallowed_features, attrib_vector)) |
| 127 return false; | 130 return false; |
| 128 | 131 |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 284 return true; | 287 return true; |
| 285 if (gpu_state_->sync_point_manager()->IsSyncPointRetired(sync_point)) | 288 if (gpu_state_->sync_point_manager()->IsSyncPointRetired(sync_point)) |
| 286 return true; | 289 return true; |
| 287 scheduler_->SetScheduled(false); | 290 scheduler_->SetScheduled(false); |
| 288 gpu_state_->sync_point_manager()->AddSyncPointCallback( | 291 gpu_state_->sync_point_manager()->AddSyncPointCallback( |
| 289 sync_point, base::Bind(&CommandBufferDriver::OnSyncPointRetired, | 292 sync_point, base::Bind(&CommandBufferDriver::OnSyncPointRetired, |
| 290 weak_factory_.GetWeakPtr())); | 293 weak_factory_.GetWeakPtr())); |
| 291 return scheduler_->scheduled(); | 294 return scheduler_->scheduled(); |
| 292 } | 295 } |
| 293 | 296 |
| 297 void CommandBufferDriver::OnFenceSyncRelease(uint32_t release) { | |
| 298 // TODO(dyen): Implement once CommandBufferID has been figured out and | |
| 299 // we have a SyncPointClient. It would probably look like what is commented | |
| 300 // out below: | |
| 301 // if (!sync_point_client_->client_state()->IsFenceSyncReleased(release)) | |
| 302 // sync_point_client_->ReleaseFenceSync(release); | |
| 303 NOTIMPLEMENTED(); | |
| 304 } | |
| 305 | |
| 306 bool CommandBufferDriver::OnWaitFenceSync( | |
| 307 gpu::CommandBufferNamespace namespace_id, | |
| 308 uint64_t command_buffer_id, | |
| 309 uint32_t release) { | |
| 310 gpu::SyncPointManager* sync_point_manager = gpu_state_->sync_point_manager(); | |
| 311 DCHECK(sync_point_manager); | |
| 312 | |
| 313 scoped_refptr<gpu::SyncPointClientState> release_state = | |
| 314 sync_point_manager->GetSyncPointClientState(namespace_id, | |
| 315 command_buffer_id); | |
| 316 | |
| 317 if (!release_state.get()) | |
|
dcheng
2015/09/28 07:39:33
No .get()
David Yen
2015/09/28 17:38:18
Done.
| |
| 318 return true; | |
| 319 | |
| 320 if (release_state->IsFenceSyncReleased(release)) | |
| 321 return true; | |
| 322 | |
| 323 // TODO(dyen): Implement once CommandBufferID has been figured out and | |
| 324 // we have a SyncPointClient. It would probably look like what is commented | |
| 325 // out below: | |
| 326 // sync_point_client_->Wait( | |
| 327 // release_state, | |
| 328 // release, | |
| 329 // base::Bind(&CommandBufferDriver::OnSyncPointRetired, | |
| 330 // weak_factory_.GetWeakPtr())); | |
| 331 NOTIMPLEMENTED(); | |
| 332 return scheduler_->scheduled(); | |
| 333 } | |
| 334 | |
| 294 void CommandBufferDriver::OnSyncPointRetired() { | 335 void CommandBufferDriver::OnSyncPointRetired() { |
| 295 scheduler_->SetScheduled(true); | 336 scheduler_->SetScheduled(true); |
| 296 } | 337 } |
| 297 | 338 |
| 298 void CommandBufferDriver::OnContextLost(uint32_t reason) { | 339 void CommandBufferDriver::OnContextLost(uint32_t reason) { |
| 299 loss_observer_->DidLoseContext(reason); | 340 loss_observer_->DidLoseContext(reason); |
| 300 client_->DidLoseContext(); | 341 client_->DidLoseContext(); |
| 301 } | 342 } |
| 302 | 343 |
| 303 void CommandBufferDriver::DestroyDecoder() { | 344 void CommandBufferDriver::DestroyDecoder() { |
| 304 if (decoder_) { | 345 if (decoder_) { |
| 305 bool have_context = decoder_->MakeCurrent(); | 346 bool have_context = decoder_->MakeCurrent(); |
| 306 decoder_->Destroy(have_context); | 347 decoder_->Destroy(have_context); |
| 307 decoder_.reset(); | 348 decoder_.reset(); |
| 308 } | 349 } |
| 309 } | 350 } |
| 310 | 351 |
| 311 } // namespace mus | 352 } // namespace mus |
| OLD | NEW |