/
cherry-pick-1fb846c.patch
90 lines (85 loc) · 3.41 KB
/
cherry-pick-1fb846c.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Alexey Knyazev <lexa.knyazev@gmail.com>
Date: Tue Aug 3 01:57:49 2021 +0400
Subject: Validate texStorage dimensions with compressed formats
Bug: angleproject:6230
Change-Id: I501ec1e6974bdc7e6731dcb88045edb0aa22b888
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3067329
Commit-Queue: Alexey Knyazev <lexa.knyazev@gmail.com>
Reviewed-by: Kenneth Russell <kbr@chromium.org>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/validationES3.cpp b/src/libANGLE/validationES3.cpp
index 53e1afd6e..5c69d568e 100644
--- a/src/libANGLE/validationES3.cpp
+++ b/src/libANGLE/validationES3.cpp
@@ -1339,17 +1339,26 @@ bool ValidateES3TexStorageParametersBase(const Context *context,
return false;
}
- if (formatInfo.compressed && target == TextureType::Rectangle)
+ if (formatInfo.compressed)
{
- context->validationError(GL_INVALID_ENUM, kRectangleTextureCompressed);
- return false;
- }
+ if (target == TextureType::Rectangle)
+ {
+ context->validationError(GL_INVALID_ENUM, kRectangleTextureCompressed);
+ return false;
+ }
- if (formatInfo.compressed && target == TextureType::_3D)
- {
- if (!ValidateES3CompressedFormatForTexture3D(context, formatInfo.internalFormat))
+ if (target == TextureType::_3D)
{
- // Error already generated.
+ if (!ValidateES3CompressedFormatForTexture3D(context, formatInfo.internalFormat))
+ {
+ // Error already generated.
+ return false;
+ }
+ }
+
+ if (!ValidCompressedImageSize(context, formatInfo.internalFormat, 0, width, height, depth))
+ {
+ context->validationError(GL_INVALID_OPERATION, kInvalidCompressedImageSize);
return false;
}
}
diff --git a/src/tests/gl_tests/SRGBTextureTest.cpp b/src/tests/gl_tests/SRGBTextureTest.cpp
index 271fe6dba..a0eab1af9 100644
--- a/src/tests/gl_tests/SRGBTextureTest.cpp
+++ b/src/tests/gl_tests/SRGBTextureTest.cpp
@@ -340,7 +340,7 @@ TEST_P(SRGBTextureTestES3, SRGBOverrideFormats)
{
GLTexture tex;
glBindTexture(GL_TEXTURE_2D, tex.get());
- glTexStorage2D(GL_TEXTURE_2D, 1, format, 1, 1);
+ glTexStorage2D(GL_TEXTURE_2D, 1, format, 4, 4);
GLenum error = glGetError();
if (error == GL_INVALID_ENUM)
{
diff --git a/src/tests/gl_tests/WebGLCompatibilityTest.cpp b/src/tests/gl_tests/WebGLCompatibilityTest.cpp
index fabaefbe3..efbd9ebdb 100644
--- a/src/tests/gl_tests/WebGLCompatibilityTest.cpp
+++ b/src/tests/gl_tests/WebGLCompatibilityTest.cpp
@@ -5073,6 +5073,21 @@ void WebGLCompatibilityTest::testCompressedTexLevelDimension(GLenum format,
{
EXPECT_GL_ERROR(expectedError) << explanation;
}
+
+ if (level == 0 && width > 0 && getClientMajorVersion() >= 3)
+ {
+ GLTexture sourceTextureStorage;
+ glBindTexture(GL_TEXTURE_2D, sourceTextureStorage);
+ glTexStorage2D(GL_TEXTURE_2D, 1, format, width, height);
+ if (expectedError == 0)
+ {
+ EXPECT_GL_NO_ERROR() << explanation << " (texStorage)";
+ }
+ else
+ {
+ EXPECT_GL_ERROR(expectedError) << explanation << " (texStorage)";
+ }
+ }
}
void WebGLCompatibilityTest::testCompressedTexImage(GLenum format)