| 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/service/gles2_cmd_decoder.h" | 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" |
| 6 | 6 |
| 7 #include <stdio.h> | 7 #include <stdio.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <list> | 10 #include <list> |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 #include "gpu/command_buffer/service/buffer_manager.h" | 33 #include "gpu/command_buffer/service/buffer_manager.h" |
| 34 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 34 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 35 #include "gpu/command_buffer/service/context_group.h" | 35 #include "gpu/command_buffer/service/context_group.h" |
| 36 #include "gpu/command_buffer/service/context_state.h" | 36 #include "gpu/command_buffer/service/context_state.h" |
| 37 #include "gpu/command_buffer/service/feature_info.h" | 37 #include "gpu/command_buffer/service/feature_info.h" |
| 38 #include "gpu/command_buffer/service/framebuffer_manager.h" | 38 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 39 #include "gpu/command_buffer/service/gl_utils.h" | 39 #include "gpu/command_buffer/service/gl_utils.h" |
| 40 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 40 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 41 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 41 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 42 #include "gpu/command_buffer/service/gpu_switches.h" | 42 #include "gpu/command_buffer/service/gpu_switches.h" |
| 43 #include "gpu/command_buffer/service/gpu_trace.h" | 43 #include "gpu/command_buffer/service/gpu_tracer.h" |
| 44 #include "gpu/command_buffer/service/image_manager.h" | 44 #include "gpu/command_buffer/service/image_manager.h" |
| 45 #include "gpu/command_buffer/service/mailbox_manager.h" | 45 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 46 #include "gpu/command_buffer/service/memory_tracking.h" | 46 #include "gpu/command_buffer/service/memory_tracking.h" |
| 47 #include "gpu/command_buffer/service/program_manager.h" | 47 #include "gpu/command_buffer/service/program_manager.h" |
| 48 #include "gpu/command_buffer/service/query_manager.h" | 48 #include "gpu/command_buffer/service/query_manager.h" |
| 49 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 49 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 50 #include "gpu/command_buffer/service/shader_manager.h" | 50 #include "gpu/command_buffer/service/shader_manager.h" |
| 51 #include "gpu/command_buffer/service/shader_translator.h" | 51 #include "gpu/command_buffer/service/shader_translator.h" |
| 52 #include "gpu/command_buffer/service/shader_translator_cache.h" | 52 #include "gpu/command_buffer/service/shader_translator_cache.h" |
| 53 #include "gpu/command_buffer/service/stream_texture.h" | 53 #include "gpu/command_buffer/service/stream_texture.h" |
| (...skipping 1610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1664 | 1664 |
| 1665 // Cached values of the currently assigned viewport dimensions. | 1665 // Cached values of the currently assigned viewport dimensions. |
| 1666 GLsizei viewport_max_width_; | 1666 GLsizei viewport_max_width_; |
| 1667 GLsizei viewport_max_height_; | 1667 GLsizei viewport_max_height_; |
| 1668 | 1668 |
| 1669 // Command buffer stats. | 1669 // Command buffer stats. |
| 1670 int texture_upload_count_; | 1670 int texture_upload_count_; |
| 1671 base::TimeDelta total_texture_upload_time_; | 1671 base::TimeDelta total_texture_upload_time_; |
| 1672 base::TimeDelta total_processing_commands_time_; | 1672 base::TimeDelta total_processing_commands_time_; |
| 1673 | 1673 |
| 1674 std::stack<linked_ptr<GPUTrace> > gpu_trace_stack_; | 1674 scoped_ptr<GPUTracer> gpu_tracer_; |
| 1675 | 1675 |
| 1676 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1676 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
| 1677 }; | 1677 }; |
| 1678 | 1678 |
| 1679 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1679 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
| 1680 : decoder_(decoder) { | 1680 : decoder_(decoder) { |
| 1681 decoder_->CopyRealGLErrorsToWrapper(); | 1681 decoder_->CopyRealGLErrorsToWrapper(); |
| 1682 } | 1682 } |
| 1683 | 1683 |
| 1684 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 1684 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
| (...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2111 const scoped_refptr<gfx::GLContext>& context, | 2111 const scoped_refptr<gfx::GLContext>& context, |
| 2112 bool offscreen, | 2112 bool offscreen, |
| 2113 const gfx::Size& size, | 2113 const gfx::Size& size, |
| 2114 const DisallowedFeatures& disallowed_features, | 2114 const DisallowedFeatures& disallowed_features, |
| 2115 const char* allowed_extensions, | 2115 const char* allowed_extensions, |
| 2116 const std::vector<int32>& attribs) { | 2116 const std::vector<int32>& attribs) { |
| 2117 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 2117 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
| 2118 DCHECK(context->IsCurrent(surface.get())); | 2118 DCHECK(context->IsCurrent(surface.get())); |
| 2119 DCHECK(!context_.get()); | 2119 DCHECK(!context_.get()); |
| 2120 | 2120 |
| 2121 gpu_tracer_ = GPUTracer::Create(); |
| 2122 |
| 2121 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2123 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2122 switches::kEnableGPUDebugging)) { | 2124 switches::kEnableGPUDebugging)) { |
| 2123 set_debug(true); | 2125 set_debug(true); |
| 2124 } | 2126 } |
| 2125 | 2127 |
| 2126 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2128 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2127 switches::kEnableGPUCommandLogging)) { | 2129 switches::kEnableGPUCommandLogging)) { |
| 2128 set_log_commands(true); | 2130 set_log_commands(true); |
| 2129 } | 2131 } |
| 2130 | 2132 |
| (...skipping 4644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6775 } | 6777 } |
| 6776 | 6778 |
| 6777 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 6779 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
| 6778 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { | 6780 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { |
| 6779 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); | 6781 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); |
| 6780 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { | 6782 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { |
| 6781 SetGLError(GL_INVALID_OPERATION, | 6783 SetGLError(GL_INVALID_OPERATION, |
| 6782 "glPostSubBufferCHROMIUM", "command not supported by surface"); | 6784 "glPostSubBufferCHROMIUM", "command not supported by surface"); |
| 6783 return error::kNoError; | 6785 return error::kNoError; |
| 6784 } | 6786 } |
| 6787 |
| 6785 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { | 6788 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { |
| 6786 return error::kNoError; | 6789 return error::kNoError; |
| 6787 } else { | 6790 } else { |
| 6788 LOG(ERROR) << "Context lost because PostSubBuffer failed."; | 6791 LOG(ERROR) << "Context lost because PostSubBuffer failed."; |
| 6789 return error::kLostContext; | 6792 return error::kLostContext; |
| 6790 } | 6793 } |
| 6791 } | 6794 } |
| 6792 | 6795 |
| 6793 error::Error GLES2DecoderImpl::GetAttribLocationHelper( | 6796 error::Error GLES2DecoderImpl::GetAttribLocationHelper( |
| 6794 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 6797 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| (...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9639 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( | 9642 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( |
| 9640 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { | 9643 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { |
| 9641 Bucket* bucket = GetBucket(c.bucket_id); | 9644 Bucket* bucket = GetBucket(c.bucket_id); |
| 9642 if (!bucket || bucket->size() == 0) { | 9645 if (!bucket || bucket->size() == 0) { |
| 9643 return error::kInvalidArguments; | 9646 return error::kInvalidArguments; |
| 9644 } | 9647 } |
| 9645 std::string command_name; | 9648 std::string command_name; |
| 9646 if (!bucket->GetAsString(&command_name)) { | 9649 if (!bucket->GetAsString(&command_name)) { |
| 9647 return error::kInvalidArguments; | 9650 return error::kInvalidArguments; |
| 9648 } | 9651 } |
| 9649 | 9652 TRACE_EVENT_COPY_ASYNC_BEGIN0("gpu", command_name.c_str(), this); |
| 9650 linked_ptr<GPUTrace> trace(new GPUTrace(command_name)); | 9653 if (!gpu_tracer_->Begin(command_name)) { |
| 9651 trace->EnableStartTrace(); | 9654 SetGLError(GL_INVALID_OPERATION, |
| 9652 gpu_trace_stack_.push(trace); | 9655 "glTraceBeginCHROMIUM", "unable to create begin trace"); |
| 9653 | 9656 return error::kNoError; |
| 9657 } |
| 9654 return error::kNoError; | 9658 return error::kNoError; |
| 9655 } | 9659 } |
| 9656 | 9660 |
| 9657 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { | 9661 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { |
| 9658 if (gpu_trace_stack_.empty()) { | 9662 if (gpu_tracer_->CurrentName().empty()) { |
| 9659 SetGLError(GL_INVALID_OPERATION, | 9663 SetGLError(GL_INVALID_OPERATION, |
| 9660 "glTraceEndCHROMIUM", "no trace begin found"); | 9664 "glTraceEndCHROMIUM", "no trace begin found"); |
| 9661 return; | 9665 return; |
| 9662 } | 9666 } |
| 9663 | 9667 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); |
| 9664 linked_ptr<GPUTrace> trace = gpu_trace_stack_.top(); | 9668 gpu_tracer_->End(); |
| 9665 trace->EnableEndTrace(); | |
| 9666 gpu_trace_stack_.pop(); | |
| 9667 } | 9669 } |
| 9668 | 9670 |
| 9669 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( | 9671 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( |
| 9670 uint32 immediate_data_size, const gles2::AsyncTexImage2DCHROMIUM& c) { | 9672 uint32 immediate_data_size, const gles2::AsyncTexImage2DCHROMIUM& c) { |
| 9671 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); | 9673 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); |
| 9672 | 9674 |
| 9673 // TODO: This is a copy of HandleTexImage2D validation. Merge | 9675 // TODO: This is a copy of HandleTexImage2D validation. Merge |
| 9674 // as much of it as possible. | 9676 // as much of it as possible. |
| 9675 tex_image_2d_failed_ = true; | 9677 tex_image_2d_failed_ = true; |
| 9676 GLenum target = static_cast<GLenum>(c.target); | 9678 GLenum target = static_cast<GLenum>(c.target); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9736 target, level, xoffset, yoffset, width, height, format, type, pixels); | 9738 target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 9737 } | 9739 } |
| 9738 | 9740 |
| 9739 // Include the auto-generated part of this file. We split this because it means | 9741 // Include the auto-generated part of this file. We split this because it means |
| 9740 // we can easily edit the non-auto generated parts right here in this file | 9742 // we can easily edit the non-auto generated parts right here in this file |
| 9741 // instead of having to edit some template or the code generator. | 9743 // instead of having to edit some template or the code generator. |
| 9742 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9744 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9743 | 9745 |
| 9744 } // namespace gles2 | 9746 } // namespace gles2 |
| 9745 } // namespace gpu | 9747 } // namespace gpu |
| OLD | NEW |