Commit 6c56c579 by Brandon Schade Committed by Commit Bot

Add Android boot animation and rounding error test

This introduces an end2end test that makes the same GLES1 calls as Android's default boot animation. The test uses images of much smaller sizes, but we do the same thing with the images as the original code (it uses one image as a mask and moves the other along behind it). The original default boot animation code can be found here: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/cmds/bootanimation/BootAnimation.cpp#422 This change also implements glTexParameterx since the default boot animation requires it. This function is part of OES_FIXED_POINT. This also includes a test to check for int to floating point cast errors when using GL_TEXTURE_CROP_RECT_OES. Tests: angle_end2end_tests --gtest_filter=*DefaultBootAnimation* angle_end2end_tests --gtest_filter=*TextureParameterTest.IntConversionsAndIntBounds* Bug: angleproject:3644 Change-Id: Ib7e99c9dc1c001c71543d03ea4dd76082192f6a7 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2053506 Commit-Queue: Brandon Schade <b.schade@samsung.com> Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarTobin Ehlis <tobine@google.com>
parent fb551728
...@@ -555,12 +555,14 @@ void Context::texEnvxv(TextureEnvTarget target, TextureEnvParameter pname, const ...@@ -555,12 +555,14 @@ void Context::texEnvxv(TextureEnvTarget target, TextureEnvParameter pname, const
void Context::texParameterx(TextureType target, GLenum pname, GLfixed param) void Context::texParameterx(TextureType target, GLenum pname, GLfixed param)
{ {
UNIMPLEMENTED(); Texture *const texture = getTextureByType(target);
SetTexParameterx(this, texture, pname, param);
} }
void Context::texParameterxv(TextureType target, GLenum pname, const GLfixed *params) void Context::texParameterxv(TextureType target, GLenum pname, const GLfixed *params)
{ {
UNIMPLEMENTED(); Texture *const texture = getTextureByType(target);
SetTexParameterxv(this, texture, pname, params);
} }
void Context::translatef(float x, float y, float z) void Context::translatef(float x, float y, float z)
......
...@@ -329,7 +329,23 @@ void QueryTexParameterBase(const Context *context, ...@@ -329,7 +329,23 @@ void QueryTexParameterBase(const Context *context,
} }
} }
template <bool isPureInteger, typename ParamType> // this function is needed to handle OES_FIXED_POINT.
// Some pname values can take in GLfixed values and may need to be converted
template <bool isGLfixed, typename ReturnType, typename ParamType>
ReturnType ConvertTexParam(GLenum pname, const ParamType param)
{
if (isGLfixed)
{
return CastQueryValueTo<ReturnType>(pname,
ConvertFixedToFloat(static_cast<GLfixed>(param)));
}
else
{
return CastQueryValueTo<ReturnType>(pname, param);
}
}
template <bool isPureInteger, bool isGLfixed, typename ParamType>
void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const ParamType *params) void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const ParamType *params)
{ {
ASSERT(texture != nullptr); ASSERT(texture != nullptr);
...@@ -355,7 +371,8 @@ void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const ...@@ -355,7 +371,8 @@ void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const
texture->setUsage(context, ConvertToGLenum(pname, params[0])); texture->setUsage(context, ConvertToGLenum(pname, params[0]));
break; break;
case GL_TEXTURE_MAX_ANISOTROPY_EXT: case GL_TEXTURE_MAX_ANISOTROPY_EXT:
texture->setMaxAnisotropy(context, CastQueryValueTo<GLfloat>(pname, params[0])); texture->setMaxAnisotropy(context,
ConvertTexParam<isGLfixed, GLfloat>(pname, params[0]));
break; break;
case GL_TEXTURE_COMPARE_MODE: case GL_TEXTURE_COMPARE_MODE:
texture->setCompareMode(context, ConvertToGLenum(pname, params[0])); texture->setCompareMode(context, ConvertToGLenum(pname, params[0]));
...@@ -398,10 +415,10 @@ void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const ...@@ -398,10 +415,10 @@ void SetTexParameterBase(Context *context, Texture *texture, GLenum pname, const
texture->setSRGBDecode(context, ConvertToGLenum(pname, params[0])); texture->setSRGBDecode(context, ConvertToGLenum(pname, params[0]));
break; break;
case GL_TEXTURE_CROP_RECT_OES: case GL_TEXTURE_CROP_RECT_OES:
texture->setCrop(gl::Rectangle(CastQueryValueTo<GLint>(pname, params[0]), texture->setCrop(gl::Rectangle(ConvertTexParam<isGLfixed, GLint>(pname, params[0]),
CastQueryValueTo<GLint>(pname, params[1]), ConvertTexParam<isGLfixed, GLint>(pname, params[1]),
CastQueryValueTo<GLint>(pname, params[2]), ConvertTexParam<isGLfixed, GLint>(pname, params[2]),
CastQueryValueTo<GLint>(pname, params[3]))); ConvertTexParam<isGLfixed, GLint>(pname, params[3])));
break; break;
case GL_GENERATE_MIPMAP: case GL_GENERATE_MIPMAP:
texture->setGenerateMipmapHint(ConvertToGLenum(params[0])); texture->setGenerateMipmapHint(ConvertToGLenum(params[0]));
...@@ -1609,34 +1626,44 @@ angle::Result QuerySynciv(const Context *context, ...@@ -1609,34 +1626,44 @@ angle::Result QuerySynciv(const Context *context,
return angle::Result::Continue; return angle::Result::Continue;
} }
void SetTexParameterx(Context *context, Texture *texture, GLenum pname, GLfixed param)
{
SetTexParameterBase<false, true>(context, texture, pname, &param);
}
void SetTexParameterxv(Context *context, Texture *texture, GLenum pname, const GLfixed *params)
{
SetTexParameterBase<false, true>(context, texture, pname, params);
}
void SetTexParameterf(Context *context, Texture *texture, GLenum pname, GLfloat param) void SetTexParameterf(Context *context, Texture *texture, GLenum pname, GLfloat param)
{ {
SetTexParameterBase<false>(context, texture, pname, &param); SetTexParameterBase<false, false>(context, texture, pname, &param);
} }
void SetTexParameterfv(Context *context, Texture *texture, GLenum pname, const GLfloat *params) void SetTexParameterfv(Context *context, Texture *texture, GLenum pname, const GLfloat *params)
{ {
SetTexParameterBase<false>(context, texture, pname, params); SetTexParameterBase<false, false>(context, texture, pname, params);
} }
void SetTexParameteri(Context *context, Texture *texture, GLenum pname, GLint param) void SetTexParameteri(Context *context, Texture *texture, GLenum pname, GLint param)
{ {
SetTexParameterBase<false>(context, texture, pname, &param); SetTexParameterBase<false, false>(context, texture, pname, &param);
} }
void SetTexParameteriv(Context *context, Texture *texture, GLenum pname, const GLint *params) void SetTexParameteriv(Context *context, Texture *texture, GLenum pname, const GLint *params)
{ {
SetTexParameterBase<false>(context, texture, pname, params); SetTexParameterBase<false, false>(context, texture, pname, params);
} }
void SetTexParameterIiv(Context *context, Texture *texture, GLenum pname, const GLint *params) void SetTexParameterIiv(Context *context, Texture *texture, GLenum pname, const GLint *params)
{ {
SetTexParameterBase<true>(context, texture, pname, params); SetTexParameterBase<true, false>(context, texture, pname, params);
} }
void SetTexParameterIuiv(Context *context, Texture *texture, GLenum pname, const GLuint *params) void SetTexParameterIuiv(Context *context, Texture *texture, GLenum pname, const GLuint *params)
{ {
SetTexParameterBase<true>(context, texture, pname, params); SetTexParameterBase<true, false>(context, texture, pname, params);
} }
void SetSamplerParameterf(Context *context, Sampler *sampler, GLenum pname, GLfloat param) void SetSamplerParameterf(Context *context, Sampler *sampler, GLenum pname, GLfloat param)
......
...@@ -130,6 +130,8 @@ void SetTexParameteri(Context *context, Texture *texture, GLenum pname, GLint pa ...@@ -130,6 +130,8 @@ void SetTexParameteri(Context *context, Texture *texture, GLenum pname, GLint pa
void SetTexParameteriv(Context *context, Texture *texture, GLenum pname, const GLint *params); void SetTexParameteriv(Context *context, Texture *texture, GLenum pname, const GLint *params);
void SetTexParameterIiv(Context *context, Texture *texture, GLenum pname, const GLint *params); void SetTexParameterIiv(Context *context, Texture *texture, GLenum pname, const GLint *params);
void SetTexParameterIuiv(Context *context, Texture *texture, GLenum pname, const GLuint *params); void SetTexParameterIuiv(Context *context, Texture *texture, GLenum pname, const GLuint *params);
void SetTexParameterx(Context *context, Texture *texture, GLenum pname, GLfixed param);
void SetTexParameterxv(Context *context, Texture *texture, GLenum pname, const GLfixed *params);
void SetSamplerParameterf(Context *context, Sampler *sampler, GLenum pname, GLfloat param); void SetSamplerParameterf(Context *context, Sampler *sampler, GLenum pname, GLfloat param);
void SetSamplerParameterfv(Context *context, Sampler *sampler, GLenum pname, const GLfloat *params); void SetSamplerParameterfv(Context *context, Sampler *sampler, GLenum pname, const GLfloat *params);
......
...@@ -1343,11 +1343,33 @@ bool ValidateTexEnvxv(const Context *context, ...@@ -1343,11 +1343,33 @@ bool ValidateTexEnvxv(const Context *context,
return ValidateTexEnvCommon(context, target, pname, paramsf); return ValidateTexEnvCommon(context, target, pname, paramsf);
} }
bool ValidateTexParameterBaseForGLfixed(const Context *context,
TextureType target,
GLenum pname,
GLsizei bufSize,
bool vectorParams,
const GLfixed *params)
{
// Convert GLfixed parameter for GL_TEXTURE_MAX_ANISOTROPY_EXT independently
// since it compares against 1 and maxTextureAnisotropy instead of just 0
// (other values are fine to leave unconverted since they only check positive or negative or
// are used as enums)
GLfloat paramValue;
if (pname == GL_TEXTURE_MAX_ANISOTROPY_EXT)
{
paramValue = ConvertFixedToFloat(static_cast<GLfixed>(params[0]));
}
else
{
paramValue = static_cast<GLfloat>(params[0]);
}
return ValidateTexParameterBase(context, target, pname, bufSize, vectorParams, &paramValue);
}
bool ValidateTexParameterx(const Context *context, TextureType target, GLenum pname, GLfixed param) bool ValidateTexParameterx(const Context *context, TextureType target, GLenum pname, GLfixed param)
{ {
ANGLE_VALIDATE_IS_GLES1(context); ANGLE_VALIDATE_IS_GLES1(context);
GLfloat paramf = ConvertFixedToFloat(param); return ValidateTexParameterBaseForGLfixed(context, target, pname, -1, false, &param);
return ValidateTexParameterBase(context, target, pname, -1, false, &paramf);
} }
bool ValidateTexParameterxv(const Context *context, bool ValidateTexParameterxv(const Context *context,
...@@ -1356,12 +1378,7 @@ bool ValidateTexParameterxv(const Context *context, ...@@ -1356,12 +1378,7 @@ bool ValidateTexParameterxv(const Context *context,
const GLfixed *params) const GLfixed *params)
{ {
ANGLE_VALIDATE_IS_GLES1(context); ANGLE_VALIDATE_IS_GLES1(context);
GLfloat paramsf[4] = {}; return ValidateTexParameterBaseForGLfixed(context, target, pname, -1, true, params);
for (unsigned int i = 0; i < GetTexParameterCount(pname); i++)
{
paramsf[i] = ConvertFixedToFloat(params[i]);
}
return ValidateTexParameterBase(context, target, pname, -1, true, paramsf);
} }
bool ValidateTranslatef(const Context *context, GLfloat x, GLfloat y, GLfloat z) bool ValidateTranslatef(const Context *context, GLfloat x, GLfloat y, GLfloat z)
......
...@@ -130,6 +130,7 @@ angle_end2end_tests_sources = [ ...@@ -130,6 +130,7 @@ angle_end2end_tests_sources = [
"gl_tests/WebGLReadOutsideFramebufferTest.cpp", "gl_tests/WebGLReadOutsideFramebufferTest.cpp",
"gl_tests/gles1/AlphaFuncTest.cpp", "gl_tests/gles1/AlphaFuncTest.cpp",
"gl_tests/gles1/BasicDrawTest.cpp", "gl_tests/gles1/BasicDrawTest.cpp",
"gl_tests/gles1/BootAnimationTest.cpp",
"gl_tests/gles1/ClientActiveTextureTest.cpp", "gl_tests/gles1/ClientActiveTextureTest.cpp",
"gl_tests/gles1/ClientStateEnable.cpp", "gl_tests/gles1/ClientStateEnable.cpp",
"gl_tests/gles1/ClipPlaneTest.cpp", "gl_tests/gles1/ClipPlaneTest.cpp",
......
...@@ -111,4 +111,19 @@ TEST_P(TextureParameterTest, Set) ...@@ -111,4 +111,19 @@ TEST_P(TextureParameterTest, Set)
} }
} }
// Make sure we don't improperly cast an int into a float in ANGLE's internals
TEST_P(TextureParameterTest, IntConversionsAndIntBounds)
{
// Test integers that can't be represented as floats, INT_MIN, and INT_MAX
constexpr GLint kFirstIntThatCannotBeFloat = 16777217;
constexpr unsigned int kParameterLength = 4;
constexpr std::array<GLint, kParameterLength> crop = {
-kFirstIntThatCannotBeFloat, kFirstIntThatCannotBeFloat, std::numeric_limits<GLint>::max(),
std::numeric_limits<GLint>::min()};
glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, crop.data());
std::array<GLint, kParameterLength> cropStored = {0};
glGetTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_CROP_RECT_OES, cropStored.data());
ASSERT_EQ(crop, cropStored);
}
ANGLE_INSTANTIATE_TEST_ES1(TextureParameterTest); ANGLE_INSTANTIATE_TEST_ES1(TextureParameterTest);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment