Bug 1242347 - Allow unsized internal format when generate mipmap. r=jgilbert
authorMorris Tseng <mtseng@mozilla.com>
Fri, 29 Jan 2016 10:58:05 +0800
changeset 282242 adace6a3f9165e3c75cb93887fa2b7abdf51d5a5
parent 282241 6c79814b760449f13f60452d2fc6eb595690acfa
child 282243 2c56aed636871f91344dc412131675141964a840
push id29953
push usercbook@mozilla.com
push dateFri, 29 Jan 2016 10:46:34 +0000
treeherdermozilla-central@ac21d6f878e6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjgilbert
bugs1242347
milestone47.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 1242347 - Allow unsized internal format when generate mipmap. r=jgilbert
dom/canvas/WebGLTexture.cpp
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -737,18 +737,37 @@ WebGLTexture::GenerateMipmap(TexTarget t
     }
 
     if (format->hasDepth) {
         mContext->ErrorInvalidOperation("generateMipmap: Depth textures are not"
                                         " supported.");
         return;
     }
 
-    if (!baseImageInfo.mFormat->isRenderable || !baseImageInfo.mFormat->isFilterable) {
-        mContext->ErrorInvalidOperation("generateMipmap: Texture at base level is not"
+    // OpenGL ES 3.0.4 p160:
+    // If the level base array was not specified with an unsized internal format from
+    // table 3.3 or a sized internal format that is both color-renderable and
+    // texture-filterable according to table 3.13, an INVALID_OPERATION error
+    // is generated.
+    const auto usage = baseImageInfo.mFormat;
+    bool canGenerateMipmap = (usage->isRenderable && usage->isFilterable);
+    switch (usage->format->effectiveFormat) {
+    case webgl::EffectiveFormat::Luminance8:
+    case webgl::EffectiveFormat::Alpha8:
+    case webgl::EffectiveFormat::Luminance8Alpha8:
+        // Non-color-renderable formats from Table 3.3.
+        canGenerateMipmap = true;
+        break;
+    default:
+        break;
+    }
+
+    if (!canGenerateMipmap) {
+        mContext->ErrorInvalidOperation("generateMipmap: Texture at base level is not unsized"
+                                        " internal format or is not"
                                         " color-renderable or texture-filterable.");
         return;
     }
 
     // Done with validation. Do the operation.
 
     mContext->MakeContextCurrent();
     gl::GLContext* gl = mContext->gl;