Hash :
e2fcf5c3
Author :
Date :
2016-03-30T11:27:12
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>
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 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
//
// Copyright 2015 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
#include "test_utils/ANGLETest.h"
using namespace angle;
class FramebufferRenderMipmapTest : public ANGLETest
{
protected:
FramebufferRenderMipmapTest()
{
setWindowWidth(256);
setWindowHeight(256);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
virtual void SetUp()
{
ANGLETest::SetUp();
const std::string vsSource = SHADER_SOURCE
(
attribute highp vec4 position;
void main(void)
{
gl_Position = position;
}
);
const std::string fsSource = SHADER_SOURCE
(
uniform highp vec4 color;
void main(void)
{
gl_FragColor = color;
}
);
mProgram = CompileProgram(vsSource, fsSource);
if (mProgram == 0)
{
FAIL() << "shader compilation failed.";
}
mColorLocation = glGetUniformLocation(mProgram, "color");
glUseProgram(mProgram);
glClearColor(0, 0, 0, 0);
glClearDepthf(0.0);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
ASSERT_GL_NO_ERROR();
}
virtual void TearDown()
{
glDeleteProgram(mProgram);
ANGLETest::TearDown();
}
GLuint mProgram;
GLint mColorLocation;
};
// Validate that if we are in ES3 or GL_OES_fbo_render_mipmap exists, there are no validation errors
// when using a non-zero level in glFramebufferTexture2D.
TEST_P(FramebufferRenderMipmapTest, Validation)
{
bool renderToMipmapSupported = extensionEnabled("GL_OES_fbo_render_mipmap") || getClientVersion() > 2;
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
const GLint levels = 5;
for (GLint i = 0; i < levels; i++)
{
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();
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
EXPECT_GL_NO_ERROR();
for (GLint i = 0; i < levels; i++)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
if (i > 0 && !renderToMipmapSupported)
{
EXPECT_GL_ERROR(GL_INVALID_VALUE);
}
else
{
EXPECT_GL_NO_ERROR();
EXPECT_EQ(glCheckFramebufferStatus(GL_FRAMEBUFFER), GLenum(GL_FRAMEBUFFER_COMPLETE));
}
}
glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &tex);
}
// Render to various levels of a texture and check that they have the correct color data via ReadPixels
TEST_P(FramebufferRenderMipmapTest, RenderToMipmap)
{
// TODO(geofflang): Figure out why this is broken on Intel OpenGL
if (IsIntel() && getPlatformRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE)
{
std::cout << "Test skipped on Intel OpenGL." << std::endl;
return;
}
bool renderToMipmapSupported = extensionEnabled("GL_OES_fbo_render_mipmap") || getClientVersion() > 2;
if (!renderToMipmapSupported)
{
std::cout << "Test skipped because GL_OES_fbo_render_mipmap or ES3 is not available." << std::endl;
return;
}
const GLfloat levelColors[] =
{
1.0f, 0.0f, 0.0f, 1.0f,
0.0f, 1.0f, 0.0f, 1.0f,
0.0f, 0.0f, 1.0f, 1.0f,
1.0f, 1.0f, 0.0f, 1.0f,
1.0f, 0.0f, 1.0f, 1.0f,
0.0f, 1.0f, 1.0f, 1.0f,
};
const GLint testLevels = static_cast<GLint>(ArraySize(levelColors) / 4);
GLuint tex = 0;
glGenTextures(1, &tex);
glBindTexture(GL_TEXTURE_2D, tex);
for (GLint i = 0; i < testLevels; i++)
{
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();
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
EXPECT_GL_NO_ERROR();
// Render to the levels of the texture with different colors
for (GLint i = 0; i < testLevels; i++)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
EXPECT_GL_NO_ERROR();
glUseProgram(mProgram);
glUniform4fv(mColorLocation, 1, levelColors + (i * 4));
drawQuad(mProgram, "position", 0.5f);
EXPECT_GL_NO_ERROR();
}
// Test that the levels of the texture are correct
for (GLint i = 0; i < testLevels; i++)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tex, i);
EXPECT_GL_NO_ERROR();
const GLfloat *color = levelColors + (i * 4);
EXPECT_PIXEL_EQ(0, 0, color[0] * 255, color[1] * 255, color[2] * 255, color[3] * 255);
}
glDeleteFramebuffers(1, &fbo);
glDeleteTextures(1, &tex);
EXPECT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(FramebufferRenderMipmapTest,
ES2_D3D9(),
ES2_D3D11(),
ES3_D3D11(),
ES2_OPENGL(),
ES3_OPENGL(),
ES2_OPENGLES(),
ES3_OPENGLES());