Misc fixes.
draft
Misc fixes.
--- a/dom/canvas/WebGLFormats.cpp
+++ b/dom/canvas/WebGLFormats.cpp
@@ -554,17 +554,17 @@ FormatUsageAuthority::CreateForWebGL1(gl
#define FOO(x) ptr->AddRBFormat(LOCAL_GL_ ## x, ptr->GetUsage(EffectiveFormat::x))
FOO(RGBA4 );
FOO(RGB5_A1 );
FOO(RGB565 );
FOO(DEPTH_COMPONENT16);
FOO(STENCIL_INDEX8 );
- //FOO(DEPTH24_STENCIL8 );
+ //FOO(DEPTH24_STENCIL8 ); // WebGL 1 uses DEPTH_STENCIL instead of DEPTH24_STENCIL8.
#undef FOO
ptr->AddRBFormat(LOCAL_GL_DEPTH_STENCIL,
ptr->GetUsage(EffectiveFormat::DEPTH24_STENCIL8));
////////////////////////////////////////////////////////////////////////////
--- a/dom/canvas/WebGLTexelConversions.cpp
+++ b/dom/canvas/WebGLTexelConversions.cpp
@@ -372,17 +372,17 @@ ConvertImage(size_t width, size_t height
//
// The case where absolutely nothing needs to be done is supposed to have
// been handled earlier (in TexImage2D_base, etc).
//
// So the case we're handling here is when even though no format conversion is
// needed, we still might have to flip vertically and/or to adjust to a different
// stride.
- MOZ_ASSERT(!shouldYFlip || srcStride != dstStride,
+ MOZ_ASSERT(shouldYFlip || srcStride != dstStride,
"Performance trap -- should handle this case earlier to avoid memcpy");
const auto bytesPerPixel = TexelBytesForFormat(srcFormat);
const size_t bytesPerRow = bytesPerPixel * width;
while (srcItr != srcEnd) {
memcpy(dstItr, srcItr, bytesPerRow);
srcItr += srcStride;
--- a/dom/canvas/WebGLTexture.cpp
+++ b/dom/canvas/WebGLTexture.cpp
@@ -800,17 +800,17 @@ WebGLTexture::TexParameter(TexTarget tex
case LOCAL_GL_TEXTURE_MIN_LOD:
case LOCAL_GL_TEXTURE_WRAP_R:
if (mContext->IsWebGL2())
isPNameValid = true;
break;
case LOCAL_GL_TEXTURE_MAX_ANISOTROPY_EXT:
if (mContext->IsExtensionEnabled(WebGLExtensionID::EXT_texture_filter_anisotropic))
- isPNameValid = false;
+ isPNameValid = true;
break;
}
if (!isPNameValid) {
mContext->ErrorInvalidEnumInfo("texParameter: pname", pname);
return;
}
--- a/dom/canvas/WebGLTextureUpload.cpp
+++ b/dom/canvas/WebGLTextureUpload.cpp
@@ -404,29 +404,34 @@ WebGLTexture::ValidateTexImageSpecificat
GLsizei depth, GLint border,
WebGLTexture::ImageInfo** const out_imageInfo)
{
if (mImmutable) {
mContext->ErrorInvalidOperation("%s: Specified texture is immutable.", funcName);
return false;
}
+ // Do this early to validate `level`.
+ WebGLTexture::ImageInfo* imageInfo;
+ if (!ValidateTexImage(mContext, this, funcName, target, level, &imageInfo))
+ return false;
+
// Check border
if (border != 0) {
mContext->ErrorInvalidValue("%s: `border` must be 0.", funcName);
return false;
}
- if (level < 0 || width < 0 || height < 0 || depth < 0) {
+ if (width < 0 || height < 0 || depth < 0) {
/* GL ES Version 2.0.25 - 3.7.1 Texture Image Specification
* "If wt and ht are the specified image width and height,
* and if either wt or ht are less than zero, then the error
* INVALID_VALUE is generated."
*/
- mContext->ErrorInvalidValue("%s: `level`/`width`/`height`/`depth` must be >= 0.",
+ mContext->ErrorInvalidValue("%s: `width`/`height`/`depth` must be >= 0.",
funcName);
return false;
}
/* GLES 3.0.4, p133-134:
* GL_MAX_TEXTURE_SIZE is *not* the max allowed texture size. Rather, it is the
* max (width/height) size guaranteed not to generate an INVALID_VALUE for too-large
* dimensions. Sizes larger than GL_MAX_TEXTURE_SIZE *may or may not* result in an
@@ -438,41 +443,40 @@ WebGLTexture::ValidateTexImageSpecificat
*
* Note that mImplMaxTextureSize must be >= than the advertized MAX_TEXTURE_SIZE.
* For simplicity, we advertize MAX_TEXTURE_SIZE as mImplMaxTextureSize.
*/
uint32_t maxWidthHeight = 0;
uint32_t maxDepth = 0;
- if (level <= 31) {
- switch (target.get()) {
- case LOCAL_GL_TEXTURE_2D:
- maxWidthHeight = mContext->mImplMaxTextureSize >> level;
- maxDepth = 1;
- break;
+ MOZ_ASSERT(level <= 31);
+ switch (target.get()) {
+ case LOCAL_GL_TEXTURE_2D:
+ maxWidthHeight = mContext->mImplMaxTextureSize >> level;
+ maxDepth = 1;
+ break;
- case LOCAL_GL_TEXTURE_3D:
- maxWidthHeight = mContext->mImplMax3DTextureSize >> level;
- maxDepth = maxWidthHeight;
- break;
+ case LOCAL_GL_TEXTURE_3D:
+ maxWidthHeight = mContext->mImplMax3DTextureSize >> level;
+ maxDepth = maxWidthHeight;
+ break;
- case LOCAL_GL_TEXTURE_2D_ARRAY:
- maxWidthHeight = mContext->mImplMaxTextureSize >> level;
- // "The maximum number of layers for two-dimensional array textures (depth)
- // must be at least MAX_ARRAY_TEXTURE_LAYERS for all levels."
- maxDepth = mContext->mImplMaxArrayTextureLayers;
- break;
+ case LOCAL_GL_TEXTURE_2D_ARRAY:
+ maxWidthHeight = mContext->mImplMaxTextureSize >> level;
+ // "The maximum number of layers for two-dimensional array textures (depth)
+ // must be at least MAX_ARRAY_TEXTURE_LAYERS for all levels."
+ maxDepth = mContext->mImplMaxArrayTextureLayers;
+ break;
- default: // cube maps
- MOZ_ASSERT(IsCubeMap());
- maxWidthHeight = mContext->mImplMaxCubeMapTextureSize >> level;
- maxDepth = 1;
- break;
- }
+ default: // cube maps
+ MOZ_ASSERT(IsCubeMap());
+ maxWidthHeight = mContext->mImplMaxCubeMapTextureSize >> level;
+ maxDepth = 1;
+ break;
}
if (uint32_t(width) > maxWidthHeight ||
uint32_t(height) > maxWidthHeight ||
uint32_t(depth) > maxDepth)
{
mContext->ErrorInvalidValue("%s: Requested size at this level is unsupported.",
funcName);
@@ -494,20 +498,16 @@ WebGLTexture::ValidateTexImageSpecificat
mContext->ErrorInvalidValue("%s: For level > 0, width and height must be"
" powers of two.",
funcName);
return false;
}
}
}
- WebGLTexture::ImageInfo* imageInfo;
- if (!ValidateTexImage(mContext, this, funcName, target, level, &imageInfo))
- return false;
-
*out_imageInfo = imageInfo;
return true;
}
// For *TexSubImage*
bool
WebGLTexture::ValidateTexImageSelection(const char* funcName, TexImageTarget target,
GLint level, GLint xOffset, GLint yOffset,