Chromium Code Reviews| 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/feature_info.h" | 5 #include "gpu/command_buffer/service/feature_info.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 224 command_line->HasSwitch(switches::kDisableVirtualContexts); | 224 command_line->HasSwitch(switches::kDisableVirtualContexts); |
| 225 | 225 |
| 226 // The shader translator is needed to translate from WebGL-conformant GLES SL | 226 // The shader translator is needed to translate from WebGL-conformant GLES SL |
| 227 // to normal GLES SL, enforce WebGL conformance, translate from GLES SL 1.0 to | 227 // to normal GLES SL, enforce WebGL conformance, translate from GLES SL 1.0 to |
| 228 // target context GLSL, etc. | 228 // target context GLSL, etc. |
| 229 // The flag here is for testing only. | 229 // The flag here is for testing only. |
| 230 disable_shader_translator_ = | 230 disable_shader_translator_ = |
| 231 command_line->HasSwitch(switches::kDisableGLSLTranslator); | 231 command_line->HasSwitch(switches::kDisableGLSLTranslator); |
| 232 | 232 |
| 233 unsafe_es3_apis_enabled_ = false; | 233 unsafe_es3_apis_enabled_ = false; |
| 234 | |
| 235 // Default context_type_ to a GLES2 Context. | |
| 236 context_type_ = CONTEXT_TYPE_OPENGLES2; | |
| 234 } | 237 } |
| 235 | 238 |
| 236 bool FeatureInfo::Initialize() { | 239 bool FeatureInfo::Initialize(ContextType context_type, |
| 237 disallowed_features_ = DisallowedFeatures(); | 240 const DisallowedFeatures& disallowed_features) { |
| 241 disallowed_features_ = disallowed_features; | |
| 242 context_type_ = context_type; | |
| 238 InitializeFeatures(); | 243 InitializeFeatures(); |
| 239 return true; | 244 return true; |
| 240 } | 245 } |
| 241 | 246 |
| 242 bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features) { | 247 bool FeatureInfo::InitializeForTesting() { |
| 243 disallowed_features_ = disallowed_features; | 248 return Initialize(CONTEXT_TYPE_OPENGLES2, DisallowedFeatures()); |
| 244 InitializeFeatures(); | |
| 245 return true; | |
| 246 } | 249 } |
| 247 | 250 |
| 248 bool IsGL_REDSupportedOnFBOs() { | 251 bool IsGL_REDSupportedOnFBOs() { |
| 249 // Skia uses GL_RED with frame buffers, unfortunately, Mesa claims to support | 252 // Skia uses GL_RED with frame buffers, unfortunately, Mesa claims to support |
| 250 // GL_EXT_texture_rg, but it doesn't support it on frame buffers. To fix | 253 // GL_EXT_texture_rg, but it doesn't support it on frame buffers. To fix |
| 251 // this, we try it, and if it fails, we don't expose GL_EXT_texture_rg. | 254 // this, we try it, and if it fails, we don't expose GL_EXT_texture_rg. |
| 252 GLint fb_binding = 0; | 255 GLint fb_binding = 0; |
| 253 GLint tex_binding = 0; | 256 GLint tex_binding = 0; |
| 254 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb_binding); | 257 glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb_binding); |
| 255 glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex_binding); | 258 glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex_binding); |
| (...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1115 if (workarounds_.avoid_egl_image_target_texture_reuse) { | 1118 if (workarounds_.avoid_egl_image_target_texture_reuse) { |
| 1116 TextureDefinition::AvoidEGLTargetTextureReuse(); | 1119 TextureDefinition::AvoidEGLTargetTextureReuse(); |
| 1117 } | 1120 } |
| 1118 | 1121 |
| 1119 if (gl_version_info_->IsLowerThanGL(4, 3)) { | 1122 if (gl_version_info_->IsLowerThanGL(4, 3)) { |
| 1120 // crbug.com/481184. | 1123 // crbug.com/481184. |
| 1121 // GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+, | 1124 // GL_PRIMITIVE_RESTART_FIXED_INDEX is only available on Desktop GL 4.3+, |
| 1122 // but we emulate ES 3.0 on top of Desktop GL 4.2+. | 1125 // but we emulate ES 3.0 on top of Desktop GL 4.2+. |
| 1123 feature_flags_.emulate_primitive_restart_fixed_index = true; | 1126 feature_flags_.emulate_primitive_restart_fixed_index = true; |
| 1124 } | 1127 } |
| 1128 | |
| 1129 if (workarounds_.disable_msaa_on_non_webgl_contexts) { | |
|
Zhenyao Mo
2015/09/30 23:50:12
This is inconsistent with the rest of the code. B
ericrk
2015/10/01 17:13:11
yup, good point - restructured this.
| |
| 1130 // crbug.com/527565 - On some GPUs, MSAA does not perform acceptably for | |
| 1131 // rasterization. We disable it on non-WebGL contexts. For WebGL contexts | |
| 1132 // we leave it up to the site to decide whether to enable MSAA. | |
| 1133 switch (context_type_) { | |
| 1134 case CONTEXT_TYPE_WEBGL1: | |
| 1135 case CONTEXT_TYPE_WEBGL2: | |
| 1136 // WebGL contexts, ignore this flag. | |
| 1137 break; | |
| 1138 case CONTEXT_TYPE_OPENGLES2: | |
| 1139 case CONTEXT_TYPE_OPENGLES3: | |
| 1140 // Non-WebGL context, disable multisampling. | |
| 1141 feature_flags_.chromium_framebuffer_multisample = false; | |
| 1142 feature_flags_.multisampled_render_to_texture = false; | |
| 1143 } | |
| 1144 } | |
| 1125 } | 1145 } |
| 1126 | 1146 |
| 1127 bool FeatureInfo::IsES3Capable() const { | 1147 bool FeatureInfo::IsES3Capable() const { |
| 1128 if (!enable_unsafe_es3_apis_switch_) | 1148 if (!enable_unsafe_es3_apis_switch_) |
| 1129 return false; | 1149 return false; |
| 1130 if (gl_version_info_) | 1150 if (gl_version_info_) |
| 1131 return gl_version_info_->IsES3Capable(); | 1151 return gl_version_info_->IsES3Capable(); |
| 1132 return false; | 1152 return false; |
| 1133 } | 1153 } |
| 1134 | 1154 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1205 if (pos == std::string::npos) { | 1225 if (pos == std::string::npos) { |
| 1206 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1226 extensions_ += (extensions_.empty() ? "" : " ") + str; |
| 1207 } | 1227 } |
| 1208 } | 1228 } |
| 1209 | 1229 |
| 1210 FeatureInfo::~FeatureInfo() { | 1230 FeatureInfo::~FeatureInfo() { |
| 1211 } | 1231 } |
| 1212 | 1232 |
| 1213 } // namespace gles2 | 1233 } // namespace gles2 |
| 1214 } // namespace gpu | 1234 } // namespace gpu |
| OLD | NEW |