| 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 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 | 126 |
| 127 FeatureInfo::Workarounds::Workarounds() : | 127 FeatureInfo::Workarounds::Workarounds() : |
| 128 #define GPU_OP(type, name) name(false), | 128 #define GPU_OP(type, name) name(false), |
| 129 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) | 129 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) |
| 130 #undef GPU_OP | 130 #undef GPU_OP |
| 131 max_texture_size(0), | 131 max_texture_size(0), |
| 132 max_cube_map_texture_size(0) { | 132 max_cube_map_texture_size(0) { |
| 133 } | 133 } |
| 134 | 134 |
| 135 FeatureInfo::FeatureInfo() { | 135 FeatureInfo::FeatureInfo() { |
| 136 InitializeBasicState(*CommandLine::ForCurrentProcess()); |
| 137 } |
| 138 |
| 139 FeatureInfo::FeatureInfo(const CommandLine& command_line) { |
| 140 InitializeBasicState(command_line); |
| 141 } |
| 142 |
| 143 void FeatureInfo::InitializeBasicState(const CommandLine& command_line) { |
| 144 if (command_line.HasSwitch(switches::kGpuDriverBugWorkarounds)) { |
| 145 std::string types = command_line.GetSwitchValueASCII( |
| 146 switches::kGpuDriverBugWorkarounds); |
| 147 StringToWorkarounds(types, &workarounds_); |
| 148 } |
| 149 feature_flags_.enable_shader_name_hashing = |
| 150 !command_line.HasSwitch(switches::kDisableShaderNameHashing); |
| 151 |
| 136 static const GLenum kAlphaTypes[] = { | 152 static const GLenum kAlphaTypes[] = { |
| 137 GL_UNSIGNED_BYTE, | 153 GL_UNSIGNED_BYTE, |
| 138 }; | 154 }; |
| 139 static const GLenum kRGBTypes[] = { | 155 static const GLenum kRGBTypes[] = { |
| 140 GL_UNSIGNED_BYTE, | 156 GL_UNSIGNED_BYTE, |
| 141 GL_UNSIGNED_SHORT_5_6_5, | 157 GL_UNSIGNED_SHORT_5_6_5, |
| 142 }; | 158 }; |
| 143 static const GLenum kRGBATypes[] = { | 159 static const GLenum kRGBATypes[] = { |
| 144 GL_UNSIGNED_BYTE, | 160 GL_UNSIGNED_BYTE, |
| 145 GL_UNSIGNED_SHORT_4_4_4_4, | 161 GL_UNSIGNED_SHORT_4_4_4_4, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 161 }; | 177 }; |
| 162 for (size_t ii = 0; ii < arraysize(kFormatTypes); ++ii) { | 178 for (size_t ii = 0; ii < arraysize(kFormatTypes); ++ii) { |
| 163 const FormatInfo& info = kFormatTypes[ii]; | 179 const FormatInfo& info = kFormatTypes[ii]; |
| 164 ValueValidator<GLenum>& validator = texture_format_validators_[info.format]; | 180 ValueValidator<GLenum>& validator = texture_format_validators_[info.format]; |
| 165 for (size_t jj = 0; jj < info.count; ++jj) { | 181 for (size_t jj = 0; jj < info.count; ++jj) { |
| 166 validator.AddValue(info.types[jj]); | 182 validator.AddValue(info.types[jj]); |
| 167 } | 183 } |
| 168 } | 184 } |
| 169 } | 185 } |
| 170 | 186 |
| 171 bool FeatureInfo::Initialize(const char* allowed_features) { | 187 bool FeatureInfo::Initialize() { |
| 172 disallowed_features_ = DisallowedFeatures(); | 188 disallowed_features_ = DisallowedFeatures(); |
| 173 AddFeatures(*CommandLine::ForCurrentProcess()); | 189 InitializeFeatures(); |
| 174 return true; | 190 return true; |
| 175 } | 191 } |
| 176 | 192 |
| 177 bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features, | 193 bool FeatureInfo::Initialize(const DisallowedFeatures& disallowed_features) { |
| 178 const char* allowed_features) { | |
| 179 disallowed_features_ = disallowed_features; | 194 disallowed_features_ = disallowed_features; |
| 180 AddFeatures(*CommandLine::ForCurrentProcess()); | 195 InitializeFeatures(); |
| 181 return true; | 196 return true; |
| 182 } | 197 } |
| 183 | 198 |
| 184 void FeatureInfo::AddFeatures(const CommandLine& command_line) { | 199 void FeatureInfo::InitializeFeatures() { |
| 185 // Figure out what extensions to turn on. | 200 // Figure out what extensions to turn on. |
| 186 StringSet extensions( | 201 StringSet extensions( |
| 187 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); | 202 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); |
| 188 | 203 |
| 189 if (command_line.HasSwitch(switches::kGpuDriverBugWorkarounds)) { | |
| 190 std::string types = command_line.GetSwitchValueASCII( | |
| 191 switches::kGpuDriverBugWorkarounds); | |
| 192 StringToWorkarounds(types, &workarounds_); | |
| 193 } | |
| 194 | |
| 195 feature_flags_.enable_shader_name_hashing = | |
| 196 !command_line.HasSwitch(switches::kDisableShaderNameHashing); | |
| 197 | |
| 198 bool npot_ok = false; | 204 bool npot_ok = false; |
| 199 | 205 |
| 200 AddExtensionString("GL_ANGLE_translated_shader_source"); | 206 AddExtensionString("GL_ANGLE_translated_shader_source"); |
| 201 AddExtensionString("GL_CHROMIUM_async_pixel_transfers"); | 207 AddExtensionString("GL_CHROMIUM_async_pixel_transfers"); |
| 202 AddExtensionString("GL_CHROMIUM_bind_uniform_location"); | 208 AddExtensionString("GL_CHROMIUM_bind_uniform_location"); |
| 203 AddExtensionString("GL_CHROMIUM_command_buffer_query"); | 209 AddExtensionString("GL_CHROMIUM_command_buffer_query"); |
| 204 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query"); | 210 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query"); |
| 205 AddExtensionString("GL_CHROMIUM_copy_texture"); | 211 AddExtensionString("GL_CHROMIUM_copy_texture"); |
| 206 AddExtensionString("GL_CHROMIUM_discard_backbuffer"); | 212 AddExtensionString("GL_CHROMIUM_discard_backbuffer"); |
| 207 AddExtensionString("GL_CHROMIUM_get_error_query"); | 213 AddExtensionString("GL_CHROMIUM_get_error_query"); |
| (...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 684 if (extensions_.find(str) == std::string::npos) { | 690 if (extensions_.find(str) == std::string::npos) { |
| 685 extensions_ += (extensions_.empty() ? "" : " ") + str; | 691 extensions_ += (extensions_.empty() ? "" : " ") + str; |
| 686 } | 692 } |
| 687 } | 693 } |
| 688 | 694 |
| 689 FeatureInfo::~FeatureInfo() { | 695 FeatureInfo::~FeatureInfo() { |
| 690 } | 696 } |
| 691 | 697 |
| 692 } // namespace gles2 | 698 } // namespace gles2 |
| 693 } // namespace gpu | 699 } // namespace gpu |
| OLD | NEW |