Commit 2d5da029 by Jamie Madill Committed by Commit Bot

Minor angle_end2end_tests cleanups.

Minor refactoring and call consolidation. Was done while working on deferring clears in the Vulkan back-end. Bug: angleproject:4517 Change-Id: I60d80d4f9646c990c4cb8bbc349fc0051389bf02 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2151171 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent dc3477f3
......@@ -409,10 +409,10 @@ TEST_P(BlitFramebufferANGLETest, BlitColorToDefault)
glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 0, 255, 0, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 255, 0, 255);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() / 4, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, GLColor::green);
EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::green);
}
// Draw to system framebuffer, blit whole-buffer color to user-created framebuffer.
......@@ -633,10 +633,10 @@ TEST_P(BlitFramebufferANGLETest, BlitWithDepthUserToDefault)
glDisable(GL_DEPTH_TEST);
EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 255, 0, 0, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255);
EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 0, 0, 255, 255);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() / 4, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, GLColor::red);
EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::blue);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::blue);
}
// blit from system FBO to user-created framebuffer, with depth buffer.
......@@ -754,10 +754,10 @@ TEST_P(BlitFramebufferANGLETest, BlitPartialColor)
glBindFramebuffer(GL_FRAMEBUFFER, mOriginalFBO);
EXPECT_PIXEL_EQ(getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, 255, 255, 255, 255);
EXPECT_PIXEL_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 255, 255, 255);
EXPECT_PIXEL_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, 255, 0, 0, 255);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, getWindowHeight() / 4, GLColor::white);
EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, getWindowHeight() / 4, GLColor::white);
EXPECT_PIXEL_COLOR_EQ(3 * getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::white);
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 4, 3 * getWindowHeight() / 4, GLColor::red);
}
TEST_P(BlitFramebufferANGLETest, BlitDifferentSizes)
......@@ -831,15 +831,14 @@ TEST_P(BlitFramebufferANGLETest, BlitStencil)
{
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_ANGLE_framebuffer_blit"));
// TODO(jmadill): Figure out if we can fix this on D3D9.
// https://code.google.com/p/angleproject/issues/detail?id=2205
// http://anglebug.com/2205
ANGLE_SKIP_TEST_IF(IsIntel() && IsD3D9());
glBindFramebuffer(GL_FRAMEBUFFER, mUserFBO);
glClearColor(0.0, 1.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glClearStencil(0x0);
glClear(GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Scissor half the screen so we fill the stencil only halfway
glScissor(0, 0, getWindowWidth(), getWindowHeight() / 2);
......
......@@ -215,7 +215,7 @@ class MaskedScissoredClearTestBase
setConfigStencilBits(8);
}
void MaskedScissoredColorDepthStencilClear(
void maskedScissoredColorDepthStencilClear(
const MaskedScissoredClearVariationsTestParams &params);
bool mHasDepth = true;
......@@ -1268,7 +1268,7 @@ TEST_P(ClearTestES3, RepeatedClear)
ASSERT_GL_NO_ERROR();
}
void MaskedScissoredClearTestBase::MaskedScissoredColorDepthStencilClear(
void MaskedScissoredClearTestBase::maskedScissoredColorDepthStencilClear(
const MaskedScissoredClearVariationsTestParams &params)
{
// Flaky on Android Nexus 5x and Pixel 2, possible Qualcomm driver bug.
......@@ -1449,7 +1449,7 @@ void MaskedScissoredClearTestBase::MaskedScissoredColorDepthStencilClear(
// Tests combinations of color, depth, stencil clears with or without masks or scissor.
TEST_P(MaskedScissoredClearTest, Test)
{
MaskedScissoredColorDepthStencilClear(GetParam());
maskedScissoredColorDepthStencilClear(GetParam());
}
// Tests combinations of color, depth, stencil clears with or without masks or scissor.
......@@ -1483,7 +1483,7 @@ TEST_P(VulkanClearTest, Test)
bindColorStencilFBO();
}
MaskedScissoredColorDepthStencilClear(GetParam());
maskedScissoredColorDepthStencilClear(GetParam());
}
// Test that just clearing a nonexistent drawbuffer of the default framebuffer doesn't cause an
......
......@@ -12,6 +12,16 @@
using namespace angle;
struct ReadbackTestParam
{
GLuint attachment;
GLuint format;
GLuint type;
void *data;
int depthBits;
int stencilBits;
};
class DepthStencilFormatsTestBase : public ANGLETest
{
protected:
......@@ -160,6 +170,14 @@ void main()
glDeleteTextures(1, &mTexture);
}
bool hasReadDepthSupport() const { return IsGLExtensionEnabled("GL_NV_read_depth"); }
bool hasReadStencilSupport() const { return IsGLExtensionEnabled("GL_NV_read_stencil"); }
bool hasFloatDepthSupport() const { return IsGLExtensionEnabled("GL_NV_depth_buffer_float2"); }
void depthStencilReadbackCase(const ReadbackTestParam &type);
GLuint mProgram;
GLuint mTexture;
GLint mTextureUniformLocation;
......@@ -214,221 +232,216 @@ TEST_P(DepthStencilFormatsTest, PackedDepthStencil)
}
}
// This test will initialize a depth texture, clear it and read it back, if possible
TEST_P(DepthStencilFormatsTest, DepthStencilReadback)
void DepthStencilFormatsTestBase::depthStencilReadbackCase(const ReadbackTestParam &type)
{
bool shouldHaveReadDepthSupport = IsGLExtensionEnabled("GL_NV_read_depth");
bool shouldHaveReadStencilSupport = IsGLExtensionEnabled("GL_NV_read_stencil");
bool shouldHaveFloatDepthSupport = IsGLExtensionEnabled("GL_NV_depth_buffer_float2");
ANGLE_SKIP_TEST_IF(!IsGLExtensionEnabled("GL_OES_depth_texture"));
const int res = 2;
const int destRes = 4;
const bool hasFloatDepth = (type.type == GL_FLOAT);
ANGLE_SKIP_TEST_IF(hasFloatDepth && !hasFloatDepthSupport());
struct TypeInfo
{
GLuint attachment;
GLuint format;
GLuint type;
void *data;
int depthBits;
int stencilBits;
};
const bool hasStencil = (type.format != GL_DEPTH_COMPONENT);
GLuint fakeData[10] = {0};
const bool supportPackedDepthStencilFramebuffer = getClientMajorVersion() >= 3;
std::vector<TypeInfo> types = {
{GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, fakeData, 16, 0},
{GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, fakeData, 16, 0},
{GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT, GL_FLOAT, fakeData, 32, 0},
{GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8_OES, fakeData, 24, 8},
};
const int res = 2;
const int destRes = 4;
for (const TypeInfo &type : types)
{
const bool hasFloatDepth = (type.type == GL_FLOAT);
if (hasFloatDepth && !shouldHaveFloatDepthSupport)
{
continue;
}
GLTexture tex;
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
const bool hasStencil = (type.format != GL_DEPTH_COMPONENT);
// test level > 0
glTexImage2D(GL_TEXTURE_2D, 1, type.format, 1, 1, 0, type.format, type.type, nullptr);
EXPECT_GL_NO_ERROR();
const bool supportPackedDepthStencilFramebuffer = getClientMajorVersion() >= 3;
// test with data
glTexImage2D(GL_TEXTURE_2D, 0, type.format, 1, 1, 0, type.format, type.type, type.data);
EXPECT_GL_NO_ERROR();
GLTexture tex;
glBindTexture(GL_TEXTURE_2D, tex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
// test real thing
glTexImage2D(GL_TEXTURE_2D, 0, type.format, res, res, 0, type.format, type.type, nullptr);
EXPECT_GL_NO_ERROR();
// test level > 0
glTexImage2D(GL_TEXTURE_2D, 1, type.format, 1, 1, 0, type.format, type.type, nullptr);
EXPECT_GL_NO_ERROR();
// test texSubImage2D
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, type.format, type.type, type.data);
EXPECT_GL_NO_ERROR();
// test with data
glTexImage2D(GL_TEXTURE_2D, 0, type.format, 1, 1, 0, type.format, type.type, type.data);
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
if (type.depthBits > 0 && type.stencilBits > 0 && !supportPackedDepthStencilFramebuffer)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex, 0);
EXPECT_GL_NO_ERROR();
// test real thing
glTexImage2D(GL_TEXTURE_2D, 0, type.format, res, res, 0, type.format, type.type, nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, tex, 0);
EXPECT_GL_NO_ERROR();
// test texSubImage2D
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 1, 1, type.format, type.type, type.data);
}
else
{
glFramebufferTexture2D(GL_FRAMEBUFFER, type.attachment, GL_TEXTURE_2D, tex, 0);
EXPECT_GL_NO_ERROR();
}
GLuint fbo = 0;
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
if (type.depthBits > 0 && type.stencilBits > 0 && !supportPackedDepthStencilFramebuffer)
{
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, tex, 0);
EXPECT_GL_NO_ERROR();
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, tex, 0);
EXPECT_GL_NO_ERROR();
}
else
{
glFramebufferTexture2D(GL_FRAMEBUFFER, type.attachment, GL_TEXTURE_2D, tex, 0);
EXPECT_GL_NO_ERROR();
}
// Ensure DEPTH_BITS returns >= 16 bits for UNSIGNED_SHORT and UNSIGNED_INT, >= 24
// UNSIGNED_INT_24_8_WEBGL. If there is stencil, ensure STENCIL_BITS reports >= 8 for
// UNSIGNED_INT_24_8_WEBGL.
GLint depthBits = 0;
glGetIntegerv(GL_DEPTH_BITS, &depthBits);
EXPECT_GE(depthBits, type.depthBits);
// Ensure DEPTH_BITS returns >= 16 bits for UNSIGNED_SHORT and UNSIGNED_INT, >= 24
// UNSIGNED_INT_24_8_WEBGL. If there is stencil, ensure STENCIL_BITS reports >= 8 for
// UNSIGNED_INT_24_8_WEBGL.
GLint stencilBits = 0;
glGetIntegerv(GL_STENCIL_BITS, &stencilBits);
EXPECT_GE(stencilBits, type.stencilBits);
GLint depthBits = 0;
glGetIntegerv(GL_DEPTH_BITS, &depthBits);
EXPECT_GE(depthBits, type.depthBits);
// TODO: remove this check if the spec is updated to require these combinations to work.
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
// try adding a color buffer.
GLuint colorTex = 0;
glGenTextures(1, &colorTex);
glBindTexture(GL_TEXTURE_2D, colorTex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, res, res, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTex, 0);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
}
GLint stencilBits = 0;
glGetIntegerv(GL_STENCIL_BITS, &stencilBits);
EXPECT_GE(stencilBits, type.stencilBits);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
// TODO: remove this check if the spec is updated to require these combinations to work.
if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE)
{
// try adding a color buffer.
GLuint colorTex = 0;
glGenTextures(1, &colorTex);
glBindTexture(GL_TEXTURE_2D, colorTex);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, res, res, 0, GL_RGBA, GL_UNSIGNED_BYTE,
nullptr);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTex,
0);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
}
// use the default texture to render with while we return to the depth texture.
glBindTexture(GL_TEXTURE_2D, 0);
EXPECT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
/* Setup 2x2 depth texture:
* 1 0.6 0.8
* |
* 0 0.2 0.4
* 0---1
*/
GLbitfield clearBits = GL_DEPTH_BUFFER_BIT;
if (hasStencil)
{
clearBits |= GL_STENCIL_BUFFER_BIT;
}
// use the default texture to render with while we return to the depth texture.
glBindTexture(GL_TEXTURE_2D, 0);
/* Setup 2x2 depth texture:
* 1 0.6 0.8
* |
* 0 0.2 0.4
* 0---1
*/
const GLfloat d00 = 0.2;
const GLfloat d01 = 0.4;
const GLfloat d10 = 0.6;
const GLfloat d11 = 0.8;
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, 1, 1);
glClearDepthf(d00);
glClear(GL_DEPTH_BUFFER_BIT);
if (hasStencil)
{
glClearStencil(1);
glClear(GL_STENCIL_BUFFER_BIT);
}
glScissor(1, 0, 1, 1);
glClearDepthf(d10);
glClear(GL_DEPTH_BUFFER_BIT);
if (hasStencil)
{
glClearStencil(2);
glClear(GL_STENCIL_BUFFER_BIT);
}
glScissor(0, 1, 1, 1);
glClearDepthf(d01);
glClear(GL_DEPTH_BUFFER_BIT);
if (hasStencil)
const GLfloat d00 = 0.2;
const GLfloat d01 = 0.4;
const GLfloat d10 = 0.6;
const GLfloat d11 = 0.8;
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, 1, 1);
glClearDepthf(d00);
glClearStencil(1);
glClear(clearBits);
glScissor(1, 0, 1, 1);
glClearDepthf(d10);
glClearStencil(2);
glClear(clearBits);
glScissor(0, 1, 1, 1);
glClearDepthf(d01);
glClearStencil(3);
glClear(clearBits);
glScissor(1, 1, 1, 1);
glClearDepthf(d11);
glClearStencil(4);
glClear(clearBits);
glDisable(GL_SCISSOR_TEST);
GLubyte actualPixels[destRes * destRes * 8];
glReadPixels(0, 0, destRes, destRes, GL_DEPTH_COMPONENT,
hasFloatDepth ? GL_FLOAT : GL_UNSIGNED_SHORT, actualPixels);
// NV_read_depth and NV_read_stencil do not support packed depth/stencil
if (hasReadDepthSupport() && type.format != GL_DEPTH_STENCIL)
{
EXPECT_GL_NO_ERROR();
if (hasFloatDepth)
{
glClearStencil(3);
glClear(GL_STENCIL_BUFFER_BIT);
constexpr float kEpsilon = 0.002f;
const float *pixels = reinterpret_cast<const float *>(actualPixels);
ASSERT_NEAR(pixels[0], d00, kEpsilon);
ASSERT_NEAR(pixels[0 + destRes], d01, kEpsilon);
ASSERT_NEAR(pixels[1], d10, kEpsilon);
ASSERT_NEAR(pixels[1 + destRes], d11, kEpsilon);
}
glScissor(1, 1, 1, 1);
glClearDepthf(d11);
glClear(GL_DEPTH_BUFFER_BIT);
if (hasStencil)
else
{
glClearStencil(4);
glClear(GL_STENCIL_BUFFER_BIT);
auto scale = [](float f) {
return static_cast<uint16_t>(
static_cast<float>(std::numeric_limits<uint16_t>::max()) * f);
};
constexpr unsigned short kEpsilon = 2;
const unsigned short *pixels = reinterpret_cast<const unsigned short *>(actualPixels);
ASSERT_NEAR(pixels[0], scale(d00), kEpsilon);
ASSERT_NEAR(pixels[0 + destRes], scale(d01), kEpsilon);
ASSERT_NEAR(pixels[1], scale(d10), kEpsilon);
ASSERT_NEAR(pixels[1 + destRes], scale(d11), kEpsilon);
}
glDisable(GL_SCISSOR_TEST);
GLubyte actualPixels[destRes * destRes * 8];
glReadPixels(0, 0, destRes, destRes, GL_DEPTH_COMPONENT,
hasFloatDepth ? GL_FLOAT : GL_UNSIGNED_SHORT, actualPixels);
// NV_read_depth and NV_read_stencil do not support packed depth/stencil
if (shouldHaveReadDepthSupport && type.format != GL_DEPTH_STENCIL)
}
else
{
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
if (hasStencil)
{
glReadPixels(0, 0, destRes, destRes, GL_STENCIL_INDEX_OES, GL_UNSIGNED_BYTE, actualPixels);
if (hasReadStencilSupport())
{
EXPECT_GL_NO_ERROR();
if (hasFloatDepth)
{
const float eps = 0.002f;
const float minValues[4] = {0.2f - eps, 0.4f - eps, 0.6f - eps, 0.8f - eps};
const float maxValues[4] = {0.2f + eps, 0.4f + eps, 0.6f + eps, 0.8f + eps};
const float *pixels = reinterpret_cast<const float *>(actualPixels);
ASSERT_TRUE((pixels[0] >= minValues[0]) && (pixels[0] <= maxValues[0]) &&
(pixels[0 + destRes] >= minValues[1]) &&
(pixels[0 + destRes] <= maxValues[1]) && (pixels[1] >= minValues[2]) &&
(pixels[1] <= maxValues[2]) && (pixels[1 + destRes] >= minValues[3]) &&
(pixels[1 + destRes] <= maxValues[3]));
}
else
{
const unsigned short minValues[4] = {13106, 26213, 39320, 52427};
const unsigned short maxValues[4] = {13109, 26216, 39323, 52430};
const unsigned short *pixels =
reinterpret_cast<const unsigned short *>(actualPixels);
ASSERT_TRUE((pixels[0] >= minValues[0]) && (pixels[0] <= maxValues[0]) &&
(pixels[0 + destRes] >= minValues[1]) &&
(pixels[0 + destRes] <= maxValues[1]) && (pixels[1] >= minValues[2]) &&
(pixels[1] <= maxValues[2]) && (pixels[1 + destRes] >= minValues[3]) &&
(pixels[1 + destRes] <= maxValues[3]));
}
ASSERT_TRUE((actualPixels[0] == 1) && (actualPixels[1] == 2) &&
(actualPixels[0 + destRes] == 3) && (actualPixels[1 + destRes] = 4));
}
else
{
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
if (hasStencil)
{
glReadPixels(0, 0, destRes, destRes, GL_STENCIL_INDEX_OES, GL_UNSIGNED_BYTE,
actualPixels);
if (shouldHaveReadStencilSupport)
{
EXPECT_GL_NO_ERROR();
ASSERT_TRUE((actualPixels[0] == 1) && (actualPixels[1] == 2) &&
(actualPixels[0 + destRes] == 3) && (actualPixels[1 + destRes] = 4));
}
else
{
EXPECT_GL_ERROR(GL_INVALID_OPERATION);
}
}
}
}
// This test will initialize a depth texture, clear it and read it back, if possible
TEST_P(DepthStencilFormatsTest, DepthStencilReadback_UShort)
{
GLuint fakeData[10] = {0};
ReadbackTestParam type = {
GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_SHORT, fakeData, 16, 0};
depthStencilReadbackCase(type);
}
// This test will initialize a depth texture, clear it and read it back, if possible
TEST_P(DepthStencilFormatsTest, DepthStencilReadback_UInt)
{
// http://anglebug.com/4573
ANGLE_SKIP_TEST_IF(IsWindows() && IsVulkan());
GLuint fakeData[10] = {0};
ReadbackTestParam type = {
GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT, GL_UNSIGNED_INT, fakeData, 16, 0};
depthStencilReadbackCase(type);
}
// This test will initialize a depth texture, clear it and read it back, if possible
TEST_P(DepthStencilFormatsTest, DepthStencilReadback_Float)
{
GLuint fakeData[10] = {0};
ReadbackTestParam type = {GL_DEPTH_ATTACHMENT, GL_DEPTH_COMPONENT, GL_FLOAT, fakeData, 32, 0};
depthStencilReadbackCase(type);
}
// This test will initialize a depth texture, clear it and read it back, if possible
TEST_P(DepthStencilFormatsTest, DepthStencilReadback_DepthStencil)
{
GLuint fakeData[10] = {0};
ReadbackTestParam type = {
GL_DEPTH_STENCIL_ATTACHMENT, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8_OES, fakeData, 24, 8};
depthStencilReadbackCase(type);
}
// This test will initialize a depth texture and then render with it and verify
// pixel correctness.
// This is modeled after webgl-depth-texture.html
......
......@@ -372,7 +372,7 @@ TEST_P(SimpleOperationTest, DrawLine)
ASSERT_GL_NO_ERROR();
for (auto x = 0; x < getWindowWidth(); x++)
for (int x = 0; x < getWindowWidth(); x++)
{
EXPECT_PIXEL_COLOR_EQ(x, x, GLColor::green);
}
......
......@@ -730,29 +730,26 @@ TEST_P(StateChangeRenderTest, RecreateRenderbuffer)
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, mRenderbuffer);
// Explictly check FBO status sync in some versions of ANGLE no_error skips FBO checks.
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Draw with red to the FBO.
GLColor red(255, 0, 0, 255);
setUniformColor(red);
setUniformColor(GLColor::red);
drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, red);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::red);
// Recreate the renderbuffer and clear to green.
glRenderbufferStorage(GL_RENDERBUFFER, GL_RGBA8, 32, 32);
glClearColor(0.0f, 1.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
GLColor green(0, 255, 0, 255);
EXPECT_PIXEL_COLOR_EQ(0, 0, green);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::green);
// Explictly check FBO status sync in some versions of ANGLE no_error skips FBO checks.
ASSERT_GLENUM_EQ(GL_FRAMEBUFFER_COMPLETE, glCheckFramebufferStatus(GL_FRAMEBUFFER));
ASSERT_GL_FRAMEBUFFER_COMPLETE(GL_FRAMEBUFFER);
// Verify drawing blue gives blue. This covers the FBO sync with D3D dirty bits.
GLColor blue(0, 0, 255, 255);
setUniformColor(blue);
setUniformColor(GLColor::blue);
drawQuad(mProgram, "position", 0.5f);
EXPECT_PIXEL_COLOR_EQ(0, 0, blue);
EXPECT_PIXEL_COLOR_EQ(0, 0, GLColor::blue);
EXPECT_GL_NO_ERROR();
}
......
......@@ -4380,13 +4380,13 @@ TEST_P(WebGLCompatibilityTest, DrawBuffers)
GLFramebuffer readFBO;
glBindFramebuffer(GL_FRAMEBUFFER, readFBO);
for (int i = 0; i < 4; ++i)
for (int attachmentIndex = 0; attachmentIndex < 4; ++attachmentIndex)
{
if (mask & (1 << i))
if (mask & (1 << attachmentIndex))
{
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER,
renderbuffers[i]);
EXPECT_PIXEL_COLOR_EQ(0, 0, color);
renderbuffers[attachmentIndex]);
EXPECT_PIXEL_COLOR_EQ(0, 0, color) << "attachment " << attachmentIndex;
}
}
ASSERT_GL_NO_ERROR();
......
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