Fix the CopyTex validation logic for sized types
Previously we allowed copies to a sized format only if the depth of each
component matched (including 0 depth). Now we require that the bit depth of
non-empty component matches.
BUG=605775
Change-Id: If8abab886b0da5a1c8e89adabf3809f928dcedce
Reviewed-on: https://chromium-review.googlesource.com/340382
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 690672d..c097059 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -728,6 +728,11 @@
return set;
}
+static bool EqualOrFirstZero(GLuint first, GLuint second)
+{
+ return first == 0 || first == second;
+}
+
static bool IsValidES3CopyTexImageCombination(GLenum textureInternalFormat, GLenum frameBufferInternalFormat, GLuint readBufferHandle)
{
const InternalFormat &textureInternalFormatInfo = GetInternalFormatInfo(textureInternalFormat);
@@ -832,12 +837,17 @@
if (textureInternalFormatInfo.pixelBytes > 0)
{
- // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination format is sized,
- // component sizes of the source and destination formats must exactly match
- if (textureInternalFormatInfo.redBits != sourceEffectiveFormat->redBits ||
- textureInternalFormatInfo.greenBits != sourceEffectiveFormat->greenBits ||
- textureInternalFormatInfo.blueBits != sourceEffectiveFormat->blueBits ||
- textureInternalFormatInfo.alphaBits != sourceEffectiveFormat->alphaBits)
+ // Section 3.8.5 of the GLES 3.0.3 spec, pg 139, requires that, if the destination
+ // format is sized, component sizes of the source and destination formats must exactly
+ // match if the destination format exists.
+ if (!EqualOrFirstZero(textureInternalFormatInfo.redBits,
+ sourceEffectiveFormat->redBits) ||
+ !EqualOrFirstZero(textureInternalFormatInfo.greenBits,
+ sourceEffectiveFormat->greenBits) ||
+ !EqualOrFirstZero(textureInternalFormatInfo.blueBits,
+ sourceEffectiveFormat->blueBits) ||
+ !EqualOrFirstZero(textureInternalFormatInfo.alphaBits,
+ sourceEffectiveFormat->alphaBits))
{
return false;
}