| 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 1599 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1653 | 1653 |
| 1654 // Cached values of the currently assigned viewport dimensions. | 1654 // Cached values of the currently assigned viewport dimensions. |
| 1655 GLsizei viewport_max_width_; | 1655 GLsizei viewport_max_width_; |
| 1656 GLsizei viewport_max_height_; | 1656 GLsizei viewport_max_height_; |
| 1657 | 1657 |
| 1658 // Command buffer stats. | 1658 // Command buffer stats. |
| 1659 int texture_upload_count_; | 1659 int texture_upload_count_; |
| 1660 base::TimeDelta total_texture_upload_time_; | 1660 base::TimeDelta total_texture_upload_time_; |
| 1661 base::TimeDelta total_processing_commands_time_; | 1661 base::TimeDelta total_processing_commands_time_; |
| 1662 | 1662 |
| 1663 std::stack<linked_ptr<GPUTrace> > gpu_trace_stack_; | 1663 scoped_ptr<GPUTracer> gpu_tracer_; |
| 1664 | 1664 |
| 1665 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1665 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
| 1666 }; | 1666 }; |
| 1667 | 1667 |
| 1668 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1668 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
| 1669 : decoder_(decoder) { | 1669 : decoder_(decoder) { |
| 1670 decoder_->CopyRealGLErrorsToWrapper(); | 1670 decoder_->CopyRealGLErrorsToWrapper(); |
| 1671 } | 1671 } |
| 1672 | 1672 |
| 1673 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 1673 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2087 const scoped_refptr<gfx::GLContext>& context, | 2087 const scoped_refptr<gfx::GLContext>& context, |
| 2088 bool offscreen, | 2088 bool offscreen, |
| 2089 const gfx::Size& size, | 2089 const gfx::Size& size, |
| 2090 const DisallowedFeatures& disallowed_features, | 2090 const DisallowedFeatures& disallowed_features, |
| 2091 const char* allowed_extensions, | 2091 const char* allowed_extensions, |
| 2092 const std::vector<int32>& attribs) { | 2092 const std::vector<int32>& attribs) { |
| 2093 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 2093 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
| 2094 DCHECK(context->IsCurrent(surface.get())); | 2094 DCHECK(context->IsCurrent(surface.get())); |
| 2095 DCHECK(!context_.get()); | 2095 DCHECK(!context_.get()); |
| 2096 | 2096 |
| 2097 gpu_tracer_ = GPUTracer::Create(); |
| 2098 |
| 2097 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2099 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2098 switches::kEnableGPUDebugging)) { | 2100 switches::kEnableGPUDebugging)) { |
| 2099 set_debug(true); | 2101 set_debug(true); |
| 2100 } | 2102 } |
| 2101 | 2103 |
| 2102 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2104 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2103 switches::kEnableGPUCommandLogging)) { | 2105 switches::kEnableGPUCommandLogging)) { |
| 2104 set_log_commands(true); | 2106 set_log_commands(true); |
| 2105 } | 2107 } |
| 2106 | 2108 |
| (...skipping 4584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6691 } | 6693 } |
| 6692 | 6694 |
| 6693 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 6695 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
| 6694 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { | 6696 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { |
| 6695 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); | 6697 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); |
| 6696 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { | 6698 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { |
| 6697 SetGLError(GL_INVALID_OPERATION, | 6699 SetGLError(GL_INVALID_OPERATION, |
| 6698 "glPostSubBufferCHROMIUM", "command not supported by surface"); | 6700 "glPostSubBufferCHROMIUM", "command not supported by surface"); |
| 6699 return error::kNoError; | 6701 return error::kNoError; |
| 6700 } | 6702 } |
| 6703 |
| 6701 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { | 6704 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { |
| 6702 return error::kNoError; | 6705 return error::kNoError; |
| 6703 } else { | 6706 } else { |
| 6704 LOG(ERROR) << "Context lost because PostSubBuffer failed."; | 6707 LOG(ERROR) << "Context lost because PostSubBuffer failed."; |
| 6705 return error::kLostContext; | 6708 return error::kLostContext; |
| 6706 } | 6709 } |
| 6707 } | 6710 } |
| 6708 | 6711 |
| 6709 error::Error GLES2DecoderImpl::GetAttribLocationHelper( | 6712 error::Error GLES2DecoderImpl::GetAttribLocationHelper( |
| 6710 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 6713 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| (...skipping 2844 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9555 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( | 9558 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( |
| 9556 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { | 9559 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { |
| 9557 Bucket* bucket = GetBucket(c.bucket_id); | 9560 Bucket* bucket = GetBucket(c.bucket_id); |
| 9558 if (!bucket || bucket->size() == 0) { | 9561 if (!bucket || bucket->size() == 0) { |
| 9559 return error::kInvalidArguments; | 9562 return error::kInvalidArguments; |
| 9560 } | 9563 } |
| 9561 std::string command_name; | 9564 std::string command_name; |
| 9562 if (!bucket->GetAsString(&command_name)) { | 9565 if (!bucket->GetAsString(&command_name)) { |
| 9563 return error::kInvalidArguments; | 9566 return error::kInvalidArguments; |
| 9564 } | 9567 } |
| 9565 | 9568 TRACE_EVENT_COPY_ASYNC_BEGIN0("gpu", command_name.c_str(), this); |
| 9566 linked_ptr<GPUTrace> trace(new GPUTrace(command_name)); | 9569 if (!gpu_tracer_->Begin(command_name)) { |
| 9567 trace->EnableStartTrace(); | 9570 SetGLError(GL_INVALID_OPERATION, |
| 9568 gpu_trace_stack_.push(trace); | 9571 "glTraceBeginCHROMIUM", "unable to create begin trace"); |
| 9569 | 9572 return error::kNoError; |
| 9573 } |
| 9570 return error::kNoError; | 9574 return error::kNoError; |
| 9571 } | 9575 } |
| 9572 | 9576 |
| 9573 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { | 9577 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { |
| 9574 if (gpu_trace_stack_.empty()) { | 9578 if (gpu_tracer_->CurrentName().empty()) { |
| 9575 SetGLError(GL_INVALID_OPERATION, | 9579 SetGLError(GL_INVALID_OPERATION, |
| 9576 "glTraceEndCHROMIUM", "no trace begin found"); | 9580 "glTraceEndCHROMIUM", "no trace begin found"); |
| 9577 return; | 9581 return; |
| 9578 } | 9582 } |
| 9579 | 9583 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); |
| 9580 linked_ptr<GPUTrace> trace = gpu_trace_stack_.top(); | 9584 gpu_tracer_->End(); |
| 9581 trace->EnableEndTrace(); | |
| 9582 gpu_trace_stack_.pop(); | |
| 9583 } | 9585 } |
| 9584 | 9586 |
| 9585 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( | 9587 error::Error GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM( |
| 9586 uint32 immediate_data_size, const gles2::AsyncTexImage2DCHROMIUM& c) { | 9588 uint32 immediate_data_size, const gles2::AsyncTexImage2DCHROMIUM& c) { |
| 9587 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); | 9589 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandleAsyncTexImage2DCHROMIUM"); |
| 9588 | 9590 |
| 9589 // TODO: This is a copy of HandleTexImage2D validation. Merge | 9591 // TODO: This is a copy of HandleTexImage2D validation. Merge |
| 9590 // as much of it as possible. | 9592 // as much of it as possible. |
| 9591 tex_image_2d_failed_ = true; | 9593 tex_image_2d_failed_ = true; |
| 9592 GLenum target = static_cast<GLenum>(c.target); | 9594 GLenum target = static_cast<GLenum>(c.target); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 9652 target, level, xoffset, yoffset, width, height, format, type, pixels); | 9654 target, level, xoffset, yoffset, width, height, format, type, pixels); |
| 9653 } | 9655 } |
| 9654 | 9656 |
| 9655 // Include the auto-generated part of this file. We split this because it means | 9657 // Include the auto-generated part of this file. We split this because it means |
| 9656 // we can easily edit the non-auto generated parts right here in this file | 9658 // we can easily edit the non-auto generated parts right here in this file |
| 9657 // instead of having to edit some template or the code generator. | 9659 // instead of having to edit some template or the code generator. |
| 9658 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9660 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 9659 | 9661 |
| 9660 } // namespace gles2 | 9662 } // namespace gles2 |
| 9661 } // namespace gpu | 9663 } // namespace gpu |
| OLD | NEW |