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

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

Issue 11416117: Hookup the GPUTrace events. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 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 | Annotate | Revision Log
OLDNEW
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
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
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
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
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 gpu_tracer_->Process();
6510
6506 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) { 6511 if (surface_->PostSubBuffer(c.x, c.y, c.width, c.height)) {
6507 return error::kNoError; 6512 return error::kNoError;
6508 } else { 6513 } else {
6509 LOG(ERROR) << "Context lost because PostSubBuffer failed."; 6514 LOG(ERROR) << "Context lost because PostSubBuffer failed.";
6510 return error::kLostContext; 6515 return error::kLostContext;
6511 } 6516 }
6512 } 6517 }
6513 6518
6514 error::Error GLES2DecoderImpl::GetAttribLocationHelper( 6519 error::Error GLES2DecoderImpl::GetAttribLocationHelper(
6515 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset, 6520 GLuint client_id, uint32 location_shm_id, uint32 location_shm_offset,
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
8179 #endif 8184 #endif
8180 } 8185 }
8181 8186
8182 error::Error GLES2DecoderImpl::HandleSwapBuffers( 8187 error::Error GLES2DecoderImpl::HandleSwapBuffers(
8183 uint32 immediate_data_size, const gles2::SwapBuffers& c) { 8188 uint32 immediate_data_size, const gles2::SwapBuffers& c) {
8184 bool is_offscreen = !!offscreen_target_frame_buffer_.get(); 8189 bool is_offscreen = !!offscreen_target_frame_buffer_.get();
8185 if (!is_offscreen && surface_->DeferSwapBuffers()) { 8190 if (!is_offscreen && surface_->DeferSwapBuffers()) {
8186 return error::kDeferCommandUntilLater; 8191 return error::kDeferCommandUntilLater;
8187 } 8192 }
8188 8193
8194 gpu_tracer_->Process();
8195
8189 int this_frame_number = frame_number_++; 8196 int this_frame_number = frame_number_++;
8190 // TRACE_EVENT for gpu tests: 8197 // TRACE_EVENT for gpu tests:
8191 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency", 8198 TRACE_EVENT_INSTANT2("test_gpu", "SwapBuffersLatency",
8192 "GLImpl", static_cast<int>(gfx::GetGLImplementation()), 8199 "GLImpl", static_cast<int>(gfx::GetGLImplementation()),
8193 "width", (is_offscreen ? offscreen_size_.width() : 8200 "width", (is_offscreen ? offscreen_size_.width() :
8194 surface_->GetSize().width())); 8201 surface_->GetSize().width()));
8195 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers", 8202 TRACE_EVENT2("gpu", "GLES2DecoderImpl::HandleSwapBuffers",
8196 "offscreen", is_offscreen, 8203 "offscreen", is_offscreen,
8197 "frame", this_frame_number); 8204 "frame", this_frame_number);
8198 // If offscreen then don't actually SwapBuffers to the display. Just copy 8205 // If offscreen then don't actually SwapBuffers to the display. Just copy
(...skipping 1145 matching lines...) Expand 10 before | Expand all | Expand 10 after
9344 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) { 9351 uint32 immediate_data_size, const gles2::TraceBeginCHROMIUM& c) {
9345 Bucket* bucket = GetBucket(c.bucket_id); 9352 Bucket* bucket = GetBucket(c.bucket_id);
9346 if (!bucket || bucket->size() == 0) { 9353 if (!bucket || bucket->size() == 0) {
9347 return error::kInvalidArguments; 9354 return error::kInvalidArguments;
9348 } 9355 }
9349 std::string command_name; 9356 std::string command_name;
9350 if (!bucket->GetAsString(&command_name)) { 9357 if (!bucket->GetAsString(&command_name)) {
9351 return error::kInvalidArguments; 9358 return error::kInvalidArguments;
9352 } 9359 }
9353 9360
9354 linked_ptr<GPUTrace> trace(new GPUTrace(command_name)); 9361 if (!gpu_tracer_->Begin(command_name)) {
9355 trace->EnableStartTrace(); 9362 SetGLError(GL_INVALID_OPERATION,
9356 gpu_trace_stack_.push(trace); 9363 "glTraceBeginCHROMIUM", "unable to create begin trace");
9364 return error::kNoError;
jonathan.backer 2012/11/23 18:55:41 Do we return an error here?
dsinclair 2012/11/23 21:13:56 From looking at the other methods in this file, I
9365 }
9357 9366
9358 return error::kNoError; 9367 return error::kNoError;
9359 } 9368 }
9360 9369
9361 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { 9370 void GLES2DecoderImpl::DoTraceEndCHROMIUM() {
9362 if (gpu_trace_stack_.empty()) { 9371 if (!gpu_tracer_->End()) {
9363 SetGLError(GL_INVALID_OPERATION, 9372 SetGLError(GL_INVALID_OPERATION,
9364 "glTraceEndCHROMIUM", "no trace begin found"); 9373 "glTraceEndCHROMIUM", "no trace begin found");
9365 return; 9374 return;
9366 } 9375 }
9367
9368 linked_ptr<GPUTrace> trace = gpu_trace_stack_.top();
9369 trace->EnableEndTrace();
9370 gpu_trace_stack_.pop();
9371 } 9376 }
9372 9377
9373 // Include the auto-generated part of this file. We split this because it means 9378 // 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 9379 // 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. 9380 // instead of having to edit some template or the code generator.
9376 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 9381 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
9377 9382
9378 } // namespace gles2 9383 } // namespace gles2
9379 } // namespace gpu 9384 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gpu_trace.h » ('j') | gpu/command_buffer/service/gpu_tracer.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698