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

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

Issue 776603003: Changed the GPU Tracer so the category names can be customized. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Disable gpu_decoder and gpu_group_marker by default Created 6 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
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 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after
1862 // Command buffer stats. 1862 // Command buffer stats.
1863 base::TimeDelta total_processing_commands_time_; 1863 base::TimeDelta total_processing_commands_time_;
1864 1864
1865 // States related to each manager. 1865 // States related to each manager.
1866 DecoderTextureState texture_state_; 1866 DecoderTextureState texture_state_;
1867 DecoderFramebufferState framebuffer_state_; 1867 DecoderFramebufferState framebuffer_state_;
1868 1868
1869 scoped_ptr<GPUTracer> gpu_tracer_; 1869 scoped_ptr<GPUTracer> gpu_tracer_;
1870 scoped_ptr<GPUStateTracer> gpu_state_tracer_; 1870 scoped_ptr<GPUStateTracer> gpu_state_tracer_;
1871 const unsigned char* cb_command_trace_category_; 1871 const unsigned char* cb_command_trace_category_;
1872 const unsigned char* gpu_decoder_category_;
1873 const unsigned char* gpu_group_marker_category_;
1872 int gpu_trace_level_; 1874 int gpu_trace_level_;
1873 bool gpu_trace_commands_; 1875 bool gpu_trace_commands_;
1874 bool gpu_debug_commands_; 1876 bool gpu_debug_commands_;
1875 1877
1876 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_; 1878 std::queue<linked_ptr<FenceCallback> > pending_readpixel_fences_;
1877 1879
1878 // Used to validate multisample renderbuffers if needed 1880 // Used to validate multisample renderbuffers if needed
1879 GLuint validation_texture_; 1881 GLuint validation_texture_;
1880 GLuint validation_fbo_multisample_; 1882 GLuint validation_fbo_multisample_;
1881 GLuint validation_fbo_; 1883 GLuint validation_fbo_;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
2377 lose_context_when_out_of_memory_(false), 2379 lose_context_when_out_of_memory_(false),
2378 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch( 2380 service_logging_(CommandLine::ForCurrentProcess()->HasSwitch(
2379 switches::kEnableGPUServiceLoggingGPU)), 2381 switches::kEnableGPUServiceLoggingGPU)),
2380 viewport_max_width_(0), 2382 viewport_max_width_(0),
2381 viewport_max_height_(0), 2383 viewport_max_height_(0),
2382 texture_state_(group_->feature_info() 2384 texture_state_(group_->feature_info()
2383 ->workarounds() 2385 ->workarounds()
2384 .texsubimage2d_faster_than_teximage2d), 2386 .texsubimage2d_faster_than_teximage2d),
2385 cb_command_trace_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED( 2387 cb_command_trace_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
2386 TRACE_DISABLED_BY_DEFAULT("cb_command"))), 2388 TRACE_DISABLED_BY_DEFAULT("cb_command"))),
2389 gpu_decoder_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
2390 TRACE_DISABLED_BY_DEFAULT("gpu_decoder"))),
2391 gpu_group_marker_category_(TRACE_EVENT_API_GET_CATEGORY_GROUP_ENABLED(
2392 TRACE_DISABLED_BY_DEFAULT("gpu_group_marker"))),
2387 gpu_trace_level_(2), 2393 gpu_trace_level_(2),
2388 gpu_trace_commands_(false), 2394 gpu_trace_commands_(false),
2389 gpu_debug_commands_(false), 2395 gpu_debug_commands_(false),
2390 validation_texture_(0), 2396 validation_texture_(0),
2391 validation_fbo_multisample_(0), 2397 validation_fbo_multisample_(0),
2392 validation_fbo_(0) { 2398 validation_fbo_(0) {
2393 DCHECK(group); 2399 DCHECK(group);
2394 2400
2395 attrib_0_value_.v[0] = 0.0f; 2401 attrib_0_value_.v[0] = 0.0f;
2396 attrib_0_value_.v[1] = 0.0f; 2402 attrib_0_value_.v[1] = 0.0f;
(...skipping 1551 matching lines...) Expand 10 before | Expand all | Expand 10 after
3948 } 3954 }
3949 3955
3950 const unsigned int arg_count = size - 1; 3956 const unsigned int arg_count = size - 1;
3951 unsigned int command_index = command - kStartPoint - 1; 3957 unsigned int command_index = command - kStartPoint - 1;
3952 if (command_index < arraysize(command_info)) { 3958 if (command_index < arraysize(command_info)) {
3953 const CommandInfo& info = command_info[command_index]; 3959 const CommandInfo& info = command_info[command_index];
3954 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count); 3960 unsigned int info_arg_count = static_cast<unsigned int>(info.arg_count);
3955 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) || 3961 if ((info.arg_flags == cmd::kFixed && arg_count == info_arg_count) ||
3956 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) { 3962 (info.arg_flags == cmd::kAtLeastN && arg_count >= info_arg_count)) {
3957 bool doing_gpu_trace = false; 3963 bool doing_gpu_trace = false;
3958 if (DebugImpl && gpu_trace_commands_) { 3964 if (DebugImpl && gpu_trace_commands_ && *gpu_decoder_category_) {
vmiura 2014/12/08 23:23:06 I think we could combine the *gpu_decoder_category
David Yen 2014/12/08 23:45:38 Done.
3959 if (CMD_FLAG_GET_TRACE_LEVEL(info.cmd_flags) <= gpu_trace_level_) { 3965 if (CMD_FLAG_GET_TRACE_LEVEL(info.cmd_flags) <= gpu_trace_level_) {
3960 doing_gpu_trace = true; 3966 doing_gpu_trace = true;
3961 gpu_tracer_->Begin(GetCommandName(command), kTraceDecoder); 3967 gpu_tracer_->Begin(TRACE_DISABLED_BY_DEFAULT("gpu_decoder"),
3968 GetCommandName(command),
3969 kTraceDecoder);
3962 } 3970 }
3963 } 3971 }
3964 3972
3965 uint32 immediate_data_size = (arg_count - info_arg_count) * 3973 uint32 immediate_data_size = (arg_count - info_arg_count) *
3966 sizeof(CommandBufferEntry); // NOLINT 3974 sizeof(CommandBufferEntry); // NOLINT
3967 3975
3968 result = (this->*info.cmd_handler)(immediate_data_size, cmd_data); 3976 result = (this->*info.cmd_handler)(immediate_data_size, cmd_data);
3969 3977
3970 if (DebugImpl && doing_gpu_trace) 3978 if (DebugImpl && doing_gpu_trace)
3971 gpu_tracer_->End(kTraceDecoder); 3979 gpu_tracer_->End(kTraceDecoder);
(...skipping 6975 matching lines...) Expand 10 before | Expand all | Expand 10 after
10947 length ? std::string(marker, length) : std::string(marker)); 10955 length ? std::string(marker, length) : std::string(marker));
10948 } 10956 }
10949 10957
10950 void GLES2DecoderImpl::DoPushGroupMarkerEXT( 10958 void GLES2DecoderImpl::DoPushGroupMarkerEXT(
10951 GLsizei length, const GLchar* marker) { 10959 GLsizei length, const GLchar* marker) {
10952 if (!marker) { 10960 if (!marker) {
10953 marker = ""; 10961 marker = "";
10954 } 10962 }
10955 std::string name = length ? std::string(marker, length) : std::string(marker); 10963 std::string name = length ? std::string(marker, length) : std::string(marker);
10956 debug_marker_manager_.PushGroup(name); 10964 debug_marker_manager_.PushGroup(name);
10957 gpu_tracer_->Begin(name, kTraceGroupMarker); 10965 if (*gpu_group_marker_category_) {
10966 gpu_tracer_->Begin(TRACE_DISABLED_BY_DEFAULT("gpu_group_marker"), name,
10967 kTraceGroupMarker);
10968 }
10958 } 10969 }
10959 10970
10960 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { 10971 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) {
10961 debug_marker_manager_.PopGroup(); 10972 debug_marker_manager_.PopGroup();
10962 gpu_tracer_->End(kTraceGroupMarker); 10973 if (*gpu_group_marker_category_) {
10974 gpu_tracer_->End(kTraceGroupMarker);
10975 }
10963 } 10976 }
10964 10977
10965 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( 10978 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM(
10966 GLenum target, GLint image_id) { 10979 GLenum target, GLint image_id) {
10967 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); 10980 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM");
10968 10981
10969 if (target == GL_TEXTURE_CUBE_MAP) { 10982 if (target == GL_TEXTURE_CUBE_MAP) {
10970 LOCAL_SET_GL_ERROR( 10983 LOCAL_SET_GL_ERROR(
10971 GL_INVALID_ENUM, 10984 GL_INVALID_ENUM,
10972 "glBindTexImage2DCHROMIUM", "invalid target"); 10985 "glBindTexImage2DCHROMIUM", "invalid target");
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
11046 texture_manager()->SetLevelInfo( 11059 texture_manager()->SetLevelInfo(
11047 texture_ref, target, 0, GL_RGBA, 0, 0, 1, 0, 11060 texture_ref, target, 0, GL_RGBA, 0, 0, 1, 0,
11048 GL_RGBA, GL_UNSIGNED_BYTE, false); 11061 GL_RGBA, GL_UNSIGNED_BYTE, false);
11049 } 11062 }
11050 11063
11051 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( 11064 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM(
11052 uint32 immediate_data_size, 11065 uint32 immediate_data_size,
11053 const void* cmd_data) { 11066 const void* cmd_data) {
11054 const gles2::cmds::TraceBeginCHROMIUM& c = 11067 const gles2::cmds::TraceBeginCHROMIUM& c =
11055 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data); 11068 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data);
11056 Bucket* bucket = GetBucket(c.bucket_id); 11069 Bucket* category_bucket = GetBucket(c.category_bucket_id);
11057 if (!bucket || bucket->size() == 0) { 11070 Bucket* name_bucket = GetBucket(c.name_bucket_id);
11071 if (!category_bucket || category_bucket->size() == 0 ||
11072 !name_bucket || name_bucket->size() == 0) {
11058 return error::kInvalidArguments; 11073 return error::kInvalidArguments;
11059 } 11074 }
11075
11076 std::string category_name;
11060 std::string command_name; 11077 std::string command_name;
11061 if (!bucket->GetAsString(&command_name)) { 11078 if (!category_bucket->GetAsString(&category_name) ||
11079 !name_bucket->GetAsString(&command_name)) {
vmiura 2014/12/08 23:23:06 nit: trace_name for consistency.
David Yen 2014/12/08 23:45:38 Done.
11062 return error::kInvalidArguments; 11080 return error::kInvalidArguments;
11063 } 11081 }
11064 TRACE_EVENT_COPY_ASYNC_BEGIN0("gpu", command_name.c_str(), this); 11082
11065 if (!gpu_tracer_->Begin(command_name, kTraceCHROMIUM)) { 11083 TRACE_EVENT_COPY_ASYNC_BEGIN0(category_name.c_str(), command_name.c_str(),
11084 this);
11085 if (!gpu_tracer_->Begin(category_name, command_name, kTraceCHROMIUM)) {
11066 LOCAL_SET_GL_ERROR( 11086 LOCAL_SET_GL_ERROR(
11067 GL_INVALID_OPERATION, 11087 GL_INVALID_OPERATION,
11068 "glTraceBeginCHROMIUM", "unable to create begin trace"); 11088 "glTraceBeginCHROMIUM", "unable to create begin trace");
11069 return error::kNoError; 11089 return error::kNoError;
11070 } 11090 }
11071 return error::kNoError; 11091 return error::kNoError;
11072 } 11092 }
11073 11093
11074 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { 11094 void GLES2DecoderImpl::DoTraceEndCHROMIUM() {
11075 if (gpu_tracer_->CurrentName().empty()) { 11095 if (gpu_tracer_->CurrentCategory().empty() ||
11096 gpu_tracer_->CurrentName().empty()) {
11076 LOCAL_SET_GL_ERROR( 11097 LOCAL_SET_GL_ERROR(
11077 GL_INVALID_OPERATION, 11098 GL_INVALID_OPERATION,
11078 "glTraceEndCHROMIUM", "no trace begin found"); 11099 "glTraceEndCHROMIUM", "no trace begin found");
11079 return; 11100 return;
11080 } 11101 }
11081 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); 11102 TRACE_EVENT_COPY_ASYNC_END0(gpu_tracer_->CurrentCategory().c_str(),
11103 gpu_tracer_->CurrentName().c_str(), this);
11082 gpu_tracer_->End(kTraceCHROMIUM); 11104 gpu_tracer_->End(kTraceCHROMIUM);
11083 } 11105 }
11084 11106
11085 void GLES2DecoderImpl::DoDrawBuffersEXT( 11107 void GLES2DecoderImpl::DoDrawBuffersEXT(
11086 GLsizei count, const GLenum* bufs) { 11108 GLsizei count, const GLenum* bufs) {
11087 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) { 11109 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) {
11088 LOCAL_SET_GL_ERROR( 11110 LOCAL_SET_GL_ERROR(
11089 GL_INVALID_VALUE, 11111 GL_INVALID_VALUE,
11090 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT"); 11112 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT");
11091 return; 11113 return;
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
11496 } 11518 }
11497 } 11519 }
11498 11520
11499 // Include the auto-generated part of this file. We split this because it means 11521 // Include the auto-generated part of this file. We split this because it means
11500 // we can easily edit the non-auto generated parts right here in this file 11522 // we can easily edit the non-auto generated parts right here in this file
11501 // instead of having to edit some template or the code generator. 11523 // instead of having to edit some template or the code generator.
11502 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 11524 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
11503 11525
11504 } // namespace gles2 11526 } // namespace gles2
11505 } // namespace gpu 11527 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698