Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(156)

Side by Side Diff: gpu/command_buffer/service/feature_info.cc

Issue 10441087: Plum through ANGLE_depth_texture (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/string_number_conversions.h" 9 #include "base/string_number_conversions.h"
10 #include "base/string_util.h" 10 #include "base/string_util.h"
11 #include "gpu/command_buffer/service/gl_utils.h" 11 #include "gpu/command_buffer/service/gl_utils.h"
12 #include "ui/gl/gl_context.h" 12 #include "ui/gl/gl_context.h"
13 #include "ui/gl/gl_implementation.h" 13 #include "ui/gl/gl_implementation.h"
14 #if defined(OS_MACOSX) 14 #if defined(OS_MACOSX)
15 #include "ui/surface/io_surface_support_mac.h" 15 #include "ui/surface/io_surface_support_mac.h"
16 #endif 16 #endif
17 17
18 namespace gpu { 18 namespace gpu {
19 namespace gles2 { 19 namespace gles2 {
20 20
21 namespace {
22
23 struct FormatInfo {
24 GLenum format;
25 const GLenum* types;
26 size_t count;
27 };
28
29 } // anonymous namespace.
30
21 FeatureInfo::FeatureInfo() { 31 FeatureInfo::FeatureInfo() {
32 static const GLenum kAlphaTypes[] = {
33 GL_UNSIGNED_BYTE,
34 };
35 static const GLenum kRGBTypes[] = {
36 GL_UNSIGNED_BYTE,
37 GL_UNSIGNED_SHORT_5_6_5,
38 };
39 static const GLenum kRGBATypes[] = {
40 GL_UNSIGNED_BYTE,
41 GL_UNSIGNED_SHORT_4_4_4_4,
42 GL_UNSIGNED_SHORT_5_5_5_1,
43 };
44 static const GLenum kLuminanceTypes[] = {
45 GL_UNSIGNED_BYTE,
46 };
47 static const GLenum kLuminanceAlphaTypes[] = {
48 GL_UNSIGNED_BYTE,
49 };
50 static const FormatInfo kFormatTypes[] = {
51 { GL_ALPHA, kAlphaTypes, arraysize(kAlphaTypes), },
52 { GL_RGB, kRGBTypes, arraysize(kRGBTypes), },
53 { GL_RGBA, kRGBATypes, arraysize(kRGBATypes), },
54 { GL_LUMINANCE, kLuminanceTypes, arraysize(kLuminanceTypes), },
55 { GL_LUMINANCE_ALPHA, kLuminanceAlphaTypes,
56 arraysize(kLuminanceAlphaTypes), } ,
57 };
58 for (size_t ii = 0; ii < arraysize(kFormatTypes); ++ii) {
59 const FormatInfo& info = kFormatTypes[ii];
60 ValueValidator<GLenum>& validator = texture_format_validators_[info.format];
61 for (size_t jj = 0; jj < info.count; ++jj) {
62 validator.AddValue(info.types[jj]);
63 }
64 }
22 } 65 }
23 66
24 // Helps query for extensions. 67 // Helps query for extensions.
25 class ExtensionHelper { 68 class ExtensionHelper {
26 public: 69 public:
27 ExtensionHelper(const char* extensions, const char* desired_features) 70 ExtensionHelper(const char* extensions, const char* desired_features)
28 : desire_all_features_(false) { 71 : desire_all_features_(false) {
29 // Check for "*" 72 // Check for "*"
30 if (desired_features && 73 if (desired_features &&
31 desired_features[0] == '*' && 74 desired_features[0] == '*' &&
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 // Check if we should enable GL_EXT_texture_filter_anisotropic. 248 // Check if we should enable GL_EXT_texture_filter_anisotropic.
206 if (ext.HaveAndDesire("GL_EXT_texture_filter_anisotropic")) { 249 if (ext.HaveAndDesire("GL_EXT_texture_filter_anisotropic")) {
207 AddExtensionString("GL_EXT_texture_filter_anisotropic"); 250 AddExtensionString("GL_EXT_texture_filter_anisotropic");
208 validators_.texture_parameter.AddValue( 251 validators_.texture_parameter.AddValue(
209 GL_TEXTURE_MAX_ANISOTROPY_EXT); 252 GL_TEXTURE_MAX_ANISOTROPY_EXT);
210 validators_.g_l_state.AddValue( 253 validators_.g_l_state.AddValue(
211 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT); 254 GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT);
212 } 255 }
213 256
214 // Check if we should support GL_OES_packed_depth_stencil and/or 257 // Check if we should support GL_OES_packed_depth_stencil and/or
215 // GL_GOOGLE_depth_texture. 258 // GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
216 // NOTE: GL_OES_depth_texture requires support for depth 259 //
217 // cubemaps. GL_ARB_depth_texture requires other features that 260 // NOTE: GL_OES_depth_texture requires support for depth cubemaps.
218 // GL_OES_packed_depth_stencil does not provide. Therefore we made up 261 // GL_ARB_depth_texture requires other features that
219 // GL_GOOGLE_depth_texture. 262 // GL_OES_packed_depth_stencil does not provide.
263 //
264 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
265 //
266 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
267 // get rid of it.
268 //
220 bool enable_depth_texture = false; 269 bool enable_depth_texture = false;
221 if (ext.Desire("GL_GOOGLE_depth_texture") && 270 if ((ext.Desire("GL_GOOGLE_depth_texture") ||
271 ext.Desire("GL_CHROMIUM_depth_texture")) &&
222 (ext.Have("GL_ARB_depth_texture") || 272 (ext.Have("GL_ARB_depth_texture") ||
223 ext.Have("GL_OES_depth_texture"))) { 273 ext.Have("GL_OES_depth_texture") ||
274 ext.Have("GL_ANGLE_depth_texture"))) {
224 enable_depth_texture = true; 275 enable_depth_texture = true;
276 }
277
278 if (enable_depth_texture) {
279 AddExtensionString("GL_CHROMIUM_depth_texture");
225 AddExtensionString("GL_GOOGLE_depth_texture"); 280 AddExtensionString("GL_GOOGLE_depth_texture");
281 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_SHORT);
282 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_INT);
226 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT); 283 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT);
227 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT); 284 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT);
228 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT); 285 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT);
229 validators_.pixel_type.AddValue(GL_UNSIGNED_INT); 286 validators_.pixel_type.AddValue(GL_UNSIGNED_INT);
230 } 287 }
231 // TODO(gman): Add depth types fo ElementsPerGroup and BytesPerElement
232 288
233 if (ext.Desire("GL_OES_packed_depth_stencil") && 289 if (ext.Desire("GL_OES_packed_depth_stencil") &&
234 (ext.Have("GL_EXT_packed_depth_stencil") || 290 (ext.Have("GL_EXT_packed_depth_stencil") ||
235 ext.Have("GL_OES_packed_depth_stencil"))) { 291 ext.Have("GL_OES_packed_depth_stencil"))) {
236 AddExtensionString("GL_OES_packed_depth_stencil"); 292 AddExtensionString("GL_OES_packed_depth_stencil");
237 if (enable_depth_texture) { 293 if (enable_depth_texture) {
294 texture_format_validators_[GL_DEPTH_STENCIL].AddValue(
295 GL_UNSIGNED_INT_24_8);
238 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL); 296 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL);
239 validators_.texture_format.AddValue(GL_DEPTH_STENCIL); 297 validators_.texture_format.AddValue(GL_DEPTH_STENCIL);
240 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8); 298 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8);
241 } 299 }
242 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8); 300 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
243 } 301 }
244 302
245 bool enable_texture_format_bgra8888 = false; 303 bool enable_texture_format_bgra8888 = false;
246 bool enable_read_format_bgra = false; 304 bool enable_read_format_bgra = false;
247 // Check if we should allow GL_EXT_texture_format_BGRA8888 305 // Check if we should allow GL_EXT_texture_format_BGRA8888
(...skipping 10 matching lines...) Expand all
258 } 316 }
259 317
260 if (ext.Desire("GL_EXT_read_format_bgra") && 318 if (ext.Desire("GL_EXT_read_format_bgra") &&
261 (ext.Have("GL_EXT_read_format_bgra") || 319 (ext.Have("GL_EXT_read_format_bgra") ||
262 ext.Have("GL_EXT_bgra"))) { 320 ext.Have("GL_EXT_bgra"))) {
263 enable_read_format_bgra = true; 321 enable_read_format_bgra = true;
264 } 322 }
265 323
266 if (enable_texture_format_bgra8888) { 324 if (enable_texture_format_bgra8888) {
267 AddExtensionString("GL_EXT_texture_format_BGRA8888"); 325 AddExtensionString("GL_EXT_texture_format_BGRA8888");
326 texture_format_validators_[GL_BGRA_EXT].AddValue(GL_UNSIGNED_BYTE);
268 validators_.texture_internal_format.AddValue(GL_BGRA_EXT); 327 validators_.texture_internal_format.AddValue(GL_BGRA_EXT);
269 validators_.texture_format.AddValue(GL_BGRA_EXT); 328 validators_.texture_format.AddValue(GL_BGRA_EXT);
270 } 329 }
271 330
272 if (enable_read_format_bgra) { 331 if (enable_read_format_bgra) {
273 AddExtensionString("GL_EXT_read_format_bgra"); 332 AddExtensionString("GL_EXT_read_format_bgra");
274 validators_.read_pixel_format.AddValue(GL_BGRA_EXT); 333 validators_.read_pixel_format.AddValue(GL_BGRA_EXT);
275 } 334 }
276 335
277 if (ext.Desire("GL_OES_rgb8_rgba8")) { 336 if (ext.Desire("GL_OES_rgb8_rgba8")) {
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 enable_texture_half_float = true; 380 enable_texture_half_float = true;
322 if (ext.HaveAndDesire("GL_OES_texture_half_float_linear") || 381 if (ext.HaveAndDesire("GL_OES_texture_half_float_linear") ||
323 (have_arb_texture_float && 382 (have_arb_texture_float &&
324 ext.Desire("GL_OES_texture_half_float_linear"))) { 383 ext.Desire("GL_OES_texture_half_float_linear"))) {
325 enable_texture_half_float_linear = true; 384 enable_texture_half_float_linear = true;
326 } 385 }
327 } 386 }
328 } 387 }
329 388
330 if (enable_texture_float) { 389 if (enable_texture_float) {
390 texture_format_validators_[GL_ALPHA].AddValue(GL_FLOAT);
391 texture_format_validators_[GL_RGB].AddValue(GL_FLOAT);
392 texture_format_validators_[GL_RGBA].AddValue(GL_FLOAT);
393 texture_format_validators_[GL_LUMINANCE].AddValue(GL_FLOAT);
394 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_FLOAT);
331 validators_.pixel_type.AddValue(GL_FLOAT); 395 validators_.pixel_type.AddValue(GL_FLOAT);
396 validators_.read_pixel_type.AddValue(GL_FLOAT);
332 AddExtensionString("GL_OES_texture_float"); 397 AddExtensionString("GL_OES_texture_float");
333 if (enable_texture_float_linear) { 398 if (enable_texture_float_linear) {
334 AddExtensionString("GL_OES_texture_float_linear"); 399 AddExtensionString("GL_OES_texture_float_linear");
335 } 400 }
336 } 401 }
337 402
338 if (enable_texture_half_float) { 403 if (enable_texture_half_float) {
404 texture_format_validators_[GL_ALPHA].AddValue(GL_HALF_FLOAT_OES);
405 texture_format_validators_[GL_RGB].AddValue(GL_HALF_FLOAT_OES);
406 texture_format_validators_[GL_RGBA].AddValue(GL_HALF_FLOAT_OES);
407 texture_format_validators_[GL_LUMINANCE].AddValue(GL_HALF_FLOAT_OES);
408 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES);
339 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); 409 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES);
410 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES);
340 AddExtensionString("GL_OES_texture_half_float"); 411 AddExtensionString("GL_OES_texture_half_float");
341 if (enable_texture_half_float_linear) { 412 if (enable_texture_half_float_linear) {
342 AddExtensionString("GL_OES_texture_half_float_linear"); 413 AddExtensionString("GL_OES_texture_half_float_linear");
343 } 414 }
344 } 415 }
345 416
346 // Check for multisample support 417 // Check for multisample support
347 if (!disallowed_features_.multisampling && 418 if (!disallowed_features_.multisampling &&
348 ext.Desire("GL_CHROMIUM_framebuffer_multisample") && 419 ext.Desire("GL_CHROMIUM_framebuffer_multisample") &&
349 (ext.Have("GL_EXT_framebuffer_multisample") || 420 (ext.Have("GL_EXT_framebuffer_multisample") ||
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
507 if (extensions_.find(str) == std::string::npos) { 578 if (extensions_.find(str) == std::string::npos) {
508 extensions_ += (extensions_.empty() ? "" : " ") + str; 579 extensions_ += (extensions_.empty() ? "" : " ") + str;
509 } 580 }
510 } 581 }
511 582
512 FeatureInfo::~FeatureInfo() { 583 FeatureInfo::~FeatureInfo() {
513 } 584 }
514 585
515 } // namespace gles2 586 } // namespace gles2
516 } // namespace gpu 587 } // namespace gpu
OLDNEW
« no previous file with comments | « gpu/command_buffer/service/feature_info.h ('k') | gpu/command_buffer/service/feature_info_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698