Fix -Wshadow.

This still disables the warning for glmark2 instead of fixing it, to
avoid needing to upstream a patch.

Bug: chromium:794619
Change-Id: Ice602996041d6090c9b09ee81c8ed095c4fa6b2e
Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/3179860
Reviewed-by: Shahbaz Youssefi <syoussefi@chromium.org>
Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
Peter Kasting
2021-09-23 09:50:46 -07:00
committed by Angle LUCI CQ
parent e1a9af6ae1
commit 4f2b299521
9 changed files with 141 additions and 87 deletions

View File

@@ -359,7 +359,6 @@ TEST(FastIntegerMap, BasicUsage)
for (KeyValuePair entry : entries)
{
std::string str;
EXPECT_TRUE(testMap.get(entry.first, &str));
EXPECT_EQ(entry.second, str);
}

View File

@@ -196,10 +196,10 @@ TEST_P(EGLCreateContextAttribsTest, IMGContextPriorityExtension)
EXPECT_EQ(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_BAD_ATTRIBUTE);
EGLint contextAttribs[] = {EGL_CONTEXT_MAJOR_VERSION, 2, EGL_CONTEXT_MINOR_VERSION, 0,
EGL_NONE};
EGLint noExtensionContextAttribs[] = {EGL_CONTEXT_MAJOR_VERSION, 2,
EGL_CONTEXT_MINOR_VERSION, 0, EGL_NONE};
context = eglCreateContext(mDisplay, config, nullptr, contextAttribs);
context = eglCreateContext(mDisplay, config, nullptr, noExtensionContextAttribs);
EXPECT_NE(context, EGL_NO_CONTEXT);
ASSERT_EGL_ERROR(EGL_SUCCESS);

View File

@@ -632,39 +632,43 @@ void main()
drawQuad(programRed, "a_position", 0);
EXPECT_GL_NO_ERROR();
// All pixels on the left of the plane x = -0.5 must be blue
GLuint x = 0;
GLuint y = 0;
GLuint width = getWindowWidth() / 4 - 1;
GLuint height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::blue);
// All pixels on the right of the plane x = -0.5 must be red, except those in the upper right
// triangle
x = getWindowWidth() / 4 + 2;
y = 0;
width = getWindowWidth() / 2 - x;
height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::red);
std::vector<GLColor> actualColors(getWindowWidth() * getWindowHeight());
glReadPixels(0, 0, getWindowWidth(), getWindowHeight(), GL_RGBA, GL_UNSIGNED_BYTE,
actualColors.data());
for (int y = 0; y < getWindowHeight(); ++y)
{
for (int x = getWindowWidth() / 2; x < getWindowWidth(); ++x)
{
const int currentPosition = y * getWindowHeight() + x;
// All pixels on the left of the plane x = -0.5 must be blue
GLuint x = 0;
GLuint y = 0;
GLuint width = getWindowWidth() / 4 - 1;
GLuint height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::blue);
if (x < getWindowWidth() * 3 / 2 - y - 1 && x < getWindowWidth() * 3 / 4 - 1)
// All pixels on the right of the plane x = -0.5 must be red, except those in the upper
// right triangle
x = getWindowWidth() / 4 + 2;
y = 0;
width = getWindowWidth() / 2 - x;
height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::red);
}
{
std::vector<GLColor> actualColors(getWindowWidth() * getWindowHeight());
glReadPixels(0, 0, getWindowWidth(), getWindowHeight(), GL_RGBA, GL_UNSIGNED_BYTE,
actualColors.data());
for (int y = 0; y < getWindowHeight(); ++y)
{
for (int x = getWindowWidth() / 2; x < getWindowWidth(); ++x)
{
// bottom left triangle clipped by x=0.5 plane
EXPECT_EQ(GLColor::red, actualColors[currentPosition]);
}
else if (x > getWindowWidth() * 3 / 2 - y + 1 || x > getWindowWidth() * 3 / 4 + 1)
{
// upper right triangle plus right of x=0.5 plane
EXPECT_EQ(GLColor::blue, actualColors[currentPosition]);
const int currentPosition = y * getWindowHeight() + x;
if (x < getWindowWidth() * 3 / 2 - y - 1 && x < getWindowWidth() * 3 / 4 - 1)
{
// bottom left triangle clipped by x=0.5 plane
EXPECT_EQ(GLColor::red, actualColors[currentPosition]);
}
else if (x > getWindowWidth() * 3 / 2 - y + 1 || x > getWindowWidth() * 3 / 4 + 1)
{
// upper right triangle plus right of x=0.5 plane
EXPECT_EQ(GLColor::blue, actualColors[currentPosition]);
}
}
}
}
@@ -690,14 +694,17 @@ void main()
}
}
// All pixels on the right of the plane x = -0.5 must be red, except those in the upper right
// triangle
x = getWindowWidth() / 4 + 2;
y = 0;
width = getWindowWidth() / 2 - x;
height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::red);
{
// All pixels on the right of the plane x = -0.5 must be red, except those in the upper
// right triangle
GLuint x = getWindowWidth() / 4 + 2;
GLuint y = 0;
GLuint width = getWindowWidth() / 2 - x;
GLuint height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::red);
}
std::vector<GLColor> actualColors(getWindowWidth() * getWindowHeight());
glReadPixels(0, 0, getWindowWidth(), getWindowHeight(), GL_RGBA, GL_UNSIGNED_BYTE,
actualColors.data());
for (int y = 0; y < getWindowHeight(); ++y)
@@ -775,20 +782,22 @@ void main()
drawQuad(programRed, "a_position", 0);
EXPECT_GL_NO_ERROR();
// All pixels on the left of the plane x = -0.5 must be blue
GLuint x = 0;
GLuint y = 0;
GLuint width = getWindowWidth() / 4 - 1;
GLuint height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::blue);
{
// All pixels on the left of the plane x = -0.5 must be blue
GLuint x = 0;
GLuint y = 0;
GLuint width = getWindowWidth() / 4 - 1;
GLuint height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::blue);
// All pixels on the right of the plane x = -0.5 must be red, except those in the upper right
// triangle
x = getWindowWidth() / 4 + 2;
y = 0;
width = getWindowWidth() / 2 - x;
height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::red);
// All pixels on the right of the plane x = -0.5 must be red, except those in the upper
// right triangle
x = getWindowWidth() / 4 + 2;
y = 0;
width = getWindowWidth() / 2 - x;
height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::red);
}
std::vector<GLColor> actualColors(getWindowWidth() * getWindowHeight());
glReadPixels(0, 0, getWindowWidth(), getWindowHeight(), GL_RGBA, GL_UNSIGNED_BYTE,
@@ -847,12 +856,14 @@ void main()
drawQuad(programRed, "a_position", 0);
EXPECT_GL_NO_ERROR();
// All pixels must be red
GLuint x = 0;
GLuint y = 0;
GLuint width = getWindowWidth();
GLuint height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::red);
{
// All pixels must be red
GLuint x = 0;
GLuint y = 0;
GLuint width = getWindowWidth();
GLuint height = getWindowHeight();
EXPECT_PIXEL_RECT_EQ(x, y, width, height, GLColor::red);
}
// Clear to green
glClearColor(0, 1, 0, 1);

View File

@@ -171,7 +171,6 @@ TEST_P(GetImageTest, GetTexImage)
// Verify the extension is enabled.
ASSERT_TRUE(IsGLExtensionEnabled(kExtensionName));
constexpr uint32_t kSmallSize = 2;
std::vector<GLColor> expectedData = {GLColor::red, GLColor::blue, GLColor::green,
GLColor::yellow};
@@ -422,7 +421,6 @@ TEST_P(GetImageTest, GetImageRGB)
// Verify the extension is enabled.
ASSERT_TRUE(IsGLExtensionEnabled(kExtensionName));
constexpr uint32_t kSmallSize = 2;
std::vector<GLColorRGB> expectedData = {GLColorRGB::red, GLColorRGB::blue, GLColorRGB::green,
GLColorRGB::yellow};
@@ -464,8 +462,8 @@ TEST_P(GetImageTestES31, Texture2DArray)
// Verify the extension is enabled.
ASSERT_TRUE(IsGLExtensionEnabled(kExtensionName));
constexpr GLsizei kSize = 2;
constexpr GLsizei kLayers = 4;
constexpr GLsizei kTextureSize = 2;
constexpr GLsizei kLayers = 4;
std::vector<GLColor> expectedPixels = {
GLColor::red, GLColor::red, GLColor::red, GLColor::red,
@@ -476,7 +474,7 @@ TEST_P(GetImageTestES31, Texture2DArray)
GLTexture tex;
glBindTexture(GL_TEXTURE_2D_ARRAY, tex);
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, kSize, kSize, kLayers, 0, GL_RGBA,
glTexImage3D(GL_TEXTURE_2D_ARRAY, 0, GL_RGBA, kTextureSize, kTextureSize, kLayers, 0, GL_RGBA,
GL_UNSIGNED_BYTE, expectedPixels.data());
ASSERT_GL_NO_ERROR();
@@ -492,7 +490,7 @@ TEST_P(GetImageTestES31, Texture3D)
// Verify the extension is enabled.
ASSERT_TRUE(IsGLExtensionEnabled(kExtensionName));
constexpr GLsizei kSize = 2;
constexpr GLsizei kTextureSize = 2;
std::vector<GLColor> expectedPixels = {
GLColor::red, GLColor::red, GLColor::green, GLColor::green,
@@ -501,8 +499,8 @@ TEST_P(GetImageTestES31, Texture3D)
GLTexture tex;
glBindTexture(GL_TEXTURE_3D, tex);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, kSize, kSize, kSize, 0, GL_RGBA, GL_UNSIGNED_BYTE,
expectedPixels.data());
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA, kTextureSize, kTextureSize, kTextureSize, 0, GL_RGBA,
GL_UNSIGNED_BYTE, expectedPixels.data());
ASSERT_GL_NO_ERROR();
std::vector<GLColor> actualPixels(expectedPixels.size(), GLColor::white);
@@ -520,8 +518,8 @@ TEST_P(GetImageTestES31, TextureCubeMapArray)
// Verify the extension is enabled.
ASSERT_TRUE(IsGLExtensionEnabled(kExtensionName));
constexpr GLsizei kSize = 1;
constexpr GLsizei kLayers = 2;
constexpr GLsizei kTextureSize = 1;
constexpr GLsizei kLayers = 2;
std::vector<GLColor> expectedPixels = {
GLColor::red, GLColor::green, GLColor::blue, GLColor::yellow,
@@ -529,12 +527,13 @@ TEST_P(GetImageTestES31, TextureCubeMapArray)
GLColor::blue, GLColor::yellow, GLColor::cyan, GLColor::magenta,
};
ASSERT_EQ(expectedPixels.size(), static_cast<size_t>(6 * kSize * kSize * kLayers));
ASSERT_EQ(expectedPixels.size(),
static_cast<size_t>(6 * kTextureSize * kTextureSize * kLayers));
GLTexture tex;
glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, tex);
glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, kSize, kSize, kLayers * 6, 0, GL_RGBA,
GL_UNSIGNED_BYTE, expectedPixels.data());
glTexImage3D(GL_TEXTURE_CUBE_MAP_ARRAY, 0, GL_RGBA, kTextureSize, kTextureSize, kLayers * 6, 0,
GL_RGBA, GL_UNSIGNED_BYTE, expectedPixels.data());
ASSERT_GL_NO_ERROR();
std::vector<GLColor> actualPixels(expectedPixels.size(), GLColor::white);
@@ -550,7 +549,6 @@ TEST_P(GetImageTest, InconsistentTexture2D)
// Verify the extension is enabled.
ASSERT_TRUE(IsGLExtensionEnabled(kExtensionName));
constexpr uint32_t kSmallSize = 2;
std::vector<GLColor> expectedData = {GLColor::red, GLColor::blue, GLColor::green,
GLColor::yellow};

View File

@@ -7050,15 +7050,16 @@ class Texture2DNorm16TestES3 : public Texture2DTestES3
char errorInfo[200];
for (GLuint y = 0; y < height; ++y)
for (GLuint row = 0; row < height; ++row)
{
GLushort *curPixel = pixelRowStart;
for (GLuint x = 0, len = (y == height - 1) ? width : std::min(l, width); x < len; ++x)
for (GLuint col = 0, len = (row == height - 1) ? width : std::min(l, width); col < len;
++col)
{
snprintf(errorInfo, sizeof(errorInfo),
"extent: {%u, %u}, coord: (%u, %u), rowLength: %d, alignment: %d, "
"skipPixels: %d, skipRows: %d\n",
width, height, x, y, packRowLength, packAlignment, packSkipPixels,
width, height, col, row, packRowLength, packAlignment, packSkipPixels,
packSkipRows);
EXPECT_EQ(color.R, curPixel[0]) << errorInfo;
EXPECT_EQ(color.G, curPixel[1]) << errorInfo;

View File

@@ -1432,7 +1432,10 @@ TEST_P(UniformBufferTest, Std140UniformBlockWithRowMajorQualifierOnStruct)
EXPECT_PIXEL_COLOR_NEAR(0, 0, GLColor(255, 64, 128, 32), 5);
}
constexpr char kFragmentShader[] = R"(#version 300 es
// Regression test for a dirty bit bug in ANGLE. See http://crbug.com/792966
TEST_P(UniformBufferTest, SimpleBindingChange)
{
constexpr char kFragmentShader[] = R"(#version 300 es
precision mediump float;
layout (std140) uniform color_ubo
@@ -1446,9 +1449,6 @@ void main()
fragColor = color;
})";
// Regression test for a dirty bit bug in ANGLE. See http://crbug.com/792966
TEST_P(UniformBufferTest, SimpleBindingChange)
{
// http://anglebug.com/2287
ANGLE_SKIP_TEST_IF(IsOSX() && IsNVIDIA() && IsDesktopOpenGL());
@@ -1497,6 +1497,20 @@ TEST_P(UniformBufferTest, SimpleBindingChange)
// Regression test for a dirty bit bug in ANGLE. Same as above but for the indexed bindings.
TEST_P(UniformBufferTest, SimpleBufferChange)
{
constexpr char kFragmentShader[] = R"(#version 300 es
precision mediump float;
layout (std140) uniform color_ubo
{
vec4 color;
};
out vec4 fragColor;
void main()
{
fragColor = color;
})";
ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Simple(), kFragmentShader);
glBindAttribLocation(program, 0, essl3_shaders::PositionAttrib());
@@ -1541,6 +1555,20 @@ TEST_P(UniformBufferTest, SimpleBufferChange)
// update in the State Manager class.
TEST_P(UniformBufferTest, DependentBufferChange)
{
constexpr char kFragmentShader[] = R"(#version 300 es
precision mediump float;
layout (std140) uniform color_ubo
{
vec4 color;
};
out vec4 fragColor;
void main()
{
fragColor = color;
})";
ANGLE_GL_PROGRAM(program, essl3_shaders::vs::Simple(), kFragmentShader);
glBindAttribLocation(program, 0, essl3_shaders::PositionAttrib());
@@ -1585,6 +1613,20 @@ TEST_P(UniformBufferTest, DependentBufferChange)
// regression in http://anglebug.com/3388
TEST_P(UniformBufferTest, SizeOverMaxBlockSize)
{
constexpr char kFragmentShader[] = R"(#version 300 es
precision mediump float;
layout (std140) uniform color_ubo
{
vec4 color;
};
out vec4 fragColor;
void main()
{
fragColor = color;
})";
// Test crashes on Windows AMD OpenGL
ANGLE_SKIP_TEST_IF(IsAMD() && IsWindows() && IsOpenGL());
// http://anglebug.com/5382

View File

@@ -745,7 +745,6 @@ void RunShouldClearWithSemaphoresTest(bool useMemoryObjectFlags,
vkReleaseSemaphore);
uint8_t pixels[4];
VkOffset3D offset = {};
VkExtent3D extent = {1, 1, 1};
helper.readPixels(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, format, offset, extent,
pixels, sizeof(pixels));
@@ -983,7 +982,6 @@ void VulkanExternalImageTest::runShouldDrawTest(bool isSwiftshader, bool enableD
uint8_t pixels[4];
VkOffset3D offset = {};
VkExtent3D extent = {1, 1, 1};
helper.readPixels(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, format, offset, extent,
pixels, sizeof(pixels));
@@ -1154,7 +1152,6 @@ void VulkanExternalImageTest::runWaitSemaphoresRetainsContentTest(bool isSwiftsh
uint8_t pixels[4];
VkOffset3D offset = {};
VkExtent3D extent = {1, 1, 1};
helper.readPixels(image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, format, offset, extent,
pixels, sizeof(pixels));

View File

@@ -2177,8 +2177,8 @@ void main(),
{,
gl_Position = vec4(1.0);,
})";
GLuint program = CompileProgram(invalidVert.c_str(), essl1_shaders::fs::Red());
EXPECT_EQ(0u, program);
GLuint program_number = CompileProgram(invalidVert.c_str(), essl1_shaders::fs::Red());
EXPECT_EQ(0u, program_number);
}
}

View File

@@ -42,6 +42,12 @@ raw_glmark_data_path = rebase_path(glmark_data_path, root_build_dir)
config("glmark2_common_config") {
defines = [ "GLMARK_DATA_PATH=\"${raw_glmark_data_path}\"" ]
include_dirs = [ "src/src" ]
cflags = []
if (is_clang) {
cflags += [ "-Wno-shadow" ]
}
if (is_win) {
include_dirs += [ "src/src/include" ]
@@ -49,7 +55,7 @@ config("glmark2_common_config") {
defines += [ "_USE_MATH_DEFINES" ]
if (!is_clang) {
cflags = [
cflags += [
# MSVC warns about the copyright character being illegal.
"/wd4828",