Bug 879954 - Implement OES_texture_float_linear - r=bjacob
authorGuillaume Abadie <gabadie@mozilla.com>
Mon, 10 Jun 2013 16:00:52 -0400
changeset 146052 dbf8cb7f9755ba629254301bd0cbdfb887a3ff42
parent 146051 97b2763d2baeb2e4a197c1c001e4b47572a37d28
child 146053 e397be02b4892305b4334ff97f4f18a03fcf61c9
push id2697
push userbbajaj@mozilla.com
push dateMon, 05 Aug 2013 18:49:53 +0000
treeherdermozilla-beta@dfec938c7b63 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs879954
milestone24.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 879954 - Implement OES_texture_float_linear - r=bjacob
content/canvas/src/WebGLContext.cpp
content/canvas/src/WebGLContext.h
content/canvas/src/WebGLExtensionTextureFloatLinear.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
--- a/content/canvas/src/WebGLContext.cpp
+++ b/content/canvas/src/WebGLContext.cpp
@@ -970,16 +970,19 @@ bool WebGLContext::IsExtensionSupported(
                 return true;
             return gl->IsExtensionSupported(GLContext::OES_standard_derivatives);
         case WEBGL_lose_context:
             // We always support this extension.
             return true;
         case OES_texture_float:
             return gl->IsExtensionSupported(gl->IsGLES2() ? GLContext::OES_texture_float
                                                           : GLContext::ARB_texture_float);
+        case OES_texture_float_linear:
+            return gl->IsExtensionSupported(gl->IsGLES2() ? GLContext::OES_texture_float_linear
+                                                          : GLContext::ARB_texture_float);
         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;
             }
             else if (gl->IsExtensionSupported(GLContext::EXT_texture_compression_dxt1) &&
                      gl->IsExtensionSupported(GLContext::ANGLE_texture_compression_dxt3) &&
@@ -1036,16 +1039,20 @@ WebGLContext::GetExtension(JSContext *cx
     if (CompareWebGLExtensionName(name, "OES_element_index_uint"))
     {
         ext = OES_element_index_uint;
     }
     else if (CompareWebGLExtensionName(name, "OES_texture_float"))
     {
         ext = OES_texture_float;
     }
+    else if (CompareWebGLExtensionName(name, "OES_texture_float_linear"))
+    {
+        ext = OES_texture_float_linear;
+    }
     else if (CompareWebGLExtensionName(name, "OES_standard_derivatives"))
     {
         ext = OES_standard_derivatives;
     }
     else if (CompareWebGLExtensionName(name, "EXT_texture_filter_anisotropic"))
     {
         ext = EXT_texture_filter_anisotropic;
     }
@@ -1124,16 +1131,19 @@ WebGLContext::GetExtension(JSContext *cx
                 obj = new WebGLExtensionDebugRendererInfo(this);
                 break;
             case WEBGL_depth_texture:
                 obj = new WebGLExtensionDepthTexture(this);
                 break;
             case OES_texture_float:
                 obj = new WebGLExtensionTextureFloat(this);
                 break;
+            case OES_texture_float_linear:
+                obj = new WebGLExtensionTextureFloatLinear(this);
+                break;
             default:
                 MOZ_ASSERT(false, "should not get there.");
         }
         mExtensions.EnsureLengthAtLeast(ext + 1);
         mExtensions[ext] = obj;
     }
 
     return WebGLObjectAsJSObject(cx, mExtensions[ext].get(), rv);
@@ -1465,16 +1475,18 @@ WebGLContext::GetSupportedExtensions(JSC
         return;
 
     nsTArray<nsString>& arr = retval.SetValue();
 
     if (IsExtensionSupported(cx, OES_element_index_uint))
         arr.AppendElement(NS_LITERAL_STRING("OES_element_index_uint"));
     if (IsExtensionSupported(cx, OES_texture_float))
         arr.AppendElement(NS_LITERAL_STRING("OES_texture_float"));
+    if (IsExtensionSupported(cx, OES_texture_float_linear))
+        arr.AppendElement(NS_LITERAL_STRING("OES_texture_float_linear"));
     if (IsExtensionSupported(cx, OES_standard_derivatives))
         arr.AppendElement(NS_LITERAL_STRING("OES_standard_derivatives"));
     if (IsExtensionSupported(cx, EXT_texture_filter_anisotropic))
         arr.AppendElement(NS_LITERAL_STRING("EXT_texture_filter_anisotropic"));
     if (IsExtensionSupported(cx, WEBGL_lose_context))
         arr.AppendElement(NS_LITERAL_STRING("MOZ_WEBGL_lose_context"));
     if (IsExtensionSupported(cx, WEBGL_lose_context))
         arr.AppendElement(NS_LITERAL_STRING("WEBGL_lose_context"));
--- a/content/canvas/src/WebGLContext.h
+++ b/content/canvas/src/WebGLContext.h
@@ -863,16 +863,17 @@ protected:
     };
 
     // extensions
     enum WebGLExtensionID {
         EXT_texture_filter_anisotropic,
         OES_element_index_uint,
         OES_standard_derivatives,
         OES_texture_float,
+        OES_texture_float_linear,
         WEBGL_compressed_texture_atc,
         WEBGL_compressed_texture_pvrtc,
         WEBGL_compressed_texture_s3tc,
         WEBGL_debug_renderer_info,
         WEBGL_depth_texture,
         WEBGL_lose_context,
         WebGLExtensionID_unknown_extension
     };
new file mode 100644
--- /dev/null
+++ b/content/canvas/src/WebGLExtensionTextureFloatLinear.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;
+
+WebGLExtensionTextureFloatLinear::WebGLExtensionTextureFloatLinear(WebGLContext* context)
+    : WebGLExtensionBase(context)
+{
+}
+
+WebGLExtensionTextureFloatLinear::~WebGLExtensionTextureFloatLinear()
+{
+}
+
+IMPL_WEBGL_EXTENSION_GOOP(WebGLExtensionTextureFloatLinear)
--- a/content/canvas/src/WebGLExtensions.h
+++ b/content/canvas/src/WebGLExtensions.h
@@ -135,11 +135,21 @@ class WebGLExtensionTextureFloat
 {
 public:
     WebGLExtensionTextureFloat(WebGLContext*);
     virtual ~WebGLExtensionTextureFloat();
 
     DECL_WEBGL_EXTENSION_GOOP
 };
 
+class WebGLExtensionTextureFloatLinear
+    : public WebGLExtensionBase
+{
+public:
+    WebGLExtensionTextureFloatLinear(WebGLContext*);
+    virtual ~WebGLExtensionTextureFloatLinear();
+
+    DECL_WEBGL_EXTENSION_GOOP
+};
+
 } // namespace mozilla
 
 #endif // WEBGLEXTENSIONS_H_
--- a/content/canvas/src/WebGLTexture.cpp
+++ b/content/canvas/src/WebGLTexture.cpp
@@ -323,31 +323,34 @@ WebGLTexture::NeedFakeBlack() {
                     mContext->GenerateWarning("%s is a cube map texture, with a minification filter not requiring a mipmap, "
                                "with some level 0 image having width or height not a power of two, and with a wrap mode "
                                "different from CLAMP_TO_EDGE.", msg_rendering_as_black);
                     mFakeBlackStatus = DoNeedFakeBlack;
                 }
             }
         }
 
-        if (ImageInfoAt(0).mType == LOCAL_GL_FLOAT)
+        if (ImageInfoAt(0).mType == LOCAL_GL_FLOAT &&
+            !Context()->IsExtensionEnabled(WebGLContext::OES_texture_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 "
-                                          "that is not compatible with gl.FLOAT", msg_rendering_as_black);
+                mContext->GenerateWarning("%s is a texture with a linear minification 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 = DoNeedFakeBlack;
             }
             else if (mMagFilter == LOCAL_GL_LINEAR)
             {
-                mContext->GenerateWarning("%s is a texture with a linear magnification filter "
-                                          "that is not compatible with gl.FLOAT", msg_rendering_as_black);
+                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 = DoNeedFakeBlack;
             }
         }
 
         // we have exhausted all cases where we do need fakeblack, so if the status is still unknown,
         // that means that we do NOT need it.
         if (mFakeBlackStatus == DontKnowIfNeedFakeBlack)
             mFakeBlackStatus = DoNotNeedFakeBlack;
--- a/content/canvas/src/moz.build
+++ b/content/canvas/src/moz.build
@@ -40,16 +40,17 @@ if CONFIG['MOZ_WEBGL']:
         'WebGLExtensionCompressedTextureS3TC.cpp',
         'WebGLExtensionDebugRendererInfo.cpp',
         'WebGLExtensionDepthTexture.cpp',
         'WebGLExtensionElementIndexUint.cpp',
         'WebGLExtensionLoseContext.cpp',
         'WebGLExtensionStandardDerivatives.cpp',
         'WebGLExtensionTextureFilterAnisotropic.cpp',
         'WebGLExtensionTextureFloat.cpp',
+        'WebGLExtensionTextureFloatLinear.cpp',
         'WebGLFramebuffer.cpp',
         'WebGLObjectModel.cpp',
         'WebGLProgram.cpp',
         'WebGLRenderbuffer.cpp',
         'WebGLShader.cpp',
         'WebGLShaderPrecisionFormat.cpp',
         'WebGLTexelConversions.cpp',
         'WebGLTexture.cpp',
--- a/dom/bindings/Bindings.conf
+++ b/dom/bindings/Bindings.conf
@@ -1173,16 +1173,21 @@ DOMInterfaces = {
    'headerFile': 'WebGLExtensions.h'
 },
 
 'WebGLExtensionTextureFloat': {
    'nativeType': 'mozilla::WebGLExtensionTextureFloat',
    'headerFile': 'WebGLExtensions.h'
 },
 
+'WebGLExtensionTextureFloatLinear': {
+   'nativeType': 'mozilla::WebGLExtensionTextureFloatLinear',
+   'headerFile': 'WebGLExtensions.h'
+},
+
 'WebGLFramebuffer': {
    'nativeType': 'mozilla::WebGLFramebuffer',
    'headerFile': 'WebGLFramebuffer.h'
 },
 
 'WebGLProgram': {
    'nativeType': 'mozilla::WebGLProgram',
    'headerFile': 'WebGLProgram.h'
--- a/dom/webidl/WebGLRenderingContext.webidl
+++ b/dom/webidl/WebGLRenderingContext.webidl
@@ -831,8 +831,13 @@ interface WebGLExtensionTextureFilterAni
 interface WebGLExtensionStandardDerivatives {
     const GLenum FRAGMENT_SHADER_DERIVATIVE_HINT_OES = 0x8B8B;
 };
 
 [NoInterfaceObject]
 interface WebGLExtensionTextureFloat
 {
 };
+
+[NoInterfaceObject]
+interface WebGLExtensionTextureFloatLinear
+{
+};
--- a/gfx/gl/GLContext.cpp
+++ b/gfx/gl/GLContext.cpp
@@ -53,16 +53,17 @@ static const char *sExtensionNames[] = {
     "GL_OES_packed_depth_stencil",
     "GL_IMG_read_format",
     "GL_EXT_read_format_bgra",
     "GL_APPLE_client_storage",
     "GL_ARB_texture_non_power_of_two",
     "GL_ARB_pixel_buffer_object",
     "GL_ARB_ES2_compatibility",
     "GL_OES_texture_float",
+    "GL_OES_texture_float_linear",
     "GL_ARB_texture_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
@@ -995,16 +995,17 @@ public:
         OES_packed_depth_stencil,
         IMG_read_format,
         EXT_read_format_bgra,
         APPLE_client_storage,
         ARB_texture_non_power_of_two,
         ARB_pixel_buffer_object,
         ARB_ES2_compatibility,
         OES_texture_float,
+        OES_texture_float_linear,
         ARB_texture_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,