From bc22a66060f6986cf219e583cd167882ac0073db Mon Sep 17 00:00:00 2001 From: Pedro Pontes Date: Thu, 16 Dec 2021 22:39:30 +0100 Subject: [PATCH 1/2] chore: cherry-pick 891020ed64d4 from angle --- patches/angle/.patches | 1 + patches/angle/cherry-pick-891020ed64d4.patch | 164 +++++++++++++++++++ patches/config.json | 4 +- 3 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 patches/angle/.patches create mode 100644 patches/angle/cherry-pick-891020ed64d4.patch diff --git a/patches/angle/.patches b/patches/angle/.patches new file mode 100644 index 0000000000000..b3bc61d884ffc --- /dev/null +++ b/patches/angle/.patches @@ -0,0 +1 @@ +cherry-pick-891020ed64d4.patch diff --git a/patches/angle/cherry-pick-891020ed64d4.patch b/patches/angle/cherry-pick-891020ed64d4.patch new file mode 100644 index 0000000000000..408404c7db6c2 --- /dev/null +++ b/patches/angle/cherry-pick-891020ed64d4.patch @@ -0,0 +1,164 @@ +From 891020ed64d418a738b867e5c7e7cb1d0e40c892 Mon Sep 17 00:00:00 2001 +From: Jonah Ryan-Davis +Date: Mon, 22 Nov 2021 14:30:52 -0500 +Subject: [PATCH] [M96] Ignore the pixel unpack state for compressed textures. + +From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding +a compressed texture image +This was causing a bad access when calling compressedTexImage3D +with GL_UNPACK_IMAGE_HEIGHT greater than the image height. + +Bug: chromium:1267496 +Change-Id: I9b1f4c645548af64f2695fd23262225a1ad07cd7 +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3296622 +Commit-Queue: Jonah Ryan-Davis +Reviewed-by: Geoff Lang +Reviewed-by: Shahbaz Youssefi +(cherry picked from commit 870f458f507ff7ba0f67b28a30a27955ce79dd3e) +Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3309097 +Reviewed-by: Jonah Ryan-Davis +Reviewed-by: Jamie Madill +--- + +diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp +index b3b7f73..94afefd 100644 +--- a/src/libANGLE/Context.cpp ++++ b/src/libANGLE/Context.cpp +@@ -5017,7 +5017,9 @@ + + Extents size(width, height, 1); + Texture *texture = getTextureByTarget(target); +- ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mState.getUnpackState(), target, level, ++ // From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture ++ // image. So we use an empty PixelUnpackState. ++ ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, PixelUnpackState(), target, level, + internalformat, size, imageSize, + static_cast(data))); + } +@@ -5049,7 +5051,9 @@ + + Extents size(width, height, depth); + Texture *texture = getTextureByTarget(target); +- ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, mState.getUnpackState(), target, level, ++ // From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture ++ // image. So we use an empty PixelUnpackState. ++ ANGLE_CONTEXT_TRY(texture->setCompressedImage(this, PixelUnpackState(), target, level, + internalformat, size, imageSize, + static_cast(data))); + } +@@ -5083,8 +5087,10 @@ + + Box area(xoffset, yoffset, 0, width, height, 1); + Texture *texture = getTextureByTarget(target); +- ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mState.getUnpackState(), target, level, +- area, format, imageSize, ++ // From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture ++ // image. So we use an empty PixelUnpackState. ++ ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, PixelUnpackState(), target, level, area, ++ format, imageSize, + static_cast(data))); + } + +@@ -5125,8 +5131,10 @@ + + Box area(xoffset, yoffset, zoffset, width, height, depth); + Texture *texture = getTextureByTarget(target); +- ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, mState.getUnpackState(), target, level, +- area, format, imageSize, ++ // From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture ++ // image. So we use an empty PixelUnpackState. ++ ANGLE_CONTEXT_TRY(texture->setCompressedSubImage(this, PixelUnpackState(), target, level, area, ++ format, imageSize, + static_cast(data))); + } + +diff --git a/src/tests/gl_tests/TextureTest.cpp b/src/tests/gl_tests/TextureTest.cpp +index 4d7ba26..79baa98 100644 +--- a/src/tests/gl_tests/TextureTest.cpp ++++ b/src/tests/gl_tests/TextureTest.cpp +@@ -5201,6 +5201,43 @@ + EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black); + } + ++// Test that compressed textures ignore the pixel unpack state. ++// (https://crbug.org/1267496) ++TEST_P(Texture3DTestES3, PixelUnpackStateTexImage) ++{ ++ ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_s3tc") && ++ !IsGLExtensionEnabled("GL_ANGLE_texture_compression_dxt3")); ++ ++ glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 5); ++ glBindTexture(GL_TEXTURE_2D_ARRAY, mTexture3D); ++ ++ uint8_t data[64] = {0}; ++ glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 4, 4, 4, 0, 64, ++ data); ++ EXPECT_GL_NO_ERROR(); ++} ++ ++// Test that compressed textures ignore the pixel unpack state. ++// (https://crbug.org/1267496) ++TEST_P(Texture3DTestES3, PixelUnpackStateTexSubImage) ++{ ++ ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_s3tc") && ++ !IsGLExtensionEnabled("GL_ANGLE_texture_compression_dxt3")); ++ ++ glBindTexture(GL_TEXTURE_2D_ARRAY, mTexture3D); ++ ++ uint8_t data[64] = {0}; ++ glCompressedTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 4, 4, 4, 0, 64, ++ data); ++ EXPECT_GL_NO_ERROR(); ++ ++ glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 5); ++ ++ glCompressedTexSubImage3D(GL_TEXTURE_2D_ARRAY, 0, 0, 0, 0, 4, 4, 4, ++ GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 64, data); ++ EXPECT_GL_NO_ERROR(); ++} ++ + // Test that 3D texture completeness is updated if texture max level changes. + // GLES 3.0.4 section 3.8.13 Texture completeness + TEST_P(Texture3DTestES3, Texture3DCompletenessChangesWithMaxLevel) +@@ -5888,6 +5925,41 @@ + EXPECT_PIXEL_ALPHA_EQ(0, 0, 255); + } + ++// Test that compressed textures ignore the pixel unpack state. ++// (https://crbug.org/1267496) ++TEST_P(Texture2DTestES3, PixelUnpackStateTexImage) ++{ ++ ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_s3tc") && ++ !IsGLExtensionEnabled("GL_ANGLE_texture_compression_dxt3")); ++ ++ glPixelStorei(GL_UNPACK_ROW_LENGTH, 5); ++ glBindTexture(GL_TEXTURE_2D, mTexture2D); ++ ++ uint8_t data[16] = {0}; ++ glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 4, 4, 0, 16, data); ++ EXPECT_GL_NO_ERROR(); ++} ++ ++// Test that compressed textures ignore the pixel unpack state. ++// (https://crbug.org/1267496) ++TEST_P(Texture2DTestES3, PixelUnpackStateTexSubImage) ++{ ++ ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_EXT_texture_compression_s3tc") && ++ !IsGLExtensionEnabled("GL_ANGLE_texture_compression_dxt3")); ++ ++ glBindTexture(GL_TEXTURE_2D, mTexture2D); ++ ++ uint8_t data[16] = {0}; ++ glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 4, 4, 0, 16, data); ++ EXPECT_GL_NO_ERROR(); ++ ++ glPixelStorei(GL_UNPACK_ROW_LENGTH, 5); ++ ++ glCompressedTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 4, 4, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, 16, ++ data); ++ EXPECT_GL_NO_ERROR(); ++} ++ + // Copied from Texture2DTest::TexStorage + // Test that glTexSubImage2D works properly when glTexStorage2DEXT has initialized the image with a + // default color. diff --git a/patches/config.json b/patches/config.json index e9a2297ba10f2..3b59b7b5108b7 100644 --- a/patches/config.json +++ b/patches/config.json @@ -13,5 +13,7 @@ "src/electron/patches/Mantle": "src/third_party/squirrel.mac/vendor/Mantle", - "src/electron/patches/ReactiveObjC": "src/third_party/squirrel.mac/vendor/ReactiveObjC" + "src/electron/patches/ReactiveObjC": "src/third_party/squirrel.mac/vendor/ReactiveObjC", + + "src/electron/patches/angle": "src/third_party/angle" } From f133735b970f617085a6d2104bc6727d5328ed1b Mon Sep 17 00:00:00 2001 From: PatchUp <73610968+patchup[bot]@users.noreply.github.com> Date: Mon, 20 Dec 2021 10:56:50 +0000 Subject: [PATCH 2/2] chore: update patches --- patches/angle/cherry-pick-891020ed64d4.patch | 21 ++++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/patches/angle/cherry-pick-891020ed64d4.patch b/patches/angle/cherry-pick-891020ed64d4.patch index 408404c7db6c2..9e00282ec9c54 100644 --- a/patches/angle/cherry-pick-891020ed64d4.patch +++ b/patches/angle/cherry-pick-891020ed64d4.patch @@ -1,7 +1,7 @@ -From 891020ed64d418a738b867e5c7e7cb1d0e40c892 Mon Sep 17 00:00:00 2001 +From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jonah Ryan-Davis Date: Mon, 22 Nov 2021 14:30:52 -0500 -Subject: [PATCH] [M96] Ignore the pixel unpack state for compressed textures. +Subject: Ignore the pixel unpack state for compressed textures. From OpenGL ES 3 spec: All pixel storage modes are ignored when decoding a compressed texture image @@ -18,13 +18,12 @@ Reviewed-by: Shahbaz Youssefi Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3309097 Reviewed-by: Jonah Ryan-Davis Reviewed-by: Jamie Madill ---- diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp -index b3b7f73..94afefd 100644 +index c4ce77d612d88a898f8a8164466d25b210e2144b..eb60719ac38543b608c122daebd71b1084ac35f2 100644 --- a/src/libANGLE/Context.cpp +++ b/src/libANGLE/Context.cpp -@@ -5017,7 +5017,9 @@ +@@ -4961,7 +4961,9 @@ void Context::compressedTexImage2D(TextureTarget target, Extents size(width, height, 1); Texture *texture = getTextureByTarget(target); @@ -35,7 +34,7 @@ index b3b7f73..94afefd 100644 internalformat, size, imageSize, static_cast(data))); } -@@ -5049,7 +5051,9 @@ +@@ -4993,7 +4995,9 @@ void Context::compressedTexImage3D(TextureTarget target, Extents size(width, height, depth); Texture *texture = getTextureByTarget(target); @@ -46,7 +45,7 @@ index b3b7f73..94afefd 100644 internalformat, size, imageSize, static_cast(data))); } -@@ -5083,8 +5087,10 @@ +@@ -5027,8 +5031,10 @@ void Context::compressedTexSubImage2D(TextureTarget target, Box area(xoffset, yoffset, 0, width, height, 1); Texture *texture = getTextureByTarget(target); @@ -59,7 +58,7 @@ index b3b7f73..94afefd 100644 static_cast(data))); } -@@ -5125,8 +5131,10 @@ +@@ -5069,8 +5075,10 @@ void Context::compressedTexSubImage3D(TextureTarget target, Box area(xoffset, yoffset, zoffset, width, height, depth); Texture *texture = getTextureByTarget(target); @@ -73,10 +72,10 @@ index b3b7f73..94afefd 100644 } diff --git a/src/tests/gl_tests/TextureTest.cpp b/src/tests/gl_tests/TextureTest.cpp -index 4d7ba26..79baa98 100644 +index e79bc700d4991752289ff3d7c76f2ccbb3ba932a..f5b82b03324f7d2b4c6c7f2bd05de568300a6fbe 100644 --- a/src/tests/gl_tests/TextureTest.cpp +++ b/src/tests/gl_tests/TextureTest.cpp -@@ -5201,6 +5201,43 @@ +@@ -5151,6 +5151,43 @@ TEST_P(Texture2DTestES3, TextureCompletenessChangesWithMaxLevel) EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::black); } @@ -120,7 +119,7 @@ index 4d7ba26..79baa98 100644 // Test that 3D texture completeness is updated if texture max level changes. // GLES 3.0.4 section 3.8.13 Texture completeness TEST_P(Texture3DTestES3, Texture3DCompletenessChangesWithMaxLevel) -@@ -5888,6 +5925,41 @@ +@@ -5830,6 +5867,41 @@ TEST_P(Texture2DTestES3, TextureCOMPRESSEDSRGB8ETC2ImplicitAlpha1) EXPECT_PIXEL_ALPHA_EQ(0, 0, 255); }