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 573cec4f8687d283e686da2ca9e9745775a8cbdc..19db779ce1688294ab5f1db72258edd8b8f44185 100644 |
--- a/gpu/command_buffer/service/feature_info.cc |
+++ b/gpu/command_buffer/service/feature_info.cc |
@@ -99,7 +99,8 @@ void StringToWorkarounds( |
} // anonymous namespace. |
FeatureInfo::FeatureFlags::FeatureFlags() |
- : chromium_framebuffer_multisample(false), |
+ : chromium_color_buffer_float(false), |
+ chromium_framebuffer_multisample(false), |
use_core_framebuffer_multisample(false), |
multisampled_render_to_texture(false), |
use_img_for_multisampled_render_to_texture(false), |
@@ -437,26 +438,27 @@ void FeatureInfo::InitializeFeatures() { |
bool enable_texture_half_float = false; |
bool enable_texture_half_float_linear = false; |
- bool have_arb_texture_float = extensions.Contains("GL_ARB_texture_float"); |
+ bool may_enable_chromium_color_buffer_float = false; |
- if (have_arb_texture_float) { |
+ if (extensions.Contains("GL_ARB_texture_float")) { |
enable_texture_float = true; |
enable_texture_float_linear = true; |
enable_texture_half_float = true; |
enable_texture_half_float_linear = true; |
+ may_enable_chromium_color_buffer_float = true; |
} else { |
- if (extensions.Contains("GL_OES_texture_float") || have_arb_texture_float) { |
+ if (extensions.Contains("GL_OES_texture_float")) { |
enable_texture_float = true; |
- if (extensions.Contains("GL_OES_texture_float_linear") || |
- have_arb_texture_float) { |
+ if (extensions.Contains("GL_OES_texture_float_linear")) { |
enable_texture_float_linear = true; |
} |
+ if (is_es3 && extensions.Contains("GL_EXT_color_buffer_float")) { |
+ may_enable_chromium_color_buffer_float = true; |
+ } |
} |
- if (extensions.Contains("GL_OES_texture_half_float") || |
- have_arb_texture_float) { |
+ if (extensions.Contains("GL_OES_texture_half_float")) { |
enable_texture_half_float = true; |
- if (extensions.Contains("GL_OES_texture_half_float_linear") || |
- have_arb_texture_float) { |
+ if (extensions.Contains("GL_OES_texture_half_float_linear")) { |
enable_texture_half_float_linear = true; |
} |
} |
@@ -490,6 +492,56 @@ void FeatureInfo::InitializeFeatures() { |
} |
} |
+ if (may_enable_chromium_color_buffer_float) { |
+ DCHECK(GL_RGBA32F_ARB == GL_RGBA32F && GL_RGBA32F_EXT == GL_RGBA32F && |
+ GL_RGB32F_ARB == GL_RGB32F && GL_RGB32F_EXT == GL_RGB32F); |
piman
2014/02/07 00:43:10
nit: you can use COMPILE_ASSERT
oetuaho-nv
2014/02/07 09:26:58
Done.
|
+ // We don't check extension support beyond ARB_texture_float on desktop GL, |
+ // and spec prior to OpenGL 3.0 mandates framebuffer support only for one |
+ // implementation-chosen format. Check for framebuffer completeness with |
+ // formats that the extension exposes, and only enable the extension when |
+ // framebuffers created with both float texture formats result in a |
+ // complete framebuffer. |
+ GLint fb_binding = 0; |
+ GLint tex_binding = 0; |
+ glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fb_binding); |
+ glGetIntegerv(GL_TEXTURE_BINDING_2D, &tex_binding); |
+ |
+ GLuint tex_id = 0; |
+ GLuint fb_id = 0; |
+ GLsizei width = 16; |
+ GLfloat* data = new GLfloat[width * width * 4]; |
piman
2014/02/07 00:43:10
Why not passing NULL to the glTexImage2D below?
oetuaho-nv
2014/02/07 09:26:58
True, NULL is fine.
|
+ |
+ glGenTextures(1, &tex_id); |
+ glGenFramebuffersEXT(1, &fb_id); |
+ glBindTexture(GL_TEXTURE_2D, tex_id); |
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F, width, width, 0, GL_RGBA, |
+ GL_FLOAT, static_cast<GLvoid*>(data)); |
+ glBindFramebufferEXT(GL_FRAMEBUFFER, fb_id); |
+ glFramebufferTexture2DEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, |
+ GL_TEXTURE_2D, tex_id, 0); |
+ GLenum statusRGBA = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
+ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB32F, width, width, 0, GL_RGB, |
+ GL_FLOAT, static_cast<GLvoid*>(data)); |
+ GLenum statusRGB = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); |
+ glDeleteFramebuffersEXT(1, &fb_id); |
+ glDeleteTextures(1, &tex_id); |
+ |
+ delete[] data; |
+ |
+ glBindFramebufferEXT(GL_FRAMEBUFFER, static_cast<GLuint>(fb_binding)); |
+ glBindTexture(GL_TEXTURE_2D, static_cast<GLuint>(tex_binding)); |
+ |
+ DCHECK(glGetError() == GL_NO_ERROR); |
+ |
+ if (statusRGBA == GL_FRAMEBUFFER_COMPLETE && |
+ statusRGB == GL_FRAMEBUFFER_COMPLETE) { |
+ validators_.texture_internal_format.AddValue(GL_RGBA32F); |
+ validators_.texture_internal_format.AddValue(GL_RGB32F); |
+ feature_flags_.chromium_color_buffer_float = true; |
+ AddExtensionString("GL_CHROMIUM_color_buffer_float"); |
+ } |
+ } |
+ |
// Check for multisample support |
if (!disallowed_features_.multisampling && |
!workarounds_.disable_framebuffer_multisample) { |