diff options
author | bajones@chromium.org <bajones@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-28 03:11:47 +0000 |
---|---|---|
committer | bajones@chromium.org <bajones@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-11-28 03:11:47 +0000 |
commit | 65f7efeeb67580e7d1a25ce391b736f12d46fc3c (patch) | |
tree | 37d026713e87e2c4c6ebe377f0498d65ad94ce6a /gpu | |
parent | aac23602db1391f06f0ac6b4eda5abbba4ee1083 (diff) | |
download | chromium_src-65f7efeeb67580e7d1a25ce391b736f12d46fc3c.zip chromium_src-65f7efeeb67580e7d1a25ce391b736f12d46fc3c.tar.gz chromium_src-65f7efeeb67580e7d1a25ce391b736f12d46fc3c.tar.bz2 |
Implemented failIfMajorPerformanceCaveat WebGL context creation attribute.
Currently only fails if using swiftshader.
BUG=319965
R=kbr@chromium.org, piman@chromium.org, zmo@chromium.org
Review URL: https://codereview.chromium.org/79123004
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@237661 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu')
-rw-r--r-- | gpu/command_buffer/client/gl_in_process_context.cc | 14 | ||||
-rw-r--r-- | gpu/command_buffer/client/gl_in_process_context.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_utils.cc | 9 | ||||
-rw-r--r-- | gpu/command_buffer/common/gles2_cmd_utils.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/service/feature_info.cc | 6 | ||||
-rw-r--r-- | gpu/command_buffer/service/feature_info.h | 1 | ||||
-rw-r--r-- | gpu/command_buffer/service/gles2_cmd_decoder.cc | 25 |
7 files changed, 45 insertions, 12 deletions
diff --git a/gpu/command_buffer/client/gl_in_process_context.cc b/gpu/command_buffer/client/gl_in_process_context.cc index a1ca1a2..ab5cede 100644 --- a/gpu/command_buffer/client/gl_in_process_context.cc +++ b/gpu/command_buffer/client/gl_in_process_context.cc @@ -128,6 +128,9 @@ bool GLInProcessContextImpl::Initialize( gfx::GpuPreference gpu_preference) { DCHECK(size.width() >= 0 && size.height() >= 0); + // Changes to these values should also be copied to + // gpu/command_buffer/client/gl_in_process_context.cc and to + // content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h const int32 ALPHA_SIZE = 0x3021; const int32 BLUE_SIZE = 0x3022; const int32 GREEN_SIZE = 0x3023; @@ -138,6 +141,9 @@ bool GLInProcessContextImpl::Initialize( const int32 SAMPLE_BUFFERS = 0x3032; const int32 NONE = 0x3038; + // Chromium-specific attributes + const int32 FAIL_IF_MAJOR_PERF_CAVEAT = 0x10002; + std::vector<int32> attrib_vector; if (attribs.alpha_size >= 0) { attrib_vector.push_back(ALPHA_SIZE); @@ -171,6 +177,10 @@ bool GLInProcessContextImpl::Initialize( attrib_vector.push_back(SAMPLE_BUFFERS); attrib_vector.push_back(attribs.sample_buffers); } + if (attribs.fail_if_major_perf_caveat > 0) { + attrib_vector.push_back(FAIL_IF_MAJOR_PERF_CAVEAT); + attrib_vector.push_back(attribs.fail_if_major_perf_caveat); + } attrib_vector.push_back(NONE); base::Closure wrapped_callback = @@ -207,14 +217,14 @@ bool GLInProcessContextImpl::Initialize( gpu_preference, wrapped_callback, share_group_id_)) { - LOG(INFO) << "Failed to initialize InProcessCommmandBuffer"; + LOG(ERROR) << "Failed to initialize InProcessCommmandBuffer"; return false; } // Create the GLES2 helper, which writes the command buffer protocol. gles2_helper_.reset(new gles2::GLES2CmdHelper(command_buffer_.get())); if (!gles2_helper_->Initialize(kCommandBufferSize)) { - LOG(INFO) << "Failed to initialize GLES2CmdHelper"; + LOG(ERROR) << "Failed to initialize GLES2CmdHelper"; Destroy(); return false; } diff --git a/gpu/command_buffer/client/gl_in_process_context.h b/gpu/command_buffer/client/gl_in_process_context.h index 8cb577b..6d96f13 100644 --- a/gpu/command_buffer/client/gl_in_process_context.h +++ b/gpu/command_buffer/client/gl_in_process_context.h @@ -40,6 +40,7 @@ struct GLES2_IMPL_EXPORT GLInProcessContextAttribs { int32 stencil_size; int32 samples; int32 sample_buffers; + int32 fail_if_major_perf_caveat; }; class GLES2_IMPL_EXPORT GLInProcessContext { diff --git a/gpu/command_buffer/common/gles2_cmd_utils.cc b/gpu/command_buffer/common/gles2_cmd_utils.cc index c7e36df..abc3544 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.cc +++ b/gpu/command_buffer/common/gles2_cmd_utils.cc @@ -734,6 +734,7 @@ const int32 kBufferDestroyed = 0x3095; // EGL_BUFFER_DESTROYED // Chromium only. const int32 kShareResources = 0x10000; const int32 kBindGeneratesResource = 0x10001; +const int32 kFailIfMajorPerfCaveat = 0x10002; } // namespace @@ -748,7 +749,8 @@ ContextCreationAttribHelper::ContextCreationAttribHelper() sample_buffers_(-1), buffer_preserved_(true), share_resources_(false), - bind_generates_resource_(true) { + bind_generates_resource_(true), + fail_if_major_perf_caveat_(false) { } void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { @@ -790,6 +792,8 @@ void ContextCreationAttribHelper::Serialize(std::vector<int32>* attribs) { attribs->push_back(share_resources_ ? 1 : 0); attribs->push_back(kBindGeneratesResource); attribs->push_back(bind_generates_resource_ ? 1 : 0); + attribs->push_back(kFailIfMajorPerfCaveat); + attribs->push_back(fail_if_major_perf_caveat_ ? 1 : 0); attribs->push_back(kNone); } @@ -841,6 +845,9 @@ bool ContextCreationAttribHelper::Parse(const std::vector<int32>& attribs) { case kBindGeneratesResource: bind_generates_resource_ = value != 0; break; + case kFailIfMajorPerfCaveat: + fail_if_major_perf_caveat_ = value != 0; + break; case kNone: // Terminate list, even if more attributes. return true; diff --git a/gpu/command_buffer/common/gles2_cmd_utils.h b/gpu/command_buffer/common/gles2_cmd_utils.h index b8619e6..bc34304 100644 --- a/gpu/command_buffer/common/gles2_cmd_utils.h +++ b/gpu/command_buffer/common/gles2_cmd_utils.h @@ -193,6 +193,7 @@ class GLES2_UTILS_EXPORT ContextCreationAttribHelper { bool buffer_preserved_; bool share_resources_; bool bind_generates_resource_; + bool fail_if_major_perf_caveat_; }; } // namespace gles2 diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc index 4257b1f..40c3701 100644 --- a/gpu/command_buffer/service/feature_info.cc +++ b/gpu/command_buffer/service/feature_info.cc @@ -127,7 +127,8 @@ FeatureInfo::FeatureFlags::FeatureFlags() map_buffer_range(false), ext_discard_framebuffer(false), angle_depth_texture(false), - is_angle(false) { + is_angle(false), + is_swiftshader(false) { } FeatureInfo::Workarounds::Workarounds() : @@ -155,6 +156,9 @@ void FeatureInfo::InitializeBasicState(const CommandLine& command_line) { feature_flags_.enable_shader_name_hashing = !command_line.HasSwitch(switches::kDisableShaderNameHashing); + feature_flags_.is_swiftshader = + (command_line.GetSwitchValueASCII(switches::kUseGL) == "swiftshader"); + static const GLenum kAlphaTypes[] = { GL_UNSIGNED_BYTE, }; diff --git a/gpu/command_buffer/service/feature_info.h b/gpu/command_buffer/service/feature_info.h index 5202c26..46eda99 100644 --- a/gpu/command_buffer/service/feature_info.h +++ b/gpu/command_buffer/service/feature_info.h @@ -59,6 +59,7 @@ class GPU_EXPORT FeatureInfo : public base::RefCounted<FeatureInfo> { bool ext_discard_framebuffer; bool angle_depth_texture; bool is_angle; + bool is_swiftshader; }; struct Workarounds { diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc index 4633580..3364f0c 100644 --- a/gpu/command_buffer/service/gles2_cmd_decoder.cc +++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc @@ -909,9 +909,9 @@ class GLES2DecoderImpl : public GLES2Decoder, void LogClientServiceMapping( const char* function_name, GLuint client_id, GLuint service_id) { if (service_logging_) { - DLOG(INFO) << "[" << logger_.GetLogPrefix() << "] " << function_name - << ": client_id = " << client_id - << ", service_id = " << service_id; + VLOG(1) << "[" << logger_.GetLogPrefix() << "] " << function_name + << ": client_id = " << client_id + << ", service_id = " << service_id; } } template<typename T> @@ -2215,6 +2215,19 @@ bool GLES2DecoderImpl::Initialize( context_ = context; surface_ = surface; + ContextCreationAttribHelper attrib_parser; + if (!attrib_parser.Parse(attribs)) + return false; + + // If the failIfMajorPerformanceCaveat context creation attribute was true + // and we are using a software renderer, fail. + if (attrib_parser.fail_if_major_perf_caveat_ && + feature_info_->feature_flags().is_swiftshader) { + group_ = NULL; // Must not destroy ContextGroup if it is not initialized. + Destroy(true); + return false; + } + if (!group_->Initialize(this, disallowed_features)) { LOG(ERROR) << "GpuScheduler::InitializeCommon failed because group " << "failed to initialize."; @@ -2277,10 +2290,6 @@ bool GLES2DecoderImpl::Initialize( glActiveTexture(GL_TEXTURE0); CHECK_GL_ERROR(); - ContextCreationAttribHelper attrib_parser; - if (!attrib_parser.Parse(attribs)) - return false; - if (offscreen) { if (attrib_parser.samples_ > 0 && attrib_parser.sample_buffers_ > 0 && features().chromium_framebuffer_multisample) { @@ -3481,7 +3490,7 @@ error::Error GLES2DecoderImpl::DoCommand( error::Error result = error::kNoError; if (log_commands()) { // TODO(notme): Change this to a LOG/VLOG that works in release. Tried - // LOG(INFO), tried VLOG(1), no luck. + // VLOG(1), no luck. LOG(ERROR) << "[" << logger_.GetLogPrefix() << "]" << "cmd: " << GetCommandName(command); } |