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

Unified Diff: gpu/command_buffer/service/feature_info.cc

Issue 2713553005: Add GL_EXT_color_buffer_half_float support (Closed)
Patch Set: Add WebGL, cleanup Created 3 years, 10 months 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 side-by-side diff with in-line comments
Download patch
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..bf9a15892a5a90c8ca3286a8170d568a75c7a200 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() {
@@ -732,14 +747,16 @@ void FeatureInfo::InitializeFeatures() {
bool enable_texture_half_float = false;
bool enable_texture_half_float_linear = false;
bool enable_ext_color_buffer_float = false;
+ bool enable_ext_color_buffer_half_float = false;
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"))
+ enable_ext_color_buffer_half_float = true;
if (extensions.Contains("GL_ARB_texture_float") ||
gl_version_info_->is_desktop_core_profile) {
@@ -835,34 +852,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 (IsWebGL1OrES2Context() &&
+ !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;
+ }
+ enable_ext_color_buffer_half_float = full_half_float_support;
+ }
glDeleteFramebuffersEXT(1, &fb_id);
glDeleteTextures(1, &tex_id);
@@ -891,6 +915,13 @@ void FeatureInfo::InitializeFeatures() {
EnableEXTColorBufferFloat();
}
+ // Enable GL_EXT_color_buffer_half_float if we have found the capability.
+ if (enable_ext_color_buffer_half_float &&
+ !disallowed_features_.ext_color_buffer_half_float) {
+ feature_flags_.enable_color_buffer_half_float = true;
+ EnableEXTColorBufferHalfFloat();
+ }
+
// Check for multisample support
if (!workarounds_.disable_chromium_framebuffer_multisample) {
bool ext_has_multisample =

Powered by Google App Engine
This is Rietveld 408576698