diff options
author | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-14 03:36:26 +0000 |
---|---|---|
committer | gman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-01-14 03:36:26 +0000 |
commit | e844ae281f29bcff6de2757399c1e48c99a4ed33 (patch) | |
tree | 5301808ec04c83571bb631ce75da85c4c98cc443 /gpu | |
parent | 7e379c121107ab6d04cbbed075e154b4bee43e95 (diff) | |
download | chromium_src-e844ae281f29bcff6de2757399c1e48c99a4ed33.zip chromium_src-e844ae281f29bcff6de2757399c1e48c99a4ed33.tar.gz chromium_src-e844ae281f29bcff6de2757399c1e48c99a4ed33.tar.bz2 |
Add --enable-gpu-debugging to call glGetError after every command in the command buffer.
TEST=none
BUG=107299
Review URL: http://codereview.chromium.org/8994013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@117775 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 21 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.h | 13 | ||||
-rw-r--r-- | gpu/command_buffer/service/gpu_switches.cc | 12 | ||||
-rw-r--r-- | gpu/command_buffer/service/gpu_switches.h | 18 | ||||
-rw-r--r-- | gpu/gpu.gyp | 4 |
5 files changed, 59 insertions, 9 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index a08b07e..3679126 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -15,6 +15,7 @@ #include "base/atomicops.h" #include "base/at_exit.h" #include "base/bind.h" +#include "base/command_line.h" #include "base/debug/trace_event.h" #if defined(OS_MACOSX) #include "base/mac/scoped_cftyperef.h" @@ -33,6 +34,7 @@ #include "gpu/command_buffer/service/framebuffer_manager.h" #include "gpu/command_buffer/service/gl_utils.h" #include "gpu/command_buffer/service/gles2_cmd_validation.h" +#include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/program_manager.h" #include "gpu/command_buffer/service/renderbuffer_manager.h" #include "gpu/command_buffer/service/shader_manager.h" @@ -492,7 +494,8 @@ bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id, } GLES2Decoder::GLES2Decoder() - : debug_(false) { + : debug_(false), + log_commands_(false) { } GLES2Decoder::~GLES2Decoder() { @@ -1926,6 +1929,11 @@ bool GLES2DecoderImpl::Initialize( DCHECK(context); DCHECK(!context_.get()); + if (CommandLine::ForCurrentProcess()->HasSwitch( + switches::kEnableGPUDebugging)) { + set_debug(true); + } + // Take ownership of the GLSurface. TODO(apatrick): once the parent / child // context is retired, the decoder should not take an initial surface as // an argument to this function. @@ -2995,8 +3003,7 @@ error::Error GLES2DecoderImpl::DoCommand( unsigned int arg_count, const void* cmd_data) { error::Error result = error::kNoError; - if (debug()) { - // TODO(gman): Change output to something useful for NaCl. + if (log_commands()) { LOG(INFO) << "[" << this << "]" << "cmd: " << GetCommandName(command); } unsigned int command_index = command - kStartPoint - 1; @@ -3021,10 +3028,10 @@ error::Error GLES2DecoderImpl::DoCommand( if (debug()) { GLenum error; while ((error = glGetError()) != GL_NO_ERROR) { - // TODO(gman): Change output to something useful for NaCl. - SetGLError(error, NULL); - DLOG(INFO) << "[" << this << "]" - << "GL ERROR: " << error << " : " << GetCommandName(command); + SetGLError(error, "GL error from driver"); + LOG(INFO) << "[" << this << "]" + << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : " + << GetCommandName(command); } } } else { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index e700efe..c9e44d0 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -54,10 +54,20 @@ class GLES2Decoder : public CommonDecoder { return debug_; } + // Set to true to call glGetError after every command. void set_debug(bool debug) { debug_ = debug; } + bool log_commands() const { + return log_commands_; + } + + // Set to true to LOG every command. + void set_log_commands(bool log_commands) { + log_commands_ = log_commands; + } + // Initializes the graphics context. Can create an offscreen // decoder with a frame buffer that can be referenced from the parent. // Takes ownership of GLContext. @@ -143,6 +153,7 @@ class GLES2Decoder : public CommonDecoder { private: bool debug_; + bool log_commands_; DISALLOW_COPY_AND_ASSIGN(GLES2Decoder); }; diff --git a/gpu/command_buffer/service/gpu_switches.cc b/gpu/command_buffer/service/gpu_switches.cc new file mode 100644 index 0000000..0c6dee5 --- /dev/null +++ b/gpu/command_buffer/service/gpu_switches.cc @@ -0,0 +1,12 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "gpu/command_buffer/service/gpu_switches.h" + +namespace switches { + +// Turn on Calling GL Error after every command. +const char kEnableGPUDebugging[] = "enable-gpu-debugging"; + +} // namespace switches diff --git a/gpu/command_buffer/service/gpu_switches.h b/gpu/command_buffer/service/gpu_switches.h new file mode 100644 index 0000000..4f30691 --- /dev/null +++ b/gpu/command_buffer/service/gpu_switches.h @@ -0,0 +1,18 @@ +// Copyright (c) 2012 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Defines all the command-line switches used by gpu/command_buffer/service/. + +#ifndef GPU_COMMAND_BUFFER_SERVICE_GPU_SWITCHES_H_ +#define GPU_COMMAND_BUFFER_SERVICE_GPU_SWITCHES_H_ +#pragma once + +namespace switches { + +extern const char kEnableGPUDebugging[]; + +} // namespace switches + +#endif // GPU_COMMAND_BUFFER_SERVICE_GPU_SWITCHES_H_ + diff --git a/gpu/gpu.gyp b/gpu/gpu.gyp index 2873c29..983285a 100644 --- a/gpu/gpu.gyp +++ b/gpu/gpu.gyp @@ -1,4 +1,4 @@ -# Copyright (c) 2011 The Chromium Authors. All rights reserved. +# Copyright (c) 2012 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. @@ -240,6 +240,8 @@ 'command_buffer/service/gpu_scheduler.h', 'command_buffer/service/gpu_scheduler.cc', 'command_buffer/service/gpu_scheduler_mock.h', + 'command_buffer/service/gpu_switches.h', + 'command_buffer/service/gpu_switches.cc', 'command_buffer/service/id_manager.h', 'command_buffer/service/id_manager.cc', 'command_buffer/service/mocks.h', |