Bug 912280 - Implement OES_texture_half_float_linear for WebGL. r=kamidphish
☠☠ backed out by 716974a64aae ☠ ☠
authorJeff Gilbert <jgilbert@mozilla.com>
Fri, 07 Feb 2014 10:21:49 -0500
changeset 167549 8d885b139d7def0c8db7ed8bc93744d4f29546c7
parent 167548 1790ca834d5645323b610450c5fc6e355a7040c8
child 167550 3ec1142c5540d5d79a72e4805bc5129e16314504
push id26173
push userryanvm@gmail.com
push dateFri, 07 Feb 2014 19:22:20 +0000
treeherdermozilla-central@a96affc08b1c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskamidphish
bugs912280
milestone30.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 912280 - Implement OES_texture_half_float_linear for WebGL. r=kamidphish
content/canvas/src/WebGLContext.h
content/canvas/src/WebGLContextExtensions.cpp
content/canvas/src/WebGLExtensionTextureHalfFloatLinear.cpp
content/canvas/src/WebGLExtensions.h
content/canvas/src/WebGLTexture.cpp
content/canvas/src/moz.build
dom/bindings/Bindings.conf
dom/webidl/WebGLRenderingContext.webidl
gfx/gl/GLContext.cpp
gfx/gl/GLContext.h
gfx/gl/GLContextFeatures.cpp
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -896,16 +896,17 @@ protected:
     enum WebGLExtensionID {
         EXT_sRGB,
         EXT_texture_filter_anisotropic,
         OES_element_index_uint,
         OES_standard_derivatives,
         OES_texture_float,
         OES_texture_float_linear,
         OES_texture_half_float,
+        OES_texture_half_float_linear,
         OES_vertex_array_object,
         WEBGL_compressed_texture_atc,
         WEBGL_compressed_texture_pvrtc,
         WEBGL_compressed_texture_s3tc,
         WEBGL_debug_renderer_info,
         WEBGL_depth_texture,
         WEBGL_lose_context,
         WEBGL_draw_buffers,
--- a/content/canvas/src/WebGLContextExtensions.cpp
+++ b/content/canvas/src/WebGLContextExtensions.cpp
@@ -19,16 +19,17 @@ using namespace mozilla::gl;
 static const char *sExtensionNames[] = {
     "EXT_sRGB",
     "EXT_texture_filter_anisotropic",
     "OES_element_index_uint",
     "OES_standard_derivatives",
     "OES_texture_float",
     "OES_texture_float_linear",
     "OES_texture_half_float",
+    "OES_texture_half_float_linear",
     "OES_vertex_array_object",
     "WEBGL_compressed_texture_atc",
     "WEBGL_compressed_texture_pvrtc",
     "WEBGL_compressed_texture_s3tc",
     "WEBGL_debug_renderer_info",
     "WEBGL_depth_texture",
     "WEBGL_lose_context",
     "WEBGL_draw_buffers",
@@ -88,16 +89,18 @@ bool WebGLContext::IsExtensionSupported(
         case OES_texture_float_linear:
             return gl->IsSupported(GLFeature::texture_float_linear);
         case OES_texture_half_float:
             // If we have Feature::texture_half_float, we must not be on ES2
             // and need to translate HALF_FLOAT_OES -> HALF_FLOAT.  We do that
             // right before making the relevant calls.
             return gl->IsExtensionSupported(GLContext::OES_texture_half_float) ||
                    gl->IsSupported(GLFeature::texture_half_float);
+        case OES_texture_half_float_linear:
+            return gl->IsSupported(GLFeature::texture_half_float_linear);
         case OES_vertex_array_object:
             return WebGLExtensionVertexArray::IsSupported(this);
         case EXT_texture_filter_anisotropic:
             return gl->IsExtensionSupported(GLContext::EXT_texture_filter_anisotropic);
         case WEBGL_compressed_texture_s3tc:
             if (gl->IsExtensionSupported(GLContext::EXT_texture_compression_s3tc)) {
                 return true;
             }
@@ -258,16 +261,19 @@ WebGLContext::EnableExtension(WebGLExten
             obj = new WebGLExtensionTextureFloat(this);
             break;
         case OES_texture_float_linear:
             obj = new WebGLExtensionTextureFloatLinear(this);
             break;
         case OES_texture_half_float:
             obj = new WebGLExtensionTextureHalfFloat(this);
             break;
+        case OES_texture_half_float_linear:
+            obj = new WebGLExtensionTextureHalfFloatLinear(this);
+            break;
         case WEBGL_draw_buffers:
             obj = new WebGLExtensionDrawBuffers(this);
             break;
         case OES_vertex_array_object:
             obj = new WebGLExtensionVertexArray(this);
             break;
         case ANGLE_instanced_arrays:
             obj = new WebGLExtensionInstancedArrays(this);
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/WebGLExtensionTextureHalfFloatLinear.cpp
@@ -0,0 +1,20 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+#include "WebGLContext.h"
+#include "WebGLExtensions.h"
+#include "mozilla/dom/WebGLRenderingContextBinding.h"
+
+using namespace mozilla;
+
+WebGLExtensionTextureHalfFloatLinear::WebGLExtensionTextureHalfFloatLinear(WebGLContext* context)
+    : WebGLExtensionBase(context)
+{
+}
+
+WebGLExtensionTextureHalfFloatLinear::~WebGLExtensionTextureHalfFloatLinear()
+{
+}
+
+IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionTextureHalfFloatLinear)
--- a/content/canvas/src/WebGLExtensions.h
+++ b/content/canvas/src/WebGLExtensions.h
@@ -166,16 +166,26 @@ class WebGLExtensionTextureHalfFloat
 {
 public:
     WebGLExtensionTextureHalfFloat(WebGLContext*);
     virtual ~WebGLExtensionTextureHalfFloat();
 
     DECL_WEBGL_EXTENSION_GOOP
 };
 
+class WebGLExtensionTextureHalfFloatLinear
+    : public WebGLExtensionBase
+{
+public:
+    WebGLExtensionTextureHalfFloatLinear(WebGLContext*);
+    virtual ~WebGLExtensionTextureHalfFloatLinear();
+
+    DECL_WEBGL_EXTENSION_GOOP
+};
+
 class WebGLExtensionDrawBuffers
     : public WebGLExtensionBase
 {
 public:
     WebGLExtensionDrawBuffers(WebGLContext*);
     virtual ~WebGLExtensionDrawBuffers();
 
     void DrawBuffersWEBGL(const dom::Sequence<GLenum>& buffers);
--- a/content/canvas/src/WebGLTexture.cpp
+++ b/content/canvas/src/WebGLTexture.cpp
@@ -345,18 +345,18 @@ WebGLTexture::ResolvedFakeBlackStatus() 
         }
         else if (mMagFilter == LOCAL_GL_LINEAR)
         {
             mContext->GenerateWarning("%s is a texture with a linear magnification filter, "
                                       "which is not compatible with gl.FLOAT by default. "
                                       "Try enabling the OES_texture_float_linear extension if supported.", msg_rendering_as_black);
             mFakeBlackStatus = WebGLTextureFakeBlackStatus::IncompleteTexture;
         }
-    }
-    else if (ImageInfoBase().mType == LOCAL_GL_HALF_FLOAT_OES)
+    } else if (ImageInfoBase().mType == LOCAL_GL_HALF_FLOAT_OES &&
+               !Context()->IsExtensionEnabled(WebGLContext::OES_texture_half_float_linear))
     {
         if (mMinFilter == LOCAL_GL_LINEAR ||
             mMinFilter == LOCAL_GL_LINEAR_MIPMAP_LINEAR ||
             mMinFilter == LOCAL_GL_LINEAR_MIPMAP_NEAREST ||
             mMinFilter == LOCAL_GL_NEAREST_MIPMAP_LINEAR)
         {
             mContext->GenerateWarning("%s is a texture with a linear minification filter, "
                                       "which is not compatible with gl.HALF_FLOAT by default. "
--- a/content/canvas/src/moz.build
+++ b/content/canvas/src/moz.build
@@ -54,16 +54,17 @@ if CONFIG['MOZ_WEBGL']:
         'WebGLExtensionInstancedArrays.cpp',
         'WebGLExtensionLoseContext.cpp',
         'WebGLExtensionSRGB.cpp',
         'WebGLExtensionStandardDerivatives.cpp',
         'WebGLExtensionTextureFilterAnisotropic.cpp',
         'WebGLExtensionTextureFloat.cpp',
         'WebGLExtensionTextureFloatLinear.cpp',
         'WebGLExtensionTextureHalfFloat.cpp',
+        'WebGLExtensionTextureHalfFloatLinear.cpp',
         'WebGLExtensionVertexArray.cpp',
         'WebGLFramebuffer.cpp',
         'WebGLObjectModel.cpp',
         'WebGLProgram.cpp',
         'WebGLQuery.cpp',
         'WebGLRenderbuffer.cpp',
         'WebGLShader.cpp',
         'WebGLShaderPrecisionFormat.cpp',
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1405,16 +1405,21 @@ DOMInterfaces = {
     'headerFile': 'WebGLExtensions.h'
 },
 
 'WebGLExtensionTextureHalfFloat': {
    'nativeType': 'mozilla::WebGLExtensionTextureHalfFloat',
    'headerFile': 'WebGLExtensions.h'
 },
 
+'WebGLExtensionTextureHalfFloatLinear': {
+   'nativeType': 'mozilla::WebGLExtensionTextureHalfFloatLinear',
+   'headerFile': 'WebGLExtensions.h'
+},
+
 'WebGLExtensionDrawBuffers': {
     'nativeType': 'mozilla::WebGLExtensionDrawBuffers',
     'headerFile': 'WebGLExtensions.h'
 },
 
 'WebGLExtensionVertexArray': {
     'nativeType': 'mozilla::WebGLExtensionVertexArray',
     'headerFile': 'WebGLExtensions.h'
--- a/dom/webidl/WebGLRenderingContext.webidl
+++ b/dom/webidl/WebGLRenderingContext.webidl
@@ -897,16 +897,21 @@ interface WebGLExtensionTextureFloatLine
 
 [NoInterfaceObject]
 interface WebGLExtensionTextureHalfFloat
 {
     const GLenum HALF_FLOAT_OES = 0x8D61;
 };
 
 [NoInterfaceObject]
+interface WebGLExtensionTextureHalfFloatLinear
+{
+};
+
+[NoInterfaceObject]
 interface WebGLExtensionVertexArray {
     const GLenum VERTEX_ARRAY_BINDING_OES = 0x85B5;
 
     WebGLVertexArray? createVertexArrayOES();
     void deleteVertexArrayOES(WebGLVertexArray? arrayObject);
     [WebGLHandlesContextLoss] GLboolean isVertexArrayOES(WebGLVertexArray? arrayObject);
     void bindVertexArrayOES(WebGLVertexArray? arrayObject);
 };
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -79,16 +79,17 @@ static const char *sExtensionNames[] = {
     "GL_ARB_texture_non_power_of_two",
     "GL_ARB_pixel_buffer_object",
     "GL_ARB_ES2_compatibility",
     "GL_ARB_ES3_compatibility",
     "GL_OES_texture_float",
     "GL_OES_texture_float_linear",
     "GL_ARB_texture_float",
     "GL_OES_texture_half_float",
+    "GL_OES_texture_half_float_linear",
     "GL_NV_half_float",
     "GL_EXT_unpack_subimage",
     "GL_OES_standard_derivatives",
     "GL_EXT_texture_filter_anisotropic",
     "GL_EXT_texture_compression_s3tc",
     "GL_EXT_texture_compression_dxt1",
     "GL_ANGLE_texture_compression_dxt3",
     "GL_ANGLE_texture_compression_dxt5",
--- a/gfx/gl/GLContext.h
+++ b/gfx/gl/GLContext.h
@@ -102,16 +102,17 @@ MOZ_BEGIN_ENUM_CLASS(GLFeature)
     packed_depth_stencil,
     query_objects,
     robustness,
     sRGB,
     standard_derivatives,
     texture_float,
     texture_float_linear,
     texture_half_float,
+    texture_half_float_linear,
     texture_non_power_of_two,
     transform_feedback,
     vertex_array_object,
     EnumMax
 MOZ_END_ENUM_CLASS(GLFeature)
 
 MOZ_BEGIN_ENUM_CLASS(ContextProfile, uint8_t)
     Unknown = 0,
@@ -355,16 +356,17 @@ public:
         ARB_texture_non_power_of_two,
         ARB_pixel_buffer_object,
         ARB_ES2_compatibility,
         ARB_ES3_compatibility,
         OES_texture_float,
         OES_texture_float_linear,
         ARB_texture_float,
         OES_texture_half_float,
+        OES_texture_half_float_linear,
         NV_half_float,
         EXT_unpack_subimage,
         OES_standard_derivatives,
         EXT_texture_filter_anisotropic,
         EXT_texture_compression_s3tc,
         EXT_texture_compression_dxt1,
         ANGLE_texture_compression_dxt3,
         ANGLE_texture_compression_dxt5,
--- a/gfx/gl/GLContextFeatures.cpp
+++ b/gfx/gl/GLContextFeatures.cpp
@@ -305,16 +305,28 @@ static const FeatureInfo sFeatureInfoArr
          *   GL_HALF_FLOAT     = 0x140B
          *   GL_HALF_FLOAT_ARB = 0x140B == GL_HALF_FLOAT
          *   GL_HALF_FLOAT_NV  = 0x140B == GL_HALF_FLOAT
          *   GL_HALF_FLOAT_OES = 0x8D61 != GL_HALF_FLOAT
          * WebGL handles this specifically with an OES_texture_half_float check.
          */
     },
     {
+        "texture_half_float_linear",
+        310, // OpenGL version
+        300, // OpenGL ES version
+        {
+            GLContext::ARB_half_float_pixel,
+            GLContext::ARB_texture_float,
+            GLContext::NV_half_float,
+            GLContext::OES_texture_half_float_linear,
+            GLContext::Extensions_End
+        }
+    },
+    {
         "texture_non_power_of_two",
         200, // OpenGL version
         300, // OpenGL ES version
         {
             GLContext::ARB_texture_non_power_of_two,
             GLContext::OES_texture_npot,
             GLContext::Extensions_End
         }