Fix C4434 warnings about 32-bit shift assigned to 64-bits
VS 2015 has a new or louder warning about 32-bit shifts that are then
assigned to a 64-bit target. This code triggers it:
int64_t size = 1 << shift_amount;
Because the '1' being shifted is a 32-bit int the result of the shift
will be a 32-bit result, so assigning it to a 64-bit variable is just
misleading.
In other cases the destination is a size_t which means that the warning
only shows up on 64-bit builds. However in this case the size_t was
later cast to a 32-bit type, so the warnings can be suppressed by
selecting more natural types and *deleting* some casts. The two warnings
were:
C4334: '<<': result of 32-bit shift implicitly converted to 64 bits
third_party\angle\src\tests\gl_tests\framebufferrendermipmaptest.cpp(90)
third_party\angle\src\tests\gl_tests\framebufferrendermipmaptest.cpp(156)
BUG=593448
Change-Id: Ice9f67096b155fbb5fa3247ad04ac41acffa36a5
Reviewed-on: https://chromium-review.googlesource.com/336332
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/tests/gl_tests/FramebufferRenderMipmapTest.cpp b/src/tests/gl_tests/FramebufferRenderMipmapTest.cpp
index 5269a4d..52a1e0f 100644
--- a/src/tests/gl_tests/FramebufferRenderMipmapTest.cpp
+++ b/src/tests/gl_tests/FramebufferRenderMipmapTest.cpp
@@ -84,12 +84,11 @@
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
- const size_t levels = 5;
- for (size_t i = 0; i < levels; i++)
+ const GLint levels = 5;
+ for (GLint i = 0; i < levels; i++)
{
- size_t size = 1 << ((levels - 1) - i);
- glTexImage2D(GL_TEXTURE_2D, static_cast<GLint>(i), GL_RGBA, static_cast<GLsizei>(size),
- static_cast<GLsizei>(size), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GLsizei size = 1 << ((levels - 1) - i);
+ glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
}
EXPECT_GL_NO_ERROR();
@@ -99,10 +98,9 @@
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
EXPECT_GL_NO_ERROR();
- for (size_t i = 0; i < levels; i++)
+ for (GLint i = 0; i < levels; i++)
{
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex,
- static_cast<GLint>(i));
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
if (i > 0 && !renderToMipmapSupported)
{
@@ -145,17 +143,16 @@
1.0f, 0.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
};
- const size_t testLevels = ArraySize(levelColors) / 4;
+ const GLint testLevels = static_cast<GLint>(ArraySize(levelColors) / 4);
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
- for (size_t i = 0; i < testLevels; i++)
+ for (GLint i = 0; i < testLevels; i++)
{
- size_t size = 1 << ((testLevels - 1) - i);
- glTexImage2D(GL_TEXTURE_2D, static_cast<GLint>(i), GL_RGBA, static_cast<GLsizei>(size),
- static_cast<GLsizei>(size), 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
+ GLsizei size = 1 << ((testLevels - 1) - i);
+ glTexImage2D(GL_TEXTURE_2D, i, GL_RGBA, size, size, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
}
EXPECT_GL_NO_ERROR();
@@ -166,10 +163,9 @@
EXPECT_GL_NO_ERROR();
// Render to the levels of the texture with different colors
- for (size_t i = 0; i < testLevels; i++)
+ for (GLint i = 0; i < testLevels; i++)
{
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex,
- static_cast<GLint>(i));
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
EXPECT_GL_NO_ERROR();
glUseProgram(mProgram);
@@ -180,10 +176,9 @@
}
// Test that the levels of the texture are correct
- for (size_t i = 0; i < testLevels; i++)
+ for (GLint i = 0; i < testLevels; i++)
{
- glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex,
- static_cast<GLint>(i));
+ glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
EXPECT_GL_NO_ERROR();
const GLfloat *color = levelColors + (i * 4);