diff options
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 80 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.h | 18 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_mock.h | 2 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc | 3 | ||||
-rw-r--r-- | gpu/command_buffer/service/logger.cc | 62 | ||||
-rw-r--r-- | gpu/command_buffer/service/logger.h | 58 | ||||
-rw-r--r-- | gpu/command_buffer_service.gypi | 2 |
7 files changed, 150 insertions, 75 deletions
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 8aea573..760b580 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -42,6 +42,7 @@ #include "gpu/command_buffer/service/gpu_switches.h" #include "gpu/command_buffer/service/gpu_tracer.h" #include "gpu/command_buffer/service/image_manager.h" +#include "gpu/command_buffer/service/logger.h" #include "gpu/command_buffer/service/mailbox_manager.h" #include "gpu/command_buffer/service/memory_tracking.h" #include "gpu/command_buffer/service/program_manager.h" @@ -534,8 +535,7 @@ bool GLES2Decoder::GetServiceTextureId(uint32 client_texture_id, GLES2Decoder::GLES2Decoder() : initialized_(false), debug_(false), - log_commands_(false), - log_synthesized_gl_errors_(true) { + log_commands_(false) { } GLES2Decoder::~GLES2Decoder() { @@ -638,7 +638,8 @@ class GLES2DecoderImpl : public GLES2Decoder { virtual void SetResizeCallback( const base::Callback<void(gfx::Size)>& callback) OVERRIDE; - virtual void SetMsgCallback(const MsgCallback& callback) OVERRIDE; + virtual Logger* GetLogger() OVERRIDE; + virtual void SetShaderCacheCallback( const ShaderCacheCallback& callback) OVERRIDE; virtual void SetWaitSyncPointCallback( @@ -960,7 +961,7 @@ class GLES2DecoderImpl : public GLES2Decoder { void LogClientServiceMapping( const char* function_name, GLuint client_id, GLuint service_id) { if (service_logging_) { - DLOG(INFO) << "[" << GetLogPrefix() << "] " << function_name + DLOG(INFO) << "[" << logger_.GetLogPrefix() << "] " << function_name << ": client_id = " << client_id << ", service_id = " << service_id; } @@ -1603,11 +1604,9 @@ class GLES2DecoderImpl : public GLES2Decoder { GLsizei width, GLsizei height, GLenum format, Texture* texture); - void LogMessage(const char* filename, int line, const std::string& msg); void RenderWarning(const char* filename, int line, const std::string& msg); void PerformanceWarning( const char* filename, int line, const std::string& msg); - const std::string& GetLogPrefix() const; const FeatureInfo::FeatureFlags& features() const { return feature_info_->feature_flags(); @@ -1649,6 +1648,9 @@ class GLES2DecoderImpl : public GLES2Decoder { // The ContextGroup for this decoder uses to track resources. scoped_refptr<ContextGroup> group_; + DebugMarkerManager debug_marker_manager_; + Logger logger_; + // All the state for this context. ContextState state_; @@ -1729,7 +1731,6 @@ class GLES2DecoderImpl : public GLES2Decoder { base::Callback<void(gfx::Size)> resize_callback_; - MsgCallback msg_callback_; WaitSyncPointCallback wait_sync_point_callback_; ShaderCacheCallback shader_cache_callback_; @@ -1750,14 +1751,9 @@ class GLES2DecoderImpl : public GLES2Decoder { // The last error message set. std::string last_error_; - int log_message_count_; - // The current decoder error. error::Error current_decoder_error_; - DebugMarkerManager debug_marker_manager_; - std::string this_in_hex_; - bool use_shader_translator_; scoped_refptr<ShaderTranslator> vertex_translator_; scoped_refptr<ShaderTranslator> fragment_translator_; @@ -2204,6 +2200,7 @@ GLES2Decoder* GLES2Decoder::Create(ContextGroup* group) { GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) : GLES2Decoder(), group_(group), + logger_(&debug_marker_manager_), state_(group_->feature_info()), error_bits_(0), unpack_flip_y_(false), @@ -2227,7 +2224,6 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) back_buffer_has_stencil_(false), backbuffer_needs_clear_bits_(0), teximage2d_faster_than_texsubimage2d_(true), - log_message_count_(0), current_decoder_error_(error::kNoError), use_shader_translator_(true), validators_(group_->feature_info()->validators()), @@ -2246,9 +2242,6 @@ GLES2DecoderImpl::GLES2DecoderImpl(ContextGroup* group) texture_upload_count_(0) { DCHECK(group); - GLES2DecoderImpl* this_temp = this; - this_in_hex_ = HexEncode(&this_temp, sizeof(this_temp)); - attrib_0_value_.v[0] = 0.0f; attrib_0_value_.v[1] = 0.0f; attrib_0_value_.v[2] = 0.0f; @@ -3127,8 +3120,8 @@ void GLES2DecoderImpl::SetResizeCallback( resize_callback_ = callback; } -void GLES2DecoderImpl::SetMsgCallback(const MsgCallback& callback) { - msg_callback_ = callback; +Logger* GLES2DecoderImpl::GetLogger() { + return &logger_; } void GLES2DecoderImpl::SetShaderCacheCallback( @@ -3575,7 +3568,7 @@ error::Error GLES2DecoderImpl::DoCommand( if (log_commands()) { // TODO(notme): Change this to a LOG/VLOG that works in release. Tried // LOG(INFO), tried VLOG(1), no luck. - LOG(ERROR) << "[" << GetLogPrefix() << "]" << "cmd: " + LOG(ERROR) << "[" << logger_.GetLogPrefix() << "]" << "cmd: " << GetCommandName(command); } unsigned int command_index = command - kStartPoint - 1; @@ -3600,7 +3593,7 @@ error::Error GLES2DecoderImpl::DoCommand( if (debug()) { GLenum error; while ((error = glGetError()) != GL_NO_ERROR) { - LOG(ERROR) << "[" << GetLogPrefix() << "] " + LOG(ERROR) << "[" << logger_.GetLogPrefix() << "] " << "GL ERROR: " << GLES2Util::GetStringEnum(error) << " : " << GetCommandName(command); LOCAL_SET_GL_ERROR(error, "DoCommand", "GL error from driver"); @@ -5733,8 +5726,8 @@ void GLES2DecoderImpl::SetGLError( unsigned error, const char* function_name, const char* msg) { if (msg) { last_error_ = msg; - LogMessage(filename, line, - GetLogPrefix() + ": " + std::string("GL ERROR :") + + logger_.LogMessage(filename, line, + logger_.GetLogPrefix() + ": " + std::string("GL ERROR :") + GLES2Util::GetStringEnum(error) + " : " + function_name + ": " + msg); } @@ -5771,44 +5764,15 @@ void GLES2DecoderImpl::SetGLErrorInvalidParam( } } -const std::string& GLES2DecoderImpl::GetLogPrefix() const { - const std::string& prefix(debug_marker_manager_.GetMarker()); - return prefix.empty() ? this_in_hex_ : prefix; -} - -void GLES2DecoderImpl::LogMessage( - const char* filename, int line, const std::string& msg) { - if (log_message_count_ < kMaxLogMessages || - CommandLine::ForCurrentProcess()->HasSwitch( - switches::kDisableGLErrorLimit)) { - ++log_message_count_; - // LOG this unless logging is turned off as any chromium code that - // generates these errors probably has a bug. - if (log_synthesized_gl_errors()) { - ::logging::LogMessage( - filename, line, ::logging::LOG_ERROR).stream() << msg; - } - if (!msg_callback_.is_null()) { - msg_callback_.Run(0, msg); - } - } else { - if (log_message_count_ == kMaxLogMessages) { - ++log_message_count_; - LOG(ERROR) - << "Too many GL errors, not reporting any more for this context." - << " use --disable-gl-error-limit to see all errors."; - } - } -} - void GLES2DecoderImpl::RenderWarning( const char* filename, int line, const std::string& msg) { - LogMessage(filename, line, std::string("RENDER WARNING: ") + msg); + logger_.LogMessage(filename, line, std::string("RENDER WARNING: ") + msg); } void GLES2DecoderImpl::PerformanceWarning( const char* filename, int line, const std::string& msg) { - LogMessage(filename, line, std::string("PERFORMANCE WARNING: ") + msg); + logger_.LogMessage(filename, line, std::string("PERFORMANCE WARNING: ") + + msg); } void GLES2DecoderImpl::ForceCompileShaderIfPending(Shader* shader) { @@ -5843,8 +5807,8 @@ void GLES2DecoderImpl::ClearRealGLErrors( while ((error = glGetError()) != GL_NO_ERROR) { if (error != GL_OUT_OF_MEMORY) { // GL_OUT_OF_MEMORY can legally happen on lost device. - LogMessage(filename, line, - GetLogPrefix() + ": " + std::string("GL ERROR :") + + logger_.LogMessage(filename, line, + logger_.GetLogPrefix() + ": " + std::string("GL ERROR :") + GLES2Util::GetStringEnum(error) + " : " + function_name + ": was unhandled"); NOTREACHED() << "GL error " << error << " was unhandled."; @@ -10035,7 +9999,7 @@ error::Error GLES2DecoderImpl::HandleGenMailboxCHROMIUM( void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoProduceTextureCHROMIUM", - "context", GetLogPrefix(), + "context", logger_.GetLogPrefix(), "mailbox[0]", static_cast<unsigned char>(mailbox[0])); Texture* texture = GetTextureInfoForTarget(target); @@ -10074,7 +10038,7 @@ void GLES2DecoderImpl::DoProduceTextureCHROMIUM(GLenum target, void GLES2DecoderImpl::DoConsumeTextureCHROMIUM(GLenum target, const GLbyte* mailbox) { TRACE_EVENT2("gpu", "GLES2DecoderImpl::DoConsumeTextureCHROMIUM", - "context", GetLogPrefix(), + "context", logger_.GetLogPrefix(), "mailbox[0]", static_cast<unsigned char>(mailbox[0])); Texture* texture = GetTextureInfoForTarget(target); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.h b/gpu/command_buffer/service/gles2_cmd_decoder.h index 9221f1c..74602ff 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder.h @@ -63,6 +63,7 @@ namespace gles2 { class ContextGroup; class GLES2Util; +class Logger; class QueryManager; class VertexArrayManager; @@ -87,7 +88,6 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>, public CommonDecoder { public: typedef error::Error Error; - typedef base::Callback<void(int32 id, const std::string& msg)> MsgCallback; typedef base::Callback<bool(uint32 id)> WaitSyncPointCallback; // Creates a decoder. @@ -121,18 +121,6 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>, log_commands_ = log_commands; } - bool log_synthesized_gl_errors() const { - return log_synthesized_gl_errors_; - } - - // Defaults to true. Set to false for the gpu_unittests as they - // are explicitly checking errors are generated and so don't need the numerous - // messages. Otherwise, chromium code that generates these errors likely has a - // bug. - void set_log_synthesized_gl_errors(bool enabled) { - log_synthesized_gl_errors_ = enabled; - } - // Initializes the graphics context. Can create an offscreen // decoder with a frame buffer that can be referenced from the parent. // Takes ownership of GLContext. @@ -286,7 +274,6 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>, const char* file, int line, const char* filename) = 0; // A callback for messages from the decoder. - virtual void SetMsgCallback(const MsgCallback& callback) = 0; virtual void SetShaderCacheCallback(const ShaderCacheCallback& callback) = 0; // Sets the callback for waiting on a sync point. The callback returns the @@ -310,6 +297,8 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>, // Used for testing only static void set_testing_force_is_angle(bool force); + virtual Logger* GetLogger() = 0; + protected: GLES2Decoder(); @@ -317,7 +306,6 @@ class GPU_EXPORT GLES2Decoder : public base::SupportsWeakPtr<GLES2Decoder>, bool initialized_; bool debug_; bool log_commands_; - bool log_synthesized_gl_errors_; static bool testing_force_is_angle_; DISALLOW_COPY_AND_ASSIGN(GLES2Decoder); diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h index a08a4b1..64f7f4c5 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_mock.h +++ b/gpu/command_buffer/service/gles2_cmd_decoder_mock.h @@ -110,7 +110,7 @@ class MockGLES2Decoder : public GLES2Decoder { MOCK_METHOD3(ClearRealGLErrors, void( const char* file, int line, const char* filename)); - MOCK_METHOD1(SetMsgCallback, void(const MsgCallback& callback)); + MOCK_METHOD0(GetLogger, Logger*()); MOCK_METHOD1(SetShaderCacheCallback, void(const ShaderCacheCallback& callback)); MOCK_METHOD1(SetWaitSyncPointCallback, diff --git a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc index 334e4c8..789b0f2 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder_unittest_base.cc @@ -14,6 +14,7 @@ #include "gpu/command_buffer/service/cmd_buffer_engine.h" #include "gpu/command_buffer/service/context_group.h" #include "gpu/command_buffer/service/gles2_cmd_decoder_mock.h" +#include "gpu/command_buffer/service/logger.h" #include "gpu/command_buffer/service/program_manager.h" #include "gpu/command_buffer/service/vertex_attrib_manager.h" #include "gpu/command_buffer/service/test_helper.h" @@ -258,7 +259,7 @@ void GLES2DecoderTestBase::InitDecoder( std::vector<int32> attribs(attributes, attributes + arraysize(attributes)); decoder_.reset(GLES2Decoder::Create(group_.get())); - decoder_->set_log_synthesized_gl_errors(false); + decoder_->GetLogger()->set_log_synthesized_gl_errors(false); decoder_->Initialize( surface_, context_, false, surface_->GetSize(), DisallowedFeatures(), NULL, attribs); diff --git a/gpu/command_buffer/service/logger.cc b/gpu/command_buffer/service/logger.cc new file mode 100644 index 0000000..54b0233 --- /dev/null +++ b/gpu/command_buffer/service/logger.cc @@ -0,0 +1,62 @@ +// Copyright (c) 2013 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/logger.h" + +#include "base/command_line.h" +#include "base/logging.h" +#include "base/string_number_conversions.h" +#include "gpu/command_buffer/common/debug_marker_manager.h" +#include "gpu/command_buffer/service/gpu_switches.h" + +namespace gpu { +namespace gles2 { + +Logger::Logger(const DebugMarkerManager* debug_marker_manager) + : debug_marker_manager_(debug_marker_manager), + log_message_count_(0), + log_synthesized_gl_errors_(true) { + Logger* this_temp = this; + this_in_hex_ = base::HexEncode(&this_temp, sizeof(this_temp)); +} + +Logger::~Logger() {} + +void Logger::LogMessage( + const char* filename, int line, const std::string& msg) { + if (log_message_count_ < kMaxLogMessages || + CommandLine::ForCurrentProcess()->HasSwitch( + switches::kDisableGLErrorLimit)) { + ++log_message_count_; + // LOG this unless logging is turned off as any chromium code that + // generates these errors probably has a bug. + if (log_synthesized_gl_errors_) { + ::logging::LogMessage( + filename, line, ::logging::LOG_ERROR).stream() << msg; + } + if (!msg_callback_.is_null()) { + msg_callback_.Run(0, msg); + } + } else { + if (log_message_count_ == kMaxLogMessages) { + ++log_message_count_; + LOG(ERROR) + << "Too many GL errors, not reporting any more for this context." + << " use --disable-gl-error-limit to see all errors."; + } + } +} + +const std::string& Logger::GetLogPrefix() const { + const std::string& prefix(debug_marker_manager_->GetMarker()); + return prefix.empty() ? this_in_hex_ : prefix; +} + +void Logger::SetMsgCallback(const MsgCallback& callback) { + msg_callback_ = callback; +} + +} // namespace gles2 +} // namespace gpu + diff --git a/gpu/command_buffer/service/logger.h b/gpu/command_buffer/service/logger.h new file mode 100644 index 0000000..4691443 --- /dev/null +++ b/gpu/command_buffer/service/logger.h @@ -0,0 +1,58 @@ +// Copyright (c) 2013 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. + +// This file contains the Logger class. + +#ifndef GPU_COMMAND_BUFFER_SERVICE_LOGGER_H_ +#define GPU_COMMAND_BUFFER_SERVICE_LOGGER_H_ + +#include <string> + +#include "base/callback.h" +#include "gpu/gpu_export.h" + +namespace gpu { +namespace gles2 { + +typedef base::Callback<void(int32 id, const std::string& msg)> MsgCallback; + +class DebugMarkerManager; + +class GPU_EXPORT Logger { + public: + static const int kMaxLogMessages = 256; + + explicit Logger(const DebugMarkerManager* debug_marker_manager); + ~Logger(); + + void LogMessage(const char* filename, int line, const std::string& msg); + const std::string& GetLogPrefix() const; + + // Defaults to true. Set to false for the gpu_unittests as they + // are explicitly checking errors are generated and so don't need the numerous + // messages. Otherwise, chromium code that generates these errors likely has a + // bug. + void set_log_synthesized_gl_errors(bool enabled) { + log_synthesized_gl_errors_ = enabled; + } + + void SetMsgCallback(const MsgCallback& callback); + + private: + // Uses the current marker to add information to logs. + const DebugMarkerManager* debug_marker_manager_; + std::string this_in_hex_; + + int log_message_count_; + bool log_synthesized_gl_errors_; + + MsgCallback msg_callback_; + DISALLOW_COPY_AND_ASSIGN(Logger); +}; + +} // namespace gles2 +} // namespace gpu + +#endif // GPU_COMMAND_BUFFER_SERVICE_LOGGER_H_ + diff --git a/gpu/command_buffer_service.gypi b/gpu/command_buffer_service.gypi index dc84ca6..b0327ef 100644 --- a/gpu/command_buffer_service.gypi +++ b/gpu/command_buffer_service.gypi @@ -70,6 +70,8 @@ 'command_buffer/service/id_manager.cc', 'command_buffer/service/image_manager.cc', 'command_buffer/service/image_manager.h', + 'command_buffer/service/logger.cc', + 'command_buffer/service/logger.h', 'command_buffer/service/mailbox_manager.cc', 'command_buffer/service/mailbox_manager.h', 'command_buffer/service/memory_program_cache.h', |