зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1081286 - WebGL2: account for the fact that SRGB formats break the 1:1 mapping between sized formats and (unsized format, type) pairs - r=jgilbert
This commit is contained in:
Родитель
aec785a65a
Коммит
9293e8da7b
|
@ -3875,13 +3875,9 @@ WebGLContext::TexSubImage2D_base(TexImageTarget texImageTarget, GLint level,
|
|||
|
||||
const WebGLTexture::ImageInfo& imageInfo = tex->ImageInfoAt(texImageTarget, level);
|
||||
const TexInternalFormat existingEffectiveInternalFormat = imageInfo.EffectiveInternalFormat();
|
||||
TexInternalFormat existingUnsizedInternalFormat = LOCAL_GL_NONE;
|
||||
TexType existingType = LOCAL_GL_NONE;
|
||||
UnsizedInternalFormatAndTypeFromEffectiveInternalFormat(existingEffectiveInternalFormat,
|
||||
&existingUnsizedInternalFormat,
|
||||
&existingType);
|
||||
|
||||
if (!ValidateTexImage(2, texImageTarget, level, existingUnsizedInternalFormat.get(),
|
||||
if (!ValidateTexImage(2, texImageTarget, level,
|
||||
existingEffectiveInternalFormat.get(),
|
||||
xoffset, yoffset, 0,
|
||||
width, height, 0,
|
||||
0, format, type, func))
|
||||
|
@ -3892,7 +3888,7 @@ WebGLContext::TexSubImage2D_base(TexImageTarget texImageTarget, GLint level,
|
|||
if (!ValidateTexInputData(type, jsArrayType, func))
|
||||
return;
|
||||
|
||||
if (type != existingType) {
|
||||
if (type != TypeFromInternalFormat(existingEffectiveInternalFormat)) {
|
||||
return ErrorInvalidOperation("texSubImage2D: type differs from that of the existing image");
|
||||
}
|
||||
|
||||
|
|
|
@ -1142,22 +1142,44 @@ WebGLContext::ValidateTexImage(GLuint dims, TexImageTarget texImageTarget,
|
|||
if (!ValidateTexImageFormatAndType(format, type, func))
|
||||
return false;
|
||||
|
||||
if (!TexInternalFormat::IsValueLegal(internalFormat)) {
|
||||
ErrorInvalidEnum("%s: invalid internalformat enum %s", info, EnumName(internalFormat));
|
||||
return false;
|
||||
}
|
||||
TexInternalFormat unsizedInternalFormat =
|
||||
UnsizedInternalFormatFromInternalFormat(internalFormat);
|
||||
|
||||
if (IsCompressedFunc(func)) {
|
||||
if (!ValidateCompTexImageInternalFormat(internalFormat, func)) {
|
||||
return false;
|
||||
}
|
||||
} else if (IsCopyFunc(func)) {
|
||||
if (!ValidateCopyTexImageInternalFormat(internalFormat, func)) {
|
||||
if (!ValidateCopyTexImageInternalFormat(unsizedInternalFormat.get(), func)) {
|
||||
return false;
|
||||
}
|
||||
} else if (format != internalFormat) {
|
||||
} else if (format != unsizedInternalFormat) {
|
||||
if (IsWebGL2()) {
|
||||
// In WebGL2, it's OK to have internalformat != format if internalformat is the sized
|
||||
// internal format corresponding to the (format, type) pair according to Table 3.2
|
||||
// in the OpenGL ES 3.0.3 spec.
|
||||
if (internalFormat != EffectiveInternalFormatFromInternalFormatAndType(format, type)) {
|
||||
ErrorInvalidOperation("%s: internalformat does not match format and type", info);
|
||||
return false;
|
||||
bool exceptionallyAllowed = false;
|
||||
if (internalFormat == LOCAL_GL_SRGB8_ALPHA8 &&
|
||||
format == LOCAL_GL_RGBA &&
|
||||
type == LOCAL_GL_UNSIGNED_BYTE)
|
||||
{
|
||||
exceptionallyAllowed = true;
|
||||
}
|
||||
else if (internalFormat == LOCAL_GL_SRGB8 &&
|
||||
format == LOCAL_GL_RGB &&
|
||||
type == LOCAL_GL_UNSIGNED_BYTE)
|
||||
{
|
||||
exceptionallyAllowed = true;
|
||||
}
|
||||
if (!exceptionallyAllowed) {
|
||||
ErrorInvalidOperation("%s: internalformat does not match format and type", info);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// in WebGL 1, format must be equal to internalformat
|
||||
|
|
Загрузка…
Ссылка в новой задаче