Commit b06128e4 authored by Laszlo Agocs's avatar Laszlo Agocs

gl: Fix asserting on compressed textures

parent cf408458
......@@ -2137,40 +2137,8 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize)
const bool isCompressed = rhiD->isCompressedFormat(m_format);
target = isCube ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D;
gltype = GL_UNSIGNED_BYTE;
switch (m_format) {
case QRhiTexture::RGBA8:
glintformat = GL_RGBA;
glformat = GL_RGBA;
break;
case QRhiTexture::BGRA8:
glintformat = rhiD->caps.bgraInternalFormat ? GL_BGRA : GL_RGBA;
glformat = GL_BGRA;
break;
case QRhiTexture::R16:
glintformat = GL_R16;
glformat = GL_RED;
gltype = GL_UNSIGNED_SHORT;
break;
case QRhiTexture::R8:
glintformat = GL_R8;
glformat = GL_RED;
break;
case QRhiTexture::RED_OR_ALPHA8:
// always alpha because we do not support core profile
glintformat = GL_ALPHA;
glformat = GL_ALPHA;
break;
default:
Q_UNREACHABLE();
glintformat = GL_RGBA;
glformat = GL_RGBA;
break;
}
mipLevelCount = hasMipMaps ? rhiD->q->mipLevelsForSize(size) : 1;
gltype = GL_UNSIGNED_BYTE;
if (isCompressed) {
glintformat = toGlCompressedTextureFormat(m_format, m_flags);
......@@ -2178,6 +2146,37 @@ bool QGles2Texture::prepareBuild(QSize *adjustedSize)
qWarning("Compressed format %d not mappable to GL compressed format", m_format);
return false;
}
glformat = GL_RGBA;
} else {
switch (m_format) {
case QRhiTexture::RGBA8:
glintformat = GL_RGBA;
glformat = GL_RGBA;
break;
case QRhiTexture::BGRA8:
glintformat = rhiD->caps.bgraInternalFormat ? GL_BGRA : GL_RGBA;
glformat = GL_BGRA;
break;
case QRhiTexture::R16:
glintformat = GL_R16;
glformat = GL_RED;
gltype = GL_UNSIGNED_SHORT;
break;
case QRhiTexture::R8:
glintformat = GL_R8;
glformat = GL_RED;
break;
case QRhiTexture::RED_OR_ALPHA8:
// always alpha because we do not support core profile
glintformat = GL_ALPHA;
glformat = GL_ALPHA;
break;
default:
Q_UNREACHABLE();
glintformat = GL_RGBA;
glformat = GL_RGBA;
break;
}
}
if (adjustedSize)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment