summaryrefslogtreecommitdiff
path: root/gfx/angle/src/tests/gl_tests/BlendMinMaxTest.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'gfx/angle/src/tests/gl_tests/BlendMinMaxTest.cpp')
-rwxr-xr-xgfx/angle/src/tests/gl_tests/BlendMinMaxTest.cpp79
1 files changed, 26 insertions, 53 deletions
diff --git a/gfx/angle/src/tests/gl_tests/BlendMinMaxTest.cpp b/gfx/angle/src/tests/gl_tests/BlendMinMaxTest.cpp
index 39f5251e56..8ccaf92744 100755
--- a/gfx/angle/src/tests/gl_tests/BlendMinMaxTest.cpp
+++ b/gfx/angle/src/tests/gl_tests/BlendMinMaxTest.cpp
@@ -32,12 +32,13 @@ class BlendMinMaxTest : public ANGLETest
float values[4];
};
- static float getExpected(bool blendMin, float curColor, float prevColor)
+ static GLubyte getExpected(bool blendMin, float curColor, GLubyte prevColor)
{
- return blendMin ? std::min(curColor, prevColor) : std::max(curColor, prevColor);
+ GLubyte curAsUbyte = static_cast<GLubyte>((curColor * std::numeric_limits<GLubyte>::max()) + 0.5f);
+ return blendMin ? std::min<GLubyte>(curAsUbyte, prevColor) : std::max<GLubyte>(curAsUbyte, prevColor);
}
- void runTest(GLenum colorFormat, GLenum type)
+ void runTest(GLenum colorFormat)
{
if (getClientMajorVersion() < 3 && !extensionEnabled("GL_EXT_blend_minmax"))
{
@@ -54,26 +55,17 @@ class BlendMinMaxTest : public ANGLETest
SetUpFramebuffer(colorFormat);
- int minValue = 0;
- int maxValue = 1;
- if (type == GL_FLOAT)
- {
- minValue = -1024;
- maxValue = 1024;
- }
-
- const size_t colorCount = 128;
+ const size_t colorCount = 1024;
Color colors[colorCount];
for (size_t i = 0; i < colorCount; i++)
{
for (size_t j = 0; j < 4; j++)
{
- colors[i].values[j] =
- static_cast<float>(minValue + (rand() % (maxValue - minValue)));
+ colors[i].values[j] = (rand() % 255) / 255.0f;
}
}
- float prevColor[4];
+ GLubyte prevColor[4];
for (size_t i = 0; i < colorCount; i++)
{
const Color &color = colors[i];
@@ -85,37 +77,16 @@ class BlendMinMaxTest : public ANGLETest
drawQuad(mProgram, "aPosition", 0.5f);
- float pixel[4];
- if (type == GL_UNSIGNED_BYTE)
- {
- GLubyte ubytePixel[4];
- glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, ubytePixel);
- for (size_t componentIdx = 0; componentIdx < ArraySize(pixel); componentIdx++)
- {
- pixel[componentIdx] = ubytePixel[componentIdx] / 255.0f;
- }
- }
- else if (type == GL_FLOAT)
- {
- glReadPixels(0, 0, 1, 1, GL_RGBA, GL_FLOAT, pixel);
- }
- else
- {
- FAIL() << "Unexpected pixel type";
- }
-
if (i > 0)
{
- const float errorRange = 1.0f / 255.0f;
- for (size_t componentIdx = 0; componentIdx < ArraySize(pixel); componentIdx++)
- {
- EXPECT_NEAR(
- getExpected(blendMin, color.values[componentIdx], prevColor[componentIdx]),
- pixel[componentIdx], errorRange);
- }
+ EXPECT_PIXEL_EQ(0, 0,
+ getExpected(blendMin, color.values[0], prevColor[0]),
+ getExpected(blendMin, color.values[1], prevColor[1]),
+ getExpected(blendMin, color.values[2], prevColor[2]),
+ getExpected(blendMin, color.values[3], prevColor[3]));
}
- memcpy(prevColor, pixel, sizeof(pixel));
+ glReadPixels(0, 0, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, prevColor);
}
}
@@ -171,9 +142,6 @@ class BlendMinMaxTest : public ANGLETest
glRenderbufferStorage(GL_RENDERBUFFER, colorFormat, getWindowWidth(), getWindowHeight());
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mColorRenderbuffer);
- glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
- glClear(GL_COLOR_BUFFER_BIT);
-
ASSERT_GL_NO_ERROR();
}
@@ -195,10 +163,10 @@ class BlendMinMaxTest : public ANGLETest
TEST_P(BlendMinMaxTest, RGBA8)
{
- runTest(GL_RGBA8, GL_UNSIGNED_BYTE);
+ runTest(GL_RGBA8);
}
-TEST_P(BlendMinMaxTest, RGBA32F)
+TEST_P(BlendMinMaxTest, RGBA32f)
{
if (getClientMajorVersion() < 3 || !extensionEnabled("GL_EXT_color_buffer_float"))
{
@@ -221,7 +189,7 @@ TEST_P(BlendMinMaxTest, RGBA32F)
return;
}
- runTest(GL_RGBA32F, GL_FLOAT);
+ runTest(GL_RGBA32F);
}
TEST_P(BlendMinMaxTest, RGBA16F)
@@ -240,16 +208,21 @@ TEST_P(BlendMinMaxTest, RGBA16F)
return;
}
- runTest(GL_RGBA16F, GL_FLOAT);
+ // TODO(geofflang): This fails because readpixels with UNSIGNED_BYTE/RGBA does not work with
+ // half float buffers (http://anglebug.com/1288)
+ if (GetParam().getRenderer() == EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE)
+ {
+ std::cout << "Test skipped on OpenGL ES targets." << std::endl;
+ return;
+ }
+
+ runTest(GL_RGBA16F);
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(BlendMinMaxTest,
ES2_D3D9(),
ES2_D3D11(),
- ES3_D3D11(),
ES2_D3D11_FL9_3(),
ES2_OPENGL(),
- ES3_OPENGL(),
- ES2_OPENGLES(),
- ES3_OPENGLES());
+ ES2_OPENGLES());