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

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

Issue 2502423003: Implement basic query functionality in the passthrough command buffer. (Closed)
Patch Set: rebase 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
OLDNEW
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 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num_texture_units); 191 glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &num_texture_units);
192 192
193 active_texture_unit_ = 0; 193 active_texture_unit_ = 0;
194 bound_textures_.resize(num_texture_units, 0); 194 bound_textures_.resize(num_texture_units, 0);
195 195
196 if (group_->gpu_preferences().enable_gpu_driver_debug_logging && 196 if (group_->gpu_preferences().enable_gpu_driver_debug_logging &&
197 feature_info_->feature_flags().khr_debug) { 197 feature_info_->feature_flags().khr_debug) {
198 InitializeGLDebugLogging(); 198 InitializeGLDebugLogging();
199 } 199 }
200 200
201 emulated_extensions_.push_back("GL_CHROMIUM_async_pixel_transfers");
202 emulated_extensions_.push_back("GL_CHROMIUM_command_buffer_query");
203 emulated_extensions_.push_back("GL_CHROMIUM_command_buffer_latency_query");
204 emulated_extensions_.push_back("GL_CHROMIUM_get_error_query");
201 emulated_extensions_.push_back("GL_CHROMIUM_lose_context"); 205 emulated_extensions_.push_back("GL_CHROMIUM_lose_context");
202 emulated_extensions_.push_back("GL_CHROMIUM_pixel_transfer_buffer_object"); 206 emulated_extensions_.push_back("GL_CHROMIUM_pixel_transfer_buffer_object");
203 emulated_extensions_.push_back("GL_CHROMIUM_resource_safe"); 207 emulated_extensions_.push_back("GL_CHROMIUM_resource_safe");
204 emulated_extensions_.push_back("GL_CHROMIUM_strict_attribs"); 208 emulated_extensions_.push_back("GL_CHROMIUM_strict_attribs");
205 emulated_extensions_.push_back("GL_CHROMIUM_texture_mailbox"); 209 emulated_extensions_.push_back("GL_CHROMIUM_texture_mailbox");
206 emulated_extensions_.push_back("GL_CHROMIUM_trace_marker"); 210 emulated_extensions_.push_back("GL_CHROMIUM_trace_marker");
207 BuildExtensionsString(); 211 BuildExtensionsString();
208 212
209 set_initialized(); 213 set_initialized();
210 return true; 214 return true;
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 gpu::gles2::VertexArrayManager* 436 gpu::gles2::VertexArrayManager*
433 GLES2DecoderPassthroughImpl::GetVertexArrayManager() { 437 GLES2DecoderPassthroughImpl::GetVertexArrayManager() {
434 return nullptr; 438 return nullptr;
435 } 439 }
436 440
437 gpu::gles2::ImageManager* GLES2DecoderPassthroughImpl::GetImageManager() { 441 gpu::gles2::ImageManager* GLES2DecoderPassthroughImpl::GetImageManager() {
438 return image_manager_.get(); 442 return image_manager_.get();
439 } 443 }
440 444
441 bool GLES2DecoderPassthroughImpl::HasPendingQueries() const { 445 bool GLES2DecoderPassthroughImpl::HasPendingQueries() const {
442 return false; 446 return !pending_queries_.empty();
443 } 447 }
444 448
445 void GLES2DecoderPassthroughImpl::ProcessPendingQueries(bool did_finish) {} 449 void GLES2DecoderPassthroughImpl::ProcessPendingQueries(bool did_finish) {
450 // TODO(geofflang): If this returned an error, store it somewhere.
451 ProcessQueries(did_finish);
452 }
446 453
447 bool GLES2DecoderPassthroughImpl::HasMoreIdleWork() const { 454 bool GLES2DecoderPassthroughImpl::HasMoreIdleWork() const {
448 return false; 455 return false;
449 } 456 }
450 457
451 void GLES2DecoderPassthroughImpl::PerformIdleWork() {} 458 void GLES2DecoderPassthroughImpl::PerformIdleWork() {}
452 459
453 bool GLES2DecoderPassthroughImpl::HasPollingWork() const { 460 bool GLES2DecoderPassthroughImpl::HasPollingWork() const {
454 return false; 461 return false;
455 } 462 }
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
702 void GLES2DecoderPassthroughImpl::BuildExtensionsString() { 709 void GLES2DecoderPassthroughImpl::BuildExtensionsString() {
703 std::ostringstream combined_string_stream; 710 std::ostringstream combined_string_stream;
704 combined_string_stream << reinterpret_cast<const char*>( 711 combined_string_stream << reinterpret_cast<const char*>(
705 glGetString(GL_EXTENSIONS)) 712 glGetString(GL_EXTENSIONS))
706 << " "; 713 << " ";
707 std::copy(emulated_extensions_.begin(), emulated_extensions_.end(), 714 std::copy(emulated_extensions_.begin(), emulated_extensions_.end(),
708 std::ostream_iterator<std::string>(combined_string_stream, " ")); 715 std::ostream_iterator<std::string>(combined_string_stream, " "));
709 extension_string_ = combined_string_stream.str(); 716 extension_string_ = combined_string_stream.str();
710 } 717 }
711 718
719 void GLES2DecoderPassthroughImpl::InsertError(GLenum error,
720 const std::string&) {
721 // Message ignored for now
722 errors_.insert(error);
723 }
724
725 GLenum GLES2DecoderPassthroughImpl::PopError() {
726 GLenum error = GL_NO_ERROR;
727 if (!errors_.empty()) {
728 error = *errors_.begin();
729 errors_.erase(errors_.begin());
730 }
731 return error;
732 }
733
734 bool GLES2DecoderPassthroughImpl::FlushErrors() {
735 bool had_error = false;
736 GLenum error = glGetError();
737 while (error != GL_NO_ERROR) {
738 errors_.insert(error);
739 had_error = true;
740 error = glGetError();
741 }
742 return had_error;
743 }
744
745 bool GLES2DecoderPassthroughImpl::IsEmulatedQueryTarget(GLenum target) const {
746 // GL_COMMANDS_COMPLETED_CHROMIUM is implemented in ANGLE
747 switch (target) {
748 case GL_COMMANDS_ISSUED_CHROMIUM:
749 case GL_LATENCY_QUERY_CHROMIUM:
750 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM:
751 case GL_GET_ERROR_QUERY_CHROMIUM:
752 return true;
753
754 default:
755 return false;
756 }
757 }
758
759 error::Error GLES2DecoderPassthroughImpl::ProcessQueries(bool did_finish) {
760 while (!pending_queries_.empty()) {
761 const PendingQuery& query = pending_queries_.front();
762 GLint result_available = GL_FALSE;
763 GLuint64 result = 0;
764 switch (query.target) {
765 case GL_COMMANDS_ISSUED_CHROMIUM:
766 result_available = GL_TRUE;
767 result = GL_TRUE;
768 break;
769
770 case GL_LATENCY_QUERY_CHROMIUM:
771 result_available = GL_TRUE;
772 // TODO: time from when the query is ended?
773 result = (base::TimeTicks::Now() - base::TimeTicks()).InMilliseconds();
774 break;
775
776 case GL_ASYNC_PIXEL_PACK_COMPLETED_CHROMIUM:
777 // TODO: Use a fence and do a real async readback
778 result_available = GL_TRUE;
779 result = GL_TRUE;
780 break;
781
782 case GL_GET_ERROR_QUERY_CHROMIUM:
783 result_available = GL_TRUE;
784 FlushErrors();
785 result = PopError();
786 break;
787
788 default:
789 DCHECK(!IsEmulatedQueryTarget(query.target));
790 if (did_finish) {
791 result_available = GL_TRUE;
792 } else {
793 glGetQueryObjectiv(query.service_id, GL_QUERY_RESULT_AVAILABLE,
794 &result_available);
795 }
796 if (result_available == GL_TRUE) {
797 glGetQueryObjectui64v(query.service_id, GL_QUERY_RESULT, &result);
798 }
799 break;
800 }
801
802 if (!result_available) {
803 break;
804 }
805
806 QuerySync* sync = GetSharedMemoryAs<QuerySync*>(
807 query.shm_id, query.shm_offset, sizeof(QuerySync));
808 if (sync == nullptr) {
809 pending_queries_.pop_front();
810 return error::kOutOfBounds;
811 }
812
813 // Mark the query as complete
814 sync->result = result;
815 base::subtle::Release_Store(&sync->process_count, query.submit_count);
816 pending_queries_.pop_front();
817 }
818
819 // If glFinish() has been called, all of our queries should be completed.
820 DCHECK(!did_finish || pending_queries_.empty());
821 return error::kNoError;
822 }
823
712 #define GLES2_CMD_OP(name) \ 824 #define GLES2_CMD_OP(name) \
713 { \ 825 { \
714 &GLES2DecoderPassthroughImpl::Handle##name, cmds::name::kArgFlags, \ 826 &GLES2DecoderPassthroughImpl::Handle##name, cmds::name::kArgFlags, \
715 cmds::name::cmd_flags, \ 827 cmds::name::cmd_flags, \
716 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \ 828 sizeof(cmds::name) / sizeof(CommandBufferEntry) - 1, \
717 }, /* NOLINT */ 829 }, /* NOLINT */
718 830
719 const GLES2DecoderPassthroughImpl::CommandInfo 831 const GLES2DecoderPassthroughImpl::CommandInfo
720 GLES2DecoderPassthroughImpl::command_info[] = { 832 GLES2DecoderPassthroughImpl::command_info[] = {
721 GLES2_COMMAND_LIST(GLES2_CMD_OP)}; 833 GLES2_COMMAND_LIST(GLES2_CMD_OP)};
722 834
723 #undef GLES2_CMD_OP 835 #undef GLES2_CMD_OP
724 836
725 } // namespace gles2 837 } // namespace gles2
726 } // namespace gpu 838 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698