From 571b20fd9f03f4b35f8e02c2fde333a69ea7250b Mon Sep 17 00:00:00 2001 From: Morris Tseng Date: Fri, 29 Jan 2016 10:58:05 +0800 Subject: [PATCH] Bug 1242347 - Allow unsized internal format when generate mipmap. r=jgilbert --HG-- extra : commitid : BMfNLWIwGbn --- dom/canvas/WebGLTexture.cpp | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/dom/canvas/WebGLTexture.cpp b/dom/canvas/WebGLTexture.cpp index 0557a6161002..7abc4e0e74a2 100644 --- a/dom/canvas/WebGLTexture.cpp +++ b/dom/canvas/WebGLTexture.cpp @@ -742,8 +742,27 @@ WebGLTexture::GenerateMipmap(TexTarget texTarget) 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; }