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

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

Issue 72173002: gpu: Support ES3 msaa and depth/stencil formats (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 1 month 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 | Annotate | Revision Log
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/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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
93 if (workarounds->max_cube_map_texture_size_limit_1024) 93 if (workarounds->max_cube_map_texture_size_limit_1024)
94 workarounds->max_cube_map_texture_size = 1024; 94 workarounds->max_cube_map_texture_size = 1024;
95 if (workarounds->max_cube_map_texture_size_limit_512) 95 if (workarounds->max_cube_map_texture_size_limit_512)
96 workarounds->max_cube_map_texture_size = 512; 96 workarounds->max_cube_map_texture_size = 512;
97 } 97 }
98 98
99 } // anonymous namespace. 99 } // anonymous namespace.
100 100
101 FeatureInfo::FeatureFlags::FeatureFlags() 101 FeatureInfo::FeatureFlags::FeatureFlags()
102 : chromium_framebuffer_multisample(false), 102 : chromium_framebuffer_multisample(false),
103 core_framebuffer_multisample(false),
103 multisampled_render_to_texture(false), 104 multisampled_render_to_texture(false),
104 use_img_for_multisampled_render_to_texture(false), 105 use_img_for_multisampled_render_to_texture(false),
105 oes_standard_derivatives(false), 106 oes_standard_derivatives(false),
106 oes_egl_image_external(false), 107 oes_egl_image_external(false),
107 oes_depth24(false), 108 oes_depth24(false),
109 packed_depth24_stencil8(false),
108 npot_ok(false), 110 npot_ok(false),
109 enable_texture_float_linear(false), 111 enable_texture_float_linear(false),
110 enable_texture_half_float_linear(false), 112 enable_texture_half_float_linear(false),
111 chromium_stream_texture(false), 113 chromium_stream_texture(false),
112 angle_translated_shader_source(false), 114 angle_translated_shader_source(false),
113 angle_pack_reverse_row_order(false), 115 angle_pack_reverse_row_order(false),
114 arb_texture_rectangle(false), 116 arb_texture_rectangle(false),
115 angle_instanced_arrays(false), 117 angle_instanced_arrays(false),
116 occlusion_query_boolean(false), 118 occlusion_query_boolean(false),
117 use_arb_occlusion_query2_for_occlusion_query_boolean(false), 119 use_arb_occlusion_query2_for_occlusion_query_boolean(false),
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 return true; 200 return true;
199 } 201 }
200 202
201 void FeatureInfo::InitializeFeatures() { 203 void FeatureInfo::InitializeFeatures() {
202 // Figure out what extensions to turn on. 204 // Figure out what extensions to turn on.
203 StringSet extensions( 205 StringSet extensions(
204 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); 206 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
205 207
206 bool npot_ok = false; 208 bool npot_ok = false;
207 209
210 bool is_es3 = false;
211 const char* str = reinterpret_cast<const char*>(glGetString(GL_VERSION));
212 if (str) {
213 std::string lstr(StringToLowerASCII(std::string(str)));
214 is_es3 = (lstr.substr(0, 12) == "opengl es 3.");
Ken Russell (switch to Gerrit) 2013/11/14 01:18:37 Is this going to scale well to some hypothetical O
Sami 2013/11/14 15:48:53 You could also check for glGetIntegerv({MAJOR_VERS
215 }
216
208 AddExtensionString("GL_ANGLE_translated_shader_source"); 217 AddExtensionString("GL_ANGLE_translated_shader_source");
209 AddExtensionString("GL_CHROMIUM_async_pixel_transfers"); 218 AddExtensionString("GL_CHROMIUM_async_pixel_transfers");
210 AddExtensionString("GL_CHROMIUM_bind_uniform_location"); 219 AddExtensionString("GL_CHROMIUM_bind_uniform_location");
211 AddExtensionString("GL_CHROMIUM_command_buffer_query"); 220 AddExtensionString("GL_CHROMIUM_command_buffer_query");
212 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query"); 221 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query");
213 AddExtensionString("GL_CHROMIUM_copy_texture"); 222 AddExtensionString("GL_CHROMIUM_copy_texture");
214 AddExtensionString("GL_CHROMIUM_discard_backbuffer"); 223 AddExtensionString("GL_CHROMIUM_discard_backbuffer");
215 AddExtensionString("GL_CHROMIUM_get_error_query"); 224 AddExtensionString("GL_CHROMIUM_get_error_query");
216 AddExtensionString("GL_CHROMIUM_lose_context"); 225 AddExtensionString("GL_CHROMIUM_lose_context");
217 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object"); 226 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object");
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 // 314 //
306 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture. 315 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
307 // 316 //
308 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't 317 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
309 // get rid of it. 318 // get rid of it.
310 // 319 //
311 bool enable_depth_texture = false; 320 bool enable_depth_texture = false;
312 if (!workarounds_.disable_depth_texture && 321 if (!workarounds_.disable_depth_texture &&
313 (extensions.Contains("GL_ARB_depth_texture") || 322 (extensions.Contains("GL_ARB_depth_texture") ||
314 extensions.Contains("GL_OES_depth_texture") || 323 extensions.Contains("GL_OES_depth_texture") ||
315 extensions.Contains("GL_ANGLE_depth_texture"))) { 324 extensions.Contains("GL_ANGLE_depth_texture") || is_es3)) {
316 enable_depth_texture = true; 325 enable_depth_texture = true;
317 } 326 }
318 327
319 if (enable_depth_texture) { 328 if (enable_depth_texture) {
320 AddExtensionString("GL_CHROMIUM_depth_texture"); 329 AddExtensionString("GL_CHROMIUM_depth_texture");
321 AddExtensionString("GL_GOOGLE_depth_texture"); 330 AddExtensionString("GL_GOOGLE_depth_texture");
322 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_SHORT); 331 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_SHORT);
323 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_INT); 332 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_INT);
324 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT); 333 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT);
325 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT); 334 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT);
326 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT); 335 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT);
327 validators_.pixel_type.AddValue(GL_UNSIGNED_INT); 336 validators_.pixel_type.AddValue(GL_UNSIGNED_INT);
328 } 337 }
329 338
330 if (extensions.Contains("GL_EXT_packed_depth_stencil") || 339 if (extensions.Contains("GL_EXT_packed_depth_stencil") ||
331 extensions.Contains("GL_OES_packed_depth_stencil")) { 340 extensions.Contains("GL_OES_packed_depth_stencil") || is_es3) {
332 AddExtensionString("GL_OES_packed_depth_stencil"); 341 AddExtensionString("GL_OES_packed_depth_stencil");
342 feature_flags_.packed_depth24_stencil8 = true;
333 if (enable_depth_texture) { 343 if (enable_depth_texture) {
334 texture_format_validators_[GL_DEPTH_STENCIL].AddValue( 344 texture_format_validators_[GL_DEPTH_STENCIL]
335 GL_UNSIGNED_INT_24_8); 345 .AddValue(GL_UNSIGNED_INT_24_8);
336 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL); 346 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL);
337 validators_.texture_format.AddValue(GL_DEPTH_STENCIL); 347 validators_.texture_format.AddValue(GL_DEPTH_STENCIL);
338 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8); 348 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8);
339 } 349 }
340 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8); 350 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
341 } 351 }
342 352
343 if (extensions.Contains("GL_OES_vertex_array_object") || 353 if (extensions.Contains("GL_OES_vertex_array_object") ||
344 extensions.Contains("GL_ARB_vertex_array_object") || 354 extensions.Contains("GL_ARB_vertex_array_object") ||
345 extensions.Contains("GL_APPLE_vertex_array_object")) { 355 extensions.Contains("GL_APPLE_vertex_array_object")) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
463 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES); 473 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES);
464 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); 474 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES);
465 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES); 475 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES);
466 AddExtensionString("GL_OES_texture_half_float"); 476 AddExtensionString("GL_OES_texture_half_float");
467 if (enable_texture_half_float_linear) { 477 if (enable_texture_half_float_linear) {
468 AddExtensionString("GL_OES_texture_half_float_linear"); 478 AddExtensionString("GL_OES_texture_half_float_linear");
469 } 479 }
470 } 480 }
471 481
472 // Check for multisample support 482 // Check for multisample support
473 if (!disallowed_features_.multisampling) { 483 if (!disallowed_features_.multisampling &&
484 !workarounds_.disable_framebuffer_multisample) {
474 bool ext_has_multisample = 485 bool ext_has_multisample =
475 extensions.Contains("GL_EXT_framebuffer_multisample"); 486 extensions.Contains("GL_EXT_framebuffer_multisample") || is_es3;
476 if (!workarounds_.disable_angle_framebuffer_multisample) { 487 if (!workarounds_.disable_angle_framebuffer_multisample) {
477 ext_has_multisample |= 488 ext_has_multisample |=
478 extensions.Contains("GL_ANGLE_framebuffer_multisample"); 489 extensions.Contains("GL_ANGLE_framebuffer_multisample");
479 } 490 }
491 feature_flags_.core_framebuffer_multisample = is_es3;
480 if (ext_has_multisample) { 492 if (ext_has_multisample) {
481 feature_flags_.chromium_framebuffer_multisample = true; 493 feature_flags_.chromium_framebuffer_multisample = true;
482 validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT); 494 validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT);
483 validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT); 495 validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT);
484 validators_.g_l_state.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT); 496 validators_.g_l_state.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT);
485 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT); 497 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT);
486 validators_.render_buffer_parameter.AddValue(GL_RENDERBUFFER_SAMPLES_EXT); 498 validators_.render_buffer_parameter.AddValue(GL_RENDERBUFFER_SAMPLES_EXT);
487 AddExtensionString("GL_CHROMIUM_framebuffer_multisample"); 499 AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
488 } else { 500 } else {
489 if (extensions.Contains("GL_EXT_multisampled_render_to_texture")) { 501 if (extensions.Contains("GL_EXT_multisampled_render_to_texture")) {
490 feature_flags_.multisampled_render_to_texture = true; 502 feature_flags_.multisampled_render_to_texture = true;
491 } else if (extensions.Contains("GL_IMG_multisampled_render_to_texture")) { 503 } else if (extensions.Contains("GL_IMG_multisampled_render_to_texture")) {
492 feature_flags_.multisampled_render_to_texture = true; 504 feature_flags_.multisampled_render_to_texture = true;
493 feature_flags_.use_img_for_multisampled_render_to_texture = true; 505 feature_flags_.use_img_for_multisampled_render_to_texture = true;
494 } 506 }
495 if (feature_flags_.multisampled_render_to_texture) { 507 if (feature_flags_.multisampled_render_to_texture) {
496 validators_.render_buffer_parameter.AddValue( 508 validators_.render_buffer_parameter.AddValue(
497 GL_RENDERBUFFER_SAMPLES_EXT); 509 GL_RENDERBUFFER_SAMPLES_EXT);
498 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT); 510 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT);
499 validators_.frame_buffer_parameter.AddValue( 511 validators_.frame_buffer_parameter.AddValue(
500 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT); 512 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT);
501 AddExtensionString("GL_EXT_multisampled_render_to_texture"); 513 AddExtensionString("GL_EXT_multisampled_render_to_texture");
502 } 514 }
503 } 515 }
504 } 516 }
505 517
506 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures()) { 518 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
519 is_es3) {
507 AddExtensionString("GL_OES_depth24"); 520 AddExtensionString("GL_OES_depth24");
508 feature_flags_.oes_depth24 = true; 521 feature_flags_.oes_depth24 = true;
509 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24); 522 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24);
510 } 523 }
511 524
512 if (!workarounds_.disable_oes_standard_derivatives && 525 if (!workarounds_.disable_oes_standard_derivatives &&
513 (extensions.Contains("GL_OES_standard_derivatives") || 526 (extensions.Contains("GL_OES_standard_derivatives") ||
514 gfx::HasDesktopGLFeatures())) { 527 gfx::HasDesktopGLFeatures())) {
515 AddExtensionString("GL_OES_standard_derivatives"); 528 AddExtensionString("GL_OES_standard_derivatives");
516 feature_flags_.oes_standard_derivatives = true; 529 feature_flags_.oes_standard_derivatives = true;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
656 } 669 }
657 670
658 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) { 671 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
659 AddExtensionString("GL_EXT_frag_depth"); 672 AddExtensionString("GL_EXT_frag_depth");
660 feature_flags_.ext_frag_depth = true; 673 feature_flags_.ext_frag_depth = true;
661 } 674 }
662 675
663 if (!disallowed_features_.swap_buffer_complete_callback) 676 if (!disallowed_features_.swap_buffer_complete_callback)
664 AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback"); 677 AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback");
665 678
666 bool is_es3 = false;
667 const char* str = reinterpret_cast<const char*>(glGetString(GL_VERSION));
668 if (str) {
669 std::string lstr(StringToLowerASCII(std::string(str)));
670 is_es3 = (lstr.substr(0, 12) == "opengl es 3.");
671 }
672
673 bool ui_gl_fence_works = extensions.Contains("GL_NV_fence") || 679 bool ui_gl_fence_works = extensions.Contains("GL_NV_fence") ||
674 extensions.Contains("GL_ARB_sync") || 680 extensions.Contains("GL_ARB_sync") ||
675 extensions.Contains("EGL_KHR_fence_sync"); 681 extensions.Contains("EGL_KHR_fence_sync");
676 682
677 feature_flags_.map_buffer_range = 683 feature_flags_.map_buffer_range =
678 is_es3 || extensions.Contains("GL_ARB_map_buffer_range"); 684 is_es3 || extensions.Contains("GL_ARB_map_buffer_range");
679 685
680 // Really it's part of core OpenGL 2.1 and up, but let's assume the 686 // Really it's part of core OpenGL 2.1 and up, but let's assume the
681 // extension is still advertised. 687 // extension is still advertised.
682 bool has_pixel_buffers = 688 bool has_pixel_buffers =
(...skipping 23 matching lines...) Expand all
706 if (extensions_.find(str) == std::string::npos) { 712 if (extensions_.find(str) == std::string::npos) {
707 extensions_ += (extensions_.empty() ? "" : " ") + str; 713 extensions_ += (extensions_.empty() ? "" : " ") + str;
708 } 714 }
709 } 715 }
710 716
711 FeatureInfo::~FeatureInfo() { 717 FeatureInfo::~FeatureInfo() {
712 } 718 }
713 719
714 } // namespace gles2 720 } // namespace gles2
715 } // namespace gpu 721 } // namespace gpu
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698