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

Side by Side Diff: gpu/command_buffer/service/in_process_command_buffer.cc

Issue 1864373002: Remove unused features for in-process GL contexts. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: inproclost: . Created 4 years, 8 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
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "gpu/command_buffer/service/in_process_command_buffer.h" 5 #include "gpu/command_buffer/service/in_process_command_buffer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <queue> 10 #include <queue>
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 gpu_preferences().gpu_program_cache_size, 202 gpu_preferences().gpu_program_cache_size,
203 gpu_preferences().disable_gpu_shader_disk_cache)); 203 gpu_preferences().disable_gpu_shader_disk_cache));
204 } 204 }
205 return program_cache_.get(); 205 return program_cache_.get();
206 } 206 }
207 207
208 InProcessCommandBuffer::InProcessCommandBuffer( 208 InProcessCommandBuffer::InProcessCommandBuffer(
209 const scoped_refptr<Service>& service) 209 const scoped_refptr<Service>& service)
210 : command_buffer_id_( 210 : command_buffer_id_(
211 CommandBufferId::FromUnsafeValue(g_next_command_buffer_id.GetNext())), 211 CommandBufferId::FromUnsafeValue(g_next_command_buffer_id.GetNext())),
212 context_lost_(false),
213 delayed_work_pending_(false), 212 delayed_work_pending_(false),
214 image_factory_(nullptr), 213 image_factory_(nullptr),
215 last_put_offset_(-1), 214 last_put_offset_(-1),
216 gpu_memory_buffer_manager_(nullptr), 215 gpu_memory_buffer_manager_(nullptr),
217 next_fence_sync_release_(1), 216 next_fence_sync_release_(1),
218 flushed_fence_sync_release_(0), 217 flushed_fence_sync_release_(0),
219 flush_event_(false, false), 218 flush_event_(false, false),
220 service_(GetInitialService(service)), 219 service_(GetInitialService(service)),
221 fence_sync_wait_event_(false, false), 220 fence_sync_wait_event_(false, false),
222 gpu_thread_weak_ptr_factory_(this) { 221 gpu_thread_weak_ptr_factory_(this) {
223 DCHECK(service_.get()); 222 DCHECK(service_.get());
224 next_image_id_.GetNext(); 223 next_image_id_.GetNext();
225 } 224 }
226 225
227 InProcessCommandBuffer::~InProcessCommandBuffer() { 226 InProcessCommandBuffer::~InProcessCommandBuffer() {
228 Destroy(); 227 Destroy();
229 } 228 }
230 229
231 bool InProcessCommandBuffer::MakeCurrent() { 230 bool InProcessCommandBuffer::MakeCurrent() {
232 CheckSequencedThread(); 231 CheckSequencedThread();
233 command_buffer_lock_.AssertAcquired(); 232 command_buffer_lock_.AssertAcquired();
234 233
235 if (!context_lost_ && decoder_->MakeCurrent()) 234 if (error::IsError(command_buffer_->GetLastState().error)) {
236 return true; 235 DLOG(ERROR) << "MakeCurrent failed because context lost.";
237 DLOG(ERROR) << "Context lost because MakeCurrent failed."; 236 return false;
238 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); 237 }
239 command_buffer_->SetParseError(gpu::error::kLostContext); 238 if (!decoder_->MakeCurrent()) {
240 return false; 239 DLOG(ERROR) << "Context lost because MakeCurrent failed.";
240 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason());
241 command_buffer_->SetParseError(gpu::error::kLostContext);
no sievers 2016/04/06 23:17:23 return false;
danakj 2016/04/06 23:29:38 Oops thanks.
242 }
243 return true;
241 } 244 }
242 245
243 void InProcessCommandBuffer::PumpCommands() { 246 void InProcessCommandBuffer::PumpCommands() {
244 CheckSequencedThread(); 247 CheckSequencedThread();
245 command_buffer_lock_.AssertAcquired(); 248 command_buffer_lock_.AssertAcquired();
246 249
247 if (!MakeCurrent()) 250 if (!MakeCurrent())
248 return; 251 return;
249 252
250 executor_->PutChanged(); 253 executor_->PutChanged();
251 } 254 }
252 255
253 bool InProcessCommandBuffer::GetBufferChanged(int32_t transfer_buffer_id) { 256 bool InProcessCommandBuffer::GetBufferChanged(int32_t transfer_buffer_id) {
254 CheckSequencedThread(); 257 CheckSequencedThread();
255 command_buffer_lock_.AssertAcquired(); 258 command_buffer_lock_.AssertAcquired();
256 command_buffer_->SetGetBuffer(transfer_buffer_id); 259 command_buffer_->SetGetBuffer(transfer_buffer_id);
257 return true; 260 return true;
258 } 261 }
259 262
260 bool InProcessCommandBuffer::Initialize( 263 bool InProcessCommandBuffer::Initialize(
261 scoped_refptr<gfx::GLSurface> surface, 264 scoped_refptr<gfx::GLSurface> surface,
262 bool is_offscreen, 265 bool is_offscreen,
263 gfx::AcceleratedWidget window, 266 gfx::AcceleratedWidget window,
264 const gfx::Size& size, 267 const gfx::Size& size,
265 const std::vector<int32_t>& attribs, 268 const std::vector<int32_t>& attribs,
266 gfx::GpuPreference gpu_preference, 269 gfx::GpuPreference gpu_preference,
267 const base::Closure& context_lost_callback,
268 InProcessCommandBuffer* share_group, 270 InProcessCommandBuffer* share_group,
269 GpuMemoryBufferManager* gpu_memory_buffer_manager, 271 GpuMemoryBufferManager* gpu_memory_buffer_manager,
270 ImageFactory* image_factory) { 272 ImageFactory* image_factory) {
271 DCHECK(!share_group || service_.get() == share_group->service_.get()); 273 DCHECK(!share_group || service_.get() == share_group->service_.get());
272 context_lost_callback_ = WrapCallback(context_lost_callback);
273 274
274 if (surface.get()) { 275 if (surface.get()) {
275 // GPU thread must be the same as client thread due to GLSurface not being 276 // GPU thread must be the same as client thread due to GLSurface not being
276 // thread safe. 277 // thread safe.
277 sequence_checker_.reset(new base::SequenceChecker); 278 sequence_checker_.reset(new base::SequenceChecker);
278 surface_ = surface; 279 surface_ = surface;
279 } 280 }
280 281
281 gpu::Capabilities capabilities; 282 gpu::Capabilities capabilities;
282 InitializeOnGpuThreadParams params(is_offscreen, 283 InitializeOnGpuThreadParams params(is_offscreen,
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 DCHECK(params.size.width() >= 0 && params.size.height() >= 0); 318 DCHECK(params.size.width() >= 0 && params.size.height() >= 0);
318 319
319 TransferBufferManager* manager = new TransferBufferManager(nullptr); 320 TransferBufferManager* manager = new TransferBufferManager(nullptr);
320 transfer_buffer_manager_ = manager; 321 transfer_buffer_manager_ = manager;
321 manager->Initialize(); 322 manager->Initialize();
322 323
323 scoped_ptr<CommandBufferService> command_buffer( 324 scoped_ptr<CommandBufferService> command_buffer(
324 new CommandBufferService(transfer_buffer_manager_.get())); 325 new CommandBufferService(transfer_buffer_manager_.get()));
325 command_buffer->SetPutOffsetChangeCallback(base::Bind( 326 command_buffer->SetPutOffsetChangeCallback(base::Bind(
326 &InProcessCommandBuffer::PumpCommands, gpu_thread_weak_ptr_)); 327 &InProcessCommandBuffer::PumpCommands, gpu_thread_weak_ptr_));
327 command_buffer->SetParseErrorCallback(base::Bind(
328 &InProcessCommandBuffer::OnContextLost, gpu_thread_weak_ptr_));
329 328
330 if (!command_buffer->Initialize()) { 329 if (!command_buffer->Initialize()) {
331 LOG(ERROR) << "Could not initialize command buffer."; 330 LOG(ERROR) << "Could not initialize command buffer.";
332 DestroyOnGpuThread(); 331 DestroyOnGpuThread();
333 return false; 332 return false;
334 } 333 }
335 334
336 gl_share_group_ = params.context_group 335 gl_share_group_ = params.context_group
337 ? params.context_group->gl_share_group_ 336 ? params.context_group->gl_share_group_
338 : service_->share_group(); 337 : service_->share_group();
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 #endif 482 #endif
484 483
485 return true; 484 return true;
486 } 485 }
487 486
488 void InProcessCommandBuffer::CheckSequencedThread() { 487 void InProcessCommandBuffer::CheckSequencedThread() {
489 DCHECK(!sequence_checker_ || 488 DCHECK(!sequence_checker_ ||
490 sequence_checker_->CalledOnValidSequencedThread()); 489 sequence_checker_->CalledOnValidSequencedThread());
491 } 490 }
492 491
493 void InProcessCommandBuffer::OnContextLost() {
494 CheckSequencedThread();
495 if (!context_lost_callback_.is_null()) {
496 context_lost_callback_.Run();
497 context_lost_callback_.Reset();
498 }
499
500 context_lost_ = true;
501 }
502
503 CommandBuffer::State InProcessCommandBuffer::GetStateFast() { 492 CommandBuffer::State InProcessCommandBuffer::GetStateFast() {
504 CheckSequencedThread(); 493 CheckSequencedThread();
505 base::AutoLock lock(state_after_last_flush_lock_); 494 base::AutoLock lock(state_after_last_flush_lock_);
506 if (state_after_last_flush_.generation - last_state_.generation < 0x80000000U) 495 if (state_after_last_flush_.generation - last_state_.generation < 0x80000000U)
507 last_state_ = state_after_last_flush_; 496 last_state_ = state_after_last_flush_;
508 return last_state_; 497 return last_state_;
509 } 498 }
510 499
511 CommandBuffer::State InProcessCommandBuffer::GetLastState() { 500 CommandBuffer::State InProcessCommandBuffer::GetLastState() {
512 CheckSequencedThread(); 501 CheckSequencedThread();
(...skipping 14 matching lines...) Expand all
527 516
528 { 517 {
529 ScopedOrderNumberProcessor scoped_order_num(sync_point_order_data_.get(), 518 ScopedOrderNumberProcessor scoped_order_num(sync_point_order_data_.get(),
530 order_num); 519 order_num);
531 command_buffer_->Flush(put_offset); 520 command_buffer_->Flush(put_offset);
532 { 521 {
533 // Update state before signaling the flush event. 522 // Update state before signaling the flush event.
534 base::AutoLock lock(state_after_last_flush_lock_); 523 base::AutoLock lock(state_after_last_flush_lock_);
535 state_after_last_flush_ = command_buffer_->GetLastState(); 524 state_after_last_flush_ = command_buffer_->GetLastState();
536 } 525 }
537 DCHECK((!error::IsError(state_after_last_flush_.error) && !context_lost_) ||
538 (error::IsError(state_after_last_flush_.error) && context_lost_));
539 526
540 // Currently the in process command buffer does not support being 527 // Currently the in process command buffer does not support being
541 // descheduled, if it does we would need to back off on calling the finish 528 // descheduled, if it does we would need to back off on calling the finish
542 // processing number function until the message is rescheduled and finished 529 // processing number function until the message is rescheduled and finished
543 // processing. This DCHECK is to enforce this. 530 // processing. This DCHECK is to enforce this.
544 DCHECK(context_lost_ || put_offset == state_after_last_flush_.get_offset); 531 DCHECK(error::IsError(state_after_last_flush_.error) ||
532 put_offset == state_after_last_flush_.get_offset);
545 } 533 }
546 534
547 // If we've processed all pending commands but still have pending queries, 535 // If we've processed all pending commands but still have pending queries,
548 // pump idle work until the query is passed. 536 // pump idle work until the query is passed.
549 if (put_offset == state_after_last_flush_.get_offset && 537 if (put_offset == state_after_last_flush_.get_offset &&
550 (executor_->HasMoreIdleWork() || executor_->HasPendingQueries())) { 538 (executor_->HasMoreIdleWork() || executor_->HasPendingQueries())) {
551 ScheduleDelayedWorkOnGpuThread(); 539 ScheduleDelayedWorkOnGpuThread();
552 } 540 }
553 } 541 }
554 542
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
909 DCHECK(query_manager_); 897 DCHECK(query_manager_);
910 898
911 gles2::QueryManager::Query* query = query_manager_->GetQuery(query_id); 899 gles2::QueryManager::Query* query = query_manager_->GetQuery(query_id);
912 if (!query) 900 if (!query)
913 callback.Run(); 901 callback.Run();
914 else 902 else
915 query->AddCallback(callback); 903 query->AddCallback(callback);
916 } 904 }
917 905
918 void InProcessCommandBuffer::SetLock(base::Lock*) { 906 void InProcessCommandBuffer::SetLock(base::Lock*) {
907 // No support for using on multiple threads.
908 NOTREACHED();
919 } 909 }
920 910
921 bool InProcessCommandBuffer::IsGpuChannelLost() { 911 bool InProcessCommandBuffer::IsGpuChannelLost() {
922 // There is no such channel to lose for in-process contexts. This only 912 // There is no such channel to lose for in-process contexts. This only
923 // makes sense for out-of-process command buffers. 913 // makes sense for out-of-process command buffers.
924 return false; 914 return false;
925 } 915 }
926 916
927 void InProcessCommandBuffer::EnsureWorkVisible() { 917 void InProcessCommandBuffer::EnsureWorkVisible() {
928 // This is only relevant for out-of-process command buffers. 918 // This is only relevant for out-of-process command buffers.
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
1091 framebuffer_completeness_cache_ = 1081 framebuffer_completeness_cache_ =
1092 new gpu::gles2::FramebufferCompletenessCache; 1082 new gpu::gles2::FramebufferCompletenessCache;
1093 return framebuffer_completeness_cache_; 1083 return framebuffer_completeness_cache_;
1094 } 1084 }
1095 1085
1096 SyncPointManager* GpuInProcessThread::sync_point_manager() { 1086 SyncPointManager* GpuInProcessThread::sync_point_manager() {
1097 return sync_point_manager_; 1087 return sync_point_manager_;
1098 } 1088 }
1099 1089
1100 } // namespace gpu 1090 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/in_process_command_buffer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698