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

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: comment, 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 use_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),
118 use_arb_occlusion_query_for_occlusion_query_boolean(false), 120 use_arb_occlusion_query_for_occlusion_query_boolean(false),
119 native_vertex_array_object(false), 121 native_vertex_array_object(false),
120 enable_shader_name_hashing(false), 122 enable_shader_name_hashing(false),
121 enable_samplers(false), 123 enable_samplers(false),
122 ext_draw_buffers(false), 124 ext_draw_buffers(false),
123 ext_frag_depth(false), 125 ext_frag_depth(false),
124 use_async_readpixels(false), 126 use_async_readpixels(false),
125 map_buffer_range(false), 127 map_buffer_range(false),
126 ext_discard_framebuffer(false), 128 ext_discard_framebuffer(false),
127 angle_depth_texture(false) { 129 angle_depth_texture(false),
130 is_angle(false) {
128 } 131 }
129 132
130 FeatureInfo::Workarounds::Workarounds() : 133 FeatureInfo::Workarounds::Workarounds() :
131 #define GPU_OP(type, name) name(false), 134 #define GPU_OP(type, name) name(false),
132 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP) 135 GPU_DRIVER_BUG_WORKAROUNDS(GPU_OP)
133 #undef GPU_OP 136 #undef GPU_OP
134 max_texture_size(0), 137 max_texture_size(0),
135 max_cube_map_texture_size(0) { 138 max_cube_map_texture_size(0) {
136 } 139 }
137 140
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 return true; 202 return true;
200 } 203 }
201 204
202 void FeatureInfo::InitializeFeatures() { 205 void FeatureInfo::InitializeFeatures() {
203 // Figure out what extensions to turn on. 206 // Figure out what extensions to turn on.
204 StringSet extensions( 207 StringSet extensions(
205 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS))); 208 reinterpret_cast<const char*>(glGetString(GL_EXTENSIONS)));
206 209
207 bool npot_ok = false; 210 bool npot_ok = false;
208 211
212 const char* renderer_str =
213 reinterpret_cast<const char*>(glGetString(GL_RENDERER));
214 if (renderer_str) {
215 feature_flags_.is_angle = StartsWithASCII(renderer_str, "ANGLE", true);
216 }
217
218 bool is_es3 = false;
219 const char* version_str =
220 reinterpret_cast<const char*>(glGetString(GL_VERSION));
221 if (version_str) {
222 std::string lstr(StringToLowerASCII(std::string(version_str)));
223 is_es3 = (lstr.substr(0, 12) == "opengl es 3.");
224 }
225
209 AddExtensionString("GL_ANGLE_translated_shader_source"); 226 AddExtensionString("GL_ANGLE_translated_shader_source");
210 AddExtensionString("GL_CHROMIUM_async_pixel_transfers"); 227 AddExtensionString("GL_CHROMIUM_async_pixel_transfers");
211 AddExtensionString("GL_CHROMIUM_bind_uniform_location"); 228 AddExtensionString("GL_CHROMIUM_bind_uniform_location");
212 AddExtensionString("GL_CHROMIUM_command_buffer_query"); 229 AddExtensionString("GL_CHROMIUM_command_buffer_query");
213 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query"); 230 AddExtensionString("GL_CHROMIUM_command_buffer_latency_query");
214 AddExtensionString("GL_CHROMIUM_copy_texture"); 231 AddExtensionString("GL_CHROMIUM_copy_texture");
215 AddExtensionString("GL_CHROMIUM_discard_backbuffer"); 232 AddExtensionString("GL_CHROMIUM_discard_backbuffer");
216 AddExtensionString("GL_CHROMIUM_get_error_query"); 233 AddExtensionString("GL_CHROMIUM_get_error_query");
217 AddExtensionString("GL_CHROMIUM_lose_context"); 234 AddExtensionString("GL_CHROMIUM_lose_context");
218 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object"); 235 AddExtensionString("GL_CHROMIUM_pixel_transfer_buffer_object");
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 // 323 //
307 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture. 324 // Therefore we made up GL_GOOGLE_depth_texture / GL_CHROMIUM_depth_texture.
308 // 325 //
309 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't 326 // GL_GOOGLE_depth_texture is legacy. As we exposed it into NaCl we can't
310 // get rid of it. 327 // get rid of it.
311 // 328 //
312 bool enable_depth_texture = false; 329 bool enable_depth_texture = false;
313 if (!workarounds_.disable_depth_texture && 330 if (!workarounds_.disable_depth_texture &&
314 (extensions.Contains("GL_ARB_depth_texture") || 331 (extensions.Contains("GL_ARB_depth_texture") ||
315 extensions.Contains("GL_OES_depth_texture") || 332 extensions.Contains("GL_OES_depth_texture") ||
316 extensions.Contains("GL_ANGLE_depth_texture"))) { 333 extensions.Contains("GL_ANGLE_depth_texture") || is_es3)) {
317 enable_depth_texture = true; 334 enable_depth_texture = true;
318 feature_flags_.angle_depth_texture = 335 feature_flags_.angle_depth_texture =
319 extensions.Contains("GL_ANGLE_depth_texture"); 336 extensions.Contains("GL_ANGLE_depth_texture");
320 } 337 }
321 338
322 if (enable_depth_texture) { 339 if (enable_depth_texture) {
323 AddExtensionString("GL_CHROMIUM_depth_texture"); 340 AddExtensionString("GL_CHROMIUM_depth_texture");
324 AddExtensionString("GL_GOOGLE_depth_texture"); 341 AddExtensionString("GL_GOOGLE_depth_texture");
325 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_SHORT); 342 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_SHORT);
326 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_INT); 343 texture_format_validators_[GL_DEPTH_COMPONENT].AddValue(GL_UNSIGNED_INT);
327 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT); 344 validators_.texture_internal_format.AddValue(GL_DEPTH_COMPONENT);
328 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT); 345 validators_.texture_format.AddValue(GL_DEPTH_COMPONENT);
329 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT); 346 validators_.pixel_type.AddValue(GL_UNSIGNED_SHORT);
330 validators_.pixel_type.AddValue(GL_UNSIGNED_INT); 347 validators_.pixel_type.AddValue(GL_UNSIGNED_INT);
331 } 348 }
332 349
333 if (extensions.Contains("GL_EXT_packed_depth_stencil") || 350 if (extensions.Contains("GL_EXT_packed_depth_stencil") ||
334 extensions.Contains("GL_OES_packed_depth_stencil")) { 351 extensions.Contains("GL_OES_packed_depth_stencil") || is_es3) {
335 AddExtensionString("GL_OES_packed_depth_stencil"); 352 AddExtensionString("GL_OES_packed_depth_stencil");
353 feature_flags_.packed_depth24_stencil8 = true;
336 if (enable_depth_texture) { 354 if (enable_depth_texture) {
337 texture_format_validators_[GL_DEPTH_STENCIL].AddValue( 355 texture_format_validators_[GL_DEPTH_STENCIL]
338 GL_UNSIGNED_INT_24_8); 356 .AddValue(GL_UNSIGNED_INT_24_8);
339 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL); 357 validators_.texture_internal_format.AddValue(GL_DEPTH_STENCIL);
340 validators_.texture_format.AddValue(GL_DEPTH_STENCIL); 358 validators_.texture_format.AddValue(GL_DEPTH_STENCIL);
341 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8); 359 validators_.pixel_type.AddValue(GL_UNSIGNED_INT_24_8);
342 } 360 }
343 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8); 361 validators_.render_buffer_format.AddValue(GL_DEPTH24_STENCIL8);
344 } 362 }
345 363
346 if (extensions.Contains("GL_OES_vertex_array_object") || 364 if (extensions.Contains("GL_OES_vertex_array_object") ||
347 extensions.Contains("GL_ARB_vertex_array_object") || 365 extensions.Contains("GL_ARB_vertex_array_object") ||
348 extensions.Contains("GL_APPLE_vertex_array_object")) { 366 extensions.Contains("GL_APPLE_vertex_array_object")) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
466 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES); 484 texture_format_validators_[GL_LUMINANCE_ALPHA].AddValue(GL_HALF_FLOAT_OES);
467 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES); 485 validators_.pixel_type.AddValue(GL_HALF_FLOAT_OES);
468 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES); 486 validators_.read_pixel_type.AddValue(GL_HALF_FLOAT_OES);
469 AddExtensionString("GL_OES_texture_half_float"); 487 AddExtensionString("GL_OES_texture_half_float");
470 if (enable_texture_half_float_linear) { 488 if (enable_texture_half_float_linear) {
471 AddExtensionString("GL_OES_texture_half_float_linear"); 489 AddExtensionString("GL_OES_texture_half_float_linear");
472 } 490 }
473 } 491 }
474 492
475 // Check for multisample support 493 // Check for multisample support
476 if (!disallowed_features_.multisampling) { 494 if (!disallowed_features_.multisampling &&
495 !workarounds_.disable_framebuffer_multisample) {
477 bool ext_has_multisample = 496 bool ext_has_multisample =
478 extensions.Contains("GL_EXT_framebuffer_multisample"); 497 extensions.Contains("GL_EXT_framebuffer_multisample") || is_es3;
479 if (!workarounds_.disable_angle_framebuffer_multisample) { 498 if (feature_flags_.is_angle) {
480 ext_has_multisample |= 499 ext_has_multisample |=
481 extensions.Contains("GL_ANGLE_framebuffer_multisample"); 500 extensions.Contains("GL_ANGLE_framebuffer_multisample");
482 } 501 }
502 feature_flags_.use_core_framebuffer_multisample = is_es3;
483 if (ext_has_multisample) { 503 if (ext_has_multisample) {
484 feature_flags_.chromium_framebuffer_multisample = true; 504 feature_flags_.chromium_framebuffer_multisample = true;
485 validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT); 505 validators_.frame_buffer_target.AddValue(GL_READ_FRAMEBUFFER_EXT);
486 validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT); 506 validators_.frame_buffer_target.AddValue(GL_DRAW_FRAMEBUFFER_EXT);
487 validators_.g_l_state.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT); 507 validators_.g_l_state.AddValue(GL_READ_FRAMEBUFFER_BINDING_EXT);
488 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT); 508 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT);
489 validators_.render_buffer_parameter.AddValue(GL_RENDERBUFFER_SAMPLES_EXT); 509 validators_.render_buffer_parameter.AddValue(GL_RENDERBUFFER_SAMPLES_EXT);
490 AddExtensionString("GL_CHROMIUM_framebuffer_multisample"); 510 AddExtensionString("GL_CHROMIUM_framebuffer_multisample");
491 } else { 511 } else {
492 if (extensions.Contains("GL_EXT_multisampled_render_to_texture")) { 512 if (extensions.Contains("GL_EXT_multisampled_render_to_texture")) {
493 feature_flags_.multisampled_render_to_texture = true; 513 feature_flags_.multisampled_render_to_texture = true;
494 } else if (extensions.Contains("GL_IMG_multisampled_render_to_texture")) { 514 } else if (extensions.Contains("GL_IMG_multisampled_render_to_texture")) {
495 feature_flags_.multisampled_render_to_texture = true; 515 feature_flags_.multisampled_render_to_texture = true;
496 feature_flags_.use_img_for_multisampled_render_to_texture = true; 516 feature_flags_.use_img_for_multisampled_render_to_texture = true;
497 } 517 }
498 if (feature_flags_.multisampled_render_to_texture) { 518 if (feature_flags_.multisampled_render_to_texture) {
499 validators_.render_buffer_parameter.AddValue( 519 validators_.render_buffer_parameter.AddValue(
500 GL_RENDERBUFFER_SAMPLES_EXT); 520 GL_RENDERBUFFER_SAMPLES_EXT);
501 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT); 521 validators_.g_l_state.AddValue(GL_MAX_SAMPLES_EXT);
502 validators_.frame_buffer_parameter.AddValue( 522 validators_.frame_buffer_parameter.AddValue(
503 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT); 523 GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_SAMPLES_EXT);
504 AddExtensionString("GL_EXT_multisampled_render_to_texture"); 524 AddExtensionString("GL_EXT_multisampled_render_to_texture");
505 } 525 }
506 } 526 }
507 } 527 }
508 528
509 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures()) { 529 if (extensions.Contains("GL_OES_depth24") || gfx::HasDesktopGLFeatures() ||
530 is_es3) {
510 AddExtensionString("GL_OES_depth24"); 531 AddExtensionString("GL_OES_depth24");
511 feature_flags_.oes_depth24 = true; 532 feature_flags_.oes_depth24 = true;
512 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24); 533 validators_.render_buffer_format.AddValue(GL_DEPTH_COMPONENT24);
513 } 534 }
514 535
515 if (!workarounds_.disable_oes_standard_derivatives && 536 if (!workarounds_.disable_oes_standard_derivatives &&
516 (extensions.Contains("GL_OES_standard_derivatives") || 537 (extensions.Contains("GL_OES_standard_derivatives") ||
517 gfx::HasDesktopGLFeatures())) { 538 gfx::HasDesktopGLFeatures())) {
518 AddExtensionString("GL_OES_standard_derivatives"); 539 AddExtensionString("GL_OES_standard_derivatives");
519 feature_flags_.oes_standard_derivatives = true; 540 feature_flags_.oes_standard_derivatives = true;
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 } 680 }
660 681
661 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) { 682 if (extensions.Contains("GL_EXT_frag_depth") || gfx::HasDesktopGLFeatures()) {
662 AddExtensionString("GL_EXT_frag_depth"); 683 AddExtensionString("GL_EXT_frag_depth");
663 feature_flags_.ext_frag_depth = true; 684 feature_flags_.ext_frag_depth = true;
664 } 685 }
665 686
666 if (!disallowed_features_.swap_buffer_complete_callback) 687 if (!disallowed_features_.swap_buffer_complete_callback)
667 AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback"); 688 AddExtensionString("GL_CHROMIUM_swapbuffers_complete_callback");
668 689
669 bool is_es3 = false;
670 const char* str = reinterpret_cast<const char*>(glGetString(GL_VERSION));
671 if (str) {
672 std::string lstr(StringToLowerASCII(std::string(str)));
673 is_es3 = (lstr.substr(0, 12) == "opengl es 3.");
674 }
675
676 bool ui_gl_fence_works = extensions.Contains("GL_NV_fence") || 690 bool ui_gl_fence_works = extensions.Contains("GL_NV_fence") ||
677 extensions.Contains("GL_ARB_sync") || 691 extensions.Contains("GL_ARB_sync") ||
678 extensions.Contains("EGL_KHR_fence_sync"); 692 extensions.Contains("EGL_KHR_fence_sync");
679 693
680 feature_flags_.map_buffer_range = 694 feature_flags_.map_buffer_range =
681 is_es3 || extensions.Contains("GL_ARB_map_buffer_range"); 695 is_es3 || extensions.Contains("GL_ARB_map_buffer_range");
682 696
683 // Really it's part of core OpenGL 2.1 and up, but let's assume the 697 // Really it's part of core OpenGL 2.1 and up, but let's assume the
684 // extension is still advertised. 698 // extension is still advertised.
685 bool has_pixel_buffers = 699 bool has_pixel_buffers =
(...skipping 23 matching lines...) Expand all
709 if (extensions_.find(str) == std::string::npos) { 723 if (extensions_.find(str) == std::string::npos) {
710 extensions_ += (extensions_.empty() ? "" : " ") + str; 724 extensions_ += (extensions_.empty() ? "" : " ") + str;
711 } 725 }
712 } 726 }
713 727
714 FeatureInfo::~FeatureInfo() { 728 FeatureInfo::~FeatureInfo() {
715 } 729 }
716 730
717 } // namespace gles2 731 } // namespace gles2
718 } // namespace gpu 732 } // 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