| 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 1851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 Loading... |
| 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 1077 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3474 const base::Callback<void(gfx::Size, float)>& callback) { | 3480 const base::Callback<void(gfx::Size, float)>& callback) { |
| 3475 resize_callback_ = callback; | 3481 resize_callback_ = callback; |
| 3476 } | 3482 } |
| 3477 | 3483 |
| 3478 Logger* GLES2DecoderImpl::GetLogger() { | 3484 Logger* GLES2DecoderImpl::GetLogger() { |
| 3479 return &logger_; | 3485 return &logger_; |
| 3480 } | 3486 } |
| 3481 | 3487 |
| 3482 void GLES2DecoderImpl::BeginDecoding() { | 3488 void GLES2DecoderImpl::BeginDecoding() { |
| 3483 gpu_tracer_->BeginDecoding(); | 3489 gpu_tracer_->BeginDecoding(); |
| 3484 gpu_trace_commands_ = gpu_tracer_->IsTracing(); | 3490 gpu_trace_commands_ = gpu_tracer_->IsTracing() && *gpu_decoder_category_; |
| 3485 gpu_debug_commands_ = log_commands() || debug() || gpu_trace_commands_ || | 3491 gpu_debug_commands_ = log_commands() || debug() || gpu_trace_commands_ || |
| 3486 (*cb_command_trace_category_ != 0); | 3492 (*cb_command_trace_category_ != 0); |
| 3487 } | 3493 } |
| 3488 | 3494 |
| 3489 void GLES2DecoderImpl::EndDecoding() { | 3495 void GLES2DecoderImpl::EndDecoding() { |
| 3490 gpu_tracer_->EndDecoding(); | 3496 gpu_tracer_->EndDecoding(); |
| 3491 } | 3497 } |
| 3492 | 3498 |
| 3493 ErrorState* GLES2DecoderImpl::GetErrorState() { | 3499 ErrorState* GLES2DecoderImpl::GetErrorState() { |
| 3494 return state_.GetErrorState(); | 3500 return state_.GetErrorState(); |
| (...skipping 456 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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_) { |
| 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 6981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10953 length ? std::string(marker, length) : std::string(marker)); | 10961 length ? std::string(marker, length) : std::string(marker)); |
| 10954 } | 10962 } |
| 10955 | 10963 |
| 10956 void GLES2DecoderImpl::DoPushGroupMarkerEXT( | 10964 void GLES2DecoderImpl::DoPushGroupMarkerEXT( |
| 10957 GLsizei length, const GLchar* marker) { | 10965 GLsizei length, const GLchar* marker) { |
| 10958 if (!marker) { | 10966 if (!marker) { |
| 10959 marker = ""; | 10967 marker = ""; |
| 10960 } | 10968 } |
| 10961 std::string name = length ? std::string(marker, length) : std::string(marker); | 10969 std::string name = length ? std::string(marker, length) : std::string(marker); |
| 10962 debug_marker_manager_.PushGroup(name); | 10970 debug_marker_manager_.PushGroup(name); |
| 10963 gpu_tracer_->Begin(name, kTraceGroupMarker); | 10971 if (*gpu_group_marker_category_) { |
| 10972 gpu_tracer_->Begin(TRACE_DISABLED_BY_DEFAULT("gpu_group_marker"), name, |
| 10973 kTraceGroupMarker); |
| 10974 } |
| 10964 } | 10975 } |
| 10965 | 10976 |
| 10966 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { | 10977 void GLES2DecoderImpl::DoPopGroupMarkerEXT(void) { |
| 10967 debug_marker_manager_.PopGroup(); | 10978 debug_marker_manager_.PopGroup(); |
| 10968 gpu_tracer_->End(kTraceGroupMarker); | 10979 if (*gpu_group_marker_category_) { |
| 10980 gpu_tracer_->End(kTraceGroupMarker); |
| 10981 } |
| 10969 } | 10982 } |
| 10970 | 10983 |
| 10971 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( | 10984 void GLES2DecoderImpl::DoBindTexImage2DCHROMIUM( |
| 10972 GLenum target, GLint image_id) { | 10985 GLenum target, GLint image_id) { |
| 10973 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); | 10986 TRACE_EVENT0("gpu", "GLES2DecoderImpl::DoBindTexImage2DCHROMIUM"); |
| 10974 | 10987 |
| 10975 if (target == GL_TEXTURE_CUBE_MAP) { | 10988 if (target == GL_TEXTURE_CUBE_MAP) { |
| 10976 LOCAL_SET_GL_ERROR( | 10989 LOCAL_SET_GL_ERROR( |
| 10977 GL_INVALID_ENUM, | 10990 GL_INVALID_ENUM, |
| 10978 "glBindTexImage2DCHROMIUM", "invalid target"); | 10991 "glBindTexImage2DCHROMIUM", "invalid target"); |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11052 texture_manager()->SetLevelInfo( | 11065 texture_manager()->SetLevelInfo( |
| 11053 texture_ref, target, 0, GL_RGBA, 0, 0, 1, 0, | 11066 texture_ref, target, 0, GL_RGBA, 0, 0, 1, 0, |
| 11054 GL_RGBA, GL_UNSIGNED_BYTE, false); | 11067 GL_RGBA, GL_UNSIGNED_BYTE, false); |
| 11055 } | 11068 } |
| 11056 | 11069 |
| 11057 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( | 11070 error::Error GLES2DecoderImpl::HandleTraceBeginCHROMIUM( |
| 11058 uint32 immediate_data_size, | 11071 uint32 immediate_data_size, |
| 11059 const void* cmd_data) { | 11072 const void* cmd_data) { |
| 11060 const gles2::cmds::TraceBeginCHROMIUM& c = | 11073 const gles2::cmds::TraceBeginCHROMIUM& c = |
| 11061 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data); | 11074 *static_cast<const gles2::cmds::TraceBeginCHROMIUM*>(cmd_data); |
| 11062 Bucket* bucket = GetBucket(c.bucket_id); | 11075 Bucket* category_bucket = GetBucket(c.category_bucket_id); |
| 11063 if (!bucket || bucket->size() == 0) { | 11076 Bucket* name_bucket = GetBucket(c.name_bucket_id); |
| 11077 if (!category_bucket || category_bucket->size() == 0 || |
| 11078 !name_bucket || name_bucket->size() == 0) { |
| 11064 return error::kInvalidArguments; | 11079 return error::kInvalidArguments; |
| 11065 } | 11080 } |
| 11066 std::string command_name; | 11081 |
| 11067 if (!bucket->GetAsString(&command_name)) { | 11082 std::string category_name; |
| 11083 std::string trace_name; |
| 11084 if (!category_bucket->GetAsString(&category_name) || |
| 11085 !name_bucket->GetAsString(&trace_name)) { |
| 11068 return error::kInvalidArguments; | 11086 return error::kInvalidArguments; |
| 11069 } | 11087 } |
| 11070 TRACE_EVENT_COPY_ASYNC_BEGIN0("gpu", command_name.c_str(), this); | 11088 |
| 11071 if (!gpu_tracer_->Begin(command_name, kTraceCHROMIUM)) { | 11089 TRACE_EVENT_COPY_ASYNC_BEGIN0(category_name.c_str(), trace_name.c_str(), |
| 11090 this); |
| 11091 if (!gpu_tracer_->Begin(category_name, trace_name, kTraceCHROMIUM)) { |
| 11072 LOCAL_SET_GL_ERROR( | 11092 LOCAL_SET_GL_ERROR( |
| 11073 GL_INVALID_OPERATION, | 11093 GL_INVALID_OPERATION, |
| 11074 "glTraceBeginCHROMIUM", "unable to create begin trace"); | 11094 "glTraceBeginCHROMIUM", "unable to create begin trace"); |
| 11075 return error::kNoError; | 11095 return error::kNoError; |
| 11076 } | 11096 } |
| 11077 return error::kNoError; | 11097 return error::kNoError; |
| 11078 } | 11098 } |
| 11079 | 11099 |
| 11080 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { | 11100 void GLES2DecoderImpl::DoTraceEndCHROMIUM() { |
| 11081 if (gpu_tracer_->CurrentName().empty()) { | 11101 if (gpu_tracer_->CurrentCategory().empty() || |
| 11102 gpu_tracer_->CurrentName().empty()) { |
| 11082 LOCAL_SET_GL_ERROR( | 11103 LOCAL_SET_GL_ERROR( |
| 11083 GL_INVALID_OPERATION, | 11104 GL_INVALID_OPERATION, |
| 11084 "glTraceEndCHROMIUM", "no trace begin found"); | 11105 "glTraceEndCHROMIUM", "no trace begin found"); |
| 11085 return; | 11106 return; |
| 11086 } | 11107 } |
| 11087 TRACE_EVENT_COPY_ASYNC_END0("gpu", gpu_tracer_->CurrentName().c_str(), this); | 11108 TRACE_EVENT_COPY_ASYNC_END0(gpu_tracer_->CurrentCategory().c_str(), |
| 11109 gpu_tracer_->CurrentName().c_str(), this); |
| 11088 gpu_tracer_->End(kTraceCHROMIUM); | 11110 gpu_tracer_->End(kTraceCHROMIUM); |
| 11089 } | 11111 } |
| 11090 | 11112 |
| 11091 void GLES2DecoderImpl::DoDrawBuffersEXT( | 11113 void GLES2DecoderImpl::DoDrawBuffersEXT( |
| 11092 GLsizei count, const GLenum* bufs) { | 11114 GLsizei count, const GLenum* bufs) { |
| 11093 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) { | 11115 if (count > static_cast<GLsizei>(group_->max_draw_buffers())) { |
| 11094 LOCAL_SET_GL_ERROR( | 11116 LOCAL_SET_GL_ERROR( |
| 11095 GL_INVALID_VALUE, | 11117 GL_INVALID_VALUE, |
| 11096 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT"); | 11118 "glDrawBuffersEXT", "greater than GL_MAX_DRAW_BUFFERS_EXT"); |
| 11097 return; | 11119 return; |
| (...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 11502 } | 11524 } |
| 11503 } | 11525 } |
| 11504 | 11526 |
| 11505 // Include the auto-generated part of this file. We split this because it means | 11527 // Include the auto-generated part of this file. We split this because it means |
| 11506 // we can easily edit the non-auto generated parts right here in this file | 11528 // we can easily edit the non-auto generated parts right here in this file |
| 11507 // instead of having to edit some template or the code generator. | 11529 // instead of having to edit some template or the code generator. |
| 11508 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" | 11530 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" |
| 11509 | 11531 |
| 11510 } // namespace gles2 | 11532 } // namespace gles2 |
| 11511 } // namespace gpu | 11533 } // namespace gpu |
| OLD | NEW |