Bug 1242347 - Allow unsized internal format when generate mipmap. r=jgilbert

This commit is contained in:
Morris Tseng 2016-01-29 10:58:05 +08:00
parent 9986be09f7
commit f1f6c6a8e5

View File

@ -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;
}