| OLD | NEW |
| 1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2016 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/gles2_cmd_decoder_passthrough.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder_passthrough.h" |
| 6 | 6 |
| 7 #include "gpu/command_buffer/service/feature_info.h" | 7 #include "gpu/command_buffer/service/feature_info.h" |
| 8 #include "gpu/command_buffer/service/gl_utils.h" | 8 #include "gpu/command_buffer/service/gl_utils.h" |
| 9 #include "ui/gl/gl_version_info.h" | 9 #include "ui/gl/gl_version_info.h" |
| 10 | 10 |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num_texture_units); | 179 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num_texture_units); |
| 180 | 180 |
| 181 active_texture_unit_ = 0; | 181 active_texture_unit_ = 0; |
| 182 bound_textures_.resize(num_texture_units, 0); | 182 bound_textures_.resize(num_texture_units, 0); |
| 183 | 183 |
| 184 if (group_->gpu_preferences().enable_gpu_driver_debug_logging && | 184 if (group_->gpu_preferences().enable_gpu_driver_debug_logging && |
| 185 feature_info_->feature_flags().khr_debug) { | 185 feature_info_->feature_flags().khr_debug) { |
| 186 InitializeGLDebugLogging(); | 186 InitializeGLDebugLogging(); |
| 187 } | 187 } |
| 188 | 188 |
| 189 emulated_extensions_.push_back("GL_CHROMIUM_async_pixel_transfers"); |
| 190 emulated_extensions_.push_back("GL_CHROMIUM_command_buffer_query"); |
| 191 emulated_extensions_.push_back("GL_CHROMIUM_command_buffer_latency_query"); |
| 192 emulated_extensions_.push_back("GL_CHROMIUM_get_error_query"); |
| 189 emulated_extensions_.push_back("GL_CHROMIUM_lose_context"); | 193 emulated_extensions_.push_back("GL_CHROMIUM_lose_context"); |
| 190 emulated_extensions_.push_back("GL_CHROMIUM_pixel_transfer_buffer_object"); | 194 emulated_extensions_.push_back("GL_CHROMIUM_pixel_transfer_buffer_object"); |
| 191 emulated_extensions_.push_back("GL_CHROMIUM_resource_safe"); | 195 emulated_extensions_.push_back("GL_CHROMIUM_resource_safe"); |
| 192 emulated_extensions_.push_back("GL_CHROMIUM_strict_attribs"); | 196 emulated_extensions_.push_back("GL_CHROMIUM_strict_attribs"); |
| 193 emulated_extensions_.push_back("GL_CHROMIUM_texture_mailbox"); | 197 emulated_extensions_.push_back("GL_CHROMIUM_texture_mailbox"); |
| 194 emulated_extensions_.push_back("GL_CHROMIUM_trace_marker"); | 198 emulated_extensions_.push_back("GL_CHROMIUM_trace_marker"); |
| 195 BuildExtensionsString(); | 199 BuildExtensionsString(); |
| 196 | 200 |
| 197 set_initialized(); | 201 set_initialized(); |
| 198 return true; | 202 return true; |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 420 gpu::gles2::VertexArrayManager* | 424 gpu::gles2::VertexArrayManager* |
| 421 GLES2DecoderPassthroughImpl::GetVertexArrayManager() { | 425 GLES2DecoderPassthroughImpl::GetVertexArrayManager() { |
| 422 return nullptr; | 426 return nullptr; |
| 423 } | 427 } |
| 424 | 428 |
| 425 gpu::gles2::ImageManager* GLES2DecoderPassthroughImpl::GetImageManager() { | 429 gpu::gles2::ImageManager* GLES2DecoderPassthroughImpl::GetImageManager() { |
| 426 return image_manager_.get(); | 430 return image_manager_.get(); |
| 427 } | 431 } |
| 428 | 432 |
| 429 bool GLES2DecoderPassthroughImpl::HasPendingQueries() const { | 433 bool GLES2DecoderPassthroughImpl::HasPendingQueries() const { |
| 430 return false; | 434 return !pending_queries_.empty(); |
| 431 } | 435 } |
| 432 | 436 |
| 433 void GLES2DecoderPassthroughImpl::ProcessPendingQueries(bool did_finish) {} | 437 void GLES2DecoderPassthroughImpl::ProcessPendingQueries(bool did_finish) { |
| 438 // TODO(geofflang): If this returned an error, store it somewhere. |
| 439 ProcessQueries(did_finish); |
| 440 } |
| 434 | 441 |
| 435 bool GLES2DecoderPassthroughImpl::HasMoreIdleWork() const { | 442 bool GLES2DecoderPassthroughImpl::HasMoreIdleWork() const { |
| 436 return false; | 443 return false; |
| 437 } | 444 } |
| 438 | 445 |
| 439 void GLES2DecoderPassthroughImpl::PerformIdleWork() {} | 446 void GLES2DecoderPassthroughImpl::PerformIdleWork() {} |
| 440 | 447 |
| 441 bool GLES2DecoderPassthroughImpl::HasPollingWork() const { | 448 bool GLES2DecoderPassthroughImpl::HasPollingWork() const { |
| 442 return false; | 449 return false; |
| 443 } | 450 } |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 void GLES2DecoderPassthroughImpl::BuildExtensionsString() { | 549 void GLES2DecoderPassthroughImpl::BuildExtensionsString() { |
| 543 std::ostringstream combined_string_stream; | 550 std::ostringstream combined_string_stream; |
| 544 combined_string_stream << reinterpret_cast<const char*>( | 551 combined_string_stream << reinterpret_cast<const char*>( |
| 545 glGetString(GL_EXTENSIONS)) | 552 glGetString(GL_EXTENSIONS)) |
| 546 << " "; | 553 << " "; |
| 547 std::copy(emulated_extensions_.begin(), emulated_extensions_.end(), | 554 std::copy(emulated_extensions_.begin(), emulated_extensions_.end(), |
| 548 std::ostream_iterator<std::string>(combined_string_stream, " ")); | 555 std::ostream_iterator<std::string>(combined_string_stream, " ")); |
| 549 extension_string_ = combined_string_stream.str(); | 556 extension_string_ = combined_string_stream.str(); |
| 550 } | 557 } |
| 551 | 558 |
| 559 void GLES2DecoderPassthroughImpl::InsertError(GLenum error, |
| 560 const std::string&) { |
| 561 // Message ignored for now |
| 562 errors_.insert(error); |
| 563 } |
| 564 |
| 565 GLenum GLES2DecoderPassthroughImpl::PopError() { |
| 566 GLenum error = GL_NO_ERROR; |
| 567 if (!errors_.empty()) { |
| 568 error = *errors_.begin(); |
| 569 errors_.erase(errors_.begin()); |
| 570 } |
| 571 return error; |
| 572 } |
| 573 |
| 574 bool GLES2DecoderPassthroughImpl::FlushErrors() { |
| 575 bool had_error = false; |
| 576 GLenum error = glGetError(); |
| 577 while (error != GL_NO_ERROR) { |
| 578 errors_.insert(error); |
| 579 had_error = true; |
| 580 error = glGetError(); |
| 581 } |
| 582 return had_error; |
| 583 } |
| 584 |
| 585 bool GLES2DecoderPassthroughImpl::IsEmulatedQueryTarget(GLenum target) const { |
| 586 // GL_COMMANDS_COMPLETED_CHROMIUM is implemented in ANGLE |
| 587 switch (target) { |
| 588 case GL_COMMANDS_ISSUED_CHROMIUM: |
| 589 case GL_LATENCY_QUERY_CHROMIUM: |
| 590 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: |
| 591 case GL_GET_ERROR_QUERY_CHROMIUM: |
| 592 return true; |
| 593 |
| 594 default: |
| 595 return false; |
| 596 } |
| 597 } |
| 598 |
| 599 error::Error GLES2DecoderPassthroughImpl::ProcessQueries(bool did_finish) { |
| 600 while (!pending_queries_.empty()) { |
| 601 const PendingQuery& query = pending_queries_.front(); |
| 602 GLint result_available = GL_FALSE; |
| 603 GLuint64 result = 0; |
| 604 switch (query.target) { |
| 605 case GL_COMMANDS_ISSUED_CHROMIUM: |
| 606 result_available = GL_TRUE; |
| 607 result = GL_TRUE; |
| 608 break; |
| 609 |
| 610 case GL_LATENCY_QUERY_CHROMIUM: |
| 611 result_available = GL_TRUE; |
| 612 // TODO: time from when the query is ended? |
| 613 result = (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds(); |
| 614 break; |
| 615 |
| 616 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM: |
| 617 // TODO: Use a fence and do a real async readback |
| 618 result_available = GL_TRUE; |
| 619 result = GL_TRUE; |
| 620 break; |
| 621 |
| 622 case GL_GET_ERROR_QUERY_CHROMIUM: |
| 623 result_available = GL_TRUE; |
| 624 FlushErrors(); |
| 625 result = PopError(); |
| 626 break; |
| 627 |
| 628 default: |
| 629 DCHECK(!IsEmulatedQueryTarget(query.target)); |
| 630 if (did_finish) { |
| 631 result_available = GL_TRUE; |
| 632 } else { |
| 633 glGetQueryObjectiv(query.service_id, GL_QUERY_RESULT_AVAILABLE, |
| 634 &result_available); |
| 635 } |
| 636 if (result_available == GL_TRUE) { |
| 637 glGetQueryObjectui64v(query.service_id, GL_QUERY_RESULT, &result); |
| 638 } |
| 639 break; |
| 640 } |
| 641 |
| 642 if (!result_available) { |
| 643 break; |
| 644 } |
| 645 |
| 646 QuerySync* sync = GetSharedMemoryAs<QuerySync*>( |
| 647 query.shm_id, query.shm_offset, sizeof(QuerySync)); |
| 648 if (sync == nullptr) { |
| 649 pending_queries_.pop_front(); |
| 650 return error::kOutOfBounds; |
| 651 } |
| 652 |
| 653 // Mark the query as complete |
| 654 sync->result = result; |
| 655 base::subtle::Release_Store(&sync->process_count, query.submit_count); |
| 656 pending_queries_.pop_front(); |
| 657 } |
| 658 |
| 659 // If glFinish() has been called, all of our queries should be completed. |
| 660 DCHECK(!did_finish || pending_queries_.empty()); |
| 661 return error::kNoError; |
| 662 } |
| 663 |
| 552 #define GLES2_CMD_OP(name) \ | 664 #define GLES2_CMD_OP(name) \ |
| 553 { \ | 665 { \ |
| 554 &GLES2DecoderPassthroughImpl::Handle##name, cmds::name::kArgFlags, \ | 666 &GLES2DecoderPassthroughImpl::Handle##name, cmds::name::kArgFlags, \ |
| 555 cmds::name::cmd_flags, \ | 667 cmds::name::cmd_flags, \ |
| 556 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ | 668 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ |
| 557 }, /* NOLINT */ | 669 }, /* NOLINT */ |
| 558 | 670 |
| 559 const GLES2DecoderPassthroughImpl::CommandInfo | 671 const GLES2DecoderPassthroughImpl::CommandInfo |
| 560 GLES2DecoderPassthroughImpl::command_info[] = { | 672 GLES2DecoderPassthroughImpl::command_info[] = { |
| 561 GLES2_COMMAND_LIST(GLES2_CMD_OP)}; | 673 GLES2_COMMAND_LIST(GLES2_CMD_OP)}; |
| 562 | 674 |
| 563 #undef GLES2_CMD_OP | 675 #undef GLES2_CMD_OP |
| 564 | 676 |
| 565 } // namespace gles2 | 677 } // namespace gles2 |
| 566 } // namespace gpu | 678 } // namespace gpu |
| OLD | NEW |