Chromium Code Reviews| Index: gpu/command_buffer/service/feature_info.cc |
| diff --git a/gpu/command_buffer/service/feature_info.cc b/gpu/command_buffer/service/feature_info.cc |
| index 1ca1169fac907915b19c160fbd3b69cbcde36924..e08f96397c65b23a3bc9d7a6130b29771c592a8f 100644 |
| --- a/gpu/command_buffer/service/feature_info.cc |
| +++ b/gpu/command_buffer/service/feature_info.cc |
| @@ -233,7 +233,22 @@ void FeatureInfo::EnableEXTColorBufferFloat() { |
| GL_RGBA32F); |
| validators_.texture_sized_color_renderable_internal_format.AddValue( |
| GL_R11F_G11F_B10F); |
| - feature_flags_.enable_color_buffer_float = true; |
| +} |
| + |
| +void FeatureInfo::EnableEXTColorBufferHalfFloat() { |
| + if (!feature_flags_.enable_color_buffer_half_float) |
| + return; |
| + AddExtensionString("GL_EXT_color_buffer_half_float"); |
| + validators_.render_buffer_format.AddValue(GL_R16F); |
| + validators_.render_buffer_format.AddValue(GL_RG16F); |
| + validators_.render_buffer_format.AddValue(GL_RGB16F); |
| + validators_.render_buffer_format.AddValue(GL_RGBA16F); |
| + validators_.texture_sized_color_renderable_internal_format.AddValue(GL_R16F); |
| + validators_.texture_sized_color_renderable_internal_format.AddValue(GL_RG16F); |
| + validators_.texture_sized_color_renderable_internal_format.AddValue( |
| + GL_RGB16F); |
| + validators_.texture_sized_color_renderable_internal_format.AddValue( |
| + GL_RGBA16F); |
| } |
| void FeatureInfo::EnableCHROMIUMColorBufferFloatRGBA() { |
| @@ -735,11 +750,12 @@ void FeatureInfo::InitializeFeatures() { |
| bool may_enable_chromium_color_buffer_float = false; |
| - // This extension allows a variety of floating point formats to be |
| + // These extensions allow a variety of floating point formats to be |
| // rendered to via framebuffer objects. |
| - if (extensions.Contains("GL_EXT_color_buffer_float")) { |
| + if (extensions.Contains("GL_EXT_color_buffer_float")) |
| enable_ext_color_buffer_float = true; |
| - } |
| + if (extensions.Contains("GL_EXT_color_buffer_half_float")) |
| + feature_flags_.enable_color_buffer_half_float = true; |
| if (extensions.Contains("GL_ARB_texture_float") || |
| gl_version_info_->is_desktop_core_profile) { |
| @@ -835,34 +851,41 @@ void FeatureInfo::InitializeFeatures() { |
| // range of formats supported by EXT_color_buffer_float |
| if (status_rgba == GL_FRAMEBUFFER_COMPLETE && enable_es3) { |
| bool full_float_support = true; |
| - |
| - glTexImage2D(GL_TEXTURE_2D, 0, GL_R16F, width, width, 0, GL_RED, |
| - GL_FLOAT, NULL); |
| - full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| - GL_FRAMEBUFFER_COMPLETE; |
| - glTexImage2D(GL_TEXTURE_2D, 0, GL_RG16F, width, width, 0, GL_RG, |
| - GL_FLOAT, NULL); |
| - full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| - GL_FRAMEBUFFER_COMPLETE; |
| - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F, width, width, 0, GL_RGBA, |
| - GL_FLOAT, NULL); |
| - full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| - GL_FRAMEBUFFER_COMPLETE; |
| - glTexImage2D(GL_TEXTURE_2D, 0, GL_R32F, width, width, 0, GL_RED, |
| - GL_FLOAT, NULL); |
| - full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| - GL_FRAMEBUFFER_COMPLETE; |
| - glTexImage2D(GL_TEXTURE_2D, 0, GL_RG32F, width, width, 0, GL_RG, |
| - GL_FLOAT, NULL); |
| - full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| - GL_FRAMEBUFFER_COMPLETE; |
| - glTexImage2D(GL_TEXTURE_2D, 0, GL_R11F_G11F_B10F, width, width, 0, GL_RGB, |
| - GL_FLOAT, NULL); |
| - full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| - GL_FRAMEBUFFER_COMPLETE; |
| - |
| + GLenum internal_formats[] = { |
| + GL_R16F, GL_RG16F, GL_RGBA16F, GL_R32F, GL_RG32F, GL_R11F_G11F_B10F, |
| + }; |
| + GLenum formats[] = { |
| + GL_RED, GL_RG, GL_RGBA, GL_RED, GL_RG, GL_RGB, |
| + }; |
| + DCHECK_EQ(arraysize(internal_formats), arraysize(formats)); |
| + for (size_t i = 0; i < arraysize(formats); ++i) { |
| + glTexImage2D(GL_TEXTURE_2D, 0, internal_formats[i], width, width, 0, |
| + formats[i], GL_FLOAT, NULL); |
| + full_float_support &= glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| + GL_FRAMEBUFFER_COMPLETE; |
| + } |
| enable_ext_color_buffer_float = full_float_support; |
| } |
| + // Likewise for EXT_color_buffer_half_float on ES2 contexts. |
| + if (context_type_ == CONTEXT_TYPE_OPENGLES2 && |
|
Zhenyao Mo
2017/02/23 00:36:57
or WebGL1
Since you are working on it for interna
ccameron
2017/02/23 02:11:57
Done.
|
| + !feature_flags_.enable_color_buffer_half_float) { |
| + bool full_half_float_support = true; |
| + GLenum internal_formats[] = { |
| + GL_R16F, GL_RG16F, GL_RGB16F, GL_RGBA16F, |
| + }; |
| + GLenum formats[] = { |
| + GL_RED, GL_RG, GL_RGB, GL_RGBA, |
| + }; |
| + DCHECK_EQ(arraysize(internal_formats), arraysize(formats)); |
| + for (size_t i = 0; i < arraysize(formats); ++i) { |
| + glTexImage2D(GL_TEXTURE_2D, 0, internal_formats[i], width, width, 0, |
| + formats[i], GL_FLOAT, NULL); |
| + full_half_float_support &= |
| + glCheckFramebufferStatusEXT(GL_FRAMEBUFFER) == |
| + GL_FRAMEBUFFER_COMPLETE; |
| + } |
| + feature_flags_.enable_color_buffer_half_float = full_half_float_support; |
| + } |
| glDeleteFramebuffersEXT(1, &fb_id); |
| glDeleteTextures(1, &tex_id); |
| @@ -891,6 +914,9 @@ void FeatureInfo::InitializeFeatures() { |
| EnableEXTColorBufferFloat(); |
| } |
| + // Enable GL_EXT_color_buffer_half_float if we have found the capability. |
| + EnableEXTColorBufferHalfFloat(); |
|
Zhenyao Mo
2017/02/23 00:36:57
You can't enable this by default on WebGL contexts
ccameron
2017/02/23 02:11:57
Disallowed for WebGL 2.
|
| + |
| // Check for multisample support |
| if (!workarounds_.disable_chromium_framebuffer_multisample) { |
| bool ext_has_multisample = |