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

--HG--
extra : commitid : BMfNLWIwGbn
This commit is contained in:
Morris Tseng 2016-01-29 10:58:05 +08:00
Родитель b78f8ff470
Коммит 571b20fd9f
1 изменённых файлов: 21 добавлений и 2 удалений

Просмотреть файл

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