| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_R16F); | 226 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_R16F); |
| 227 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_RG16F); | 227 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_RG16F); |
| 228 validators_.texture_sized_color_renderable_internal_format.AddValue( | 228 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 229 GL_RGBA16F); | 229 GL_RGBA16F); |
| 230 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_R32F); | 230 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_R32F); |
| 231 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_RG32F); | 231 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_RG32F); |
| 232 validators_.texture_sized_color_renderable_internal_format.AddValue( | 232 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 233 GL_RGBA32F); | 233 GL_RGBA32F); |
| 234 validators_.texture_sized_color_renderable_internal_format.AddValue( | 234 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 235 GL_R11F_G11F_B10F); | 235 GL_R11F_G11F_B10F); |
| 236 feature_flags_.enable_color_buffer_float = true; | 236 } |
| 237 |
| 238 void FeatureInfo::EnableEXTColorBufferHalfFloat() { |
| 239 if (!feature_flags_.enable_color_buffer_half_float) |
| 240 return; |
| 241 AddExtensionString("GL_EXT_color_buffer_half_float"); |
| 242 validators_.render_buffer_format.AddValue(GL_R16F); |
| 243 validators_.render_buffer_format.AddValue(GL_RG16F); |
| 244 validators_.render_buffer_format.AddValue(GL_RGB16F); |
| 245 validators_.render_buffer_format.AddValue(GL_RGBA16F); |
| 246 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_R16F); |
| 247 validators_.texture_sized_color_renderable_internal_format.AddValue(GL_RG16F); |
| 248 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 249 GL_RGB16F); |
| 250 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 251 GL_RGBA16F); |
| 237 } | 252 } |
| 238 | 253 |
| 239 void FeatureInfo::EnableCHROMIUMColorBufferFloatRGBA() { | 254 void FeatureInfo::EnableCHROMIUMColorBufferFloatRGBA() { |
| 240 if (!feature_flags_.chromium_color_buffer_float_rgba) | 255 if (!feature_flags_.chromium_color_buffer_float_rgba) |
| 241 return; | 256 return; |
| 242 validators_.texture_internal_format.AddValue(GL_RGBA32F); | 257 validators_.texture_internal_format.AddValue(GL_RGBA32F); |
| 243 validators_.texture_sized_color_renderable_internal_format.AddValue( | 258 validators_.texture_sized_color_renderable_internal_format.AddValue( |
| 244 GL_RGBA32F); | 259 GL_RGBA32F); |
| 245 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba"); | 260 AddExtensionString("GL_CHROMIUM_color_buffer_float_rgba"); |
| 246 } | 261 } |
| (...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 725 feature_flags_.npot_ok = true; | 740 feature_flags_.npot_ok = true; |
| 726 } | 741 } |
| 727 | 742 |
| 728 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float, | 743 // Check if we should allow GL_OES_texture_float, GL_OES_texture_half_float, |
| 729 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear | 744 // GL_OES_texture_float_linear, GL_OES_texture_half_float_linear |
| 730 bool enable_texture_float = false; | 745 bool enable_texture_float = false; |
| 731 bool enable_texture_float_linear = false; | 746 bool enable_texture_float_linear = false; |
| 732 bool enable_texture_half_float = false; | 747 bool enable_texture_half_float = false; |
| 733 bool enable_texture_half_float_linear = false; | 748 bool enable_texture_half_float_linear = false; |
| 734 bool enable_ext_color_buffer_float = false; | 749 bool enable_ext_color_buffer_float = false; |
| 750 bool enable_ext_color_buffer_half_float = false; |
| 735 | 751 |
| 736 bool may_enable_chromium_color_buffer_float = false; | 752 bool may_enable_chromium_color_buffer_float = false; |
| 737 | 753 |
| 738 // This extension allows a variety of floating point formats to be | 754 // These extensions allow a variety of floating point formats to be |
| 739 // rendered to via framebuffer objects. | 755 // rendered to via framebuffer objects. |
| 740 if (extensions.Contains("GL_EXT_color_buffer_float")) { | 756 if (extensions.Contains("GL_EXT_color_buffer_float")) |
| 741 enable_ext_color_buffer_float = true; | 757 enable_ext_color_buffer_float = true; |
| 742 } | 758 if (extensions.Contains("GL_EXT_color_buffer_half_float")) |
| 759 enable_ext_color_buffer_half_float = true; |
| 743 | 760 |
| 744 if (extensions.Contains("GL_ARB_texture_float") || | 761 if (extensions.Contains("GL_ARB_texture_float") || |
| 745 gl_version_info_->is_desktop_core_profile) { | 762 gl_version_info_->is_desktop_core_profile) { |
| 746 enable_texture_float = true; | 763 enable_texture_float = true; |
| 747 enable_texture_float_linear = true; | 764 enable_texture_float_linear = true; |
| 748 enable_texture_half_float = true; | 765 enable_texture_half_float = true; |
| 749 enable_texture_half_float_linear = true; | 766 enable_texture_half_float_linear = true; |
| 750 may_enable_chromium_color_buffer_float = true; | 767 may_enable_chromium_color_buffer_float = true; |
| 751 } else { | 768 } else { |
| 752 // GLES3 adds support for Float type by default but it doesn't support all | 769 // GLES3 adds support for Float type by default but it doesn't support all |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 828 GL_TEXTURE_2D, tex_id, 0); | 845 GL_TEXTURE_2D, tex_id, 0); |
| 829 GLenum status_rgba = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 846 GLenum status_rgba = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
| 830 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB, | 847 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB, |
| 831 GL_FLOAT, NULL); | 848 GL_FLOAT, NULL); |
| 832 GLenum status_rgb = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); | 849 GLenum status_rgb = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
| 833 | 850 |
| 834 // For desktop systems, check to see if we support rendering to the full | 851 // For desktop systems, check to see if we support rendering to the full |
| 835 // range of formats supported by EXT_color_buffer_float | 852 // range of formats supported by EXT_color_buffer_float |
| 836 if (status_rgba == GL_FRAMEBUFFER_COMPLETE && enable_es3) { | 853 if (status_rgba == GL_FRAMEBUFFER_COMPLETE && enable_es3) { |
| 837 bool full_float_support = true; | 854 bool full_float_support = true; |
| 838 | 855 GLenum internal_formats[] = { |
| 839 glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width, 0, GL_RED, | 856 GL_R16F, GL_RG16F, GL_RGBA16F, GL_R32F, GL_RG32F, GL_R11F_G11F_B10F, |
| 840 GL_FLOAT, NULL); | 857 }; |
| 841 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == | 858 GLenum formats[] = { |
| 842 GL_FRAMEBUFFER_COMPLETE; | 859 GL_RED, GL_RG, GL_RGBA, GL_RED, GL_RG, GL_RGB, |
| 843 glTexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width, 0, GL_RG, | 860 }; |
| 844 GL_FLOAT, NULL); | 861 DCHECK_EQ(arraysize(internal_formats), arraysize(formats)); |
| 845 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == | 862 for (size_t i = 0; i < arraysize(formats); ++i) { |
| 846 GL_FRAMEBUFFER_COMPLETE; | 863 glTexImage2D(GL_TEXTURE_2D, 0, internal_formats[i], width, width, 0, |
| 847 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, width, 0, GL_RGBA, | 864 formats[i], GL_FLOAT, NULL); |
| 848 GL_FLOAT, NULL); | 865 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| 849 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == | 866 GL_FRAMEBUFFER_COMPLETE; |
| 850 GL_FRAMEBUFFER_COMPLETE; | 867 } |
| 851 glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, width, width, 0, GL_RED, | |
| 852 GL_FLOAT, NULL); | |
| 853 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == | |
| 854 GL_FRAMEBUFFER_COMPLETE; | |
| 855 glTexImage2D(GL_TEXTURE_2D, 0, GL_RG32F, width, width, 0, GL_RG, | |
| 856 GL_FLOAT, NULL); | |
| 857 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == | |
| 858 GL_FRAMEBUFFER_COMPLETE; | |
| 859 glTexImage2D(GL_TEXTURE_2D, 0, GL_R11F_G11F_B10F, width, width, 0, GL_RGB, | |
| 860 GL_FLOAT, NULL); | |
| 861 full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == | |
| 862 GL_FRAMEBUFFER_COMPLETE; | |
| 863 | |
| 864 enable_ext_color_buffer_float = full_float_support; | 868 enable_ext_color_buffer_float = full_float_support; |
| 865 } | 869 } |
| 870 // Likewise for EXT_color_buffer_half_float on ES2 contexts. |
| 871 if (IsWebGL1OrES2Context() && |
| 872 !feature_flags_.enable_color_buffer_half_float) { |
| 873 bool full_half_float_support = true; |
| 874 GLenum internal_formats[] = { |
| 875 GL_R16F, GL_RG16F, GL_RGB16F, GL_RGBA16F, |
| 876 }; |
| 877 GLenum formats[] = { |
| 878 GL_RED, GL_RG, GL_RGB, GL_RGBA, |
| 879 }; |
| 880 DCHECK_EQ(arraysize(internal_formats), arraysize(formats)); |
| 881 for (size_t i = 0; i < arraysize(formats); ++i) { |
| 882 glTexImage2D(GL_TEXTURE_2D, 0, internal_formats[i], width, width, 0, |
| 883 formats[i], GL_FLOAT, NULL); |
| 884 full_half_float_support &= |
| 885 glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| 886 GL_FRAMEBUFFER_COMPLETE; |
| 887 } |
| 888 enable_ext_color_buffer_half_float = full_half_float_support; |
| 889 } |
| 866 | 890 |
| 867 glDeleteFramebuffersEXT(1, &fb_id); | 891 glDeleteFramebuffersEXT(1, &fb_id); |
| 868 glDeleteTextures(1, &tex_id); | 892 glDeleteTextures(1, &tex_id); |
| 869 | 893 |
| 870 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding)); | 894 glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding)); |
| 871 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding)); | 895 glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding)); |
| 872 | 896 |
| 873 DCHECK(glGetError() == GL_NO_ERROR); | 897 DCHECK(glGetError() == GL_NO_ERROR); |
| 874 | 898 |
| 875 if (status_rgba == GL_FRAMEBUFFER_COMPLETE) { | 899 if (status_rgba == GL_FRAMEBUFFER_COMPLETE) { |
| 876 feature_flags_.chromium_color_buffer_float_rgba = true; | 900 feature_flags_.chromium_color_buffer_float_rgba = true; |
| 877 if (!disallowed_features_.chromium_color_buffer_float_rgba) | 901 if (!disallowed_features_.chromium_color_buffer_float_rgba) |
| 878 EnableCHROMIUMColorBufferFloatRGBA(); | 902 EnableCHROMIUMColorBufferFloatRGBA(); |
| 879 } | 903 } |
| 880 if (status_rgb == GL_FRAMEBUFFER_COMPLETE) { | 904 if (status_rgb == GL_FRAMEBUFFER_COMPLETE) { |
| 881 feature_flags_.chromium_color_buffer_float_rgb = true; | 905 feature_flags_.chromium_color_buffer_float_rgb = true; |
| 882 if (!disallowed_features_.chromium_color_buffer_float_rgb) | 906 if (!disallowed_features_.chromium_color_buffer_float_rgb) |
| 883 EnableCHROMIUMColorBufferFloatRGB(); | 907 EnableCHROMIUMColorBufferFloatRGB(); |
| 884 } | 908 } |
| 885 } | 909 } |
| 886 | 910 |
| 887 // Enable the GL_EXT_color_buffer_float extension for WebGL 2.0 | 911 // Enable the GL_EXT_color_buffer_float extension for WebGL 2.0 |
| 888 if (enable_ext_color_buffer_float && enable_es3) { | 912 if (enable_ext_color_buffer_float && enable_es3) { |
| 889 ext_color_buffer_float_available_ = true; | 913 ext_color_buffer_float_available_ = true; |
| 890 if (!disallowed_features_.ext_color_buffer_float) | 914 if (!disallowed_features_.ext_color_buffer_float) |
| 891 EnableEXTColorBufferFloat(); | 915 EnableEXTColorBufferFloat(); |
| 892 } | 916 } |
| 893 | 917 |
| 918 // Enable GL_EXT_color_buffer_half_float if we have found the capability. |
| 919 if (enable_ext_color_buffer_half_float && |
| 920 !disallowed_features_.ext_color_buffer_half_float) { |
| 921 feature_flags_.enable_color_buffer_half_float = true; |
| 922 EnableEXTColorBufferHalfFloat(); |
| 923 } |
| 924 |
| 894 // Check for multisample support | 925 // Check for multisample support |
| 895 if (!workarounds_.disable_chromium_framebuffer_multisample) { | 926 if (!workarounds_.disable_chromium_framebuffer_multisample) { |
| 896 bool ext_has_multisample = | 927 bool ext_has_multisample = |
| 897 extensions.Contains("GL_EXT_framebuffer_multisample") || | 928 extensions.Contains("GL_EXT_framebuffer_multisample") || |
| 898 gl_version_info_->is_es3 || | 929 gl_version_info_->is_es3 || |
| 899 gl_version_info_->is_desktop_core_profile; | 930 gl_version_info_->is_desktop_core_profile; |
| 900 if (gl_version_info_->is_angle) { | 931 if (gl_version_info_->is_angle) { |
| 901 feature_flags_.angle_framebuffer_multisample = | 932 feature_flags_.angle_framebuffer_multisample = |
| 902 extensions.Contains("GL_ANGLE_framebuffer_multisample"); | 933 extensions.Contains("GL_ANGLE_framebuffer_multisample"); |
| 903 ext_has_multisample |= feature_flags_.angle_framebuffer_multisample; | 934 ext_has_multisample |= feature_flags_.angle_framebuffer_multisample; |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 if (pos == std::string::npos) { | 1559 if (pos == std::string::npos) { |
| 1529 extensions_ += (extensions_.empty() ? "" : " ") + str; | 1560 extensions_ += (extensions_.empty() ? "" : " ") + str; |
| 1530 } | 1561 } |
| 1531 } | 1562 } |
| 1532 | 1563 |
| 1533 FeatureInfo::~FeatureInfo() { | 1564 FeatureInfo::~FeatureInfo() { |
| 1534 } | 1565 } |
| 1535 | 1566 |
| 1536 } // namespace gles2 | 1567 } // namespace gles2 |
| 1537 } // namespace gpu | 1568 } // namespace gpu |
| OLD | NEW |