| OLD | NEW |
| 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> |
| 11 #include <stdint.h> | 11 #include <stdint.h> |
| 12 | 12 |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/at_exit.h" | 15 #include "base/at_exit.h" |
| 16 #include "base/bind.h" | 16 #include "base/bind.h" |
| 17 #include "base/memory/ref_counted_memory.h" | 17 #include "base/memory/ref_counted_memory.h" |
| 18 #include "gpu/command_buffer/client/gles2_cmd_helper.h" | 18 #include "gpu/command_buffer/client/gles2_cmd_helper.h" |
| 19 #include "gpu/command_buffer/client/gles2_implementation.h" | 19 #include "gpu/command_buffer/client/gles2_implementation.h" |
| 20 #include "gpu/command_buffer/client/gles2_lib.h" | 20 #include "gpu/command_buffer/client/gles2_lib.h" |
| 21 #include "gpu/command_buffer/client/transfer_buffer.h" | 21 #include "gpu/command_buffer/client/transfer_buffer.h" |
| 22 #include "gpu/command_buffer/common/constants.h" | 22 #include "gpu/command_buffer/common/constants.h" |
| 23 #include "gpu/command_buffer/common/gles2_cmd_utils.h" | 23 #include "gpu/command_buffer/common/gles2_cmd_utils.h" |
| 24 #include "gpu/command_buffer/common/sync_token.h" |
| 24 #include "gpu/command_buffer/common/value_state.h" | 25 #include "gpu/command_buffer/common/value_state.h" |
| 25 #include "gpu/command_buffer/service/command_buffer_service.h" | 26 #include "gpu/command_buffer/service/command_buffer_service.h" |
| 26 #include "gpu/command_buffer/service/context_group.h" | 27 #include "gpu/command_buffer/service/context_group.h" |
| 27 #include "gpu/command_buffer/service/gl_context_virtual.h" | 28 #include "gpu/command_buffer/service/gl_context_virtual.h" |
| 28 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" | 29 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 29 #include "gpu/command_buffer/service/gpu_scheduler.h" | 30 #include "gpu/command_buffer/service/gpu_scheduler.h" |
| 30 #include "gpu/command_buffer/service/image_manager.h" | 31 #include "gpu/command_buffer/service/image_manager.h" |
| 31 #include "gpu/command_buffer/service/mailbox_manager_impl.h" | 32 #include "gpu/command_buffer/service/mailbox_manager_impl.h" |
| 32 #include "gpu/command_buffer/service/memory_tracking.h" | 33 #include "gpu/command_buffer/service/memory_tracking.h" |
| 33 #include "gpu/command_buffer/service/sync_point_manager.h" | 34 #include "gpu/command_buffer/service/sync_point_manager.h" |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 115 virtual_manager(NULL), | 116 virtual_manager(NULL), |
| 116 bind_generates_resource(false), | 117 bind_generates_resource(false), |
| 117 lose_context_when_out_of_memory(false), | 118 lose_context_when_out_of_memory(false), |
| 118 context_lost_allowed(false), | 119 context_lost_allowed(false), |
| 119 context_type(gles2::CONTEXT_TYPE_OPENGLES2), | 120 context_type(gles2::CONTEXT_TYPE_OPENGLES2), |
| 120 force_shader_name_hashing(false) {} | 121 force_shader_name_hashing(false) {} |
| 121 | 122 |
| 122 GLManager::GLManager() | 123 GLManager::GLManager() |
| 123 : sync_point_manager_(nullptr), | 124 : sync_point_manager_(nullptr), |
| 124 context_lost_allowed_(false), | 125 context_lost_allowed_(false), |
| 126 pause_commands_(false), |
| 127 paused_order_num_(0), |
| 125 command_buffer_id_(g_next_command_buffer_id++), | 128 command_buffer_id_(g_next_command_buffer_id++), |
| 126 next_fence_sync_release_(1) { | 129 next_fence_sync_release_(1) { |
| 127 SetupBaseContext(); | 130 SetupBaseContext(); |
| 128 } | 131 } |
| 129 | 132 |
| 130 GLManager::~GLManager() { | 133 GLManager::~GLManager() { |
| 131 --use_count_; | 134 --use_count_; |
| 132 if (!use_count_) { | 135 if (!use_count_) { |
| 133 if (base_share_group_) { | 136 if (base_share_group_) { |
| 134 delete base_context_; | 137 delete base_context_; |
| (...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 395 | 398 |
| 396 void GLManager::PumpCommands() { | 399 void GLManager::PumpCommands() { |
| 397 if (!decoder_->MakeCurrent()) { | 400 if (!decoder_->MakeCurrent()) { |
| 398 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); | 401 command_buffer_->SetContextLostReason(decoder_->GetContextLostReason()); |
| 399 command_buffer_->SetParseError(::gpu::error::kLostContext); | 402 command_buffer_->SetParseError(::gpu::error::kLostContext); |
| 400 return; | 403 return; |
| 401 } | 404 } |
| 402 uint32_t order_num = 0; | 405 uint32_t order_num = 0; |
| 403 if (sync_point_manager_) { | 406 if (sync_point_manager_) { |
| 404 // If sync point manager is supported, assign order numbers to commands. | 407 // If sync point manager is supported, assign order numbers to commands. |
| 405 order_num = sync_point_order_data_->GenerateUnprocessedOrderNumber( | 408 if (paused_order_num_) { |
| 406 sync_point_manager_); | 409 // Was previous paused, continue to process the order number. |
| 410 order_num = paused_order_num_; |
| 411 paused_order_num_ = 0; |
| 412 } else { |
| 413 order_num = sync_point_order_data_->GenerateUnprocessedOrderNumber( |
| 414 sync_point_manager_); |
| 415 } |
| 407 sync_point_order_data_->BeginProcessingOrderNumber(order_num); | 416 sync_point_order_data_->BeginProcessingOrderNumber(order_num); |
| 408 } | 417 } |
| 409 | 418 |
| 419 if (pause_commands_) { |
| 420 // Do not process commands, simply store the current order number. |
| 421 paused_order_num_ = order_num; |
| 422 |
| 423 sync_point_order_data_->PauseProcessingOrderNumber(order_num); |
| 424 return; |
| 425 } |
| 426 |
| 410 gpu_scheduler_->PutChanged(); | 427 gpu_scheduler_->PutChanged(); |
| 411 ::gpu::CommandBuffer::State state = command_buffer_->GetLastState(); | 428 ::gpu::CommandBuffer::State state = command_buffer_->GetLastState(); |
| 412 if (!context_lost_allowed_) { | 429 if (!context_lost_allowed_) { |
| 413 ASSERT_EQ(::gpu::error::kNoError, state.error); | 430 ASSERT_EQ(::gpu::error::kNoError, state.error); |
| 414 } | 431 } |
| 415 | 432 |
| 416 if (sync_point_manager_) { | 433 if (sync_point_manager_) { |
| 417 // Finish processing order number here. | 434 // Finish processing order number here. |
| 418 sync_point_order_data_->FinishProcessingOrderNumber(order_num); | 435 sync_point_order_data_->FinishProcessingOrderNumber(order_num); |
| 419 } | 436 } |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 526 bool GLManager::IsFenceSyncFlushed(uint64_t release) { | 543 bool GLManager::IsFenceSyncFlushed(uint64_t release) { |
| 527 return IsFenceSyncRelease(release); | 544 return IsFenceSyncRelease(release); |
| 528 } | 545 } |
| 529 | 546 |
| 530 bool GLManager::IsFenceSyncFlushReceived(uint64_t release) { | 547 bool GLManager::IsFenceSyncFlushReceived(uint64_t release) { |
| 531 return IsFenceSyncRelease(release); | 548 return IsFenceSyncRelease(release); |
| 532 } | 549 } |
| 533 | 550 |
| 534 void GLManager::SignalSyncToken(const gpu::SyncToken& sync_token, | 551 void GLManager::SignalSyncToken(const gpu::SyncToken& sync_token, |
| 535 const base::Closure& callback) { | 552 const base::Closure& callback) { |
| 536 NOTIMPLEMENTED(); | 553 if (sync_point_manager_) { |
| 554 scoped_refptr<gpu::SyncPointClientState> release_state = |
| 555 sync_point_manager_->GetSyncPointClientState( |
| 556 sync_token.namespace_id(), sync_token.command_buffer_id()); |
| 557 |
| 558 if (release_state) { |
| 559 sync_point_client_->WaitOutOfOrder(release_state.get(), |
| 560 sync_token.release_count(), callback); |
| 561 return; |
| 562 } |
| 563 } |
| 564 |
| 565 // Something went wrong, just run the callback now. |
| 566 callback.Run(); |
| 537 } | 567 } |
| 538 | 568 |
| 539 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { | 569 bool GLManager::CanWaitUnverifiedSyncToken(const gpu::SyncToken* sync_token) { |
| 540 return false; | 570 return false; |
| 541 } | 571 } |
| 542 | 572 |
| 543 } // namespace gpu | 573 } // namespace gpu |
| OLD | NEW |