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