Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 Loading... | |
| 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( | |
| 97 base::Bind(&CommandBufferLocal::OnFenceSyncRelease, | |
| 98 base::Unretained(this))); | |
| 99 decoder_->SetWaitFenceSyncCallback( | |
| 100 base::Bind(&CommandBufferLocal::OnWaitFenceSync, | |
| 101 base::Unretained(this))); | |
| 95 | 102 |
| 96 gpu::gles2::DisallowedFeatures disallowed_features; | 103 gpu::gles2::DisallowedFeatures disallowed_features; |
| 97 | 104 |
| 98 // TODO(piman): attributes. | 105 // TODO(piman): attributes. |
| 99 std::vector<int32> attrib_vector; | 106 std::vector<int32> attrib_vector; |
| 100 if (!decoder_->Initialize(surface_, context_, false /* offscreen */, | 107 if (!decoder_->Initialize(surface_, context_, false /* offscreen */, |
| 101 gfx::Size(1, 1), disallowed_features, | 108 gfx::Size(1, 1), disallowed_features, |
| 102 attrib_vector)) | 109 attrib_vector)) |
| 103 return false; | 110 return false; |
| 104 | 111 |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 213 gpu::CommandBufferNamespace CommandBufferLocal::GetNamespaceID() const { | 220 gpu::CommandBufferNamespace CommandBufferLocal::GetNamespaceID() const { |
| 214 NOTIMPLEMENTED(); | 221 NOTIMPLEMENTED(); |
| 215 return gpu::CommandBufferNamespace::INVALID; | 222 return gpu::CommandBufferNamespace::INVALID; |
| 216 } | 223 } |
| 217 | 224 |
| 218 uint64_t CommandBufferLocal::GetCommandBufferID() const { | 225 uint64_t CommandBufferLocal::GetCommandBufferID() const { |
| 219 NOTIMPLEMENTED(); | 226 NOTIMPLEMENTED(); |
| 220 return 0; | 227 return 0; |
| 221 } | 228 } |
| 222 | 229 |
| 230 uint32_t CommandBufferLocal::GenerateFenceSyncRelease() { | |
| 231 return next_fence_sync_release_++; | |
| 232 } | |
| 233 | |
| 234 bool CommandBufferLocal::IsFenceSyncRelease(uint32_t release) { | |
| 235 return release > 0 && release < next_fence_sync_release_; | |
| 236 } | |
| 237 | |
| 238 bool CommandBufferLocal::IsFenceSyncFlushed(uint32_t release) { | |
| 239 return IsFenceSyncRelease(release); | |
| 240 } | |
| 241 | |
| 223 void CommandBufferLocal::PumpCommands() { | 242 void CommandBufferLocal::PumpCommands() { |
| 224 if (!decoder_->MakeCurrent()) { | 243 if (!decoder_->MakeCurrent()) { |
| 225 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); | 244 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); |
| 226 command_buffer_->SetParseError(::gpu::error::kLostContext); | 245 command_buffer_->SetParseError(::gpu::error::kLostContext); |
| 227 return; | 246 return; |
| 228 } | 247 } |
| 229 scheduler_->PutChanged(); | 248 scheduler_->PutChanged(); |
| 230 } | 249 } |
| 231 | 250 |
| 232 void CommandBufferLocal::OnResize(gfx::Size size, float scale_factor) { | 251 void CommandBufferLocal::OnResize(gfx::Size size, float scale_factor) { |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 246 return true; | 265 return true; |
| 247 if (gpu_state_->sync_point_manager()->IsSyncPointRetired(sync_point)) | 266 if (gpu_state_->sync_point_manager()->IsSyncPointRetired(sync_point)) |
| 248 return true; | 267 return true; |
| 249 scheduler_->SetScheduled(false); | 268 scheduler_->SetScheduled(false); |
| 250 gpu_state_->sync_point_manager()->AddSyncPointCallback( | 269 gpu_state_->sync_point_manager()->AddSyncPointCallback( |
| 251 sync_point, base::Bind(&CommandBufferLocal::OnSyncPointRetired, | 270 sync_point, base::Bind(&CommandBufferLocal::OnSyncPointRetired, |
| 252 weak_factory_.GetWeakPtr())); | 271 weak_factory_.GetWeakPtr())); |
| 253 return scheduler_->scheduled(); | 272 return scheduler_->scheduled(); |
| 254 } | 273 } |
| 255 | 274 |
| 275 void CommandBufferLocal::OnFenceSyncRelease(uint32_t release) { | |
| 276 // TODO(dyen): Implement once CommandBufferID has been figured out and | |
| 277 // we have a SyncPointClient. It would probably look like what is commented | |
| 278 // out below: | |
| 279 // if (!sync_point_client_->client_state()->IsFenceSyncReleased(release)) | |
| 280 // sync_point_client_->ReleaseFenceSync(release); | |
| 281 NOTIMPLEMENTED(); | |
| 282 } | |
| 283 | |
| 284 bool CommandBufferLocal::OnWaitFenceSync( | |
| 285 gpu::CommandBufferNamespace namespace_id, | |
| 286 uint64_t command_buffer_id, | |
| 287 uint32_t release) { | |
| 288 gpu::SyncPointManager* sync_point_manager = gpu_state_->sync_point_manager(); | |
| 289 DCHECK(sync_point_manager); | |
| 290 | |
| 291 scoped_refptr<gpu::SyncPointClientState> release_state = | |
| 292 sync_point_manager->GetSyncPointClientState(namespace_id, | |
| 293 command_buffer_id); | |
| 294 | |
| 295 if (!release_state.get()) | |
|
dcheng
2015/09/28 07:39:33
No .get()
David Yen
2015/09/28 17:38:18
Done.
| |
| 296 return true; | |
| 297 | |
| 298 if (release_state->IsFenceSyncReleased(release)) | |
| 299 return true; | |
| 300 | |
| 301 // TODO(dyen): Implement once CommandBufferID has been figured out and | |
| 302 // we have a SyncPointClient. It would probably look like what is commented | |
| 303 // out below: | |
| 304 // sync_point_client_->Wait( | |
| 305 // release_state, | |
| 306 // release, | |
| 307 // base::Bind(&CommandBufferLocal::OnSyncPointRetired, | |
| 308 // weak_factory_.GetWeakPtr())); | |
| 309 NOTIMPLEMENTED(); | |
| 310 return scheduler_->scheduled(); | |
| 311 } | |
| 312 | |
| 256 void CommandBufferLocal::OnParseError() { | 313 void CommandBufferLocal::OnParseError() { |
| 257 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 314 gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
| 258 OnContextLost(state.context_lost_reason); | 315 OnContextLost(state.context_lost_reason); |
| 259 } | 316 } |
| 260 | 317 |
| 261 void CommandBufferLocal::OnContextLost(uint32_t reason) { | 318 void CommandBufferLocal::OnContextLost(uint32_t reason) { |
| 262 if (client_) | 319 if (client_) |
| 263 client_->DidLoseContext(); | 320 client_->DidLoseContext(); |
| 264 } | 321 } |
| 265 | 322 |
| 266 void CommandBufferLocal::OnSyncPointRetired() { | 323 void CommandBufferLocal::OnSyncPointRetired() { |
| 267 scheduler_->SetScheduled(true); | 324 scheduler_->SetScheduled(true); |
| 268 } | 325 } |
| 269 | 326 |
| 270 } // namespace mus | 327 } // namespace mus |
| OLD | NEW |