Bug 879952 - OES_texture_float should not allow linear filtering - r=bjacob
authorGuillaume Abadie <gabadie@mozilla.com>
Mon, 10 Jun 2013 16:00:46 -0400
changeset 134560 97b2763d2baeb2e4a197c1c001e4b47572a37d28
parent 134559 0e5a7f0d8a4b5effc3fb981a38cddba9e7fdcba6
child 134561 dbf8cb7f9755ba629254301bd0cbdfb887a3ff42
push id29269
push userbjacob@mozilla.com
push dateMon, 10 Jun 2013 20:46:31 +0000
treeherdermozilla-inbound@dbf8cb7f9755 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbjacob
bugs879952
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 879952 - OES_texture_float should not allow linear filtering - r=bjacob
content/canvas/src/WebGLContextGL.cpp
content/canvas/src/WebGLTexture.cpp
--- a/content/canvas/src/WebGLContextGL.cpp
+++ b/content/canvas/src/WebGLContextGL.cpp
@@ -240,16 +240,17 @@ WebGLContext::BindTexture(WebGLenum targ
     if (target == LOCAL_GL_TEXTURE_2D) {
         mBound2DTextures[mActiveTexture] = tex;
     } else if (target == LOCAL_GL_TEXTURE_CUBE_MAP) {
         mBoundCubeMapTextures[mActiveTexture] = tex;
     } else {
         return ErrorInvalidEnumInfo("bindTexture: target", target);
     }
 
+    SetDontKnowIfNeedFakeBlack();
     MakeContextCurrent();
 
     if (tex)
         tex->Bind(target);
     else
         gl->fBindTexture(target, 0 /* == texturename */);
 }
 
@@ -1344,33 +1345,32 @@ WebGLContext::UndoFakeVertexAttrib0()
 
 bool
 WebGLContext::NeedFakeBlack()
 {
     // handle this case first, it's the generic case
     if (mFakeBlackStatus == DoNotNeedFakeBlack)
         return false;
 
-    if (mFakeBlackStatus == DontKnowIfNeedFakeBlack) {
-        for (int32_t i = 0; i < mGLMaxTextureUnits; ++i) {
-            if ((mBound2DTextures[i] && mBound2DTextures[i]->NeedFakeBlack()) ||
-                (mBoundCubeMapTextures[i] && mBoundCubeMapTextures[i]->NeedFakeBlack()))
-            {
-                mFakeBlackStatus = DoNeedFakeBlack;
-                break;
-            }
+    if (mFakeBlackStatus == DoNeedFakeBlack)
+        return true;
+
+    for (int32_t i = 0; i < mGLMaxTextureUnits; ++i) {
+        if ((mBound2DTextures[i] && mBound2DTextures[i]->NeedFakeBlack()) ||
+            (mBoundCubeMapTextures[i] && mBoundCubeMapTextures[i]->NeedFakeBlack()))
+        {
+            mFakeBlackStatus = DoNeedFakeBlack;
+            return true;
         }
-
-        // 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;
-    }
-
-    return 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.
+    mFakeBlackStatus = DoNotNeedFakeBlack;
+    return false;
 }
 
 void
 WebGLContext::BindFakeBlackTextures()
 {
     // this is the generic case: try to return early
     if (!NeedFakeBlack())
         return;
--- a/content/canvas/src/WebGLTexture.cpp
+++ b/content/canvas/src/WebGLTexture.cpp
@@ -323,16 +323,35 @@ 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 (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);
+                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);
+                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;
     }
 
     return mFakeBlackStatus == DoNeedFakeBlack;
 }