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

Side by Side Diff: gpu/command_buffer/tests/gl_manager.cc

Issue 2550583002: gpu: Thread-safe command buffer state lookup. (Closed)
Patch Set: jbauman's review Created 4 years 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/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_readback_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/tests/gl_manager.h" 5 #include "gpu/command_buffer/tests/gl_manager.h"
6 6
7 #include <GLES2/gl2.h> 7 #include <GLES2/gl2.h>
8 #include <GLES2/gl2ext.h> 8 #include <GLES2/gl2ext.h>
9 #include <GLES2/gl2extchromium.h> 9 #include <GLES2/gl2extchromium.h>
10 #include <stddef.h> 10 #include <stddef.h>
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 base_share_group_->get(), base_surface_->get(), 421 base_share_group_->get(), base_surface_->get(),
422 gl::GLContextAttribs())); 422 gl::GLContextAttribs()));
423 #endif 423 #endif
424 } 424 }
425 ++use_count_; 425 ++use_count_;
426 } 426 }
427 427
428 void GLManager::OnFenceSyncRelease(uint64_t release) { 428 void GLManager::OnFenceSyncRelease(uint64_t release) {
429 DCHECK(sync_point_client_); 429 DCHECK(sync_point_client_);
430 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release)); 430 DCHECK(!sync_point_client_->client_state()->IsFenceSyncReleased(release));
431 command_buffer_->SetReleaseCount(release);
431 sync_point_client_->ReleaseFenceSync(release); 432 sync_point_client_->ReleaseFenceSync(release);
432 } 433 }
433 434
434 bool GLManager::OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id, 435 bool GLManager::OnWaitFenceSync(gpu::CommandBufferNamespace namespace_id,
435 gpu::CommandBufferId command_buffer_id, 436 gpu::CommandBufferId command_buffer_id,
436 uint64_t release) { 437 uint64_t release) {
437 DCHECK(sync_point_client_); 438 DCHECK(sync_point_client_);
438 scoped_refptr<gpu::SyncPointClientState> release_state = 439 scoped_refptr<gpu::SyncPointClientState> release_state =
439 sync_point_manager_->GetSyncPointClientState(namespace_id, 440 sync_point_manager_->GetSyncPointClientState(namespace_id,
440 command_buffer_id); 441 command_buffer_id);
441 if (!release_state) 442 if (!release_state)
442 return true; 443 return true;
443 444
444 // GLManager does not support being multithreaded at this point, so the fence 445 // GLManager does not support being multithreaded at this point, so the fence
445 // sync must be released by the time wait is called. 446 // sync must be released by the time wait is called.
446 DCHECK(release_state->IsFenceSyncReleased(release)); 447 DCHECK(release_state->IsFenceSyncReleased(release));
447 return true; 448 return true;
448 } 449 }
449 450
450 void GLManager::MakeCurrent() { 451 void GLManager::MakeCurrent() {
451 ::gles2::SetGLContext(gles2_implementation_.get()); 452 ::gles2::SetGLContext(gles2_implementation_.get());
452 } 453 }
453 454
454 void GLManager::SetSurface(gl::GLSurface* surface) { 455 void GLManager::SetSurface(gl::GLSurface* surface) {
455 decoder_->SetSurface(surface); 456 decoder_->SetSurface(surface);
456 } 457 }
457 458
459 void GLManager::PerformIdleWork() {
460 executor_->PerformIdleWork();
461 }
462
458 void GLManager::Destroy() { 463 void GLManager::Destroy() {
459 if (gles2_implementation_.get()) { 464 if (gles2_implementation_.get()) {
460 MakeCurrent(); 465 MakeCurrent();
461 EXPECT_TRUE(glGetError() == GL_NONE); 466 EXPECT_TRUE(glGetError() == GL_NONE);
462 gles2_implementation_->Flush(); 467 gles2_implementation_->Flush();
463 gles2_implementation_.reset(); 468 gles2_implementation_.reset();
464 } 469 }
465 transfer_buffer_.reset(); 470 transfer_buffer_.reset();
466 gles2_helper_.reset(); 471 gles2_helper_.reset();
467 command_buffer_.reset(); 472 command_buffer_.reset();
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
626 } 631 }
627 632
628 bool GLManager::IsFenceSyncFlushed(uint64_t release) { 633 bool GLManager::IsFenceSyncFlushed(uint64_t release) {
629 return IsFenceSyncRelease(release); 634 return IsFenceSyncRelease(release);
630 } 635 }
631 636
632 bool GLManager::IsFenceSyncFlushReceived(uint64_t release) { 637 bool GLManager::IsFenceSyncFlushReceived(uint64_t release) {
633 return IsFenceSyncRelease(release); 638 return IsFenceSyncRelease(release);
634 } 639 }
635 640
641 bool GLManager::IsFenceSyncReleased(uint64_t release) {
642 return release <= command_buffer_->GetLastState().release_count;
643 }
644
636 void GLManager::SignalSyncToken(const gpu::SyncToken& sync_token, 645 void GLManager::SignalSyncToken(const gpu::SyncToken& sync_token,
637 const base::Closure& callback) { 646 const base::Closure& callback) {
638 if (sync_point_manager_) { 647 if (sync_point_manager_) {
639 scoped_refptr<gpu::SyncPointClientState> release_state = 648 scoped_refptr<gpu::SyncPointClientState> release_state =
640 sync_point_manager_->GetSyncPointClientState( 649 sync_point_manager_->GetSyncPointClientState(
641 sync_token.namespace_id(), sync_token.command_buffer_id()); 650 sync_token.namespace_id(), sync_token.command_buffer_id());
642 651
643 if (release_state) { 652 if (release_state) {
644 sync_point_client_->WaitOutOfOrder(release_state.get(), 653 sync_point_client_->WaitOutOfOrder(release_state.get(),
645 sync_token.release_count(), callback); 654 sync_token.release_count(), callback);
646 return; 655 return;
647 } 656 }
648 } 657 }
649 658
650 // Something went wrong, just run the callback now. 659 // Something went wrong, just run the callback now.
651 callback.Run(); 660 callback.Run();
652 } 661 }
653 662
654 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { 663 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) {
655 return false; 664 return false;
656 } 665 }
657 666
658 } // namespace gpu 667 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/tests/gl_manager.h ('k') | gpu/command_buffer/tests/gl_readback_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698