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 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1574 | 1574 |
1575 // Cached values of the currently assigned viewport dimensions. | 1575 // Cached values of the currently assigned viewport dimensions. |
1576 GLsizei viewport_max_width_; | 1576 GLsizei viewport_max_width_; |
1577 GLsizei viewport_max_height_; | 1577 GLsizei viewport_max_height_; |
1578 | 1578 |
1579 // Command buffer stats. | 1579 // Command buffer stats. |
1580 int texture_upload_count_; | 1580 int texture_upload_count_; |
1581 base::TimeDelta total_texture_upload_time_; | 1581 base::TimeDelta total_texture_upload_time_; |
1582 base::TimeDelta total_processing_commands_time_; | 1582 base::TimeDelta total_processing_commands_time_; |
1583 | 1583 |
1584 std::stack<linked_ptr<GPUTrace> > gpu_trace_stack_; | 1584 scoped_ptr<GPUTracer> gpu_tracer_; |
1585 | 1585 |
1586 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); | 1586 DISALLOW_COPY_AND_ASSIGN(GLES2DecoderImpl); |
1587 }; | 1587 }; |
1588 | 1588 |
1589 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) | 1589 ScopedGLErrorSuppressor::ScopedGLErrorSuppressor(GLES2DecoderImpl* decoder) |
1590 : decoder_(decoder) { | 1590 : decoder_(decoder) { |
1591 decoder_->CopyRealGLErrorsToWrapper(); | 1591 decoder_->CopyRealGLErrorsToWrapper(); |
1592 } | 1592 } |
1593 | 1593 |
1594 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { | 1594 ScopedGLErrorSuppressor::~ScopedGLErrorSuppressor() { |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2005 const scoped_refptr<gfx::GLContext>& context, | 2005 const scoped_refptr<gfx::GLContext>& context, |
2006 bool offscreen, | 2006 bool offscreen, |
2007 const gfx::Size& size, | 2007 const gfx::Size& size, |
2008 const DisallowedFeatures& disallowed_features, | 2008 const DisallowedFeatures& disallowed_features, |
2009 const char* allowed_extensions, | 2009 const char* allowed_extensions, |
2010 const std::vector<int32>& attribs) { | 2010 const std::vector<int32>& attribs) { |
2011 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); | 2011 TRACE_EVENT0("gpu", "GLES2DecoderImpl::Initialize"); |
2012 DCHECK(context->IsCurrent(surface.get())); | 2012 DCHECK(context->IsCurrent(surface.get())); |
2013 DCHECK(!context_.get()); | 2013 DCHECK(!context_.get()); |
2014 | 2014 |
| 2015 gpu_tracer_ = GPUTracer::Create(); |
| 2016 |
2015 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2017 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2016 switches::kEnableGPUDebugging)) { | 2018 switches::kEnableGPUDebugging)) { |
2017 set_debug(true); | 2019 set_debug(true); |
2018 } | 2020 } |
2019 | 2021 |
2020 if (CommandLine::ForCurrentProcess()->HasSwitch( | 2022 if (CommandLine::ForCurrentProcess()->HasSwitch( |
2021 switches::kEnableGPUCommandLogging)) { | 2023 switches::kEnableGPUCommandLogging)) { |
2022 set_log_commands(true); | 2024 set_log_commands(true); |
2023 } | 2025 } |
2024 | 2026 |
(...skipping 4471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6496 } | 6498 } |
6497 | 6499 |
6498 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( | 6500 error::Error GLES2DecoderImpl::HandlePostSubBufferCHROMIUM( |
6499 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { | 6501 uint32 immediate_data_size, const gles2::PostSubBufferCHROMIUM& c) { |
6500 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); | 6502 TRACE_EVENT0("gpu", "GLES2DecoderImpl::HandlePostSubBufferCHROMIUM"); |
6501 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { | 6503 if (!surface_->HasExtension("GL_CHROMIUM_post_sub_buffer")) { |
6502 SetGLError(GL_INVALID_OPERATION, | 6504 SetGLError(GL_INVALID_OPERATION, |
6503 "glPostSubBufferCHROMIUM", "command not supported by surface"); | 6505 "glPostSubBufferCHROMIUM", "command not supported by surface"); |
6504 return error::kNoError; | 6506 return error::kNoError; |
6505 } | 6507 } |
| 6508 |
| 6509 if (gpu_tracer_.get()) |
| 6510 gpu_tracer_->Process(); |
| 6511 |
6506 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { | 6512 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { |
6507 return error::kNoError; | 6513 return error::kNoError; |
6508 } else { | 6514 } else { |
6509 LOG(ERROR) << "Context lost because PostSubBuffer failed."; | 6515 LOG(ERROR) << "Context lost because PostSubBuffer failed."; |
6510 return error::kLostContext; | 6516 return error::kLostContext; |
6511 } | 6517 } |
6512 } | 6518 } |
6513 | 6519 |
6514 error::Error GLES2DecoderImpl::GetAttribLocationHelper( | 6520 error::Error GLES2DecoderImpl::GetAttribLocationHelper( |
6515 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, | 6521 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, |
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
8179 #endif | 8185 #endif |
8180 } | 8186 } |
8181 | 8187 |
8182 error::Error GLES2DecoderImpl::HandleSwapBuffers( | 8188 error::Error GLES2DecoderImpl::HandleSwapBuffers( |
8183 uint32 immediate_data_size, const gles2::SwapBuffers& c) { | 8189 uint32 immediate_data_size, const gles2::SwapBuffers& c) { |
8184 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); | 8190 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); |
8185 if (!is_offscreen && surface_->DeferSwapBuffers()) { | 8191 if (!is_offscreen && surface_->DeferSwapBuffers()) { |
8186 return error::kDeferCommandUntilLater; | 8192 return error::kDeferCommandUntilLater; |
8187 } | 8193 } |
8188 | 8194 |
| 8195 if (gpu_tracer_.get()) |
| 8196 gpu_tracer_->Process(); |
| 8197 |
8189 int this_frame_number = frame_number_++; | 8198 int this_frame_number = frame_number_++; |
8190 // TRACE_EVENT for gpu tests: | 8199 // TRACE_EVENT for gpu tests: |
8191 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", | 8200 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", |
8192 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), | 8201 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), |
8193 "width", (is_offscreen ? offscreen_size_.width() : | 8202 "width", (is_offscreen ? offscreen_size_.width() : |
8194 surface_->GetSize().width())); | 8203 surface_->GetSize().width())); |
8195 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers", | 8204 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers", |
8196 "offscreen", is_offscreen, | 8205 "offscreen", is_offscreen, |
8197 "frame", this_frame_number); | 8206 "frame", this_frame_number); |
8198 // If offscreen then don't actually SwapBuffers to the display. Just copy | 8207 // If offscreen then don't actually SwapBuffers to the display. Just copy |
(...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9335 | 9344 |
9336 gl_image->ReleaseTexImage(); | 9345 gl_image->ReleaseTexImage(); |
9337 | 9346 |
9338 texture_manager()->SetLevelInfo( | 9347 texture_manager()->SetLevelInfo( |
9339 info, target, 0, GL_RGBA, 0, 0, 1, 0, | 9348 info, target, 0, GL_RGBA, 0, 0, 1, 0, |
9340 GL_RGBA, GL_UNSIGNED_BYTE, false); | 9349 GL_RGBA, GL_UNSIGNED_BYTE, false); |
9341 } | 9350 } |
9342 | 9351 |
9343 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( | 9352 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( |
9344 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { | 9353 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { |
| 9354 TRACE_EVENT_ASYNC_BEGIN0("gpu", "GLES2DecoderImpl::Trace", this); |
| 9355 |
9345 Bucket* bucket = GetBucket(c.bucket_id); | 9356 Bucket* bucket = GetBucket(c.bucket_id); |
9346 if (!bucket || bucket->size() == 0) { | 9357 if (!bucket || bucket->size() == 0) { |
9347 return error::kInvalidArguments; | 9358 return error::kInvalidArguments; |
9348 } | 9359 } |
9349 std::string command_name; | 9360 std::string command_name; |
9350 if (!bucket->GetAsString(&command_name)) { | 9361 if (!bucket->GetAsString(&command_name)) { |
9351 return error::kInvalidArguments; | 9362 return error::kInvalidArguments; |
9352 } | 9363 } |
9353 | 9364 |
9354 linked_ptr<GPUTrace> trace(new GPUTrace(command_name)); | 9365 if (!gpu_tracer_.get()) |
9355 trace->EnableStartTrace(); | 9366 return error::kNoError; |
9356 gpu_trace_stack_.push(trace); | 9367 |
| 9368 if (!gpu_tracer_->Begin(command_name)) { |
| 9369 SetGLError(GL_INVALID_OPERATION, |
| 9370 "glTraceBeginCHROMIUM", "unable to create begin trace"); |
| 9371 return error::kNoError; |
| 9372 } |
9357 | 9373 |
9358 return error::kNoError; | 9374 return error::kNoError; |
9359 } | 9375 } |
9360 | 9376 |
9361 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { | 9377 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { |
9362 if (gpu_trace_stack_.empty()) { | 9378 TRACE_EVENT_ASYNC_END0("gpu", "GLES2DecoderImpl::Trace", this); |
| 9379 if (!gpu_tracer_.get()) |
| 9380 return; |
| 9381 |
| 9382 if (!gpu_tracer_->End()) { |
9363 SetGLError(GL_INVALID_OPERATION, | 9383 SetGLError(GL_INVALID_OPERATION, |
9364 "glTraceEndCHROMIUM", "no trace begin found"); | 9384 "glTraceEndCHROMIUM", "no trace begin found"); |
9365 return; | 9385 return; |
9366 } | 9386 } |
9367 | |
9368 linked_ptr<GPUTrace> trace = gpu_trace_stack_.top(); | |
9369 trace->EnableEndTrace(); | |
9370 gpu_trace_stack_.pop(); | |
9371 } | 9387 } |
9372 | 9388 |
9373 // Include the auto-generated part of this file. We split this because it means | 9389 // Include the auto-generated part of this file. We split this because it means |
9374 // we can easily edit the non-auto generated parts right here in this file | 9390 // we can easily edit the non-auto generated parts right here in this file |
9375 // instead of having to edit some template or the code generator. | 9391 // instead of having to edit some template or the code generator. |
9376 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 9392 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
9377 | 9393 |
9378 } // namespace gles2 | 9394 } // namespace gles2 |
9379 } // namespace gpu | 9395 } // namespace gpu |
OLD | NEW |