Chromium Code Reviews| 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 24 matching lines...) Expand all Loading... | |
| 35 #include "gpu/command_buffer/service/buffer_manager.h" | 35 #include "gpu/command_buffer/service/buffer_manager.h" |
| 36 #include "gpu/command_buffer/service/cmd_buffer_engine.h" | 36 #include "gpu/command_buffer/service/cmd_buffer_engine.h" |
| 37 #include "gpu/command_buffer/service/context_group.h" | 37 #include "gpu/command_buffer/service/context_group.h" |
| 38 #include "gpu/command_buffer/service/context_state.h" | 38 #include "gpu/command_buffer/service/context_state.h" |
| 39 #include "gpu/command_buffer/service/error_state.h" | 39 #include "gpu/command_buffer/service/error_state.h" |
| 40 #include "gpu/command_buffer/service/feature_info.h" | 40 #include "gpu/command_buffer/service/feature_info.h" |
| 41 #include "gpu/command_buffer/service/framebuffer_manager.h" | 41 #include "gpu/command_buffer/service/framebuffer_manager.h" |
| 42 #include "gpu/command_buffer/service/gl_utils.h" | 42 #include "gpu/command_buffer/service/gl_utils.h" |
| 43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" | 43 #include "gpu/command_buffer/service/gles2_cmd_copy_texture_chromium.h" |
| 44 #include "gpu/command_buffer/service/gles2_cmd_validation.h" | 44 #include "gpu/command_buffer/service/gles2_cmd_validation.h" |
| 45 #include "gpu/command_buffer/service/gpu_state_tracer.h" | |
| 45 #include "gpu/command_buffer/service/gpu_switches.h" | 46 #include "gpu/command_buffer/service/gpu_switches.h" |
| 46 #include "gpu/command_buffer/service/gpu_tracer.h" | 47 #include "gpu/command_buffer/service/gpu_tracer.h" |
| 47 #include "gpu/command_buffer/service/image_manager.h" | 48 #include "gpu/command_buffer/service/image_manager.h" |
| 48 #include "gpu/command_buffer/service/mailbox_manager.h" | 49 #include "gpu/command_buffer/service/mailbox_manager.h" |
| 49 #include "gpu/command_buffer/service/memory_tracking.h" | 50 #include "gpu/command_buffer/service/memory_tracking.h" |
| 50 #include "gpu/command_buffer/service/program_manager.h" | 51 #include "gpu/command_buffer/service/program_manager.h" |
| 51 #include "gpu/command_buffer/service/query_manager.h" | 52 #include "gpu/command_buffer/service/query_manager.h" |
| 52 #include "gpu/command_buffer/service/renderbuffer_manager.h" | 53 #include "gpu/command_buffer/service/renderbuffer_manager.h" |
| 53 #include "gpu/command_buffer/service/shader_manager.h" | 54 #include "gpu/command_buffer/service/shader_manager.h" |
| 54 #include "gpu/command_buffer/service/shader_translator.h" | 55 #include "gpu/command_buffer/service/shader_translator.h" |
| (...skipping 1603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1658 GLsizei viewport_max_height_; | 1659 GLsizei viewport_max_height_; |
| 1659 | 1660 |
| 1660 // Command buffer stats. | 1661 // Command buffer stats. |
| 1661 base::TimeDelta total_processing_commands_time_; | 1662 base::TimeDelta total_processing_commands_time_; |
| 1662 | 1663 |
| 1663 // States related to each manager. | 1664 // States related to each manager. |
| 1664 DecoderTextureState texture_state_; | 1665 DecoderTextureState texture_state_; |
| 1665 DecoderFramebufferState framebuffer_state_; | 1666 DecoderFramebufferState framebuffer_state_; |
| 1666 | 1667 |
| 1667 scoped_ptr<GPUTracer> gpu_tracer_; | 1668 scoped_ptr<GPUTracer> gpu_tracer_; |
| 1669 scoped_ptr<GPUStateTracer> gpu_state_tracer_; | |
| 1668 | 1670 |
| 1669 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_; | 1671 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_; |
| 1670 | 1672 |
| 1671 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1673 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
| 1672 }; | 1674 }; |
| 1673 | 1675 |
| 1674 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor( | 1676 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor( |
| 1675 const char* function_name, GLES2DecoderImpl* decoder) | 1677 const char* function_name, GLES2DecoderImpl* decoder) |
| 1676 : function_name_(function_name), | 1678 : function_name_(function_name), |
| 1677 decoder_(decoder) { | 1679 decoder_(decoder) { |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2122 const gfx::Size& size, | 2124 const gfx::Size& size, |
| 2123 const DisallowedFeatures& disallowed_features, | 2125 const DisallowedFeatures& disallowed_features, |
| 2124 const char* allowed_extensions, | 2126 const char* allowed_extensions, |
| 2125 const std::vector<int32>& attribs) { | 2127 const std::vector<int32>& attribs) { |
| 2126 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 2128 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
| 2127 DCHECK(context->IsCurrent(surface.get())); | 2129 DCHECK(context->IsCurrent(surface.get())); |
| 2128 DCHECK(!context_.get()); | 2130 DCHECK(!context_.get()); |
| 2129 | 2131 |
| 2130 set_initialized(); | 2132 set_initialized(); |
| 2131 gpu_tracer_ = GPUTracer::Create(); | 2133 gpu_tracer_ = GPUTracer::Create(); |
| 2134 gpu_state_tracer_ = GPUStateTracer::Create(&state_); | |
| 2132 | 2135 |
| 2133 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2136 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2134 switches::kEnableGPUDebugging)) { | 2137 switches::kEnableGPUDebugging)) { |
| 2135 set_debug(true); | 2138 set_debug(true); |
| 2136 } | 2139 } |
| 2137 | 2140 |
| 2138 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2141 if (CommandLine::ForCurrentProcess()->HasSwitch( |
| 2139 switches::kEnableGPUCommandLogging)) { | 2142 switches::kEnableGPUCommandLogging)) { |
| 2140 set_log_commands(true); | 2143 set_log_commands(true); |
| 2141 } | 2144 } |
| (...skipping 4834 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 6976 | 6979 |
| 6977 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 6980 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
| 6978 uint32 immediate_data_size, const cmds::PostSubBufferCHROMIUM& c) { | 6981 uint32 immediate_data_size, const cmds::PostSubBufferCHROMIUM& c) { |
| 6979 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); | 6982 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); |
| 6980 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { | 6983 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { |
| 6981 LOCAL_SET_GL_ERROR( | 6984 LOCAL_SET_GL_ERROR( |
| 6982 GL_INVALID_OPERATION, | 6985 GL_INVALID_OPERATION, |
| 6983 "glPostSubBufferCHROMIUM", "command not supported by surface"); | 6986 "glPostSubBufferCHROMIUM", "command not supported by surface"); |
| 6984 return error::kNoError; | 6987 return error::kNoError; |
| 6985 } | 6988 } |
| 6989 bool is_tracing; | |
| 6990 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), | |
| 6991 &is_tracing); | |
| 6992 if (is_tracing) { | |
| 6993 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | |
| 6994 ScopedFrameBufferBinder binder(this, 0); | |
|
piman
2013/09/10 17:40:08
you want GetBackbufferServiceId() rather than 0, t
Sami
2013/09/10 17:45:29
Great point, done.
| |
| 6995 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( | |
| 6996 is_offscreen ? offscreen_size_ : surface_->GetSize()); | |
| 6997 } | |
| 6986 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { | 6998 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { |
| 6987 return error::kNoError; | 6999 return error::kNoError; |
| 6988 } else { | 7000 } else { |
| 6989 LOG(ERROR) << "Context lost because PostSubBuffer failed."; | 7001 LOG(ERROR) << "Context lost because PostSubBuffer failed."; |
| 6990 return error::kLostContext; | 7002 return error::kLostContext; |
| 6991 } | 7003 } |
| 6992 } | 7004 } |
| 6993 | 7005 |
| 6994 error::Error GLES2DecoderImpl::GetAttribLocationHelper( | 7006 error::Error GLES2DecoderImpl::GetAttribLocationHelper( |
| 6995 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 7007 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
| (...skipping 1572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 8568 int this_frame_number = frame_number_++; | 8580 int this_frame_number = frame_number_++; |
| 8569 // TRACE_EVENT for gpu tests: | 8581 // TRACE_EVENT for gpu tests: |
| 8570 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", | 8582 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", |
| 8571 TRACE_EVENT_SCOPE_THREAD, | 8583 TRACE_EVENT_SCOPE_THREAD, |
| 8572 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), | 8584 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), |
| 8573 "width", (is_offscreen ? offscreen_size_.width() : | 8585 "width", (is_offscreen ? offscreen_size_.width() : |
| 8574 surface_->GetSize().width())); | 8586 surface_->GetSize().width())); |
| 8575 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoSwapBuffers", | 8587 TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoSwapBuffers", |
| 8576 "offscreen", is_offscreen, | 8588 "offscreen", is_offscreen, |
| 8577 "frame", this_frame_number); | 8589 "frame", this_frame_number); |
| 8590 bool is_tracing; | |
| 8591 TRACE_EVENT_CATEGORY_GROUP_ENABLED(TRACE_DISABLED_BY_DEFAULT("gpu.debug"), | |
| 8592 &is_tracing); | |
| 8593 if (is_tracing) { | |
| 8594 ScopedFrameBufferBinder binder(this, 0); | |
| 8595 gpu_state_tracer_->TakeSnapshotWithCurrentFramebuffer( | |
| 8596 is_offscreen ? offscreen_size_ : surface_->GetSize()); | |
| 8597 } | |
| 8598 | |
| 8578 // If offscreen then don't actually SwapBuffers to the display. Just copy | 8599 // If offscreen then don't actually SwapBuffers to the display. Just copy |
| 8579 // the rendered frame to another frame buffer. | 8600 // the rendered frame to another frame buffer. |
| 8580 if (is_offscreen) { | 8601 if (is_offscreen) { |
| 8581 TRACE_EVENT2("gpu", "Offscreen", | 8602 TRACE_EVENT2("gpu", "Offscreen", |
| 8582 "width", offscreen_size_.width(), "height", offscreen_size_.height()); | 8603 "width", offscreen_size_.width(), "height", offscreen_size_.height()); |
| 8583 if (offscreen_size_ != offscreen_saved_color_texture_->size()) { | 8604 if (offscreen_size_ != offscreen_saved_color_texture_->size()) { |
| 8584 // Workaround for NVIDIA driver bug on OS X; crbug.com/89557, | 8605 // Workaround for NVIDIA driver bug on OS X; crbug.com/89557, |
| 8585 // crbug.com/94163. TODO(kbr): figure out reproduction so Apple will | 8606 // crbug.com/94163. TODO(kbr): figure out reproduction so Apple will |
| 8586 // fix this. | 8607 // fix this. |
| 8587 if (workarounds().needs_offscreen_buffer_workaround) { | 8608 if (workarounds().needs_offscreen_buffer_workaround) { |
| (...skipping 1676 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 10264 return error::kNoError; | 10285 return error::kNoError; |
| 10265 } | 10286 } |
| 10266 | 10287 |
| 10267 // Include the auto-generated part of this file. We split this because it means | 10288 // Include the auto-generated part of this file. We split this because it means |
| 10268 // we can easily edit the non-auto generated parts right here in this file | 10289 // we can easily edit the non-auto generated parts right here in this file |
| 10269 // instead of having to edit some template or the code generator. | 10290 // instead of having to edit some template or the code generator. |
| 10270 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 10291 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 10271 | 10292 |
| 10272 } // namespace gles2 | 10293 } // namespace gles2 |
| 10273 } // namespace gpu | 10294 } // namespace gpu |
| OLD | NEW |